diff --git a/tasks/format-code-task-000001/environment/Dockerfile b/tasks/format-code-task-000001/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..39ea615e990c070c5336b6fe8fe189e24859b847 --- /dev/null +++ b/tasks/format-code-task-000001/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f0701aeb7d0813fe06c2b72bb6b558df48cefb21be6a283fbb0250b317b45e12 diff --git a/tasks/format-code-task-000001/environment/setup/files/blocklist b/tasks/format-code-task-000001/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000001/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000001/environment/setup/setup.sh b/tasks/format-code-task-000001/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000001/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000001/tests/test.patch b/tasks/format-code-task-000001/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..78f9a70b507372d2cf9ba368e249d3af96a55f3b --- /dev/null +++ b/tasks/format-code-task-000001/tests/test.patch @@ -0,0 +1,216 @@ +diff --git a/state/transition_recoverable_test.go b/state/transition_recoverable_test.go +new file mode 100644 +index 00000000..2a31e771 +--- /dev/null ++++ b/state/transition_recoverable_test.go +@@ -0,0 +1,114 @@ ++package state ++ ++import ( ++ "math/big" ++ "testing" ++ ++ "github.com/0xPolygon/polygon-sdk/chain" ++ "github.com/0xPolygon/polygon-sdk/state/runtime" ++ "github.com/0xPolygon/polygon-sdk/types" ++ "github.com/hashicorp/go-hclog" ++ "github.com/stretchr/testify/assert" ++) ++ ++ ++ ++func newRecoverableTransition( ++ preState map[types.Address]*PreState, ++ blockGasLimit uint64, ++ remainingGas uint64, ++) *Transition { ++ return &Transition{ ++ logger: hclog.NewNullLogger(), ++ r: &Executor{config: &chain.Params{}}, ++ state: newTestTxn(preState), ++ config: chain.ForksInTime{}, ++ ctx: runtime.TxContext{GasLimit: int64(blockGasLimit)}, ++ gasPool: remainingGas, ++ } ++} ++ ++func TestWriteTransactionRecoverability(t *testing.T) { ++ sender := types.StringToAddress("1") ++ receiver := types.StringToAddress("2") ++ ++ testTable := []struct { ++ name string ++ preState map[types.Address]*PreState ++ blockGasLimit uint64 ++ remainingGas uint64 ++ txGas uint64 ++ txGasPrice int64 ++ txNonce uint64 ++ isRecoverable bool ++ }{ ++ { ++ name: "gas exceeding the block gas limit is non-recoverable", ++ preState: map[types.Address]*PreState{ ++ sender: {Nonce: 0, Balance: 100000000000}, ++ }, ++ blockGasLimit: 8000000, ++ remainingGas: 8000000, ++ txGas: 10000000, ++ txGasPrice: 1, ++ txNonce: 0, ++ isRecoverable: false, ++ }, ++ { ++ name: "fits the block but not the remaining gas is recoverable", ++ preState: map[types.Address]*PreState{ ++ sender: {Nonce: 0, Balance: 100000000000}, ++ }, ++ blockGasLimit: 8000000, ++ remainingGas: 1000000, ++ txGas: 5000000, ++ txGasPrice: 1, ++ txNonce: 0, ++ isRecoverable: true, ++ }, ++ { ++ name: "incorrect nonce is recoverable", ++ preState: map[types.Address]*PreState{ ++ sender: {Nonce: 5, Balance: 100000000000}, ++ }, ++ blockGasLimit: 8000000, ++ remainingGas: 8000000, ++ txGas: 21000, ++ txGasPrice: 1, ++ txNonce: 0, ++ isRecoverable: true, ++ }, ++ { ++ name: "not enough funds to cover the gas cost is recoverable", ++ preState: map[types.Address]*PreState{ ++ sender: {Nonce: 0, Balance: 10}, ++ }, ++ blockGasLimit: 8000000, ++ remainingGas: 8000000, ++ txGas: 21000, ++ txGasPrice: 1000, ++ txNonce: 0, ++ isRecoverable: true, ++ }, ++ } ++ ++ for _, tc := range testTable { ++ t.Run(tc.name, func(t *testing.T) { ++ transition := newRecoverableTransition(tc.preState, tc.blockGasLimit, tc.remainingGas) ++ ++ txn := &types.Transaction{ ++ From: sender, ++ To: &receiver, ++ Nonce: tc.txNonce, ++ Gas: tc.txGas, ++ GasPrice: big.NewInt(tc.txGasPrice), ++ Value: big.NewInt(0), ++ } ++ ++ appErr := transition.Write(txn) ++ if assert.NotNil(t, appErr, "expected the write to fail") { ++ assert.Equal(t, tc.isRecoverable, appErr.IsRecoverable) ++ } ++ }) ++ } ++} +diff --git a/txpool/decrease_nonce_test.go b/txpool/decrease_nonce_test.go +new file mode 100644 +index 00000000..363c9b23 +--- /dev/null ++++ b/txpool/decrease_nonce_test.go +@@ -0,0 +1,69 @@ ++package txpool ++ ++import ( ++ "math/big" ++ "testing" ++ ++ "github.com/0xPolygon/polygon-sdk/types" ++ "github.com/hashicorp/go-hclog" ++ "github.com/stretchr/testify/assert" ++) ++ ++func TestDecreaseAccountNonce(t *testing.T) { ++ pool, err := NewTxPool(hclog.NewNullLogger(), false, forks.At(0), &mockStore{}, nil, nil) ++ assert.NoError(t, err) ++ pool.EnableDev() ++ ++ addr := types.Address{0x1} ++ ++ tx0 := &types.Transaction{ ++ From: addr, ++ Nonce: 0, ++ Gas: validGasLimit, ++ GasPrice: big.NewInt(1), ++ Value: big.NewInt(0), ++ } ++ tx1 := &types.Transaction{ ++ From: addr, ++ Nonce: 1, ++ Gas: validGasLimit, ++ GasPrice: big.NewInt(1), ++ Value: big.NewInt(0), ++ } ++ assert.NoError(t, pool.addImpl("", tx0)) ++ assert.NoError(t, pool.addImpl("", tx1)) ++ ++ nonce, ok := pool.GetNonce(addr) ++ assert.True(t, ok) ++ assert.Equal(t, uint64(2), nonce) ++ ++ ++ pool.DecreaseAccountNonce(tx1) ++ ++ nonce, ok = pool.GetNonce(addr) ++ assert.True(t, ok) ++ assert.Equal(t, uint64(1), nonce) ++} ++ ++func TestDecreaseAccountNonce_UntrackedAccount(t *testing.T) { ++ pool, err := NewTxPool(hclog.NewNullLogger(), false, forks.At(0), &mockStore{}, nil, nil) ++ assert.NoError(t, err) ++ pool.EnableDev() ++ ++ untracked := types.Address{0x9} ++ tx := &types.Transaction{ ++ From: untracked, ++ Nonce: 0, ++ Gas: validGasLimit, ++ GasPrice: big.NewInt(1), ++ Value: big.NewInt(0), ++ } ++ ++ ++ assert.NotPanics(t, func() { ++ pool.DecreaseAccountNonce(tx) ++ }) ++ ++ _, ok := pool.GetNonce(untracked) ++ assert.False(t, ok) ++} +diff --git 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 ++ ++ ++ ++ ++go test ./state/... ./txpool/... ./types/... ++ ++ ++go test -run 'TestWriteTransactionRecoverability' ./state/ ++go test -run 'TestDecreaseAccountNonce' ./txpool/ diff --git a/tasks/format-code-task-000001/tests/test.sh b/tasks/format-code-task-000001/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aad227ebfdc3eed3b9a67071b62e8859e82eb81e --- /dev/null +++ b/tasks/format-code-task-000001/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' +state/transition_recoverable_test.go +txpool/decrease_nonce_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-000001/tests/test_command.sh b/tasks/format-code-task-000001/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000001/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000008/environment/Dockerfile b/tasks/format-code-task-000008/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c4c85eb5fc834133dbd27211f1eeff4bdb4f765a --- /dev/null +++ b/tasks/format-code-task-000008/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f83df347542976209efc13596eabae5e46f35b4330f7fae6fa9e487c5493f0dd diff --git a/tasks/format-code-task-000008/environment/setup/files/blocklist b/tasks/format-code-task-000008/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000008/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000008/environment/setup/setup.sh b/tasks/format-code-task-000008/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000008/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000008/tests/test.patch b/tasks/format-code-task-000008/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a66f5bfcf99d7ddf8b00793e17177eb606689a3 --- /dev/null +++ b/tasks/format-code-task-000008/tests/test.patch @@ -0,0 +1,208 @@ +diff --git a/usercase-test-coderl/fixtures/open_flags_scene.py b/usercase-test-coderl/fixtures/open_flags_scene.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/open_flags_scene.py +@@ -0,0 +1,11 @@ ++from manimlib.scene.scene import Scene ++ ++ ++class EmptyScene(Scene): ++ def construct(self): ++ self.wait(0.1) ++ ++ ++class OtherScene(Scene): ++ def construct(self): ++ self.wait(0.1) +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,170 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++ ++ ++export PYTHONPATH="/workspace/repo:${PYTHONPATH:-}" ++ ++command -v xvfb-run >/dev/null 2>&1 \ ++ || { echo "FAIL: xvfb-run is required for ManimGL rendering in this environment" >&2; exit 1; } ++ ++MANIMGL_BIN=$(command -v manimgl || true) ++MANIM_RENDER_BIN=$(command -v manim-render || true) ++[ -n "$MANIMGL_BIN" ] || { echo "FAIL: manimgl not found after build" >&2; exit 1; } ++[ -n "$MANIM_RENDER_BIN" ] || { echo "FAIL: manim-render not found after build" >&2; exit 1; } ++ ++ROOT=/workspace/repo/usercase-test-coderl ++SCENE="$ROOT/fixtures/open_flags_scene.py" ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++mkdir -p "$TMP/bin" "$TMP/media" ++cat > "$TMP/bin/xdg-open" <<'SH' ++#!/usr/bin/env bash ++printf '%s\n' "$*" >> "$XDG_OPEN_LOG" ++exit 0 ++SH ++chmod +x "$TMP/bin/xdg-open" ++export PATH="$TMP/bin:$PATH" ++export XDG_OPEN_LOG="$TMP/xdg-open.log" ++ ++run_render() { ++ local bin="$1" ++ shift ++ : > "$XDG_OPEN_LOG" ++ rm -rf "$TMP/media" ++ mkdir -p "$TMP/media" ++ xvfb-run -a "$bin" "$SCENE" EmptyScene "$@" -r 16x16 --fps 1 --quiet >out 2>err ++ ec=$? ++} ++ ++assert_no_crash_output() { ++ ++ ++ ! grep -Eiq 'Traceback|SyntaxError|Exception:' out err \ ++ || fail "$1 unexpected crash output: stdout=$(cat out) stderr=$(cat err)" ++} ++ ++help_block_for() { ++ grep -A1 -F -- "$1" out | tr '[:upper:]' '[:lower:]' ++} ++ ++assert_finder_log_reveals() { ++ local label="$1" ++ local file="$2" ++ local dir ++ dir=$(dirname "$file") ++ local log ++ log=$(cat "$XDG_OPEN_LOG") ++ ++ ++ ++ case "$log" in ++ "-R $file"|"--reveal $file"|"--select $file"|"$dir") ;; ++ *) fail "$label opener log: $log" ;; ++ esac ++} ++ ++ ++ ++ ++"$MANIMGL_BIN" --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++ ++open_help=$(help_block_for "--open") ++printf '%s\n' "$open_help" | grep -Fq -- "--open" || fail "F1 missing --open help" ++printf '%s\n' "$open_help" | grep -Eq -- '(^|[[:space:]])-o([,[:space:]]|$)' \ ++ || fail "F1 missing -o help alias" ++printf '%s\n' "$open_help" | grep -Eq -- '(open|launch).*(saved|output|file)|(saved|output|file).*(open|launch)' \ ++ || fail "F1 --open help does not describe opening the saved file" ++ ++ ++finder_help=$(help_block_for "--finder") ++printf '%s\n' "$finder_help" | grep -Fq -- "--finder" || fail "F1 missing --finder help" ++printf '%s\n' "$finder_help" | grep -Eq -- '(show|reveal|browser|file manager|file explorer)' \ ++ || fail "F1 --finder help does not describe showing/revealing output" ++printf '%s\n' "$finder_help" | grep -Eq -- '(output|file|directory|folder)' \ ++ || fail "F1 --finder help does not mention the output file/location" ++assert_no_crash_output F1 ++ ++ ++ ++ ++run_render "$MANIMGL_BIN" --open --video_dir "$TMP/media" --file_name opened_movie ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_no_crash_output F2 ++[ -f "$TMP/media/opened_movie.mp4" ] || fail "F2 missing movie file" ++[ "$(cat "$XDG_OPEN_LOG")" = "$TMP/media/opened_movie.mp4" ] \ ++ || fail "F2 opener log: $(cat "$XDG_OPEN_LOG")" ++ ++ ++ ++ ++run_render "$MANIMGL_BIN" -o --video_dir "$TMP/media" --file_name short_open_movie ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_no_crash_output F3 ++[ -f "$TMP/media/short_open_movie.mp4" ] || fail "F3 missing movie file" ++[ "$(cat "$XDG_OPEN_LOG")" = "$TMP/media/short_open_movie.mp4" ] \ ++ || fail "F3 opener log: $(cat "$XDG_OPEN_LOG")" ++ ++ ++ ++ ++run_render "$MANIMGL_BIN" --finder --video_dir "$TMP/media" --file_name revealed_movie ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_no_crash_output F4 ++[ -f "$TMP/media/revealed_movie.mp4" ] || fail "F4 missing movie file" ++assert_finder_log_reveals F4 "$TMP/media/revealed_movie.mp4" ++ ++ ++ ++ ++run_render "$MANIMGL_BIN" --open --skip_animations --video_dir "$TMP/media" --file_name opened_image ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++assert_no_crash_output F5 ++[ -f "$TMP/media/opened_image.png" ] || fail "F5 missing image file" ++[ ! -e "$TMP/media/opened_image.mp4" ] || fail "F5 unexpectedly wrote a movie" ++[ "$(cat "$XDG_OPEN_LOG")" = "$TMP/media/opened_image.png" ] \ ++ || fail "F5 opener log: $(cat "$XDG_OPEN_LOG")" ++ ++ ++ ++ ++run_render "$MANIM_RENDER_BIN" --finder --skip_animations --video_dir "$TMP/media" --file_name revealed_image ++[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0" ++assert_no_crash_output F6 ++[ -f "$TMP/media/revealed_image.png" ] || fail "F6 missing image file" ++[ ! -e "$TMP/media/revealed_image.mp4" ] || fail "F6 unexpectedly wrote a movie" ++assert_finder_log_reveals F6 "$TMP/media/revealed_image.png" ++ ++ ++ ++ ++run_render "$MANIM_RENDER_BIN" --open --video_dir "$TMP/media" --file_name render_cmd_movie ++[ "$ec" -eq 0 ] || fail "F7 exit $ec; want 0" ++assert_no_crash_output F7 ++[ -f "$TMP/media/render_cmd_movie.mp4" ] || fail "F7 missing movie file" ++[ "$(cat "$XDG_OPEN_LOG")" = "$TMP/media/render_cmd_movie.mp4" ] \ ++ || fail "F7 opener log: $(cat "$XDG_OPEN_LOG")" ++ ++ ++ ++ ++: > "$XDG_OPEN_LOG" ++printf 'this is not python !!!\n' > "$TMP/broken_scene.py" ++xvfb-run -a "$MANIMGL_BIN" "$TMP/broken_scene.py" --open --video_dir "$TMP/media" --file_name no_scene -r 16x16 --fps 1 --quiet >out 2>err ++ec=$? ++[ "$ec" -ne 0 ] || fail "F8 exit 0; want non-zero" ++ ++ ++[ ! -e "$TMP/media/no_scene.mp4" ] || fail "F8 unexpectedly wrote a movie" ++[ ! -e "$TMP/media/no_scene.png" ] || fail "F8 unexpectedly wrote an image" ++[ ! -s "$XDG_OPEN_LOG" ] || fail "F8 opener should not be called: $(cat "$XDG_OPEN_LOG")" ++ ++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-000008/tests/test.sh b/tasks/format-code-task-000008/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..83004946211424b95826c8d01de04bbb134d8ceb --- /dev/null +++ b/tasks/format-code-task-000008/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/open_flags_scene.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-000008/tests/test_command.sh b/tasks/format-code-task-000008/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000008/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-000030/environment/Dockerfile b/tasks/format-code-task-000030/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bbd82ff34cc32471708274b754ede9d4e13241db --- /dev/null +++ b/tasks/format-code-task-000030/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e8a9ca146420b25fb170db312469d9b11d8eb9783ac4586ec2e33a33c0bf4311 diff --git a/tasks/format-code-task-000030/environment/setup/files/blocklist b/tasks/format-code-task-000030/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000030/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000030/environment/setup/setup.sh b/tasks/format-code-task-000030/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000030/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000030/tests/test.patch b/tasks/format-code-task-000030/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e9304330ec0a23c404142875f822783ae82cf8a5 --- /dev/null +++ b/tasks/format-code-task-000030/tests/test.patch @@ -0,0 +1,124 @@ +diff --git a/tests/blob/blobCorsRequest.test.ts b/tests/blob/blobCorsRequest.test.ts +index f46468450..7fc25f36c 100644 +--- a/tests/blob/blobCorsRequest.test.ts ++++ b/tests/blob/blobCorsRequest.test.ts +@@ -7,6 +7,7 @@ import * as assert from "assert"; + + import { configLogger } from "../../src/common/Logger"; + import BlobTestServerFactory from "../BlobTestServerFactory"; ++import { RestError } from "@azure/core-http"; + import { + EMULATOR_ACCOUNT_KEY, + EMULATOR_ACCOUNT_NAME, +@@ -531,6 +532,77 @@ describe("Blob Cors requests test", () => { + assert.ok(res._response.status === 200); + }); + ++ context( ++ "OPTIONS request should work with matching rule containing wildcard in Origin @loki @sql", ++ async () => { ++ const testCases = [ ++ { origin: undefined, expected: 403 }, ++ { origin: "contoso.com", expected: 403 }, ++ { origin: "bar.notcontoso.com", expected: 403 }, ++ { origin: "foo.contoso.com", expected: 200 }, ++ { origin: "foo.bar.baz.contoso.com", expected: 200 }, ++ { origin: "foo.CONTOSO.com", expected: 200 } ++ ]; ++ ++ testCases.forEach(async (testCase) => { ++ it(`${testCase.origin}`, async () => { ++ const serviceProperties = await serviceClient.getProperties(); ++ ++ const newCORS = { ++ allowedHeaders: "header", ++ allowedMethods: "GET", ++ allowedOrigins: "*.contoso.com", ++ exposedHeaders: "*", ++ maxAgeInSeconds: 8888 ++ }; ++ ++ serviceProperties.cors = [newCORS]; ++ ++ await serviceClient.setProperties(serviceProperties); ++ ++ await sleep(100); ++ ++ const origin = testCase.origin; ++ const requestMethod = "GET"; ++ const expectedStatus = testCase.expected; ++ ++ const pipeline = newPipeline( ++ new StorageSharedKeyCredential( ++ EMULATOR_ACCOUNT_NAME, ++ EMULATOR_ACCOUNT_KEY ++ ), ++ { ++ retryOptions: { maxTries: 1 }, ++ ++ keepAliveOptions: { enable: false } ++ } ++ ); ++ pipeline.factories.unshift( ++ new OPTIONSRequestPolicyFactory(origin, requestMethod) ++ ); ++ const serviceClientForOptions = new BlobServiceClient( ++ baseURL, ++ pipeline ++ ); ++ ++ let status: number = 0; ++ try { ++ const res = await serviceClientForOptions.getProperties(); ++ status = res._response.status; ++ } catch (e: any) { ++ if (!(e instanceof RestError)) { ++ throw e; ++ } ++ ++ status = e.response?.status || 0; ++ } ++ ++ assert.ok(status === expectedStatus); ++ }); ++ }); ++ } ++ ); ++ + it("Response of request to service without cors rules should not contains cors info @loki @sql", async () => { + const serviceProperties = await serviceClient.getProperties(); + +@@ -714,9 +786,8 @@ describe("Blob Cors requests test", () => { + pipeline.factories.unshift(new OriginPolicyFactory(origin)); + const serviceClientWithOrigin = new BlobServiceClient(baseURL, pipeline); + +- const containerClientWithOrigin = serviceClientWithOrigin.getContainerClient( +- "notexistcontainer" +- ); ++ const containerClientWithOrigin = ++ serviceClientWithOrigin.getContainerClient("notexistcontainer"); + + try { + await containerClientWithOrigin.getProperties(); +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+3ST0+DMBgGcM77FP0CQCEWTyaajUSN2RLcLl4If5qtEejsWxY/vl0vLia6y5Zp ++fH6HvoW28IaHqB5V15Zy2MXBuXDnWghfna/VzxORJkl2lXGRBNzNeBowcbaODoxkK8NYYLS2P+07 ++tv5HRZ/5W0m2bHTfV0Mb0eZ07ziWfyoO8uf7/F3NAsZP18L3/nn+Tct88LVsJ8P2nTVGE4Xud2Dz ++xSwvl0/PZZE/5tNluZrfrZb3i+LhJZ/dcLbf3OtmU7EwNPJtVEYyS+GgWxkbuVZkpXFLgw6t6qUe ++LbmrtZFbdtvpV+VPNaMhtXPnXAMU152u/TDVhgr3SHc3sn6gyaW/EwAAAAAAAAAAAAAAAAAAAADA ++b/QBSL+fCwAoAAA= +diff --git 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-000030/tests/test.sh b/tasks/format-code-task-000030/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3606cb7b3a0401d72651d6cc09f7a5d15318bac8 --- /dev/null +++ b/tasks/format-code-task-000030/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/blob/blobCorsRequest.test.ts +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-000030/tests/test_command.sh b/tasks/format-code-task-000030/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000030/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000037/environment/Dockerfile b/tasks/format-code-task-000037/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ac218810016237ec288caff48341541d9a6dbe65 --- /dev/null +++ b/tasks/format-code-task-000037/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3920c30b14a52e951a66b08c4fd83ea4591a427f0376ad54cd7813f86ae3eae2 diff --git a/tasks/format-code-task-000037/environment/setup/files/blocklist b/tasks/format-code-task-000037/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000037/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000037/environment/setup/setup.sh b/tasks/format-code-task-000037/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000037/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000037/tests/test.patch b/tasks/format-code-task-000037/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..35ad49d845b2eabc285b39bb21fff9810a06233d --- /dev/null +++ b/tasks/format-code-task-000037/tests/test.patch @@ -0,0 +1,131 @@ +diff --git a/packages/components/psammead-social-embed/src/Notice/index.test.jsx b/packages/components/psammead-social-embed/src/Notice/index.test.jsx +new file mode 100644 +index 000000000..ad2a67723 +--- /dev/null ++++ b/packages/components/psammead-social-embed/src/Notice/index.test.jsx +@@ -0,0 +1,103 @@ ++import React from 'react'; ++import { render } from '@testing-library/react'; ++import 'jest-styled-components'; ++import Notice from './index'; ++ ++const renderNotice = () => ++ render( ++ , ++ ); ++ ++const KNOWN_COLOR_VALUES = [ ++ '#222222', ++ '#3F3F42', ++ '#6E6E73', ++ '#AEAEB5', ++ '#404040', ++ '#000000', ++ '#FFFFFF', ++ 'inherit', ++ 'transparent', ++ 'currentColor', ++]; ++ ++const hasRule = (element, property, value, modifier) => { ++ try { ++ if (modifier) { ++ expect(element).toHaveStyleRule(property, value, { modifier }); ++ } else { ++ expect(element).toHaveStyleRule(property, value); ++ } ++ return true; ++ } catch (e) { ++ return false; ++ } ++}; ++ ++const getExplicitColor = (wrapper, modifier) => { ++ for (let i = 0; i < KNOWN_COLOR_VALUES.length; i += 1) { ++ const c = KNOWN_COLOR_VALUES[i]; ++ if (hasRule(wrapper, 'color', c, modifier)) return c; ++ } ++ return null; ++}; ++ ++const getWrapperColor = wrapper => { ++ for (let i = 0; i < KNOWN_COLOR_VALUES.length; i += 1) { ++ const c = KNOWN_COLOR_VALUES[i]; ++ if (hasRule(wrapper, 'color', c)) return c; ++ } ++ return null; ++}; ++ ++ ++const effectiveColorIs = (wrapper, modifier, color) => { ++ if (!modifier) return hasRule(wrapper, 'color', color); ++ const explicit = getExplicitColor(wrapper, modifier); ++ if (explicit && explicit !== 'inherit') return explicit === color; ++ return getWrapperColor(wrapper) === color; ++}; ++ ++describe('Notice fallback colours', () => { ++ it('paragraph text should render as C_SHADOW (#3F3F42)', () => { ++ const { container } = renderNotice(); ++ expect(effectiveColorIs(container.firstChild, 'p', '#3F3F42')).toBe(true); ++ }); ++ ++ it('warning (small) text should render as C_SHADOW (#3F3F42)', () => { ++ const { container } = renderNotice(); ++ expect(effectiveColorIs(container.firstChild, 'small', '#3F3F42')).toBe( ++ true, ++ ); ++ }); ++ ++ it('paragraph text should no longer render as C_EBON (#222222)', () => { ++ const { container } = renderNotice(); ++ expect(effectiveColorIs(container.firstChild, 'p', '#222222')).toBe(false); ++ }); ++ ++ it('link should render as C_EBON (#222222)', () => { ++ const { container } = renderNotice(); ++ expect(effectiveColorIs(container.firstChild, 'a', '#222222')).toBe(true); ++ }); ++ ++ it('link should not render as C_SHADOW (#3F3F42)', () => { ++ const { container } = renderNotice(); ++ expect(effectiveColorIs(container.firstChild, 'a', '#3F3F42')).toBe(false); ++ }); ++ ++ it('visited link should remain C_METAL (#6E6E73)', () => { ++ const { container } = renderNotice(); ++ expect(container.firstChild).toHaveStyleRule('color', '#6E6E73', { ++ modifier: 'a:visited', ++ }); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..4d8854ef1 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest packages/components/psammead-social-embed/src/Notice/index.test.jsx --no-coverage --ci"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest packages/components/psammead-social-embed/src/Notice/index.test.jsx --no-coverage --ci ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000037/tests/test.sh b/tasks/format-code-task-000037/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2189bc0433516da8d2ba94a7f0a6bc93b0d4363d --- /dev/null +++ b/tasks/format-code-task-000037/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/components/psammead-social-embed/src/Notice/index.test.jsx +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000037/tests/test_command.sh b/tasks/format-code-task-000037/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000037/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000039/environment/Dockerfile b/tasks/format-code-task-000039/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c6ba4221a1bc48ca7d891eef895eb19a9c2184b0 --- /dev/null +++ b/tasks/format-code-task-000039/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:36ca2c575bd37e62dc399f5da74ebc9aceb950e4f418103b3cfa3e96e993557b diff --git a/tasks/format-code-task-000039/environment/setup/files/blocklist b/tasks/format-code-task-000039/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000039/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000039/environment/setup/setup.sh b/tasks/format-code-task-000039/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000039/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000039/tests/test.patch b/tasks/format-code-task-000039/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7e895791d7c598c8dd61c68e06e616c40a72ff7f --- /dev/null +++ b/tasks/format-code-task-000039/tests/test.patch @@ -0,0 +1,354 @@ +diff --git a/backend/aopp_approval_external_test.go b/backend/aopp_approval_external_test.go +new file mode 100644 +index 000000000..58d8dce33 +--- /dev/null ++++ b/backend/aopp_approval_external_test.go +@@ -0,0 +1,236 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package backend_test ++ ++import ( ++ "fmt" ++ "net/http" ++ "net/http/httptest" ++ "net/url" ++ "testing" ++ ++ "github.com/digitalbitbox/bitbox-wallet-app/backend" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/arguments" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/types" ++ coinpkg "github.com/digitalbitbox/bitbox-wallet-app/backend/coins/coin" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/devices/device" ++ deviceevent "github.com/digitalbitbox/bitbox-wallet-app/backend/devices/device/event" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/devices/usb" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/handlers" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/keystore" ++ keystoremock "github.com/digitalbitbox/bitbox-wallet-app/backend/keystore/mocks" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/keystore/software" ++ "github.com/digitalbitbox/bitbox-wallet-app/backend/signing" ++ "github.com/digitalbitbox/bitbox-wallet-app/util/observable" ++ "github.com/digitalbitbox/bitbox-wallet-app/util/test" ++ "github.com/stretchr/testify/require" ++) ++ ++type aoppTestEnv struct{} ++ ++func (aoppTestEnv) NotifyUser(string) {} ++func (aoppTestEnv) DeviceInfos() []usb.DeviceInfo { return nil } ++func (aoppTestEnv) SystemOpen(string) error { return nil } ++func (aoppTestEnv) UsingMobileData() bool { return false } ++func (aoppTestEnv) NativeLocale() string { return "en" } ++ ++type aoppTestDevice struct { ++ observable.Implementation ++ keystore keystore.Keystore ++ onEvent func(deviceevent.Event, interface{}) ++} ++ ++func (d *aoppTestDevice) Init(bool) error { ++ d.onEvent(deviceevent.EventKeystoreAvailable, nil) ++ return nil ++} ++ ++func (d *aoppTestDevice) ProductName() string { return "test-device" } ++func (d *aoppTestDevice) Identifier() string { return "aopp-test-device" } ++func (d *aoppTestDevice) Keystore() keystore.Keystore { ++ return d.keystore ++} ++func (d *aoppTestDevice) SetOnEvent(f func(deviceevent.Event, interface{})) { d.onEvent = f } ++func (d *aoppTestDevice) Close() {} ++ ++func newAOPPTestBackend(t *testing.T) *backend.Backend { ++ t.Helper() ++ b, err := backend.NewBackend( ++ arguments.NewArguments( ++ test.TstTempDir("aopp-approval"), ++ false, false, ++ false, false, ++ &types.GapLimits{Receive: 20, Change: 6}), ++ aoppTestEnv{}, ++ ) ++ require.NoError(t, err) ++ b.RatesUpdater().SetCoingeckoURL("unused") ++ b.OnDeviceInit(func(device.Interface) {}) ++ b.OnDeviceUninit(func(string) {}) ++ return b ++} ++ ++func registerAOPPSigningKeystore(t *testing.T, b *backend.Backend) { ++ t.Helper() ++ keystoreHelper := software.NewKeystoreFromPIN("0000") ++ ks := &keystoremock.KeystoreMock{ ++ RootFingerprintFunc: func() ([]byte, error) { ++ return []byte{0x55, 0x55, 0x55, 0x55}, nil ++ }, ++ SupportsAccountFunc: func(coin coinpkg.Coin, meta interface{}) bool { ++ switch coin.(type) { ++ case *btc.Coin: ++ scriptType := meta.(signing.ScriptType) ++ return scriptType != signing.ScriptTypeP2PKH ++ default: ++ return true ++ } ++ }, ++ SupportsUnifiedAccountsFunc: func() bool { ++ return true ++ }, ++ SupportsMultipleAccountsFunc: func() bool { ++ return true ++ }, ++ CanSignMessageFunc: func(coinpkg.Code) bool { ++ return true ++ }, ++ ExtendedPublicKeyFunc: keystoreHelper.ExtendedPublicKey, ++ } ++ require.NoError(t, b.Register(&aoppTestDevice{keystore: ks})) ++} ++ ++func defaultAOPPParams() url.Values { ++ params := url.Values{} ++ params.Set("v", "0") ++ params.Set("msg", "message to be signed") ++ params.Set("format", "any") ++ params.Set("asset", "btc") ++ params.Set("callback", "http://localhost/aopp/") ++ return params ++} ++ ++func postAOPPRoute(t *testing.T, b *backend.Backend, path string) { ++ t.Helper() ++ h := handlers.NewHandlers(b, handlers.NewConnectionData(0, "")) ++ request := httptest.NewRequest(http.MethodPost, path, nil) ++ response := httptest.NewRecorder() ++ h.Router.ServeHTTP(response, request) ++ require.Equal(t, http.StatusOK, response.Code) ++} ++ ++func currentAOPPState(b *backend.Backend) string { ++ return fmt.Sprint(b.AOPP().State) ++} ++ ++func currentAOPPErrorCode(b *backend.Backend) string { ++ return fmt.Sprint(b.AOPP().ErrorCode) ++} ++ ++func TestAOPPSuccess(t *testing.T) { ++ t.Run("user-approval-before-account-selection", func(t *testing.T) { ++ b := newAOPPTestBackend(t) ++ defer b.Close() ++ ++ params := defaultAOPPParams() ++ params.Set("callback", "https://approval-gate.example.org/callback") ++ registerAOPPSigningKeystore(t, b) ++ b.HandleURI("aopp:?" + params.Encode()) ++ ++ require.Equal(t, "user-approval", currentAOPPState(b)) ++ require.NotEqual(t, "choosing-account", currentAOPPState(b)) ++ require.Equal(t, "approval-gate.example.org", b.AOPP().CallbackHost) ++ }) ++ ++ t.Run("approve-continues-flow", func(t *testing.T) { ++ b := newAOPPTestBackend(t) ++ defer b.Close() ++ ++ params := defaultAOPPParams() ++ params.Set("callback", "https://approval-continues.example.org/callback") ++ registerAOPPSigningKeystore(t, b) ++ b.HandleURI("aopp:?" + params.Encode()) ++ require.Equal(t, "user-approval", currentAOPPState(b)) ++ ++ postAOPPRoute(t, b, "/api/aopp/approve") ++ ++ require.Equal(t, "choosing-account", currentAOPPState(b)) ++ require.NotEmpty(t, b.AOPP().Accounts) ++ }) ++ ++ t.Run("approve-noops-outside-approval", func(t *testing.T) { ++ b := newAOPPTestBackend(t) ++ defer b.Close() ++ require.Equal(t, "inactive", currentAOPPState(b)) ++ ++ postAOPPRoute(t, b, "/api/aopp/approve") ++ ++ require.Equal(t, "inactive", currentAOPPState(b)) ++ }) ++ ++ t.Run("approval-keystore-disconnect", func(t *testing.T) { ++ b := newAOPPTestBackend(t) ++ defer b.Close() ++ ++ params := defaultAOPPParams() ++ params.Set("callback", "https://approval-disconnect.example.org/callback") ++ registerAOPPSigningKeystore(t, b) ++ b.HandleURI("aopp:?" + params.Encode()) ++ require.Equal(t, "user-approval", currentAOPPState(b)) ++ b.DeregisterKeystore() ++ ++ postAOPPRoute(t, b, "/api/aopp/approve") ++ ++ require.Equal(t, "awaiting-keystore", currentAOPPState(b)) ++ require.NotEqual(t, "choosing-account", currentAOPPState(b)) ++ }) ++ ++ t.Run("cancel-from-approval-stops-before-account-selection", func(t *testing.T) { ++ b := newAOPPTestBackend(t) ++ defer b.Close() ++ ++ params := defaultAOPPParams() ++ params.Set("callback", "https://approval-cancel.example.org/callback") ++ registerAOPPSigningKeystore(t, b) ++ b.HandleURI("aopp:?" + params.Encode()) ++ require.Equal(t, "user-approval", currentAOPPState(b)) ++ ++ postAOPPRoute(t, b, "/api/aopp/cancel") ++ ++ require.Equal(t, "inactive", currentAOPPState(b)) ++ require.NotEqual(t, "choosing-account", currentAOPPState(b)) ++ }) ++} ++ ++func TestAOPPFailures(t *testing.T) { ++ t.Run("no_accounts", func(t *testing.T) { ++ b := newAOPPTestBackend(t) ++ defer b.Close() ++ ++ registerAOPPSigningKeystore(t, b) ++ for _, acct := range b.Accounts() { ++ require.NoError(t, b.SetAccountActive(acct.Config().Code, false)) ++ } ++ params := defaultAOPPParams() ++ b.HandleURI("aopp:?" + params.Encode()) ++ require.Equal(t, "user-approval", currentAOPPState(b)) ++ ++ postAOPPRoute(t, b, "/api/aopp/approve") ++ ++ require.Equal(t, "error", currentAOPPState(b)) ++ require.Equal(t, "aoppNoAccounts", currentAOPPErrorCode(b)) ++ }) ++} +diff --git a/backend/aopp_test.go b/backend/aopp_test.go +index 9f85738e6..93116adc0 100644 +--- a/backend/aopp_test.go ++++ b/backend/aopp_test.go +@@ -307,7 +307,9 @@ func TestAOPPFailures(t *testing.T) { + params := defaultParams() + b.registerKeystore(&ks) + require.NoError(t, b.SetAccountActive("v0-55555555-btc-0", false)) ++ b.DeregisterKeystore() + b.HandleURI("aopp:?" + params.Encode()) ++ b.registerKeystore(&ks) + require.Equal(t, aoppStateError, b.AOPP().State) + require.Equal(t, errAOPPNoAccounts, b.AOPP().ErrorCode) + }) +diff --git a/backend/handlers/aopp_approve_route_test.go b/backend/handlers/aopp_approve_route_test.go +new file mode 100644 +index 000000000..1563eda47 +--- /dev/null ++++ b/backend/handlers/aopp_approve_route_test.go +@@ -0,0 +1,70 @@ ++package handlers_test ++ ++import ( ++ "os" ++ "path/filepath" ++ "strings" ++ "testing" ++ ++ "github.com/stretchr/testify/require" ++) ++ ++func TestAOPPFrontendApprovalSurface(t *testing.T) { ++ apiSource, err := os.ReadFile(filepath.Join("..", "..", "frontends", "web", "src", "api", "aopp.ts")) ++ require.NoError(t, err) ++ componentSource, err := os.ReadFile(filepath.Join("..", "..", "frontends", "web", "src", "components", "aopp", "aopp.tsx")) ++ require.NoError(t, err) ++ ++ api := string(apiSource) ++ component := string(componentSource) ++ require.Contains(t, api, "'user-approval'") ++ require.Contains(t, api, "approve = (): Promise") ++ require.Contains(t, api, "apiPost('aopp/approve')") ++ ++ approvalIndex := strings.Index(component, "case 'user-approval':") ++ require.NotEqual(t, -1, approvalIndex) ++ approvalCase := component[approvalIndex:] ++ if nextCase := strings.Index(approvalCase[len("case 'user-approval':"):], "case '"); nextCase >= 0 { ++ approvalCase = approvalCase[:len("case 'user-approval':")+nextCase] ++ } ++ approvalSource := approvalCase ++ if !strings.Contains(approvalSource, "aoppAPI.approve") && !strings.Contains(approvalSource, "aoppAPI.cancel") { ++ if methodName := calledComponentMethod(approvalCase); methodName != "" { ++ approvalSource += componentMethodSource(component, methodName) ++ } ++ } ++ require.Contains(t, approvalSource, "callbackHost") ++ require.Contains(t, approvalSource, "aoppAPI.cancel") ++ require.Contains(t, approvalSource, "aoppAPI.approve") ++} ++ ++func calledComponentMethod(source string) string { ++ const receiver = "this." ++ idx := strings.Index(source, receiver) ++ if idx < 0 { ++ return "" ++ } ++ rest := source[idx+len(receiver):] ++ end := 0 ++ for end < len(rest) { ++ c := rest[end] ++ if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' { ++ end++ ++ continue ++ } ++ break ++ } ++ return rest[:end] ++} ++ ++func componentMethodSource(component, methodName string) string { ++ idx := strings.Index(component, methodName) ++ if idx < 0 { ++ return "" ++ } ++ end := idx + 800 ++ if end > len(component) { ++ end = len(component) ++ } ++ return component[idx: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,17 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 -run 'TestAOPPFailures/(wrong_version|missing_callback|invalid_callback|missing_msg|unsupported_asset)$' ./backend/ ++ ;; ++ new) ++ go test -v -count=1 -run 'TestAOPPSuccess/(user-approval-before-account-selection|approve-continues-flow|approve-noops-outside-approval|approval-keystore-disconnect|cancel-from-approval-stops-before-account-selection)$|TestAOPPFailures/no_accounts$' ./backend/ ++ go test -v -count=1 -run 'TestAOPP(ApproveRouteCallsBackend|FrontendApprovalSurface)$' ./backend/handlers/ ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000039/tests/test.sh b/tasks/format-code-task-000039/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..664bc3acfffeaefd881593a149e6ce8b3c798251 --- /dev/null +++ b/tasks/format-code-task-000039/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' +backend/aopp_approval_external_test.go +backend/aopp_test.go +backend/handlers/aopp_approve_route_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-000039/tests/test_command.sh b/tasks/format-code-task-000039/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000039/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-000053/environment/Dockerfile b/tasks/format-code-task-000053/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c71814de98145366d217640c9d6e654061b1374b --- /dev/null +++ b/tasks/format-code-task-000053/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:07d3d16e52e278a171f897cf33c907494c3389a4df4f6675896a1661003c823e diff --git a/tasks/format-code-task-000053/environment/setup/files/blocklist b/tasks/format-code-task-000053/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000053/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000053/environment/setup/setup.sh b/tasks/format-code-task-000053/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000053/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000053/tests/test.patch b/tasks/format-code-task-000053/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..770f20eb236d80e2a61ab7f2b8137e6b755108ab --- /dev/null +++ b/tasks/format-code-task-000053/tests/test.patch @@ -0,0 +1,385 @@ +diff --git a/internal/controller/postgrescluster/instance_test.go b/internal/controller/postgrescluster/instance_test.go +index 2eff97aa71..06e38c055b 100644 +--- a/internal/controller/postgrescluster/instance_test.go ++++ b/internal/controller/postgrescluster/instance_test.go +@@ -568,6 +568,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +@@ -618,6 +620,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +@@ -676,6 +680,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +@@ -726,6 +732,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +diff --git a/internal/controller/postgrescluster/pgbackrest_test.go b/internal/controller/postgrescluster/pgbackrest_test.go +index ccebca4563..999ec535fc 100644 +--- a/internal/controller/postgrescluster/pgbackrest_test.go ++++ b/internal/controller/postgrescluster/pgbackrest_test.go +@@ -2519,6 +2519,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/conf.d + name: pgbackrest-config +diff --git a/internal/controller/postgrescluster/pgmonitor_test.go b/internal/controller/postgrescluster/pgmonitor_test.go +index 1143035156..4549e5a523 100644 +--- a/internal/controller/postgrescluster/pgmonitor_test.go ++++ b/internal/controller/postgrescluster/pgmonitor_test.go +@@ -169,6 +169,8 @@ securityContext: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /conf + name: exporter-config +diff --git a/internal/controller/postgrescluster/volumes_test.go b/internal/controller/postgrescluster/volumes_test.go +index 6254f717a1..11e5974a0e 100644 +--- a/internal/controller/postgrescluster/volumes_test.go ++++ b/internal/controller/postgrescluster/volumes_test.go +@@ -776,6 +776,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: +@@ -834,6 +836,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: +@@ -894,6 +898,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: +diff --git a/internal/controller/standalone_pgadmin/pod_test.go b/internal/controller/standalone_pgadmin/pod_test.go +index 5f00138171..af5b9e0bea 100644 +--- a/internal/controller/standalone_pgadmin/pod_test.go ++++ b/internal/controller/standalone_pgadmin/pod_test.go +@@ -120,6 +120,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgadmin/conf.d + name: pgadmin-config +@@ -172,6 +174,8 @@ initContainers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgadmin + name: pgadmin-config-system +@@ -298,6 +302,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgadmin/conf.d + name: pgadmin-config +@@ -354,6 +360,8 @@ initContainers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgadmin + name: pgadmin-config-system +diff --git a/internal/initialize/security_test.go b/internal/initialize/security_test.go +index da16f74ce6..86ff98f701 100644 +--- a/internal/initialize/security_test.go ++++ b/internal/initialize/security_test.go +@@ -20,6 +20,7 @@ import ( + "testing" + + "gotest.tools/v3/assert" ++ corev1 "k8s.io/api/core/v1" + + "github.com/crunchydata/postgres-operator/internal/initialize" + ) +@@ -59,9 +60,10 @@ func TestPodSecurityContext(t *testing.T) { + assert.Assert(t, psc.RunAsUser == nil, + `Containers must not set runAsUser to 0`) + +- // TODO(cbandy): delegate to v1.SecurityContext +- assert.Assert(t, psc.SeccompProfile == nil, +- `Seccomp profile must be explicitly set to one of the allowed values. Both the Unconfined profile and the absence of a profile are prohibited.`) ++ if assert.Check(t, psc.SeccompProfile == nil) { ++ assert.Assert(t, initialize.RestrictedSecurityContext().SeccompProfile != nil, ++ `SeccompProfile should be delegated to the container-level v1.SecurityContext`) ++ } + }) + } + +@@ -121,7 +123,7 @@ func TestRestrictedSecurityContext(t *testing.T) { + // of OpenShift 4.11 uses the "runtime/default" profile. + // - https://docs.openshift.com/container-platform/4.10/security/seccomp-profiles.html + // - https://docs.openshift.com/container-platform/4.11/security/seccomp-profiles.html +- assert.Assert(t, sc.SeccompProfile == nil, ++ assert.Assert(t, sc.SeccompProfile.Type == corev1.SeccompProfileTypeRuntimeDefault, + `Seccomp profile must be explicitly set to one of the allowed values. Both the Unconfined profile and the absence of a profile are prohibited.`) + }) + +diff --git a/internal/pgadmin/reconcile_test.go b/internal/pgadmin/reconcile_test.go +index 7036ec6575..7448552029 100644 +--- a/internal/pgadmin/reconcile_test.go ++++ b/internal/pgadmin/reconcile_test.go +@@ -244,6 +244,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgadmin + name: pgadmin-startup +@@ -284,6 +286,8 @@ initContainers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgadmin + name: pgadmin-startup +@@ -482,6 +486,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgadmin + name: pgadmin-startup +@@ -526,6 +532,8 @@ initContainers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgadmin + name: pgadmin-startup +diff --git a/internal/pgbackrest/reconcile_test.go b/internal/pgbackrest/reconcile_test.go +index ef3ac7b1ea..257529fc0c 100644 +--- a/internal/pgbackrest/reconcile_test.go ++++ b/internal/pgbackrest/reconcile_test.go +@@ -620,6 +620,8 @@ func TestAddServerToInstancePod(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +@@ -669,6 +671,8 @@ func TestAddServerToInstancePod(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +@@ -736,6 +740,8 @@ func TestAddServerToInstancePod(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +@@ -787,6 +793,8 @@ func TestAddServerToInstancePod(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +@@ -855,6 +863,8 @@ func TestAddServerToRepoPod(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +@@ -900,6 +910,8 @@ func TestAddServerToRepoPod(t *testing.T) { + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbackrest/server + name: pgbackrest-server +diff --git a/internal/pgbouncer/reconcile_test.go b/internal/pgbouncer/reconcile_test.go +index 72d31312c1..9747e8cdc1 100644 +--- a/internal/pgbouncer/reconcile_test.go ++++ b/internal/pgbouncer/reconcile_test.go +@@ -148,6 +148,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbouncer + name: pgbouncer-config +@@ -179,6 +181,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbouncer + name: pgbouncer-config +@@ -258,6 +262,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbouncer + name: pgbouncer-config +@@ -294,6 +300,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbouncer + name: pgbouncer-config +@@ -364,6 +372,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbouncer + name: pgbouncer-config +@@ -399,6 +409,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /etc/pgbouncer + name: pgbouncer-config +diff --git a/internal/postgres/reconcile_test.go b/internal/postgres/reconcile_test.go +index 644bf3798a..40886fb97d 100644 +--- a/internal/postgres/reconcile_test.go ++++ b/internal/postgres/reconcile_test.go +@@ -160,6 +160,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /pgconf/tls + name: cert-volume +@@ -201,6 +203,8 @@ containers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /pgconf/tls + name: cert-volume +@@ -289,6 +293,8 @@ initContainers: + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault + volumeMounts: + - mountPath: /pgconf/tls + name: cert-volume +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+2V32/aMBDHec5fYaFqah+ABAp7YhKimlSpldhA29uQsW/UmrGR7fTHxB+/SwIt ++RJSqBVRVu8+LHZ9957vvJalPUqXlGMxto3IsYuRzu52PSHnM50m7GTdxU9I6r8RJ0onbFdY+2o3W ++SH3gjrGKszbs2veS/YNSf9I/gA9jYWczbmTd3xwuxgv6o+ytR/3jTgf1P+9gG7D4cFd4nv9cfyFZ ++LvwEZBR5CKwGEdyrrBEkdOMoAnFjWbXb7bIRblNmypQJ4AzXDWVUUFyrv8DQXo2mlmWuWE3Y1IRu ++wmpBzcCmgbXi2LN6Y8vJBmt++ZSwxYI9RU1WUau7os+nXM6UeW3o5bF94k64+OOyaKcOhDVCaRhn ++0et4C2v0w9nr77Ry2WA1lxpW/XWaxe1J+R3m9ofV6Qz8yA6sXCzX+9b8VtORvTTYv0bAFlN2dOuy ++D9atHxiCuwW31dfKtO4L51oJ3nfAA/SL70VuGIJwEM5OqvvUFmslwB2ytIXHzcoWxbjm87WL59NV ++kgPrw9TB8NvVXvkUXvzh0lk63MzmggdeNMl15iBP4Gfvqrx0Ye/MHXeyN7gsm0Z8osHPuYCypdwU ++OGK5UqfCAxYxwP1egmNRgrNaoz5ZGMm1NTB+46u909lmxdayKVrhK0rjj5vgSjuh8Z+DLf727Eqe ++nvuW4QM7eVyK3vtXQxAEQRAEQRAEQRAEQRAEQRAEQRAEQRyRfwy2oScAKAAA +diff --git 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-000053/tests/test.sh b/tasks/format-code-task-000053/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..658d1c2ee4688574b530d14f73963ce3f2a10fc6 --- /dev/null +++ b/tasks/format-code-task-000053/tests/test.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 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/controller/postgrescluster/instance_test.go +internal/controller/postgrescluster/pgbackrest_test.go +internal/controller/postgrescluster/pgmonitor_test.go +internal/controller/postgrescluster/volumes_test.go +internal/controller/standalone_pgadmin/pod_test.go +internal/initialize/security_test.go +internal/pgadmin/reconcile_test.go +internal/pgbackrest/reconcile_test.go +internal/pgbouncer/reconcile_test.go +internal/postgres/reconcile_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-000053/tests/test_command.sh b/tasks/format-code-task-000053/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000053/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000055/environment/Dockerfile b/tasks/format-code-task-000055/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..05c4e1d4a3b5d6b1ddfd115f38f57a5aef71cae1 --- /dev/null +++ b/tasks/format-code-task-000055/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8df5e78b8414a0f6363a4ef1f328de3b545b5a7eb781bc4d954961a54312baf0 diff --git a/tasks/format-code-task-000055/environment/setup/files/blocklist b/tasks/format-code-task-000055/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000055/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000055/environment/setup/setup.sh b/tasks/format-code-task-000055/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000055/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000055/tests/test.sh b/tasks/format-code-task-000055/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dbe618588474f07df50697bf266bfa327a411aa0 --- /dev/null +++ b/tasks/format-code-task-000055/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' +packages/core/test/sessionManagement.spec.ts +packages/rum/test/rum.spec.ts +packages/rum/test/specHelper.ts +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-000062/environment/Dockerfile b/tasks/format-code-task-000062/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..48c109a806e7b2a1b34f995db047cca902f8dd19 --- /dev/null +++ b/tasks/format-code-task-000062/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:431223d61ff3999242835c72529da923868e2f7beb5a260d2e75136d8e96af77 diff --git a/tasks/format-code-task-000062/environment/setup/files/blocklist b/tasks/format-code-task-000062/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000062/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000062/environment/setup/setup.sh b/tasks/format-code-task-000062/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000062/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000062/tests/test.patch b/tasks/format-code-task-000062/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..22b8375f9425c8ff4f435d9932a9dba7f1739063 --- /dev/null +++ b/tasks/format-code-task-000062/tests/test.patch @@ -0,0 +1,85 @@ +diff --git a/profiler/options_test.go b/profiler/options_test.go +index 0cc04d69e..053c13ca1 100644 +--- a/profiler/options_test.go ++++ b/profiler/options_test.go +@@ -105,6 +105,18 @@ func TestOptions(t *testing.T) { + assert.Equal(t, 3*time.Second, cfg.cpuDuration) + }) + ++ t.Run("CPUProfileRate", func(t *testing.T) { ++ var cfg config ++ CPUProfileRate(123)(&cfg) ++ assert.Equal(t, 123, cfg.cpuProfileRate) ++ }) ++ ++ t.Run("CPUProfileRate/default", func(t *testing.T) { ++ cfg, err := defaultConfig() ++ require.NoError(t, err) ++ assert.Equal(t, 0, cfg.cpuProfileRate) ++ }) ++ + t.Run("MutexProfileFraction", func(t *testing.T) { + var cfg config + MutexProfileFraction(1)(&cfg) +diff --git a/profiler/profile_test.go b/profiler/profile_test.go +index 7c14422c9..ead96f9dc 100644 +--- a/profiler/profile_test.go ++++ b/profiler/profile_test.go +@@ -11,6 +11,7 @@ import ( + "io" + "io/ioutil" + "os" ++ "runtime" + "strconv" + "strings" + "testing" +@@ -192,6 +193,27 @@ main;bar 0 0 8 16 + assert.Equal(t, []byte("my-cpu-profile"), profs[0].data) + }) + ++ t.Run("cpu-profile-rate", func(t *testing.T) { ++ ++ ++ ++ ++ defer runtime.SetCPUProfileRate(0) ++ rate := 500 ++ p, err := unstartedProfiler( ++ CPUProfileRate(rate), ++ CPUDuration(20*time.Millisecond), ++ ) ++ require.NoError(t, err) ++ profs, err := p.runProfile(CPUProfile) ++ require.NoError(t, err) ++ require.Equal(t, "cpu.pprof", profs[0].name) ++ prof, err := pprofile.ParseData(profs[0].data) ++ require.NoError(t, err) ++ assert.Equal(t, int64(1e9/rate), prof.Period, ++ "CPU profile period should reflect the configured CPUProfileRate") ++ }) ++ + t.Run("goroutine", func(t *testing.T) { + defer func(old func(_ string, _ io.Writer, _ int) error) { lookupProfile = old }(lookupProfile) + lookupProfile = func(name string, w io.Writer, _ int) error { +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..ca7b84652 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./profiler/ -run \"TestRunProfile/cpu|TestOptions/CPUProfileRate\" -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 ./profiler/ -run "TestRunProfile/cpu|TestOptions/CPUProfileRate" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000062/tests/test.sh b/tasks/format-code-task-000062/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8bf54589458bb27440870435749c4a21a1c2698 --- /dev/null +++ b/tasks/format-code-task-000062/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' +profiler/options_test.go +profiler/profile_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-000062/tests/test_command.sh b/tasks/format-code-task-000062/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000062/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000065/environment/Dockerfile b/tasks/format-code-task-000065/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d96e8b0988b78a3d095f878a39b52147782d32d3 --- /dev/null +++ b/tasks/format-code-task-000065/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6cc1ad55d1fd9ee8a37653b599d7e8fe777eef4745dd1a1ea6efb1b72b273f7e diff --git a/tasks/format-code-task-000065/environment/setup/files/blocklist b/tasks/format-code-task-000065/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000065/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000065/environment/setup/setup.sh b/tasks/format-code-task-000065/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000065/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000065/tests/test.patch b/tasks/format-code-task-000065/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1d5abc85385d52a1e08df3086af15f7eea6af312 --- /dev/null +++ b/tasks/format-code-task-000065/tests/test.patch @@ -0,0 +1,212 @@ +diff --git a/packages/dd-trace/test/opentracing/span.spec.js b/packages/dd-trace/test/opentracing/span.spec.js +index bbf18bad5..6d91d4a26 100644 +--- a/packages/dd-trace/test/opentracing/span.spec.js ++++ b/packages/dd-trace/test/opentracing/span.spec.js +@@ -57,7 +57,7 @@ describe('Span', () => { + expect(span.context()._trace.started).to.deep.equal([span]) + }) + +- it('should use a parent context', () => { ++ it('uses the parent trace object for child spans', () => { + const parent = { + _traceId: '123', + _spanId: '456', +@@ -74,25 +74,29 @@ describe('Span', () => { + expect(span.context()._traceId).to.deep.equal('123') + expect(span.context()._parentId).to.deep.equal('456') + expect(span.context()._baggageItems).to.deep.equal({ foo: 'bar' }) +- expect(span.context()._trace.started).to.deep.equal(['span', span]) ++ expect(span.context()._trace).to.equal(parent._trace) ++ expect(parent._trace.started).to.include(span) + expect(span.context()._trace.origin).to.equal('synthetics') + }) + +- it('should start a new trace if the parent trace is finished', () => { ++ it('uses the parent trace object even after the parent trace has completed', () => { + const parent = { + _traceId: '123', + _spanId: '456', + _baggageItems: { foo: 'bar' }, + _trace: { +- started: ['span'], +- finished: ['span'], ++ started: [], ++ finished: [], + origin: 'synthetics' + } + } + + span = new Span(tracer, recorder, sampler, prioritySampler, { operationName: 'operation', parent }) + +- expect(span.context()._trace.started).to.deep.equal([span]) ++ expect(span.context()._trace).to.equal(parent._trace) ++ expect(parent._trace.started).to.include(span) ++ parent._trace.finished.push(span) ++ expect(span.context()._trace.finished).to.include(span) + expect(span.context()._trace.origin).to.equal('synthetics') + }) + +diff --git a/packages/dd-trace/test/writer.spec.js b/packages/dd-trace/test/writer.spec.js +index fcdb62b59..c290e9172 100644 +--- a/packages/dd-trace/test/writer.spec.js ++++ b/packages/dd-trace/test/writer.spec.js +@@ -17,6 +17,24 @@ describe('Writer', () => { + let tracer + let scope + ++ function captureFormattedTrace () { ++ let formattedTrace ++ ++ format.resetBehavior() ++ format.callsFake(span => ({ ++ meta: Object.assign({}, span.context()._tags), ++ metrics: Object.assign({}, span.context()._metrics) ++ })) ++ ++ encode.resetBehavior() ++ encode.callsFake(trace => { ++ formattedTrace = trace ++ return Buffer.from('encoded') ++ }) ++ ++ return () => formattedTrace ++ } ++ + beforeEach(() => { + scope = { + _wipe: sinon.stub() +@@ -37,6 +55,7 @@ describe('Writer', () => { + _trace: trace, + _sampling: {}, + _tags: {}, ++ _metrics: {}, + _traceFlags: {} + }) + } +@@ -131,24 +150,88 @@ describe('Writer', () => { + expect(prioritySampler.sample).to.have.been.calledWith(span.context()) + }) + +- it('should remove spans from all scopes when the trace is finished', () => { +- trace.started = [span, span] +- trace.finished = [span, span] ++ it('erases span tags and metrics after a completed trace is flushed', () => { ++ const tagKey = `phase3.tag.${Date.now()}` ++ const metricKey = `phase3.metric.${Date.now()}` ++ ++ span.context()._tags[tagKey] = 'tag-value' ++ span.context()._metrics[metricKey] = 42 ++ trace.started = [span] ++ trace.finished = [span] ++ ++ writer.append(span) ++ ++ expect(span.context()._tags).to.not.have.property(tagKey) ++ expect(span.context()._metrics).to.not.have.property(metricKey) ++ }) ++ ++ it('sends formatted data before erasing span metadata', () => { ++ const getFormattedTrace = captureFormattedTrace() ++ const tagKey = `phase3.sent.tag.${Date.now()}` ++ const metricKey = `phase3.sent.metric.${Date.now()}` ++ ++ span.context()._tags[tagKey] = 'sent-tag' ++ span.context()._metrics[metricKey] = 17 ++ trace.started = [span] ++ trace.finished = [span] + + writer.append(span) + +- expect(scope._wipe).to.have.been.calledTwice +- expect(scope._wipe).to.have.been.calledWith(span) ++ expect(getFormattedTrace()[0].meta).to.have.property(tagKey, 'sent-tag') ++ expect(getFormattedTrace()[0].metrics).to.have.property(metricKey, 17) ++ expect(span.context()._tags).to.not.have.property(tagKey) ++ expect(span.context()._metrics).to.not.have.property(metricKey) + }) + +- it('should wait for more spans before removing for consumers', () => { ++ it('does not retain flushed spans in trace span collections', () => { ++ const getFormattedTrace = captureFormattedTrace() ++ const first = span ++ const secondContext = { ++ _trace: trace, ++ _sampling: {}, ++ _tags: { 'phase3.second': 'yes' }, ++ _metrics: { 'phase3.second.metric': 2 }, ++ _traceFlags: {} ++ } ++ const second = { ++ tracer: sinon.stub().returns(tracer), ++ context: sinon.stub().returns(secondContext) ++ } ++ ++ first.context()._tags['phase3.first'] = 'yes' ++ first.context()._metrics['phase3.first.metric'] = 1 ++ trace.started = [first, second] ++ trace.finished = [first, second] ++ ++ writer.append(second) ++ ++ expect(getFormattedTrace()).to.have.length(2) ++ expect(trace.started).to.not.include(first) ++ expect(trace.started).to.not.include(second) ++ expect(trace.finished).to.not.include(first) ++ expect(trace.finished).to.not.include(second) ++ }) ++ ++ it('erases metadata for a flushed single consumer span', () => { ++ const getFormattedTrace = captureFormattedTrace() ++ const tagKey = `phase3.consumer.tag.${Date.now()}` ++ const metricKey = `phase3.consumer.metric.${Date.now()}` ++ + span.context()._tags['span.kind'] = 'consumer' ++ span.context()._tags[tagKey] = 'consumer-value' ++ span.context()._metrics[metricKey] = 99 + trace.started = [span] + trace.finished = [span] + + writer.append(span) + +- expect(scope._wipe).to.not.have.been.called ++ expect(getFormattedTrace()[0].meta).to.include({ ++ 'span.kind': 'consumer', ++ [tagKey]: 'consumer-value' ++ }) ++ expect(getFormattedTrace()[0].metrics).to.have.property(metricKey, 99) ++ expect(span.context()._tags).to.not.have.property(tagKey) ++ expect(span.context()._metrics).to.not.have.property(metricKey) + }) + }) + +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,26 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++ ++ ++if [ ! -x node_modules/.bin/mocha ]; then ++ npm install ++fi ++ ++ ++NEW_TEST_PATTERN='erases span tags and metrics after a completed trace is flushed|sends formatted data before erasing span metadata|does not retain flushed spans in trace span collections|erases metadata for a flushed single consumer span|uses the parent trace object for child spans|uses the parent trace object even after the parent trace has completed' ++TEST_FILES='packages/dd-trace/test/writer.spec.js packages/dd-trace/test/opentracing/span.spec.js' ++ ++case "${1:-}" in ++ base) ++ npx mocha --exit --file packages/dd-trace/test/setup/core.js $TEST_FILES --grep "$NEW_TEST_PATTERN" --invert ++ ;; ++ new) ++ npx mocha --exit --file packages/dd-trace/test/setup/core.js $TEST_FILES --grep "$NEW_TEST_PATTERN" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000065/tests/test.sh b/tasks/format-code-task-000065/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea98e6b346fdc937244e99cdd1ec86525e0b0119 --- /dev/null +++ b/tasks/format-code-task-000065/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/dd-trace/test/opentracing/span.spec.js +packages/dd-trace/test/writer.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-000065/tests/test_command.sh b/tasks/format-code-task-000065/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000065/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-000096/environment/Dockerfile b/tasks/format-code-task-000096/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ad889f1e651afc9b20a6a00983a337dc45a82f07 --- /dev/null +++ b/tasks/format-code-task-000096/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:72506d9170f86814ac51f635dd3cfbec20d08fc6ef48265f0a4c59472ef17f18 diff --git a/tasks/format-code-task-000096/environment/setup/files/blocklist b/tasks/format-code-task-000096/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000096/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000096/environment/setup/setup.sh b/tasks/format-code-task-000096/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000096/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000096/tests/test.patch b/tasks/format-code-task-000096/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1947391a3353065365c5cc5b5eaad61afacc9b73 --- /dev/null +++ b/tasks/format-code-task-000096/tests/test.patch @@ -0,0 +1,79 @@ +diff --git a/core/test/lib/network-recorder-test.js b/core/test/lib/network-recorder-test.js +index 3eba3bc9d464..3811cb5cf73f 100644 +--- a/core/test/lib/network-recorder-test.js ++++ b/core/test/lib/network-recorder-test.js +@@ -587,7 +587,7 @@ describe('network recorder', function() { + localizedFailDescription: 'net::ERR_ABORTED', + rendererStartTime: 500, + networkRequestTime: 500, +- responseHeadersEndTime: -1, ++ responseHeadersEndTime: 500, + networkEndTime: 501, + transferSize: 0, + resourceSize: 0, +diff --git a/core/test/network-records-to-devtools-log.js b/core/test/network-records-to-devtools-log.js +index 8c6ef1e1ef16..abfb7acf024b 100644 +--- a/core/test/network-records-to-devtools-log.js ++++ b/core/test/network-records-to-devtools-log.js +@@ -96,6 +96,7 @@ function extractPartialTiming(networkRecord) { + responseHeadersEndTime, + networkEndTime, + redirectResponseTimestamp, // Generated timestamp added in addRedirectResponseIfNeeded; only used as backup start time. ++ responseTimestamp, + } = networkRecord; + + const requestTime = timeDefined(requestTimeS) ? requestTimeS * 1000 : undefined; +@@ -130,6 +131,7 @@ function extractPartialTiming(networkRecord) { + + return { + redirectResponseTimestamp, ++ responseTimestamp, + rendererStartTime, + networkRequestTime, + requestTime, +@@ -199,11 +201,14 @@ function getNormalizedRequestTiming(networkRecord) { + const networkEndTime = extractedTimes.networkEndTime ?? + (responseHeadersEndTime + defaultTimingOffset); + ++ const responseTimestamp = extractedTimes.responseTimestamp ?? requestTime + receiveHeadersEnd; ++ + return { + rendererStartTime, + networkRequestTime, + responseHeadersEndTime, + networkEndTime, ++ responseTimestamp, + timing: { + // TODO: other `timing` properties could have default values. + ...networkRecord.timing, +@@ -277,7 +282,7 @@ function getResponseReceivedEvent(networkRecord, index, normalizedTiming) { + method: 'Network.responseReceived', + params: { + requestId: getBaseRequestId(networkRecord) || `${idBase}.${index}`, +- timestamp: normalizedTiming.responseHeadersEndTime / 1000, ++ timestamp: normalizedTiming.responseTimestamp / 1000, + type: networkRecord.resourceType || undefined, + response: { + url: networkRecord.url || exampleUrl, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SQU+DMBQHcM58ijq9llIElpjs4M2jB+8L0Mah0EfaMv34FhJ1M9FdNs3i/3cp ++efxbXnhN6rHt1FqbrYhOJQ2WRTGvwdd1fpZFJuVS5mWeR6mUZVpGrDhZRztG5yvLWGSJ/E+5Q+/P ++VPI5f6+dXzfU95VRidsc7xuH5n+d5R/zL8pQD9dAhvmnx2vhe/98/pcXom6NqCu3iRvF5ktQaxXr ++14GsZ/e3D3erhaDBC0NK8yyf4jdXU30RTyXGeUeV0nY1bVU01p1mDVk9HyVcY9vBO2FHw3tqNhWf ++yi55cjuhrq2F0f6F7DO3OtTDcXNuP7YfcdwTV3rriToXenh83xH/9T8FAAAAAAAAAAAAAAAAAAAA ++APgtb7hgunsAKAAA +diff --git 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-000096/tests/test.sh b/tasks/format-code-task-000096/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..99a6c5f4920ba462b10106b63f2d6dc359142318 --- /dev/null +++ b/tasks/format-code-task-000096/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +core/test/lib/network-recorder-test.js +core/test/network-records-to-devtools-log.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-000096/tests/test_command.sh b/tasks/format-code-task-000096/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000096/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000098/environment/Dockerfile b/tasks/format-code-task-000098/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..98e5d48ac0881acff29efa1c478ceb805151a953 --- /dev/null +++ b/tasks/format-code-task-000098/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6d9f359d81f45e10d39168c0767ae25577b28f6d17cc7e6c3b99d19f7492480a diff --git a/tasks/format-code-task-000098/environment/setup/files/blocklist b/tasks/format-code-task-000098/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000098/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000098/environment/setup/setup.sh b/tasks/format-code-task-000098/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000098/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000098/tests/test.patch b/tasks/format-code-task-000098/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d4bf4736e30cc89c4c153b4529cfb181b59bfb92 --- /dev/null +++ b/tasks/format-code-task-000098/tests/test.patch @@ -0,0 +1,184 @@ +diff --git a/lighthouse-core/test/lib/i18n/i18n-test.js b/lighthouse-core/test/lib/i18n/i18n-test.js +index 53c5789db..a33dc7250 100644 +--- a/lighthouse-core/test/lib/i18n/i18n-test.js ++++ b/lighthouse-core/test/lib/i18n/i18n-test.js +@@ -104,9 +104,13 @@ describe('i18n', () => { + helloPercentWorld: 'Hello {in, number, extendedPercent} World', + helloWorldMultiReplace: '{hello} {world}', + helloPlural: '{itemCount, plural, =1{1 hello} other{hellos}}', ++ helloLongMissing: 'This deliberately longer localized message contains ' + ++ '{laterValue} so missing value errors still include the full message context.', + helloPluralNestedICU: '{itemCount, plural, ' + + '=1{1 hello {in, number, bytes}} ' + + 'other{hellos {in, number, bytes}}}', ++ ruPluralCategories: '{itemCount, plural, one{one item} few{few items} ' + ++ 'many{many items} other{other items}}', + helloPluralNestedPluralAndICU: '{itemCount, plural, ' + + '=1{{innerItemCount, plural, ' + + '=1{1 hello 1 goodbye {in, number, bytes}} ' + +@@ -147,15 +151,32 @@ describe('i18n', () => { + expect(helloPercentStr).toBeDisplayString('Hello 43.08% World'); + }); + ++ ++ ++ ++ ++ ++ function expectThrowIdentifies(fn, icuMessage, reference) { ++ let thrownError; ++ try { ++ fn(); ++ } catch (err) { ++ thrownError = err; ++ } ++ ++ expect(thrownError).toBeTruthy(); ++ expect(thrownError.message).toContain(icuMessage); ++ expect(thrownError.message).toContain(reference); ++ } ++ + it('throws an error when values are needed but not provided', () => { +- expect(_ => i18n.getFormatted(str_(UIStrings.helloBytesWorld), 'en-US')) +- .toThrow(`ICU Message contains a value reference ("in") that wasn't provided`); ++ expectThrowIdentifies(_ => i18n.getFormatted(str_(UIStrings.helloBytesWorld), 'en-US'), ++ UIStrings.helloBytesWorld, 'in'); + }); + + it('throws an error when a value is missing', () => { +- expect(_ => i18n.getFormatted(str_(UIStrings.helloWorldMultiReplace, +- {hello: 'hello'}), 'en-US')) +- .toThrow(`ICU Message contains a value reference ("world") that wasn't provided`); ++ expectThrowIdentifies(_ => i18n.getFormatted(str_(UIStrings.helloWorldMultiReplace, ++ {hello: 'hello'}), 'en-US'), UIStrings.helloWorldMultiReplace, 'world'); + }); + + it('formats a message with plurals', () => { +@@ -164,8 +185,22 @@ describe('i18n', () => { + }); + + it('throws an error when a plural control value is missing', () => { +- expect(_ => i18n.getFormatted(str_(UIStrings.helloPlural), 'en-US')) +- .toThrow(`ICU Message contains a value reference ("itemCount") that wasn't provided`); ++ expectThrowIdentifies(_ => i18n.getFormatted(str_(UIStrings.helloPlural), 'en-US'), ++ UIStrings.helloPlural, 'itemCount'); ++ }); ++ ++ it('throws contextual errors for longer messages with missing values', () => { ++ expectThrowIdentifies(_ => i18n.getFormatted(str_(UIStrings.helloLongMissing), 'en-US'), ++ UIStrings.helloLongMissing, 'laterValue'); ++ }); ++ ++ it('throws contextual errors for missing values inside plural branches', () => { ++ const helloStr = str_(UIStrings.helloPluralNestedICU, { ++ itemCount: 3, ++ }); ++ ++ expectThrowIdentifies(_ => i18n.getFormatted(helloStr, 'en-US'), ++ UIStrings.helloPluralNestedICU, 'in'); + }); + + it('formats a message with plurals and nested custom ICU', () => { +@@ -179,5 +214,70 @@ describe('i18n', () => { + in: 1875}); + expect(helloStr).toBeDisplayString('hellos 1 goodbye 2'); + }); ++ ++ it('throws an error if a string value is used for a numeric placeholder', () => { ++ const helloStr = str_(UIStrings.helloBytesWorld, { ++ in: 'not-a-valid-input', ++ }); ++ ++ expectThrowIdentifies(_ => i18n.getFormatted(helloStr, 'en-US'), ++ UIStrings.helloBytesWorld, 'in'); ++ }); ++ ++ it('throws an error if undefined is used for a numeric placeholder', () => { ++ const helloStr = str_(UIStrings.helloTimeInMsWorld, { ++ timeInMs: undefined, ++ }); ++ ++ expectThrowIdentifies(_ => i18n.getFormatted(helloStr, 'en-US'), ++ UIStrings.helloTimeInMsWorld, 'timeInMs'); ++ }); ++ ++ it('throws an error if a boolean value is used for a milliseconds placeholder', () => { ++ const helloStr = str_(UIStrings.helloMsWorld, { ++ in: false, ++ }); ++ ++ expectThrowIdentifies(_ => i18n.getFormatted(helloStr, 'en-US'), ++ UIStrings.helloMsWorld, 'in'); ++ }); ++ ++ it('formats plural messages when Intl.PluralRules is unavailable in the polyfill path', () => { ++ const originalNumberFormat = Intl.NumberFormat; ++ const originalPluralRules = Intl.PluralRules; ++ ++ try { ++ ++ Intl.NumberFormat.polyfilled = true; ++ delete Intl.PluralRules; ++ jest.resetModules(); ++ ++ const freshI18n = require('../../../lib/i18n/i18n.js'); ++ const freshStr = freshI18n.createMessageInstanceIdFn(__filename, UIStrings); ++ ++ const singular = freshI18n.getFormatted(freshStr(UIStrings.helloPlural, { ++ itemCount: 1, ++ }), 'en-US'); ++ const plural = freshI18n.getFormatted(freshStr(UIStrings.helloPlural, { ++ itemCount: 2, ++ }), 'en-US'); ++ const russianFew = freshI18n.getFormatted(freshStr(UIStrings.ruPluralCategories, { ++ itemCount: 2, ++ }), 'ru'); ++ ++ expect(singular).toBeDisplayString('1 hello'); ++ expect(plural).toBeDisplayString('hellos'); ++ expect(russianFew).toBeDisplayString('few items'); ++ } finally { ++ Intl.NumberFormat = originalNumberFormat; ++ if (originalPluralRules) { ++ Intl.PluralRules = originalPluralRules; ++ } else { ++ delete Intl.PluralRules; ++ } ++ ++ jest.resetModules(); ++ } ++ }); + }); + }); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,27 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++if [ ! -x node_modules/.bin/jest ] || \ ++ ! node -e "require.resolve('intl-messageformat')" >/dev/null 2>&1 || \ ++ (grep -q '"intl-pluralrules"' package.json && ! node -e "require.resolve('intl-pluralrules')" >/dev/null 2>&1); then ++ npm_config_loglevel=error npx --yes yarn@1.22.22 install --frozen-lockfile --ignore-engines --ignore-scripts --non-interactive ++fi ++ ++TEST_FILE="lighthouse-core/test/lib/i18n/i18n-test.js" ++NEW_PATTERN='throws an error when values are needed but not provided|throws an error when a value is missing|throws an error when a plural control value is missing|throws contextual errors for longer messages with missing values|throws contextual errors for missing values inside plural branches|throws an error if a string value is used for a numeric placeholder|throws an error if undefined is used for a numeric placeholder|throws an error if a boolean value is used for a milliseconds placeholder|formats plural messages when Intl\.PluralRules is unavailable in the polyfill path' ++ ++case "${1:-}" in ++ base) ++ node node_modules/.bin/jest "$TEST_FILE" --runInBand --testNamePattern="^(?!.*(${NEW_PATTERN})).*$" ++ ;; ++ new) ++ node node_modules/.bin/jest "$TEST_FILE" --runInBand --testNamePattern="$NEW_PATTERN" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000098/tests/test.sh b/tasks/format-code-task-000098/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b109caf419554fcf88c12733b8fa1d5c59df17dc --- /dev/null +++ b/tasks/format-code-task-000098/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' +lighthouse-core/test/lib/i18n/i18n-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-000098/tests/test_command.sh b/tasks/format-code-task-000098/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000098/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-000202/environment/Dockerfile b/tasks/format-code-task-000202/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..848e9d9b40631ad45c4d1f27bc218443eb81033f --- /dev/null +++ b/tasks/format-code-task-000202/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:653a11da26846e3dc7acc7d8f099c4c6a675d670a3abc83058360633fbd10f22 diff --git a/tasks/format-code-task-000202/environment/setup/files/blocklist b/tasks/format-code-task-000202/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000202/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000202/environment/setup/setup.sh b/tasks/format-code-task-000202/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000202/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000202/tests/test.patch b/tasks/format-code-task-000202/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b121320894557132064c89456bc8af56ca1a828e --- /dev/null +++ b/tasks/format-code-task-000202/tests/test.patch @@ -0,0 +1,129 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..6e5415309 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_add_zero.py -v"] ++} +diff --git a/tests/test_add_zero.py b/tests/test_add_zero.py +new file mode 100644 +index 000000000..2deaf9095 +--- /dev/null ++++ b/tests/test_add_zero.py +@@ -0,0 +1,101 @@ ++ ++ ++ ++ ++ ++import pytest ++ ++import pennylane as qml ++ ++ ++class TestObservableAddZero: ++ def test_sum_of_observables_reproduction(self): ++ ++ H = sum([qml.PauliX(i) for i in range(10)]) ++ expected = qml.Hamiltonian([1.0] * 10, [qml.PauliX(i) for i in range(10)]) ++ assert isinstance(H, qml.Hamiltonian) ++ assert H.compare(expected) ++ ++ def test_observable_plus_zero_returns_self(self): ++ ++ obs = qml.PauliX(0) ++ result = obs + 0 ++ ++ assert isinstance(result, type(obs)) or result.compare(obs) ++ ++ def test_zero_plus_observable_returns_self(self): ++ ++ obs = qml.PauliY(2) ++ result = 0 + obs ++ assert isinstance(result, type(obs)) or result.compare(obs) ++ ++ def test_observable_plus_zero_float(self): ++ ++ obs = qml.PauliZ(1) ++ result = obs + 0.0 ++ assert result.compare(obs) ++ ++ def test_observable_plus_nonzero_raises(self): ++ ++ obs = qml.PauliX(0) ++ with pytest.raises((ValueError, TypeError)): ++ _ = obs + 5 ++ ++ def test_observable_plus_observable_still_works(self): ++ ++ result = qml.PauliX(0) + qml.PauliZ(1) ++ expected = qml.Hamiltonian([1.0, 1.0], [qml.PauliX(0), qml.PauliZ(1)]) ++ assert isinstance(result, qml.Hamiltonian) ++ assert result.compare(expected) ++ ++ ++class TestTensorAddZero: ++ def test_tensor_plus_zero(self): ++ ++ T = qml.PauliX(0) @ qml.PauliZ(1) ++ result = T + 0 ++ assert result.compare(T) ++ ++ def test_zero_plus_tensor(self): ++ ++ T = qml.PauliX(0) @ qml.PauliZ(1) ++ result = 0 + T ++ assert result.compare(T) ++ ++ ++class TestHamiltonianAddZero: ++ def test_hamiltonian_plus_zero(self): ++ ++ H = qml.Hamiltonian([1.0, 2.0], [qml.PauliX(0), qml.PauliZ(1)]) ++ result = H + 0 ++ assert result.compare(H) ++ ++ def test_zero_plus_hamiltonian(self): ++ ++ H = qml.Hamiltonian([1.0, 2.0], [qml.PauliX(0), qml.PauliZ(1)]) ++ result = 0 + H ++ assert result.compare(H) ++ ++ def test_hamiltonian_iadd_zero(self): ++ ++ H = qml.Hamiltonian([1.0, 2.0], [qml.PauliX(0), qml.PauliZ(1)]) ++ expected = qml.Hamiltonian([1.0, 2.0], [qml.PauliX(0), qml.PauliZ(1)]) ++ H += 0 ++ assert H.compare(expected) ++ ++ def test_hamiltonian_plus_nonzero_raises(self): ++ ++ H = qml.Hamiltonian([1.0], [qml.PauliX(0)]) ++ with pytest.raises((ValueError, TypeError)): ++ _ = H + 5 ++ ++ def test_sum_of_hamiltonians(self): ++ ++ terms = [qml.Hamiltonian([1.0], [qml.PauliX(i)]) for i in range(3)] ++ H = sum(terms) ++ expected = qml.Hamiltonian( ++ [1.0, 1.0, 1.0], ++ [qml.PauliX(0), qml.PauliX(1), qml.PauliX(2)], ++ ) ++ assert isinstance(H, qml.Hamiltonian) ++ assert H.compare(expected) +diff --git 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_add_zero.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000202/tests/test.sh b/tasks/format-code-task-000202/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f80e8b729d79fa708cb976de3acca8e5c937515 --- /dev/null +++ b/tasks/format-code-task-000202/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_add_zero.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-000202/tests/test_command.sh b/tasks/format-code-task-000202/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000202/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000205/environment/Dockerfile b/tasks/format-code-task-000205/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6f3cf93745c323ae562a6f3b0bce646d7d2b9027 --- /dev/null +++ b/tasks/format-code-task-000205/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0d59d94464ca515c8b62287423c336869d1a7e2ca0c521e9c38d53c7168670fd diff --git a/tasks/format-code-task-000205/environment/setup/files/blocklist b/tasks/format-code-task-000205/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000205/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000205/environment/setup/setup.sh b/tasks/format-code-task-000205/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000205/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000205/tests/test.patch b/tasks/format-code-task-000205/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7c1d524fbe938554d664a5692285794cb8b882b5 --- /dev/null +++ b/tasks/format-code-task-000205/tests/test.patch @@ -0,0 +1,273 @@ +diff --git a/test/cases/plugin-hmr-data.js b/test/cases/plugin-hmr-data.js +new file mode 100644 +index 0000000..e34f322 +--- /dev/null ++++ b/test/cases/plugin-hmr-data.js +@@ -0,0 +1,246 @@ ++let plugin = require('../../lib/plugin-hmr'); ++let { expect } = require('../nollup'); ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++function createEnv (defs, options = {}) { ++ defs = JSON.parse(JSON.stringify(defs)); ++ options.bundleId = options.bundleId || ''; ++ ++ let window = { location: { host: 'example.com' } }; ++ let instances = []; ++ let modules = []; ++ let stdout = []; ++ let codeById = defs.map(d => d.code); ++ ++ let console = { ++ log: function (...args) { ++ stdout.push(args.join(' ')); ++ } ++ }; ++ ++ let _ws = { ++ onmessage: null, ++ url: null, ++ send: function (data) { ++ if (data.changes) { ++ data.changes.forEach(function (c) { ++ if (!c.removed) { ++ codeById[c.id] = c.code; ++ } ++ }); ++ } ++ this.onmessage({ data: JSON.stringify(data) }); ++ } ++ }; ++ ++ let WebSocket = function (url) { ++ _ws.url = url; ++ return _ws; ++ }; ++ ++ let plugin_instance = plugin(options); ++ eval(plugin_instance.nollupBundleInit()); ++ ++ let createInstance = function (id) { ++ let module = { ++ id: id, ++ dependencies: defs[id].dependencies.slice(0) ++ }; ++ ++ eval(plugin_instance.nollupModuleInit()); ++ instances[id] = module; ++ eval('(' + codeById[id] + ')()'); ++ return module; ++ }; ++ ++ defs.forEach(function (d, i) { ++ createInstance(i); ++ }); ++ ++ return { ++ instances, ++ ws: _ws, ++ console, ++ window, ++ stdout, ++ recreate: createInstance ++ }; ++} ++ ++describe('plugin-hmr hot data', () => { ++ it ('should expose undefined module.hot.data on the first run', () => { ++ let env = createEnv([{ ++ dependencies: [], ++ code: `function () { ++ console.log('data=' + String(module.hot.data)); ++ }` ++ }]); ++ ++ expect(env.stdout.length).to.equal(1); ++ expect(env.stdout[0]).to.equal('data=undefined'); ++ }); ++ ++ it ('should pass a fresh empty object to the dispose callback', () => { ++ let env = createEnv([{ ++ dependencies: [1], ++ code: `function () { module.hot.accept(function () {}); }` ++ }, { ++ dependencies: [], ++ code: `function () { ++ module.hot.dispose(function (data) { ++ console.log('isObject=' + (data !== null && typeof data === 'object')); ++ console.log('keys=' + Object.keys(data).length); ++ }); ++ }` ++ }]); ++ ++ env.ws.send({ ++ changes: [{ ++ id: 1, ++ code: `function () {}` ++ }] ++ }); ++ ++ expect(env.stdout).to.deep.equal(['isObject=true', 'keys=0']); ++ }); ++ ++ it ('should make whatever dispose wrote available as module.hot.data on the replacement', () => { ++ let env = createEnv([{ ++ dependencies: [1], ++ code: `function () { module.hot.accept(function () {}); }` ++ }, { ++ dependencies: [], ++ code: `function () { ++ module.hot.dispose(function (data) { ++ data.count = 42; ++ data.label = 'kept'; ++ }); ++ }` ++ }]); ++ ++ env.ws.send({ ++ changes: [{ ++ id: 1, ++ code: `function () { ++ console.log('count=' + module.hot.data.count); ++ console.log('label=' + module.hot.data.label); ++ }` ++ }] ++ }); ++ ++ env.recreate(1); ++ ++ expect(env.stdout).to.deep.equal(['count=42', 'label=kept']); ++ }); ++ ++ it ('should give each update its own fresh hand-off object', () => { ++ let env = createEnv([{ ++ dependencies: [1], ++ code: `function () { module.hot.accept(function () {}); }` ++ }, { ++ dependencies: [], ++ code: `function () { ++ module.hot.dispose(function (data) { ++ data.first = true; ++ }); ++ }` ++ }]); ++ ++ ++ ++ env.ws.send({ ++ changes: [{ ++ id: 1, ++ code: `function () { ++ module.hot.dispose(function (data) { ++ console.log('hadFirst=' + (data.first === true)); ++ console.log('keys=' + Object.keys(data).length); ++ }); ++ }` ++ }] ++ }); ++ ++ env.recreate(1); ++ ++ ++ ++ env.ws.send({ ++ changes: [{ ++ id: 1, ++ code: `function () {}` ++ }] ++ }); ++ ++ expect(env.stdout).to.deep.equal(['hadFirst=false', 'keys=0']); ++ }); ++ ++ it ('should let a module carry state forward across several updates', () => { ++ let factory = `function () { ++ var previous = module.hot.data && module.hot.data.count || 0; ++ console.log('count=' + previous); ++ module.hot.dispose(function (data) { ++ data.count = previous + 1; ++ }); ++ }`; ++ ++ let env = createEnv([{ ++ dependencies: [1], ++ code: `function () { module.hot.accept(function () {}); }` ++ }, { ++ dependencies: [], ++ code: factory ++ }]); ++ ++ env.ws.send({ changes: [{ id: 1, code: factory }] }); ++ env.recreate(1); ++ ++ env.ws.send({ changes: [{ id: 1, code: factory }] }); ++ env.recreate(1); ++ ++ expect(env.stdout).to.deep.equal(['count=0', 'count=1', 'count=2']); ++ }); ++ ++ it ('should track hot data independently per module', () => { ++ let env = createEnv([{ ++ dependencies: [1, 2], ++ code: `function () { module.hot.accept(function () {}); }` ++ }, { ++ dependencies: [], ++ code: `function () { ++ module.hot.dispose(function (data) { data.who = 'one'; }); ++ }` ++ }, { ++ dependencies: [], ++ code: `function () { ++ module.hot.dispose(function (data) { data.who = 'two'; }); ++ }` ++ }]); ++ ++ env.ws.send({ ++ changes: [{ ++ id: 1, ++ code: `function () { console.log('mod1 sees ' + module.hot.data.who); }` ++ }] ++ }); ++ env.recreate(1); ++ ++ ++ env.ws.send({ ++ changes: [{ ++ id: 2, ++ code: `function () { console.log('mod2 sees ' + module.hot.data.who); }` ++ }] ++ }); ++ env.recreate(2); ++ ++ expect(env.stdout).to.deep.equal(['mod1 sees one', 'mod2 sees two']); ++ }); ++}); +diff --git 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 ++ ++ ++ ++ ++./node_modules/.bin/mocha "test/cases/plugin-hmr.js" ++ ++ ++./node_modules/.bin/mocha "test/cases/plugin-hmr-data.js" diff --git a/tasks/format-code-task-000205/tests/test.sh b/tasks/format-code-task-000205/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f6c6b3d4401341453d0d5443ecbfc56e6db6a38a --- /dev/null +++ b/tasks/format-code-task-000205/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/cases/plugin-hmr-data.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-000205/tests/test_command.sh b/tasks/format-code-task-000205/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000205/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000233/environment/Dockerfile b/tasks/format-code-task-000233/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c47af10fd3b8594d7e7ea0be5887eff8b1f281bd --- /dev/null +++ b/tasks/format-code-task-000233/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d5e1a3f81b6eaaecdd1b8d6babb67e3f53a561624ed7f662672668e355e4bc62 diff --git a/tasks/format-code-task-000233/environment/setup/files/blocklist b/tasks/format-code-task-000233/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000233/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000233/environment/setup/setup.sh b/tasks/format-code-task-000233/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000233/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000233/tests/test.patch b/tasks/format-code-task-000233/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ccde83564ef3b81f29ae02206b02b632dd195a05 --- /dev/null +++ b/tasks/format-code-task-000233/tests/test.patch @@ -0,0 +1,49 @@ +diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py +index ca047a744e..fc43ca6396 100644 +--- a/tests/core/calculators/vasp/test_vasp.py ++++ b/tests/core/calculators/vasp/test_vasp.py +@@ -693,6 +693,24 @@ def test_lorbit(): + assert calc.int_params["lorbit"] == 11 + + ++def test_d4(): ++ atoms = bulk("Cu") ++ calc = Vasp(atoms, xc="r2scan") ++ assert calc.float_params["vdw_s6"] == 1.0 ++ assert calc.float_params["vdw_s8"] == 0.60187490 ++ assert calc.float_params["vdw_a1"] == 0.51559235 ++ assert calc.float_params["vdw_a2"] == 5.77342911 ++ ++ calc = Vasp(atoms, metagga="r2scan") ++ assert calc.float_params["vdw_s6"] == 1.0 ++ assert calc.float_params["vdw_s8"] == 0.60187490 ++ assert calc.float_params["vdw_a1"] == 0.51559235 ++ assert calc.float_params["vdw_a2"] == 5.77342911 ++ ++ calc = Vasp(atoms, metagga="r2scan", vdw_s6=2.0) ++ assert calc.float_params["vdw_s6"] == 2.0 ++ ++ + def test_setups(): + atoms = bulk("Cu") + calc = Vasp(atoms, preset="BulkSet") +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+3S3wqCMBQGcK97ivMCbi5de5yYUyhQJ25KvX3T6A9BdaNE9f0udg5ssDO+sbzf ++V8W2bAYeLSUJlJRTDR7r1Au5FkJlMkvSKBFiEwrJxSa60zuvO6Kos9a/Ovdu/0uxW/6+dH5rbF3r ++pmBuN98d7/IXqbrmn2Yq5J9t1iqiZL4Rnvvz/E1BU/B5WawuDWfD+B/yfcPbo9/ZhuKaQhd2aVwc ++N7YrudGV6Svtbef4oF17/kBjx9ojxQeKh9WnnwcAAAAAAAAAAAAAAAAAAAAA8NNOJQSKHAAoAAA= +diff --git 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-000233/tests/test.sh b/tasks/format-code-task-000233/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..20ed4cfdd4948964fca9fe8e26aff2001181ef1d --- /dev/null +++ b/tasks/format-code-task-000233/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/core/calculators/vasp/test_vasp.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-000233/tests/test_command.sh b/tasks/format-code-task-000233/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000233/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000234/environment/Dockerfile b/tasks/format-code-task-000234/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a73c5205ba03bd0e3091db02a07b29df5acd84d8 --- /dev/null +++ b/tasks/format-code-task-000234/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:86d2cd5cdbb63c8284085e3b43834b735c204066d454d9031c320b9d1f9b278e diff --git a/tasks/format-code-task-000234/environment/setup/files/blocklist b/tasks/format-code-task-000234/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000234/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000234/environment/setup/setup.sh b/tasks/format-code-task-000234/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000234/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000234/tests/test.patch b/tasks/format-code-task-000234/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2613fa5d70e96e4259da2b284788b1e079fd82e1 --- /dev/null +++ b/tasks/format-code-task-000234/tests/test.patch @@ -0,0 +1,187 @@ +diff --git a/conftest.py b/conftest.py +new file mode 100644 +index 00000000..4fc9a69c +--- /dev/null ++++ b/conftest.py +@@ -0,0 +1,25 @@ ++ ++ ++ ++ ++ ++ ++import collections ++import collections.abc ++ ++for _name in ( ++ "Hashable", ++ "Mapping", ++ "MutableMapping", ++ "Sequence", ++ "Iterable", ++ "Iterator", ++ "Callable", ++ "Container", ++ "Sized", ++ "Set", ++ "MutableSet", ++ "ByteString", ++): ++ if not hasattr(collections, _name): ++ setattr(collections, _name, getattr(collections.abc, _name)) +diff --git a/quarkchain/tests/test_full_shard_id.py b/quarkchain/tests/test_full_shard_id.py +new file mode 100644 +index 00000000..21f29cfe +--- /dev/null ++++ b/quarkchain/tests/test_full_shard_id.py +@@ -0,0 +1,125 @@ ++import unittest ++ ++from quarkchain.core import Branch, Address, Identity ++ ++ ++def make_full_shard_id(chain_id, shard_size, shard_id): ++ return (chain_id << 16) | shard_size | shard_id ++ ++ ++class TestBranchChainId(unittest.TestCase): ++ def test_zero_chain_id_backward_compatible(self): ++ b = Branch(make_full_shard_id(0, 8, 6)) ++ self.assertEqual(b.get_chain_id(), 0) ++ self.assertEqual(b.get_shard_size(), 8) ++ self.assertEqual(b.get_shard_id(), 6) ++ self.assertEqual(b.get_full_shard_id(), 8 | 6) ++ ++ def test_nonzero_chain_id(self): ++ value = make_full_shard_id(3, 8, 6) ++ b = Branch(value) ++ self.assertEqual(b.get_chain_id(), 3) ++ self.assertEqual(b.get_shard_size(), 8) ++ self.assertEqual(b.get_shard_id(), 6) ++ self.assertEqual(b.get_full_shard_id(), value) ++ ++ def test_chain_id_does_not_affect_shard_fields(self): ++ ++ for chain_id in (0, 1, 2, 7, 100, 65535): ++ b = Branch(make_full_shard_id(chain_id, 4, 2)) ++ self.assertEqual(b.get_shard_size(), 4) ++ self.assertEqual(b.get_shard_id(), 2) ++ self.assertEqual(b.get_chain_id(), chain_id) ++ ++ def test_single_shard(self): ++ b = Branch(make_full_shard_id(5, 1, 0)) ++ self.assertEqual(b.get_shard_size(), 1) ++ self.assertEqual(b.get_shard_id(), 0) ++ self.assertEqual(b.get_chain_id(), 5) ++ ++ ++class TestBranchIsInBranch(unittest.TestCase): ++ def setUp(self): ++ ++ self.branch = Branch(make_full_shard_id(3, 4, 2)) ++ ++ def test_matching_key(self): ++ ++ key = (3 << 16) | 6 ++ self.assertTrue(self.branch.is_in_branch(key)) ++ ++ def test_matching_key_other_high_bits(self): ++ ++ key = (3 << 16) | 14 ++ self.assertTrue(self.branch.is_in_branch(key)) ++ ++ def test_wrong_chain(self): ++ key = (2 << 16) | 6 ++ self.assertFalse(self.branch.is_in_branch(key)) ++ ++ def test_wrong_shard(self): ++ key = (3 << 16) | 5 ++ self.assertFalse(self.branch.is_in_branch(key)) ++ ++ ++class TestAddressFullShardId(unittest.TestCase): ++ def test_computes_full_shard_id(self): ++ ++ addr = Address(bytes(20), (5 << 16) | 0b1011) ++ ++ self.assertEqual(addr.get_full_shard_id(4), make_full_shard_id(5, 4, 3)) ++ ++ self.assertEqual(addr.get_full_shard_id(8), make_full_shard_id(5, 8, 3)) ++ ++ self.assertEqual(addr.get_full_shard_id(1), make_full_shard_id(5, 1, 0)) ++ ++ def test_zero_chain(self): ++ addr = Address(bytes(20), 0b1101) ++ self.assertEqual(addr.get_full_shard_id(4), make_full_shard_id(0, 4, 1)) ++ ++ def test_invalid_shard_size_raises(self): ++ addr = Address(bytes(20), (1 << 16) | 5) ++ with self.assertRaises(RuntimeError): ++ addr.get_full_shard_id(3) ++ with self.assertRaises(RuntimeError): ++ addr.get_full_shard_id(6) ++ ++ ++class TestAddressInBranch(unittest.TestCase): ++ def test_rehome_keeps_recipient_and_adopts_chain_and_shard(self): ++ recipient = Identity.create_random_identity().get_recipient() ++ ++ addr = Address(recipient, (1 << 16) | 0b1101) ++ ++ branch = Branch(make_full_shard_id(4, 4, 2)) ++ new_addr = addr.address_in_branch(branch) ++ ++ self.assertEqual(new_addr.recipient, recipient) ++ ++ self.assertEqual(new_addr.full_shard_key, (4 << 16) | 14) ++ ++ self.assertTrue(branch.is_in_branch(new_addr.full_shard_key)) ++ ++ def test_rehome_single_shard(self): ++ recipient = Identity.create_random_identity().get_recipient() ++ addr = Address(recipient, (2 << 16) | 0b111) ++ branch = Branch(make_full_shard_id(0, 1, 0)) ++ new_addr = addr.address_in_branch(branch) ++ self.assertEqual(new_addr.recipient, recipient) ++ self.assertEqual(new_addr.full_shard_key, 0b111) ++ self.assertTrue(branch.is_in_branch(new_addr.full_shard_key)) ++ ++ ++class TestConsistency(unittest.TestCase): ++ def test_address_branch_round_trip(self): ++ addr = Address(bytes(20), (6 << 16) | 0b10110) ++ for shard_size in (1, 2, 4, 8, 16): ++ full_shard_id = addr.get_full_shard_id(shard_size) ++ branch = Branch(full_shard_id) ++ self.assertEqual(branch.get_chain_id(), 6) ++ self.assertEqual(branch.get_shard_size(), shard_size) ++ self.assertTrue(branch.is_in_branch(addr.full_shard_key)) ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++python -m pytest quarkchain/tests/test_core.py -q ++ ++ ++python -m pytest quarkchain/tests/test_full_shard_id.py -q diff --git a/tasks/format-code-task-000234/tests/test.sh b/tasks/format-code-task-000234/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..16632e9b04dea96ffa9f31c67e642e70a0bb3bce --- /dev/null +++ b/tasks/format-code-task-000234/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' +conftest.py +quarkchain/tests/test_full_shard_id.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-000234/tests/test_command.sh b/tasks/format-code-task-000234/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000234/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000250/environment/Dockerfile b/tasks/format-code-task-000250/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cf23eaa8bb2eae11f34f7b1f9c6a5aae60488c72 --- /dev/null +++ b/tasks/format-code-task-000250/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:aced6a9958199f53d68f77067aeb1e072de758b1b88a56b96bbd96f1fb4b6d78 diff --git a/tasks/format-code-task-000250/environment/setup/files/blocklist b/tasks/format-code-task-000250/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000250/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000250/environment/setup/setup.sh b/tasks/format-code-task-000250/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000250/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000250/tests/test.patch b/tasks/format-code-task-000250/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5e9c7593acde915699b62fee1f560efb164fb2ab --- /dev/null +++ b/tasks/format-code-task-000250/tests/test.patch @@ -0,0 +1,63 @@ +diff --git a/java-surefire/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java b/java-surefire/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java +index 543d344e95a..72ea813cb42 100644 +--- a/java-surefire/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java ++++ b/java-surefire/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java +@@ -125,6 +125,13 @@ public void shouldSupportSkippedTestWithoutTimeAttribute() throws XMLStreamExcep + assertThat(publicClass.getTests(), is(4)); + } + ++ @Test ++ public void output_of_junit_5_2_test_without_display_name() throws XMLStreamException { ++ parse("TEST-#29.xml"); ++ assertThat(index.get(")").getTests(), is(1)); ++ } ++ ++ + private void parse(String path) throws XMLStreamException { + StaxParser parser = new StaxParser(index); + File xmlFile; +diff --git a/java-surefire/src/test/resources/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest/TEST-#29.xml b/java-surefire/src/test/resources/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest/TEST-#29.xml +new file mode 100644 +index 00000000000..9ae0b9a8508 +--- /dev/null ++++ b/java-surefire/src/test/resources/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest/TEST-#29.xml +@@ -0,0 +1,7 @@ ++ ++ ++ ++ ++ ++ ++ +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,16 @@ ++H4sIAAAAAAAAA+1W3XPTOBDPs/+KJTwAD7bz2TIdx8zdwEEZWjpNbqZvjGLLjags+SQ5Sf971qJ2 ++nDa9AhOOA/TrTGNpP6Vd7W4wLxlPP1CxDDvfCz3E4XhsfxG3f+13fzzo49+oNxp2ev3++HDYgfF3 ++86iFUhuiADpKSvNvfA/Rf1IEm/hragwTlzpY53yvNqoAH4xG98V/0DsYNPHHfxj/ES470NurF/fg ++N49/9AKjDUuqNJNi0u0HvS5QkcgUM2HS/Xv2l/+8+yL2ojo5ANmFnnQXxhRHYZiTJRUBKUiyoIFU ++l+H01Wx2fPp6GqIm1OVBAyt4tNasEV6tVsFqaMUGvV4/vDh5N0U9OfGZwKiIhG7Ja3akLfmdTIix ++7n6ZFy0lu1Ap0bu0rHXaPArfagpwqxujvqhQMmOc6tgqr5fxjamIpXFKM1JyE4X4XW8rWkjNjFSs ++ltzevo5bvlZKEiqMIrytxJJKxePa70o6uOO83RhEYcXZllSUU6LRfEQFmXOaxkaVNArrVRQ2HG0x ++LUihF9K05DLC9ZbghmdztPDu2Vp7rWuICl5eMnG++4ZuEX/Be7rvhHcozcUgZZN1zcISI5IYtqRn ++20m6tbnJz+1tq+u2eNS8g9j70RXLYZ9o9X9DtfmQyDwnIg30Yn82Hpj/htjt6/4/PBwfVP3/YDBy ++/f+/wONH4ZyJcE70wktSsEkwp6nnPYbpiplkAUbCW7Ik8ByeKvpPyRRNIZMK3v5x8SfkMi2xQkCp ++cXd+DR+R07cl1UcS5c+8lC59/VnTR6umUv1K6FJRSPDyZQ4nFT80EwZdM23g6fy6IBrLK1wwInMG ++OVMKzZoFMcBJcqVBy5wCUYZlWK/0My+/SpkCv2hOEW6y28ORAeJdlK25F6IIntTTwxPPTUduOnLT ++0f/gnn6a6ah+W1WVO67eKedQEIUBgLP3J1Ux5fg+OVTX7eVLAeyGyT8F/6W+YsUMK5QGXz9Yq9om ++msqc0oKKFGvUdV2bt60U/E6N/mq7OxVmSgqDpr/lFOelwLpOATvxJTVQSVgj1cfGQtUyMjwkWqgI ++k+nNemrI+g3OLJyqmRV4mRHGj7NTaZ2Y2Az7Ild+dDN2cHBwcHBwcHBwcHBwcHBwcHBwcNgjPgEX ++PvvDACgAAA== +diff --git 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-000250/tests/test.sh b/tasks/format-code-task-000250/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2344f83d31d4ce76f7b7426f4193304be356107f --- /dev/null +++ b/tasks/format-code-task-000250/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' +java-surefire/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java +java-surefire/src/test/resources/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest/TEST-#29.xml +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-000250/tests/test_command.sh b/tasks/format-code-task-000250/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000250/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000257/environment/Dockerfile b/tasks/format-code-task-000257/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cd0f98da818ebe011564abbfcc502e8f096c29ba --- /dev/null +++ b/tasks/format-code-task-000257/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1ac59880140d4a2c48ee1330744b874e3bf912aca53f20e8408eaf90f522f7fc diff --git a/tasks/format-code-task-000257/environment/setup/files/blocklist b/tasks/format-code-task-000257/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000257/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000257/environment/setup/setup.sh b/tasks/format-code-task-000257/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000257/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000257/tests/test.patch b/tasks/format-code-task-000257/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cc677fb8b1be9eb3194292c6efb1e4c6da2644f2 --- /dev/null +++ b/tasks/format-code-task-000257/tests/test.patch @@ -0,0 +1,100 @@ +diff --git a/theano/tensor/tests/test_extra_ops.py b/theano/tensor/tests/test_extra_ops.py +index 9f3146b3fa2..8486f2539d0 100644 +--- a/theano/tensor/tests/test_extra_ops.py ++++ b/theano/tensor/tests/test_extra_ops.py +@@ -137,6 +137,9 @@ def test_grad(self): + + + class TestRepeatOp(utt.InferShapeTester): ++ def _possible_axis(self, ndim): ++ return [None] + range(ndim) + [-i for i in range(ndim)] ++ + def setUp(self): + super(TestRepeatOp, self).setUp() + self.op_class = RepeatOp +@@ -147,37 +150,40 @@ def test_repeatOp(self): + x = T.TensorType(theano.config.floatX, [False] * ndim)() + a = np.random.random((10, ) * ndim) + +- r_var = T.lscalar() +- r = 3 +- for axis in [None] + range(ndim): ++ for axis in self._possible_axis(ndim): ++ r_var = T.lscalar() ++ r = 3 + f = theano.function([x, r_var], repeat(x, r_var, axis=axis)) + assert np.allclose(np.repeat(a, r, axis=axis), f(a, r)) + +- r_var = T.lvector() +- r = np.random.random_integers(5, size=(10,)) ++ r_var = T.lvector() ++ if axis is None: ++ r = np.random.random_integers(5, size=a.size) ++ else: ++ r = np.random.random_integers(5, size=(10,)) + +- for axis in range(ndim): + f = theano.function([x, r_var], repeat(x, r_var, axis=axis)) + assert np.allclose(np.repeat(a, r, axis=axis), f(a, r)) + +- + def test_infer_shape(self): + for ndim in range(4): + x = T.TensorType(theano.config.floatX, [False] * ndim)() + a = np.random.random((10, ) * ndim) + +- r_var = T.lscalar() +- r = 3 +- for axis in [None] + range(ndim): ++ for axis in self._possible_axis(ndim): ++ r_var = T.lscalar() ++ r = 3 + self._compile_and_check([x, r_var], + [RepeatOp(axis=axis)(x, r_var)], + [a, r], + self.op_class) + +- r_var = T.lvector() +- r = np.random.random_integers(5, size=(10,)) ++ r_var = T.lvector() ++ if axis is None: ++ r = np.random.random_integers(5, size=a.size) ++ else: ++ r = np.random.random_integers(5, size=(10,)) + +- for axis in range(ndim): + self._compile_and_check([x, r_var], + [RepeatOp(axis=axis)(x, r_var)], + [a, r], +@@ -187,10 +193,8 @@ def test_grad(self): + for ndim in range(3): + a = np.random.random((10, ) * ndim) + +- for axis in [None] + range(ndim): ++ for axis in self._possible_axis(ndim): + utt.verify_grad(lambda x: RepeatOp(axis=axis)(x, 3), [a]) +- if ndim > 0: +- utt.verify_grad(lambda x: RepeatOp(axis=-1)(x, 3), [a]) + + + class TestBartlett(utt.InferShapeTester): +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+3S0WrDIBTG8Vz3Kc5dr5LlhNk8TjCJkEGjIdqyvv0kg20Mtt60jNH/70bRIx75 ++rPrTy3HsnD8/FfdSZ60x25h9H7e5mka1bY22TVGrHlQLMXfr6ItTTHYVKdYQ0m911/b/qeoz/+Ri ++6oYwz9aPVZxud8e1/LXRj/xzYc7/+ZCXpL5dCz978PyHUbbgezfuehsnKY+D7JdLmoKXcpY8y7uS ++Jmd9yJU+hnU7EN//i3tNq+3CEqvlIuV5v/vrBwEAAAAAAAAAAAAAAAAP5A23fOxRACgAAA== +diff --git 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-000257/tests/test.sh b/tasks/format-code-task-000257/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4355cc1e4fd0a1726f1782b11894729f837ad419 --- /dev/null +++ b/tasks/format-code-task-000257/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' +theano/tensor/tests/test_extra_ops.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-000257/tests/test_command.sh b/tasks/format-code-task-000257/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000257/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000259/environment/Dockerfile b/tasks/format-code-task-000259/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1a5f65c4bbd02e09b9f29093bb4d8aa8b5a9ff1b --- /dev/null +++ b/tasks/format-code-task-000259/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:45a7f28e0191df9a89ef93eb070b631374f469839f3e09b83ad6534fc015c57d diff --git a/tasks/format-code-task-000259/environment/setup/files/blocklist b/tasks/format-code-task-000259/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000259/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000259/environment/setup/setup.sh b/tasks/format-code-task-000259/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000259/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000259/tests/test.patch b/tasks/format-code-task-000259/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3a5d38bf35694a7b1695b6af6cd73231388c23f8 --- /dev/null +++ b/tasks/format-code-task-000259/tests/test.patch @@ -0,0 +1,63 @@ +diff --git a/editions/test/tiddlers/tests/test-linked-list.js b/editions/test/tiddlers/tests/test-linked-list.js +index cf16fb91c..14a1649b2 100644 +--- a/editions/test/tiddlers/tests/test-linked-list.js ++++ b/editions/test/tiddlers/tests/test-linked-list.js +@@ -265,6 +265,36 @@ describe("LinkedList class tests", function() { + // Seems simple. Caused an infinite loop during development. + compare(newPair(["A", "A"])); + }); ++ ++ it("can remove duplicate values when a different value is between them (issue reproducer)", function() { ++ ++ ++ compare(remove(newPair(["A", "A", "B", "A"]), ["A", "A", "A"])); ++ }); ++ ++ it("preserves prev-array length when removing first occurrence with duplicate next", function() { ++ ++ ++ ++ var pair = newPair(["A", "B", "X", "B"]); ++ compare(remove(pair, "A")); ++ compare(remove(pair, "B")); ++ pair.list.push("X"); ++ pair.array.push("X"); ++ compare(pair); ++ compare(remove(pair, "B")); ++ }); ++ ++ it("can repeatedly remove leading duplicate when other duplicates follow", function() { ++ ++ ++ ++ var pair = newPair(["A", "B", "B", "X", "B"]); ++ compare(remove(pair, "A")); ++ compare(remove(pair, "B")); ++ compare(remove(pair, "B")); ++ compare(remove(pair, "B")); ++ }); + }); + + })(); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..c39808dbf +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["bash bin/test.sh"] ++} +diff --git 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 ++bash bin/test.sh ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000259/tests/test.sh b/tasks/format-code-task-000259/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e3166cb78933c63b34bb0988db3d15c54733e330 --- /dev/null +++ b/tasks/format-code-task-000259/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' +editions/test/tiddlers/tests/test-linked-list.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-000259/tests/test_command.sh b/tasks/format-code-task-000259/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000259/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000293/environment/Dockerfile b/tasks/format-code-task-000293/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8f512d76e7f87bdc4047985aa32ab2743a371f78 --- /dev/null +++ b/tasks/format-code-task-000293/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f24542df771e2ec29e265ed23a9c049d27ff3d08ce3d3c19e1da05190a3f7798 diff --git a/tasks/format-code-task-000293/environment/setup/files/blocklist b/tasks/format-code-task-000293/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000293/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000293/environment/setup/setup.sh b/tasks/format-code-task-000293/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000293/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000293/tests/test.patch b/tasks/format-code-task-000293/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a8fae0369d343100f52d78c541da027e5e0f32a6 --- /dev/null +++ b/tasks/format-code-task-000293/tests/test.patch @@ -0,0 +1,201 @@ +diff --git a/tests/helpers.js b/tests/helpers.js +new file mode 100644 +index 0000000..7752691 +--- /dev/null ++++ b/tests/helpers.js +@@ -0,0 +1,174 @@ ++ ++'use strict'; ++ ++var expect = require('chai').expect; ++var Atomizer = require('../src/atomizer'); ++ ++describe('Atomizer() helper classes', function () { ++ describe('getCss()', function () { ++ it('generates a rule from a helper declaration template with parameter substitution', function () { ++ var atomizer = new Atomizer(null, [ ++ { ++ type: 'helper', ++ name: 'Foo', ++ prefix: 'Foo', ++ declaration: { ++ 'param0': '$0', ++ 'param1': '$1' ++ } ++ } ++ ]); ++ var result = atomizer.getCss(['Foo(1,10px)']); ++ var expected = [ ++ '.Foo\\(1\\,10px\\) {', ++ ' param0: 1;', ++ ' param1: 10px;', ++ '}' ++ ].join('\n'); ++ expect(result).to.contain(expected); ++ }); ++ ++ it('substitutes a placeholder embedded inside a value', function () { ++ var atomizer = new Atomizer(null, [ ++ { ++ type: 'helper', ++ name: 'Clamp', ++ prefix: 'Clamp', ++ declaration: { ++ 'lines': '$0', ++ 'height': '$1px' ++ } ++ } ++ ]); ++ var result = atomizer.getCss(['Clamp(3,68)']); ++ var expected = [ ++ '.Clamp\\(3\\,68\\) {', ++ ' lines: 3;', ++ ' height: 68px;', ++ '}' ++ ].join('\n'); ++ expect(result).to.contain(expected); ++ }); ++ ++ it('supports a helper class with an empty argument list', function () { ++ var atomizer = new Atomizer(null, [ ++ { ++ type: 'helper', ++ name: 'Bar', ++ prefix: 'Bar', ++ declaration: { ++ 'bar': 'foo' ++ } ++ } ++ ]); ++ var result = atomizer.getCss(['Bar()']); ++ var expected = [ ++ '.Bar\\(\\) {', ++ ' bar: foo;', ++ '}' ++ ].join('\n'); ++ expect(result).to.contain(expected); ++ }); ++ ++ it('emits the helper\'s associated base rules verbatim', function () { ++ var atomizer = new Atomizer(null, [ ++ { ++ type: 'helper', ++ name: 'Foo', ++ prefix: 'Foo', ++ declaration: { ++ 'param0': '$0' ++ }, ++ rules: { ++ 'rule': { ++ 'foo': 'bar' ++ } ++ } ++ } ++ ]); ++ var result = atomizer.getCss(['Foo(9)']); ++ var base = [ ++ 'rule {', ++ ' foo: bar;', ++ '}' ++ ].join('\n'); ++ var declaration = [ ++ '.Foo\\(9\\) {', ++ ' param0: 9;', ++ '}' ++ ].join('\n'); ++ expect(result).to.contain(base); ++ expect(result).to.contain(declaration); ++ }); ++ ++ it('lets helper rules and pattern rules coexist', function () { ++ var atomizer = new Atomizer(null, [ ++ { ++ type: 'pattern', ++ name: 'Padding', ++ prefix: 'P-', ++ properties: ['padding'] ++ }, ++ { ++ type: 'helper', ++ name: 'Foo', ++ prefix: 'Foo', ++ declaration: { ++ 'a': '$0' ++ } ++ } ++ ]); ++ var result = atomizer.getCss(['P-10px', 'Foo(5)']); ++ var pattern = [ ++ '.P-10px {', ++ ' padding: 10px;', ++ '}' ++ ].join('\n'); ++ var helper = [ ++ '.Foo\\(5\\) {', ++ ' a: 5;', ++ '}' ++ ].join('\n'); ++ expect(result).to.contain(pattern); ++ expect(result).to.contain(helper); ++ }); ++ ++ it('throws when a helper has no declaration', function () { ++ var atomizer = new Atomizer(null, [ ++ { ++ type: 'helper', ++ name: 'Bad', ++ prefix: 'Bad' ++ } ++ ]); ++ expect(function () { ++ atomizer.getCss(['Bad()']); ++ }).to.throw(); ++ }); ++ }); ++ ++ describe('findClassNames()', function () { ++ it('recognizes helper class names alongside pattern class names', function () { ++ var atomizer = new Atomizer(null, [ ++ { ++ type: 'pattern', ++ name: 'Padding', ++ prefix: 'P-', ++ properties: ['padding'] ++ }, ++ { ++ type: 'helper', ++ name: 'LineClamp', ++ prefix: 'LineClamp', ++ declaration: { ++ 'a': '$0', ++ 'b': '$1' ++ } ++ } ++ ]); ++ var result = atomizer.findClassNames('
'); ++ expect(result).to.contain('LineClamp(2,40px)'); ++ expect(result).to.contain('P-10px'); ++ }); ++ }); ++}); +diff --git 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 ++ ++ ++ ++ ++./node_modules/.bin/mocha tests/atomizer.js --reporter spec ++ ++ ++./node_modules/.bin/mocha tests/helpers.js --reporter spec diff --git a/tasks/format-code-task-000293/tests/test.sh b/tasks/format-code-task-000293/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..22cdc046c26423f5e6fbf464dc76e372a0eb6c03 --- /dev/null +++ b/tasks/format-code-task-000293/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/helpers.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-000293/tests/test_command.sh b/tasks/format-code-task-000293/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000293/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000295/environment/Dockerfile b/tasks/format-code-task-000295/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a6703f532a0dcd1ccd95e16e8c9704942d5a023e --- /dev/null +++ b/tasks/format-code-task-000295/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:308f10c39c49d82d5ae0a5f0dbe711d776c3962441915df95e0d358ab60e4baf diff --git a/tasks/format-code-task-000295/environment/setup/files/blocklist b/tasks/format-code-task-000295/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000295/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000295/environment/setup/setup.sh b/tasks/format-code-task-000295/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000295/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000295/tests/test.patch b/tasks/format-code-task-000295/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f8a03aa98abb47d528dc7bbc78568443d2529f42 --- /dev/null +++ b/tasks/format-code-task-000295/tests/test.patch @@ -0,0 +1,149 @@ +diff --git a/sqle/driver/mysql/audit_offline_test.go b/sqle/driver/mysql/audit_offline_test.go +index f857236b6f..f958d6ec93 100644 +--- a/sqle/driver/mysql/audit_offline_test.go ++++ b/sqle/driver/mysql/audit_offline_test.go +@@ -292,7 +292,7 @@ INDEX idx_%s (v1) + runDefaultRulesInspectCase(t, "alter_table: table length > 64", DefaultMysqlInspectOffline(), + fmt.Sprintf(` + ALTER TABLE exist_db.exist_tb_1 RENAME %s;`, length65), +- newTestResult().addResult(rulepkg.DDLCheckObjectNameLength, 64), ++ newTestResult().addResult(rulepkg.DDLCheckObjectNameLength, 64).addResult(rulepkg.DDLNotAllowRenaming), + ) + + runDefaultRulesInspectCase(t, "alter_table:Add column length > 64", DefaultMysqlInspectOffline(), +@@ -304,7 +304,7 @@ ALTER TABLE exist_db.exist_tb_1 ADD COLUMN %s varchar(255) NOT NULL DEFAULT "uni + runDefaultRulesInspectCase(t, "alter_table:change column length > 64", DefaultMysqlInspectOffline(), + fmt.Sprintf(` + ALTER TABLE exist_db.exist_tb_1 CHANGE COLUMN v1 %s varchar(255) NOT NULL DEFAULT "unit test" COMMENT "unit test";`, length65), +- newTestResult().addResult(rulepkg.DDLCheckObjectNameLength, 64), ++ newTestResult().addResult(rulepkg.DDLCheckObjectNameLength, 64).addResult(rulepkg.DDLNotAllowRenaming), + ) + + runDefaultRulesInspectCase(t, "alter_table: Add index length > 64", DefaultMysqlInspectOffline(), +@@ -2297,3 +2297,16 @@ end;`, + newTestResult().add(driver.RuleLevelWarn, "语法错误或者解析器不支持,请人工确认SQL正确性")) + } + } ++ ++func TestDDLNotAllowRenamingOffline(t *testing.T) { ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "success", DefaultMysqlInspectOffline(), "ALTER TABLE exist_tb_1 MODIFY v1 CHAR(10);", newTestResult()) ++ ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "change 1", DefaultMysqlInspectOffline(), "ALTER TABLE exist_tb_1 CHANGE v1 a BIGINT;", newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) ++ ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "change 2", DefaultMysqlInspectOffline(), "ALTER TABLE exist_tb_1 RENAME COLUMN v1 TO a", newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) ++ ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "rename 1", DefaultMysqlInspectOffline(), "RENAME TABLE exist_tb_1 TO test", newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) ++ ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "rename 2", DefaultMysqlInspectOffline(), "ALTER TABLE exist_tb_1 RENAME TO test", newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) ++ ++} +diff --git a/sqle/driver/mysql/audit_test.go b/sqle/driver/mysql/audit_test.go +index 9ce5d5721e..64b9cc7dd9 100644 +--- a/sqle/driver/mysql/audit_test.go ++++ b/sqle/driver/mysql/audit_test.go +@@ -474,11 +474,14 @@ func TestCheckInvalidAlterTable(t *testing.T) { + // elegant method: unit test support MySQL. + handlerEngine := rulepkg.RuleHandlerMap[rulepkg.DDLCheckTableDBEngine] + handlerCharacter := rulepkg.RuleHandlerMap[rulepkg.DDLCheckTableCharacterSet] ++ handlerNotAllowRenaming := rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming] + delete(rulepkg.RuleHandlerMap, rulepkg.DDLCheckTableDBEngine) + delete(rulepkg.RuleHandlerMap, rulepkg.DDLCheckTableCharacterSet) ++ delete(rulepkg.RuleHandlerMap, rulepkg.DDLNotAllowRenaming) + defer func() { + rulepkg.RuleHandlerMap[rulepkg.DDLCheckTableDBEngine] = handlerEngine + rulepkg.RuleHandlerMap[rulepkg.DDLCheckTableCharacterSet] = handlerCharacter ++ rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming] = handlerNotAllowRenaming + }() + runDefaultRulesInspectCase(t, "alter_table: schema not exist", DefaultMysqlInspect(), + `ALTER TABLE not_exist_db.exist_tb_1 add column v5 varchar(255) NOT NULL DEFAULT "unit test" COMMENT "unit test"; +@@ -1264,7 +1267,7 @@ INDEX idx_%s (v1) + runDefaultRulesInspectCase(t, "alter_table: table length > 64", DefaultMysqlInspect(), + fmt.Sprintf(` + ALTER TABLE exist_db.exist_tb_1 RENAME %s;`, length65), +- newTestResult().addResult(rulepkg.DDLCheckObjectNameLength, 64), ++ newTestResult().addResult(rulepkg.DDLCheckObjectNameLength, 64).addResult(rulepkg.DDLNotAllowRenaming), + ) + + runDefaultRulesInspectCase(t, "alter_table:Add column length > 64", DefaultMysqlInspect(), +@@ -1276,7 +1279,7 @@ ALTER TABLE exist_db.exist_tb_1 ADD COLUMN %s varchar(255) NOT NULL DEFAULT "uni + runDefaultRulesInspectCase(t, "alter_table:change column length > 64", DefaultMysqlInspect(), + fmt.Sprintf(` + ALTER TABLE exist_db.exist_tb_1 CHANGE COLUMN v1 %s varchar(255) NOT NULL DEFAULT "unit test" COMMENT "unit test";`, length65), +- newTestResult().addResult(rulepkg.DDLCheckObjectNameLength, 64), ++ newTestResult().addResult(rulepkg.DDLCheckObjectNameLength, 64).addResult(rulepkg.DDLNotAllowRenaming), + ) + + runDefaultRulesInspectCase(t, "alter_table: Add index length > 64", DefaultMysqlInspect(), +@@ -4424,7 +4427,7 @@ func TestInspect_CheckColumn(t *testing.T) { + ` + alter table exist_db.exist_tb_1 change column v1 v11 varchar(255) DEFAULT "v11" COMMENT "uint test"; + `, +- newTestResult()) ++ newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) + + runDefaultRulesInspectCase(t, "check column 2", DefaultMysqlInspect(), + ` +@@ -4436,7 +4439,7 @@ func TestInspect_CheckColumn(t *testing.T) { + ` + alter table exist_db.exist_tb_1 change column V1 v11 varchar(255) DEFAULT "v11" COMMENT "uint test"; + `, +- newTestResult()) ++ newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) + + runDefaultRulesInspectCase(t, "check column 4", DefaultMysqlInspect(), + ` +@@ -5081,3 +5084,16 @@ func TestDDLCheckAutoIncrement(t *testing.T) { + } + + } ++ ++func TestDDLNotAllowRenaming(t *testing.T) { ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "success", DefaultMysqlInspect(), "ALTER TABLE exist_tb_1 MODIFY v1 CHAR(10);", newTestResult()) ++ ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "change 1", DefaultMysqlInspect(), "ALTER TABLE exist_tb_1 CHANGE v1 a BIGINT;", newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) ++ ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "change 2", DefaultMysqlInspect(), "ALTER TABLE exist_tb_1 RENAME COLUMN v1 TO a", newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) ++ ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "rename 1", DefaultMysqlInspect(), "RENAME TABLE exist_tb_1 TO test", newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) ++ ++ runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLNotAllowRenaming].Rule, t, "rename 2", DefaultMysqlInspect(), "ALTER TABLE exist_tb_1 RENAME TO test", newTestResult().addResult(rulepkg.DDLNotAllowRenaming)) ++ ++} +diff --git a/sqle/driver/mysql/context_test.go b/sqle/driver/mysql/context_test.go +index 9dc555de23..dbaf156386 100644 +--- a/sqle/driver/mysql/context_test.go ++++ b/sqle/driver/mysql/context_test.go +@@ -10,9 +10,12 @@ import ( + + func TestContext(t *testing.T) { + handler := rule.RuleHandlerMap[rule.DDLCheckAlterTableNeedMerge] ++ handlerNotAllowRenaming := rule.RuleHandlerMap[rule.DDLNotAllowRenaming] + delete(rule.RuleHandlerMap, rule.DDLCheckAlterTableNeedMerge) ++ delete(rule.RuleHandlerMap, rule.DDLNotAllowRenaming) + defer func() { + rule.RuleHandlerMap[rule.DDLCheckAlterTableNeedMerge] = handler ++ rule.RuleHandlerMap[rule.DDLNotAllowRenaming] = handlerNotAllowRenaming + }() + + runDefaultRulesInspectCase(t, "rename table and drop column: table not exists", DefaultMysqlInspect(), +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+3RsW7DIBAGYM95insBG2MFe/JQZUg3S+kDRMSgxJIB1YCVvH2pl1aR2iyJqrb/ ++N3AgTuLQXxziMKq9tjPLHqVMGiGWmlzXZc9FxauyqThPfWlpREbiYRN9En2QE1E2ORe+67t1/0sV ++H/kH7cO+d8ZIqwp/ut8bt/Lngl/lv67LOqPyfiN87Z/n3ytagj9otdp23Us7Djaeads97TbPrTSq ++XtPR0XsL5TPlxql21la5ifIgj55UNOZy0lJR3rtoQ8upYP511ExNw6wnZi7pxFY//VEAAAAAAAAA ++AAAAAAAAAAAAgD/oDVhi5o0AKAAA +diff --git 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-000295/tests/test.sh b/tasks/format-code-task-000295/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..32f518fa5d2f17ed64565ae9b7f8178f6bb08961 --- /dev/null +++ b/tasks/format-code-task-000295/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' +sqle/driver/mysql/audit_offline_test.go +sqle/driver/mysql/audit_test.go +sqle/driver/mysql/context_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-000295/tests/test_command.sh b/tasks/format-code-task-000295/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000295/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000401/tests/test.patch b/tasks/format-code-task-000401/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7cb42a49dc385cea8cf7ab811b25bcfb29fc3411 --- /dev/null +++ b/tasks/format-code-task-000401/tests/test.patch @@ -0,0 +1,291 @@ +diff --git a/usercase-test-coderl/calendar_data_view.test.js b/usercase-test-coderl/calendar_data_view.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/calendar_data_view.test.js +@@ -0,0 +1,259 @@ ++const assert = require('node:assert/strict'); ++const test = require('node:test'); ++ ++function installBrowserShim() { ++ global.window = global; ++ global.navigator = {userAgent: 'node'}; ++ ++ const document = { ++ documentElement: {style: {}}, ++ body: { ++ style: {}, ++ appendChild() {}, ++ removeChild() {} ++ }, ++ createElement(tag) { ++ return { ++ tagName: String(tag).toUpperCase(), ++ style: {}, ++ children: [], ++ ownerDocument: document, ++ appendChild() {}, ++ removeChild() {}, ++ setAttribute() {}, ++ getAttribute() { return undefined; }, ++ getElementsByTagName() { return []; } ++ }; ++ }, ++ createElementNS(_namespace, tag) { ++ return document.createElement(tag); ++ }, ++ getElementsByTagName() { return []; }, ++ addEventListener() {}, ++ removeEventListener() {} ++ }; ++ ++ global.document = document; ++} ++ ++installBrowserShim(); ++require('/workspace/repo'); ++const anychart = global.anychart; ++ ++function collectCalendarRows(chart) { ++ const iterator = chart.data().getIterator(); ++ const rows = []; ++ while (iterator.advance()) { ++ rows.push({ ++ x: iterator.get('x'), ++ ++ value: Number(iterator.get('value')) ++ }); ++ } ++ return rows; ++} ++ ++test('constructor data view keeps valid rows sorted by parsed date', () => { ++ ++ ++ const inputRows = [ ++ {x: '2020-03-02', value: '5'}, ++ {x: 'not-a-date', value: '7'}, ++ {x: '2020-01-01', value: '10'}, ++ {x: '2020-02-01', value: 'bad-number'} ++ ]; ++ ++ const chart = anychart.calendar(inputRows); ++ ++ ++ assert.deepStrictEqual(collectCalendarRows(chart), [ ++ {x: '2020-01-01', value: 10}, ++ {x: '2020-03-02', value: 5} ++ ]); ++ assert.strictEqual(chart.data().getIterator().getRowsCount(), 2); ++ ++ chart.dispose(); ++}); ++ ++test('chart.data(newRows) replaces the calendar view with the same filtering rules', () => { ++ ++ ++ const chart = anychart.calendar([ ++ {x: '2020-03-02', value: '5'}, ++ {x: 'not-a-date', value: '7'} ++ ]); ++ ++ const replacementRows = [ ++ {x: '2021-12-31', value: 1}, ++ {x: null, value: 99}, ++ {x: '2021-01-05', value: '2'}, ++ {x: '2021-06-15', value: NaN}, ++ {x: '2021-03-10T00:00:00Z', value: '3.5'} ++ ]; ++ ++ chart.data(replacementRows); ++ ++ assert.deepStrictEqual(collectCalendarRows(chart), [ ++ {x: '2021-01-05', value: 2}, ++ {x: '2021-03-10T00:00:00Z', value: 3.5}, ++ {x: '2021-12-31', value: 1} ++ ]); ++ assert.strictEqual(chart.data().getIterator().getRowsCount(), 3); ++ ++ chart.dispose(); ++}); ++ ++test('input rows remain unchanged after construction and replacement', () => { ++ ++ ++ const constructorRows = [ ++ {x: '2020-03-02', value: '5'}, ++ {x: 'not-a-date', value: '7'}, ++ {x: '2020-01-01', value: '10'}, ++ {x: '2020-02-01', value: 'bad-number'} ++ ]; ++ const constructorRowsExpected = [ ++ {x: '2020-03-02', value: '5'}, ++ {x: 'not-a-date', value: '7'}, ++ {x: '2020-01-01', value: '10'}, ++ {x: '2020-02-01', value: 'bad-number'} ++ ]; ++ const replacementRows = [ ++ {x: '2021-12-31', value: 1}, ++ {x: null, value: 99}, ++ {x: '2021-01-05', value: '2'}, ++ {x: '2021-06-15', value: NaN}, ++ {x: '2021-03-10T00:00:00Z', value: '3.5'} ++ ]; ++ const replacementRowsExpected = [ ++ {x: '2021-12-31', value: 1}, ++ {x: null, value: 99}, ++ {x: '2021-01-05', value: '2'}, ++ {x: '2021-06-15', value: NaN}, ++ {x: '2021-03-10T00:00:00Z', value: '3.5'} ++ ]; ++ ++ const chart = anychart.calendar(constructorRows); ++ chart.data(replacementRows); ++ ++ assert.deepStrictEqual(constructorRows, constructorRowsExpected); ++ assert.deepStrictEqual(replacementRows, replacementRowsExpected); ++ ++ chart.dispose(); ++}); ++ ++test('same input produces deterministic iterator output across charts', () => { ++ ++ ++ const rows = [ ++ {x: '2020-03-02', value: '5'}, ++ {x: 'not-a-date', value: '7'}, ++ {x: '2020-01-01', value: '10'}, ++ {x: '2020-02-01', value: 'bad-number'} ++ ]; ++ ++ const first = anychart.calendar(rows); ++ const second = anychart.calendar(rows); ++ ++ ++ assert.deepStrictEqual(collectCalendarRows(first), [ ++ {x: '2020-01-01', value: 10}, ++ {x: '2020-03-02', value: 5} ++ ]); ++ ++ assert.deepStrictEqual(collectCalendarRows(second), [ ++ {x: '2020-01-01', value: 10}, ++ {x: '2020-03-02', value: 5} ++ ]); ++ ++ first.dispose(); ++ second.dispose(); ++}); ++ ++test('two calendar instances keep independent data views', () => { ++ ++ ++ const a = anychart.calendar([ ++ {x: '2022-01-02', value: 8}, ++ {x: '2022-01-01', value: 7} ++ ]); ++ const b = anychart.calendar([ ++ {x: '2023-05-02', value: 4}, ++ {x: 'bad', value: 1}, ++ {x: '2023-05-01', value: 6} ++ ]); ++ ++ a.data([ ++ {x: '2020-01-02', value: 12}, ++ {x: '2020-01-01', value: 11} ++ ]); ++ ++ ++ assert.deepStrictEqual(collectCalendarRows(a), [ ++ {x: '2020-01-01', value: 11}, ++ {x: '2020-01-02', value: 12} ++ ]); ++ ++ assert.deepStrictEqual(collectCalendarRows(b), [ ++ {x: '2023-05-01', value: 6}, ++ {x: '2023-05-02', value: 4} ++ ]); ++ ++ a.dispose(); ++ b.dispose(); ++}); ++ ++test('calendar iterator visits retained rows and then exhausts', () => { ++ ++ ++ const chart = anychart.calendar([ ++ {x: 'bad-date', value: 10}, ++ {x: '2024-01-01', value: 1}, ++ {x: '2024-01-02', value: NaN} ++ ]); ++ const iterator = chart.data().getIterator(); ++ ++ ++ assert.strictEqual(iterator.advance(), true); ++ assert.strictEqual(iterator.get('x'), '2024-01-01'); ++ assert.strictEqual(iterator.get('value'), 1); ++ ++ assert.strictEqual(iterator.advance(), false); ++ ++ chart.dispose(); ++}); ++ ++test('all-invalid constructor data produces an empty calendar data view', () => { ++ ++ ++ const chart = anychart.calendar([ ++ {x: 'not-a-date', value: 7}, ++ {x: null, value: 8}, ++ {x: '2024-01-01', value: NaN} ++ ]); ++ ++ ++ assert.deepStrictEqual(collectCalendarRows(chart), []); ++ assert.strictEqual(chart.data().getIterator().getRowsCount(), 0); ++ ++ chart.dispose(); ++}); ++ ++test('repeated calendar creations expose filtered data views deterministically', () => { ++ ++ ++ for (let i = 0; i < 120; i += 1) { ++ const chart = anychart.calendar([ ++ {x: '2024-02-02', value: i}, ++ {x: 'bad-date', value: i + 1000}, ++ {x: '2024-01-01', value: String(i)} ++ ]); ++ ++ ++ assert.deepStrictEqual(collectCalendarRows(chart), [ ++ {x: '2024-01-01', value: i}, ++ {x: '2024-02-02', value: i} ++ ]); ++ chart.dispose(); ++ } ++}); +diff --git 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 ++ ++unset TRAVIS_BRANCH GITHUB_TOKEN ++ ++trap 'rm -rf /workspace/repo/dist /workspace/repo/libs/closure-library/closure/bin/build/__pycache__' EXIT ++ ++python build.py compile -d -b bundle --output /workspace/repo/dist/js >/dev/null ++ ++node --test /workspace/repo/usercase-test-coderl/calendar_data_view.test.js diff --git a/tasks/format-code-task-000406/environment/Dockerfile b/tasks/format-code-task-000406/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b81754dedfbe4901668184e79878e73c228a2eae --- /dev/null +++ b/tasks/format-code-task-000406/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b40b062aed81c1579a7b63fd40d9b3e568f510b859005907489d8a6f9c1b59fb diff --git a/tasks/format-code-task-000406/environment/setup/files/blocklist b/tasks/format-code-task-000406/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000406/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000406/environment/setup/setup.sh b/tasks/format-code-task-000406/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000406/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000406/tests/test.patch b/tasks/format-code-task-000406/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ca9821a262ab668cbef842e42f7700a6560fa993 --- /dev/null +++ b/tasks/format-code-task-000406/tests/test.patch @@ -0,0 +1,82 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..55fdbc4a6f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/executors/test_celery_kubernetes_executor.py tests/executors/test_local_kubernetes_executor.py -v"] ++} +diff --git a/tests/executors/test_celery_kubernetes_executor.py b/tests/executors/test_celery_kubernetes_executor.py +index 84ca14c5f0..9a17f90d83 100644 +--- a/tests/executors/test_celery_kubernetes_executor.py ++++ b/tests/executors/test_celery_kubernetes_executor.py +@@ -223,3 +223,23 @@ class TestCeleryKubernetesExecutor: + assert k8s_executor_mock.kubernetes_queue == conf.get( + 'celery_kubernetes_executor', 'kubernetes_queue' + ) ++ ++ def test_send_callback_method_exists(self): ++ cel_exec = CeleryExecutor() ++ k8s_exec = KubernetesExecutor() ++ cke = CeleryKubernetesExecutor(cel_exec, k8s_exec) ++ ++ assert hasattr(cke, 'send_callback') ++ assert callable(cke.send_callback) ++ ++ def test_send_callback_dispatches_to_sink(self): ++ cel_exec = CeleryExecutor() ++ k8s_exec = KubernetesExecutor() ++ cke = CeleryKubernetesExecutor(cel_exec, k8s_exec) ++ callback_sink = mock.MagicMock() ++ cke.callback_sink = callback_sink ++ ++ request = mock.MagicMock() ++ cke.send_callback(request) ++ ++ callback_sink.send.assert_called_once_with(request) +diff --git a/tests/executors/test_local_kubernetes_executor.py b/tests/executors/test_local_kubernetes_executor.py +index 274175f127..5e0450a6bf 100644 +--- a/tests/executors/test_local_kubernetes_executor.py ++++ b/tests/executors/test_local_kubernetes_executor.py +@@ -67,3 +67,27 @@ class TestLocalKubernetesExecutor: + LocalKubernetesExecutor(local_executor_mock, k8s_executor_mock) + + assert k8s_executor_mock.kubernetes_queue == conf.get('local_kubernetes_executor', 'kubernetes_queue') ++ ++ def test_send_callback_method_exists(self): ++ from airflow.executors.kubernetes_executor import KubernetesExecutor ++ ++ local_exec = LocalExecutor() ++ k8s_exec = KubernetesExecutor() ++ lke = LocalKubernetesExecutor(local_exec, k8s_exec) ++ ++ assert hasattr(lke, 'send_callback') ++ assert callable(lke.send_callback) ++ ++ def test_send_callback_dispatches_to_sink(self): ++ from airflow.executors.kubernetes_executor import KubernetesExecutor ++ ++ local_exec = LocalExecutor() ++ k8s_exec = KubernetesExecutor() ++ lke = LocalKubernetesExecutor(local_exec, k8s_exec) ++ callback_sink = mock.MagicMock() ++ lke.callback_sink = callback_sink ++ ++ request = mock.MagicMock() ++ lke.send_callback(request) ++ ++ callback_sink.send.assert_called_once_with(request) +diff --git 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/executors/test_celery_kubernetes_executor.py tests/executors/test_local_kubernetes_executor.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000406/tests/test.sh b/tasks/format-code-task-000406/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b0a54a536060c490506544fce16124f1fe6dd9b --- /dev/null +++ b/tasks/format-code-task-000406/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/executors/test_celery_kubernetes_executor.py +tests/executors/test_local_kubernetes_executor.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-000406/tests/test_command.sh b/tasks/format-code-task-000406/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000406/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000408/environment/Dockerfile b/tasks/format-code-task-000408/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4f9e11c1a9b832318944ef1d975fedf6be5361c6 --- /dev/null +++ b/tasks/format-code-task-000408/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dc2e29f078b0f308f9f88bb646eb0573fb1c02ea6715a28acf2c8e331105acbe diff --git a/tasks/format-code-task-000408/environment/setup/files/blocklist b/tasks/format-code-task-000408/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000408/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000408/environment/setup/setup.sh b/tasks/format-code-task-000408/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000408/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000408/tests/test.patch b/tasks/format-code-task-000408/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6c81edec4c153e1d71b557e159ba5096bd763c2d --- /dev/null +++ b/tasks/format-code-task-000408/tests/test.patch @@ -0,0 +1,205 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..7a75987318 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py -k \"schema_object_with_autodetect_false or schema_object_bucket_used_for\""] ++} +diff --git a/tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py b/tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py +index f4b5f59f82..24ee25c5b9 100644 +--- a/tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py ++++ b/tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py +@@ -1375,6 +1375,178 @@ class TestGCSToBigQueryOperator(unittest.TestCase): + } + ) + ++ @mock.patch("airflow.providers.google.cloud.transfers.gcs_to_bigquery.GCSHook") ++ @mock.patch("airflow.providers.google.cloud.transfers.gcs_to_bigquery.BigQueryHook") ++ def test_schema_object_with_autodetect_false_no_external_table_should_execute_successfully( ++ self, bq_hook, gcs_hook ++ ): ++ """ ++ Reproduces the issue: autodetect=False + schema_object (without schema_fields) ++ on a non-external table should NOT raise and the schema loaded from the ++ GCS object should be used in the load configuration sent to BigQuery. ++ """ ++ import json as _json ++ ++ bq_hook.return_value.insert_job.side_effect = [ ++ MagicMock(job_id=pytest.real_job_id, error_result=False), ++ pytest.real_job_id, ++ ] ++ bq_hook.return_value.generate_job_id.return_value = pytest.real_job_id ++ bq_hook.return_value.split_tablename.return_value = (PROJECT_ID, DATASET, TABLE) ++ bq_hook.return_value.get_job.return_value.result.return_value = ("1",) ++ gcs_hook.return_value.download.return_value = _json.dumps(SCHEMA_FIELDS).encode("utf-8") ++ ++ operator = GCSToBigQueryOperator( ++ task_id=TASK_ID, ++ bucket=TEST_BUCKET, ++ source_objects=TEST_SOURCE_OBJECTS, ++ destination_project_dataset_table=TEST_EXPLICIT_DEST, ++ write_disposition=WRITE_DISPOSITION, ++ schema_object="path/to/schema.json", ++ external_table=False, ++ autodetect=False, ++ ) ++ ++ operator.execute(context=MagicMock()) ++ ++ calls = [ ++ call( ++ configuration={ ++ "load": dict( ++ autodetect=False, ++ createDisposition="CREATE_IF_NEEDED", ++ destinationTable={"projectId": PROJECT_ID, "datasetId": DATASET, "tableId": TABLE}, ++ destinationTableProperties={ ++ "description": None, ++ "labels": None, ++ }, ++ sourceFormat="CSV", ++ skipLeadingRows=None, ++ sourceUris=[f"gs://{TEST_BUCKET}/{TEST_SOURCE_OBJECTS_AS_STRING}"], ++ writeDisposition=WRITE_DISPOSITION, ++ ignoreUnknownValues=False, ++ allowQuotedNewlines=False, ++ encoding="UTF-8", ++ schema={"fields": SCHEMA_FIELDS}, ++ allowJaggedRows=False, ++ fieldDelimiter=",", ++ maxBadRecords=0, ++ quote=None, ++ schemaUpdateOptions=(), ++ ), ++ }, ++ project_id=bq_hook.return_value.project_id, ++ location=None, ++ job_id=pytest.real_job_id, ++ timeout=None, ++ retry=DEFAULT_RETRY, ++ nowait=True, ++ ), ++ ] ++ bq_hook.return_value.insert_job.assert_has_calls(calls) ++ ++ @mock.patch("airflow.providers.google.cloud.transfers.gcs_to_bigquery.GCSHook") ++ @mock.patch("airflow.providers.google.cloud.transfers.gcs_to_bigquery.BigQueryHook") ++ def test_schema_object_with_autodetect_false_external_table_should_execute_successfully( ++ self, bq_hook, gcs_hook ++ ): ++ """ ++ autodetect=False + schema_object (without schema_fields) on an external table ++ should NOT raise and the loaded schema should be in the table_resource passed ++ to create_empty_table. ++ """ ++ import json as _json ++ ++ bq_hook.return_value.insert_job.side_effect = [ ++ MagicMock(job_id=pytest.real_job_id, error_result=False), ++ pytest.real_job_id, ++ ] ++ bq_hook.return_value.generate_job_id.return_value = pytest.real_job_id ++ bq_hook.return_value.split_tablename.return_value = (PROJECT_ID, DATASET, TABLE) ++ bq_hook.return_value.get_job.return_value.result.return_value = ("1",) ++ gcs_hook.return_value.download.return_value = _json.dumps(SCHEMA_FIELDS).encode("utf-8") ++ ++ operator = GCSToBigQueryOperator( ++ task_id=TASK_ID, ++ bucket=TEST_BUCKET, ++ source_objects=TEST_SOURCE_OBJECTS, ++ destination_project_dataset_table=TEST_EXPLICIT_DEST, ++ write_disposition=WRITE_DISPOSITION, ++ schema_object="path/to/schema.json", ++ external_table=True, ++ autodetect=False, ++ ) ++ ++ operator.execute(context=MagicMock()) ++ bq_hook.return_value.create_empty_table.assert_called_once_with( ++ table_resource={ ++ "tableReference": {"projectId": PROJECT_ID, "datasetId": DATASET, "tableId": TABLE}, ++ "labels": None, ++ "description": None, ++ "externalDataConfiguration": { ++ "source_uris": [f"gs://{TEST_BUCKET}/{TEST_SOURCE_OBJECTS_AS_STRING}"], ++ "source_format": "CSV", ++ "maxBadRecords": 0, ++ "autodetect": False, ++ "compression": "NONE", ++ "csvOptions": { ++ "fieldDelimeter": ",", ++ "skipLeadingRows": None, ++ "quote": None, ++ "allowQuotedNewlines": False, ++ "allowJaggedRows": False, ++ }, ++ }, ++ "location": None, ++ "encryptionConfiguration": None, ++ "schema": {"fields": SCHEMA_FIELDS}, ++ } ++ ) ++ ++ @mock.patch("airflow.providers.google.cloud.transfers.gcs_to_bigquery.GCSHook") ++ @mock.patch("airflow.providers.google.cloud.transfers.gcs_to_bigquery.BigQueryHook") ++ def test_schema_object_bucket_used_for_schema_download(self, bq_hook, gcs_hook): ++ """ ++ When schema_object_bucket is set explicitly (different from bucket), the ++ schema JSON download should target schema_object_bucket, not bucket. ++ """ ++ import json as _json ++ ++ bq_hook.return_value.insert_job.side_effect = [ ++ MagicMock(job_id=pytest.real_job_id, error_result=False), ++ pytest.real_job_id, ++ ] ++ bq_hook.return_value.generate_job_id.return_value = pytest.real_job_id ++ bq_hook.return_value.split_tablename.return_value = (PROJECT_ID, DATASET, TABLE) ++ bq_hook.return_value.get_job.return_value.result.return_value = ("1",) ++ gcs_hook.return_value.download.return_value = _json.dumps(SCHEMA_FIELDS).encode("utf-8") ++ ++ schema_bucket = "different-schema-bucket" ++ schema_object = "schemas/table.json" ++ operator = GCSToBigQueryOperator( ++ task_id=TASK_ID, ++ bucket=TEST_BUCKET, ++ source_objects=TEST_SOURCE_OBJECTS, ++ destination_project_dataset_table=TEST_EXPLICIT_DEST, ++ write_disposition=WRITE_DISPOSITION, ++ schema_object_bucket=schema_bucket, ++ schema_object=schema_object, ++ external_table=False, ++ autodetect=False, ++ ) ++ ++ operator.execute(context=MagicMock()) ++ ++ ++ assert any( ++ c.args == (schema_bucket, schema_object) ++ for c in gcs_hook.return_value.download.call_args_list ++ ), ( ++ "Expected gcs_hook.download to be called with schema_object_bucket " ++ f"({schema_bucket!r}, {schema_object!r}); actual calls: " ++ f"{gcs_hook.return_value.download.call_args_list}" ++ ) ++ + + @mock.patch("airflow.providers.google.cloud.transfers.gcs_to_bigquery.BigQueryHook") + def test_execute_without_external_table_async_should_execute_successfully(hook): +diff --git 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_gcs_to_bigquery.py -k "schema_object_with_autodetect_false or schema_object_bucket_used_for" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000408/tests/test.sh b/tasks/format-code-task-000408/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d7e1cec4611ce98be1a08856f2a7e624ef34cc6a --- /dev/null +++ b/tasks/format-code-task-000408/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_gcs_to_bigquery.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-000408/tests/test_command.sh b/tasks/format-code-task-000408/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000408/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000409/environment/Dockerfile b/tasks/format-code-task-000409/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0f0c5030adb822dcc8028959ef7c585afa1e898a --- /dev/null +++ b/tasks/format-code-task-000409/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c526b23ea053191e6cb115c8b9b9fb47560281a5ee1ff69f5f86509f72f7e4b2 diff --git a/tasks/format-code-task-000409/environment/setup/files/blocklist b/tasks/format-code-task-000409/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000409/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000409/environment/setup/setup.sh b/tasks/format-code-task-000409/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000409/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000409/tests/test.patch b/tasks/format-code-task-000409/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..89f2a9589e4345353f2230d8429b9cc31197ca71 --- /dev/null +++ b/tasks/format-code-task-000409/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..5dcfb03cb7 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/providers/google/cloud/operators/test_bigquery_dts.py -v"] ++} +diff --git a/tests/providers/google/cloud/operators/test_bigquery_dts.py b/tests/providers/google/cloud/operators/test_bigquery_dts.py +index 78c92d52ed..a2b81a588a 100644 +--- a/tests/providers/google/cloud/operators/test_bigquery_dts.py ++++ b/tests/providers/google/cloud/operators/test_bigquery_dts.py +@@ -22,6 +22,7 @@ from unittest import mock + + from google.api_core.gapic_v1.method import DEFAULT + from google.cloud.bigquery_datatransfer_v1 import StartManualTransferRunsResponse, TransferConfig, TransferRun ++from google.protobuf.struct_pb2 import Struct + + from airflow.providers.google.cloud.operators.bigquery_dts import ( + BigQueryCreateDataTransferOperator, +@@ -42,6 +43,17 @@ TRANSFER_CONFIG = { + "schedule": "first sunday of quarter 00:00", + } + ++ ++def _s3_transfer_config_response(): ++ """Build a TransferConfig response that mimics an S3 transfer with AWS creds in params.""" ++ params = Struct() ++ params["destination_table_name_template"] = "destination_table" ++ params["file_format"] = "PARQUET" ++ params["data_path"] = "s3://bucket/path" ++ params["access_key_id"] = "AKIAEXAMPLEKEYID" ++ params["secret_access_key"] = "EXAMPLESECRETACCESSKEY" ++ return TransferConfig(name=TRANSFER_CONFIG_NAME, params=params) ++ + TRANSFER_CONFIG_ID = "id1234" + + TRANSFER_CONFIG_NAME = "projects/123abc/locations/321cba/transferConfig/1a2b3c" +@@ -71,6 +83,46 @@ class BigQueryCreateDataTransferOperatorTestCase(unittest.TestCase): + ) + ti.xcom_push.assert_called_with(execution_date=None, key="transfer_config_id", value="1a2b3c") + ++ @mock.patch( ++ "airflow.providers.google.cloud.operators.bigquery_dts.BiqQueryDataTransferServiceHook", ++ **{"return_value.create_transfer_config.return_value": _s3_transfer_config_response()}, ++ ) ++ def test_execute_hides_secret_access_key_in_return_value(self, mock_hook): ++ op = BigQueryCreateDataTransferOperator( ++ transfer_config=TRANSFER_CONFIG, project_id=PROJECT_ID, task_id="id" ++ ) ++ ti = mock.MagicMock() ++ ++ result = op.execute({"ti": ti}) ++ ++ ++ ++ ++ assert "params" in result ++ assert result["params"].get("secret_access_key") != "EXAMPLESECRETACCESSKEY", ( ++ "secret_access_key value must not be exposed in the operator's return value (XCom)" ++ ) ++ assert "EXAMPLESECRETACCESSKEY" not in str(result), ( ++ "the original AWS secret_access_key must not appear anywhere in the return value" ++ ) ++ ++ @mock.patch( ++ "airflow.providers.google.cloud.operators.bigquery_dts.BiqQueryDataTransferServiceHook", ++ **{"return_value.create_transfer_config.return_value": _s3_transfer_config_response()}, ++ ) ++ def test_execute_preserves_non_sensitive_params(self, mock_hook): ++ op = BigQueryCreateDataTransferOperator( ++ transfer_config=TRANSFER_CONFIG, project_id=PROJECT_ID, task_id="id" ++ ) ++ ti = mock.MagicMock() ++ ++ result = op.execute({"ti": ti}) ++ ++ ++ assert result["params"].get("file_format") == "PARQUET" ++ assert result["params"].get("data_path") == "s3://bucket/path" ++ assert result["params"].get("destination_table_name_template") == "destination_table" ++ + + class BigQueryDeleteDataTransferConfigOperatorTestCase(unittest.TestCase): + @mock.patch("airflow.providers.google.cloud.operators.bigquery_dts.BiqQueryDataTransferServiceHook") +diff --git 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/operators/test_bigquery_dts.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000409/tests/test.sh b/tasks/format-code-task-000409/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..45083cca305e7c5d99fc07dbfcff23e83d9bdb5b --- /dev/null +++ b/tasks/format-code-task-000409/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/operators/test_bigquery_dts.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-000409/tests/test_command.sh b/tasks/format-code-task-000409/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000409/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000431/environment/Dockerfile b/tasks/format-code-task-000431/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a7baf13b5df8765b23cb0d128f34d527e8099846 --- /dev/null +++ b/tasks/format-code-task-000431/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:48f547fd3bf484a70b0526f7b7343551e1c5093442093d9d38d9c51faaef6ae5 diff --git a/tasks/format-code-task-000431/environment/setup/files/blocklist b/tasks/format-code-task-000431/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000431/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000431/environment/setup/setup.sh b/tasks/format-code-task-000431/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000431/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000431/tests/test.patch b/tasks/format-code-task-000431/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6f746547d9033dbe69f54d962d452f17c264d205 --- /dev/null +++ b/tasks/format-code-task-000431/tests/test.patch @@ -0,0 +1,144 @@ +diff --git a/controllers/solrcloud_controller_externaldns_test.go b/controllers/solrcloud_controller_externaldns_test.go +index 68e4e836..9e054c18 100644 +--- a/controllers/solrcloud_controller_externaldns_test.go ++++ b/controllers/solrcloud_controller_externaldns_test.go +@@ -114,6 +114,7 @@ func TestEDSCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=3000"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -225,6 +226,7 @@ func TestEDSNoNodesCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=2000"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "2000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -333,6 +335,7 @@ func TestEDSNoCommonCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=3000"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -441,6 +444,7 @@ func TestEDSUseInternalAddressCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=3000"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -552,6 +556,7 @@ func TestEDSExtraDomainsCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=3000"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + hostnameAnnotation := instance.Namespace + "." + testDomain + for _, domain := range testAdditionalDomains { +@@ -669,6 +674,7 @@ func TestEDSKubeDomainCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=2000"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "2000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +diff --git a/controllers/solrcloud_controller_ingress_test.go b/controllers/solrcloud_controller_ingress_test.go +index dacea920..396a4df5 100644 +--- a/controllers/solrcloud_controller_ingress_test.go ++++ b/controllers/solrcloud_controller_ingress_test.go +@@ -130,6 +130,7 @@ func TestIngressCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=100"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments (Solr advertising port)") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -252,6 +253,7 @@ func TestIngressNoNodesCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=3000"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments (Solr advertising port)") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -375,6 +377,7 @@ func TestIngressNoCommonCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=100"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments (Solr advertising port)") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -496,6 +499,7 @@ func TestIngressUseInternalAddressCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=100"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments (Solr advertising port)") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -621,6 +625,7 @@ func TestIngressExtraDomainsCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=100"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments (Solr advertising port)") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +@@ -743,6 +748,7 @@ func TestIngressKubeDomainCloudReconcile(t *testing.T) { + } + testPodEnvVariables(t, expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env) + assert.ElementsMatch(t, []string{"-DhostPort=100"}, statefulSet.Spec.Template.Spec.Containers[0].Args, "Wrong Solr container arguments (Solr advertising port)") ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "3000"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + + // Check the client Service + service := expectService(t, g, requests, expectedCloudRequest, cloudCsKey, statefulSet.Spec.Template.Labels) +diff --git a/controllers/solrcloud_controller_test.go b/controllers/solrcloud_controller_test.go +index f31fff13..d8c8b125 100644 +--- a/controllers/solrcloud_controller_test.go ++++ b/controllers/solrcloud_controller_test.go +@@ -256,6 +256,7 @@ func TestCustomKubeOptionsCloudReconcile(t *testing.T) { + testMapsEqual(t, "pod node selectors", testNodeSelectors, statefulSet.Spec.Template.Spec.NodeSelector) + testPodProbe(t, testProbeLivenessNonDefaults, statefulSet.Spec.Template.Spec.Containers[0].LivenessProbe) + testPodProbe(t, testProbeReadinessNonDefaults, statefulSet.Spec.Template.Spec.Containers[0].ReadinessProbe) ++ assert.ElementsMatch(t, []string{"solr", "stop", "-p", "8983"}, statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command, "Incorrect pre-stop command") + testPodTolerations(t, testTolerations, statefulSet.Spec.Template.Spec.Tolerations) + + // Check the client Service +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,12 @@ ++H4sIAAAAAAAAA+2UbWvbMBDH89qf4pq+67Adp00CG3vVlFE2WMkGg20l2NY5FpUlI8lZKPnwlZU+ ++pM3SdKNlG7sfGNvS/04n3Z2irOGCTVHO485L0XOMBgP/djx8++9k0O/1h4ejUTLq9JJkmBx2YPBi ++Ea3RGJtqgI5Wyj6m2zX/jxLd5d+isdNcVVUqWWTK51tjR/77/WFym/9B4nTJ0bB/1IHe84Wwnf88 ++//t7ccZlnKWmDHIGvggyZEGwD6fSHY0QcNFk6KsENbTTkBqD1gAvQCoLtUaD0gbu9xvsQVhA3Bgd ++C5WnIl6z9eu0/2Fac4N67tydw3L5BCu0LrTzN2BLlAE4qgvGNYT1I0ZelzdaQGg+QLe0tjav43jG ++bdlkkStzb6Alui2Fhs/MPQcaBaYGTczUDylUyuJ5PzqMknXR1I9MBZfNYppWbHgUuVKKZpddCJU7 ++yapeV1/P+bDaigsXl8U2EYTHq6nVJuoN3ebSd+e04xx/0eWDhD05tb+xTG7FLv9OsnJcVorBq8Vj +++gOv1BWEevOgN8PYmrCCt80wvq4DeKfArd0IBIY1SoYy52iCmR+Gm3JpTSaNbDM9Q+vbxkChdFvC ++7tGIq1YquEADpsacFxwZcOkVZ5PWoVdEca6k1UoI1CaG735XoXa+u5/d/Mn4U3SwbL9O5cx1orn+ ++OxaqYRN0trlbYjXkrjpVvXc7/FhbrqT5maYd+uJ65EyrOWfIvip1gW6jeovuZGFdE6XiVndctjel ++F42xSBthzXp498ZujNuYxqpKubwfUvdmu7lqpH2bQDgP/vSFSRAEQRAEQRAEQRAEQRAEQRAEQRAE ++QRB/IVfME3pnACgAAA== +diff --git 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-000431/tests/test.sh b/tasks/format-code-task-000431/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..256fa607a34b5715b6df495340adaacfc5a0ca24 --- /dev/null +++ b/tasks/format-code-task-000431/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' +controllers/solrcloud_controller_externaldns_test.go +controllers/solrcloud_controller_ingress_test.go +controllers/solrcloud_controller_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000431/tests/test_command.sh b/tasks/format-code-task-000431/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000431/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000437/environment/Dockerfile b/tasks/format-code-task-000437/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a32ca69bedc3956a5e57358ab745f2f7a6af91d8 --- /dev/null +++ b/tasks/format-code-task-000437/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c215cb637646d1da302a8620330180959e42b0fee77e2f393eb34d178f9121c7 diff --git a/tasks/format-code-task-000437/environment/setup/files/blocklist b/tasks/format-code-task-000437/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000437/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000437/environment/setup/setup.sh b/tasks/format-code-task-000437/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000437/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000437/tests/test.patch b/tasks/format-code-task-000437/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..93b225dbf920b7ac9b18a15574bc26d8e0a79ffb --- /dev/null +++ b/tasks/format-code-task-000437/tests/test.patch @@ -0,0 +1,97 @@ +diff --git a/coremltools/converters/mil/mil/ops/tests/test_reverse_sequence_contract.py b/coremltools/converters/mil/mil/ops/tests/test_reverse_sequence_contract.py +new file mode 100644 +index 00000000..efa3ecfe +--- /dev/null ++++ b/coremltools/converters/mil/mil/ops/tests/test_reverse_sequence_contract.py +@@ -0,0 +1,81 @@ ++import numpy as np ++import pytest ++ ++from coremltools.converters.mil.mil import Builder as mb ++from coremltools.converters.mil.mil import Function, types ++ ++ ++def _reverse_sequence(x, lengths, seq_axis=None, batch_axis=None): ++ with Function({}): ++ kwargs = {"x": x, "lengths": lengths} ++ if seq_axis is not None: ++ kwargs["seq_axis"] = seq_axis ++ if batch_axis is not None: ++ kwargs["batch_axis"] = batch_axis ++ return mb.reverse_sequence(**kwargs) ++ ++ ++def test_reverse_sequence_evaluates_arbitrary_rank_with_negative_axes(): ++ x = np.arange(24, dtype=np.float32).reshape(2, 3, 4) ++ result = _reverse_sequence(x, [3, 1, 4], seq_axis=-1, batch_axis=-2) ++ ++ expected = np.array( ++ [ ++ [[2, 1, 0, 3], [4, 5, 6, 7], [11, 10, 9, 8]], ++ [[14, 13, 12, 15], [16, 17, 18, 19], [23, 22, 21, 20]], ++ ], ++ dtype=np.float32, ++ ) ++ np.testing.assert_array_equal(result.val, expected) ++ assert result.dtype == types.fp32 ++ assert tuple(result.shape) == x.shape ++ ++ ++def test_reverse_sequence_preserves_zero_and_full_length_boundaries(): ++ x = np.arange(8, dtype=np.int32).reshape(2, 4) ++ result = _reverse_sequence(x, [0, 4], seq_axis=1, batch_axis=0) ++ ++ expected = np.array([[0, 1, 2, 3], [7, 6, 5, 4]], dtype=np.int32) ++ np.testing.assert_array_equal(result.val, expected) ++ assert result.dtype == types.int32 ++ ++ ++def test_reverse_sequence_uses_tensorflow_compatible_default_axes(): ++ x = np.array([[1, 10], [2, 20], [3, 30]], dtype=np.float32) ++ expected = np.array([[3, 10], [2, 20], [1, 30]], dtype=np.float32) ++ ++ both_default = _reverse_sequence(x, [3, 1]) ++ seq_default = _reverse_sequence(x, [3, 1], batch_axis=1) ++ batch_default = _reverse_sequence(x, [3, 1], seq_axis=0) ++ for result in (both_default, seq_default, batch_default): ++ np.testing.assert_array_equal(result.val, expected) ++ ++ ++def test_reverse_sequence_keeps_symbolic_output_type_without_folding(): ++ with Function({"x": mb.placeholder(shape=(2, 3, 4), dtype=types.fp32)}) as function: ++ result = mb.reverse_sequence( ++ x=function.inputs["x"], lengths=[3, 1, 4], seq_axis=-1, batch_axis=-2 ++ ) ++ ++ assert result.val is None ++ assert result.dtype == types.fp32 ++ assert tuple(result.shape) == (2, 3, 4) ++ ++ ++@pytest.mark.parametrize( ++ "x, lengths, seq_axis, batch_axis", ++ [ ++ (np.zeros((2, 3), dtype=np.float32), [[1, 2]], 1, 0), ++ (np.zeros((2, 3), dtype=np.float32), [1], 1, 0), ++ (np.zeros((2, 3), dtype=np.float32), [-1, 2], 1, 0), ++ (np.zeros((2, 3), dtype=np.float32), [1, 4], 1, 0), ++ (np.zeros((2, 3), dtype=np.float32), [1, 2], 2, 0), ++ (np.zeros((2, 3), dtype=np.float32), [1, 2], 1, -3), ++ (np.zeros((2, 3), dtype=np.float32), [1, 2], 0, 0), ++ ], ++) ++def test_reverse_sequence_rejects_invalid_lengths_and_axes( ++ x, lengths, seq_axis, batch_axis ++): ++ with pytest.raises((ValueError, IndexError)): ++ _reverse_sequence(x, lengths, seq_axis, batch_axis) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++pytest -q coremltools/converters/mil/mil/ops/tests/test_reverse_sequence_contract.py --disable-warnings diff --git a/tasks/format-code-task-000437/tests/test.sh b/tasks/format-code-task-000437/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a51a921fb9dbb61d7c386b343bb0111ea469aee3 --- /dev/null +++ b/tasks/format-code-task-000437/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' +coremltools/converters/mil/mil/ops/tests/test_reverse_sequence_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-000437/tests/test_command.sh b/tasks/format-code-task-000437/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000437/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000439/environment/Dockerfile b/tasks/format-code-task-000439/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..130eeca4c28c67b3d99f3b71b51c40a9256b947b --- /dev/null +++ b/tasks/format-code-task-000439/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:eea977b9671f600a5b7fac63d635d6845f89bd1c5501bd3a77d3a2066173bf5d diff --git a/tasks/format-code-task-000439/environment/setup/files/blocklist b/tasks/format-code-task-000439/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000439/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000439/environment/setup/setup.sh b/tasks/format-code-task-000439/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000439/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000439/tests/test.patch b/tasks/format-code-task-000439/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4827cb921c7c077efac1338132e20b52b88aa4ed --- /dev/null +++ b/tasks/format-code-task-000439/tests/test.patch @@ -0,0 +1,241 @@ +diff --git a/codespec/runtime_selectors_test.go b/codespec/runtime_selectors_test.go +new file mode 100644 +index 0000000..e47bf24 +--- /dev/null ++++ b/codespec/runtime_selectors_test.go +@@ -0,0 +1,222 @@ ++package runtimecontract_test ++ ++import ( ++ "strings" ++ "testing" ++ ++ aquaruntime "github.com/aquaproj/aqua/v2/pkg/runtime" ++) ++ ++func envs(runtimes []*aquaruntime.Runtime) []string { ++ got := make([]string, len(runtimes)) ++ for i, rt := range runtimes { ++ if rt == nil { ++ got[i] = "" ++ continue ++ } ++ got[i] = rt.Env() ++ } ++ return got ++} ++ ++func assertEnvs(t *testing.T, got []*aquaruntime.Runtime, want ...string) { ++ t.Helper() ++ actual := envs(got) ++ if len(actual) != len(want) { ++ t.Fatalf("runtime count: got %v, want %v", actual, want) ++ } ++ for i := range want { ++ if actual[i] != want[i] { ++ t.Fatalf("runtime order: got %v, want %v", actual, want) ++ } ++ } ++} ++ ++func TestCodespecGetRuntimesSelectorGrammar(t *testing.T) { ++ tests := []struct { ++ selector string ++ want []string ++ }{ ++ {selector: "all", want: []string{"darwin/amd64", "darwin/arm64", "linux/amd64", "linux/arm64", "windows/amd64", "windows/arm64"}}, ++ {selector: "linux", want: []string{"linux/amd64", "linux/arm64"}}, ++ {selector: "amd64", want: []string{"darwin/amd64", "windows/amd64", "linux/amd64"}}, ++ {selector: "linux/arm64", want: []string{"linux/arm64"}}, ++ {selector: " \tlinux/arm64\n", want: []string{"linux/arm64"}}, ++ } ++ for _, tc := range tests { ++ got, err := aquaruntime.GetRuntimes(tc.selector) ++ if err != nil { ++ t.Errorf("GetRuntimes(%q) returned an error: %v", tc.selector, err) ++ continue ++ } ++ assertEnvs(t, got, tc.want...) ++ } ++} ++ ++func TestCodespecGetRuntimesRejectsInvalidSelectors(t *testing.T) { ++ invalid := []string{ ++ "", ++ "plan9", ++ "plan9/amd64", ++ "linux/mips", ++ "linux/amd64/extra", ++ "linux /amd64", ++ "!linux", ++ } ++ for _, selector := range invalid { ++ got, err := aquaruntime.GetRuntimes(selector) ++ if err == nil { ++ t.Errorf("GetRuntimes(%q) succeeded with %v; want an error", selector, envs(got)) ++ continue ++ } ++ if got != nil { ++ t.Errorf("GetRuntimes(%q) returned partial runtimes %v", selector, envs(got)) ++ } ++ trimmed := strings.TrimSpace(selector) ++ if trimmed != "" && !strings.Contains(err.Error(), trimmed) { ++ t.Errorf("GetRuntimes(%q) error %q does not identify the selector", selector, err) ++ } ++ } ++} ++ ++func TestCodespecListDistinguishesNilAndEmpty(t *testing.T) { ++ got, err := aquaruntime.GetRuntimesFromEnvs(nil) ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, got, "darwin/amd64", "darwin/arm64", "linux/amd64", "linux/arm64", "windows/amd64", "windows/arm64") ++ ++ got, err = aquaruntime.GetRuntimesFromEnvs([]string{}) ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, got) ++} ++ ++func TestCodespecPositiveSelectorsPreserveFirstSeenOrder(t *testing.T) { ++ got, err := aquaruntime.GetRuntimesFromEnvs([]string{ ++ "linux/arm64", ++ "darwin", ++ "arm64", ++ "linux", ++ "darwin/amd64", ++ }) ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, got, ++ "linux/arm64", ++ "darwin/amd64", ++ "darwin/arm64", ++ "windows/arm64", ++ "linux/amd64", ++ ) ++} ++ ++func TestCodespecExclusionsAreOrderIndependent(t *testing.T) { ++ tests := []struct { ++ selectors []string ++ want []string ++ }{ ++ { ++ selectors: []string{"!windows", "all", "!amd64"}, ++ want: []string{"darwin/arm64", "linux/arm64"}, ++ }, ++ { ++ selectors: []string{"all", "!linux", "linux/arm64"}, ++ want: []string{"darwin/amd64", "darwin/arm64", "windows/amd64", "windows/arm64"}, ++ }, ++ } ++ for _, tc := range tests { ++ got, err := aquaruntime.GetRuntimesFromEnvs(tc.selectors) ++ if err != nil { ++ t.Errorf("GetRuntimesFromEnvs(%v): %v", tc.selectors, err) ++ continue ++ } ++ assertEnvs(t, got, tc.want...) ++ } ++} ++ ++func TestCodespecNegativeOnlyListsStartFromAll(t *testing.T) { ++ got, err := aquaruntime.GetRuntimesFromEnvs([]string{"!arm64"}) ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, got, "darwin/amd64", "linux/amd64", "windows/amd64") ++ ++ got, err = aquaruntime.GetRuntimesFromEnvs([]string{"!all"}) ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, got) ++} ++ ++func TestCodespecListSelectorsTrimWhitespace(t *testing.T) { ++ got, err := aquaruntime.GetRuntimesFromEnvs([]string{" linux ", " \t!linux/arm64\n"}) ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, got, "linux/amd64") ++} ++ ++func TestCodespecInvalidListIsAtomic(t *testing.T) { ++ invalidLists := [][]string{ ++ {"linux", "plan9", "windows"}, ++ {"linux", " ", "windows"}, ++ {"linux", "!", "windows"}, ++ {"linux", "!!arm64", "windows"}, ++ {"linux", "! linux", "windows"}, ++ {"linux", "!windows/mips", "darwin"}, ++ } ++ for _, selectors := range invalidLists { ++ got, err := aquaruntime.GetRuntimesFromEnvs(selectors) ++ if err == nil { ++ t.Errorf("GetRuntimesFromEnvs(%v) succeeded with %v; want an error", selectors, envs(got)) ++ continue ++ } ++ if got != nil { ++ t.Errorf("GetRuntimesFromEnvs(%v) leaked partial result %v", selectors, envs(got)) ++ } ++ bad := strings.TrimSpace(selectors[1]) ++ if bad != "" && !strings.Contains(err.Error(), bad) { ++ t.Errorf("GetRuntimesFromEnvs(%v) error %q does not identify %q", selectors, err, bad) ++ } ++ } ++} ++ ++func TestCodespecResultsAreFresh(t *testing.T) { ++ first, err := aquaruntime.GetRuntimesFromEnvs(nil) ++ if err != nil { ++ t.Fatal(err) ++ } ++ first[0].GOOS = "changed" ++ first[1] = nil ++ ++ second, err := aquaruntime.GetRuntimesFromEnvs(nil) ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, second, "darwin/amd64", "darwin/arm64", "linux/amd64", "linux/arm64", "windows/amd64", "windows/arm64") ++ ++ direct, err := aquaruntime.GetRuntimes("linux") ++ if err != nil { ++ t.Fatal(err) ++ } ++ direct[0].GOARCH = "changed" ++ directAgain, err := aquaruntime.GetRuntimes("linux") ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, directAgain, "linux/amd64", "linux/arm64") ++ ++ selected, err := aquaruntime.GetRuntimesFromEnvs([]string{"darwin"}) ++ if err != nil { ++ t.Fatal(err) ++ } ++ selected[0].GOOS = "changed" ++ selectedAgain, err := aquaruntime.GetRuntimesFromEnvs([]string{"darwin"}) ++ if err != nil { ++ t.Fatal(err) ++ } ++ assertEnvs(t, selectedAgain, "darwin/amd64", "darwin/arm64") ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++CODESPEC_GOMODCACHE="$(mktemp -d)" ++trap 'rm -rf -- "${CODESPEC_GOMODCACHE}"' EXIT ++GOMODCACHE="${CODESPEC_GOMODCACHE}" GOTOOLCHAIN=local GOPROXY=off GOSUMDB=off \ ++ go test ./codespec -count=1 diff --git a/tasks/format-code-task-000439/tests/test.sh b/tasks/format-code-task-000439/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cf745a21ee394d23f9e6a25ae1e0ace5037ab305 --- /dev/null +++ b/tasks/format-code-task-000439/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/runtime_selectors_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-000439/tests/test_command.sh b/tasks/format-code-task-000439/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000439/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000453/environment/Dockerfile b/tasks/format-code-task-000453/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a55b262ee75f8065d58942ab72f00cbd5a4948c7 --- /dev/null +++ b/tasks/format-code-task-000453/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:373460084a9fab9a08a17b4805821f13588c3069b8ab293e4262c7b639ec9391 diff --git a/tasks/format-code-task-000453/environment/setup/files/blocklist b/tasks/format-code-task-000453/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000453/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000453/environment/setup/setup.sh b/tasks/format-code-task-000453/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000453/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000453/tests/test.patch b/tasks/format-code-task-000453/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..67e15c98fee56c4523efc522ee35222f56ffba49 --- /dev/null +++ b/tasks/format-code-task-000453/tests/test.patch @@ -0,0 +1,170 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..d1dbf7753 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test -count=1 -run 'TestKillDaemon|TestDAGContainerSet|TestDirectContainerSet' ./workflow/controller/"] ++} +diff --git a/workflow/controller/exec_control_test.go b/workflow/controller/exec_control_test.go +index 40394b66b..2060d8678 100644 +--- a/workflow/controller/exec_control_test.go ++++ b/workflow/controller/exec_control_test.go +@@ -1,11 +1,14 @@ + package controller + + import ( ++ "context" + "testing" + + "github.com/stretchr/testify/assert" ++ apiv1 "k8s.io/api/core/v1" + "k8s.io/utils/pointer" + ++ wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" + "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" + ) + +@@ -30,3 +33,128 @@ func TestKillDaemonChildrenUnmarkPod(t *testing.T) { + woc.killDaemonedChildren("a") + assert.Nil(t, woc.wf.Status.Nodes["a"].Daemoned) + } ++ ++ ++ ++ ++ ++ ++ ++func TestDAGContainerSetTerminationDoesNotHang(t *testing.T) { ++ wf := wfv1.MustUnmarshalWorkflow(` ++apiVersion: argoproj.io/v1alpha1 ++kind: Workflow ++metadata: ++ name: container-set-termination-demo ++ namespace: argo ++spec: ++ entrypoint: main ++ templates: ++ - name: main ++ dag: ++ tasks: ++ - name: using-container-set-template ++ template: problematic-container-set ++ - name: problematic-container-set ++ containerSet: ++ containers: ++ - name: step-1 ++ image: alpine ++ command: [sh, -c, "sleep 10"] ++ - name: step-2 ++ image: alpine ++ command: [sh, -c, "sleep 10"] ++`) ++ ++ cancel, controller := newController(wf) ++ defer cancel() ++ ++ ctx := context.Background() ++ woc := newWorkflowOperationCtx(wf, controller) ++ woc.operate(ctx) ++ ++ ++ ++ containerNodes := map[string]wfv1.NodePhase{} ++ for _, n := range woc.wf.Status.Nodes { ++ if n.Type == wfv1.NodeTypeContainer { ++ containerNodes[n.DisplayName] = n.Phase ++ } ++ } ++ assert.Equal(t, wfv1.NodePending, containerNodes["step-1"], ++ "step-1 container child should start in Pending") ++ assert.Equal(t, wfv1.NodePending, containerNodes["step-2"], ++ "step-2 container child should start in Pending") ++ ++ ++ makePodsPhase(ctx, woc, apiv1.PodPending) ++ wfOut := woc.wf ++ wfOut.Spec.Shutdown = wfv1.ShutdownStrategyTerminate ++ ++ woc1 := newWorkflowOperationCtx(wfOut, controller) ++ woc1.operate(ctx) ++ ++ ++ ++ ++ containerCount := 0 ++ for _, n := range woc1.wf.Status.Nodes { ++ if n.Type == wfv1.NodeTypeContainer { ++ containerCount++ ++ assert.Equal(t, wfv1.NodeFailed, n.Phase, ++ "container child %s must be Failed after Terminate, was %s", ++ n.DisplayName, n.Phase) ++ } ++ } ++ assert.Equal(t, 2, containerCount, "expected to find both container child nodes") ++ assert.NotEqual(t, wfv1.WorkflowRunning, woc1.wf.Status.Phase, ++ "workflow must not remain Running after Terminate — that is the hang the fix addresses") ++} ++ ++ ++ ++ ++ ++ ++func TestDirectContainerSetTerminationStillWorks(t *testing.T) { ++ wf := wfv1.MustUnmarshalWorkflow(` ++apiVersion: argoproj.io/v1alpha1 ++kind: Workflow ++metadata: ++ name: direct-container-set-termination ++ namespace: argo ++spec: ++ entrypoint: problematic-container-set ++ templates: ++ - name: problematic-container-set ++ containerSet: ++ containers: ++ - name: step-1 ++ image: alpine ++ command: [sh, -c, "sleep 10"] ++`) ++ ++ cancel, controller := newController(wf) ++ defer cancel() ++ ++ ctx := context.Background() ++ woc := newWorkflowOperationCtx(wf, controller) ++ woc.operate(ctx) ++ ++ makePodsPhase(ctx, woc, apiv1.PodPending) ++ wfOut := woc.wf ++ wfOut.Spec.Shutdown = wfv1.ShutdownStrategyTerminate ++ ++ woc1 := newWorkflowOperationCtx(wfOut, controller) ++ woc1.operate(ctx) ++ ++ assert.NotEqual(t, wfv1.WorkflowRunning, woc1.wf.Status.Phase, ++ "direct-containerset workflow must not remain Running after Terminate") ++ for _, n := range woc1.wf.Status.Nodes { ++ if n.Type == wfv1.NodeTypeContainer { ++ assert.Equal(t, wfv1.NodeFailed, n.Phase, ++ "container child %s must be Failed after Terminate, was %s", ++ n.DisplayName, n.Phase) ++ } ++ } ++} +diff --git 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 -count=1 -run 'TestKillDaemon|TestDAGContainerSet|TestDirectContainerSet' ./workflow/controller/ ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000453/tests/test.sh b/tasks/format-code-task-000453/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..19e4af3632619a99dc78b587d9acfd4790c98466 --- /dev/null +++ b/tasks/format-code-task-000453/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +workflow/controller/exec_control_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-000453/tests/test_command.sh b/tasks/format-code-task-000453/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000453/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000454/environment/Dockerfile b/tasks/format-code-task-000454/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5405abe8af1be11eed9892070a1223654d1e07f3 --- /dev/null +++ b/tasks/format-code-task-000454/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3d0a8e20567d0f9a97c05266381cf08303c1b25cab2a24e1347497e1946d960d diff --git a/tasks/format-code-task-000454/environment/setup/files/blocklist b/tasks/format-code-task-000454/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000454/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000454/environment/setup/setup.sh b/tasks/format-code-task-000454/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000454/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000454/tests/test.patch b/tasks/format-code-task-000454/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9f6643cd47a4ed0e77d0121564d1d99c710be2d5 --- /dev/null +++ b/tasks/format-code-task-000454/tests/test.patch @@ -0,0 +1,273 @@ +diff --git a/server/artifacts/artifact_server_test.go b/server/artifacts/artifact_server_test.go +index 686224bb4..69eaf8e9b 100644 +--- a/server/artifacts/artifact_server_test.go ++++ b/server/artifacts/artifact_server_test.go +@@ -633,3 +633,246 @@ func TestArtifactServer_httpFromError(t *testing.T) { + s.httpFromError(err, w) + assert.Equal(t, http.StatusNotFound, w.StatusCode) + } ++ ++ ++ ++ ++ ++ ++func newServerForInlineTest() *ArtifactServer { ++ gatekeeper := &authmocks.Gatekeeper{} ++ kube := kubefake.NewSimpleClientset() ++ instanceId := "my-instanceid" ++ wf := &wfv1.Workflow{ ++ ObjectMeta: metav1.ObjectMeta{Namespace: "my-ns", Name: "inline-wf", Labels: map[string]string{ ++ common.LabelKeyControllerInstanceID: instanceId, ++ }}, ++ Spec: wfv1.WorkflowSpec{ ++ Entrypoint: "main", ++ Templates: []wfv1.Template{ ++ { ++ Name: "main", ++ Steps: []wfv1.ParallelSteps{ ++ { ++ Steps: []wfv1.WorkflowStep{ ++ { ++ Name: "a", ++ Inline: &wfv1.Template{ ++ Container: nil, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ Status: wfv1.WorkflowStatus{ ++ Nodes: wfv1.Nodes{ ++ ++ "parent-node": wfv1.NodeStatus{ ++ ID: "parent-node", ++ Name: "inline-wf", ++ DisplayName: "inline-wf", ++ TemplateName: "main", ++ Type: wfv1.NodeTypeSteps, ++ }, ++ ++ ++ ++ ++ "inline-node": wfv1.NodeStatus{ ++ ID: "inline-node", ++ Name: "inline-wf[0].a", ++ DisplayName: "a", ++ TemplateName: "", ++ TemplateRef: nil, ++ BoundaryID: "parent-node", ++ Type: wfv1.NodeTypePod, ++ Outputs: &wfv1.Outputs{ ++ Artifacts: wfv1.Artifacts{ ++ { ++ Name: "my-inline-artifact", ++ ArtifactLocation: wfv1.ArtifactLocation{ ++ S3: &wfv1.S3Artifact{ ++ ++ Key: "inline-wf/inline-node/my-inline-artifact.tgz", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ } ++ argo := fakewfv1.NewSimpleClientset(wf) ++ ctx := context.WithValue(context.WithValue(context.Background(), auth.KubeKey, kube), auth.WfKey, argo) ++ gatekeeper.On("ContextWithRequest", mock.Anything, mock.Anything).Return(ctx, nil) ++ a := &sqldbmocks.WorkflowArchive{} ++ ++ driverData := []byte("inline-data") ++ fakeDriverFactory := func(_ context.Context, _ *wfv1.Artifact, _ resource.Interface) (artifactscommon.ArtifactDriver, error) { ++ return &inlineFakeDriver{data: driverData}, nil ++ } ++ ++ artifactRepositories := armocks.DummyArtifactRepositories(&wfv1.ArtifactRepository{ ++ S3: &wfv1.S3ArtifactRepository{ ++ S3Bucket: wfv1.S3Bucket{ ++ Endpoint: "my-endpoint", ++ Bucket: "my-bucket", ++ }, ++ }, ++ }) ++ ++ return newArtifactServer(gatekeeper, hydratorfake.Noop, a, instanceid.NewService(instanceId), fakeDriverFactory, artifactRepositories) ++} ++ ++ ++ ++ ++ ++type inlineFakeDriver struct { ++ artifactscommon.ArtifactDriver ++ data []byte ++} ++ ++func (a *inlineFakeDriver) Load(_ *wfv1.Artifact, path string) error { ++ return ioutil.WriteFile(path, a.data, 0o600) ++} ++ ++func (a *inlineFakeDriver) OpenStream(_ *wfv1.Artifact) (io.ReadCloser, error) { ++ return io.NopCloser(bytes.NewReader(a.data)), nil ++} ++ ++func (a *inlineFakeDriver) IsDirectory(_ *wfv1.Artifact) (bool, error) { ++ return false, nil ++} ++ ++func (a *inlineFakeDriver) ListObjects(_ *wfv1.Artifact) ([]string, error) { ++ return []string{}, nil ++} ++ ++ ++ ++ ++ ++ ++func TestArtifactServer_GetOutputArtifact_InlineTemplate(t *testing.T) { ++ s := newServerForInlineTest() ++ ++ r := &http.Request{} ++ r.URL = mustParse("/artifacts/my-ns/inline-wf/inline-node/my-inline-artifact") ++ recorder := httptest.NewRecorder() ++ ++ s.GetOutputArtifact(recorder, r) ++ ++ assert.Equal(t, http.StatusOK, recorder.Result().StatusCode, ++ "inline-template node should not produce Internal Server Error") ++ body, err := io.ReadAll(recorder.Result().Body) ++ assert.NoError(t, err) ++ assert.Equal(t, "inline-data", string(body)) ++} ++ ++ ++ ++func TestArtifactServer_GetArtifactFile_InlineTemplate(t *testing.T) { ++ s := newServerForInlineTest() ++ ++ r := &http.Request{} ++ r.URL = mustParse("/artifact-files/my-ns/workflows/inline-wf/inline-node/outputs/my-inline-artifact") ++ recorder := httptest.NewRecorder() ++ ++ s.GetArtifactFile(recorder, r) ++ ++ assert.Equal(t, http.StatusOK, recorder.Result().StatusCode, ++ "inline-template node should serve artifact files, not return 500") ++ body, err := io.ReadAll(recorder.Result().Body) ++ assert.NoError(t, err) ++ assert.Equal(t, "inline-data", string(body)) ++} ++ ++ ++ ++ ++ ++ ++func TestArtifactServer_getArtifactAndDriver_InlineTemplate(t *testing.T) { ++ s := newServerForInlineTest() ++ ++ ++ ctx, err := s.gateKeeping(&http.Request{URL: mustParse("/artifacts/my-ns/inline-wf/inline-node/my-inline-artifact")}, nil) ++ assert.NoError(t, err) ++ ++ wf, err := s.getWorkflowAndValidate(ctx, "my-ns", "inline-wf") ++ assert.NoError(t, err) ++ ++ art, driver, err := s.getArtifactAndDriver(ctx, "inline-node", "my-inline-artifact", false, wf, nil) ++ assert.NoError(t, err, "inline-template node must not produce a template-not-found error") ++ assert.NotNil(t, art) ++ assert.NotNil(t, driver) ++ if art != nil && art.S3 != nil { ++ ++ ++ ++ assert.Equal(t, "my-bucket", art.S3.Bucket, ++ "bucket must come from the resolved artifact repository when template is inline") ++ } ++} ++ ++ ++ ++ ++ ++func TestArtifactServer_getArtifactAndDriver_MissingNamedTemplate(t *testing.T) { ++ gatekeeper := &authmocks.Gatekeeper{} ++ kube := kubefake.NewSimpleClientset() ++ instanceId := "my-instanceid" ++ wf := &wfv1.Workflow{ ++ ObjectMeta: metav1.ObjectMeta{Namespace: "my-ns", Name: "missing-tmpl-wf", Labels: map[string]string{ ++ common.LabelKeyControllerInstanceID: instanceId, ++ }}, ++ Spec: wfv1.WorkflowSpec{ ++ Templates: []wfv1.Template{}, ++ }, ++ Status: wfv1.WorkflowStatus{ ++ Nodes: wfv1.Nodes{ ++ "some-node": wfv1.NodeStatus{ ++ ID: "some-node", ++ Name: "some-node", ++ TemplateName: "no-such-template", ++ Outputs: &wfv1.Outputs{ ++ Artifacts: wfv1.Artifacts{ ++ { ++ Name: "art", ++ ArtifactLocation: wfv1.ArtifactLocation{ ++ S3: &wfv1.S3Artifact{ ++ Key: "k", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ } ++ argo := fakewfv1.NewSimpleClientset(wf) ++ ctx := context.WithValue(context.WithValue(context.Background(), auth.KubeKey, kube), auth.WfKey, argo) ++ gatekeeper.On("ContextWithRequest", mock.Anything, mock.Anything).Return(ctx, nil) ++ a := &sqldbmocks.WorkflowArchive{} ++ fakeDriverFactory := func(_ context.Context, _ *wfv1.Artifact, _ resource.Interface) (artifactscommon.ArtifactDriver, error) { ++ return &inlineFakeDriver{data: []byte("x")}, nil ++ } ++ artifactRepositories := armocks.DummyArtifactRepositories(&wfv1.ArtifactRepository{ ++ S3: &wfv1.S3ArtifactRepository{ ++ S3Bucket: wfv1.S3Bucket{Endpoint: "my-endpoint", Bucket: "my-bucket"}, ++ }, ++ }) ++ s := newArtifactServer(gatekeeper, hydratorfake.Noop, a, instanceid.NewService(instanceId), fakeDriverFactory, artifactRepositories) ++ ++ wf2, err := s.getWorkflowAndValidate(ctx, "my-ns", "missing-tmpl-wf") ++ assert.NoError(t, err) ++ _, _, err = s.getArtifactAndDriver(ctx, "some-node", "art", false, wf2, nil) ++ assert.Error(t, err, "an explicit non-empty TemplateName that does not resolve must still produce an error") ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..6a0d29c9b +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./server/artifacts/ -run \"TestArtifactServer_GetOutputArtifact_InlineTemplate|TestArtifactServer_GetArtifactFile_InlineTemplate|TestArtifactServer_getArtifactAndDriver_InlineTemplate|TestArtifactServer_getArtifactAndDriver_MissingNamedTemplate\" -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 ++go test ./server/artifacts/ -run "TestArtifactServer_GetOutputArtifact_InlineTemplate|TestArtifactServer_GetArtifactFile_InlineTemplate|TestArtifactServer_getArtifactAndDriver_InlineTemplate|TestArtifactServer_getArtifactAndDriver_MissingNamedTemplate" -count=1 -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000454/tests/test.sh b/tasks/format-code-task-000454/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..00ef6098a22da1559be3138113af1e6dacf1a5a9 --- /dev/null +++ b/tasks/format-code-task-000454/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +server/artifacts/artifact_server_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-000454/tests/test_command.sh b/tasks/format-code-task-000454/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000454/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000462/environment/Dockerfile b/tasks/format-code-task-000462/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f3c9bd4f95fe8e673e015253d6a59d7b1db04cb --- /dev/null +++ b/tasks/format-code-task-000462/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:81d00cf1b9eb1eb16b3b59c5f7b05514cb6cc62b1ac9a8635ca7431dbd9c9369 diff --git a/tasks/format-code-task-000462/environment/setup/files/blocklist b/tasks/format-code-task-000462/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000462/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000462/environment/setup/setup.sh b/tasks/format-code-task-000462/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000462/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000462/tests/test.patch b/tasks/format-code-task-000462/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bb7a3066beeefeac0f71c40af273bc58500ef47a --- /dev/null +++ b/tasks/format-code-task-000462/tests/test.patch @@ -0,0 +1,327 @@ +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,300 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++TMPROOT=$(mktemp -d) ++trap 'rm -rf "$TMPROOT"' EXIT ++ ++fail() { ++ echo "FAIL: $*" >&2 ++ exit 1 ++} ++ ++( cd /workspace/repo && go build -ldflags='-s' -o="$TMPROOT/asdf" ./cmd/asdf ) \ ++ || fail "build" ++BIN="$TMPROOT/asdf" ++ ++setup_case() { ++ local name=$1 ++ CASE_DIR="$TMPROOT/$name" ++ HOME="$CASE_DIR/home" ++ ASDF_DATA_DIR="$CASE_DIR/data" ++ ASDF_CONFIG_FILE="$CASE_DIR/asdfrc" ++ export HOME ASDF_DATA_DIR ASDF_CONFIG_FILE ++ mkdir -p "$HOME" "$ASDF_DATA_DIR/plugins/dummy/bin" "$ASDF_DATA_DIR/installs/dummy" "$ASDF_DATA_DIR/shims" ++ : >"$ASDF_CONFIG_FILE" ++ cd "$CASE_DIR" || fail "cd $CASE_DIR" ++} ++ ++install_dummy_version() { ++ local version=$1 ++ local install_dir="$ASDF_DATA_DIR/installs/dummy/$version" ++ mkdir -p "$install_dir/bin" ++ cat >"$install_dir/bin/dummy" <"$install_dir/bin/other_bin" <"$file" ++} ++ ++assert_empty_file() { ++ local file=$1 label=$2 ++ [ ! -s "$file" ] || fail "$label: unexpected content: $(sed -n l "$file")" ++} ++ ++assert_file_equals() { ++ local actual=$1 expected=$2 label=$3 ++ cmp -s "$actual" "$expected" || fail "$label: got $(sed -n l "$actual")" ++} ++ ++assert_nonempty_file() { ++ local file=$1 label=$2 ++ [ -s "$file" ] || fail "$label: expected non-empty content" ++} ++ ++assert_file_has_line() { ++ local file=$1 line=$2 label=$3 ++ grep -Fxq -- "$line" "$file" || fail "$label: missing line '$line'; got $(sed -n l "$file")" ++} ++ ++assert_file_contains_text() { ++ local file=$1 text=$2 label=$3 ++ grep -Fq -- "$text" "$file" || fail "$label: missing text '$text'; got $(sed -n l "$file")" ++} ++ ++assert_file_lacks_text() { ++ local file=$1 text=$2 label=$3 ++ ! grep -Fq -- "$text" "$file" || fail "$label: unexpected text '$text'; got $(sed -n l "$file")" ++} ++ ++assert_file_contains_ordered_lines() { ++ local file=$1 label=$2 ++ shift 2 ++ local expected=("$@") ++ local idx=0 line ++ ++ while IFS= read -r line && [ "$idx" -lt "${#expected[@]}" ]; do ++ if [ "$line" = "${expected[$idx]}" ]; then ++ idx=$((idx + 1)) ++ fi ++ done <"$file" ++ ++ [ "$idx" -eq "${#expected[@]}" ] || fail "$label: missing ordered lines; got $(sed -n l "$file")" ++} ++ ++assert_shim_advertises_only() { ++ local shim=$1 version=$2 label=$3 ++ [ -f "$shim" ] || fail "$label: missing shim $shim" ++ grep -qx "# asdf-plugin: dummy $version" "$shim" || fail "$label: missing dummy $version metadata" ++ ! grep -q "1.0.0" "$shim" || fail "$label: removed version still advertised" ++} ++ ++ ++ ++ ++setup_case f1_success_full_lifecycle ++install_dummy_version 1.0.0 ++"$BIN" reshim dummy >setup_out 2>setup_err || fail "F1 setup reshim: $(sed -n l setup_err)" ++[ -f "$ASDF_DATA_DIR/shims/dummy" ] || fail "F1 setup missing dummy shim" ++[ -f "$ASDF_DATA_DIR/shims/other_bin" ] || fail "F1 setup missing other_bin shim" ++cat >"$ASDF_DATA_DIR/plugins/dummy/bin/uninstall" <<'EOF' ++#!/usr/bin/env bash ++echo "custom uninstall" ++printf 'callback stderr %s %s %s\n' "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH" >&2 ++EOF ++chmod +x "$ASDF_DATA_DIR/plugins/dummy/bin/uninstall" ++cat >"$ASDF_CONFIG_FILE" <<'EOF' ++pre_asdf_uninstall_dummy = echo pre_asdf_uninstall_dummy $1 ++post_asdf_uninstall_dummy = echo post_asdf_uninstall_dummy $1 ++EOF ++"$BIN" uninstall dummy 1.0.0 >out 2>err; ec=$? ++ ++required_out=( ++ "pre_asdf_uninstall_dummy 1.0.0" \ ++ "custom uninstall" \ ++ "post_asdf_uninstall_dummy 1.0.0" ++) ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_file_contains_ordered_lines out "F1 stdout" "${required_out[@]}" ++ ++assert_file_has_line err "callback stderr version 1.0.0 $ASDF_DATA_DIR/installs/dummy/1.0.0" "F1 stderr" ++[ ! -d "$ASDF_DATA_DIR/installs/dummy/1.0.0" ] || fail "F1 install directory still exists" ++[ ! -e "$ASDF_DATA_DIR/shims/dummy" ] || fail "F1 dummy shim still exists" ++[ ! -e "$ASDF_DATA_DIR/shims/other_bin" ] || fail "F1 other_bin shim still exists" ++ ++ ++ ++ ++setup_case f2_no_callback_refresh_remaining ++install_dummy_version 1.0.0 ++install_dummy_version 1.1.0 ++"$BIN" reshim dummy >setup_out 2>setup_err || fail "F2 setup reshim: $(sed -n l setup_err)" ++grep -q "1.0.0" "$ASDF_DATA_DIR/shims/dummy" || fail "F2 setup dummy shim did not advertise 1.0.0" ++grep -q "1.1.0" "$ASDF_DATA_DIR/shims/dummy" || fail "F2 setup dummy shim did not advertise 1.1.0" ++"$BIN" uninstall dummy 1.0.0 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++[ -f out ] || fail "F2 stdout capture missing" ++ ++[ -f err ] || fail "F2 stderr capture missing" ++[ ! -d "$ASDF_DATA_DIR/installs/dummy/1.0.0" ] || fail "F2 1.0.0 install directory still exists" ++[ -d "$ASDF_DATA_DIR/installs/dummy/1.1.0" ] || fail "F2 1.1.0 install directory was removed" ++assert_shim_advertises_only "$ASDF_DATA_DIR/shims/dummy" "1.1.0" "F2 dummy shim" ++assert_shim_advertises_only "$ASDF_DATA_DIR/shims/other_bin" "1.1.0" "F2 other_bin shim" ++ ++ ++ ++ ++setup_case f3_missing_args ++"$BIN" uninstall >out_no_tool 2>err_no_tool; ec_no_tool=$? ++"$BIN" uninstall dummy >out_no_version 2>err_no_version; ec_no_version=$? ++write_expected expected_missing "No plugin given" ++[ "$ec_no_tool" -ne 0 ] || fail "F3 no-tool exit was zero" ++[ "$ec_no_version" -ne 0 ] || fail "F3 no-version exit was zero" ++ ++[ -f out_no_tool ] || fail "F3 no-tool stdout capture missing" ++ ++[ -f out_no_version ] || fail "F3 no-version stdout capture missing" ++ ++assert_file_has_line err_no_tool "No plugin given" "F3 no-tool stderr" ++ ++assert_file_has_line err_no_version "No plugin given" "F3 no-version stderr" ++ ++ ++ ++ ++setup_case f4_latest_rejected ++"$BIN" uninstall dummy latest >out 2>err; ec=$? ++write_expected expected_err "'latest' is a special version value that cannot be used for uninstall command" ++[ "$ec" -ne 0 ] || fail "F4 exit was zero" ++ ++[ -f out ] || fail "F4 stdout capture missing" ++ ++assert_file_has_line err "'latest' is a special version value that cannot be used for uninstall command" "F4 stderr" ++ ++ ++ ++ ++setup_case f5_not_installed ++"$BIN" uninstall dummy 9.9.9 >out 2>err; ec=$? ++write_expected expected_err "No such version" ++[ "$ec" -ne 0 ] || fail "F5 exit was zero" ++ ++[ -f out ] || fail "F5 stdout capture missing" ++ ++assert_file_has_line err "No such version" "F5 stderr" ++ ++ ++ ++ ++setup_case f6_config_load_failure ++install_dummy_version 1.0.0 ++printf '[\n' >"$ASDF_CONFIG_FILE" ++"$BIN" uninstall dummy 1.0.0 >out 2>err; ec=$? ++write_expected expected_err "unclosed section: [" ++[ "$ec" -ne 0 ] || fail "F6 exit was zero" ++ ++[ -f out ] || fail "F6 stdout capture missing" ++ ++assert_nonempty_file err "F6 stderr" ++[ -d "$ASDF_DATA_DIR/installs/dummy/1.0.0" ] || fail "F6 install directory should remain" ++ ++ ++ ++ ++setup_case f7_pre_hook_failure ++install_dummy_version 1.0.0 ++cat >"$CASE_DIR/failing-pre-hook" <<'EOF' ++#!/usr/bin/env bash ++echo hook stdout before failure ++echo hook stderr detail >&2 ++exit 37 ++EOF ++chmod +x "$CASE_DIR/failing-pre-hook" ++printf 'pre_asdf_uninstall_dummy = %s $1\n' "$CASE_DIR/failing-pre-hook" >"$ASDF_CONFIG_FILE" ++"$BIN" uninstall dummy 1.0.0 >out 2>err; ec=$? ++write_expected expected_out "hook stdout before failure" ++write_expected expected_err "hook stderr detail" "exit status 37" ++[ "$ec" -ne 0 ] || fail "F7 exit was zero" ++ ++assert_file_has_line out "hook stdout before failure" "F7 stdout" ++ ++assert_file_has_line err "hook stderr detail" "F7 stderr" ++assert_file_contains_text err "37" "F7 stderr" ++[ -d "$ASDF_DATA_DIR/installs/dummy/1.0.0" ] || fail "F7 install directory should remain" ++ ++ ++ ++ ++setup_case f8_callback_failure ++install_dummy_version 1.0.0 ++cat >"$ASDF_DATA_DIR/plugins/dummy/bin/uninstall" <<'EOF' ++#!/usr/bin/env bash ++echo callback before failure ++echo callback err detail >&2 ++exit 42 ++EOF ++chmod +x "$ASDF_DATA_DIR/plugins/dummy/bin/uninstall" ++printf 'post_asdf_uninstall_dummy = echo should not run\n' >"$ASDF_CONFIG_FILE" ++"$BIN" uninstall dummy 1.0.0 >out 2>err; ec=$? ++write_expected expected_out "callback before failure" ++write_expected expected_err "callback err detail" "exit status 42" ++[ "$ec" -ne 0 ] || fail "F8 exit was zero" ++ ++assert_file_has_line out "callback before failure" "F8 stdout" ++ ++assert_file_has_line err "callback err detail" "F8 stderr" ++assert_file_contains_text err "42" "F8 stderr" ++assert_file_lacks_text out "should not run" "F8 stdout" ++assert_file_lacks_text err "should not run" "F8 stderr" ++[ -d "$ASDF_DATA_DIR/installs/dummy/1.0.0" ] || fail "F8 install directory should remain" ++ ++ ++ ++ ++setup_case f9_remove_failure ++"$BIN" uninstall dummy path:/proc/self >out 2>err; ec=$? ++write_expected expected_err "openfdat /proc/self: operation not permitted" ++[ "$ec" -ne 0 ] || fail "F9 exit was zero" ++ ++[ -f out ] || fail "F9 stdout capture missing" ++ ++assert_file_contains_text err "/proc/self" "F9 stderr" ++ ++ ++ ++ ++setup_case f10_post_hook_failure ++install_dummy_version 1.0.0 ++cat >"$CASE_DIR/failing-post-hook" <<'EOF' ++#!/usr/bin/env bash ++echo post hook stdout before failure ++echo post hook stderr detail >&2 ++exit 38 ++EOF ++chmod +x "$CASE_DIR/failing-post-hook" ++printf 'post_asdf_uninstall_dummy = %s $1\n' "$CASE_DIR/failing-post-hook" >"$ASDF_CONFIG_FILE" ++"$BIN" uninstall dummy 1.0.0 >out 2>err; ec=$? ++write_expected expected_out "post hook stdout before failure" ++write_expected expected_err "post hook stderr detail" "exit status 38" ++[ "$ec" -ne 0 ] || fail "F10 exit was zero" ++ ++assert_file_has_line out "post hook stdout before failure" "F10 stdout" ++ ++assert_file_has_line err "post hook stderr detail" "F10 stderr" ++assert_file_contains_text err "38" "F10 stderr" ++[ ! -d "$ASDF_DATA_DIR/installs/dummy/1.0.0" ] || fail "F10 install directory should have been removed before post hook failure" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++ ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000462/tests/test.sh b/tasks/format-code-task-000462/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000462/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-000462/tests/test_command.sh b/tasks/format-code-task-000462/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000462/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-000491/environment/Dockerfile b/tasks/format-code-task-000491/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8fbc67186ef94780378f2dc5ff5d23f24241ec11 --- /dev/null +++ b/tasks/format-code-task-000491/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fdbd3d6becc7286bc4e84643acf2f7443c15811eb066dddb0a3a5639eca5cc99 diff --git a/tasks/format-code-task-000491/environment/setup/files/blocklist b/tasks/format-code-task-000491/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000491/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000491/environment/setup/setup.sh b/tasks/format-code-task-000491/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000491/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000491/tests/test.patch b/tasks/format-code-task-000491/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..57e6e13b0fcce141a4e78e587a5ed5848c8c1d79 --- /dev/null +++ b/tasks/format-code-task-000491/tests/test.patch @@ -0,0 +1,100 @@ +diff --git a/e2e_tests/stack_sync_delete_merged_test.go b/e2e_tests/stack_sync_delete_merged_test.go +index 9cc98d0b..a837659f 100644 +--- a/e2e_tests/stack_sync_delete_merged_test.go ++++ b/e2e_tests/stack_sync_delete_merged_test.go +@@ -75,10 +75,75 @@ func TestStackSyncDeleteMerged(t *testing.T) { + tx.SetBranch(stack1Meta) + require.NoError(t, tx.Commit()) + ++ repo.Git(t, "switch", "stack-1") + RequireAv(t, "stack", "sync", "--prune=yes") + + require.Equal(t, 1, + Cmd(t, "git", "show-ref", "refs/heads/stack-1").ExitCode, + "stack-1 should be deleted after merge", + ) ++ require.Equal(t, "refs/heads/main\n", ++ repo.Git(t, "rev-parse", "--symbolic-full-name", "HEAD"), ++ "HEAD should be on main after stack-1 is deleted", ++ ) ++} ++ ++func TestStackSyncDeleteMerged_NoMain(t *testing.T) { ++ server := RunMockGitHubServer(t) ++ defer server.Close() ++ repo := gittest.NewTempRepoWithGitHubServer(t, server.URL) ++ Chdir(t, repo.RepoDir) ++ ++ RequireAv(t, "stack", "branch", "stack-1") ++ repo.CommitFile(t, "my-file", "1a\n", gittest.WithMessage("Commit 1a")) ++ repo.Git(t, "push", "origin", "stack-1:refs/pull/42/head") ++ ++ var squashCommit plumbing.Hash ++ repo.WithCheckoutBranch(t, "refs/heads/main", func() { ++ repo.Git(t, "merge", "--squash", "stack-1") ++ ++ ++ repo.Git(t, "commit", "--no-edit") ++ ++ squashCommit = repo.GetCommitAtRef(t, plumbing.HEAD) ++ ++ repo.Git(t, "push", "origin", "main") ++ }) ++ ++ server.pulls = append(server.pulls, mockPR{ ++ ID: "nodeid-42", ++ Number: 42, ++ State: "MERGED", ++ HeadRefName: "stack-1", ++ MergeCommitOID: squashCommit.String(), ++ }) ++ ++ ++ ++ ++ ++ db := repo.OpenDB(t) ++ tx := db.WriteTx() ++ stack1Meta, _ := tx.Branch("stack-1") ++ stack1Meta.PullRequest = &meta.PullRequest{ID: "nodeid-42", Number: 42} ++ tx.SetBranch(stack1Meta) ++ require.NoError(t, tx.Commit()) ++ ++ repo.Git(t, "switch", "stack-1") ++ repo.Git(t, "branch", "-D", "main") ++ RequireAv(t, "stack", "sync", "--prune=yes") ++ ++ require.Equal(t, 1, ++ Cmd(t, "git", "show-ref", "refs/heads/stack-1").ExitCode, ++ "stack-1 should be deleted after merge", ++ ) ++ require.Equal(t, "HEAD\n", ++ repo.Git(t, "rev-parse", "--symbolic-full-name", "HEAD"), ++ "HEAD should be on a detached HEAD after stack-1 is deleted", ++ ) ++ require.Equal(t, ++ repo.Git(t, "rev-parse", "HEAD"), ++ repo.Git(t, "rev-parse", "origin/main"), ++ "HEAD should be on origin/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,4 @@ ++H4sIAAAAAAAAA+3RwUrDQBDG8T33KYbem+zErnkBr57qPaTZoYptAsmm4Nub5qAiaC8tIv3/LjPL ++DuwsX7YdX/axsvaYu2vxkzKEuU6+17nXUKiWGvSucF41lKWTcLWNvhiHVPciru+69Nvcuft/KvvM ++P9mQqqY7HOo2ZsPz5d44l7/68JG/D+sp//W9Fk785Vb42Y3n30SZg99aXOw6ObWyOsqqH1tZPk2n ++Taqb181b2zzY3pI9Wr+zuJQst8Kq0/iQL/76EwAAAAAAAAAAAAAAAMCNegddeamCACgAAA== +diff --git 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-000491/tests/test.sh b/tasks/format-code-task-000491/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dea0eb3cd60b56920d8312dc29dc9e0f0339c15f --- /dev/null +++ b/tasks/format-code-task-000491/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' +e2e_tests/stack_sync_delete_merged_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-000491/tests/test_command.sh b/tasks/format-code-task-000491/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000491/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000496/environment/Dockerfile b/tasks/format-code-task-000496/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..091fd202f6ab387212954c787b31ef0f4232a0e5 --- /dev/null +++ b/tasks/format-code-task-000496/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e98e8f25d443adb41a721c8e31076583d647af158ecf02f73118c421076daa09 diff --git a/tasks/format-code-task-000496/environment/setup/files/blocklist b/tasks/format-code-task-000496/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000496/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000496/environment/setup/setup.sh b/tasks/format-code-task-000496/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000496/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000496/tests/test.patch b/tasks/format-code-task-000496/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..32c405415835b2ca2d562f17ea556f8c48aa79f2 --- /dev/null +++ b/tasks/format-code-task-000496/tests/test.patch @@ -0,0 +1,132 @@ +diff --git a/test/unit/module/template/transforms/test_language_extensions.py b/test/unit/module/template/transforms/test_language_extensions.py +index 921929e7c..a2f9b941d 100644 +--- a/test/unit/module/template/transforms/test_language_extensions.py ++++ b/test/unit/module/template/transforms/test_language_extensions.py +@@ -395,6 +395,105 @@ class TestFindInMap(TestCase): + "Production", + ) + ++ def test_find_in_map_default_value_when_second_key_missing(self): ++ """Issue: 4-element FindInMap with DefaultValue should fall back to the ++ default when the top-level key is present in the mapping but the ++ second-level key is absent (mapping.get(top, {}).get(second) is None). ++ """ ++ template_obj = convert_dict( ++ { ++ "Mappings": { ++ "Roles": { ++ "A": {"Subjects": ["repo:org/repo:ref:*"]}, ++ }, ++ }, ++ } ++ ) ++ cfn = Template( ++ filename="", template=template_obj, regions=["us-east-1"] ++ ) ++ ++ m = _ForEachValueFnFindInMap( ++ "a", ["Roles", "A", "Source", {"DefaultValue": "Github"}] ++ ) ++ ++ self.assertEqual(m.value(cfn, None, False, True), "Github") ++ ++ def test_find_in_map_default_value_returns_actual_value_when_present(self): ++ """Preservation: when the second-level key IS present, the actual ++ value is returned (DefaultValue is not used).""" ++ template_obj = convert_dict( ++ { ++ "Mappings": { ++ "Roles": { ++ "A": { ++ "Subjects": ["repo:org/repo:ref:*"], ++ "Source": "Jenkins", ++ }, ++ }, ++ }, ++ } ++ ) ++ cfn = Template( ++ filename="", template=template_obj, regions=["us-east-1"] ++ ) ++ ++ m = _ForEachValueFnFindInMap( ++ "a", ["Roles", "A", "Source", {"DefaultValue": "Github"}] ++ ) ++ ++ ++ self.assertEqual(m.value(cfn, None, False, True), "Jenkins") ++ ++ def test_find_in_map_no_list_fallback_raises_resolve_error_4_element(self): ++ """4-element FindInMap, default_on_resolver_failure=False, ++ second-level key missing, and no list value to fall back on: ++ the resolver must raise _ResolveError (not silently return None).""" ++ template_obj = convert_dict( ++ { ++ "Mappings": { ++ "Roles": { ++ "A": {"OnlyString": "value"}, ++ }, ++ }, ++ } ++ ) ++ cfn = Template( ++ filename="", template=template_obj, regions=["us-east-1"] ++ ) ++ ++ m = _ForEachValueFnFindInMap( ++ "a", ["Roles", "A", "Source", {"DefaultValue": "Github"}] ++ ) ++ ++ self.assertEqual(m.value(cfn, None, False, True), "Github") ++ ++ with self.assertRaises(_ResolveError): ++ m.value(cfn, None, False, False) ++ ++ def test_find_in_map_no_default_no_list_fallback_raises_resolve_error(self): ++ """3-element FindInMap (no DefaultValue), top-level key present, ++ second-level key missing, no list value to fall back on: the ++ resolver must raise _ResolveError (not silently return None).""" ++ template_obj = convert_dict( ++ { ++ "Mappings": { ++ "Roles": { ++ "A": {"OnlyString": "value"}, ++ }, ++ }, ++ } ++ ) ++ cfn = Template( ++ filename="", template=template_obj, regions=["us-east-1"] ++ ) ++ ++ m = _ForEachValueFnFindInMap("a", ["Roles", "A", "Source"]) ++ with self.assertRaises(_ResolveError): ++ m.value(cfn, None, False, True) ++ with self.assertRaises(_ResolveError): ++ m.value(cfn, None, False, False) ++ + + class TestTransform(TestCase): + def setUp(self) -> None: +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..3d1fde5b1 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest test/unit/module/template/transforms/test_language_extensions.py -k \"test_find_in_map_default_value_when_second_key_missing or test_find_in_map_default_value_returns_actual_value_when_present or test_find_in_map_no_list_fallback_raises_resolve_error_4_element or test_find_in_map_no_default_no_list_fallback_raises_resolve_error\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest -rA test/unit/module/template/transforms/test_language_extensions.py::TestFindInMap::test_find_in_map_default_value_when_second_key_missing test/unit/module/template/transforms/test_language_extensions.py::TestFindInMap::test_find_in_map_default_value_returns_actual_value_when_present test/unit/module/template/transforms/test_language_extensions.py::TestFindInMap::test_find_in_map_no_list_fallback_raises_resolve_error_4_element test/unit/module/template/transforms/test_language_extensions.py::TestFindInMap::test_find_in_map_no_default_no_list_fallback_raises_resolve_error ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000496/tests/test.sh b/tasks/format-code-task-000496/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81a6a415833615c0f766f9d64785270a85ea0d00 --- /dev/null +++ b/tasks/format-code-task-000496/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/module/template/transforms/test_language_extensions.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-000496/tests/test_command.sh b/tasks/format-code-task-000496/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000496/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000498/environment/Dockerfile b/tasks/format-code-task-000498/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..280c396ade6890bb29b657b64851c298da78127b --- /dev/null +++ b/tasks/format-code-task-000498/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:01f392e293b52b8d0b0d10e04702b1584de6c4518b4c9e5d816419843051d7ac diff --git a/tasks/format-code-task-000498/environment/setup/files/blocklist b/tasks/format-code-task-000498/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000498/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000498/environment/setup/setup.sh b/tasks/format-code-task-000498/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000498/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000498/tests/test.patch b/tasks/format-code-task-000498/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9da95e0afa0ddc19afffabd432e3b901b84ace9e --- /dev/null +++ b/tasks/format-code-task-000498/tests/test.patch @@ -0,0 +1,152 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..26a409161 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/functional/event_handler/required_dependencies/test_api_gateway.py -k \"additional_service_error_classes_exist or forbidden_error_response or request_timeout_error_response or request_entity_too_large_error_response or service_unavailable_error_response\" -v"] ++} +diff --git a/tests/functional/event_handler/required_dependencies/test_api_gateway.py b/tests/functional/event_handler/required_dependencies/test_api_gateway.py +index fdab6080f..b803bfbb3 100644 +--- a/tests/functional/event_handler/required_dependencies/test_api_gateway.py ++++ b/tests/functional/event_handler/required_dependencies/test_api_gateway.py +@@ -921,6 +921,125 @@ def test_service_error_responses(json_dump): + assert result["body"] == json_dump(expected) + + ++def test_additional_service_error_classes_exist(): ++ ++ ++ from http import HTTPStatus ++ ++ from aws_lambda_powertools.event_handler.exceptions import ( ++ ForbiddenError, ++ RequestEntityTooLargeError, ++ RequestTimeoutError, ++ ServiceError, ++ ServiceUnavailableError, ++ ) ++ ++ ++ fe = ForbiddenError("forbidden msg") ++ assert isinstance(fe, ServiceError) ++ assert fe.status_code == HTTPStatus.FORBIDDEN ++ assert fe.status_code == 403 ++ assert fe.msg == "forbidden msg" ++ ++ rte = RequestTimeoutError("timeout msg") ++ assert isinstance(rte, ServiceError) ++ assert rte.status_code == HTTPStatus.REQUEST_TIMEOUT ++ assert rte.status_code == 408 ++ assert rte.msg == "timeout msg" ++ ++ rel = RequestEntityTooLargeError("too large msg") ++ assert isinstance(rel, ServiceError) ++ assert rel.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE ++ assert rel.status_code == 413 ++ assert rel.msg == "too large msg" ++ ++ sue = ServiceUnavailableError("unavailable msg") ++ assert isinstance(sue, ServiceError) ++ assert sue.status_code == HTTPStatus.SERVICE_UNAVAILABLE ++ assert sue.status_code == 503 ++ assert sue.msg == "unavailable msg" ++ ++ ++def test_forbidden_error_response(json_dump): ++ ++ from aws_lambda_powertools.event_handler.exceptions import ForbiddenError ++ ++ app = ApiGatewayResolver() ++ ++ @app.get(rule="/forbidden-error") ++ def forbidden_error(): ++ raise ForbiddenError("Forbidden") ++ ++ ++ result = app({"path": "/forbidden-error", "httpMethod": "GET"}, None) ++ ++ ++ assert result["statusCode"] == 403 ++ assert result["multiValueHeaders"]["Content-Type"] == [content_types.APPLICATION_JSON] ++ expected = {"statusCode": 403, "message": "Forbidden"} ++ assert result["body"] == json_dump(expected) ++ ++ ++def test_request_timeout_error_response(json_dump): ++ ++ from aws_lambda_powertools.event_handler.exceptions import RequestTimeoutError ++ ++ app = ApiGatewayResolver() ++ ++ @app.get(rule="/request-timeout-error") ++ def request_timeout_error(): ++ raise RequestTimeoutError("Request timed out") ++ ++ ++ result = app({"path": "/request-timeout-error", "httpMethod": "GET"}, None) ++ ++ ++ assert result["statusCode"] == 408 ++ assert result["multiValueHeaders"]["Content-Type"] == [content_types.APPLICATION_JSON] ++ expected = {"statusCode": 408, "message": "Request timed out"} ++ assert result["body"] == json_dump(expected) ++ ++ ++def test_request_entity_too_large_error_response(json_dump): ++ ++ from aws_lambda_powertools.event_handler.exceptions import RequestEntityTooLargeError ++ ++ app = ApiGatewayResolver() ++ ++ @app.get(rule="/payload-too-large-error") ++ def payload_too_large_error(): ++ raise RequestEntityTooLargeError("Payload too large") ++ ++ ++ result = app({"path": "/payload-too-large-error", "httpMethod": "GET"}, None) ++ ++ ++ assert result["statusCode"] == 413 ++ assert result["multiValueHeaders"]["Content-Type"] == [content_types.APPLICATION_JSON] ++ expected = {"statusCode": 413, "message": "Payload too large"} ++ assert result["body"] == json_dump(expected) ++ ++ ++def test_service_unavailable_error_response(json_dump): ++ ++ from aws_lambda_powertools.event_handler.exceptions import ServiceUnavailableError ++ ++ app = ApiGatewayResolver() ++ ++ @app.get(rule="/service-unavailable-error") ++ def service_unavailable_error(): ++ raise ServiceUnavailableError("Service unavailable") ++ ++ ++ result = app({"path": "/service-unavailable-error", "httpMethod": "GET"}, None) ++ ++ ++ assert result["statusCode"] == 503 ++ assert result["multiValueHeaders"]["Content-Type"] == [content_types.APPLICATION_JSON] ++ expected = {"statusCode": 503, "message": "Service unavailable"} ++ assert result["body"] == json_dump(expected) ++ ++ + def test_debug_unhandled_exceptions_debug_on(): + # GIVEN debug is enabled + # AND an unhandled exception is raised +diff --git 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/functional/event_handler/required_dependencies/test_api_gateway.py -k "additional_service_error_classes_exist or forbidden_error_response or request_timeout_error_response or request_entity_too_large_error_response or service_unavailable_error_response" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000498/tests/test.sh b/tasks/format-code-task-000498/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..36c9a8d95d5abcc9b893c6766a24c14540a53e04 --- /dev/null +++ b/tasks/format-code-task-000498/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/functional/event_handler/required_dependencies/test_api_gateway.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-000498/tests/test_command.sh b/tasks/format-code-task-000498/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000498/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000603/environment/Dockerfile b/tasks/format-code-task-000603/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e198e302654725960c2c405025491a7ba846cc8b --- /dev/null +++ b/tasks/format-code-task-000603/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:21816500b0e2140886df4134ebdb0e7fbeb8680774a5d25a50b21635edeceed0 diff --git a/tasks/format-code-task-000603/environment/setup/files/blocklist b/tasks/format-code-task-000603/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000603/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000603/environment/setup/setup.sh b/tasks/format-code-task-000603/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000603/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000603/tests/test.patch b/tasks/format-code-task-000603/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8f562281980c63612a3e07cbdcc062aa7f2a2aa2 --- /dev/null +++ b/tasks/format-code-task-000603/tests/test.patch @@ -0,0 +1,521 @@ +diff --git a/usercase-test-coderl/fresh_state_child.test.ts b/usercase-test-coderl/fresh_state_child.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fresh_state_child.test.ts +@@ -0,0 +1,51 @@ ++import { expect, it, vi } from 'vitest'; ++import axios from 'axios'; ++import { getTransactions as getZkSyncTransactions } from '../src/blockchains/zksync/transaction.ts'; ++ ++vi.mock('axios', () => ({ ++ default: { ++ get: vi.fn(), ++ }, ++})); ++ ++it('returns the pinned zkSync transaction in a fresh process', async () => { ++ vi.mocked(axios.get).mockResolvedValueOnce({ ++ status: 200, ++ data: { ++ status: '1', ++ result: [ ++ { ++ blockNumber: 101, ++ timeStamp: 1700000001, ++ hash: '0xzkA', ++ from: '0xabc', ++ to: '0x111', ++ value: 7, ++ gas: 21000, ++ gasPrice: 11, ++ gasUsed: 21000, ++ input: '0x', ++ contractAddress: '', ++ transfers: [{ tokenSymbol: 'ETH', transferPrice: 12.5 }], ++ }, ++ ], ++ }, ++ }); ++ ++ await expect(getZkSyncTransactions('0xabc')).resolves.toEqual([ ++ { ++ blockNumber: 101, ++ timeStamp: 1700000001, ++ hash: '0xzkA', ++ from: '0xabc', ++ to: '0x111', ++ value: 7, ++ gas: 21000, ++ gasPrice: 11, ++ gasUsed: 21000, ++ input: '0x', ++ contractAddress: '', ++ transfers: [{ tokenSymbol: 'ETH', transferPrice: 12.5 }], ++ }, ++ ]); ++}); +diff --git a/usercase-test-coderl/transactions.test.ts b/usercase-test-coderl/transactions.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/transactions.test.ts +@@ -0,0 +1,437 @@ ++import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; ++import axios from 'axios'; ++import { getTransactions as getScrollTransactions } from '../src/blockchains/scroll/transaction.ts'; ++import { getTransactions as getZkSyncTransactions } from '../src/blockchains/zksync/transaction.ts'; ++ ++vi.mock('axios', () => ({ ++ default: { ++ get: vi.fn(), ++ }, ++})); ++ ++const mockedAxiosGet = vi.mocked(axios.get); ++ ++const zksyncUrl = 'https://block-explorer-api.mainnet.zksync.io/api'; ++const scrollUrl = 'https://api.scrollscan.com/api'; ++ ++const txA = { ++ blockNumber: 101, ++ timeStamp: 1700000001, ++ hash: '0xzkA', ++ from: '0xabc', ++ to: '0x111', ++ value: 7, ++ gas: 21000, ++ gasPrice: 11, ++ gasUsed: 21000, ++ input: '0x', ++ contractAddress: '', ++ transfers: [{ tokenSymbol: 'ETH', transferPrice: 12.5 }], ++}; ++ ++const txB = { ++ blockNumber: 5252, ++ timeStamp: 1700000525, ++ hash: '0xzkB', ++ from: '0x222', ++ to: '0xabc', ++ value: 19, ++ gas: 44000, ++ gasPrice: 13, ++ gasUsed: 33000, ++ input: '0x1234', ++ contractAddress: '0xcontractB', ++ transfers: [], ++}; ++ ++const normalTx = { ++ blockNumber: 700, ++ timeStamp: 1700000700, ++ hash: '0xscrollNormal', ++ nonce: 9, ++ blockHash: '0xblockNormal', ++ transactionIndex: 4, ++ from: '0xdef', ++ to: '0x999', ++ value: 123, ++ gas: 50000, ++ gasPrice: 22, ++ isError: 0, ++ txreceipt_status: 1, ++ input: '0xabcd', ++ contractAddress: '', ++ cumulativeGasUsed: 60000, ++ gasUsed: 49000, ++ confirmations: 88, ++ methodId: '0xabcd1234', ++ functionName: 'swap()', ++ transfers: [{ tokenSymbol: 'ETH', transferPrice: 42 }], ++}; ++ ++const internalDifferentHash = { ++ blockNumber: 710, ++ timeStamp: 1700000710, ++ hash: '0xscrollInternalOnly', ++ from: '0xbridge', ++ to: '0xdef', ++ value: 321, ++ gas: 81000, ++ gasUsed: 80000, ++ input: '0xfeed', ++ contractAddress: '0xinternalContract', ++ isError: 0, ++}; ++ ++const zksyncInitialParams = (address: string, startblock = 0) => ({ ++ params: { ++ module: 'account', ++ action: 'txlist', ++ address, ++ startblock, ++ endblock: 99999999999999, ++ sort: 'asc', ++ offset: 1000, ++ }, ++}); ++ ++const scrollParams = (action: 'txlist' | 'txlistinternal', address: string, startblock = 0) => ({ ++ params: { ++ module: 'account', ++ action, ++ address, ++ startblock, ++ endblock: 99999999999999, ++ sort: 'asc', ++ offset: 1000, ++ }, ++}); ++ ++const okPage = (result: unknown[]) => ({ ++ status: 200, ++ data: { ++ status: '1', ++ result, ++ }, ++}); ++ ++const statusZeroPage = (message: string) => ({ ++ status: 200, ++ data: { ++ status: '0', ++ message, ++ result: [], ++ }, ++}); ++ ++const generatedTxPage = (prefix: string, lastBlock: number) => ++ Array.from({ length: 1000 }, (_, index) => ({ ++ blockNumber: index === 999 ? lastBlock : 1000 + index, ++ timeStamp: 1710000000 + index, ++ hash: `${prefix}${index}`, ++ from: '0xpageFrom', ++ to: '0xpageTo', ++ value: index, ++ gas: 21000 + index, ++ gasPrice: 30, ++ gasUsed: 20000 + index, ++ input: '0x', ++ contractAddress: '', ++ ++ isError: 0, ++ transfers: [], ++ })); ++ ++beforeEach(() => { ++ mockedAxiosGet.mockReset(); ++ vi.spyOn(console, 'error').mockImplementation(() => undefined); ++}); ++ ++afterEach(() => { ++ vi.restoreAllMocks(); ++}); ++ ++describe('chain transaction history retrieval', () => { ++ it('returns the first successful zkSync txlist page and sends the declared explorer params', async () => { ++ ++ ++ mockedAxiosGet.mockResolvedValueOnce(okPage([txA])); ++ ++ const actual = await getZkSyncTransactions('0xabc'); ++ ++ expect(actual).toEqual([ ++ { ++ blockNumber: 101, ++ timeStamp: 1700000001, ++ hash: '0xzkA', ++ from: '0xabc', ++ to: '0x111', ++ value: 7, ++ gas: 21000, ++ gasPrice: 11, ++ gasUsed: 21000, ++ input: '0x', ++ contractAddress: '', ++ transfers: [{ tokenSymbol: 'ETH', transferPrice: 12.5 }], ++ }, ++ ]); ++ expect(mockedAxiosGet).toHaveBeenCalledTimes(1); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(1, zksyncUrl, zksyncInitialParams('0xabc')); ++ }); ++ ++ it('continues zkSync pagination after a full 1000 item page and concatenates fetch-order pages', async () => { ++ ++ ++ const firstPage = generatedTxPage('0xzkBulk', 4242); ++ mockedAxiosGet.mockResolvedValueOnce(okPage(firstPage)).mockResolvedValueOnce(okPage([txB])); ++ ++ const actual = await getZkSyncTransactions('0xabc'); ++ ++ expect(actual).toEqual([...firstPage, txB]); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(1, zksyncUrl, zksyncInitialParams('0xabc', 0)); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(2, zksyncUrl, zksyncInitialParams('0xabc', 4242)); ++ }); ++ ++ it('keeps only the normal Scroll transaction when an internal transaction has the same hash', async () => { ++ ++ ++ mockedAxiosGet ++ .mockResolvedValueOnce(okPage([normalTx])) ++ .mockResolvedValueOnce(okPage([{ ...internalDifferentHash, hash: '0xscrollNormal' }])); ++ ++ const actual = await getScrollTransactions('0xdef'); ++ ++ expect(actual).toEqual([ ++ { ++ blockNumber: 700, ++ timeStamp: 1700000700, ++ hash: '0xscrollNormal', ++ nonce: 9, ++ blockHash: '0xblockNormal', ++ transactionIndex: 4, ++ from: '0xdef', ++ to: '0x999', ++ value: 123, ++ gas: 50000, ++ gasPrice: 22, ++ isError: 0, ++ txreceipt_status: 1, ++ input: '0xabcd', ++ contractAddress: '', ++ cumulativeGasUsed: 60000, ++ gasUsed: 49000, ++ confirmations: 88, ++ methodId: '0xabcd1234', ++ functionName: 'swap()', ++ transfers: [{ tokenSymbol: 'ETH', transferPrice: 42 }], ++ }, ++ ]); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(1, scrollUrl, scrollParams('txlist', '0xdef')); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(2, scrollUrl, scrollParams('txlistinternal', '0xdef')); ++ }); ++ ++ it('appends a different-hash Scroll internal transaction with unsupported fields filled by defaults', async () => { ++ ++ ++ mockedAxiosGet.mockResolvedValueOnce(okPage([normalTx])).mockResolvedValueOnce(okPage([internalDifferentHash])); ++ ++ const actual = await getScrollTransactions('0xdef'); ++ ++ expect(actual).toEqual([ ++ normalTx, ++ { ++ blockHash: '', ++ confirmations: 0, ++ contractAddress: '0xinternalContract', ++ cumulativeGasUsed: 0, ++ from: '0xbridge', ++ functionName: '', ++ gas: 81000, ++ gasPrice: 0, ++ gasUsed: 80000, ++ hash: '0xscrollInternalOnly', ++ input: '0xfeed', ++ isError: 0, ++ methodId: '', ++ nonce: 0, ++ timeStamp: 1700000710, ++ to: '0xdef', ++ transactionIndex: 0, ++ transfers: [], ++ txreceipt_status: 0, ++ value: 321, ++ blockNumber: 710, ++ }, ++ ]); ++ }); ++ ++ it('pages Scroll internal transactions with txlistinternal and the same startblock boundary behavior', async () => { ++ ++ ++ const firstInternalPage = generatedTxPage('0xscrollInternalBulk', 9090); ++ const finalInternalTx = { ++ ...internalDifferentHash, ++ hash: '0xscrollInternalFinal', ++ blockNumber: 9091, ++ timeStamp: 1700009091, ++ }; ++ mockedAxiosGet ++ .mockResolvedValueOnce(okPage([])) ++ .mockResolvedValueOnce(okPage(firstInternalPage)) ++ .mockResolvedValueOnce(okPage([finalInternalTx])); ++ ++ const actual = await getScrollTransactions('0xdef'); ++ ++ expect(actual).toEqual([ ++ ...firstInternalPage.map((internalTransaction) => ({ ++ blockHash: '', ++ confirmations: 0, ++ contractAddress: internalTransaction.contractAddress, ++ cumulativeGasUsed: 0, ++ from: internalTransaction.from, ++ functionName: '', ++ gas: internalTransaction.gas, ++ gasPrice: 0, ++ gasUsed: internalTransaction.gasUsed, ++ hash: internalTransaction.hash, ++ input: internalTransaction.input, ++ isError: internalTransaction.isError, ++ methodId: '', ++ nonce: 0, ++ timeStamp: internalTransaction.timeStamp, ++ to: internalTransaction.to, ++ transactionIndex: 0, ++ transfers: [], ++ txreceipt_status: 0, ++ value: internalTransaction.value, ++ blockNumber: internalTransaction.blockNumber, ++ })), ++ { ++ blockHash: '', ++ confirmations: 0, ++ contractAddress: '0xinternalContract', ++ cumulativeGasUsed: 0, ++ from: '0xbridge', ++ functionName: '', ++ gas: 81000, ++ gasPrice: 0, ++ gasUsed: 80000, ++ hash: '0xscrollInternalFinal', ++ input: '0xfeed', ++ isError: 0, ++ methodId: '', ++ nonce: 0, ++ timeStamp: 1700009091, ++ to: '0xdef', ++ transactionIndex: 0, ++ transfers: [], ++ txreceipt_status: 0, ++ value: 321, ++ blockNumber: 9091, ++ }, ++ ]); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(1, scrollUrl, scrollParams('txlist', '0xdef', 0)); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(2, scrollUrl, scrollParams('txlistinternal', '0xdef', 0)); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(3, scrollUrl, scrollParams('txlistinternal', '0xdef', 9090)); ++ }); ++ ++ it('logs an explorer status zero message and returns transactions accumulated so far', async () => { ++ ++ ++ const firstPage = generatedTxPage('0xzkBeforeStatusZero', 8080); ++ mockedAxiosGet ++ .mockResolvedValueOnce(okPage(firstPage)) ++ .mockResolvedValueOnce(statusZeroPage('NOTOK: rate limit')); ++ ++ const actual = await getZkSyncTransactions('0xabc'); ++ ++ expect(actual).toEqual(firstPage); ++ expect(console.error).toHaveBeenCalledWith('Error occurred while retrieving transactions:', 'NOTOK: rate limit'); ++ }); ++ ++ it('logs a thrown HTTP request error and resolves with transactions accumulated so far', async () => { ++ ++ ++ const requestError = new TypeError('network down'); ++ mockedAxiosGet.mockResolvedValueOnce(okPage([normalTx])).mockRejectedValueOnce(requestError); ++ ++ const actual = await getScrollTransactions('0xdef'); ++ ++ expect(actual).toEqual([normalTx]); ++ expect(console.error).toHaveBeenCalledWith('Error occurred while making the request:', requestError); ++ }); ++}); ++ ++describe('additional transaction history contract checks', () => { ++ it('performs the declared zkSync explorer request for repeated calls', async () => { ++ mockedAxiosGet.mockResolvedValue(okPage([txA])); ++ ++ const first = await getZkSyncTransactions('0xabc'); ++ const second = await getZkSyncTransactions('0xabc'); ++ ++ ++ expect(first).toEqual([ ++ { ++ blockNumber: 101, ++ timeStamp: 1700000001, ++ hash: '0xzkA', ++ from: '0xabc', ++ to: '0x111', ++ value: 7, ++ gas: 21000, ++ gasPrice: 11, ++ gasUsed: 21000, ++ input: '0x', ++ contractAddress: '', ++ transfers: [{ tokenSymbol: 'ETH', transferPrice: 12.5 }], ++ }, ++ ]); ++ expect(second).toEqual(first); ++ expect(mockedAxiosGet).toHaveBeenCalledTimes(2); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(1, zksyncUrl, zksyncInitialParams('0xabc')); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(2, zksyncUrl, zksyncInitialParams('0xabc')); ++ }); ++ ++ it('uses the caller-provided address value in the zkSync explorer request', async () => { ++ mockedAxiosGet.mockResolvedValueOnce(okPage([txA])); ++ const callerInput = { address: '0xabc' }; ++ ++ await getZkSyncTransactions(callerInput.address); ++ ++ ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(1, zksyncUrl, zksyncInitialParams('0xabc')); ++ }); ++ ++ it('resolves with the first successful zkSync page in the current test process', async () => { ++ mockedAxiosGet.mockResolvedValueOnce(okPage([txA])); ++ const inProcess = await getZkSyncTransactions('0xabc'); ++ ++ ++ expect(inProcess).toEqual([ ++ { ++ blockNumber: 101, ++ timeStamp: 1700000001, ++ hash: '0xzkA', ++ from: '0xabc', ++ to: '0x111', ++ value: 7, ++ gas: 21000, ++ gasPrice: 11, ++ gasUsed: 21000, ++ input: '0x', ++ contractAddress: '', ++ transfers: [{ tokenSymbol: 'ETH', transferPrice: 12.5 }], ++ }, ++ ]); ++ }); ++ ++ it('performs the declared zkSync explorer request for a short successful page', async () => { ++ mockedAxiosGet.mockResolvedValueOnce(okPage([txA])); ++ ++ const actual = await getZkSyncTransactions('0xabc'); ++ ++ expect(actual).toEqual([txA]); ++ ++ expect(mockedAxiosGet).toHaveBeenCalledTimes(1); ++ expect(mockedAxiosGet).toHaveBeenNthCalledWith(1, zksyncUrl, zksyncInitialParams('0xabc')); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++if [ ! -x ./node_modules/.bin/vitest ]; then ++ echo "Missing prepared offline dependency: ./node_modules/.bin/vitest" >&2 ++ exit 127 ++fi ++exec ./node_modules/.bin/vitest run /workspace/repo/usercase-test-coderl/transactions.test.ts --reporter=verbose --pool=forks diff --git a/tasks/format-code-task-000603/tests/test.sh b/tasks/format-code-task-000603/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..67655dcfd4ee9a45ae626062e8fa254dc8ba55d3 --- /dev/null +++ b/tasks/format-code-task-000603/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/fresh_state_child.test.ts +usercase-test-coderl/transactions.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-000603/tests/test_command.sh b/tasks/format-code-task-000603/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000603/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-000605/environment/Dockerfile b/tasks/format-code-task-000605/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d9f75abbc367a380cd71a33fd4eaf4f64ebaf076 --- /dev/null +++ b/tasks/format-code-task-000605/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a2068a858ad998e64c86bcf473355f4f669a82b7f4225aa617bb819353d81504 diff --git a/tasks/format-code-task-000605/environment/setup/files/blocklist b/tasks/format-code-task-000605/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000605/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000605/environment/setup/setup.sh b/tasks/format-code-task-000605/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000605/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000605/tests/test.patch b/tasks/format-code-task-000605/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f5415f1011984c647f7ddb0d812a98ccb3b0f050 --- /dev/null +++ b/tasks/format-code-task-000605/tests/test.patch @@ -0,0 +1,259 @@ +diff --git a/test/data_join/test_dfs_client.py b/test/data_join/test_dfs_client.py +new file mode 100644 +index 00000000..f7b29dd0 +--- /dev/null ++++ b/test/data_join/test_dfs_client.py +@@ -0,0 +1,202 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++# coding: utf-8 ++ ++import os ++import shutil ++import sys ++import tempfile ++import types ++import unittest ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++sys.modules.setdefault('tensorflow_io', types.ModuleType('tensorflow_io')) ++sys.modules.setdefault('fedlearner.trainer', ++ types.ModuleType('fedlearner.trainer')) ++ ++ ++def _install_tf_stub(): ++ try: ++ from tensorflow.compat.v1 import gfile # noqa: F401 ++ return ++ except Exception: # pylint: disable=broad-except ++ pass ++ ++ class _OpError(Exception): ++ pass ++ ++ class _GFile(object): ++ @staticmethod ++ def Exists(path): ++ return os.path.exists(path) ++ ++ @staticmethod ++ def IsDirectory(path): ++ return os.path.isdir(path) ++ ++ @staticmethod ++ def ListDirectory(path): ++ return os.listdir(path) ++ ++ @staticmethod ++ def MakeDirs(path): ++ os.makedirs(path, exist_ok=True) ++ ++ @staticmethod ++ def Open(path, mode='r'): ++ return open(path, mode) ++ ++ @staticmethod ++ def Remove(path): ++ if not os.path.exists(path): ++ raise _OpError('not found: %s' % path) ++ os.remove(path) ++ ++ @staticmethod ++ def DeleteRecursively(path): ++ if not os.path.exists(path): ++ raise _OpError('not found: %s' % path) ++ shutil.rmtree(path) ++ ++ tf = types.ModuleType('tensorflow') ++ compat = types.ModuleType('tensorflow.compat') ++ v1 = types.ModuleType('tensorflow.compat.v1') ++ errors = types.ModuleType('tensorflow.compat.v1.errors') ++ errors.OpError = _OpError ++ gfile = _GFile() ++ v1.gfile = gfile ++ v1.errors = errors ++ compat.v1 = v1 ++ tf.compat = compat ++ tf.errors = errors ++ gfile_mod = types.ModuleType('tensorflow.compat.v1.gfile') ++ sys.modules['tensorflow'] = tf ++ sys.modules['tensorflow.compat'] = compat ++ sys.modules['tensorflow.compat.v1'] = v1 ++ sys.modules['tensorflow.compat.v1.errors'] = errors ++ sys.modules['tensorflow.compat.v1.gfile'] = gfile_mod ++ ++ ++_install_tf_stub() ++ ++from fedlearner.common.dfs_client import DFSClient ++ ++ ++class TestDFSClient(unittest.TestCase): ++ def setUp(self): ++ self.base_dir = tempfile.mkdtemp(prefix='dfs_test_') ++ self.client = DFSClient(self.base_dir) ++ ++ def tearDown(self): ++ shutil.rmtree(self.base_dir, ignore_errors=True) ++ ++ def test_set_get_roundtrip(self): ++ ++ self.assertIsNone(self.client.get_data('missing')) ++ ++ ++ self.assertTrue(self.client.set_data('fl_key', b'fl_value')) ++ self.assertEqual(self.client.get_data('fl_key'), b'fl_value') ++ ++ ++ self.assertTrue(self.client.set_data('fl_key1', 'fl_value')) ++ self.assertEqual(self.client.get_data('fl_key1'), b'fl_value') ++ ++ ++ self.assertTrue(self.client.set_data('fl_key', b'updated')) ++ self.assertEqual(self.client.get_data('fl_key'), b'updated') ++ ++ def test_cas(self): ++ self.client.set_data('fl_key', b'fl_value') ++ ++ self.assertFalse(self.client.cas('fl_key', b'wrong', b'fl_value2')) ++ self.assertEqual(self.client.get_data('fl_key'), b'fl_value') ++ ++ self.assertTrue(self.client.cas('fl_key', b'fl_value', b'fl_value1')) ++ self.assertEqual(self.client.get_data('fl_key'), b'fl_value1') ++ ++ ++ self.client.set_data('fl_key1', 'fl_value') ++ self.assertFalse(self.client.cas('fl_key1', 'fl_value1', b'fl_value2')) ++ self.assertTrue(self.client.cas('fl_key1', 'fl_value', 'fl_value1')) ++ self.assertEqual(self.client.get_data('fl_key1'), b'fl_value1') ++ ++ ++ self.assertTrue(self.client.cas('fl_key2', None, 'fl_value2')) ++ self.assertEqual(self.client.get_data('fl_key2'), b'fl_value2') ++ ++ def test_prefix_listing_and_hierarchy(self): ++ ++ self.client.set_data('fl_key', b'fl_value1') ++ self.client.set_data('fl_key/c', '3') ++ self.client.set_data('fl_key/a', '1') ++ self.client.set_data('fl_key/b', '2') ++ ++ expected = [(b'fl_key', b'fl_value1'), (b'fl_key/a', b'1'), ++ (b'fl_key/b', b'2'), (b'fl_key/c', b'3')] ++ self.assertEqual(self.client.get_prefix_kvs('fl_key'), expected) ++ ++ ++ self.assertEqual(self.client.get_prefix_kvs('fl_key', True), ++ expected[1:]) ++ ++ ++ self.assertEqual(self.client.get_prefix_kvs('nope'), []) ++ ++ def test_delete(self): ++ self.client.set_data('fl_key', b'fl_value') ++ self.client.delete('fl_key') ++ self.assertIsNone(self.client.get_data('fl_key')) ++ ++ def test_delete_prefix(self): ++ self.client.set_data('fl_key', b'fl_value1') ++ self.client.set_data('fl_key/a', '1') ++ self.client.set_data('fl_key/b', '2') ++ ++ self.assertTrue(self.client.delete_prefix('fl_key')) ++ self.assertEqual(self.client.get_prefix_kvs('fl_key'), []) ++ self.assertIsNone(self.client.get_data('fl_key')) ++ ++ self.assertFalse(self.client.delete_prefix('fl_key')) ++ ++ def test_persisted_on_filesystem(self): ++ ++ ++ self.client.set_data('fl_key', b'fl_value') ++ self.client.set_data('fl_key/a', '1') ++ ++ ++ written = [] ++ for root, _, files in os.walk(self.base_dir): ++ written.extend(os.path.join(root, f) for f in files) ++ self.assertTrue(written) ++ ++ ++ other = DFSClient(self.base_dir) ++ self.assertEqual(other.get_data('fl_key'), b'fl_value') ++ self.assertEqual(other.get_prefix_kvs('fl_key'), ++ [(b'fl_key', b'fl_value'), (b'fl_key/a', b'1')]) ++ ++ ++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,46 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++ ++STUBDIR="$(mktemp -d)" ++trap 'rm -rf "$STUBDIR"' EXIT ++cat > "$STUBDIR/sitecustomize.py" <<'PY' ++import sys ++import types ++ ++ ++def _ensure(name): ++ try: ++ __import__(name) ++ except Exception: # pylint: disable=broad-except ++ sys.modules[name] = types.ModuleType(name) ++ ++ ++_ensure('tensorflow_io') ++_ensure('etcd3') ++try: ++ __import__('tensorflow') ++except Exception: # pylint: disable=broad-except ++ sys.modules.setdefault('fedlearner.trainer', ++ types.ModuleType('fedlearner.trainer')) ++PY ++export PYTHONPATH="$STUBDIR:/testbed:${PYTHONPATH:-}" ++ ++ ++python test/data_join/test_etcd_client.py ++python test/data_join/test_mysql_client.py ++ ++ ++python test/data_join/test_dfs_client.py diff --git a/tasks/format-code-task-000605/tests/test.sh b/tasks/format-code-task-000605/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3526290e05b111f62f980c8c7fb8b0e88b28f208 --- /dev/null +++ b/tasks/format-code-task-000605/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/data_join/test_dfs_client.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-000605/tests/test_command.sh b/tasks/format-code-task-000605/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000605/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000634/environment/Dockerfile b/tasks/format-code-task-000634/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c88af89b6eff3573d11f7367efddfb14e24d6b24 --- /dev/null +++ b/tasks/format-code-task-000634/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:771eaa2125b009adf2aaa97bb014816045010f5548c11a07d763da96426fc2a1 diff --git a/tasks/format-code-task-000634/environment/setup/files/blocklist b/tasks/format-code-task-000634/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000634/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000634/environment/setup/setup.sh b/tasks/format-code-task-000634/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000634/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000634/tests/test.patch b/tasks/format-code-task-000634/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a1cc8b64a864ea3534a7b1ce77f5bb22ba38cd25 --- /dev/null +++ b/tasks/format-code-task-000634/tests/test.patch @@ -0,0 +1,438 @@ +diff --git a/usercase-test-coderl/test_async_result_dependency_tree.py b/usercase-test-coderl/test_async_result_dependency_tree.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_async_result_dependency_tree.py +@@ -0,0 +1,408 @@ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++from celery import Celery, states ++from celery.exceptions import IncompleteStream ++from celery.utils.graph import GraphFormatter ++ ++ ++class RequestWithChildren: ++ def __init__(self, children): ++ self.children = children ++ ++ ++def make_app(name): ++ app = Celery(name, broker="memory://", backend="cache+memory://") ++ app.conf.result_serializer = "json" ++ app.conf.accept_content = ["json"] ++ return app ++ ++ ++def store_success(app, task_id, value, children=None): ++ request = RequestWithChildren(children or []) ++ app.backend.store_result(task_id, value, states.SUCCESS, request=request) ++ ++ ++def collect_ids(result, **kwargs): ++ return [(handle.id, value) for handle, value in result.collect(**kwargs)] ++ ++ ++def dependency_ids(result, **kwargs): ++ return [(parent and parent.id, node.id) for parent, node in result.iterdeps(**kwargs)] ++ ++ ++def graph_edges(graph): ++ return { ++ (node.id, child.id) ++ for node in graph ++ for child in graph[node] ++ } ++ ++ ++def test_iterdeps_and_collect_walk_ready_children_breadth_first(): ++ ++ ++ ++ app = make_app("fixture-ready-children") ++ for task_id, value in [ ++ ("s3-child0", 0), ++ ("s3-child1", 1), ++ ("s3-child2", 2), ++ ]: ++ store_success(app, task_id, value) ++ children = [ ++ app.AsyncResult("s3-child0"), ++ app.AsyncResult("s3-child1"), ++ app.AsyncResult("s3-child2"), ++ ] ++ store_success(app, "s3-root", "root-value", children=children) ++ ++ root = app.AsyncResult("s3-root") ++ ++ assert dependency_ids(root) == [ ++ (None, "s3-root"), ++ ("s3-root", "s3-child0"), ++ ("s3-root", "s3-child1"), ++ ("s3-root", "s3-child2"), ++ ] ++ assert collect_ids(root, disable_sync_subtasks=False) == [ ++ ("s3-root", "root-value"), ++ ("s3-child0", 0), ++ ("s3-child1", 1), ++ ("s3-child2", 2), ++ ] ++ ++ assert [node_id for _, node_id in dependency_ids(root)][1:] == [ ++ "s3-child0", "s3-child1", "s3-child2", ++ ] ++ ++ ++def test_get_leaf_returns_last_result_value_from_simple_chain(): ++ ++ ++ ++ app = make_app("fixture-chain-leaf") ++ store_success(app, "s3-chain-leaf", 2) ++ store_success( ++ app, ++ "s3-chain-middle", ++ 1, ++ children=[app.AsyncResult("s3-chain-leaf")], ++ ) ++ store_success( ++ app, ++ "s3-chain-root", ++ "chain-root-value", ++ children=[app.AsyncResult("s3-chain-middle")], ++ ) ++ ++ root = app.AsyncResult("s3-chain-root") ++ ++ assert dependency_ids(root) == [ ++ (None, "s3-chain-root"), ++ ("s3-chain-root", "s3-chain-middle"), ++ ("s3-chain-middle", "s3-chain-leaf"), ++ ] ++ assert root.get_leaf() == 2 ++ ++ ++def test_nested_ready_tree_uses_breadth_first_order_for_collect_and_leaf(): ++ ++ ++ ++ app = make_app("fixture-nested-ready") ++ store_success(app, "s3-aa", "AA") ++ store_success(app, "s3-bb", "BB") ++ store_success(app, "s3-a", "A", children=[app.AsyncResult("s3-aa")]) ++ store_success(app, "s3-b", "B", children=[app.AsyncResult("s3-bb")]) ++ store_success( ++ app, ++ "s3-bf-root", ++ "ROOT", ++ children=[app.AsyncResult("s3-a"), app.AsyncResult("s3-b")], ++ ) ++ ++ root = app.AsyncResult("s3-bf-root") ++ ++ assert dependency_ids(root) == [ ++ (None, "s3-bf-root"), ++ ("s3-bf-root", "s3-a"), ++ ("s3-bf-root", "s3-b"), ++ ("s3-a", "s3-aa"), ++ ("s3-b", "s3-bb"), ++ ] ++ assert collect_ids(root, disable_sync_subtasks=False) == [ ++ ("s3-bf-root", "ROOT"), ++ ("s3-a", "A"), ++ ("s3-b", "B"), ++ ("s3-aa", "AA"), ++ ("s3-bb", "BB"), ++ ] ++ assert root.get_leaf() == "BB" ++ ++ ++def test_strict_iterdeps_raises_specific_incomplete_stream_for_pending_root(): ++ ++ ++ ++ app = make_app("fixture-pending-root") ++ root = app.AsyncResult("s3-pending-root") ++ ++ stream = root.iterdeps() ++ parent, node = next(stream) ++ ++ assert (parent and parent.id, node.id) == (None, "s3-pending-root") ++ ++ assert root.ready() is False ++ with pytest.raises(IncompleteStream): ++ next(stream) ++ ++ ++def test_intermediate_true_yields_incomplete_node_without_descending_branch(): ++ ++ ++ ++ app = make_app("fixture-intermediate-started") ++ store_success(app, "s3-hidden-grandchild", "hidden-value") ++ app.backend.store_result( ++ "s3-started-parent", ++ "not-ready-yet", ++ states.STARTED, ++ request=RequestWithChildren([app.AsyncResult("s3-hidden-grandchild")]), ++ ) ++ store_success(app, "s3-ready-sibling-2", "ready-value") ++ store_success( ++ app, ++ "s3-root-started-child", ++ "root-value", ++ children=[ ++ app.AsyncResult("s3-started-parent"), ++ app.AsyncResult("s3-ready-sibling-2"), ++ ], ++ ) ++ ++ root = app.AsyncResult("s3-root-started-child") ++ started = app.AsyncResult("s3-started-parent") ++ ++ ++ assert started.ready() is False ++ assert dependency_ids(root, intermediate=True) == [ ++ (None, "s3-root-started-child"), ++ ("s3-root-started-child", "s3-started-parent"), ++ ("s3-root-started-child", "s3-ready-sibling-2"), ++ ] ++ assert "s3-hidden-grandchild" not in [ ++ node_id for _, node_id in dependency_ids(root, intermediate=True) ++ ] ++ ++ strict_stream = root.iterdeps() ++ parent, node = next(strict_stream) ++ assert (parent and parent.id, node.id) == (None, "s3-root-started-child") ++ parent, node = next(strict_stream) ++ assert (parent and parent.id, node.id) == ( ++ "s3-root-started-child", ++ "s3-started-parent", ++ ) ++ with pytest.raises(IncompleteStream): ++ next(strict_stream) ++ ++ ++def test_build_graph_records_all_arcs_edges_and_default_formatter(): ++ ++ ++ ++ app = make_app("fixture-graph-default") ++ store_success(app, "s3-graph-aa", "AA") ++ store_success(app, "s3-graph-bb", "BB") ++ store_success(app, "s3-graph-a", "A", children=[app.AsyncResult("s3-graph-aa")]) ++ store_success(app, "s3-graph-b", "B", children=[app.AsyncResult("s3-graph-bb")]) ++ store_success( ++ app, ++ "s3-graph-root", ++ "ROOT", ++ children=[app.AsyncResult("s3-graph-a"), app.AsyncResult("s3-graph-b")], ++ ) ++ ++ graph = app.AsyncResult("s3-graph-root").build_graph() ++ ++ assert type(graph).__name__ == "DependencyGraph" ++ assert len(graph) == 5 ++ ++ assert {node.id for node in graph} == { ++ "s3-graph-root", ++ "s3-graph-a", ++ "s3-graph-b", ++ "s3-graph-aa", ++ "s3-graph-bb", ++ } ++ assert graph_edges(graph) == { ++ ("s3-graph-root", "s3-graph-a"), ++ ("s3-graph-root", "s3-graph-b"), ++ ("s3-graph-a", "s3-graph-aa"), ++ ("s3-graph-b", "s3-graph-bb"), ++ } ++ ++ assert graph.formatter.root == "s3-graph-root" ++ ++ ++def test_build_graph_accepts_custom_formatter_and_intermediate_tree(): ++ ++ ++ ++ app = make_app("fixture-graph-custom") ++ store_success(app, "s3-custom-hidden", "hidden-value") ++ app.backend.store_result( ++ "s3-custom-started", ++ "started-value", ++ states.STARTED, ++ request=RequestWithChildren([app.AsyncResult("s3-custom-hidden")]), ++ ) ++ store_success(app, "s3-custom-ready", "ready-value") ++ store_success( ++ app, ++ "s3-custom-root", ++ "root-value", ++ children=[app.AsyncResult("s3-custom-started"), app.AsyncResult("s3-custom-ready")], ++ ) ++ ++ custom_formatter = GraphFormatter(root="s3-custom-format-root", shape="diamond") ++ graph = app.AsyncResult("s3-custom-root").build_graph( ++ intermediate=True, ++ formatter=custom_formatter, ++ ) ++ ++ ++ assert {node.id for node in graph} == { ++ "s3-custom-root", ++ "s3-custom-started", ++ "s3-custom-ready", ++ } ++ assert graph_edges(graph) == { ++ ("s3-custom-root", "s3-custom-started"), ++ ("s3-custom-root", "s3-custom-ready"), ++ } ++ ++ assert graph.formatter.root == "s3-custom-format-root" ++ ++ ++def test_graph_property_builds_default_graph_once_and_caches_it(): ++ ++ ++ ++ app = make_app("fixture-graph-cache") ++ store_success(app, "s3-cache-child", "cache-child-value") ++ store_success( ++ app, ++ "s3-cache-root", ++ "cache-root-value", ++ children=[app.AsyncResult("s3-cache-child")], ++ ) ++ root = app.AsyncResult("s3-cache-root") ++ ++ first_graph = root.graph ++ second_graph = root.graph ++ ++ assert (first_graph is second_graph) is True ++ assert len(first_graph) == 2 ++ ++ assert {node.id for node in first_graph} == {"s3-cache-root", "s3-cache-child"} ++ assert graph_edges(first_graph) == {("s3-cache-root", "s3-cache-child")} ++ assert first_graph.formatter.root == "s3-cache-root" ++ ++ ++def test_two_async_result_instances_observe_independent_backend_state(): ++ ++ ++ ++ app = make_app("fixture-instance-independence") ++ a = app.AsyncResult("s3-independent-a") ++ b = app.AsyncResult("s3-independent-b") ++ ++ ++ assert dependency_ids(a, intermediate=True) == [(None, "s3-independent-a")] ++ assert dependency_ids(b, intermediate=True) == [(None, "s3-independent-b")] ++ ++ store_success(app, "s3-independent-a-child", "a-child-value") ++ store_success( ++ app, ++ "s3-independent-a", ++ "A-root", ++ children=[app.AsyncResult("s3-independent-a-child")], ++ ) ++ ++ assert dependency_ids(a) == [ ++ (None, "s3-independent-a"), ++ ("s3-independent-a", "s3-independent-a-child"), ++ ] ++ assert collect_ids(a, disable_sync_subtasks=False) == [ ++ ("s3-independent-a", "A-root"), ++ ("s3-independent-a-child", "a-child-value"), ++ ] ++ assert dependency_ids(b, intermediate=True) == [(None, "s3-independent-b")] ++ ++ assert b.ready() is False ++ ++ ++def test_collect_passes_get_options_to_each_result_handle(monkeypatch): ++ ++ ++ ++ app = make_app("fixture-collect-get-options") ++ store_success(app, "s3-options-child", "child-value") ++ store_success( ++ app, ++ "s3-options-root", ++ "root-value", ++ children=[app.AsyncResult("s3-options-child")], ++ ) ++ root = app.AsyncResult("s3-options-root") ++ original_get = type(root).get ++ calls = [] ++ ++ def recording_get(self, **kwargs): ++ calls.append((self.id, dict(kwargs))) ++ return original_get(self, **kwargs) ++ ++ monkeypatch.setattr(type(root), "get", recording_get) ++ ++ ++ get_options = {"timeout": 0.01, "disable_sync_subtasks": False} ++ assert collect_ids(root, **get_options) == [ ++ ("s3-options-root", "root-value"), ++ ("s3-options-child", "child-value"), ++ ] ++ assert calls == [ ++ ("s3-options-root", get_options), ++ ("s3-options-child", get_options), ++ ] ++ ++ ++def test_repeated_result_tree_sessions_keep_dependency_trees_isolated(): ++ ++ ++ ++ app = make_app("fixture-repeated-trees") ++ observed = [] ++ expected = [] ++ ++ for index in range(120): ++ root_id = f"s3-leak-root-{index}" ++ child_id = f"s3-leak-child-{index}" ++ store_success(app, child_id, index) ++ store_success(app, root_id, f"root-{index}", children=[app.AsyncResult(child_id)]) ++ ++ root = app.AsyncResult(root_id) ++ expected_tree = [ ++ (root_id, f"root-{index}"), ++ (child_id, index), ++ ] ++ observed.append(collect_ids(root, disable_sync_subtasks=False)) ++ expected.append(expected_tree) ++ ++ ++ assert observed == expected +diff --git 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_DISABLE_PIP_VERSION_CHECK=1 ++export PIP_NO_INDEX=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_async_result_dependency_tree.py -v diff --git a/tasks/format-code-task-000634/tests/test.sh b/tasks/format-code-task-000634/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c86e563beb5231f5791bcad5a8c958cd175f92ae --- /dev/null +++ b/tasks/format-code-task-000634/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_async_result_dependency_tree.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-000634/tests/test_command.sh b/tasks/format-code-task-000634/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000634/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-000657/environment/Dockerfile b/tasks/format-code-task-000657/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cb6980593ef01fb209599d5de4d91898e34f66d9 --- /dev/null +++ b/tasks/format-code-task-000657/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ebcb07f9e12de9521aad43ba339d163c819d74fda67d65f5051487aa2853e92b diff --git a/tasks/format-code-task-000657/environment/setup/files/blocklist b/tasks/format-code-task-000657/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000657/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000657/environment/setup/setup.sh b/tasks/format-code-task-000657/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000657/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000657/tests/test.patch b/tasks/format-code-task-000657/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a38db2f2891c0c673a7edc14c56733e7347eec00 --- /dev/null +++ b/tasks/format-code-task-000657/tests/test.patch @@ -0,0 +1,61 @@ +diff --git a/tests/test_opnieuw.py b/tests/test_opnieuw.py +index ea5c3ab..e0ae443 100644 +--- a/tests/test_opnieuw.py ++++ b/tests/test_opnieuw.py +@@ -110,6 +110,36 @@ def test_mixed_states(self) -> None: + with retry_immediately("bar_retry"): + self.test_retry_with_waits() + ++ from opnieuw import retry ++ ++ ++class TestExceptionChaining(unittest.TestCase): ++ def setUp(self) -> None: ++ self.counter = 0 ++ ++ @retry( ++ retry_on_exceptions=(TypeError, ValueError), ++ max_calls_total=3, ++ retry_window_after_first_call_in_seconds=1, ++ ) ++ def raise_depending_on_counter(self) -> None: ++ self.counter += 1 ++ if self.counter == 1: ++ raise TypeError ++ elif self.counter == 2: ++ raise ValueError ++ else: ++ raise IndexError ++ ++ def test_exception_chaining(self) -> None: ++ with retry_immediately(): ++ try: ++ self.raise_depending_on_counter() ++ except IndexError as e: ++ self.assertIsInstance(e.__cause__, ValueError) ++ assert e.__cause__ is not None ++ self.assertIsInstance(e.__cause__.__cause__, TypeError) ++ + + 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,4 @@ ++H4sIAAAAAAAAA+3S0QqCMBTGca97ivMCWptOHycqBYN0otPo7VsGFUF1o0T0/13sHLbBDnyLtv3+ ++kK+LelgGc1l5mTFj9Z7r2CujldYqTrTfV8pkKhAz20QP+s5tWpGgtda9u/fp/EdF9/xd0bn1zlbV ++ps6jrpzujY/5p9kt/zjTPv8kVWkgq+lGeO3P89/lMga/LfJFc3KlrWMJK/Gt35TL0l0/hm3qfdEf ++o+Yk4bD49tgAAAAAAAAAAAAAAAAAvDOQyEuDACgAAA== +diff --git 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-000657/tests/test.sh b/tasks/format-code-task-000657/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e18426e0d2edee02a3c2fd0abe4bb6d09f3b8d12 --- /dev/null +++ b/tasks/format-code-task-000657/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_opnieuw.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-000657/tests/test_command.sh b/tasks/format-code-task-000657/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000657/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000659/environment/Dockerfile b/tasks/format-code-task-000659/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a0074dd75d200578948230ad9b00faef9a022fc8 --- /dev/null +++ b/tasks/format-code-task-000659/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3fb8e74eb82b816b31d9087dcc6ff8fe32441f25947e67441e5b73295285eb45 diff --git a/tasks/format-code-task-000659/environment/setup/files/blocklist b/tasks/format-code-task-000659/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000659/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000659/environment/setup/setup.sh b/tasks/format-code-task-000659/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000659/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000659/tests/test.patch b/tasks/format-code-task-000659/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6ba09075b7c766ab74c500e172e9bf5984f7d492 --- /dev/null +++ b/tasks/format-code-task-000659/tests/test.patch @@ -0,0 +1,97 @@ +diff --git a/util/test/test_convert_junit_codespec.py b/util/test/test_convert_junit_codespec.py +new file mode 100644 +index 00000000000..35fea04fcad +--- /dev/null ++++ b/util/test/test_convert_junit_codespec.py +@@ -0,0 +1,82 @@ ++#!/usr/bin/env python3 ++import os ++import subprocess ++import sys ++import tempfile ++import unittest ++import xml.etree.ElementTree as ET ++ ++ ++REPO = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) ++CONVERTER = os.path.join(REPO, "util/test/convert_start_test_log_to_junit_xml.py") ++ ++ ++def convert(log_text): ++ with tempfile.TemporaryDirectory() as td: ++ log_path = os.path.join(td, "run.log") ++ xml_path = os.path.join(td, "report.xml") ++ with open(log_path, "w", encoding="utf-8") as fp: ++ fp.write(log_text) ++ result = subprocess.run( ++ [sys.executable, CONVERTER, "--start-test-log", log_path, ++ "--junit-xml", xml_path], ++ cwd=REPO, text=True, capture_output=True ++ ) ++ if result.returncode != 0: ++ raise AssertionError(f"converter failed: {result.stdout}\n{result.stderr}") ++ return ET.parse(xml_path).getroot() ++ ++ ++class JUnitReportContractTests(unittest.TestCase): ++ def test_standalone_test_blocks_and_suite_summary(self): ++ root = convert( ++ "unrelated runner line\n" ++ "[test: smoke/pass.chpl]\n" ++ "[Elapsed time to compile and execute all versions of \"pass\" - 1.25 seconds]\n" ++ "[test: smoke/skip.chpl]\n" ++ "[Skipping because this configuration is unavailable]\n" ++ ) ++ ++ self.assertEqual(root.get("tests"), "2") ++ self.assertEqual(root.get("failures"), "0") ++ self.assertEqual(root.get("errors"), "0") ++ self.assertEqual(root.get("skipped"), "1") ++ self.assertAlmostEqual(float(root.get("time")), 1.25) ++ ++ cases = root.findall("testcase") ++ self.assertEqual([c.get("classname") for c in cases], ["smoke", "smoke"]) ++ self.assertEqual([c.get("name") for c in cases], ["pass", "skip"]) ++ self.assertIsNone(cases[0].find("skipped")) ++ self.assertIsNotNone(cases[1].find("skipped")) ++ self.assertIn("Elapsed time", cases[0].find("system-out").text or "") ++ ++ def test_errors_are_failures_and_warnings_do_not_fail_cases(self): ++ root = convert( ++ "[Starting subtest - wrapped]\n" ++ "[test: suite/fail.chpl]\n" ++ "[Error: compiler rejected the program]\n" ++ "[Elapsed time to compile and execute all versions of \"fail\" - 0.5 seconds]\n" ++ "[test: suite/warn.chpl]\n" ++ "[Warning: deprecated syntax]\n" ++ "[Elapsed time to compile and execute all versions of \"warn\" - 0.25 seconds]\n" ++ "[Finished subtest \"wrapped\"]\n" ++ ) ++ ++ self.assertEqual(root.get("tests"), "2") ++ self.assertEqual(root.get("failures"), "1") ++ self.assertEqual(root.get("errors"), "0") ++ self.assertEqual(root.get("skipped"), "0") ++ self.assertAlmostEqual(float(root.get("time")), 0.75) ++ ++ failed, warned = root.findall("testcase") ++ failure = failed.find("failure") ++ self.assertIsNotNone(failure) ++ self.assertEqual(failure.get("message"), "Error: compiler rejected the program") ++ self.assertIsNone(failed.find("error")) ++ self.assertIsNone(warned.find("failure")) ++ serialized = ET.tostring(root, encoding="unicode") ++ self.assertIn("Warning: deprecated syntax", serialized) ++ ++ ++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 ++ ++python3 -m unittest util.test.test_convert_junit_codespec diff --git a/tasks/format-code-task-000659/tests/test.sh b/tasks/format-code-task-000659/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a8186bba5fbb1459e9e7bbca66d8e1ef82a3d578 --- /dev/null +++ b/tasks/format-code-task-000659/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' +util/test/test_convert_junit_codespec.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000659/tests/test_command.sh b/tasks/format-code-task-000659/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000659/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000666/environment/Dockerfile b/tasks/format-code-task-000666/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1c8f8da3cc6195e2d7f28ffb317ff9339edba2c5 --- /dev/null +++ b/tasks/format-code-task-000666/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b23a0ff9eb97a0c35f128f161cb86fb49f40f78a5607fa3c7d380b3e475c1bf2 diff --git a/tasks/format-code-task-000666/environment/setup/files/blocklist b/tasks/format-code-task-000666/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000666/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000666/environment/setup/setup.sh b/tasks/format-code-task-000666/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000666/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000666/tests/test.patch b/tasks/format-code-task-000666/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..20729f7d55adaceb12baff255d1b14d621fafe54 --- /dev/null +++ b/tasks/format-code-task-000666/tests/test.patch @@ -0,0 +1,205 @@ +diff --git a/usercase-test-coderl/test_get_catalog_lookup.py b/usercase-test-coderl/test_get_catalog_lookup.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_get_catalog_lookup.py +@@ -0,0 +1,177 @@ ++ ++ ++ ++ ++ ++ ++import builtins ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++ ++import pytest ++ ++import pyromat as pm ++ ++ ++def _identity_tuple(substance): ++ ++ return substance.sid(), substance.pmclass() ++ ++ ++def _loaded_catalog_entry(sid): ++ matches = [substance for substance in pm.search() if substance.sid() == sid] ++ assert len(matches) == 1 ++ return matches[0] ++ ++ ++def _assert_loaded_substance(actual, sid, pmclass=None): ++ ++ assert actual is _loaded_catalog_entry(sid) ++ assert actual.sid() == sid ++ if pmclass is not None: ++ assert actual.pmclass() == pmclass ++ ++ ++def _assert_invalid_substance_error(excinfo, output, missing_sid): ++ ++ assert isinstance(excinfo.value, pm.utility.PMParamError) ++ normalized = " ".join(output.lower().split()) ++ assert missing_sid.lower() in normalized ++ assert "found" in normalized ++ assert ("not" in normalized) or ("no" in normalized) ++ ++ ++def _catalog_fingerprint(): ++ return sorted((substance.sid(), substance.pmclass()) for substance in pm.search()) ++ ++ ++def test_get_returns_exact_ideal_gas_oxygen(): ++ ++ ++ ++ actual = pm.get("ig.O2") ++ ++ ++ _assert_loaded_substance(actual, "ig.O2", "ig2") ++ ++ ++def test_get_returns_exact_multiphase_water(): ++ ++ ++ ++ actual = pm.get("mp.H2O") ++ ++ ++ _assert_loaded_substance(actual, "mp.H2O", "mp1") ++ ++ ++def test_get_returns_another_exact_loaded_substance(): ++ ++ ++ ++ actual = pm.get("ig.Ar") ++ ++ ++ _assert_loaded_substance(actual, "ig.Ar") ++ ++ ++def test_get_reports_invalid_substance_id(capsys): ++ ++ ++ ++ with pytest.raises(pm.utility.PMParamError) as excinfo: ++ pm.get("not.a.real.substance") ++ ++ ++ _assert_invalid_substance_error(excinfo, capsys.readouterr().out, "not.a.real.substance") ++ ++ ++def test_get_requires_exact_case_for_loaded_ids(capsys): ++ ++ ++ ++ with pytest.raises(pm.utility.PMParamError) as excinfo: ++ pm.get("ig.o2") ++ ++ ++ _assert_invalid_substance_error(excinfo, capsys.readouterr().out, "ig.o2") ++ ++ ++def test_get_is_referentially_transparent_for_same_id(): ++ first = pm.get("ig.O2") ++ second = pm.get("ig.O2") ++ ++ assert first is second ++ ++ _assert_loaded_substance(first, "ig.O2", "ig2") ++ ++ _assert_loaded_substance(second, "ig.O2", "ig2") ++ ++ ++def test_get_does_not_mutate_caller_input_or_loaded_catalog(): ++ idstr = "mp.H2O" ++ original_idstr = copy.deepcopy(idstr) ++ before_catalog = _catalog_fingerprint() ++ ++ actual = pm.get(idstr) ++ ++ assert idstr == original_idstr ++ ++ _assert_loaded_substance(actual, "mp.H2O", "mp1") ++ assert _catalog_fingerprint() == before_catalog ++ ++ ++def test_get_has_same_result_in_fresh_process(): ++ obj = pm.get("ig.CO2") ++ ++ assert obj is _loaded_catalog_entry("ig.CO2") ++ in_process = _identity_tuple(obj) ++ script = """ ++import json ++import pyromat as pm ++obj = pm.get("ig.CO2") ++print(json.dumps([obj.sid(), obj.pmclass()])) ++""" ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ text=True, ++ ) ++ fresh_process = tuple(json.loads(completed.stdout)) ++ expected_identity = _identity_tuple(_loaded_catalog_entry("ig.CO2")) ++ ++ ++ assert in_process == expected_identity ++ ++ assert fresh_process == expected_identity ++ assert fresh_process == in_process ++ ++ ++def test_get_does_not_scan_files_write_cwd_or_use_network(tmp_path, monkeypatch): ++ before_entries = sorted(path.name for path in tmp_path.iterdir()) ++ ++ def forbidden_side_effect(*args, **kwargs): ++ raise AssertionError("pm.get performed undeclared IO, scanning, or networking") ++ ++ with monkeypatch.context() as guard: ++ guard.chdir(tmp_path) ++ guard.setattr(builtins, "open", forbidden_side_effect) ++ guard.setattr(os, "listdir", forbidden_side_effect) ++ guard.setattr(os, "scandir", forbidden_side_effect) ++ guard.setattr(os, "walk", forbidden_side_effect) ++ guard.setattr(socket, "socket", forbidden_side_effect) ++ ++ actual = pm.get("ig.O2") ++ ++ ++ _assert_loaded_substance(actual, "ig.O2", "ig2") ++ ++ after_entries = sorted(path.name for path in tmp_path.iterdir()) ++ assert after_entries == before_entries == [] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo/src" ++export PYTHONNOUSERSITE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++unset PYTEST_ADDOPTS PYTEST_PLUGINS ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_get_catalog_lookup.py -v diff --git a/tasks/format-code-task-000666/tests/test.sh b/tasks/format-code-task-000666/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6420d8fe0c2958be5851bad29c371d520f8c692c --- /dev/null +++ b/tasks/format-code-task-000666/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_get_catalog_lookup.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-000666/tests/test_command.sh b/tasks/format-code-task-000666/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000666/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-000668/environment/Dockerfile b/tasks/format-code-task-000668/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1746df17f413109ba71d6462278a85940a01a1aa --- /dev/null +++ b/tasks/format-code-task-000668/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:52ce716ca04569fb9d7dd0a7a797e705c4caa0aeb51adf9168f3c9e086ebcc41 diff --git a/tasks/format-code-task-000668/environment/setup/files/blocklist b/tasks/format-code-task-000668/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000668/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000668/environment/setup/setup.sh b/tasks/format-code-task-000668/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000668/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000668/tests/test.patch b/tasks/format-code-task-000668/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..044ee0273ca6f2525bfc4b468680608f28830c9d --- /dev/null +++ b/tasks/format-code-task-000668/tests/test.patch @@ -0,0 +1,122 @@ +diff --git a/pkg/k8s/identitybackend/identity_test.go b/pkg/k8s/identitybackend/identity_test.go +index a37a9ec185..7dd499e606 100644 +--- a/pkg/k8s/identitybackend/identity_test.go ++++ b/pkg/k8s/identitybackend/identity_test.go +@@ -17,11 +17,20 @@ + package identitybackend + + import ( ++ "context" + "testing" + ++ "github.com/cilium/cilium/pkg/allocator" + "github.com/cilium/cilium/pkg/checker" ++ "github.com/cilium/cilium/pkg/idpool" ++ ciliumio "github.com/cilium/cilium/pkg/k8s/apis/cilium.io" ++ "github.com/cilium/cilium/pkg/k8s/client/clientset/versioned/fake" ++ "github.com/cilium/cilium/pkg/labels" + + . "gopkg.in/check.v1" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++ "k8s.io/apimachinery/pkg/apis/meta/v1/validation" ++ "k8s.io/apimachinery/pkg/util/validation/field" + ) + + // Hook up gocheck into the "go test" runner. +@@ -33,6 +42,28 @@ type K8sIdentityBackendSuite struct{} + + var _ = Suite(&K8sIdentityBackendSuite{}) + ++type testAllocatorKey map[string]string ++ ++func (t testAllocatorKey) String() string { ++ return "" ++} ++ ++func (t testAllocatorKey) GetKey() string { ++ return "" ++} ++ ++func (t testAllocatorKey) PutKey(string) allocator.AllocatorKey { ++ return t ++} ++ ++func (t testAllocatorKey) GetAsMap() map[string]string { ++ return t ++} ++ ++func (t testAllocatorKey) PutKeyFromMap(v map[string]string) allocator.AllocatorKey { ++ return testAllocatorKey(v) ++} ++ + func (s *K8sIdentityBackendSuite) TestSanitizeK8sLabels(c *C) { + testCases := []struct { + input map[string]string +@@ -67,3 +98,42 @@ func (s *K8sIdentityBackendSuite) TestSanitizeK8sLabels(c *C) { + c.Assert(skipped, checker.DeepEquals, test.skipped) + } + } ++ ++func (s *K8sIdentityBackendSuite) TestSanitizeK8sLabelsSkipsNamespaceDerivedLabels(c *C) { ++ client := fake.NewSimpleClientset() ++ backend := &crdBackend{ ++ CRDBackendConfiguration: CRDBackendConfiguration{ ++ Client: client, ++ }, ++ } ++ namespaceLabelKey := ciliumio.PodNamespaceMetaLabels + ".team" ++ longNamespaceLabelKey := ciliumio.PodNamespaceMetaLabels + ".some.really.really.long.namespace.label.name" ++ securityLabels := labels.Labels{ ++ "app": labels.NewLabel("app", "frontend", labels.LabelSourceK8s), ++ "runtime": labels.NewLabel("runtime", "docker", labels.LabelSourceContainer), ++ namespaceLabelKey: labels.NewLabel(namespaceLabelKey, "platform", labels.LabelSourceK8s), ++ longNamespaceLabelKey: labels.NewLabel(longNamespaceLabelKey, "someval", labels.LabelSourceK8s), ++ } ++ key := testAllocatorKey(securityLabels.StringMap()) ++ ++ err := backend.AllocateID(context.Background(), idpool.ID(1234), key) ++ c.Assert(err, IsNil) ++ ++ created, err := client.CiliumV2().CiliumIdentities().Get(context.Background(), "1234", metav1.GetOptions{}) ++ c.Assert(err, IsNil) ++ ++ c.Assert( ++ validation.ValidateLabels(created.ObjectMeta.Labels, field.NewPath("test", "labels")), ++ HasLen, ++ 0, ++ ) ++ c.Assert(created.ObjectMeta.Labels, checker.DeepEquals, map[string]string{ ++ "app": "frontend", ++ }) ++ c.Assert(created.SecurityLabels, checker.DeepEquals, map[string]string{ ++ "k8s:app": "frontend", ++ "container:runtime": "docker", ++ "k8s:" + namespaceLabelKey: "platform", ++ "k8s:" + longNamespaceLabelKey: "someval", ++ }) ++} +diff --git 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 -count=1 -v ./pkg/k8s/identitybackend/ -check.f 'TestSanitizeK8sLabels$' ++ ;; ++ new) ++ go test -count=1 -v ./pkg/k8s/identitybackend/ -check.f 'TestSanitizeK8sLabelsSkipsNamespaceDerivedLabels$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000668/tests/test.sh b/tasks/format-code-task-000668/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..506fa033f8124a317bdacca794e662d20dbec16f --- /dev/null +++ b/tasks/format-code-task-000668/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/k8s/identitybackend/identity_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-000668/tests/test_command.sh b/tasks/format-code-task-000668/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000668/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-000692/environment/Dockerfile b/tasks/format-code-task-000692/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c35e806efe9e2322321dbfc43716c0970daf3495 --- /dev/null +++ b/tasks/format-code-task-000692/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ef3ce3b9d856adf00342e6e65dfe30de4c2ebd58a60e9a69042431248de63c89 diff --git a/tasks/format-code-task-000692/environment/setup/files/blocklist b/tasks/format-code-task-000692/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000692/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000692/environment/setup/setup.sh b/tasks/format-code-task-000692/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000692/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000692/tests/test.patch b/tasks/format-code-task-000692/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b7ed32bdf4829d15429f945f9e682d2d1a57035 --- /dev/null +++ b/tasks/format-code-task-000692/tests/test.patch @@ -0,0 +1,124 @@ +diff --git a/pkg/wrappers/clientgo/normalize_contract_test.go b/pkg/wrappers/clientgo/normalize_contract_test.go +new file mode 100644 +index 0000000..c5731c5 +--- /dev/null ++++ b/pkg/wrappers/clientgo/normalize_contract_test.go +@@ -0,0 +1,108 @@ ++package clientgo ++ ++import ( ++ "io" ++ "net/http" ++ "net/url" ++ "strings" ++ "testing" ++) ++ ++type contractRecordingRoundTripper struct { ++ seen *url.URL ++} ++ ++func (r *contractRecordingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { ++ r.seen = req.URL ++ return &http.Response{ ++ StatusCode: http.StatusNoContent, ++ Body: io.NopCloser(strings.NewReader("")), ++ Header: make(http.Header), ++ Request: req, ++ }, nil ++} ++ ++func TestRoundTripPathNormalizationContract(t *testing.T) { ++ tests := []struct { ++ name string ++ host string ++ path string ++ want string ++ }{ ++ { ++ name: "core API with query", ++ host: "https://hub.example/proxy", ++ path: "https://hub.example/proxy/api/v1/namespaces/demo/pods?watch=true&resourceVersion=7", ++ want: "/proxy/apis/shadow/v1alpha1/namespaces/demo/pods?watch=true&resourceVersion=7", ++ }, ++ { ++ name: "API root preserves trailing slash", ++ host: "https://hub.example/proxy", ++ path: "https://hub.example/proxy/api/v1/", ++ want: "/proxy/apis/shadow/v1alpha1/", ++ }, ++ { ++ name: "group API with hyphenated non clusternet group", ++ host: "https://hub.example/proxy", ++ path: "https://hub.example/proxy/apis/apps.example/v1beta1/deployments", ++ want: "/proxy/apis/shadow/v1alpha1/deployments", ++ }, ++ { ++ name: "clusternet group remains untouched", ++ host: "https://hub.example/proxy", ++ path: "https://hub.example/proxy/apis/foo-bar.clusternet.io/v1alpha1/widgets?x=1", ++ want: "/proxy/apis/foo-bar.clusternet.io/v1alpha1/widgets?x=1", ++ }, ++ { ++ name: "invalid version remains untouched", ++ host: "https://hub.example/proxy", ++ path: "https://hub.example/proxy/apis/apps.example/vfuture/deployments", ++ want: "/proxy/apis/apps.example/vfuture/deployments", ++ }, ++ { ++ name: "outside configured prefix remains untouched", ++ host: "https://hub.example/proxy", ++ path: "https://hub.example/other/proxy/api/v1/pods", ++ want: "/other/proxy/api/v1/pods", ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ recorder := &contractRecordingRoundTripper{} ++ transport := NewClusternetTransport(tt.host, recorder) ++ reqURL, err := url.Parse(tt.path) ++ if err != nil { ++ t.Fatal(err) ++ } ++ req := &http.Request{Method: http.MethodGet, URL: reqURL, Header: make(http.Header)} ++ if _, err := transport.RoundTrip(req); err != nil { ++ t.Fatalf("RoundTrip() error = %v", err) ++ } ++ if recorder.seen == nil { ++ t.Fatal("underlying transport did not receive a request") ++ } ++ wantURL, err := url.Parse("https://hub.example" + tt.want) ++ if err != nil { ++ t.Fatal(err) ++ } ++ if got := recorder.seen.EscapedPath(); got != wantURL.EscapedPath() || recorder.seen.RawQuery != wantURL.RawQuery { ++ t.Fatalf("normalized URL = %q, want path/query %q", recorder.seen.EscapedPath()+"?"+recorder.seen.RawQuery, tt.want) ++ } ++ }) ++ } ++} ++ ++func TestRoundTripNormalizesVersionRoots(t *testing.T) { ++ for _, path := range []string{"/api/v1", "/apis/apps.example/v1"} { ++ recorder := &contractRecordingRoundTripper{} ++ transport := NewClusternetTransport("https://hub.example", recorder) ++ reqURL, _ := url.Parse("https://hub.example" + path) ++ if _, err := transport.RoundTrip(&http.Request{Method: http.MethodGet, URL: reqURL}); err != nil { ++ t.Fatal(err) ++ } ++ if got := recorder.seen.Path; got != "/apis/shadow/v1alpha1" { ++ t.Errorf("%s normalized to %q, want /apis/shadow/v1alpha1", path, got) ++ } ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./pkg/wrappers/clientgo diff --git a/tasks/format-code-task-000692/tests/test.sh b/tasks/format-code-task-000692/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..58899a1265fcf3cf764975783467368e87400e59 --- /dev/null +++ b/tasks/format-code-task-000692/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/wrappers/clientgo/normalize_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-000692/tests/test_command.sh b/tasks/format-code-task-000692/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000692/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000695/environment/Dockerfile b/tasks/format-code-task-000695/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..30f2875daaaadb7fd53fd2ad6bf84ab5b2497e73 --- /dev/null +++ b/tasks/format-code-task-000695/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b60bfdd7e70630922e86b21822a959756f45d7bab235e38fef184572b14f747b diff --git a/tasks/format-code-task-000695/environment/setup/files/blocklist b/tasks/format-code-task-000695/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000695/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000695/environment/setup/setup.sh b/tasks/format-code-task-000695/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000695/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000695/tests/test.patch b/tasks/format-code-task-000695/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..968df371e5bf6447d30737b1d0694ae00667320b --- /dev/null +++ b/tasks/format-code-task-000695/tests/test.patch @@ -0,0 +1,66 @@ +diff --git a/coderd/users_test.go b/coderd/users_test.go +index 2d85a9823a587..cbd7607701c1f 100644 +--- a/coderd/users_test.go ++++ b/coderd/users_test.go +@@ -2,6 +2,7 @@ package coderd_test + + import ( + "context" ++ "database/sql" + "fmt" + "net/http" + "slices" +@@ -1873,6 +1874,33 @@ func TestGetUsers(t *testing.T) { + require.NoError(t, err) + require.ElementsMatch(t, active, res.Users) + }) ++ t.Run("GithubComUserID", func(t *testing.T) { ++ t.Parallel() ++ ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) ++ defer cancel() ++ ++ client, db := coderdtest.NewWithDatabase(t, nil) ++ first := coderdtest.CreateFirstUser(t, client) ++ _ = dbgen.User(t, db, database.User{ ++ Email: "test2@coder.com", ++ Username: "test2", ++ }) ++ // nolint:gocritic // Unit test ++ err := db.UpdateUserGithubComUserID(dbauthz.AsSystemRestricted(ctx), database.UpdateUserGithubComUserIDParams{ ++ ID: first.UserID, ++ GithubComUserID: sql.NullInt64{ ++ Int64: 123, ++ Valid: true, ++ }, ++ }) ++ require.NoError(t, err) ++ res, err := client.Users(ctx, codersdk.UsersRequest{ ++ SearchQuery: "github_com_user_id:123", ++ }) ++ require.NoError(t, err) ++ require.Len(t, res.Users, 1) ++ require.Equal(t, res.Users[0].ID, first.UserID) ++ }) + } + + func TestGetUsersPagination(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,4 @@ ++H4sIAAAAAAAAA+3Ry2rDMBCFYa/zFEP2voyxnW6y7gu065BYog3UFuiS56/iTUqhzSahlPzfZgZp ++QCNOdUjHD7Oz86ku7qXJNn2/1Ox7XXrtW23bbug2eU51UC2kv9tGX6QQ916k8M7F3+au3f9T1SX/ ++aEPcjW6a9rOpwvvt3riWv2p3yb89598N+Uia263wswfPfzSyBH+wZvXm5NxK6dMs65fcPtv4GqwP ++aylHl+a4VSlPUtWjM9abWsp4nKxLUfSpCau//gsAAAAAAAAAAAAAAADwaD4ByqgzpgAoAAA= +diff --git 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-000695/tests/test.sh b/tasks/format-code-task-000695/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0bbe8d55fc087fa1b2bde980978e5b26a3f6ac85 --- /dev/null +++ b/tasks/format-code-task-000695/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +coderd/users_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-000695/tests/test_command.sh b/tasks/format-code-task-000695/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000695/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000802/environment/Dockerfile b/tasks/format-code-task-000802/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..81e046a24540b049fcf321b84851a472db68da7a --- /dev/null +++ b/tasks/format-code-task-000802/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7ab2c77bd491df4907b082b689acd8b4f34e4bd72acd2ee8d9f4e3a3bbbbd3cf diff --git a/tasks/format-code-task-000802/environment/setup/files/blocklist b/tasks/format-code-task-000802/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000802/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000802/environment/setup/setup.sh b/tasks/format-code-task-000802/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000802/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000802/tests/test.patch b/tasks/format-code-task-000802/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..22f7bf7e35a32494658b9677a5d95f6828799864 --- /dev/null +++ b/tasks/format-code-task-000802/tests/test.patch @@ -0,0 +1,71 @@ +diff --git a/dragonfly/test/test_language_de_number.py b/dragonfly/test/test_language_de_number.py +index 19ce1ffb..0de99efb 100644 +--- a/dragonfly/test/test_language_de_number.py ++++ b/dragonfly/test/test_language_de_number.py +@@ -37,6 +37,7 @@ class GermanIntegerTestCase(ElementTestCase): + def _build_element(self): + return Integer(content=IntegerContent, min=0, max=10**12 - 1) + input_output = [ ++ + ("null", 0), + ("eins", 1), + ("zwei", 2), +@@ -61,6 +62,7 @@ def _build_element(self): + ("ein und zwanzig", 21), + ("zwei und zwanzig", 22), + ("drei und zwanzig", 23), ++ ("ein und dreissig", 31), + ("vier und dreissig", 34), + ("fuenf und vierzig", 45), + ("sechs und fuenfzig", 56), +@@ -70,4 +72,28 @@ def _build_element(self): + ("hundert", 100), + ("ein hundert", 100), + ("ein hundert drei und zwanzig", 123), ++ ("drei hundert neun und achtzig", 389), ++ ("ein tausend ein hundert ein und dreissig", 1131), ++ ("ein und dreissig tausend ein hundert ein und dreissig", 31131), ++ ("ein hundert ein und dreissig tausend ein hundert ein und dreissig", 131131), ++ ("ein million ein hundert ein und dreissig tausend ein hundert ein und dreissig", 1131131), ++ ++ ++ ("einundzwanzig", 21), ++ ("zweiundzwanzig", 22), ++ ("dreiundzwanzig", 23), ++ ("einunddreissig", 31), ++ ("vierunddreissig", 34), ++ ("fuenfundvierzig", 45), ++ ("sechsundfuenfzig", 56), ++ ("siebenundsechzig", 67), ++ ("achtundsiebzig", 78), ++ ("neunundachtzig", 89), ++ ("ein hundert dreiundzwanzig", 123), ++ ("ein hundert einunddreissig", 131), ++ ("drei hundert neunundachtzig", 389), ++ ("ein tausend ein hundert einunddreissig", 1131), ++ ("einunddreissig tausend ein hundert einunddreissig", 31131), ++ ("ein hundert einunddreissig tausend ein hundert einunddreissig", 131131), ++ ("ein million ein hundert einunddreissig tausend ein hundert einunddreissig", 1131131), + ] +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+3S32qDMBQGcK/zFKE3KqzOP9Ve7UnGkGhSGzCJxFjat19miyuDrTctY+z73SQk ++cnLwO0kzyZ7XQh+eg0dJvW1Zzqv3dZ33WZlneVrlebEJ0iwrt1VAy4d1dGUaHbOUBtYY99N3t+7/ ++qOQzfydGV7dGKaZ5Mu7v98at/Itiu+SflR/5b6rM55/er4Xv/fP8W07n4BvByXBye6MLum7piuys ++UZRb1hm9609UqsFYRzvh/Kx0UgtyXujL1VkUOnF0YXy5S1qjtWhdtBzUTiphaz9hrBM24XJkTS/8 ++PbnU9y34Zog4Shed94liUkev4foQPtFwaWhu+jyyPdPd5OvVXNR6Uo0vPJzCtzgmK/LbvxcAAAAA ++AAAAAAAAAAAAAAAA4KHeAZVQUpAAKAAA +diff --git 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-000802/tests/test.sh b/tasks/format-code-task-000802/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..eeada703e368cfb182d017f02c05dce0512d2cc1 --- /dev/null +++ b/tasks/format-code-task-000802/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' +dragonfly/test/test_language_de_number.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-000802/tests/test_command.sh b/tasks/format-code-task-000802/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000802/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000805/environment/Dockerfile b/tasks/format-code-task-000805/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4d943dee13bb8cbc86cb80aad255babd4cb9fc65 --- /dev/null +++ b/tasks/format-code-task-000805/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:58c816948a937037324f13a9a274896425a24c9c742bf4397b07741a947af0ce diff --git a/tasks/format-code-task-000805/environment/setup/files/blocklist b/tasks/format-code-task-000805/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000805/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000805/environment/setup/setup.sh b/tasks/format-code-task-000805/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000805/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000805/tests/test.patch b/tasks/format-code-task-000805/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bb6da8f2648dbd2a9f1ba7a41f34f2ccd3bc3393 --- /dev/null +++ b/tasks/format-code-task-000805/tests/test.patch @@ -0,0 +1,365 @@ +diff --git a/commands/kubernetes_test.go b/commands/kubernetes_test.go +index 46f7c155..24953b8a 100644 +--- a/commands/kubernetes_test.go ++++ b/commands/kubernetes_test.go +@@ -7,6 +7,7 @@ import ( + "github.com/digitalocean/doctl" + "github.com/digitalocean/doctl/do" + "github.com/digitalocean/godo" ++ "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + +@@ -378,7 +379,7 @@ func TestKubernetesUpdate(t *testing.T) { + StartTime: "00:00", + Day: godo.KubernetesMaintenanceDayAny, + }, +- AutoUpgrade: false, ++ AutoUpgrade: boolPtr(false), + } + tm.kubernetes.EXPECT().Update(testCluster.ID, &r).Return(&testCluster, nil) + +@@ -401,7 +402,7 @@ func TestKubernetesUpdate(t *testing.T) { + StartTime: "00:00", + Day: godo.KubernetesMaintenanceDayAny, + }, +- AutoUpgrade: false, ++ AutoUpgrade: boolPtr(false), + } + tm.kubernetes.EXPECT().List().Return(testClusterList, nil) + tm.kubernetes.EXPECT().Update(testCluster.ID, &r).Return(&testCluster, nil) +@@ -640,7 +641,7 @@ func TestKubernetesNodePool_Update(t *testing.T) { + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + r := godo.KubernetesNodePoolUpdateRequest{ + Name: testNodePool.Name, +- Count: testNodePool.Count, ++ Count: &testNodePool.Count, + Tags: testNodePool.Tags, + } + tm.kubernetes.EXPECT().UpdateNodePool(testCluster.ID, testNodePool.ID, &r).Return(&testNodePool, nil) +@@ -658,7 +659,7 @@ func TestKubernetesNodePool_Update(t *testing.T) { + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + r := godo.KubernetesNodePoolUpdateRequest{ + Name: testNodePool.Name, +- Count: testNodePool.Count, ++ Count: &testNodePool.Count, + Tags: testNodePool.Tags, + } + tm.kubernetes.EXPECT().List().Return(testClusterList, nil) +@@ -677,7 +678,7 @@ func TestKubernetesNodePool_Update(t *testing.T) { + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + r := godo.KubernetesNodePoolUpdateRequest{ + Name: testNodePool.Name, +- Count: testNodePool.Count, ++ Count: &testNodePool.Count, + Tags: testNodePool.Tags, + } + tm.kubernetes.EXPECT().ListNodePools(testCluster.ID).Return(testNodePools, nil) +@@ -696,7 +697,7 @@ func TestKubernetesNodePool_Update(t *testing.T) { + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + r := godo.KubernetesNodePoolUpdateRequest{ + Name: testNodePool.Name, +- Count: testNodePool.Count, ++ Count: &testNodePool.Count, + Tags: testNodePool.Tags, + } + tm.kubernetes.EXPECT().List().Return(testClusterList, nil) +@@ -940,3 +941,276 @@ func TestLatestVersionForUpgrade(t *testing.T) { + }) + } + } ++ ++func TestKubernetesUpdateDoesNotSendAutoUpgradeWhenUnset(t *testing.T) { ++ cases := []struct { ++ name string ++ configure func(*CmdConfig) ++ assertBody func(*testing.T, *godo.KubernetesClusterUpdateRequest) ++ }{ ++ { ++ name: "tags changed", ++ configure: func(config *CmdConfig) { ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"env:test"}) ++ }, ++ assertBody: func(t *testing.T, r *godo.KubernetesClusterUpdateRequest) { ++ ++ if r.AutoUpgrade != nil { ++ t.Fatalf("expected auto-upgrade to be omitted when --auto-upgrade is unset, got %v", *r.AutoUpgrade) ++ } ++ assert.Equal(t, []string{"env:test"}, r.Tags) ++ }, ++ }, ++ { ++ name: "name changed", ++ configure: func(config *CmdConfig) { ++ config.Doit.Set(config.NS, doctl.ArgClusterName, "renamed-cluster") ++ }, ++ assertBody: func(t *testing.T, r *godo.KubernetesClusterUpdateRequest) { ++ ++ if r.AutoUpgrade != nil { ++ t.Fatalf("expected auto-upgrade to be omitted when --auto-upgrade is unset, got %v", *r.AutoUpgrade) ++ } ++ assert.Equal(t, "renamed-cluster", r.Name) ++ }, ++ }, ++ { ++ name: "cluster id, prod namespace", ++ configure: func(config *CmdConfig) { ++ config.NS = "prod" ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"env:prod"}) ++ config.Doit.Set(config.NS, doctl.ArgMaintenanceWindow, "tuesday=01:00") ++ }, ++ assertBody: func(t *testing.T, r *godo.KubernetesClusterUpdateRequest) { ++ if r.AutoUpgrade != nil { ++ t.Fatalf("expected auto-upgrade to be omitted when --auto-upgrade is unset, got %v", *r.AutoUpgrade) ++ } ++ assert.Equal(t, []string{"env:prod"}, r.Tags) ++ }, ++ }, ++ } ++ ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ withTestClient(t, func(config *CmdConfig, tm *tcMocks) { ++ config.Args = append(config.Args, testCluster.ID) ++ config.Doit.Set(config.NS, doctl.ArgMaintenanceWindow, "any=00:00") ++ tc.configure(config) ++ ++ tm.kubernetes.EXPECT(). ++ Update(testCluster.ID, gomock.Any()). ++ DoAndReturn(func(_ string, r *godo.KubernetesClusterUpdateRequest) (*do.KubernetesCluster, error) { ++ tc.assertBody(t, r) ++ return &testCluster, nil ++ }) ++ ++ err := testK8sCmdService().RunKubernetesClusterUpdate(config) ++ assert.NoError(t, err) ++ }) ++ }) ++ } ++} ++ ++func TestKubernetesUpdateSendsExplicitAutoUpgradeValues(t *testing.T) { ++ cases := []struct { ++ name string ++ want bool ++ }{ ++ {name: "true", want: true}, ++ {name: "false", want: false}, ++ } ++ ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ withTestClient(t, func(config *CmdConfig, tm *tcMocks) { ++ config.Args = append(config.Args, testCluster.ID) ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"env:test"}) ++ config.Doit.Set(config.NS, doctl.ArgMaintenanceWindow, "any=00:00") ++ config.Doit.Set(config.NS, doctl.ArgAutoUpgrade, tc.want) ++ ++ tm.kubernetes.EXPECT(). ++ Update(testCluster.ID, gomock.Any()). ++ DoAndReturn(func(_ string, r *godo.KubernetesClusterUpdateRequest) (*do.KubernetesCluster, error) { ++ ++ if r.AutoUpgrade == nil { ++ t.Fatalf("expected explicit --auto-upgrade=%v to be sent", tc.want) ++ } ++ assert.Equal(t, tc.want, *r.AutoUpgrade) ++ return &testCluster, nil ++ }) ++ ++ err := testK8sCmdService().RunKubernetesClusterUpdate(config) ++ assert.NoError(t, err) ++ }) ++ }) ++ } ++ t.Run("true with prod namespace", func(t *testing.T) { ++ withTestClient(t, func(config *CmdConfig, tm *tcMocks) { ++ config.NS = "prod" ++ config.Args = append(config.Args, testCluster.ID) ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"env:prod"}) ++ config.Doit.Set(config.NS, doctl.ArgMaintenanceWindow, "tuesday=01:00") ++ config.Doit.Set(config.NS, doctl.ArgAutoUpgrade, true) ++ ++ tm.kubernetes.EXPECT(). ++ Update(testCluster.ID, gomock.Any()). ++ DoAndReturn(func(_ string, r *godo.KubernetesClusterUpdateRequest) (*do.KubernetesCluster, error) { ++ if r.AutoUpgrade == nil { ++ t.Fatalf("expected explicit --auto-upgrade=true to be sent") ++ } ++ assert.True(t, *r.AutoUpgrade) ++ return &testCluster, nil ++ }) ++ ++ err := testK8sCmdService().RunKubernetesClusterUpdate(config) ++ assert.NoError(t, err) ++ }) ++ }) ++} ++ ++func TestKubernetesNodePoolUpdateDoesNotSendCountWhenUnset(t *testing.T) { ++ cases := []struct { ++ name string ++ configure func(*CmdConfig) ++ assertBody func(*testing.T, *godo.KubernetesNodePoolUpdateRequest) ++ }{ ++ { ++ name: "tags changed", ++ configure: func(config *CmdConfig) { ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"role:web"}) ++ }, ++ assertBody: func(t *testing.T, r *godo.KubernetesNodePoolUpdateRequest) { ++ ++ if r.Count != nil { ++ t.Fatalf("expected count to be omitted when --count is unset, got %v", *r.Count) ++ } ++ assert.Equal(t, []string{"role:web"}, r.Tags) ++ }, ++ }, ++ { ++ name: "name changed", ++ configure: func(config *CmdConfig) { ++ config.Doit.Set(config.NS, doctl.ArgNodePoolName, "renamed-pool") ++ }, ++ assertBody: func(t *testing.T, r *godo.KubernetesNodePoolUpdateRequest) { ++ ++ if r.Count != nil { ++ t.Fatalf("expected count to be omitted when --count is unset, got %v", *r.Count) ++ } ++ assert.Equal(t, "renamed-pool", r.Name) ++ }, ++ }, ++ { ++ name: "pool id with prod namespace", ++ configure: func(config *CmdConfig) { ++ config.NS = "prod" ++ config.Doit.Set(config.NS, doctl.ArgNodePoolName, "worker-pool") ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"role:worker"}) ++ }, ++ assertBody: func(t *testing.T, r *godo.KubernetesNodePoolUpdateRequest) { ++ if r.Count != nil { ++ t.Fatalf("expected count to be omitted when --count is unset, got %v", *r.Count) ++ } ++ assert.Equal(t, "worker-pool", r.Name) ++ assert.Equal(t, []string{"role:worker"}, r.Tags) ++ }, ++ }, ++ } ++ ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ withTestClient(t, func(config *CmdConfig, tm *tcMocks) { ++ config.Args = append(config.Args, testCluster.ID, testNodePool.ID) ++ tc.configure(config) ++ ++ tm.kubernetes.EXPECT(). ++ UpdateNodePool(testCluster.ID, testNodePool.ID, gomock.Any()). ++ DoAndReturn(func(_, _ string, r *godo.KubernetesNodePoolUpdateRequest) (*do.KubernetesNodePool, error) { ++ tc.assertBody(t, r) ++ return &testNodePool, nil ++ }) ++ ++ err := testK8sCmdService().RunKubernetesNodePoolUpdate(config) ++ assert.NoError(t, err) ++ }) ++ }) ++ } ++ t.Run("prod namespace nonfixture pool id", func(t *testing.T) { ++ withTestClient(t, func(config *CmdConfig, tm *tcMocks) { ++ config.NS = "prod" ++ const otherPoolID = "11111111-2222-3333-4444-555555555555" ++ config.Args = append(config.Args, testCluster.ID, otherPoolID) ++ config.Doit.Set(config.NS, doctl.ArgNodePoolName, "worker-pool") ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"role:worker"}) ++ ++ tm.kubernetes.EXPECT(). ++ UpdateNodePool(testCluster.ID, otherPoolID, gomock.Any()). ++ DoAndReturn(func(_, _ string, r *godo.KubernetesNodePoolUpdateRequest) (*do.KubernetesNodePool, error) { ++ if r.Count != nil { ++ t.Fatalf("expected count to be omitted when --count is unset, got %v", *r.Count) ++ } ++ assert.Equal(t, "worker-pool", r.Name) ++ assert.Equal(t, []string{"role:worker"}, r.Tags) ++ return &testNodePool, nil ++ }) ++ ++ err := testK8sCmdService().RunKubernetesNodePoolUpdate(config) ++ assert.NoError(t, err) ++ }) ++ }) ++} ++ ++func TestKubernetesNodePoolUpdateSendsExplicitCountValues(t *testing.T) { ++ cases := []int{2, 7} ++ ++ for _, want := range cases { ++ t.Run(fmt.Sprintf("count_%d", want), func(t *testing.T) { ++ withTestClient(t, func(config *CmdConfig, tm *tcMocks) { ++ config.Args = append(config.Args, testCluster.ID, testNodePool.ID) ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"role:web"}) ++ config.Doit.Set(config.NS, doctl.ArgNodePoolCount, want) ++ ++ tm.kubernetes.EXPECT(). ++ UpdateNodePool(testCluster.ID, testNodePool.ID, gomock.Any()). ++ DoAndReturn(func(_, _ string, r *godo.KubernetesNodePoolUpdateRequest) (*do.KubernetesNodePool, error) { ++ ++ if r.Count == nil { ++ t.Fatalf("expected explicit --count=%d to be sent", want) ++ } ++ assert.Equal(t, want, *r.Count) ++ return &testNodePool, nil ++ }) ++ ++ err := testK8sCmdService().RunKubernetesNodePoolUpdate(config) ++ assert.NoError(t, err) ++ }) ++ }) ++ } ++ t.Run("explicit count with prod namespace", func(t *testing.T) { ++ withTestClient(t, func(config *CmdConfig, tm *tcMocks) { ++ config.NS = "prod" ++ const otherPoolID = "11111111-2222-3333-4444-555555555555" ++ config.Args = append(config.Args, testCluster.ID, otherPoolID) ++ config.Doit.Set(config.NS, doctl.ArgNodePoolName, "worker-pool") ++ config.Doit.Set(config.NS, doctl.ArgTag, []string{"role:worker"}) ++ config.Doit.Set(config.NS, doctl.ArgNodePoolCount, 11) ++ ++ tm.kubernetes.EXPECT(). ++ UpdateNodePool(testCluster.ID, otherPoolID, gomock.Any()). ++ DoAndReturn(func(_, _ string, r *godo.KubernetesNodePoolUpdateRequest) (*do.KubernetesNodePool, error) { ++ if r.Count == nil { ++ t.Fatalf("expected explicit --count=11 to be sent") ++ } ++ assert.Equal(t, 11, *r.Count) ++ return &testNodePool, nil ++ }) ++ ++ err := testK8sCmdService().RunKubernetesNodePoolUpdate(config) ++ assert.NoError(t, err) ++ }) ++ }) ++} ++ ++func boolPtr(val bool) *bool { ++ return &val ++} +diff --git 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 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++ ++case "$1" in ++ base) ++ go test -v -count=1 ./commands/ -run '^(TestKubernetesCommand|TestKubernetesClusterCommand|TestKubernetesNodePoolCommand|TestKubernetesOptionsCommand|TestKubernetesGet|TestKubernetesGetUpgrades|TestKubernetesKubeconfigSave|TestKubernetesKubeconfigShow|TestKubernetesList|TestKubernetesCreate|TestKubernetesUpdate|TestKubernetesUpgrade|TestKubernetesDelete|TestKubernetesNodePool_Get|TestKubernetesNodePool_List|TestKubernetesNodePool_Create|TestKubernetesNodePool_Update|TestKubernetesNodePool_Recycle|TestKubernetesNodePool_Delete|TestKubernetesOptions_Versions|TestKubernetesLatestVersions|Test_waitForClusterRunningDoesntPanicWithNilGet|TestLatestVersionForUpgrade)$' ++ ;; ++ new) ++ go test -v -count=1 ./commands/ -run '^(TestKubernetesUpdate|TestKubernetesNodePool_Update|TestKubernetesUpdateDoesNotSendAutoUpgradeWhenUnset|TestKubernetesUpdateSendsExplicitAutoUpgradeValues|TestKubernetesNodePoolUpdateDoesNotSendCountWhenUnset|TestKubernetesNodePoolUpdateSendsExplicitCountValues)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000805/tests/test.sh b/tasks/format-code-task-000805/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e30740e2424396bffb9808dcedfc72ecf61970fe --- /dev/null +++ b/tasks/format-code-task-000805/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' +commands/kubernetes_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-000805/tests/test_command.sh b/tasks/format-code-task-000805/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000805/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-000833/environment/Dockerfile b/tasks/format-code-task-000833/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8786070df72f786eaaaa787be1b2307fd38eaf26 --- /dev/null +++ b/tasks/format-code-task-000833/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:aa2e24fb616bfd8cbecaba25f18c8c4c1221972d532a7c12a3a199902820d010 diff --git a/tasks/format-code-task-000833/environment/setup/files/blocklist b/tasks/format-code-task-000833/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000833/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000833/environment/setup/setup.sh b/tasks/format-code-task-000833/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000833/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000833/tests/test.patch b/tasks/format-code-task-000833/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4c0a3f3923f726201610c54d0359ac7d8ac407d1 --- /dev/null +++ b/tasks/format-code-task-000833/tests/test.patch @@ -0,0 +1,551 @@ +diff --git a/usercase-test-coderl/test_sqla_interface_mutations.py b/usercase-test-coderl/test_sqla_interface_mutations.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_sqla_interface_mutations.py +@@ -0,0 +1,515 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++from pathlib import Path ++import tempfile ++ ++from flask import Flask ++import pytest ++from sqlalchemy import Column, Integer, String, create_engine ++from sqlalchemy.exc import IntegrityError, InvalidRequestError, OperationalError ++from sqlalchemy.orm import Session as SASession ++from sqlalchemy.orm import sessionmaker ++ ++from flask_appbuilder.exceptions import DatabaseException ++from flask_appbuilder.models.mixins import FileColumn, ImageColumn ++from flask_appbuilder.models.sqla import Model ++from flask_appbuilder.models.sqla.interface import SQLAInterface ++ ++ ++class MutationBook(Model): ++ __tablename__ = "usercase_fixture_mutation_book" ++ ++ id = Column(Integer, primary_key=True) ++ title = Column(String(80), unique=True, nullable=False) ++ ++ ++class ManagedAssetBook(Model): ++ __tablename__ = "usercase_fixture_managed_asset_book" ++ ++ id = Column(Integer, primary_key=True) ++ title = Column(String(80), unique=True, nullable=False) ++ file_name = Column(FileColumn) ++ image_name = Column(ImageColumn) ++ ++ ++class CountingSession(SASession): ++ def __init__(self, *args, **kwargs): ++ super().__init__(*args, **kwargs) ++ self.commit_calls = 0 ++ self.rollback_calls = 0 ++ ++ def commit(self): ++ self.commit_calls += 1 ++ return super().commit() ++ ++ def rollback(self): ++ self.rollback_calls += 1 ++ return super().rollback() ++ ++ ++class FailingMergeSession(CountingSession): ++ def __init__(self, *args, **kwargs): ++ super().__init__(*args, **kwargs) ++ self.error = OperationalError("UPDATE usercase_fixture_mutation_book", {}, RuntimeError("merge failed")) ++ ++ def merge(self, instance, *args, **kwargs): ++ raise self.error ++ ++ ++class FailingDeleteSession(CountingSession): ++ def __init__(self, *args, **kwargs): ++ super().__init__(*args, **kwargs) ++ self.error = OperationalError("DELETE usercase_fixture_mutation_book", {}, RuntimeError("delete failed")) ++ ++ def delete(self, instance): ++ raise self.error ++ ++ ++class FailingSecondDeleteSession(CountingSession): ++ def __init__(self, *args, **kwargs): ++ super().__init__(*args, **kwargs) ++ self.delete_calls = 0 ++ self.error = OperationalError("DELETE usercase_fixture_mutation_book", {}, RuntimeError("bulk delete failed")) ++ ++ def delete(self, instance): ++ self.delete_calls += 1 ++ if self.delete_calls == 2: ++ raise self.error ++ return super().delete(instance) ++ ++ ++@pytest.fixture ++def sqla_env(): ++ with tempfile.TemporaryDirectory() as tmp: ++ root = Path(tmp) ++ upload_dir = root / "uploads" ++ image_dir = root / "images" ++ upload_dir.mkdir() ++ image_dir.mkdir() ++ ++ engine = create_engine(f"sqlite:///{root / 'fixture.sqlite'}") ++ Model.metadata.create_all( ++ engine, tables=[MutationBook.__table__, ManagedAssetBook.__table__] ++ ) ++ session_factory = sessionmaker(bind=engine, class_=CountingSession) ++ ++ app = Flask("usercase_fixture_sqla") ++ app.config.update( ++ UPLOAD_FOLDER=str(upload_dir), ++ IMG_UPLOAD_FOLDER=str(image_dir), ++ IMG_UPLOAD_URL="/images/", ++ ) ++ ++ with app.app_context(): ++ yield session_factory, upload_dir, image_dir ++ ++ ++def external_titles(session, model=MutationBook): ++ session.rollback() ++ return [item.title for item in session.query(model).order_by(model.id).all()] ++ ++ ++def external_count(session, model=MutationBook): ++ session.rollback() ++ return session.query(model).count() ++ ++ ++def managed_files(upload_dir, image_dir): ++ return sorted( ++ [path.name for path in upload_dir.iterdir()] ++ + [path.name for path in image_dir.iterdir()] ++ ) ++ ++ ++def test_add_commit_true_persists_immediately(sqla_env): ++ ++ ++ ++ ++ Session, _upload_dir, _image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ interface = SQLAInterface(MutationBook, writer) ++ ++ book = MutationBook(title="Alpha") ++ result = interface.add(book) ++ ++ assert result is None ++ assert writer.commit_calls == 1 ++ assert writer.rollback_calls == 0 ++ ++ assert book.id is not None ++ assert external_count(reader) == 1 ++ assert external_titles(reader) == ["Alpha"] ++ ++ ++def test_add_commit_false_stages_until_manual_commit(sqla_env): ++ ++ ++ ++ ++ Session, _upload_dir, _image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ interface = SQLAInterface(MutationBook, writer) ++ ++ book = MutationBook(title="Beta") ++ result = interface.add(book, commit=False) ++ ++ assert result is None ++ assert writer.commit_calls == 0 ++ assert writer.rollback_calls == 0 ++ ++ assert book in writer ++ assert external_count(reader) == 0 ++ assert external_titles(reader) == [] ++ ++ writer.commit() ++ ++ assert writer.commit_calls == 1 ++ ++ assert book in writer ++ ++ assert book.id is not None ++ assert external_count(reader) == 1 ++ assert external_titles(reader) == ["Beta"] ++ ++ ++def test_edit_commit_modes_merge_state(sqla_env): ++ ++ ++ ++ ++ Session, _upload_dir, _image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ interface = SQLAInterface(MutationBook, writer) ++ interface.add(MutationBook(title="Gamma")) ++ writer.commit_calls = 0 ++ ++ committed_edit = MutationBook(id=1, title="Gamma committed") ++ result = interface.edit(committed_edit) ++ ++ assert result is None ++ assert writer.commit_calls == 1 ++ assert writer.rollback_calls == 0 ++ assert len(writer.new) == 0 ++ assert len(writer.dirty) == 0 ++ assert len(writer.deleted) == 0 ++ assert external_titles(reader) == ["Gamma committed"] ++ ++ uncommitted_edit = MutationBook(id=1, title="Gamma staged") ++ result = interface.edit(uncommitted_edit, commit=False) ++ ++ assert result is None ++ assert writer.commit_calls == 1 ++ assert writer.rollback_calls == 0 ++ ++ assert writer.get(MutationBook, 1).title == "Gamma staged" ++ assert external_titles(reader) == ["Gamma committed"] ++ ++ writer.commit() ++ ++ assert writer.commit_calls == 2 ++ assert len(writer.dirty) == 0 ++ assert external_titles(reader) == ["Gamma staged"] ++ ++ ++def test_delete_commit_modes_remove_rows(sqla_env): ++ ++ ++ ++ ++ Session, _upload_dir, _image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ interface = SQLAInterface(MutationBook, writer) ++ first = MutationBook(title="Delta") ++ second = MutationBook(title="Epsilon") ++ interface.add(first) ++ interface.add(second) ++ writer.commit_calls = 0 ++ ++ result = interface.delete(first) ++ ++ assert result is None ++ assert writer.commit_calls == 1 ++ assert writer.rollback_calls == 0 ++ assert len(writer.deleted) == 0 ++ assert external_count(reader) == 1 ++ assert external_titles(reader) == ["Epsilon"] ++ ++ second_id = second.id ++ result = interface.delete(second, commit=False) ++ ++ assert result is None ++ assert writer.commit_calls == 1 ++ assert writer.rollback_calls == 0 ++ ++ writer.flush() ++ assert writer.get(MutationBook, second_id) is None ++ assert external_count(reader) == 1 ++ assert external_titles(reader) == ["Epsilon"] ++ ++ writer.commit() ++ ++ assert writer.commit_calls == 2 ++ assert len(writer.deleted) == 0 ++ assert external_count(reader) == 0 ++ assert external_titles(reader) == [] ++ ++ ++def test_delete_removes_managed_file_and_image(sqla_env): ++ ++ ++ ++ ++ Session, upload_dir, image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ interface = SQLAInterface(ManagedAssetBook, writer) ++ (upload_dir / "doc-one.txt").write_text("one") ++ (image_dir / "cover-one.png").write_text("image") ++ book = ManagedAssetBook( ++ title="Managed One", file_name="doc-one.txt", image_name="cover-one.png" ++ ) ++ interface.add(book) ++ writer.commit_calls = 0 ++ ++ assert managed_files(upload_dir, image_dir) == ["cover-one.png", "doc-one.txt"] ++ assert external_count(reader, ManagedAssetBook) == 1 ++ ++ result = interface.delete(book) ++ ++ assert result is None ++ assert writer.commit_calls == 1 ++ assert writer.rollback_calls == 0 ++ assert managed_files(upload_dir, image_dir) == [] ++ assert external_count(reader, ManagedAssetBook) == 0 ++ assert external_titles(reader, ManagedAssetBook) == [] ++ ++ ++def test_delete_all_removes_every_item_file_and_image_and_commits_once(sqla_env): ++ ++ ++ ++ ++ Session, upload_dir, image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ interface = SQLAInterface(ManagedAssetBook, writer) ++ (upload_dir / "doc-two.txt").write_text("two") ++ (image_dir / "cover-two.png").write_text("two") ++ (upload_dir / "doc-three.txt").write_text("three") ++ (image_dir / "cover-three.png").write_text("three") ++ first = ManagedAssetBook( ++ title="Managed Two", file_name="doc-two.txt", image_name="cover-two.png" ++ ) ++ second = ManagedAssetBook( ++ title="Managed Three", file_name="doc-three.txt", image_name="cover-three.png" ++ ) ++ interface.add(first) ++ interface.add(second) ++ writer.commit_calls = 0 ++ ++ assert managed_files(upload_dir, image_dir) == [ ++ "cover-three.png", ++ "cover-two.png", ++ "doc-three.txt", ++ "doc-two.txt", ++ ] ++ assert external_count(reader, ManagedAssetBook) == 2 ++ assert external_titles(reader, ManagedAssetBook) == ["Managed Two", "Managed Three"] ++ ++ result = interface.delete_all([first, second]) ++ ++ assert result is None ++ assert writer.commit_calls == 1 ++ assert writer.rollback_calls == 0 ++ assert managed_files(upload_dir, image_dir) == [] ++ assert external_count(reader, ManagedAssetBook) == 0 ++ assert external_titles(reader, ManagedAssetBook) == [] ++ ++ ++def test_out_of_order_delete_transient_model_raises_database_exception(sqla_env): ++ ++ ++ ++ ++ Session, _upload_dir, _image_dir = sqla_env ++ writer = Session() ++ interface = SQLAInterface(MutationBook, writer) ++ ++ with pytest.raises(DatabaseException) as exc_info: ++ interface.delete(MutationBook(title="Never persisted")) ++ ++ assert type(exc_info.value.__cause__) is InvalidRequestError ++ assert writer.rollback_calls == 1 ++ assert writer.commit_calls == 0 ++ ++ ++def test_delete_all_empty_cleanup_is_idempotent(sqla_env): ++ ++ ++ ++ ++ Session, _upload_dir, _image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ interface = SQLAInterface(MutationBook, writer) ++ ++ assert interface.delete_all([]) is None ++ assert interface.delete_all([]) is None ++ ++ assert writer.commit_calls == 2 ++ assert writer.rollback_calls == 0 ++ assert external_count(reader) == 0 ++ assert external_titles(reader) == [] ++ ++ ++def test_two_interfaces_keep_independent_session_state(sqla_env): ++ ++ ++ ++ ++ Session, _upload_dir, _image_dir = sqla_env ++ writer_a = Session() ++ writer_b = Session() ++ interface_a = SQLAInterface(MutationBook, writer_a) ++ interface_b = SQLAInterface(MutationBook, writer_b) ++ book_a = MutationBook(title="Only A") ++ book_b = MutationBook(title="Only B") ++ ++ assert interface_a.add(book_a, commit=False) is None ++ ++ ++ assert book_a in writer_a ++ assert book_a not in writer_b ++ assert writer_a.commit_calls == 0 ++ ++ assert book_b not in writer_b ++ assert writer_b.commit_calls == 0 ++ ++ assert interface_b.add(book_b, commit=False) is None ++ ++ ++ assert book_a in writer_a ++ assert book_b in writer_b ++ assert writer_a.commit_calls == 0 ++ assert writer_b.commit_calls == 0 ++ ++ ++def test_repeated_add_delete_cycles_keep_rows_and_managed_files_bounded(sqla_env): ++ ++ ++ ++ ++ Session, upload_dir, image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ ++ for index in range(125): ++ interface = SQLAInterface(ManagedAssetBook, writer) ++ file_name = f"cycle-{index}.txt" ++ image_name = f"cycle-{index}.png" ++ (upload_dir / file_name).write_text("payload") ++ (image_dir / image_name).write_text("image") ++ item = ManagedAssetBook( ++ title=f"Cycle {index}", file_name=file_name, image_name=image_name ++ ) ++ ++ assert interface.add(item) is None ++ assert interface.delete(item) is None ++ ++ assert external_count(reader, ManagedAssetBook) == 0 ++ assert external_titles(reader, ManagedAssetBook) == [] ++ assert managed_files(upload_dir, image_dir) == [] ++ ++ ++def test_add_rolls_back_and_reraises_original_sqlalchemy_exception(sqla_env): ++ ++ ++ ++ ++ Session, _upload_dir, _image_dir = sqla_env ++ writer = Session() ++ reader = Session() ++ interface = SQLAInterface(MutationBook, writer) ++ interface.add(MutationBook(title="Duplicate")) ++ writer.rollback_calls = 0 ++ ++ with pytest.raises(IntegrityError): ++ interface.add(MutationBook(title="Duplicate")) ++ ++ assert writer.rollback_calls == 1 ++ assert external_count(reader) == 1 ++ assert external_titles(reader) == ["Duplicate"] ++ ++ ++def test_edit_rolls_back_and_wraps_sqlalchemy_exception(sqla_env): ++ ++ ++ ++ ++ _Session, _upload_dir, _image_dir = sqla_env ++ engine = create_engine("sqlite:///:memory:") ++ Model.metadata.create_all(engine, tables=[MutationBook.__table__]) ++ writer = sessionmaker(bind=engine, class_=FailingMergeSession)() ++ interface = SQLAInterface(MutationBook, writer) ++ ++ with pytest.raises(DatabaseException) as exc_info: ++ interface.edit(MutationBook(id=1, title="Broken edit")) ++ ++ assert type(exc_info.value.__cause__) is OperationalError ++ assert writer.rollback_calls == 1 ++ assert writer.commit_calls == 0 ++ ++ ++def test_delete_rolls_back_and_wraps_sqlalchemy_exception(sqla_env): ++ ++ ++ ++ ++ _Session, _upload_dir, _image_dir = sqla_env ++ engine = create_engine("sqlite:///:memory:") ++ Model.metadata.create_all(engine, tables=[MutationBook.__table__]) ++ writer = sessionmaker(bind=engine, class_=FailingDeleteSession)() ++ interface = SQLAInterface(MutationBook, writer) ++ ++ with pytest.raises(DatabaseException) as exc_info: ++ interface.delete(MutationBook(id=1, title="Broken delete")) ++ ++ assert type(exc_info.value.__cause__) is OperationalError ++ assert writer.rollback_calls == 1 ++ assert writer.commit_calls == 0 ++ ++ ++def test_delete_all_rolls_back_and_wraps_sqlalchemy_exception(sqla_env): ++ ++ ++ ++ ++ _Session, _upload_dir, _image_dir = sqla_env ++ engine = create_engine("sqlite:///:memory:") ++ Model.metadata.create_all(engine, tables=[MutationBook.__table__]) ++ writer = sessionmaker(bind=engine, class_=FailingSecondDeleteSession)() ++ writer.add_all([MutationBook(title="Bulk One"), MutationBook(title="Bulk Two")]) ++ writer.commit() ++ writer.commit_calls = 0 ++ items = writer.query(MutationBook).order_by(MutationBook.id).all() ++ interface = SQLAInterface(MutationBook, writer) ++ ++ with pytest.raises(DatabaseException) as exc_info: ++ interface.delete_all(items) ++ ++ assert type(exc_info.value.__cause__) is OperationalError ++ assert writer.delete_calls == 2 ++ assert writer.rollback_calls == 1 ++ assert writer.commit_calls == 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,26 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++ ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PIP_NO_INPUT=1 ++unset PIP_INDEX_URL PIP_EXTRA_INDEX_URL PIP_FIND_LINKS ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++python -m pip install --no-index --disable-pip-version-check --no-input --no-build-isolation --no-deps -e . pytest >/dev/null ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_sqla_interface_mutations.py -v diff --git a/tasks/format-code-task-000833/tests/test.sh b/tasks/format-code-task-000833/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..483fa29df20bf171d6121d86b53d1c6bbedf4420 --- /dev/null +++ b/tasks/format-code-task-000833/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_sqla_interface_mutations.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-000833/tests/test_command.sh b/tasks/format-code-task-000833/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000833/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-000834/environment/Dockerfile b/tasks/format-code-task-000834/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ad0ba2ff60879ffeb7d8170001fa95f55d28b8bd --- /dev/null +++ b/tasks/format-code-task-000834/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1ee7aa3e611debbd31483b322d8491aebf0db61df49887d21199a7dd2b766a7c diff --git a/tasks/format-code-task-000834/environment/setup/files/blocklist b/tasks/format-code-task-000834/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000834/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000834/environment/setup/setup.sh b/tasks/format-code-task-000834/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000834/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000834/tests/test.patch b/tasks/format-code-task-000834/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bf6ae6bf07c03b0744a40867fe7b7b98117380e4 --- /dev/null +++ b/tasks/format-code-task-000834/tests/test.patch @@ -0,0 +1,120 @@ +diff --git a/dragonchain/job_processor/iam_role_utest.py b/dragonchain/job_processor/iam_role_utest.py +new file mode 100644 +index 0000000..e0fa386 +--- /dev/null ++++ b/dragonchain/job_processor/iam_role_utest.py +@@ -0,0 +1,92 @@ ++import os ++import importlib ++import unittest ++from unittest.mock import patch ++ ++from dragonchain import test_env # noqa: F401 ++from dragonchain.job_processor import job_processor ++ ++ ++valid_task_definition = { ++ "task_type": "create", ++ "txn_type": "test", ++ "id": "my-id", ++ "image": "test", ++ "cmd": "echo", ++ "args": [], ++ "env": {}, ++ "execution_order": "serial", ++} ++ ++ ++def _get_annotations_from_create_call(mock_kube): ++ call_args = mock_kube.create_namespaced_job.call_args ++ body = call_args.kwargs.get("body") ++ if body is None and len(call_args.args) >= 2: ++ body = call_args.args[1] ++ return body.spec.template.metadata.annotations ++ ++ ++class TestJobProcessorIAMRoleOptional(unittest.TestCase): ++ def test_job_processor_import_does_not_crash_when_iam_role_missing(self): ++ ++ original = os.environ.pop("IAM_ROLE", None) ++ crashed_with_iam_role_key_error = False ++ try: ++ try: ++ importlib.reload(job_processor) ++ except KeyError as e: ++ if "IAM_ROLE" in str(e): ++ crashed_with_iam_role_key_error = True ++ else: ++ raise ++ finally: ++ if original is not None: ++ os.environ["IAM_ROLE"] = original ++ else: ++ os.environ["IAM_ROLE"] = "" ++ importlib.reload(job_processor) ++ self.assertFalse( ++ crashed_with_iam_role_key_error, ++ "job_processor module crashed with KeyError on IAM_ROLE when env var was missing", ++ ) ++ ++ @patch("dragonchain.job_processor.job_processor._kube") ++ def test_attempt_job_launch_omits_iam_annotation_when_iam_role_empty(self, mock_kube): ++ ++ with patch.object(job_processor, "IAM_ROLE", ""): ++ job_processor.attempt_job_launch(valid_task_definition) ++ annotations = _get_annotations_from_create_call(mock_kube) or {} ++ self.assertNotIn( ++ "iam.amazonaws.com/role", ++ annotations, ++ f"iam.amazonaws.com/role annotation should not be present when IAM_ROLE is empty; got {annotations!r}", ++ ) ++ ++ @patch("dragonchain.job_processor.job_processor._kube") ++ def test_attempt_job_launch_omits_iam_annotation_when_iam_role_none(self, mock_kube): ++ ++ with patch.object(job_processor, "IAM_ROLE", None): ++ job_processor.attempt_job_launch(valid_task_definition) ++ annotations = _get_annotations_from_create_call(mock_kube) or {} ++ self.assertNotIn( ++ "iam.amazonaws.com/role", ++ annotations, ++ f"iam.amazonaws.com/role annotation should not be present when IAM_ROLE is None; got {annotations!r}", ++ ) ++ ++ @patch("dragonchain.job_processor.job_processor._kube") ++ def test_attempt_job_launch_includes_iam_annotation_when_iam_role_set(self, mock_kube): ++ ++ with patch.object(job_processor, "IAM_ROLE", "my-test-role"): ++ job_processor.attempt_job_launch(valid_task_definition) ++ annotations = _get_annotations_from_create_call(mock_kube) or {} ++ self.assertEqual( ++ annotations.get("iam.amazonaws.com/role"), ++ "my-test-role", ++ f"Expected iam.amazonaws.com/role annotation set to 'my-test-role'; got {annotations!r}", ++ ) ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..9e2dfe5 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest discover -p 'iam_role_utest.py' -s dragonchain/job_processor -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest discover -p 'iam_role_utest.py' -s dragonchain/job_processor -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000834/tests/test.sh b/tasks/format-code-task-000834/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8e949f185a75a2135decf9ec8e7c6e4e98d0b075 --- /dev/null +++ b/tasks/format-code-task-000834/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' +dragonchain/job_processor/iam_role_utest.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-000834/tests/test_command.sh b/tasks/format-code-task-000834/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000834/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000850/environment/Dockerfile b/tasks/format-code-task-000850/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..23adc079ddeaa45760b9b4e3586704f5a3a57e4d --- /dev/null +++ b/tasks/format-code-task-000850/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1ef09118020532c927ca2fdc022cdc7e91787f59a5249d87bb29660bf4e3c06b diff --git a/tasks/format-code-task-000850/environment/setup/files/blocklist b/tasks/format-code-task-000850/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000850/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000850/environment/setup/setup.sh b/tasks/format-code-task-000850/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000850/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000850/tests/test.patch b/tasks/format-code-task-000850/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..96606871e3883d9b57c7b3896deff97df2733e0b --- /dev/null +++ b/tasks/format-code-task-000850/tests/test.patch @@ -0,0 +1,78 @@ +diff --git a/internal/security/config/command/proxy/tls/command_test.go b/internal/security/config/command/proxy/tls/command_test.go +index 8733324bcf..f2dec30ff8 100644 +--- a/internal/security/config/command/proxy/tls/command_test.go ++++ b/internal/security/config/command/proxy/tls/command_test.go +@@ -27,13 +27,13 @@ func TestTLSBagArguments(t *testing.T) { + badArgTestcases := [][]string{ + {}, // missing arg --in + {"-badarg"}, // invalid arg +- {"--incert", "somefile"}, // missing --inkey +- {"--inkey", "keyfile"}, // missing --incert +- {"--inkey"}, // missing filename +- {"--incert"}, // missing filename +- {"--targetfolder"}, // missing filename +- {"--certfilename"}, // missing filename +- {"--keyfilename"}, // missing filename ++ {"--inCert", "somefile"}, ++ {"--inKey", "keyfile"}, ++ {"--inKey"}, ++ {"--inCert"}, ++ {"--targetFolder"}, ++ {"--certFilename"}, ++ {"--keyFilename"}, + } + + for _, args := range badArgTestcases { +@@ -51,9 +51,9 @@ func TestTLSErrorFileNotFound(t *testing.T) { + // Arrange + lc := logger.MockLogger{} + fileNotFoundTestcases := [][]string{ +- {"--incert", "missingcertificate", "--inkey", "missingprivatekey"}, // both files missing +- {"--incert", "testdata/testCert.pem", "--inkey", "missingprivatekey"}, // key file missing +- {"--incert", "missingcertificate", "--inkey", "testdata/testCert.prkey"}, // cert file missing ++ {"--inCert", "missingcertificate", "--inKey", "missingprivatekey"}, ++ {"--inCert", "testdata/testCert.pem", "--inKey", "missingprivatekey"}, ++ {"--inCert", "missingcertificate", "--inKey", "testdata/testCert.prkey"}, + } + + for _, args := range fileNotFoundTestcases { +@@ -74,14 +74,14 @@ func TestInstallCertificate(t *testing.T) { + lc := logger.MockLogger{} + validCommandLines := [][]string{ + {"new.crt", "new.key", "", "", "/etc/ssl/nginx/nginx.crt", "/etc/ssl/nginx/nginx.key"}, +- {"new.crt", "new.key", "--targetfolder", "/foofolder", "/foofolder/nginx.crt", "/foofolder/nginx.key"}, +- {"new.crt", "new.key", "--certfilename", "foo.crt", "/etc/ssl/nginx/foo.crt", "/etc/ssl/nginx/nginx.key"}, +- {"new.crt", "new.key", "--keyfilename", "foo.key", "/etc/ssl/nginx/nginx.crt", "/etc/ssl/nginx/foo.key"}, ++ {"new.crt", "new.key", "--targetFolder", "/foofolder", "/foofolder/nginx.crt", "/foofolder/nginx.key"}, ++ {"new.crt", "new.key", "--certFilename", "foo.crt", "/etc/ssl/nginx/foo.crt", "/etc/ssl/nginx/nginx.key"}, ++ {"new.crt", "new.key", "--keyFilename", "foo.key", "/etc/ssl/nginx/nginx.crt", "/etc/ssl/nginx/foo.key"}, + } + + for _, args := range validCommandLines { + // Arrange +- command, err := NewCommand(lc, []string{"--incert", args[0], "--inkey", args[1], args[2], args[3]}) ++ command, err := NewCommand(lc, []string{"--inCert", args[0], "--inKey", args[1], args[2], args[3]}) + require.NoError(t, err) + mockOpener := &mocks.FileIoPerformer{} + command.fileOpener = mockOpener +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+3S0QrCIBQG4F3vKYyu25nWtqueJTZnJSwNdVFv3xrBIqhuGlH93805qOCR36Rq ++dVOvlDlQNJa0U2RZXzv3te95JrgQeZEX8yjlPOeLiGWjTXSj9aF0jEXO2vDs3Kv9L5UM+Qflw0ra ++3a40deK377vjVf58Lob8RbfOF33+6ftGeOzP859OqNKGqtJvY1mz/hNUqo43ll1aNjuwmbStCUvO ++EtImKGfKhrySrdPhRNKatd7Q9dvQ3tnjiULjKf70ywAAAAAAAAAAAAAAAAAAAAAAft8ZnqmmxQAo ++AAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000850/tests/test.sh b/tasks/format-code-task-000850/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ffc413d202821054b570182ae129a46c349a3e87 --- /dev/null +++ b/tasks/format-code-task-000850/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/security/config/command/proxy/tls/command_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-000850/tests/test_command.sh b/tasks/format-code-task-000850/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000850/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000851/environment/Dockerfile b/tasks/format-code-task-000851/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f047c68bc12fc06441ed583d324df3485739b78b --- /dev/null +++ b/tasks/format-code-task-000851/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:adb3f1b0a50816483740f2b795066d9cbf1210410f4bb3d7bed73682ea412226 diff --git a/tasks/format-code-task-000851/environment/setup/files/blocklist b/tasks/format-code-task-000851/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000851/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000851/environment/setup/setup.sh b/tasks/format-code-task-000851/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000851/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000851/tests/test.patch b/tasks/format-code-task-000851/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..760c7b3d33089615d5aa3d838ed60ce6edf83210 --- /dev/null +++ b/tasks/format-code-task-000851/tests/test.patch @@ -0,0 +1,58 @@ +diff --git a/tests/conform-react.spec.ts b/tests/conform-react.spec.ts +index dc26e244..cb9da1bc 100644 +--- a/tests/conform-react.spec.ts ++++ b/tests/conform-react.spec.ts +@@ -297,7 +297,6 @@ describe('conform-react', () => { + }), + ).toEqual({ + ...props, +- 'aria-invalid': true, + 'aria-describedby': 'test-error', + }); + expect( +@@ -316,7 +315,6 @@ describe('conform-react', () => { + ), + ).toEqual({ + ...props, +- 'aria-invalid': true, + 'aria-describedby': 'test-error something', + }); + expect( +diff --git a/tests/integrations/input-attributes.spec.ts b/tests/integrations/input-attributes.spec.ts +index f35f8e1c..9ae9dd18 100644 +--- a/tests/integrations/input-attributes.spec.ts ++++ b/tests/integrations/input-attributes.spec.ts +@@ -220,7 +220,7 @@ test('setup aria-invalid correctly', async ({ page }) => { + ); + + await playground.submit.click(); +- await expect(playground.form).toHaveAttribute('aria-invalid', 'true'); ++ await expect(playground.form).not.toHaveAttribute('aria-invalid', 'true'); + await expect(fieldset.title).toHaveAttribute('aria-invalid', 'true'); + await expect(fieldset.description).toHaveAttribute('aria-invalid', 'true'); + await expect(fieldset.images).toHaveAttribute('aria-invalid', '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,9 @@ ++H4sIAAAAAAAAA+3TzW/TMBQA8J7zVzyEBN0hX93SHRAckDhwQ1wRqpz4pTFzbMsf2frfY6el7dBg ++l00I7f0uqVO/D+clRRuE5BtUU7l4LlV03TTzNfr9Ov+um1VdX6/rpor76npdXS2gebaOzgTnmQVY ++WK393/Y99v9/qjjN36Pzm06PI1O8cMPT1Xhk/nW9ao7zv1yn+V+tV5cLqJ6uhT974fPvOMyDb5Fn ++2Wv4pFywCEaZEYQDNjEhWSsRlm43SqFuwGtQmmO+qt66ed9FJnp4BYcXB/JpH/3mQ8lxKlWQ8h34 ++AVUGIBXkrodSG18ekpStUOUcUAZnS6k7Jo/3sl6kpj6rOCMpgaNBxVF1Ah3EoinFZtQ8yLR2MArn ++hNqmfr7FjnJ+f8f3Yx/74+2zHmp8TJ8BGNbdsG3cu1SIHDn02kKr/QDpGYHfGXQX2Rxug4L520nR ++X+Mi5oZJzPtaq28d2n3QstMqphlzi6zzhTPYFT5muZv6Nk9ZlLn7FZiWeW6s/oHd/TSufDDNefEv ++ku1urdgOPp7N49YyL7Q6NCGUCT5n3lvRhnjr1Ecqb06h+4POFc+ypMXDCU79vu8Gq0cRxuxfv9SE ++EEIIIYQQQgghhBBCCCGEEEIIIS/IT1sH3osAKAAA +diff --git 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-000851/tests/test.sh b/tasks/format-code-task-000851/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aa39de5ce43bf6c5ed62fc2965b58412281afeb5 --- /dev/null +++ b/tasks/format-code-task-000851/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/conform-react.spec.ts +tests/integrations/input-attributes.spec.ts +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-000851/tests/test_command.sh b/tasks/format-code-task-000851/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000851/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000856/environment/Dockerfile b/tasks/format-code-task-000856/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6c7a59ff38fb2540c1f161a40e995f54c9fa5b20 --- /dev/null +++ b/tasks/format-code-task-000856/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ca6de980fa2f650b076406c1073230e667d53252c921c8d9e4582a05dcfb5cc3 diff --git a/tasks/format-code-task-000856/environment/setup/files/blocklist b/tasks/format-code-task-000856/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000856/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000856/environment/setup/setup.sh b/tasks/format-code-task-000856/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000856/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000856/tests/test.patch b/tasks/format-code-task-000856/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..90527fde747b91397885b737680b5762c7deba2c --- /dev/null +++ b/tasks/format-code-task-000856/tests/test.patch @@ -0,0 +1,197 @@ +diff --git a/config/configuration_test.go b/config/configuration_test.go +index 5f76d34..59295d0 100644 +--- a/config/configuration_test.go ++++ b/config/configuration_test.go +@@ -8,10 +8,11 @@ import ( + ) + + const ( +- PIHOLE_HOSTNAME = "PIHOLE_HOSTNAME" +- PIHOLE_PORT = "PIHOLE_PORT" +- PIHOLE_API_TOKEN = "PIHOLE_API_TOKEN" +- PIHOLE_PROTOCOL = "PIHOLE_PROTOCOL" ++ PIHOLE_HOSTNAME = "PIHOLE_HOSTNAME" ++ PIHOLE_PORT = "PIHOLE_PORT" ++ PIHOLE_ADMIN_CONTEXT = "PIHOLE_ADMIN_CONTEXT" ++ PIHOLE_API_TOKEN = "PIHOLE_API_TOKEN" ++ PIHOLE_PROTOCOL = "PIHOLE_PROTOCOL" + ) + + type EnvInitiazlier func(*testing.T) +@@ -32,6 +33,7 @@ func TestSplitDefault(t *testing.T) { + clientConfig := clientConfigs[0] + assert.Equal("127.0.0.1", clientConfig.PIHoleHostname) + assert.Equal("http", clientConfig.PIHoleProtocol) ++ assert.Equal("admin", clientConfig.PIHoleAdminContext) + assert.Equal(uint16(80), clientConfig.PIHolePort) + assert.Empty(clientConfig.PIHoleApiToken) + assert.Empty(clientConfig.PIHolePassword) +@@ -43,6 +45,7 @@ func TestSplitMultipleHostWithSameConfig(t *testing.T) { + env := getDefaultEnvConfig() + env.PIHoleHostname = []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"} + env.PIHoleApiToken = []string{"api-token"} ++ env.PIHoleAdminContext = []string{"foo"} + env.PIHolePort = []uint16{8080} + + clientConfigs, err := env.Split() +@@ -50,24 +53,28 @@ func TestSplitMultipleHostWithSameConfig(t *testing.T) { + assert.Len(clientConfigs, 3) + + testCases := []struct { +- Host string +- Port uint16 +- Protocol string ++ Host string ++ Port uint16 ++ AdminContext string ++ Protocol string + }{ + { +- Host: "127.0.0.1", +- Port: 8080, +- Protocol: "http", ++ Host: "127.0.0.1", ++ Port: 8080, ++ AdminContext: "foo", ++ Protocol: "http", + }, + { +- Host: "127.0.0.2", +- Port: 8080, +- Protocol: "http", ++ Host: "127.0.0.2", ++ Port: 8080, ++ AdminContext: "foo", ++ Protocol: "http", + }, + { +- Host: "127.0.0.3", +- Port: 8080, +- Protocol: "http", ++ Host: "127.0.0.3", ++ Port: 8080, ++ AdminContext: "foo", ++ Protocol: "http", + }, + } + +@@ -90,6 +97,7 @@ func TestSplitMultipleHostWithMultipleConfigs(t *testing.T) { + env := getDefaultEnvConfig() + env.PIHoleHostname = []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"} + env.PIHoleApiToken = []string{"api-token1", "", "api-token3"} ++ env.PIHoleAdminContext = []string{"", "foo", "bar"} + env.PIHolePassword = []string{"", "password2", ""} + env.PIHolePort = []uint16{8081, 8082, 8083} + +@@ -98,32 +106,36 @@ func TestSplitMultipleHostWithMultipleConfigs(t *testing.T) { + assert.Len(clientConfigs, 3) + + testCases := []struct { +- Host string +- Port uint16 +- Protocol string +- ApiToken string +- Password string ++ Host string ++ Port uint16 ++ AdminContext string ++ Protocol string ++ ApiToken string ++ Password string + }{ + { +- Host: "127.0.0.1", +- Port: 8081, +- Protocol: "http", +- ApiToken: "api-token1", +- Password: "", ++ Host: "127.0.0.1", ++ Port: 8081, ++ AdminContext: "", ++ Protocol: "http", ++ ApiToken: "api-token1", ++ Password: "", + }, + { +- Host: "127.0.0.2", +- Port: 8082, +- Protocol: "http", +- ApiToken: "", +- Password: "password2", ++ Host: "127.0.0.2", ++ Port: 8082, ++ AdminContext: "foo", ++ Protocol: "http", ++ ApiToken: "", ++ Password: "password2", + }, + { +- Host: "127.0.0.3", +- Port: 8083, +- Protocol: "http", +- ApiToken: "api-token3", +- Password: "", ++ Host: "127.0.0.3", ++ Port: 8083, ++ AdminContext: "bar", ++ Protocol: "http", ++ ApiToken: "api-token3", ++ Password: "", + }, + } + +@@ -133,6 +145,7 @@ func TestSplitMultipleHostWithMultipleConfigs(t *testing.T) { + + assert.Equal(tc.Host, clientConfig.PIHoleHostname) + assert.Equal(tc.Protocol, clientConfig.PIHoleProtocol) ++ assert.Equal(tc.AdminContext, clientConfig.PIHoleAdminContext) + assert.Equal(tc.Port, clientConfig.PIHolePort) + assert.Equal(tc.ApiToken, clientConfig.PIHoleApiToken) + assert.Equal(tc.Password, clientConfig.PIHolePassword) +@@ -140,7 +153,7 @@ func TestSplitMultipleHostWithMultipleConfigs(t *testing.T) { + } + } + +-func TestWrongParams(t *testing.T) { ++func TestWrongNumberOfApiTokenParams(t *testing.T) { + assert := assert.New(t) + + env := getDefaultEnvConfig() +@@ -152,3 +165,17 @@ func TestWrongParams(t *testing.T) { + assert.Errorf(err, "Wrong number of PIHoleApiToken. PIHoleApiToken can be empty to use default, one value to use for all hosts, or match the number of hosts") + assert.Nil(clientConfigs) + } ++ ++func TestWrongNumberOfAdminContextParams(t *testing.T) { ++ assert := assert.New(t) ++ ++ env := getDefaultEnvConfig() ++ env.PIHoleHostname = []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"} ++ env.PIHoleApiToken = []string{"api-token"} ++ env.PIHoleAdminContext = []string{"admin1", "admin2"} ++ env.PIHolePort = []uint16{808} ++ ++ clientConfigs, err := env.Split() ++ assert.Errorf(err, "Wrong number of PIHoleAdminContext. PIHoleAdminContext can be empty to use default, one value to use for all hosts, or match the number of hosts") ++ assert.Nil(clientConfigs) ++} +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+3RywrCMBCF4ax9inmBXlKbZuWzlN6sgjbQpn1+tSCKoN0oIv7fZgYmkAMnLMf9 ++oc6bborUp8Rn1ph5nj3Oedcm0dpaG6eZirXO9FqJ+ViiO+Pgi15E9c75V++W7j8qvPXvm8HnlTse ++i64Oh937/ljs3yTX/jM7959m60RJ/L4Iz/15/1Utc/FlU69aJ5dVwqhy3XbfRhJMElRu7PxGr76d ++FAAAAAAAAAAAAAAAAMCjExENI34AKAAA +diff --git 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-000856/tests/test.sh b/tasks/format-code-task-000856/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..98d341cddccdfa327aec36492c9454d4d1913645 --- /dev/null +++ b/tasks/format-code-task-000856/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/configuration_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-000856/tests/test_command.sh b/tasks/format-code-task-000856/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000856/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000857/environment/Dockerfile b/tasks/format-code-task-000857/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3b5725c4df7e6f53b20f35b2b99fd77e330776de --- /dev/null +++ b/tasks/format-code-task-000857/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:86e9c9364c9799dae4aa156202c79f34d9ab318e4dcfdf2cf67fa79ffab20bfd diff --git a/tasks/format-code-task-000857/environment/setup/files/blocklist b/tasks/format-code-task-000857/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000857/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000857/environment/setup/setup.sh b/tasks/format-code-task-000857/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000857/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000857/tests/test.patch b/tasks/format-code-task-000857/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a2512d3e516ca32b5b1ba177093aa5454ba3c3e5 --- /dev/null +++ b/tasks/format-code-task-000857/tests/test.patch @@ -0,0 +1,103 @@ +diff --git a/pkg/apis/eksctl.io/v1alpha5/validation_test.go b/pkg/apis/eksctl.io/v1alpha5/validation_test.go +index c31f5349ad..2361b11db1 100644 +--- a/pkg/apis/eksctl.io/v1alpha5/validation_test.go ++++ b/pkg/apis/eksctl.io/v1alpha5/validation_test.go +@@ -4,6 +4,7 @@ import ( + "github.com/bxcodec/faker" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" ++ "github.com/weaveworks/eksctl/pkg/utils/strings" + ) + + var _ = Describe("ClusterConfig validation", func() { +@@ -469,6 +470,29 @@ var _ = Describe("ClusterConfig validation", func() { + err = validateInstancesDistribution(ng) + Expect(err).ToNot(HaveOccurred()) + }) ++ ++ It("It fails when the spotAllocationStrategy is not a supported strategy", func() { ++ ng.InstancesDistribution.SpotAllocationStrategy = strings.Pointer("unsupported-strategy") ++ ++ err := validateInstancesDistribution(ng) ++ Expect(err).To(HaveOccurred()) ++ }) ++ ++ It("It fails when the spotAllocationStrategy is capacity-optimized and spotInstancePools is specified", func() { ++ ng.InstancesDistribution.SpotAllocationStrategy = strings.Pointer("capacity-optimized") ++ ng.InstancesDistribution.SpotInstancePools = newInt(2) ++ ++ err := validateInstancesDistribution(ng) ++ Expect(err).To(HaveOccurred()) ++ }) ++ ++ It("It does not fail when the spotAllocationStrategy is lowest-price and spotInstancePools is specified", func() { ++ ng.InstancesDistribution.SpotAllocationStrategy = strings.Pointer("lowest-price") ++ ng.InstancesDistribution.SpotInstancePools = newInt(2) ++ ++ err := validateInstancesDistribution(ng) ++ Expect(err).ToNot(HaveOccurred()) ++ }) + }) + }) + +diff --git a/pkg/cfn/builder/api_test.go b/pkg/cfn/builder/api_test.go +index d8064f2807..5974a945b2 100644 +--- a/pkg/cfn/builder/api_test.go ++++ b/pkg/cfn/builder/api_test.go +@@ -107,6 +107,7 @@ type Properties struct { + OnDemandPercentageAboveBaseCapacity string + SpotMaxPrice string + SpotInstancePools string ++ SpotAllocationStrategy string + } + } + } +@@ -2618,6 +2619,7 @@ var _ = Describe("CloudFormation template builder API", func() { + baseCap := 40 + percentageOnDemand := 20 + pools := 3 ++ spotAllocationStrategy := "lowest-price" + ng.InstanceType = "mixed" + ng.InstancesDistribution = &api.NodeGroupInstancesDistribution{ + MaxPrice: &maxSpotPrice, +@@ -2625,6 +2627,7 @@ var _ = Describe("CloudFormation template builder API", func() { + OnDemandBaseCapacity: &baseCap, + OnDemandPercentageAboveBaseCapacity: &percentageOnDemand, + SpotInstancePools: &pools, ++ SpotAllocationStrategy: &spotAllocationStrategy, + } + + zero := 0 +@@ -2657,6 +2660,7 @@ var _ = Describe("CloudFormation template builder API", func() { + Expect(nodeGroupProperties.MixedInstancesPolicy.InstancesDistribution.OnDemandPercentageAboveBaseCapacity).To(Equal("20")) + Expect(nodeGroupProperties.MixedInstancesPolicy.InstancesDistribution.SpotInstancePools).To(Equal("3")) + Expect(nodeGroupProperties.MixedInstancesPolicy.InstancesDistribution.SpotMaxPrice).To(Equal("0.045000")) ++ Expect(nodeGroupProperties.MixedInstancesPolicy.InstancesDistribution.SpotAllocationStrategy).To(Equal("lowest-price")) + + }) + }) +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+3TT2/TMBQA8J7zKR7dpRVKnLRNiib1gITEhXGAcdhpcp2XxjSzI9sJE5+el7QM ++1gG7bEKI97skkZP3x89Jtp1uyms0vZg8l5Ss83y8ktPreJ/liyxbp8u8WE7SLCvS1QTyZ6voJ50P ++0gFMnLXhT+89tv6PSn7MP6AP18re3EhTJr5+uhyPzD9Li/xu/qt1QfNfFYt8AunTlfB7//n8z16I ++rTZiK30deQwQY2eh1S1WUjdRpEoYz8UWyyg6g08e4a2FLFksYXa4Wb0EJTuPHlpptPKgDTisGlRh ++IT57a2Id0MlgHXzRoYZQaw/KlkgpcR6V2MeeFlQNu0PgIc+HzkAvG13KoK2BoQIPM9k0lMT7cyhy ++UeTzCFVtYbrZbIYPjDa7hx/R4jSiyMMTxD0kot3vhGy1F7j3KjSJtqLPZNPWMhffc48/BbpjjBgq ++qzoPFPRC32JJLdKhMYp6nrWSSo8dNjLQwvj+nIK8twHP4RW0DmO81T4MxdHuuTcyyGPYYYeh7BCC ++HTa1R+eHuq9eX7wDelNTK18PrZS6qtDhkPEXPd8vdnZS4vzBFsSOOrykh48djea4I6qiQ3AIJCDe ++abPf2WRsezM9iTiN/vahZYwxxhhjjDHGGGOMMcYYY4wxxhhjd74B89xuNgAoAAA= +diff --git 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-000857/tests/test.sh b/tasks/format-code-task-000857/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..48a6b29abf12b6da64d7abc8b407c008469a5c0c --- /dev/null +++ b/tasks/format-code-task-000857/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/apis/eksctl.io/v1alpha5/validation_test.go +pkg/cfn/builder/api_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000857/tests/test_command.sh b/tasks/format-code-task-000857/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000857/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000859/environment/Dockerfile b/tasks/format-code-task-000859/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5ec70570a63dd4daf8464500e4e75ad275f0ebc7 --- /dev/null +++ b/tasks/format-code-task-000859/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9236bec86ab78db742124e7f9c88ce2a9c9a5bed8224020f78dcdbfc1af87b27 diff --git a/tasks/format-code-task-000859/environment/setup/files/blocklist b/tasks/format-code-task-000859/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000859/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000859/environment/setup/setup.sh b/tasks/format-code-task-000859/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000859/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000859/tests/test.patch b/tasks/format-code-task-000859/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bff890756197982d658b737815e5b9c983b26bc9 --- /dev/null +++ b/tasks/format-code-task-000859/tests/test.patch @@ -0,0 +1,187 @@ +diff --git a/pkg/nodebootstrap/managed_al2_prebootstrap_test.go b/pkg/nodebootstrap/managed_al2_prebootstrap_test.go +new file mode 100644 +index 000000000..a6dd698e3 +--- /dev/null ++++ b/pkg/nodebootstrap/managed_al2_prebootstrap_test.go +@@ -0,0 +1,159 @@ ++package nodebootstrap_test ++ ++import ( ++ "encoding/base64" ++ "strings" ++ "testing" ++ ++ "github.com/aws/aws-sdk-go/aws" ++ api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5" ++ ++ "github.com/weaveworks/eksctl/pkg/nodebootstrap" ++) ++ ++func runManagedUserData(t *testing.T, ng *api.ManagedNodeGroup) string { ++ t.Helper() ++ api.SetManagedNodeGroupDefaults(ng, &api.ClusterMeta{Name: "cluster"}) ++ bs := nodebootstrap.NewManagedAL2Bootstrapper(ng) ++ bs.UserDataMimeBoundary = "//" ++ ud, err := bs.UserData() ++ if err != nil { ++ t.Fatalf("UserData returned err: %v", err) ++ } ++ if ud == "" { ++ return "" ++ } ++ dec, err := base64.StdEncoding.DecodeString(ud) ++ if err != nil { ++ t.Fatalf("base64 decode err: %v", err) ++ } ++ return strings.ReplaceAll(string(dec), "\r\n", "\n") ++} ++ ++ ++ ++ ++ ++ ++func TestManagedCustomAMIPreBootstrapOnly(t *testing.T) { ++ ng := &api.ManagedNodeGroup{ ++ NodeGroupBase: &api.NodeGroupBase{ ++ Name: "custom-ami-pre", ++ InstanceType: "m5.xlarge", ++ AMI: "ami-custom", ++ PreBootstrapCommands: []string{"echo pre-one-PRECMDA", "echo pre-two-PRECMDB"}, ++ }, ++ } ++ actual := runManagedUserData(t, ng) ++ ++ if !strings.Contains(actual, "echo pre-one-PRECMDA") { ++ t.Fatalf("expected user data to contain first pre-bootstrap command, got:\n%s", actual) ++ } ++ if !strings.Contains(actual, "echo pre-two-PRECMDB") { ++ t.Fatalf("expected user data to contain second pre-bootstrap command, got:\n%s", actual) ++ } ++ idxA := strings.Index(actual, "echo pre-one-PRECMDA") ++ idxB := strings.Index(actual, "echo pre-two-PRECMDB") ++ if idxA >= idxB { ++ t.Fatalf("expected pre-one before pre-two, got indices %d, %d in:\n%s", idxA, idxB, actual) ++ } ++} ++ ++ ++ ++func TestManagedCustomAMIPreBootstrapAndOverride(t *testing.T) { ++ ng := &api.ManagedNodeGroup{ ++ NodeGroupBase: &api.NodeGroupBase{ ++ Name: "custom-ami-both", ++ InstanceType: "m5.xlarge", ++ AMI: "ami-custom", ++ PreBootstrapCommands: []string{"echo pre-one-PRECMDX"}, ++ OverrideBootstrapCommand: aws.String("echo override-OVRCMDY"), ++ }, ++ } ++ actual := runManagedUserData(t, ng) ++ ++ if !strings.Contains(actual, "echo pre-one-PRECMDX") { ++ t.Fatalf("expected user data to contain pre-bootstrap command, got:\n%s", actual) ++ } ++ if !strings.Contains(actual, "echo override-OVRCMDY") { ++ t.Fatalf("expected user data to contain override command, got:\n%s", actual) ++ } ++ idxPre := strings.Index(actual, "echo pre-one-PRECMDX") ++ idxOver := strings.Index(actual, "echo override-OVRCMDY") ++ if idxPre >= idxOver { ++ t.Fatalf("expected pre-bootstrap before override, got indices %d, %d in:\n%s", ++ idxPre, idxOver, actual) ++ } ++} ++ ++ ++ ++func TestManagedCustomAMIOverrideOnlyUsesMIME(t *testing.T) { ++ ng := &api.ManagedNodeGroup{ ++ NodeGroupBase: &api.NodeGroupBase{ ++ Name: "custom-ami-override", ++ InstanceType: "m5.xlarge", ++ AMI: "ami-custom", ++ OverrideBootstrapCommand: aws.String("echo override-ONLYCMD"), ++ }, ++ } ++ actual := runManagedUserData(t, ng) ++ ++ if !strings.Contains(actual, "echo override-ONLYCMD") { ++ t.Fatalf("expected user data to contain override command, got:\n%s", actual) ++ } ++} ++ ++ ++ ++func TestManagedCustomAMINoCommandsEmpty(t *testing.T) { ++ ng := &api.ManagedNodeGroup{ ++ NodeGroupBase: &api.NodeGroupBase{ ++ Name: "custom-ami-empty", ++ InstanceType: "m5.xlarge", ++ AMI: "ami-custom", ++ }, ++ } ++ api.SetManagedNodeGroupDefaults(ng, &api.ClusterMeta{Name: "cluster"}) ++ bs := nodebootstrap.NewManagedAL2Bootstrapper(ng) ++ bs.UserDataMimeBoundary = "//" ++ ud, err := bs.UserData() ++ if err != nil { ++ t.Fatalf("UserData err: %v", err) ++ } ++ if ud != "" { ++ t.Fatalf("expected empty user data, got %q", ud) ++ } ++} ++ ++ ++ ++ ++ ++func TestManagedCustomAMIPreAndOverrideContainBoth(t *testing.T) { ++ ng := &api.ManagedNodeGroup{ ++ NodeGroupBase: &api.NodeGroupBase{ ++ Name: "custom-ami-both2", ++ InstanceType: "m5.xlarge", ++ AMI: "ami-1234", ++ PreBootstrapCommands: []string{"PRECOMMAND_ALPHA", "PRECOMMAND_BETA"}, ++ OverrideBootstrapCommand: aws.String("OVERRIDE_GAMMA"), ++ }, ++ } ++ actual := runManagedUserData(t, ng) ++ ++ for _, needle := range []string{"PRECOMMAND_ALPHA", "PRECOMMAND_BETA", "OVERRIDE_GAMMA"} { ++ if !strings.Contains(actual, needle) { ++ t.Fatalf("expected user data to contain %q, got:\n%s", needle, actual) ++ } ++ } ++ ++ idxPreA := strings.Index(actual, "PRECOMMAND_ALPHA") ++ idxPreB := strings.Index(actual, "PRECOMMAND_BETA") ++ idxOver := strings.Index(actual, "OVERRIDE_GAMMA") ++ if !(idxPreA < idxPreB && idxPreB < idxOver) { ++ t.Fatalf("expected ordering pre-alpha < pre-beta < override, got %d, %d, %d in:\n%s", ++ idxPreA, idxPreB, idxOver, actual) ++ } ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..ea11ca8c2 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/nodebootstrap/ -run TestManagedCustomAMI -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/nodebootstrap/ -run TestManagedCustomAMI -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000859/tests/test.sh b/tasks/format-code-task-000859/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2129b9c2d848983bd2eaaae7d15199b65a2cb7c9 --- /dev/null +++ b/tasks/format-code-task-000859/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/nodebootstrap/managed_al2_prebootstrap_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-000859/tests/test_command.sh b/tasks/format-code-task-000859/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000859/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000861/environment/Dockerfile b/tasks/format-code-task-000861/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b2b2a35736045c595689b257f295900fa1ef8126 --- /dev/null +++ b/tasks/format-code-task-000861/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:820715e5afdaf0286ca9fc3e0279d820094adf660a309b273cd8db1cdced6942 diff --git a/tasks/format-code-task-000861/environment/setup/files/blocklist b/tasks/format-code-task-000861/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000861/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000861/environment/setup/setup.sh b/tasks/format-code-task-000861/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000861/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000861/tests/test.patch b/tasks/format-code-task-000861/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..530c19ba91530237435cc4a5fd2e9cf94a842cd6 --- /dev/null +++ b/tasks/format-code-task-000861/tests/test.patch @@ -0,0 +1,230 @@ +diff --git a/metricbeat/module/uwsgi/status/status_integration_test.go b/metricbeat/module/uwsgi/status/status_integration_test.go +index 5ac48b5e4a2d..18673776b1e1 100644 +--- a/metricbeat/module/uwsgi/status/status_integration_test.go ++++ b/metricbeat/module/uwsgi/status/status_integration_test.go +@@ -32,23 +32,37 @@ import ( + func TestFetchTCP(t *testing.T) { + compose.EnsureUp(t, "uwsgi_tcp") + +- f := mbtest.NewEventsFetcher(t, getConfig("tcp")) +- events, err := f.Fetch() +- assert.NoError(t, err) ++ f := mbtest.NewReportingMetricSetV2Error(t, getConfig("tcp")) ++ events, errs := mbtest.ReportingFetchV2Error(f) ++ if len(errs) > 0 { ++ t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs) ++ } ++ assert.NotEmpty(t, events) + +- assert.True(t, len(events) > 0) ++ t.Log(events) + totals := findItems(events, "total") + assert.Equal(t, 1, len(totals)) + } + ++func TestData(t *testing.T) { ++ f := mbtest.NewReportingMetricSetV2Error(t, getConfig("http")) ++ ++ if err := mbtest.WriteEventsReporterV2Error(f, t, ""); err != nil { ++ t.Fatal("write", err) ++ } ++} ++ + func TestFetchHTTP(t *testing.T) { + compose.EnsureUp(t, "uwsgi_http") + +- f := mbtest.NewEventsFetcher(t, getConfig("http")) +- events, err := f.Fetch() +- assert.NoError(t, err) ++ f := mbtest.NewReportingMetricSetV2Error(t, getConfig("http")) ++ events, errs := mbtest.ReportingFetchV2Error(f) ++ if len(errs) > 0 { ++ t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs) ++ } ++ assert.NotEmpty(t, events) + +- assert.True(t, len(events) > 0) ++ t.Log(events) + totals := findItems(events, "total") + assert.Equal(t, 1, len(totals)) + } +diff --git a/metricbeat/module/uwsgi/status/status_linux_test.go b/metricbeat/module/uwsgi/status/status_linux_test.go +index 824f948fbead..68934f4d6f3a 100644 +--- a/metricbeat/module/uwsgi/status/status_linux_test.go ++++ b/metricbeat/module/uwsgi/status/status_linux_test.go +@@ -57,9 +57,11 @@ func TestFetchDataUnixSock(t *testing.T) { + "hosts": []string{"unix://" + listener.Addr().String()}, + } + +- f := mbtest.NewEventsFetcher(t, config) +- events, err := f.Fetch() +- assert.NoError(t, err) ++ f := mbtest.NewReportingMetricSetV2Error(t, config) ++ events, errs := mbtest.ReportingFetchV2Error(f) ++ if len(errs) > 0 { ++ t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs) ++ } + + assertTestData(t, events) + wg.Wait() +diff --git a/metricbeat/module/uwsgi/status/status_test.go b/metricbeat/module/uwsgi/status/status_test.go +index 1e3827d534d7..9bb4b55dfb4d 100644 +--- a/metricbeat/module/uwsgi/status/status_test.go ++++ b/metricbeat/module/uwsgi/status/status_test.go +@@ -29,6 +29,7 @@ import ( + "github.com/stretchr/testify/assert" + + "github.com/elastic/beats/libbeat/common" ++ "github.com/elastic/beats/metricbeat/mb" + mbtest "github.com/elastic/beats/metricbeat/mb/testing" + ) + +@@ -47,10 +48,10 @@ func testData(t *testing.T) (data []byte) { + return + } + +-func findItems(mp []common.MapStr, key string) []common.MapStr { ++func findItems(mp []mb.Event, key string) []common.MapStr { + result := make([]common.MapStr, 0, 1) + for _, v := range mp { +- if el, ok := v[key]; ok { ++ if el, ok := v.MetricSetFields[key]; ok { + result = append(result, el.(common.MapStr)) + } + } +@@ -58,15 +59,15 @@ func findItems(mp []common.MapStr, key string) []common.MapStr { + return result + } + +-func assertTestData(t *testing.T, mp []common.MapStr) { +- totals := findItems(mp, "total") ++func assertTestData(t *testing.T, evt []mb.Event) { ++ totals := findItems(evt, "total") + assert.Equal(t, 1, len(totals)) + assert.Equal(t, 2042, totals[0]["requests"]) + assert.Equal(t, 0, totals[0]["exceptions"]) + assert.Equal(t, 34, totals[0]["write_errors"]) + assert.Equal(t, 38, totals[0]["read_errors"]) + +- workers := findItems(mp, "core") ++ workers := findItems(evt, "core") + assert.Equal(t, 4, len(workers)) + } + +@@ -93,9 +94,11 @@ func TestFetchDataTCP(t *testing.T) { + "hosts": []string{"tcp://" + listener.Addr().String()}, + } + +- f := mbtest.NewEventsFetcher(t, config) +- events, err := f.Fetch() +- assert.NoError(t, err) ++ f := mbtest.NewReportingMetricSetV2Error(t, config) ++ events, errs := mbtest.ReportingFetchV2Error(f) ++ if len(errs) > 0 { ++ t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs) ++ } + + assertTestData(t, events) + wg.Wait() +@@ -117,9 +120,11 @@ func TestFetchDataHTTP(t *testing.T) { + "hosts": []string{server.URL}, + } + +- f := mbtest.NewEventsFetcher(t, config) +- events, err := f.Fetch() +- assert.NoError(t, err) ++ f := mbtest.NewReportingMetricSetV2Error(t, config) ++ events, errs := mbtest.ReportingFetchV2Error(f) ++ if len(errs) > 0 { ++ t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs) ++ } + + assertTestData(t, events) + } +@@ -138,9 +143,9 @@ func TestFetchDataUnmarshalledError(t *testing.T) { + "hosts": []string{server.URL}, + } + +- f := mbtest.NewEventsFetcher(t, config) +- _, err := f.Fetch() +- assert.Error(t, err) ++ f := mbtest.NewReportingMetricSetV2Error(t, config) ++ _, errs := mbtest.ReportingFetchV2Error(f) ++ assert.NotEmpty(t, errs) + } + + func TestFetchDataSourceDown(t *testing.T) { +@@ -155,9 +160,9 @@ func TestFetchDataSourceDown(t *testing.T) { + "hosts": []string{server.URL}, + } + +- f := mbtest.NewEventsFetcher(t, config) +- _, err := f.Fetch() +- assert.Error(t, err) ++ f := mbtest.NewReportingMetricSetV2Error(t, config) ++ _, errs := mbtest.ReportingFetchV2Error(f) ++ assert.NotEmpty(t, errs) + } + + func TestConfigError(t *testing.T) { +@@ -167,9 +172,9 @@ func TestConfigError(t *testing.T) { + "hosts": []string{"unix://127.0.0.1:8080"}, + } + +- f := mbtest.NewEventsFetcher(t, config) +- _, err := f.Fetch() +- assert.Error(t, err) ++ f := mbtest.NewReportingMetricSetV2Error(t, config) ++ _, errs := mbtest.ReportingFetchV2Error(f) ++ assert.NotEmpty(t, errs) + + config = map[string]interface{}{ + "module": "uwsgi", +@@ -177,9 +182,9 @@ func TestConfigError(t *testing.T) { + "hosts": []string{"unknown_url_format"}, + } + +- f = mbtest.NewEventsFetcher(t, config) +- _, err = f.Fetch() +- assert.Error(t, err) ++ f = mbtest.NewReportingMetricSetV2Error(t, config) ++ _, errs = mbtest.ReportingFetchV2Error(f) ++ assert.NotEmpty(t, errs) + + config = map[string]interface{}{ + "module": "uwsgi", +@@ -187,7 +192,7 @@ func TestConfigError(t *testing.T) { + "hosts": []string{"ftp://127.0.0.1:8080"}, + } + +- f = mbtest.NewEventsFetcher(t, config) +- _, err = f.Fetch() +- assert.Error(t, err) ++ f = mbtest.NewReportingMetricSetV2Error(t, config) ++ _, errs = mbtest.ReportingFetchV2Error(f) ++ assert.NotEmpty(t, errs) + } +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+3TTU/cMBAG4JzzKwZxaYUSr7NkOSAOlai2h1Zb9eOMnMSbWJvYW3u8hX/fbKgo ++qgTLAVShvs/F+ZhkJp5JXkXTN1fa7kTyUmajs7Kc1tHf63Qsy0IWs3kxL+fJTMryrEyofLGK7omB ++lSdKvHP8WNyh+69U/qf/rANf1W4YlG3y0D1fjkP9X8j5Xf+LxenY/9OFLBKaPV8JD/vP+398JCpj ++RaVCl9YNTUNQ6SZNj+mrZopbWq4+v/v2gcLN0Bu7oeBo6ahWlrwOrt9pMsPWeaat4i6kw6YxnrIt ++if2GidaJ4GvRGu5ilY/DJXSvAps67S1lYX2X8FC8qLTisC/rS7TEnab4M7RGjN3jGGj/lkBvojVM ++JzQWGq9vr52Tsaxbr9g4+zvM6x/ReE2Xrt5oT+O4kxpPpz8hY9VSq1g3b6f9eFJVy5WU8tPq8vvH ++9xduvabWTZko21FWu2j5QlIuBs3e1PsnxOCa2Gtx/xNE+q9HAQAAAAAAAAAAAAAAAAAAAABeoV// ++/ekbACgAAA== +diff --git 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-000861/tests/test.sh b/tasks/format-code-task-000861/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c035a11efc438d45406acf8d9269587d24a38851 --- /dev/null +++ b/tasks/format-code-task-000861/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' +metricbeat/module/uwsgi/status/status_integration_test.go +metricbeat/module/uwsgi/status/status_linux_test.go +metricbeat/module/uwsgi/status/status_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-000861/tests/test_command.sh b/tasks/format-code-task-000861/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000861/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001111/environment/Dockerfile b/tasks/format-code-task-001111/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d37886f103a526835da10b4a97e731a612ebb860 --- /dev/null +++ b/tasks/format-code-task-001111/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6470149d2ea2dc5968b791c405f3587553b1c8a7f373901979d8a9a476dfec02 diff --git a/tasks/format-code-task-001111/environment/setup/files/blocklist b/tasks/format-code-task-001111/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001111/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001111/environment/setup/setup.sh b/tasks/format-code-task-001111/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001111/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001111/tests/test.patch b/tasks/format-code-task-001111/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f0bbd1f75e0f75361beefa1d5953893189467ecf --- /dev/null +++ b/tasks/format-code-task-001111/tests/test.patch @@ -0,0 +1,274 @@ +diff --git a/shared-libs/outbound/test/outbound-delivery-policy-codespec.spec.js b/shared-libs/outbound/test/outbound-delivery-policy-codespec.spec.js +new file mode 100644 +index 000000000..6f85360ed +--- /dev/null ++++ b/shared-libs/outbound/test/outbound-delivery-policy-codespec.spec.js +@@ -0,0 +1,257 @@ ++const { assert } = require('chai'); ++const rewire = require('rewire'); ++const sinon = require('sinon'); ++ ++const request = require('request-promise-native'); ++const requestErrors = require('request-promise-native/errors'); ++const secureSettings = require('@medic/settings'); ++const outboundModule = rewire('../src/outbound'); ++ ++const logger = { ++ debug: sinon.stub(), ++ error: sinon.stub(), ++ info: sinon.stub(), ++ isDebugEnabled: () => false, ++}; ++ ++const destination = overrides => Object.assign({ ++ base_url: 'https://receiver.example', ++ path: '/events', ++}, overrides); ++ ++const config = destinationOverrides => ({ ++ mapping: { ++ report_id: 'doc._id', ++ value: 'doc.value', ++ }, ++ destination: destination(destinationOverrides), ++}); ++ ++const record = () => ({ _id: 'report-1', value: 42 }); ++const info = () => ({ _id: 'report-1-info', completed_tasks: [] }); ++ ++const statusError = statusCode => { ++ const response = { statusCode, body: 'failed' }; ++ return new requestErrors.StatusCodeError(statusCode, 'failed', {}, response); ++}; ++ ++const networkError = () => new requestErrors.RequestError(new Error('connection reset'), {}, undefined); ++ ++describe('outbound delivery policy CodeSpec contract', () => { ++ let service; ++ ++ beforeEach(() => { ++ service = outboundModule(logger); ++ logger.debug.resetHistory(); ++ logger.error.resetHistory(); ++ logger.info.resetHistory(); ++ }); ++ ++ afterEach(() => sinon.restore()); ++ ++ it('retries configured transient statuses and records one completion after success', async () => { ++ const first = statusError(503); ++ const second = statusError(429); ++ const post = sinon.stub(request, 'post'); ++ post.onCall(0).rejects(first); ++ post.onCall(1).rejects(second); ++ post.onCall(2).resolves({ accepted: true }); ++ const recordInfo = info(); ++ const outboundConfig = config({ ++ retry: { max_attempts: 3, status_codes: [429, 503] }, ++ }); ++ ++ const sent = await service.send(outboundConfig, 'district-feed', record(), recordInfo); ++ ++ assert.strictEqual(sent, true); ++ assert.strictEqual(post.callCount, 3); ++ assert.lengthOf(recordInfo.completed_tasks, 1); ++ assert.strictEqual(recordInfo.completed_tasks[0].name, 'district-feed'); ++ assert.match(recordInfo.completed_tasks[0].hash, /^[a-f0-9]{64}$/); ++ post.args.forEach(args => assert.deepEqual(args[0].body, { report_id: 'report-1', value: 42 })); ++ }); ++ ++ it('does not retry an HTTP status outside the configured allowlist', async () => { ++ const failure = statusError(400); ++ const post = sinon.stub(request, 'post').rejects(failure); ++ const recordInfo = info(); ++ ++ const thrown = await service.send(config({ ++ retry: { max_attempts: 4, status_codes: [429, 503] }, ++ }), 'district-feed', record(), recordInfo).catch(error => error); ++ ++ assert.strictEqual(thrown, failure); ++ assert.strictEqual(post.callCount, 1); ++ assert.deepEqual(recordInfo.completed_tasks, []); ++ }); ++ ++ it('stops at max_attempts and leaves the infodoc unchanged', async () => { ++ const failure = statusError(503); ++ const post = sinon.stub(request, 'post').rejects(failure); ++ const recordInfo = info(); ++ ++ const thrown = await service.send(config({ ++ retry: { max_attempts: 3, status_codes: [503] }, ++ }), 'district-feed', record(), recordInfo).catch(error => error); ++ ++ assert.strictEqual(thrown, failure); ++ assert.strictEqual(post.callCount, 3); ++ assert.deepEqual(recordInfo.completed_tasks, []); ++ }); ++ ++ it('retries network failures by default when retries are enabled', async () => { ++ const failure = networkError(); ++ const post = sinon.stub(request, 'post'); ++ post.onFirstCall().rejects(failure); ++ post.onSecondCall().resolves(); ++ ++ const sent = await service.send(config({ ++ retry: { max_attempts: 2 }, ++ }), 'district-feed', record(), info()); ++ ++ assert.strictEqual(sent, true); ++ assert.strictEqual(post.callCount, 2); ++ }); ++ ++ it('honors retry_on_network_error false', async () => { ++ const failure = networkError(); ++ const post = sinon.stub(request, 'post').rejects(failure); ++ ++ const thrown = await service.send(config({ ++ retry: { max_attempts: 3, retry_on_network_error: false }, ++ }), 'district-feed', record(), info()).catch(error => error); ++ ++ assert.strictEqual(thrown, failure); ++ assert.strictEqual(post.callCount, 1); ++ }); ++ ++ it('merges static, credential, and stable idempotency headers on every attempt', async () => { ++ sinon.stub(secureSettings, 'getCredentials').withArgs('api-token').resolves('Bearer secret'); ++ const post = sinon.stub(request, 'post'); ++ post.onFirstCall().rejects(statusError(503)); ++ post.onSecondCall().resolves(); ++ const recordInfo = info(); ++ const outboundConfig = config({ ++ headers: { ++ 'X-Project': 'alpha', ++ Authorization: 'stale credential', ++ 'Idempotency-Key': 'caller supplied', ++ }, ++ idempotency_key_header: 'Idempotency-Key', ++ auth: { type: 'Header', name: 'Authorization', value_key: 'api-token' }, ++ retry: { max_attempts: 2, status_codes: [503] }, ++ }); ++ ++ await service.send(outboundConfig, 'district-feed', record(), recordInfo); ++ ++ assert.strictEqual(secureSettings.getCredentials.callCount, 1); ++ assert.strictEqual(post.callCount, 2); ++ const firstHeaders = post.firstCall.args[0].headers; ++ const secondHeaders = post.secondCall.args[0].headers; ++ assert.deepEqual(firstHeaders, secondHeaders); ++ assert.include(firstHeaders, { ++ 'X-Project': 'alpha', ++ Authorization: 'Bearer secret', ++ }); ++ assert.match(firstHeaders['Idempotency-Key'], /^[a-f0-9]{64}$/); ++ assert.strictEqual(firstHeaders['Idempotency-Key'], recordInfo.completed_tasks[0].hash); ++ }); ++ ++ it('derives the same idempotency key for equivalent payload object order', async () => { ++ const post = sinon.stub(request, 'post').resolves(); ++ const firstConfig = { ++ mapping: { alpha: 'doc.alpha', beta: 'doc.beta' }, ++ destination: destination({ idempotency_key_header: 'X-Delivery-Key' }), ++ }; ++ const secondConfig = { ++ mapping: { beta: 'doc.beta', alpha: 'doc.alpha' }, ++ destination: destination({ idempotency_key_header: 'X-Delivery-Key' }), ++ }; ++ const source = { _id: 'report-1', alpha: 1, beta: 2 }; ++ ++ await service.send(firstConfig, 'first', source, info()); ++ await service.send(secondConfig, 'second', source, info()); ++ ++ assert.strictEqual( ++ post.firstCall.args[0].headers['X-Delivery-Key'], ++ post.secondCall.args[0].headers['X-Delivery-Key'] ++ ); ++ }); ++ ++ it('rejects invalid retry policies before credentials or delivery are attempted', async () => { ++ const post = sinon.stub(request, 'post'); ++ sinon.stub(secureSettings, 'getCredentials'); ++ const invalidPolicies = [ ++ {}, ++ { max_attempts: 0 }, ++ { max_attempts: 2.5 }, ++ { max_attempts: '3' }, ++ { max_attempts: 2, status_codes: [399] }, ++ { max_attempts: 2, status_codes: [600] }, ++ { max_attempts: 2, status_codes: [503, '429'] }, ++ { max_attempts: 2, retry_on_network_error: 'yes' }, ++ ]; ++ ++ for (const retry of invalidPolicies) { ++ const recordInfo = info(); ++ const thrown = await service.send(config({ ++ auth: { type: 'Header', name: 'Authorization', value_key: 'api-token' }, ++ retry, ++ }), 'district-feed', record(), recordInfo).catch(error => error); ++ ++ assert.instanceOf(thrown, Error); ++ assert.match(thrown.message, /retry/i); ++ assert.deepEqual(recordInfo.completed_tasks, []); ++ } ++ ++ assert.strictEqual(post.callCount, 0); ++ assert.strictEqual(secureSettings.getCredentials.callCount, 0); ++ }); ++ ++ it('preserves one-shot behavior when no retry policy is configured', async () => { ++ const failure = statusError(503); ++ const post = sinon.stub(request, 'post').rejects(failure); ++ ++ const thrown = await service.send(config(), 'district-feed', record(), info()).catch(error => error); ++ ++ assert.strictEqual(thrown, failure); ++ assert.strictEqual(post.callCount, 1); ++ }); ++ ++ it('skips a duplicate before credentials or delivery and preserves the infodoc', async () => { ++ const post = sinon.stub(request, 'post').resolves(); ++ sinon.stub(secureSettings, 'getCredentials'); ++ const recordInfo = info(); ++ const initialConfig = config({ idempotency_key_header: 'Idempotency-Key' }); ++ await service.send(initialConfig, 'district-feed', record(), recordInfo); ++ const completedSnapshot = JSON.parse(JSON.stringify(recordInfo.completed_tasks)); ++ post.resetHistory(); ++ ++ initialConfig.destination.auth = { ++ type: 'Header', name: 'Authorization', value_key: 'api-token' ++ }; ++ const sent = await service.send(initialConfig, 'district-feed', record(), recordInfo); ++ ++ assert.strictEqual(sent, false); ++ assert.strictEqual(post.callCount, 0); ++ assert.strictEqual(secureSettings.getCredentials.callCount, 0); ++ assert.deepEqual(recordInfo.completed_tasks, completedSnapshot); ++ }); ++ ++ it('does not retry mapping failures', async () => { ++ const post = sinon.stub(request, 'post'); ++ const recordInfo = info(); ++ const outboundConfig = config({ ++ retry: { max_attempts: 3, status_codes: [503] }, ++ }); ++ outboundConfig.mapping.required_value = 'doc.missing'; ++ ++ const thrown = await service.send( ++ outboundConfig, 'district-feed', record(), recordInfo ++ ).catch(error => error); ++ ++ assert.match(thrown.message, /Mapping error/); ++ assert.strictEqual(post.callCount, 0); ++ assert.deepEqual(recordInfo.completed_tasks, []); ++ }); ++}); +diff --git 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 ++ ++ ++cd shared-libs/outbound ++npm test -- --reporter dot diff --git a/tasks/format-code-task-001111/tests/test.sh b/tasks/format-code-task-001111/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2dd8a678036bfda6613fd248e9fbad4b2e390186 --- /dev/null +++ b/tasks/format-code-task-001111/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' +shared-libs/outbound/test/outbound-delivery-policy-codespec.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-001111/tests/test_command.sh b/tasks/format-code-task-001111/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001111/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001116/environment/Dockerfile b/tasks/format-code-task-001116/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..93421ac5fac92caac9d5f8609795ee244717176e --- /dev/null +++ b/tasks/format-code-task-001116/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7d770ef2cbfa79044c63d8dabf8ddb91c9de6da78f7729dfe203cbdbd0a39a40 diff --git a/tasks/format-code-task-001116/environment/setup/files/blocklist b/tasks/format-code-task-001116/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001116/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001116/environment/setup/setup.sh b/tasks/format-code-task-001116/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001116/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001116/tests/test.patch b/tasks/format-code-task-001116/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9add0555dd9c9e65a0d82c22bb28b7ac7e3f4788 --- /dev/null +++ b/tasks/format-code-task-001116/tests/test.patch @@ -0,0 +1,124 @@ +diff --git a/test/ecto/multi_read_test.exs b/test/ecto/multi_read_test.exs +new file mode 100644 +index 00000000..71af4048 +--- /dev/null ++++ b/test/ecto/multi_read_test.exs +@@ -0,0 +1,108 @@ ++defmodule Ecto.MultiReadTest do ++ use ExUnit.Case, async: false ++ ++ import Ecto.Query ++ ++ alias Ecto.Multi ++ alias Ecto.TestRepo ++ ++ defp query(source) do ++ from row in source, select: row.id ++ end ++ ++ defp call_multi(fun, args) do ++ assert function_exported?(Multi, fun, length(args)), ++ "expected Ecto.Multi.#{fun}/#{length(args)} to be part of the public API" ++ ++ apply(Multi, fun, args) ++ end ++ ++ setup do ++ Process.delete(:test_repo_all_results) ++ :ok ++ end ++ ++ test "exposes read operations in the canonical operation list" do ++ rows = query("multi_read_rows") ++ multi = call_multi(:all, [Multi.new(), :rows, rows, [prefix: "tenant"]]) ++ multi = call_multi(:one, [multi, :row, rows, [timeout: 321]]) ++ multi = call_multi(:exists?, [multi, :present, rows, []]) ++ ++ assert Multi.to_list(multi) == [ ++ {:rows, {:all, rows, [prefix: "tenant"]}}, ++ {:row, {:one, rows, [timeout: 321]}}, ++ {:present, {:exists?, rows, []}} ++ ] ++ end ++ ++ test "all returns every row and preserves query options" do ++ Process.put(:test_repo_all_results, {2, [[11], [22]]}) ++ rows = query("multi_read_all") ++ multi = call_multi(:all, [Multi.new(), :rows, rows, [prefix: "tenant"]]) ++ ++ assert {:ok, %{rows: [11, 22]}} = TestRepo.transaction(multi) ++ assert_received {:all, executed} ++ assert executed.prefix == "tenant" ++ end ++ ++ test "one returns nil for no rows, the value for one row, and rejects many rows" do ++ rows = query("multi_read_one") ++ ++ Process.put(:test_repo_all_results, {0, []}) ++ empty = call_multi(:one, [Multi.new(), :row, rows, [prefix: "tenant_one"]]) ++ assert {:ok, %{row: nil}} = TestRepo.transaction(empty) ++ assert_received {:all, %{prefix: "tenant_one"}} ++ ++ Process.put(:test_repo_all_results, {1, [[42]]}) ++ single = call_multi(:one, [Multi.new(), :row, rows, []]) ++ assert {:ok, %{row: 42}} = TestRepo.transaction(single) ++ ++ Process.put(:test_repo_all_results, {2, [[1], [2]]}) ++ many = call_multi(:one, [Multi.new(), :row, rows, []]) ++ assert_raise Ecto.MultipleResultsError, fn -> TestRepo.transaction(many) end ++ end ++ ++ test "exists? converts the read result into a boolean and limits the query" do ++ rows = query("multi_read_exists") ++ ++ Process.put(:test_repo_all_results, {1, [[1]]}) ++ present = call_multi(:exists?, [Multi.new(), :present, rows, [prefix: "tenant_exists"]]) ++ assert {:ok, %{present: true}} = TestRepo.transaction(present) ++ assert_received {:all, present_query} ++ assert present_query.prefix == "tenant_exists" ++ assert inspect(present_query) =~ "limit: 1" ++ assert inspect(present_query) =~ "select: 1" ++ ++ Process.put(:test_repo_all_results, {0, []}) ++ absent = call_multi(:exists?, [Multi.new(), :present, rows, []]) ++ assert {:ok, %{present: false}} = TestRepo.transaction(absent) ++ end ++ ++ test "read operation names remain unique" do ++ rows = query("multi_read_duplicate") ++ multi = call_multi(:all, [Multi.new(), :same, rows, []]) ++ ++ assert_raise RuntimeError, ~r/:same is already a member of the Ecto\.Multi/, fn -> ++ call_multi(:one, [multi, :same, rows, []]) ++ end ++ end ++ ++ test "read operations run in order, receive prior changes, and halt after an error" do ++ Process.put(:test_repo_all_results, {1, [[9]]}) ++ ++ multi = Multi.new() |> Multi.run(:before, fn _repo, _changes -> {:ok, :ready} end) ++ multi = call_multi(:all, [multi, :rows, query("multi_read_order"), []]) ++ multi = Multi.run(multi, :after, fn _repo, %{before: before, rows: rows} -> ++ {:ok, {before, rows}} ++ end) ++ ++ assert {:ok, %{after: {:ready, [9]}}} = TestRepo.transaction(multi) ++ assert_received {:all, %{from: %{source: {"multi_read_order", nil}}}} ++ ++ blocked = Multi.new() |> Multi.run(:stop, fn _repo, _changes -> {:error, :bad} end) ++ blocked = call_multi(:all, [blocked, :never, query("multi_read_blocked"), []]) ++ ++ assert {:error, :stop, :bad, %{}} = TestRepo.transaction(blocked) ++ refute_received {:all, %{from: %{source: {"multi_read_blocked", nil}}}} ++ 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,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++MIX_ENV=test mix test --no-deps-check test/ecto/multi_read_test.exs diff --git a/tasks/format-code-task-001116/tests/test.sh b/tasks/format-code-task-001116/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..02f5992ee067e52aeb84b8df746da074406e3e79 --- /dev/null +++ b/tasks/format-code-task-001116/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/ecto/multi_read_test.exs +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001116/tests/test_command.sh b/tasks/format-code-task-001116/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001116/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001118/environment/Dockerfile b/tasks/format-code-task-001118/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..49f46c86ea3d49aeee467eca22dfe898f84a222b --- /dev/null +++ b/tasks/format-code-task-001118/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:aec84c0a4505d8974b6705f1139baf452a2808e89348460fd00078fb9252d193 diff --git a/tasks/format-code-task-001118/environment/setup/files/blocklist b/tasks/format-code-task-001118/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001118/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001118/environment/setup/setup.sh b/tasks/format-code-task-001118/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001118/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001118/tests/test.patch b/tasks/format-code-task-001118/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4056b1d877896e03d96088a3f2b3d1d4c2deef47 --- /dev/null +++ b/tasks/format-code-task-001118/tests/test.patch @@ -0,0 +1,148 @@ +diff --git a/src/dynamic/dynamic.directive.contract.spec.ts b/src/dynamic/dynamic.directive.contract.spec.ts +new file mode 100644 +index 00000000..dbc62ebc +--- /dev/null ++++ b/src/dynamic/dynamic.directive.contract.spec.ts +@@ -0,0 +1,133 @@ ++import 'rxjs/add/operator/takeUntil'; ++ ++import { SimpleChanges } from '@angular/core'; ++import { async, ComponentFixture, TestBed } from '@angular/core/testing'; ++import { By } from '@angular/platform-browser'; ++ ++import { ++ ComponentInjectorComponent, ++ InjectedBoundComponent, ++ TestComponent, ++ TestModule, ++} from '../test/index'; ++import { COMPONENT_INJECTOR } from './component-injector'; ++import { DynamicDirective } from './dynamic.directive'; ++ ++describe('DynamicDirective configuration replacement contract', () => { ++ describe('inputs', () => { ++ let fixture: ComponentFixture; ++ let injectorComp: ComponentInjectorComponent; ++ let injectedComp: any; ++ ++ beforeEach(async(() => { ++ TestBed.configureTestingModule({ ++ declarations: [TestComponent, ComponentInjectorComponent, DynamicDirective], ++ providers: [{ provide: COMPONENT_INJECTOR, useValue: ComponentInjectorComponent }] ++ }); ++ ++ TestBed.overrideComponent(TestComponent, { ++ set: { template: '' } ++ }); ++ fixture = TestBed.createComponent(TestComponent); ++ injectorComp = fixture.debugElement.query(By.directive(ComponentInjectorComponent)).componentInstance; ++ injectedComp = injectorComp.component; ++ })); ++ ++ it('keeps falsy values and does not notify for an equivalent replacement object', () => { ++ fixture.componentInstance['inputs'] = { zero: 0, disabled: false, empty: '' }; ++ fixture.detectChanges(); ++ ++ expect(injectedComp.zero).toBe(0); ++ expect(injectedComp.disabled).toBe(false); ++ expect(injectedComp.empty).toBe(''); ++ expect(injectedComp.ngOnChanges).toHaveBeenCalledTimes(1); ++ ++ fixture.componentInstance['inputs'] = { zero: 0, disabled: false, empty: '' }; ++ expect(() => fixture.detectChanges()).not.toThrow(); ++ expect(injectedComp.ngOnChanges).toHaveBeenCalledTimes(1); ++ }); ++ ++ it('clears removed keys from the component instance', () => { ++ fixture.componentInstance['inputs'] = { retained: 'one', removed: 'old' }; ++ fixture.detectChanges(); ++ ++ fixture.componentInstance['inputs'] = { retained: 'two' }; ++ fixture.detectChanges(); ++ ++ expect(injectedComp.retained).toBe('two'); ++ expect(injectedComp.removed).toBeUndefined(); ++ }); ++ ++ it('reports previous and current values when an input is removed', () => { ++ fixture.componentInstance['inputs'] = { retained: 'one', removed: 'old' }; ++ fixture.detectChanges(); ++ injectedComp.ngOnChanges.calls.reset(); ++ ++ fixture.componentInstance['inputs'] = { retained: 'two' }; ++ fixture.detectChanges(); ++ ++ expect(injectedComp.ngOnChanges).toHaveBeenCalledTimes(1); ++ const changes: SimpleChanges = injectedComp.ngOnChanges.calls.mostRecent().args[0]; ++ expect(changes.retained.previousValue).toBe('one'); ++ expect(changes.retained.currentValue).toBe('two'); ++ expect(changes.removed.previousValue).toBe('old'); ++ expect(changes.removed.currentValue).toBeUndefined(); ++ expect(changes.removed.isFirstChange()).toBe(false); ++ }); ++ }); ++ ++ describe('outputs', () => { ++ let fixture: ComponentFixture; ++ let injectedComp: InjectedBoundComponent; ++ let firstHandler: jasmine.Spy; ++ let secondHandler: jasmine.Spy; ++ ++ beforeEach(async(() => { ++ TestBed.configureTestingModule({ ++ imports: [TestModule], ++ declarations: [DynamicDirective, TestComponent], ++ providers: [{ provide: COMPONENT_INJECTOR, useValue: ComponentInjectorComponent }], ++ }); ++ TestBed.overrideComponent(TestComponent, { ++ set: { ++ template: '' ++ } ++ }); ++ fixture = TestBed.createComponent(TestComponent); ++ fixture.componentInstance['comp'] = InjectedBoundComponent; ++ fixture.componentInstance['outputs'] = null; ++ fixture.detectChanges(); ++ injectedComp = fixture.debugElement.query(By.directive(InjectedBoundComponent)).componentInstance; ++ firstHandler = jasmine.createSpy('firstHandler'); ++ secondHandler = jasmine.createSpy('secondHandler'); ++ })); ++ ++ it('disconnects the old handler when the output map is replaced', () => { ++ fixture.componentInstance['outputs'] = { outerEvt: firstHandler }; ++ fixture.detectChanges(); ++ injectedComp.innerEvt.emit('first'); ++ ++ fixture.componentInstance['outputs'] = { outerEvt: secondHandler }; ++ fixture.detectChanges(); ++ injectedComp.innerEvt.emit('second'); ++ ++ expect(firstHandler).toHaveBeenCalledTimes(1); ++ expect(firstHandler).toHaveBeenCalledWith('first'); ++ expect(secondHandler).toHaveBeenCalledTimes(1); ++ expect(secondHandler).toHaveBeenCalledWith('second'); ++ }); ++ ++ it('disconnects handlers when outputs are cleared', () => { ++ fixture.componentInstance['outputs'] = { outerEvt: firstHandler }; ++ fixture.detectChanges(); ++ injectedComp.innerEvt.emit('before-clear'); ++ ++ fixture.componentInstance['outputs'] = null; ++ fixture.detectChanges(); ++ injectedComp.innerEvt.emit('after-clear'); ++ ++ expect(firstHandler).toHaveBeenCalledTimes(1); ++ expect(firstHandler).toHaveBeenCalledWith('before-clear'); ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++./node_modules/.bin/jest --runInBand src/dynamic/dynamic.directive.contract.spec.ts --coverage=false diff --git a/tasks/format-code-task-001118/tests/test.sh b/tasks/format-code-task-001118/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..11ea0606a1045da378be244556df8f7a53d891e1 --- /dev/null +++ b/tasks/format-code-task-001118/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/dynamic/dynamic.directive.contract.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-001118/tests/test_command.sh b/tasks/format-code-task-001118/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001118/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001120/environment/Dockerfile b/tasks/format-code-task-001120/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..078c2caa5e9e378b0a3ea913dd7cb18f040c59c7 --- /dev/null +++ b/tasks/format-code-task-001120/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f6a63b802422f536e1144aa57481a048f2875bb68be33a4bc0556c8e131bf73f diff --git a/tasks/format-code-task-001120/environment/setup/files/blocklist b/tasks/format-code-task-001120/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001120/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001120/environment/setup/setup.sh b/tasks/format-code-task-001120/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001120/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001120/tests/test.patch b/tasks/format-code-task-001120/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3c2cefc7d07742a12403206701b220d9b0796dae --- /dev/null +++ b/tasks/format-code-task-001120/tests/test.patch @@ -0,0 +1,212 @@ +diff --git a/@commitlint/travis-cli/src/travis-behavior.test.js b/@commitlint/travis-cli/src/travis-behavior.test.js +new file mode 100644 +index 00000000..918bfcbb +--- /dev/null ++++ b/@commitlint/travis-cli/src/travis-behavior.test.js +@@ -0,0 +1,196 @@ ++const fs = require('fs'); ++const os = require('os'); ++const path = require('path'); ++const execa = require('execa'); ++ ++const cli = require.resolve('../cli.js'); ++ ++function makeScript(body) { ++ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'commitlint-travis-')); ++ const file = path.join(dir, 'bin.js'); ++ fs.writeFileSync(file, `#!/usr/bin/env node\n${body}\n`); ++ fs.chmodSync(file, 0o755); ++ return {dir, file}; ++} ++ ++function setup(options = {}) { ++ const log = path.join( ++ fs.mkdtempSync(path.join(os.tmpdir(), 'commitlint-log-')), ++ 'calls.log' ++ ); ++ fs.writeFileSync(log, ''); ++ const git = makeScript(` ++const fs = require('fs'); ++const args = process.argv.slice(2); ++fs.appendFileSync(${JSON.stringify( ++ log ++ )}, JSON.stringify({tool: 'git', args}) + '\\n'); ++if (args[0] === 'status' && process.env.TEST_DIRTY === '1') process.stdout.write(' M tracked.txt\\n'); ++if (process.env.TEST_FAIL_GIT === args[0]) process.exit(23); ++`); ++ const commitlint = makeScript(` ++const fs = require('fs'); ++const args = process.argv.slice(2); ++fs.appendFileSync(${JSON.stringify( ++ log ++ )}, JSON.stringify({tool: 'commitlint', args}) + '\\n'); ++if (process.env.TEST_FAIL_COMMITLINT === '1') process.exit(19); ++`); ++ const env = { ++ CI: 'true', ++ TRAVIS: 'true', ++ TRAVIS_COMMIT: 'HEAD', ++ TRAVIS_COMMIT_RANGE: 'BASE...HEAD', ++ TRAVIS_EVENT_TYPE: options.event || 'push', ++ TRAVIS_REPO_SLUG: options.baseSlug || 'org/base-repo', ++ TRAVIS_PULL_REQUEST_SLUG: Object.prototype.hasOwnProperty.call( ++ options, ++ 'sourceSlug' ++ ) ++ ? options.sourceSlug ++ : 'contributor/source-repo', ++ TRAVIS_COMMITLINT_GIT_BIN: git.file, ++ TRAVIS_COMMITLINT_BIN: commitlint.file, ++ TEST_DIRTY: options.dirty ? '1' : '0', ++ TEST_FAIL_GIT: options.failGit || '', ++ TEST_FAIL_COMMITLINT: options.failCommitlint ? '1' : '0', ++ }; ++ return {env, log}; ++} ++ ++async function run(options = {}, args = []) { ++ const {env, log} = setup(options); ++ const result = await execa(process.execPath, [cli, ...args], { ++ env, ++ reject: false, ++ }); ++ const calls = fs ++ .readFileSync(log, 'utf8') ++ .trim() ++ .split('\n') ++ .filter(Boolean) ++ .map((line) => JSON.parse(line)); ++ return {result, calls}; ++} ++ ++function findCall(calls, tool, args) { ++ return calls.find( ++ (call) => ++ call.tool === tool && JSON.stringify(call.args) === JSON.stringify(args) ++ ); ++} ++ ++test('fetches the base remote on a clean non-PR build and does not add a source remote', async () => { ++ const {result, calls} = await run({baseSlug: 'company/push-repo'}); ++ expect(result.exitCode).toBe(0); ++ expect( ++ findCall(calls, 'git', [ ++ 'remote', ++ 'add', ++ 'base', ++ 'https://github.com/company/push-repo.git', ++ ]) ++ ).toBeTruthy(); ++ expect(findCall(calls, 'git', ['fetch', 'base', '--quiet'])).toBeTruthy(); ++ expect(calls.some((call) => call.args[2] === 'source')).toBe(false); ++ expect(calls.some((call) => call.args[0] === 'stash')).toBe(false); ++ expect( ++ findCall(calls, 'git', ['log', '-n', '1', '--pretty=format:%B', 'HEAD']) ++ ).toBeTruthy(); ++ expect(calls.find((call) => call.tool === 'commitlint').args).toEqual([]); ++}); ++ ++test('uses the base repository as the source when a pull request slug is empty', async () => { ++ const {result, calls} = await run({ ++ event: 'pull_request', ++ baseSlug: 'company/same-repo', ++ sourceSlug: '', ++ }); ++ ++ expect(result.exitCode).toBe(0); ++ expect( ++ findCall(calls, 'git', [ ++ 'remote', ++ 'add', ++ 'source', ++ 'https://github.com/company/same-repo.git', ++ ]) ++ ).toBeTruthy(); ++ expect(findCall(calls, 'git', ['fetch', 'source', '--quiet'])).toBeTruthy(); ++}); ++ ++test('fetches both remotes for pull requests before invoking commitlint with the range', async () => { ++ const {result, calls} = await run({event: 'pull_request', dirty: true}, [ ++ '--verbose', ++ ]); ++ ++ expect(result.exitCode).toBe(0); ++ expect( ++ findCall(calls, 'git', [ ++ 'remote', ++ 'add', ++ 'base', ++ 'https://github.com/org/base-repo.git', ++ ]) ++ ).toBeTruthy(); ++ expect(findCall(calls, 'git', ['fetch', 'base', '--quiet'])).toBeTruthy(); ++ expect( ++ findCall(calls, 'git', [ ++ 'remote', ++ 'add', ++ 'source', ++ 'https://github.com/contributor/source-repo.git', ++ ]) ++ ).toBeTruthy(); ++ expect(findCall(calls, 'git', ['fetch', 'source', '--quiet'])).toBeTruthy(); ++ ++ const lintIndex = calls.findIndex((call) => call.tool === 'commitlint'); ++ const fetchIndexes = calls ++ .map((call, index) => ++ call.tool === 'git' && call.args[0] === 'fetch' ? index : -1 ++ ) ++ .filter((index) => index >= 0); ++ expect(fetchIndexes).toHaveLength(2); ++ expect(lintIndex).toBeGreaterThan(Math.max(...fetchIndexes)); ++ expect(calls[1]).toEqual({ ++ tool: 'git', ++ args: ['stash', '-k', '-u', '--quiet'], ++ }); ++ const popIndex = calls.findIndex( ++ (call) => ++ call.tool === 'git' && call.args[0] === 'stash' && call.args[1] === 'pop' ++ ); ++ expect(popIndex).toBeGreaterThan(lintIndex); ++ ++ const lint = calls.find((call) => call.tool === 'commitlint'); ++ expect(lint.args).toEqual(['--from', 'BASE', '--to', 'HEAD', '--verbose']); ++}); ++ ++test('restores a dirty worktree when remote setup fails and keeps the failure status', async () => { ++ const {result, calls} = await run({dirty: true, failGit: 'fetch'}); ++ ++ expect(result.exitCode).not.toBe(0); ++ const stashIndex = calls.findIndex( ++ (call) => call.tool === 'git' && call.args[0] === 'stash' ++ ); ++ const popIndex = calls.findIndex( ++ (call) => ++ call.tool === 'git' && call.args[0] === 'stash' && call.args[1] === 'pop' ++ ); ++ expect(stashIndex).toBeGreaterThanOrEqual(0); ++ expect(popIndex).toBeGreaterThan(stashIndex); ++ expect(calls.some((call) => call.tool === 'commitlint')).toBe(false); ++}); ++ ++test('restores a dirty worktree before reporting a lint failure', async () => { ++ const {result, calls} = await run({dirty: true, failCommitlint: true}); ++ ++ expect(result.exitCode).not.toBe(0); ++ const popIndex = calls.findIndex( ++ (call) => ++ call.tool === 'git' && call.args[0] === 'stash' && call.args[1] === 'pop' ++ ); ++ const lintIndex = calls.findIndex((call) => call.tool === 'commitlint'); ++ expect(popIndex).toBeGreaterThanOrEqual(0); ++ expect(popIndex).toBeGreaterThan(lintIndex); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++./node_modules/.bin/tsc -b ./@commitlint/travis-cli/tsconfig.json --pretty false ++./node_modules/.bin/jest @commitlint/travis-cli/src/travis-behavior.test.js --runInBand diff --git a/tasks/format-code-task-001120/tests/test.sh b/tasks/format-code-task-001120/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..61dceeb1fa512148b58c413fe5b63c9b2d441b0d --- /dev/null +++ b/tasks/format-code-task-001120/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' +@commitlint/travis-cli/src/travis-behavior.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-001120/tests/test_command.sh b/tasks/format-code-task-001120/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001120/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001127/environment/Dockerfile b/tasks/format-code-task-001127/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e1f8f1d7336e766dbffca4a1bdd972e2959c8405 --- /dev/null +++ b/tasks/format-code-task-001127/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:845007224a208c5062c88990cf9718b05f50ee74a15941e5071378b23c9970ab diff --git a/tasks/format-code-task-001127/environment/setup/files/blocklist b/tasks/format-code-task-001127/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001127/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001127/environment/setup/setup.sh b/tasks/format-code-task-001127/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001127/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001127/tests/test.patch b/tasks/format-code-task-001127/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9ad271268571cde8d5e051c1fad1b88f11464e8 --- /dev/null +++ b/tasks/format-code-task-001127/tests/test.patch @@ -0,0 +1,139 @@ +diff --git a/test/test_recording_work_attributes_synthesis.py b/test/test_recording_work_attributes_synthesis.py +new file mode 100644 +index 000000000..e5bc7131e +--- /dev/null ++++ b/test/test_recording_work_attributes_synthesis.py +@@ -0,0 +1,124 @@ ++# -*- coding: utf-8 -*- ++ ++from test.picardtestcase import PicardTestCase ++ ++from picard.mbjson import recording_to_metadata ++from picard.metadata import Metadata ++from picard.track import Track ++ ++ ++def _artist(name, artist_id): ++ return { ++ 'id': artist_id, ++ 'name': name, ++ 'sort-name': name, ++ 'aliases': [], ++ } ++ ++ ++def _role_relation(role, name, artist_id): ++ return { ++ 'type': role, ++ 'target-type': 'artist', ++ 'attributes': [], ++ 'artist': _artist(name, artist_id), ++ } ++ ++ ++def _work(work_id, title, language='eng', lyricist=None): ++ relations = [] ++ if lyricist: ++ relations.append(_role_relation('lyricist', lyricist, 'artist-' + work_id)) ++ return { ++ 'id': work_id, ++ 'title': title, ++ 'language': language, ++ 'languages': [language] if language else [], ++ 'relations': relations, ++ } ++ ++ ++def _recording(relations): ++ return { ++ 'id': 'recording-synthesis', ++ 'title': 'Medley', ++ 'relations': relations, ++ } ++ ++ ++def _performance(work, attributes=None): ++ relation = { ++ 'type': 'performance', ++ 'target-type': 'work', ++ 'work': work, ++ } ++ if attributes is not None: ++ relation['attributes'] = attributes ++ return relation ++ ++ ++class RecordingWorkAttributesSynthesisTest(PicardTestCase): ++ ++ def setUp(self): ++ super().setUp() ++ self.set_config_values({ ++ 'standardize_artists': False, ++ 'standardize_instruments': True, ++ 'translate_artist_names': False, ++ 'translate_artist_names_script_exception': False, ++ 'artist_locales': ['en'], ++ }) ++ ++ def _metadata(self, relations): ++ metadata = Metadata() ++ recording_to_metadata(_recording(relations), metadata, Track('track-synthesis')) ++ return metadata ++ ++ def test_mixed_medley_scopes_instrumental_suppression(self): ++ instrumental = _work('instrumental', 'Instrumental Part', 'fra', 'Hidden Lyricist') ++ vocal = _work('vocal', 'Vocal Part', 'eng', 'Visible Lyricist') ++ metadata = self._metadata([ ++ _performance(instrumental, ['instrumental']), ++ _performance(vocal, []), ++ ]) ++ self.assertEqual(metadata.getall('language'), ['eng']) ++ self.assertEqual(metadata.getall('lyricist'), ['Visible Lyricist']) ++ self.assertEqual(metadata.getall('musicbrainz_workid'), ['instrumental', 'vocal']) ++ self.assertEqual(metadata.getall('work'), ['Instrumental Part', 'Vocal Part']) ++ self.assertEqual(metadata.getall('~performance_attributes'), ['instrumental']) ++ ++ def test_all_instrumental_medley_is_zxx_without_lyricist(self): ++ metadata = self._metadata([ ++ _performance(_work('one', 'One', 'eng', 'Lyricist One'), ['instrumental']), ++ _performance(_work('two', 'Two', 'deu', 'Lyricist Two'), ['instrumental']), ++ ]) ++ self.assertEqual(metadata['language'], 'zxx') ++ self.assertNotIn('lyricist', metadata) ++ self.assertEqual(metadata.getall('musicbrainz_workid'), ['one', 'two']) ++ ++ def test_same_work_vocal_relationship_preserves_its_credit(self): ++ work = _work('reused', 'Reused Work', 'eng', 'Reused Lyricist') ++ metadata = self._metadata([ ++ _performance(work, ['instrumental']), ++ _performance(work, []), ++ ]) ++ self.assertEqual(metadata['language'], 'eng') ++ self.assertEqual(metadata['lyricist'], 'Reused Lyricist') ++ ++ def test_missing_attributes_are_non_instrumental_and_work_data_survives(self): ++ metadata = self._metadata([_performance(_work('plain', 'Plain Work', 'spa', 'Spanish Lyricist'))]) ++ self.assertEqual(metadata['language'], 'spa') ++ self.assertEqual(metadata['lyricist'], 'Spanish Lyricist') ++ self.assertEqual(metadata['~performance_attributes'], '') ++ ++ def test_non_performance_relationship_does_not_change_work_semantics(self): ++ metadata = self._metadata([ ++ { ++ 'type': 'samples', ++ 'target-type': 'recording', ++ 'attributes': ['instrumental'], ++ }, ++ _performance(_work('vocal-only', 'Vocal Only', 'ita', 'Italian Lyricist'), []), ++ ]) ++ self.assertEqual(metadata['language'], 'ita') ++ self.assertEqual(metadata['lyricist'], 'Italian Lyricist') +diff --git 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 test/test_recording_work_attributes_synthesis.py test/test_mbjson.py diff --git a/tasks/format-code-task-001127/tests/test.sh b/tasks/format-code-task-001127/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0d42be309dd15e21456786af2e581c6b35ae01e5 --- /dev/null +++ b/tasks/format-code-task-001127/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test_recording_work_attributes_synthesis.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-001127/tests/test_command.sh b/tasks/format-code-task-001127/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001127/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001129/environment/Dockerfile b/tasks/format-code-task-001129/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b68846ad4d4d18138b85c85f264cee1b03b0a72c --- /dev/null +++ b/tasks/format-code-task-001129/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f472ff8fdbb23009f9675eadc594d20b63b91c2a28e0caf3f339a8d11fda904b diff --git a/tasks/format-code-task-001129/environment/setup/files/blocklist b/tasks/format-code-task-001129/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001129/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001129/environment/setup/setup.sh b/tasks/format-code-task-001129/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001129/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001129/tests/test.patch b/tasks/format-code-task-001129/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b505cbf09f607453fc8bcf45f771a3681042698 --- /dev/null +++ b/tasks/format-code-task-001129/tests/test.patch @@ -0,0 +1,284 @@ +diff --git a/internal/cmd/document_match_test.go b/internal/cmd/document_match_test.go +new file mode 100644 +index 0000000..1601884 +--- /dev/null ++++ b/internal/cmd/document_match_test.go +@@ -0,0 +1,269 @@ ++package cmd_test ++ ++import ( ++ "bytes" ++ "fmt" ++ "io/ioutil" ++ "os" ++ "os/exec" ++ "path/filepath" ++ "strings" ++ ++ . "github.com/onsi/ginkgo" ++ . "github.com/onsi/gomega" ++) ++ ++var documentMatchVerifierBinary string ++ ++var _ = BeforeSuite(func() { ++ dir, err := ioutil.TempDir("", "dyff-document-match-verifier") ++ Expect(err).NotTo(HaveOccurred()) ++ documentMatchVerifierBinary = filepath.Join(dir, "dyff") ++ build := exec.Command("go", "build", "-o", documentMatchVerifierBinary, "../../cmd/dyff") ++ output, err := build.CombinedOutput() ++ Expect(err).NotTo(HaveOccurred(), string(output)) ++}) ++ ++var _ = AfterSuite(func() { ++ if documentMatchVerifierBinary != "" { ++ _ = os.RemoveAll(filepath.Dir(documentMatchVerifierBinary)) ++ } ++}) ++ ++func runDocumentMatchVerifier(args ...string) (stdout string, stderr string, exitCode int) { ++ command := exec.Command(documentMatchVerifierBinary, args...) ++ var stdoutBuffer, stderrBuffer bytes.Buffer ++ command.Stdout = &stdoutBuffer ++ command.Stderr = &stderrBuffer ++ err := command.Run() ++ if err == nil { ++ return stdoutBuffer.String(), stderrBuffer.String(), 0 ++ } ++ ++ exitError, ok := err.(*exec.ExitError) ++ Expect(ok).To(BeTrue(), fmt.Sprintf("failed to execute dyff: %v", err)) ++ return stdoutBuffer.String(), stderrBuffer.String(), exitError.ExitCode() ++} ++ ++var _ = Describe("identity matching for multi-document comparisons", func() { ++ It("keeps positional comparison as the default", func() { ++ from := createTestFile("kind: ConfigMap\nmetadata:\n name: one\n") ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile("kind: ConfigMap\nmetadata:\n name: one\n---\nkind: ConfigMap\nmetadata:\n name: two\n") ++ defer func() { _ = os.Remove(to) }() ++ ++ _, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", from, to) ++ Expect(exitCode).NotTo(Equal(0)) ++ Expect(stderr).To(ContainSubstring("different number of documents")) ++ }) ++ ++ It("matches documents by all requested scalar paths independent of stream order", func() { ++ from := createTestFile(`kind: Deployment ++metadata: ++ name: api ++spec: ++ replicas: 1 ++--- ++kind: Service ++metadata: ++ name: api ++spec: ++ port: 80 ++`) ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile(`kind: Service ++metadata: ++ name: api ++spec: ++ port: 80 ++--- ++kind: Deployment ++metadata: ++ name: api ++spec: ++ replicas: 2 ++`) ++ defer func() { _ = os.Remove(to) }() ++ ++ out, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", "--omit-header", ++ "--match-documents-by", "/kind", ++ "--match-documents-by", "/metadata/name", from, to) ++ Expect(exitCode).To(Equal(0), stderr) ++ Expect(out).To(ContainSubstring("replicas")) ++ Expect(out).To(ContainSubstring("- 1")) ++ Expect(out).To(ContainSubstring("+ 2")) ++ Expect(strings.Count(out, "port")).To(Equal(0)) ++ }) ++ ++ It("reports documents present on only one side as additions or removals", func() { ++ from := createTestFile(`kind: ConfigMap ++metadata: ++ name: base ++data: ++ value: old ++`) ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile(`kind: ConfigMap ++metadata: ++ name: base ++data: ++ value: old ++--- ++kind: ConfigMap ++metadata: ++ name: worker ++data: ++ value: new ++`) ++ defer func() { _ = os.Remove(to) }() ++ ++ out, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", "--omit-header", ++ "--match-documents-by", "/kind", ++ "--match-documents-by", "/metadata/name", from, to) ++ Expect(exitCode).To(Equal(0), stderr) ++ Expect(out).To(ContainSubstring("worker")) ++ Expect(out).To(ContainSubstring("value: new")) ++ Expect(out).To(ContainSubstring("added")) ++ }) ++ ++ It("reports a document removed from the target stream", func() { ++ from := createTestFile(`kind: ConfigMap ++metadata: ++ name: base ++--- ++kind: ConfigMap ++metadata: ++ name: retired ++data: ++ value: old ++`) ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile(`kind: ConfigMap ++metadata: ++ name: base ++`) ++ defer func() { _ = os.Remove(to) }() ++ ++ out, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", "--omit-header", ++ "--match-documents-by", "/kind", ++ "--match-documents-by", "/metadata/name", from, to) ++ Expect(exitCode).To(Equal(0), stderr) ++ Expect(out).To(ContainSubstring("retired")) ++ Expect(out).To(ContainSubstring("value: old")) ++ Expect(out).To(ContainSubstring("removed")) ++ }) ++ ++ It("preserves comparison options for matched documents", func() { ++ from := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++data: ++ keys: ++ - alpha ++ - beta ++`) ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++data: ++ keys: ++ - beta ++ - alpha ++`) ++ defer func() { _ = os.Remove(to) }() ++ ++ out, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", "--omit-header", "--ignore-order-changes", ++ "--match-documents-by", "/kind", ++ "--match-documents-by", "/metadata/name", from, to) ++ Expect(exitCode).To(Equal(0), stderr) ++ Expect(out).To(Equal("\n")) ++ }) ++ ++ It("rejects a document that is missing an identity path", func() { ++ from := createTestFile(`kind: ConfigMap ++metadata: {} ++`) ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++`) ++ defer func() { _ = os.Remove(to) }() ++ ++ out, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", "--match-documents-by", "/metadata/name", from, to) ++ Expect(exitCode).NotTo(Equal(0)) ++ Expect(out).To(BeEmpty()) ++ Expect(stderr).To(ContainSubstring("/metadata/name")) ++ Expect(stderr).To(ContainSubstring("document")) ++ }) ++ ++ It("rejects a non-scalar identity value", func() { ++ from := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++ labels: ++ app: demo ++`) ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++ labels: ++ app: demo ++`) ++ defer func() { _ = os.Remove(to) }() ++ ++ out, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", "--match-documents-by", "/metadata/labels", from, to) ++ Expect(exitCode).NotTo(Equal(0)) ++ Expect(out).To(BeEmpty()) ++ Expect(stderr).To(ContainSubstring("/metadata/labels")) ++ Expect(stderr).To(ContainSubstring("scalar")) ++ }) ++ ++ It("rejects duplicate composite identities on either side", func() { ++ from := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++--- ++kind: ConfigMap ++metadata: ++ name: settings ++`) ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++`) ++ defer func() { _ = os.Remove(to) }() ++ ++ out, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", "--match-documents-by", "/kind", "--match-documents-by", "/metadata/name", from, to) ++ Expect(exitCode).NotTo(Equal(0)) ++ Expect(out).To(BeEmpty()) ++ Expect(stderr).To(ContainSubstring("duplicate")) ++ Expect(stderr).To(ContainSubstring("settings")) ++ }) ++ ++ It("rejects duplicate composite identities in the target stream", func() { ++ from := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++`) ++ defer func() { _ = os.Remove(from) }() ++ to := createTestFile(`kind: ConfigMap ++metadata: ++ name: settings ++--- ++kind: ConfigMap ++metadata: ++ name: settings ++`) ++ defer func() { _ = os.Remove(to) }() ++ ++ out, stderr, exitCode := runDocumentMatchVerifier("--color", "off", "between", "--match-documents-by", "/kind", "--match-documents-by", "/metadata/name", from, to) ++ Expect(exitCode).NotTo(Equal(0)) ++ Expect(out).To(BeEmpty()) ++ Expect(stderr).To(ContainSubstring("duplicate")) ++ Expect(stderr).To(ContainSubstring("settings")) ++ }) ++}) +diff --git 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 ./internal/cmd -run TestCmd -count=1 diff --git a/tasks/format-code-task-001129/tests/test.sh b/tasks/format-code-task-001129/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f3160b2915e3aba922091b554e32653e8852cb8 --- /dev/null +++ b/tasks/format-code-task-001129/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/cmd/document_match_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-001129/tests/test_command.sh b/tasks/format-code-task-001129/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001129/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001144/environment/Dockerfile b/tasks/format-code-task-001144/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6fc095cfbd7a22555516a2e95735389fcc1fab7a --- /dev/null +++ b/tasks/format-code-task-001144/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:31d0325f5dc197676ef41ccae1c933a0aa2da94ca43499c8d6614f0ccd344587 diff --git a/tasks/format-code-task-001144/environment/setup/files/blocklist b/tasks/format-code-task-001144/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001144/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001144/environment/setup/setup.sh b/tasks/format-code-task-001144/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001144/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001144/tests/test.patch b/tasks/format-code-task-001144/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a35bc54b03a543a19cd44b74a1bd5717296308b0 --- /dev/null +++ b/tasks/format-code-task-001144/tests/test.patch @@ -0,0 +1,271 @@ +diff --git a/qcodes/tests/test_deprecate_descriptor_contract.py b/qcodes/tests/test_deprecate_descriptor_contract.py +new file mode 100644 +index 000000000..8c9e783d8 +--- /dev/null ++++ b/qcodes/tests/test_deprecate_descriptor_contract.py +@@ -0,0 +1,252 @@ ++import asyncio ++import inspect ++import warnings ++ ++from qcodes.utils.deprecate import QCoDeSDeprecationWarning, deprecate ++ ++ ++REASON = "descriptor coverage" ++ ++ ++def _invoke_with_deprecation_capture(call): ++ with warnings.catch_warnings(record=True) as captured: ++ warnings.simplefilter("always", QCoDeSDeprecationWarning) ++ result = call() ++ return result, captured ++ ++ ++class _DeprecationParent: ++ def inherited_method(self, value): ++ return value + 10 ++ ++ @staticmethod ++ def inherited_static(value): ++ return value + 20 ++ ++ @classmethod ++ def inherited_class(cls, value): ++ return cls.__name__, value + 30 ++ ++ @property ++ def inherited_property(self): ++ return "parent" ++ ++ ++@deprecate(reason=REASON) ++class _DeprecatedDescriptors(_DeprecationParent): ++ def __init__(self, value): ++ self._value = value ++ ++ def instance_method(self, value): ++ return self._value + value ++ ++ @staticmethod ++ def static_method(value): ++ return value + 1 ++ ++ @classmethod ++ def class_method(cls, value): ++ return cls.__name__, value + 2 ++ ++ @property ++ def value(self): ++ return self._value ++ ++ @value.setter ++ def value(self, new_value): ++ self._value = new_value ++ ++ @value.deleter ++ def value(self): ++ self._value = "deleted" ++ ++ async def async_method(self, value): ++ return value + 4 ++ ++ ++@deprecate(reason=REASON) ++class _DeprecatedChild(_DeprecationParent): ++ pass ++ ++ ++def _new_deprecated_instance(): ++ with warnings.catch_warnings(): ++ warnings.simplefilter("ignore", QCoDeSDeprecationWarning) ++ return _DeprecatedDescriptors(5) ++ ++ ++def test_class_construction_and_instance_method_warn_once_and_return_value(): ++ instance, construction_warnings = _invoke_with_deprecation_capture( ++ lambda: _DeprecatedDescriptors(5)) ++ assert instance._value == 5 ++ assert len(construction_warnings) == 1 ++ assert str(construction_warnings[0].message) == ( ++ "The class <_DeprecatedDescriptors> is deprecated, because " ++ "descriptor coverage.") ++ ++ result, method_warnings = _invoke_with_deprecation_capture( ++ lambda: instance.instance_method(3)) ++ assert result == 8 ++ assert len(method_warnings) == 1 ++ assert str(method_warnings[0].message) == ( ++ "The function is deprecated, because " ++ "descriptor coverage.") ++ ++ ++def test_static_method_keeps_static_binding_on_class_and_instance(): ++ class_result, class_warnings = _invoke_with_deprecation_capture( ++ lambda: _DeprecatedDescriptors.static_method(2)) ++ instance = _new_deprecated_instance() ++ instance_result, instance_warnings = _invoke_with_deprecation_capture( ++ lambda: instance.static_method(2)) ++ ++ assert class_result == instance_result == 3 ++ assert len(class_warnings) == len(instance_warnings) == 1 ++ assert all(str(item.message) == ( ++ "The function is deprecated, because " ++ "descriptor coverage.") for item in class_warnings + instance_warnings) ++ ++ ++def test_class_method_keeps_class_binding_on_class_and_instance(): ++ class_result, class_warnings = _invoke_with_deprecation_capture( ++ lambda: _DeprecatedDescriptors.class_method(2)) ++ instance = _new_deprecated_instance() ++ instance_result, instance_warnings = _invoke_with_deprecation_capture( ++ lambda: instance.class_method(2)) ++ ++ assert class_result == instance_result == ("_DeprecatedDescriptors", 4) ++ assert len(class_warnings) == len(instance_warnings) == 1 ++ assert all(str(item.message) == ( ++ "The function is deprecated, because " ++ "descriptor coverage.") for item in class_warnings + instance_warnings) ++ ++ ++def test_property_get_warns_and_preserves_value(): ++ instance = _new_deprecated_instance() ++ result, get_warnings = _invoke_with_deprecation_capture( ++ lambda: instance.value) ++ assert result == 5 ++ assert len(get_warnings) == 1 ++ assert "" in str(get_warnings[0].message) ++ ++ ++def test_property_set_warns_and_preserves_state_change(): ++ instance = _new_deprecated_instance() ++ _, set_warnings = _invoke_with_deprecation_capture( ++ lambda: setattr(instance, "value", 7)) ++ result, readback_warnings = _invoke_with_deprecation_capture( ++ lambda: instance.value) ++ assert result == 7 ++ assert len(set_warnings) == 1 ++ assert len(readback_warnings) == 1 ++ assert "" in str(set_warnings[0].message) ++ ++ ++def test_property_delete_warns_and_preserves_state_change(): ++ instance = _new_deprecated_instance() ++ ++ def delete_value(): ++ del instance.value ++ ++ _, delete_warnings = _invoke_with_deprecation_capture(delete_value) ++ result, post_delete_warnings = _invoke_with_deprecation_capture( ++ lambda: instance.value) ++ assert result == "deleted" ++ assert len(delete_warnings) == 1 ++ assert len(post_delete_warnings) == 1 ++ assert "" in str(delete_warnings[0].message) ++ ++ ++def test_async_method_is_awaitable_and_warns_when_called(): ++ instance = _new_deprecated_instance() ++ assert inspect.iscoroutinefunction(_DeprecatedDescriptors.async_method) ++ result, captured = _invoke_with_deprecation_capture( ++ lambda: asyncio.run(instance.async_method(6))) ++ assert result == 10 ++ assert len(captured) == 1 ++ assert str(captured[0].message) == ( ++ "The function is deprecated, because " ++ "descriptor coverage.") ++ ++ ++def _new_deprecated_child(): ++ with warnings.catch_warnings(): ++ warnings.simplefilter("ignore", QCoDeSDeprecationWarning) ++ return _DeprecatedChild() ++ ++ ++def test_inherited_instance_method_remains_unwrapped(): ++ child = _new_deprecated_child() ++ result, captured = _invoke_with_deprecation_capture( ++ lambda: child.inherited_method(1)) ++ assert result == 11 ++ assert captured == [] ++ ++ ++def test_deprecated_subclass_construction_still_warns_once(): ++ instance, captured = _invoke_with_deprecation_capture( ++ lambda: _DeprecatedChild()) ++ assert isinstance(instance, _DeprecatedChild) ++ assert len(captured) == 1 ++ assert str(captured[0].message) == ( ++ "The class <_DeprecatedChild> is deprecated, because " ++ "descriptor coverage.") ++ ++ ++def test_inherited_static_method_remains_unwrapped(): ++ result, captured = _invoke_with_deprecation_capture( ++ lambda: _DeprecatedChild.inherited_static(1)) ++ assert result == 21 ++ assert captured == [] ++ ++ ++def test_inherited_class_method_remains_unwrapped_and_binds_subclass(): ++ child = _new_deprecated_child() ++ result, captured = _invoke_with_deprecation_capture( ++ lambda: child.inherited_class(1)) ++ assert result == ("_DeprecatedChild", 31) ++ assert captured == [] ++ ++ ++def test_inherited_property_remains_unwrapped(): ++ child = _new_deprecated_child() ++ result, captured = _invoke_with_deprecation_capture( ++ lambda: child.inherited_property) ++ assert result == "parent" ++ assert captured == [] ++ ++ ++def test_decorating_subclass_does_not_mutate_parent_descriptors(): ++ parent = _DeprecationParent() ++ for call, expected in [ ++ (lambda: parent.inherited_method(1), 11), ++ (lambda: _DeprecationParent.inherited_static(1), 21), ++ (lambda: parent.inherited_class(1), ("_DeprecationParent", 31)), ++ (lambda: parent.inherited_property, "parent"), ++ ]: ++ result, captured = _invoke_with_deprecation_capture(call) ++ assert result == expected ++ assert captured == [] ++ ++ ++def test_function_metadata_and_signature_are_preserved(): ++ @deprecate(reason=REASON) ++ def documented_function(first: int, second: str = "x") -> str: ++ ++ return second * first ++ ++ assert documented_function.__name__ == "documented_function" ++ assert documented_function.__doc__.startswith("A public function") ++ assert inspect.signature(documented_function) == inspect.Signature( ++ parameters=[ ++ inspect.Parameter("first", inspect.Parameter.POSITIONAL_OR_KEYWORD, ++ annotation=int), ++ inspect.Parameter("second", inspect.Parameter.POSITIONAL_OR_KEYWORD, ++ default="x", annotation=str), ++ ], ++ return_annotation=str, ++ ) ++ result, captured = _invoke_with_deprecation_capture( ++ lambda: documented_function(2)) ++ assert result == "xx" ++ assert len(captured) == 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 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++PYTHONPATH="${PWD}/.build_env/.venv/lib/python3.11/site-packages${PYTHONPATH:+:${PYTHONPATH}}" \ ++ python -m pytest -q \ ++ qcodes/tests/test_deprecate_descriptor_contract.py \ ++ qcodes/tests/test_deprecate.py diff --git a/tasks/format-code-task-001144/tests/test.sh b/tasks/format-code-task-001144/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9aebe628bb0ccc1686a55c1d3eaec784788a3acc --- /dev/null +++ b/tasks/format-code-task-001144/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' +qcodes/tests/test_deprecate_descriptor_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-001144/tests/test_command.sh b/tasks/format-code-task-001144/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001144/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001173/environment/Dockerfile b/tasks/format-code-task-001173/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9f7006eeba07af854dce3471c1ef32e17e11852f --- /dev/null +++ b/tasks/format-code-task-001173/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:356ee84b29a1a2efde965efebdec5dc5ab2e5219aaa54a4521d5294ad4fe74f5 diff --git a/tasks/format-code-task-001173/environment/setup/files/blocklist b/tasks/format-code-task-001173/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001173/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001173/environment/setup/setup.sh b/tasks/format-code-task-001173/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001173/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001173/tests/test.patch b/tasks/format-code-task-001173/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..18ee10ec944e750b94ad724768e0037f2d2c99d0 --- /dev/null +++ b/tasks/format-code-task-001173/tests/test.patch @@ -0,0 +1,196 @@ +diff --git a/asyncconcat/test/abort-and-limits.task.js b/asyncconcat/test/abort-and-limits.task.js +new file mode 100644 +index 0000000..bf34c21 +--- /dev/null ++++ b/asyncconcat/test/abort-and-limits.task.js +@@ -0,0 +1,180 @@ ++const assert = require('assert'); ++const {Readable} = require('stream'); ++const asyncConcat = require('..'); ++ ++async function expectRejected(promise, expected) { ++ try { ++ await promise; ++ } catch (error) { ++ if (expected instanceof Error) { ++ assert.strictEqual(error, expected); ++ } else { ++ assert(error instanceof expected, `expected ${expected.name}, got ${error}`); ++ } ++ return; ++ } ++ ++ assert.fail('expected the concatenation promise to reject'); ++} ++ ++async function legacyCallsKeepTheirReturnShapes() { ++ const bytes = Buffer.from('legacy'); ++ const bufferResult = await asyncConcat(Readable.from([bytes])); ++ assert(Buffer.isBuffer(bufferResult)); ++ assert(bufferResult.equals(bytes)); ++ ++ assert.strictEqual( ++ await asyncConcat(Readable.from([bytes]), 'utf8'), ++ 'legacy' ++ ); ++} ++ ++async function oversizedInputRejectsByByteLength() { ++ const source = new Readable({read() {}}); ++ const result = asyncConcat(source, 'utf8', {maxBytes: 2}); ++ let settled = false; ++ let rejection; ++ result.then( ++ () => { settled = true; }, ++ error => { settled = true; rejection = error; } ++ ); ++ ++ source.push(Buffer.from('abc')); ++ await new Promise(resolve => setImmediate(resolve)); ++ ++ assert.strictEqual(settled, true, 'maxBytes must reject before the stream ends'); ++ assert(rejection instanceof RangeError, `expected RangeError, got ${rejection}`); ++ source.destroy(); ++} ++ ++async function limitBoundaryAndChunkNormalization() { ++ const mixedChunks = [Buffer.from('ab'), 'cde', new Uint8Array([102])]; ++ assert.strictEqual( ++ await asyncConcat( ++ Readable.from(mixedChunks, {objectMode: true}), ++ {encoding: 'utf8', maxBytes: 6} ++ ), ++ 'abcdef' ++ ); ++ ++ assert.strictEqual( ++ await asyncConcat( ++ Readable.from([Buffer.from([0xe2, 0x82, 0xac])]), ++ 'utf8', ++ {maxBytes: 3} ++ ), ++ '\u20ac' ++ ); ++ ++ await expectRejected( ++ asyncConcat( ++ Readable.from(['\u20ac'], {objectMode: true}), ++ {encoding: 'utf8', maxBytes: 2} ++ ), ++ RangeError ++ ); ++ ++ assert.strictEqual( ++ await asyncConcat( ++ Readable.from(['\u20ac'], {objectMode: true}), ++ {encoding: 'utf8', maxBytes: 3} ++ ), ++ '\u20ac' ++ ); ++ ++ assert.strictEqual( ++ await asyncConcat( ++ Readable.from([Buffer.from([0, 255])]), ++ 'hex', ++ {maxBytes: 2} ++ ), ++ '00ff' ++ ); ++ ++ assert.strictEqual( ++ await asyncConcat(Readable.from([]), {encoding: 'utf8', maxBytes: 0}), ++ '' ++ ); ++} ++ ++async function positionalEncodingWinsOverTheOption() { ++ assert.strictEqual( ++ await asyncConcat( ++ Readable.from([Buffer.from('A')]), ++ 'utf8', ++ {encoding: 'hex', maxBytes: 1} ++ ), ++ 'A' ++ ); ++} ++ ++async function invalidMaxBytesRejects() { ++ for (const maxBytes of [-1, 1.5, NaN, Infinity, null, '2', true]) { ++ await expectRejected( ++ asyncConcat(Readable.from([Buffer.from('x')]), {maxBytes}), ++ RangeError ++ ); ++ } ++} ++ ++async function alreadyAbortedSignalRejectsWithItsReason() { ++ const controller = new AbortController(); ++ const reason = new Error('already cancelled'); ++ controller.abort(reason); ++ ++ await expectRejected( ++ asyncConcat(Readable.from([Buffer.from('content')]), 'utf8', {signal: controller.signal}), ++ reason ++ ); ++} ++ ++async function abortDuringConsumptionRejectsWithItsReason() { ++ const controller = new AbortController(); ++ const reason = new Error('cancel while reading'); ++ const source = new Readable({ ++ read() {} ++ }); ++ const result = asyncConcat(source, 'utf8', {signal: controller.signal}); ++ ++ source.push(Buffer.from('first')); ++ controller.abort(reason); ++ source.push(null); ++ ++ await expectRejected(result, reason); ++} ++ ++async function sourceErrorsRemainObservable() { ++ const failure = new Error('source failure'); ++ const source = new Readable({ ++ read() { ++ this.destroy(failure); ++ } ++ }); ++ ++ await expectRejected(asyncConcat(source), failure); ++} ++ ++async function unsupportedChunksRejectWithTypeError() { ++ for (const chunk of [42, {bytes: [1, 2]}]) { ++ await expectRejected( ++ asyncConcat(Readable.from([chunk], {objectMode: true})), ++ TypeError ++ ); ++ } ++} ++ ++(async () => { ++ await legacyCallsKeepTheirReturnShapes(); ++ await oversizedInputRejectsByByteLength(); ++ await limitBoundaryAndChunkNormalization(); ++ await positionalEncodingWinsOverTheOption(); ++ await invalidMaxBytesRejects(); ++ await alreadyAbortedSignalRejectsWithItsReason(); ++ await abortDuringConsumptionRejectsWithItsReason(); ++ await sourceErrorsRemainObservable(); ++ await unsupportedChunksRejectWithTypeError(); ++ console.log('asyncconcat abort and limits task tests passed'); ++})().catch(error => { ++ console.error(error.stack || error); ++ process.exitCode = 1; ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++node asyncconcat/test/abort-and-limits.task.js diff --git a/tasks/format-code-task-001173/tests/test.sh b/tasks/format-code-task-001173/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..487a100c6c1f4fc14eae1ec9eff61319179cbee0 --- /dev/null +++ b/tasks/format-code-task-001173/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' +asyncconcat/test/abort-and-limits.task.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-001173/tests/test_command.sh b/tasks/format-code-task-001173/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001173/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001175/environment/Dockerfile b/tasks/format-code-task-001175/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ecc179a5603358f61519a65652494f55a3bf187b --- /dev/null +++ b/tasks/format-code-task-001175/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ffc9825e9c8dac9ded4f425633a921ac54ecc429ab0c5817cee69cadfa03942b diff --git a/tasks/format-code-task-001175/environment/setup/files/blocklist b/tasks/format-code-task-001175/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001175/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001175/environment/setup/setup.sh b/tasks/format-code-task-001175/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001175/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001175/tests/test.patch b/tasks/format-code-task-001175/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..98c944dcf6e731bcbfc03970b29fba1bde1ca8db --- /dev/null +++ b/tasks/format-code-task-001175/tests/test.patch @@ -0,0 +1,188 @@ +diff --git a/codespec_sdk_resource_pagination.py b/codespec_sdk_resource_pagination.py +new file mode 100644 +index 000000000..56bf93521 +--- /dev/null ++++ b/codespec_sdk_resource_pagination.py +@@ -0,0 +1,171 @@ ++import httpx ++import pytest ++ ++from nucliadb_sdk import NucliaDB, NucliaDBAsync, Region, exceptions ++ ++ ++def _page(ids, page, size, last): ++ return { ++ "resources": [{"id": rid} for rid in ids], ++ "pagination": {"page": page, "size": size, "last": last}, ++ } ++ ++ ++def test_sync_iter_resources_is_lazy_and_preserves_query_params(): ++ seen = [] ++ pages = { ++ 2: _page([], 2, 7, False), ++ 3: _page(["r-3a", "r-3b"], 3, 7, False), ++ 4: _page(["r-4"], 4, 7, True), ++ } ++ ++ def handler(request): ++ params = request.url.params ++ seen.append((request.url.path, dict(params))) ++ return httpx.Response(200, json=pages[int(params["page"])]) ++ ++ sdk = NucliaDB(region=Region.ON_PREM, url="http://test/api") ++ sdk.session.close() ++ sdk.session = httpx.Client(transport=httpx.MockTransport(handler)) ++ query_params = {"size": 99, "show": "basic", "sort": "title"} ++ ++ iterator = sdk.iter_resources(kbid="kb-1", page=2, page_size=7, query_params=query_params) ++ assert seen == [] ++ assert [resource.id for resource in iterator] == ["r-3a", "r-3b", "r-4"] ++ ++ assert [int(params["page"]) for _, params in seen] == [2, 3, 4] ++ assert all(path == "/api/v1/kb/kb-1/resources" for path, _ in seen) ++ assert all( ++ params["size"] == "7" and params["show"] == "basic" and params["sort"] == "title" ++ for _, params in seen ++ ) ++ assert query_params == {"size": 99, "show": "basic", "sort": "title"} ++ sdk.session.close() ++ ++ ++@pytest.mark.asyncio ++async def test_async_iter_resources_matches_sync_and_page_size_wins(): ++ seen = [] ++ pages = { ++ 0: _page(["a"], 0, 3, False), ++ 1: _page(["b", "c"], 1, 3, True), ++ } ++ ++ def handler(request): ++ params = request.url.params ++ seen.append(dict(params)) ++ return httpx.Response(200, json=pages[int(params["page"])]) ++ ++ sdk = NucliaDBAsync(region=Region.ON_PREM, url="http://test/api") ++ await sdk.session.aclose() ++ sdk.session = httpx.AsyncClient(transport=httpx.MockTransport(handler)) ++ query_params = {"filter": "tag:blue", "size": 99, "page": 8} ++ ++ result = [] ++ async for resource in sdk.iter_resources( ++ kbid="kb-2", page=0, page_size=3, query_params=query_params ++ ): ++ result.append(resource.id) ++ ++ assert result == ["a", "b", "c"] ++ assert seen == [ ++ {"filter": "tag:blue", "size": "3", "page": "0"}, ++ {"filter": "tag:blue", "size": "3", "page": "1"}, ++ ] ++ assert query_params == {"filter": "tag:blue", "size": 99, "page": 8} ++ await sdk.session.aclose() ++ ++ ++@pytest.mark.parametrize( ++ "kwargs", ++ [ ++ {"page_size": 0}, ++ {"page_size": -1}, ++ {"page": -1}, ++ ], ++) ++def test_iter_resources_rejects_invalid_paging_before_request(kwargs): ++ def handler(request): ++ pytest.fail(f"invalid paging made a request to {request.url}") ++ ++ sdk = NucliaDB(region=Region.ON_PREM, url="http://test/api") ++ sdk.session.close() ++ sdk.session = httpx.Client(transport=httpx.MockTransport(handler)) ++ ++ with pytest.raises(ValueError): ++ list(sdk.iter_resources(kbid="kb", **kwargs)) ++ sdk.session.close() ++ ++ ++@pytest.mark.asyncio ++async def test_async_iter_resources_rejects_invalid_paging_before_request(): ++ def handler(request): ++ pytest.fail(f"invalid paging made a request to {request.url}") ++ ++ sdk = NucliaDBAsync(region=Region.ON_PREM, url="http://test/api") ++ await sdk.session.aclose() ++ sdk.session = httpx.AsyncClient(transport=httpx.MockTransport(handler)) ++ ++ with pytest.raises(ValueError): ++ async for _ in sdk.iter_resources(kbid="kb", page_size=0): ++ pass ++ await sdk.session.aclose() ++ ++ ++def test_iter_resources_propagates_page_errors_and_stops(): ++ pages_seen = [] ++ ++ def handler(request): ++ page = int(request.url.params["page"]) ++ pages_seen.append(page) ++ if page == 1: ++ return httpx.Response(503, text="backend unavailable") ++ return httpx.Response(200, json=_page(["first"], page, 20, False)) ++ ++ sdk = NucliaDB(region=Region.ON_PREM, url="http://test/api") ++ sdk.session.close() ++ sdk.session = httpx.Client(transport=httpx.MockTransport(handler)) ++ iterator = sdk.iter_resources(kbid="kb") ++ ++ assert next(iterator).id == "first" ++ with pytest.raises(exceptions.UnknownError, match="503.*backend unavailable"): ++ next(iterator) ++ assert pages_seen == [0, 1] ++ sdk.session.close() ++ ++ ++def test_list_resources_still_returns_one_page(): ++ requests = [] ++ ++ def handler(request): ++ requests.append(request) ++ return httpx.Response(200, json=_page(["only"], 5, 1, False)) ++ ++ sdk = NucliaDB(region=Region.ON_PREM, url="http://test/api") ++ sdk.session.close() ++ sdk.session = httpx.Client(transport=httpx.MockTransport(handler)) ++ ++ page = sdk.list_resources(kbid="kb", query_params={"page": 5, "size": 1}) ++ assert [resource.id for resource in page.resources] == ["only"] ++ assert page.pagination.page == 5 and page.pagination.last is False ++ assert len(requests) == 1 ++ sdk.session.close() ++ ++ ++@pytest.mark.asyncio ++async def test_async_list_resources_still_returns_one_page(): ++ requests = [] ++ ++ def handler(request): ++ requests.append(request) ++ return httpx.Response(200, json=_page(["only-async"], 5, 1, False)) ++ ++ sdk = NucliaDBAsync(region=Region.ON_PREM, url="http://test/api") ++ await sdk.session.aclose() ++ sdk.session = httpx.AsyncClient(transport=httpx.MockTransport(handler)) ++ ++ page = await sdk.list_resources(kbid="kb", query_params={"page": 5, "size": 1}) ++ assert [resource.id for resource in page.resources] == ["only-async"] ++ assert page.pagination.page == 5 and page.pagination.last is False ++ assert len(requests) == 1 ++ await sdk.session.aclose() +diff --git 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="${PWD}/nucliadb_sdk:${PWD}/nucliadb_models:${PWD}/nucliadb_protos/python:${PWD}/nucliadb_utils:${PWD}/nucliadb_telemetry:${PWD}/nucliadb_client:${PWD}/.venv/lib/python3.12/site-packages" \ ++ /usr/bin/python3.12 -m pytest -q codespec_sdk_resource_pagination.py diff --git a/tasks/format-code-task-001175/tests/test.sh b/tasks/format-code-task-001175/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f3e7751f2aac433269d5eab4d464fd6896515db6 --- /dev/null +++ b/tasks/format-code-task-001175/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_sdk_resource_pagination.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-001175/tests/test_command.sh b/tasks/format-code-task-001175/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001175/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001181/environment/Dockerfile b/tasks/format-code-task-001181/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d6c434edfdd9416148e9fe52c98d55aa347eb773 --- /dev/null +++ b/tasks/format-code-task-001181/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9bfffeb2c65b4591df22d0ae8fad6c192a0e701597ba5260e5c15cabe9e44da8 diff --git a/tasks/format-code-task-001181/environment/setup/files/blocklist b/tasks/format-code-task-001181/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001181/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001181/environment/setup/setup.sh b/tasks/format-code-task-001181/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001181/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001181/tests/test.patch b/tasks/format-code-task-001181/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..61f38acae7f0960881c4b23ebf47e4050ab6a163 --- /dev/null +++ b/tasks/format-code-task-001181/tests/test.patch @@ -0,0 +1,158 @@ +diff --git a/tests/test_codespec_progress_telemetry.py b/tests/test_codespec_progress_telemetry.py +new file mode 100644 +index 00000000..6788a502 +--- /dev/null ++++ b/tests/test_codespec_progress_telemetry.py +@@ -0,0 +1,143 @@ ++import io ++from typing import Tuple ++ ++import pytest ++ ++from rich.console import Console ++from rich.progress import Progress ++ ++ ++class Clock: ++ def __init__(self) -> None: ++ self.value = 0.0 ++ ++ def __call__(self) -> float: ++ return self.value ++ ++ ++def make_progress(clock: Clock, *, total: float = 100.0) -> Tuple[Progress, int]: ++ progress = Progress( ++ console=Console(file=io.StringIO()), ++ get_time=clock, ++ auto_refresh=False, ++ speed_estimate_period=30.0, ++ ) ++ return progress, progress.add_task("work", total=total) ++ ++ ++def test_speed_includes_every_positive_increment() -> None: ++ clock = Clock() ++ progress, task_id = make_progress(clock) ++ ++ clock.value = 2.0 ++ progress.advance(task_id, 2) ++ clock.value = 5.0 ++ progress.advance(task_id, 4) ++ ++ ++ assert progress.tasks[task_id].speed == 2.0 ++ ++ ++def test_absolute_completed_updates_feed_the_same_rate_estimator() -> None: ++ clock = Clock() ++ progress, task_id = make_progress(clock) ++ ++ clock.value = 1.0 ++ progress.update(task_id, completed=2) ++ clock.value = 4.0 ++ progress.update(task_id, completed=8) ++ ++ assert progress.tasks[task_id].speed == pytest.approx(8 / 3) ++ ++ ++def test_non_positive_advance_does_not_create_progress() -> None: ++ clock = Clock() ++ progress, task_id = make_progress(clock) ++ ++ clock.value = 1.0 ++ progress.advance(task_id, 5) ++ clock.value = 2.0 ++ progress.advance(task_id, 0) ++ clock.value = 3.0 ++ progress.advance(task_id, -2) ++ clock.value = 5.0 ++ progress.advance(task_id, 5) ++ ++ ++ assert progress.tasks[task_id].completed == 8 ++ assert progress.tasks[task_id].speed == 2.5 ++ ++ ++def test_time_remaining_uses_the_observed_speed() -> None: ++ clock = Clock() ++ progress, task_id = make_progress(clock, total=20) ++ ++ clock.value = 2.0 ++ progress.advance(task_id, 4) ++ clock.value = 6.0 ++ progress.advance(task_id, 4) ++ ++ task = progress.tasks[task_id] ++ assert task.speed == 2.0 ++ assert task.time_remaining == 6 ++ ++ ++def test_completion_via_update_records_and_freezes_finished_speed() -> None: ++ clock = Clock() ++ progress, task_id = make_progress(clock, total=10) ++ ++ clock.value = 1.0 ++ progress.update(task_id, completed=4) ++ clock.value = 3.0 ++ progress.update(task_id, completed=10) ++ task = progress.tasks[task_id] ++ ++ assert task.finished ++ assert task.finished_speed == 5.0 ++ finished_time = task.finished_time ++ ++ clock.value = 20.0 ++ progress.update(task_id, advance=1) ++ assert task.finished_time == finished_time ++ assert task.finished_speed == 5.0 ++ ++ ++def test_reset_clears_old_speed_samples() -> None: ++ clock = Clock() ++ progress, task_id = make_progress(clock, total=20) ++ ++ clock.value = 1.0 ++ progress.advance(task_id, 4) ++ clock.value = 3.0 ++ progress.advance(task_id, 4) ++ assert progress.tasks[task_id].speed == 4.0 ++ ++ progress.reset(task_id, total=20) ++ assert progress.tasks[task_id].speed is None ++ assert progress.tasks[task_id].finished_speed is None ++ ++ ++def test_changing_total_invalidates_old_speed_samples() -> None: ++ clock = Clock() ++ progress, task_id = make_progress(clock, total=50) ++ ++ clock.value = 1.0 ++ progress.advance(task_id, 4) ++ clock.value = 3.0 ++ progress.advance(task_id, 4) ++ assert progress.tasks[task_id].speed == 4.0 ++ ++ progress.update(task_id, total=80) ++ assert progress.tasks[task_id].speed is None ++ ++ ++def test_new_samples_after_reset_are_used_for_speed() -> None: ++ clock = Clock() ++ progress, task_id = make_progress(clock, total=20) ++ progress.reset(task_id) ++ ++ clock.value = 4.0 ++ progress.advance(task_id, 2) ++ clock.value = 6.0 ++ progress.advance(task_id, 2) ++ assert progress.tasks[task_id].speed == 2.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,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++python -m pytest -q tests/test_progress.py tests/test_codespec_progress_telemetry.py diff --git a/tasks/format-code-task-001181/tests/test.sh b/tasks/format-code-task-001181/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d37f324d9d25085ee431bf9b68f5fe7aa26dc12b --- /dev/null +++ b/tasks/format-code-task-001181/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_codespec_progress_telemetry.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-001181/tests/test_command.sh b/tasks/format-code-task-001181/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001181/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001187/environment/Dockerfile b/tasks/format-code-task-001187/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d9f1b6f4ad7a85b011e06a56f5a94d0062a9dfc7 --- /dev/null +++ b/tasks/format-code-task-001187/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bb8ace8fe570403e0c522b6728168dc1ac4b7a51fb41585b44ed15c5b75b637a diff --git a/tasks/format-code-task-001187/environment/setup/files/blocklist b/tasks/format-code-task-001187/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001187/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001187/environment/setup/setup.sh b/tasks/format-code-task-001187/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001187/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001187/tests/test.patch b/tasks/format-code-task-001187/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..661f723956f1649010835153d709a18a513f552a --- /dev/null +++ b/tasks/format-code-task-001187/tests/test.patch @@ -0,0 +1,54 @@ +diff --git a/server/service/integration_mdm_test.go b/server/service/integration_mdm_test.go +index 90a45e183793..fc014d25258e 100644 +--- a/server/service/integration_mdm_test.go ++++ b/server/service/integration_mdm_test.go +@@ -9250,6 +9250,15 @@ func (s *integrationMDMTestSuite) TestConnectedToFleetWithoutCheckout() { + require.False(t, *hostResp.Host.MDM.ConnectedToFleet) + } + ++func (s *integrationMDMTestSuite) TestInvalidCommandUUID() { ++ t := s.T() ++ _, device := createHostThenEnrollMDM(s.ds, s.server.URL, t) ++ s.runWorker() ++ cmd, err := device.Acknowledge("foo") ++ require.NoError(t, err) ++ require.NotNil(t, cmd) ++} ++ + func (s *integrationMDMTestSuite) TestEnrollAfterDEPSyncIOSIPadOS() { + t := s.T() + ctx := context.Background() +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,18 @@ ++H4sIAAAAAAAAA+1VbW/bNhDOZ/2KqxPE6FbqxY5tbKmCvljtDDhDZjsbimIIZImyCUukJlJOMuTH ++7ygptuMtyTC0GIbxMWBS5JH33HNH0p6XLI2vKF87B18LLmLQ61UtYr+t+l6v43XczsA76R+4ntd3 ++vQPofTVGOyilCguAg0II9ZTdc/P/Udjb/Csq1VUksizksS2XX87HM/nvnvT69/nv9d0B5v+k3+kd ++gPvlKDyO/3n+oxiqxM9pbFmHMOIoR5pCEq4oxCJa0YJgSeRCUrguwjynBbAEuFCQF1RSriz8fAFN ++2QBZ7686c2K6dniJm3bOjj24u0PzPRt6QyMgM8hu5W/plaZTd4GUWnYguRKiAEKhNQ3GwfsZeK39 ++jU9BLSm3ABGFCs7AKWXhpCIKU2fOuLPn8vVraP8yeXtxEUza1uGLymQeyqUVRooJ7reOvJYllyyp ++AvwMraN6ogU+tDTfFvy64/J6yVKKZkeHQBYKXD0Zi2qqZoQu9ZbA+GZQg8xeQuUFTk8fTGyluKu7 ++Bc1TFoXV0MsHpho10/3RStdGyaXXGdgu/jwgF92uO0A+b1p/WrJH45u/oEdlGFUfseDUqv0wBZ5F ++U7nz7VoJsxqJ67QsMxHDtzdPZ0avwkIMuCwLCue305/GwCQUJeeML0BwyEWhQEdQl959fLAbYDWP ++5QP/pH5otBRoifeC0i5rDruObduulctWMcN9c3DWYeEgR6diE8PxMYYrrnnN7vua456RtckznhtS ++Slr4TSxEe/LrEAhKFJMwjvG4SX8nRiK1bsrf27VpbD2rd2IxSbA2HzPDeTiumMiU0hy6W1bPaIpi ++vh3PgglcTvGvrQfbb9pVWpdCqjaMhsGPs9GHUTCEd5+grVPQPoUP48vpD3AxGf08Ggcfg+lpC+Xf ++pgKvB1WUe1UwoTGWwLYK6sQXepREKYNcp+lv57PabZPCehcUf41XGyFxSDPB2e8UbqlsMgH97uC7 ++HY28ht1HymkRKgo6RaEK9c2YMSkbhp+RI0k216tT+3AaY2fRrI7thXhwl9R0m8014WbFhjLaoxCw ++YGpZzm08N86Krhmfl8WKOgtBNh42XSzR1cLffKhwISHRShHhP0UrKQRXlMcYQ5anOCodCKWkSjrI ++BpqlWcjSrUUjzgQZYkhwPjzHS0/RhQ4GD5FWQ1r0phL2/BMeratZMJ353v3YJBiOpvdj1u77hISq ++t2HL/1WiZO8VpwqnyBoPg0gS/QYR1Mefoe1o61kiE6ceW4cpi9/XT9bl5WgI9n1ydMMi6qAPllFR ++Kt9zM8C7qeTYtf7t19rAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDgcfwBm4UKUgAoAAA= +diff --git 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-001187/tests/test.sh b/tasks/format-code-task-001187/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..02eec0b2186d39a673c76d976333442ba1d0e98a --- /dev/null +++ b/tasks/format-code-task-001187/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +server/service/integration_mdm_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-001187/tests/test_command.sh b/tasks/format-code-task-001187/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001187/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001312/environment/Dockerfile b/tasks/format-code-task-001312/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..56ce342623c278f244434526f662885c43dacda2 --- /dev/null +++ b/tasks/format-code-task-001312/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:50282af30688dba6b11a22bc13b0ab7712869ff1d23265e387464ec17601c2c1 diff --git a/tasks/format-code-task-001312/environment/setup/files/blocklist b/tasks/format-code-task-001312/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001312/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001312/environment/setup/setup.sh b/tasks/format-code-task-001312/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001312/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001312/tests/test.patch b/tasks/format-code-task-001312/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e758858669c1799d35ec7259e8804320c45cfa6c --- /dev/null +++ b/tasks/format-code-task-001312/tests/test.patch @@ -0,0 +1,70 @@ +diff --git a/validator_test.go b/validator_test.go +index 506413915..799efdfe4 100644 +--- a/validator_test.go ++++ b/validator_test.go +@@ -11343,6 +11343,45 @@ func TestBicIsoFormatValidation(t *testing.T) { + } + } + ++func TestRFC1035LabelFormatValidation(t *testing.T) { ++ tests := []struct { ++ value string `validate:"dns_rfc1035_label"` ++ tag string ++ expected bool ++ }{ ++ {"abc", "dns_rfc1035_label", true}, ++ {"abc-", "dns_rfc1035_label", false}, ++ {"abc-123", "dns_rfc1035_label", true}, ++ {"ABC", "dns_rfc1035_label", false}, ++ {"ABC-123", "dns_rfc1035_label", false}, ++ {"abc-abc", "dns_rfc1035_label", true}, ++ {"ABC-ABC", "dns_rfc1035_label", false}, ++ {"123-abc", "dns_rfc1035_label", false}, ++ {"", "dns_rfc1035_label", false}, ++ } ++ ++ validate := New() ++ ++ for i, test := range tests { ++ errs := validate.Var(test.value, test.tag) ++ ++ if test.expected { ++ if !IsEqual(errs, nil) { ++ t.Fatalf("Index: %d dns_rfc1035_label failed Error: %s", i, errs) ++ } ++ } else { ++ if IsEqual(errs, nil) { ++ t.Fatalf("Index: %d dns_rfc1035_label failed Error: %s", i, errs) ++ } else { ++ val := getError(errs, "", "") ++ if val.Tag() != "dns_rfc1035_label" { ++ t.Fatalf("Index: %d dns_rfc1035_label failed Error: %s", i, errs) ++ } ++ } ++ } ++ } ++} ++ + func TestPostCodeByIso3166Alpha2(t *testing.T) { + tests := map[string][]struct { + value 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+3SsQrCMBAG4Mx9ihNn25w18QEEJycRV0lM0UKbQJv6/NYuiqAuioj/t9yFBHLh ++T2q7snK7wp8y8SmyN1dqqL37OvSspsxKT7VmIZm11ILUxya60bXRNESiCSE+O/dq/0el1/xj0cbd ++PtS18S5tj++741X+zPk1f5n3+c80syD5vhEe+/P8x6PMlj6zpj0me0fDJ7CFSw6BLi1NTjRpOk+b ++frFeLljmamVsUS1DU5u4NVXpTCyDpzT59lMAAAAAAAAAAAAAAAAAAAAAAP7OGX0wUMwAKAAA +diff --git 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-001312/tests/test.sh b/tasks/format-code-task-001312/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..07a761784c98dbb73ea4183fd03567097e54041e --- /dev/null +++ b/tasks/format-code-task-001312/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' +validator_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-001312/tests/test_command.sh b/tasks/format-code-task-001312/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001312/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001315/environment/Dockerfile b/tasks/format-code-task-001315/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d9f78e86ac13a530e042990571a8386ab125d877 --- /dev/null +++ b/tasks/format-code-task-001315/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0aa94f14131eaf9db6ed0fd9654a23ba9fd7e6bd125a85cc4f87520ff3559c0a diff --git a/tasks/format-code-task-001315/environment/setup/files/blocklist b/tasks/format-code-task-001315/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001315/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001315/environment/setup/setup.sh b/tasks/format-code-task-001315/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001315/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001315/tests/test.patch b/tasks/format-code-task-001315/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..58af5b86dce53ac1dca90a07d5b00698de97a071 --- /dev/null +++ b/tasks/format-code-task-001315/tests/test.patch @@ -0,0 +1,355 @@ +diff --git a/usercase-test-coderl/syntax_parse_test.go b/usercase-test-coderl/syntax_parse_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/syntax_parse_test.go +@@ -0,0 +1,317 @@ ++package usercase_test_coderl ++ ++ ++ ++ ++ ++ ++import ( ++ "fmt" ++ "os" ++ "path/filepath" ++ "reflect" ++ "sort" ++ "testing" ++ ++ "github.com/gobwas/glob/syntax" ++ "github.com/gobwas/glob/syntax/ast" ++) ++ ++type nodeSnap struct { ++ ++ Kind ast.Kind ++ Value *valueSnap ++ Children []nodeSnap ++} ++ ++type valueSnap struct { ++ Type string ++ Text string ++ Not bool ++ Chars string ++ Lo rune ++ Hi rune ++} ++ ++func snapNode(t *testing.T, n *ast.Node) nodeSnap { ++ t.Helper() ++ if n == nil { ++ t.Fatalf("Parse returned nil node without error") ++ } ++ ++ out := nodeSnap{Kind: n.Kind} ++ switch n.Kind { ++ case ast.KindText: ++ v, ok := n.Value.(ast.Text) ++ if !ok { ++ t.Fatalf("KindText node has value type %T, want ast.Text", n.Value) ++ } ++ out.Value = &valueSnap{Type: "ast.Text", Text: v.Text} ++ case ast.KindList: ++ v, ok := n.Value.(ast.List) ++ if !ok { ++ t.Fatalf("KindList node has value type %T, want ast.List", n.Value) ++ } ++ out.Value = &valueSnap{Type: "ast.List", Not: v.Not, Chars: v.Chars} ++ case ast.KindRange: ++ v, ok := n.Value.(ast.Range) ++ if !ok { ++ t.Fatalf("KindRange node has value type %T, want ast.Range", n.Value) ++ } ++ out.Value = &valueSnap{Type: "ast.Range", Not: v.Not, Lo: v.Lo, Hi: v.Hi} ++ default: ++ ++ } ++ ++ if len(n.Children) > 0 { ++ out.Children = make([]nodeSnap, len(n.Children)) ++ for i, child := range n.Children { ++ out.Children[i] = snapNode(t, child) ++ } ++ } ++ return out ++} ++ ++func mustParseSnap(t *testing.T, pattern string) nodeSnap { ++ t.Helper() ++ n, err := syntax.Parse(pattern) ++ if err != nil { ++ t.Fatalf("Parse(%q) returned unexpected error: %v", pattern, err) ++ } ++ return snapNode(t, n) ++} ++ ++func assertParseSnap(t *testing.T, pattern string, expected nodeSnap) { ++ t.Helper() ++ actual := mustParseSnap(t, pattern) ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("Parse(%q) snapshot mismatch\nactual: %#v\nexpected: %#v", pattern, actual, expected) ++ } ++} ++ ++func assertParseError(t *testing.T, pattern string) { ++ t.Helper() ++ n, err := syntax.Parse(pattern) ++ if n != nil { ++ t.Fatalf("Parse(%q) returned node %#v on error path", pattern, snapNode(t, n)) ++ } ++ if err == nil { ++ t.Fatalf("Parse(%q) returned nil error", pattern) ++ } ++ ++} ++ ++func textNode(text string) nodeSnap { ++ return nodeSnap{Kind: ast.KindText, Value: &valueSnap{Type: "ast.Text", Text: text}} ++} ++ ++func pattern(children ...nodeSnap) nodeSnap { ++ return nodeSnap{Kind: ast.KindPattern, Children: children} ++} ++ ++func anyOf(children ...nodeSnap) nodeSnap { ++ return nodeSnap{Kind: ast.KindAnyOf, Children: children} ++} ++ ++func list(chars string, not bool) nodeSnap { ++ return nodeSnap{Kind: ast.KindList, Value: &valueSnap{Type: "ast.List", Chars: chars, Not: not}} ++} ++ ++func rangeNode(lo, hi rune, not bool) nodeSnap { ++ return nodeSnap{Kind: ast.KindRange, Value: &valueSnap{Type: "ast.Range", Lo: lo, Hi: hi, Not: not}} ++} ++ ++func anyNode() nodeSnap { ++ return nodeSnap{Kind: ast.KindAny} ++} ++ ++func superNode() nodeSnap { ++ return nodeSnap{Kind: ast.KindSuper} ++} ++ ++func singleNode() nodeSnap { ++ return nodeSnap{Kind: ast.KindSingle} ++} ++ ++func TestParseLiteralText(t *testing.T) { ++ ++ ++ assertParseSnap(t, "abc", pattern(textNode("abc"))) ++} ++ ++func TestParseAnyWildcard(t *testing.T) { ++ ++ ++ assertParseSnap(t, "a*c", pattern(textNode("a"), anyNode(), textNode("c"))) ++} ++ ++func TestParseSuperWildcard(t *testing.T) { ++ ++ ++ assertParseSnap(t, "a**c", pattern(textNode("a"), superNode(), textNode("c"))) ++} ++ ++func TestParseSingleWildcard(t *testing.T) { ++ ++ ++ assertParseSnap(t, "a?c", pattern(textNode("a"), singleNode(), textNode("c"))) ++} ++ ++func TestParseCharacterList(t *testing.T) { ++ ++ ++ assertParseSnap(t, "[az]", pattern(list("az", false))) ++} ++ ++func TestParseNegatedCharacterRange(t *testing.T) { ++ ++ ++ assertParseSnap(t, "[!a-z]", pattern(rangeNode('a', 'z', true))) ++} ++ ++func TestParseAlternativesWithSuffixWildcard(t *testing.T) { ++ ++ ++ assertParseSnap(t, "/{z,ab}*", pattern( ++ textNode("/"), ++ anyOf( ++ pattern(textNode("z")), ++ pattern(textNode("ab")), ++ ), ++ anyNode(), ++ )) ++} ++ ++func TestParseNestedAlternativesAndMixedTerms(t *testing.T) { ++ ++ ++ assertParseSnap(t, "{a,{x,y},?,[a-z],[!qwe]}", pattern( ++ anyOf( ++ pattern(textNode("a")), ++ pattern(anyOf( ++ pattern(textNode("x")), ++ pattern(textNode("y")), ++ )), ++ pattern(singleNode()), ++ pattern(rangeNode('a', 'z', false)), ++ pattern(list("qwe", true)), ++ ), ++ )) ++} ++ ++func TestParseCommaOutsideAlternativesAsText(t *testing.T) { ++ ++ ++ assertParseSnap(t, "hello,world", pattern(textNode("hello,world"))) ++} ++ ++func TestParseEscapedCommaInsideAlternativeTerms(t *testing.T) { ++ ++ ++ assertParseSnap(t, `{a\,b,c}`, pattern( ++ anyOf( ++ pattern(textNode("a,b")), ++ pattern(textNode("c")), ++ ), ++ )) ++} ++ ++func TestParseEscapedGlobOperatorsAsText(t *testing.T) { ++ ++ ++ assertParseSnap(t, `\*\?\[\{\}\\\,`, pattern(textNode(`*?[{}\,`))) ++} ++ ++func TestParseUnterminatedRangeError(t *testing.T) { ++ ++ ++ assertParseError(t, "[abc") ++} ++ ++func TestParseImpossibleRangeError(t *testing.T) { ++ ++ ++ assertParseError(t, "[z-a]") ++} ++ ++func TestParseInvalidUTF8Error(t *testing.T) { ++ ++ ++ assertParseError(t, string([]byte{0xff, 'a'})) ++} ++ ++func TestParseUnexpectedRangeTokenError(t *testing.T) { ++ ++ ++ assertParseError(t, "[a-b-c]") ++} ++ ++func TestParseReferentialTransparency(t *testing.T) { ++ first := mustParseSnap(t, "/{z,ab}*") ++ second := mustParseSnap(t, "/{z,ab}*") ++ if !reflect.DeepEqual(first, second) { ++ t.Fatalf("same input produced different AST snapshots\nfirst: %#v\nsecond: %#v", first, second) ++ } ++} ++ ++func TestParseDoesNotMutateInputString(t *testing.T) { ++ input := string([]byte(`\*\?\[\{\}\\\,`)) ++ before := string([]byte(input)) ++ _ = mustParseSnap(t, input) ++ if input != before { ++ t.Fatalf("Parse mutated input string: got %q, want %q", input, before) ++ } ++} ++ ++func TestParseNoHiddenGlobalStateAcrossCalls(t *testing.T) { ++ expected := pattern(textNode("a"), anyNode(), textNode("c")) ++ assertParseSnap(t, "a*c", expected) ++ _ = mustParseSnap(t, "/{z,ab}*") ++ _ = mustParseSnap(t, "[!a-z]") ++ _ = mustParseSnap(t, `\*\?\[\{\}\\\,`) ++ assertParseSnap(t, "a*c", expected) ++} ++ ++func TestParseDoesNotWriteCurrentWorkingDirectory(t *testing.T) { ++ originalCWD, 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(originalCWD); err != nil { ++ t.Fatalf("restore Chdir(%q) failed: %v", originalCWD, err) ++ } ++ }() ++ ++ before := snapshotCWD(t) ++ _ = mustParseSnap(t, "{a,{x,y},?,[a-z],[!qwe]}") ++ after := snapshotCWD(t) ++ if !reflect.DeepEqual(before, after) { ++ t.Fatalf("Parse changed cwd contents\nbefore: %#v\nafter: %#v", before, after) ++ } ++} ++ ++func snapshotCWD(t *testing.T) []string { ++ t.Helper() ++ var entries []string ++ err := filepath.WalkDir(".", func(path string, d os.DirEntry, err error) error { ++ if err != nil { ++ return err ++ } ++ info, err := d.Info() ++ if err != nil { ++ return err ++ } ++ entries = append(entries, fmt.Sprintf("%s|dir=%t|size=%d", filepath.ToSlash(path), d.IsDir(), info.Size())) ++ return nil ++ }) ++ if err != nil { ++ t.Fatalf("snapshot cwd failed: %v", err) ++ } ++ sort.Strings(entries) ++ return entries ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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 ++ ++REPO=/workspace/repo ++GOPATH_DIR=/tmp/fixture-gopath-gobwas-glob ++ ++rm -rf "$GOPATH_DIR" ++mkdir -p "$GOPATH_DIR/src/github.com/gobwas" ++ln -s "$REPO" "$GOPATH_DIR/src/github.com/gobwas/glob" ++ ++cd "$REPO" ++exec env \ ++ GO111MODULE=off \ ++ GOPATH="$GOPATH_DIR" \ ++ GOPROXY=off \ ++ GOSUMDB=off \ ++ GOVCS='*:off' \ ++ go test -v github.com/gobwas/glob/usercase-test-coderl diff --git a/tasks/format-code-task-001315/tests/test.sh b/tasks/format-code-task-001315/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..862ff4449ddda8a718d8b3a59820b92306dba95d --- /dev/null +++ b/tasks/format-code-task-001315/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/syntax_parse_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-001315/tests/test_command.sh b/tasks/format-code-task-001315/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001315/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-001323/environment/Dockerfile b/tasks/format-code-task-001323/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..974143c46008fb5d2c1cb05a56ad7e97b48a3fe7 --- /dev/null +++ b/tasks/format-code-task-001323/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:eccca24f1be5a4d68b50a8000556d847ee62d1b1d7d6d06e0bc547c6425f15a9 diff --git a/tasks/format-code-task-001323/environment/setup/files/blocklist b/tasks/format-code-task-001323/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001323/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001323/environment/setup/setup.sh b/tasks/format-code-task-001323/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001323/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001323/tests/test.patch b/tasks/format-code-task-001323/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0b3a445870542078243faa47da5759b0c7c4bf14 --- /dev/null +++ b/tasks/format-code-task-001323/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/conn_test.go b/conn_test.go +index 8ac32b8..b73fddd 100644 +--- a/conn_test.go ++++ b/conn_test.go +@@ -13,17 +13,43 @@ import ( + ) + + func TestSessionBus(t *testing.T) { +- _, err := SessionBus() ++ oldConn, err := SessionBus() + if err != nil { + t.Error(err) + } ++ if err = oldConn.Close(); err != nil { ++ t.Fatal(err) ++ } ++ if oldConn.Connected() { ++ t.Fatal("Should be closed") ++ } ++ newConn, err := SessionBus() ++ if err != nil { ++ t.Error(err) ++ } ++ if newConn == oldConn { ++ t.Fatal("Should get a new connection") ++ } + } + + func TestSystemBus(t *testing.T) { +- _, err := SystemBus() ++ oldConn, err := SystemBus() ++ if err != nil { ++ t.Error(err) ++ } ++ if err = oldConn.Close(); err != nil { ++ t.Fatal(err) ++ } ++ if oldConn.Connected() { ++ t.Fatal("Should be closed") ++ } ++ newConn, err := SystemBus() + if err != nil { + t.Error(err) + } ++ if newConn == oldConn { ++ t.Fatal("Should get a new connection") ++ } + } + + func TestConnectSessionBus(t *testing.T) { +@@ -34,6 +60,9 @@ func TestConnectSessionBus(t *testing.T) { + if err = conn.Close(); err != nil { + t.Fatal(err) + } ++ if conn.Connected() { ++ t.Fatal("Should be closed") ++ } + } + + func TestConnectSystemBus(t *testing.T) { +@@ -44,6 +73,9 @@ func TestConnectSystemBus(t *testing.T) { + if err = conn.Close(); err != nil { + t.Fatal(err) + } ++ if conn.Connected() { ++ t.Fatal("Should be closed") ++ } + } + + func TestSend(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+3SQU/CMBQHcM77FE+86KHbWNg4GC8av4B4M4aMtUADa7FdSUz88HaFRSVRLhBD ++/P8u6/peX9/yFk+dXPGJUJukdyqpN8rz8PT2n2E9yLM0K4oiG/n9waBIRz3KT9bRF842pSHqGa2b ++3/IOxc9U/Dn/RthmUum6LhWP7eJ4dxyaf5Hln/MfDv38h/4/6FF6vBZ+9s/nX3EKg58KHkWX9KCs ++M4KahSD7ZhtRE586S7wUtVYkLRmnlFRzujLi1UkjOM206XLb1LaYvY7kjJ7pgtiYkk1pEn8saSsl ++28yJX06srpaioZeb9joVkWdqYrO9E2vJQ6xecmmIrb+HQ6hdsF2PjO2aYcx3tgxxuxJiTWmcRTPZ ++fuWjU+ET/eTnvoPQMjnFhaGSrLBW+kJt8VDYX8W6TcZorsMBYhtilXaquR1Qm0P9J7893ibeOfse ++XkMv3du9VkpU+zndbpfaj/76pwAAAAAAAAAAAAAAAAAAAACAs/EBwev1/AAoAAA= +diff --git 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-001323/tests/test.sh b/tasks/format-code-task-001323/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..546da62a29c8e4f66c64cf885a50d142d9f8f687 --- /dev/null +++ b/tasks/format-code-task-001323/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' +conn_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-001323/tests/test_command.sh b/tasks/format-code-task-001323/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001323/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001324/environment/Dockerfile b/tasks/format-code-task-001324/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5c887c3740505ba67973034345282f1d4c1d0e57 --- /dev/null +++ b/tasks/format-code-task-001324/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:443b37c084235d6dea42c07dd92d043245bb390b79dde07c037c371083468775 diff --git a/tasks/format-code-task-001324/environment/setup/files/blocklist b/tasks/format-code-task-001324/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001324/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001324/environment/setup/setup.sh b/tasks/format-code-task-001324/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001324/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001324/tests/test.patch b/tasks/format-code-task-001324/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..04bf2a11f003f2c6b5245173061b0b142a433385 --- /dev/null +++ b/tasks/format-code-task-001324/tests/test.patch @@ -0,0 +1,579 @@ +diff --git a/usercase-test-coderl/blob_stateful_test.go b/usercase-test-coderl/blob_stateful_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/blob_stateful_test.go +@@ -0,0 +1,548 @@ ++package usercase_test_coderl ++ ++import ( ++ "bufio" ++ "bytes" ++ "os" ++ "runtime" ++ "strconv" ++ "strings" ++ "testing" ++ "time" ++ ++ imagick "gopkg.in/gographics/imagick.v2/imagick" ++) ++ ++ ++ ++ ++ ++ ++func initialize(t *testing.T) { ++ t.Helper() ++ imagick.Initialize() ++ t.Cleanup(imagick.Terminate) ++} ++ ++func requireNoError(t *testing.T, label string, err error) { ++ t.Helper() ++ if err != nil { ++ t.Fatalf("%s returned error: %T %v", label, err, err) ++ } ++} ++ ++func requireBlobPrefix(t *testing.T, label string, blob []byte, prefix []byte) { ++ t.Helper() ++ if len(blob) <= len(prefix) { ++ t.Fatalf("%s blob length = %d, want more than signature length %d", label, len(blob), len(prefix)) ++ } ++ if !bytes.HasPrefix(blob, prefix) { ++ t.Fatalf("%s blob signature = % x, want prefix % x", label, blob[:len(prefix)], prefix) ++ } ++} ++ ++func newSolidWand(t *testing.T, width, height uint, color, format string) (*imagick.MagickWand, *imagick.PixelWand) { ++ t.Helper() ++ bg := imagick.NewPixelWand() ++ if got := bg.SetColor(color); got != true { ++ t.Fatalf("PixelWand.SetColor(%q) = %v, want true", color, got) ++ } ++ mw := imagick.NewMagickWand() ++ requireNoError(t, "NewImage", mw.NewImage(width, height, bg)) ++ requireNoError(t, "SetImageFormat", mw.SetImageFormat(format)) ++ return mw, bg ++} ++ ++func TestBlobRoundTripBetweenIndependentWands(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ src, srcBg := newSolidWand(t, 3, 2, "#336699", "PNG") ++ defer src.Destroy() ++ defer srcBg.Destroy() ++ ++ if got := src.GetNumberImages(); got != 1 { ++ t.Fatalf("source image count = %d, want 1", got) ++ } ++ if got := src.GetImageWidth(); got != 3 { ++ t.Fatalf("source width = %d, want 3", got) ++ } ++ if got := src.GetImageHeight(); got != 2 { ++ t.Fatalf("source height = %d, want 2", got) ++ } ++ if got := src.GetImageFormat(); got != "PNG" { ++ t.Fatalf("source format = %q, want %q", got, "PNG") ++ } ++ ++ blob, err := src.GetImageBlob() ++ requireNoError(t, "GetImageBlob", err) ++ ++ requireBlobPrefix(t, "PNG", blob, []byte("\x89PNG\r\n\x1a\n")) ++ ++ dst := imagick.NewMagickWand() ++ defer dst.Destroy() ++ if got := dst.GetNumberImages(); got != 0 { ++ t.Fatalf("fresh destination image count = %d, want 0", got) ++ } ++ if got := dst.GetImageWidth(); got != 0 { ++ t.Fatalf("fresh destination width = %d, want 0", got) ++ } ++ if got := dst.GetImageHeight(); got != 0 { ++ t.Fatalf("fresh destination height = %d, want 0", got) ++ } ++ if got := dst.GetImageFormat(); got != "" { ++ t.Fatalf("fresh destination format = %q, want empty string", got) ++ } ++ ++ requireNoError(t, "ReadImageBlob", dst.ReadImageBlob(blob)) ++ if got := dst.GetNumberImages(); got != 1 { ++ t.Fatalf("decoded destination image count = %d, want 1", got) ++ } ++ if got := dst.GetImageWidth(); got != 3 { ++ t.Fatalf("decoded destination width = %d, want 3", got) ++ } ++ if got := dst.GetImageHeight(); got != 2 { ++ t.Fatalf("decoded destination height = %d, want 2", got) ++ } ++ if got := dst.GetImageFormat(); got != "PNG" { ++ t.Fatalf("decoded destination format = %q, want %q", got, "PNG") ++ } ++} ++ ++func TestPingImageBlobPopulatesMetadataOnlyFromBytes(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ src, srcBg := newSolidWand(t, 3, 2, "#336699", "PNG") ++ defer src.Destroy() ++ defer srcBg.Destroy() ++ blob, err := src.GetImageBlob() ++ requireNoError(t, "GetImageBlob", err) ++ ++ requireBlobPrefix(t, "PNG", blob, []byte("\x89PNG\r\n\x1a\n")) ++ ++ ping := imagick.NewMagickWand() ++ defer ping.Destroy() ++ if got := ping.GetNumberImages(); got != 0 { ++ t.Fatalf("fresh ping wand image count = %d, want 0", got) ++ } ++ requireNoError(t, "PingImageBlob", ping.PingImageBlob(blob)) ++ if got := ping.GetNumberImages(); got != 1 { ++ t.Fatalf("ping image count = %d, want 1", got) ++ } ++ if got := ping.GetImageWidth(); got != 3 { ++ t.Fatalf("ping width = %d, want 3", got) ++ } ++ if got := ping.GetImageHeight(); got != 2 { ++ t.Fatalf("ping height = %d, want 2", got) ++ } ++ if got := ping.GetImageFormat(); got != "PNG" { ++ t.Fatalf("ping format = %q, want %q", got, "PNG") ++ } ++} ++ ++func TestGetImagesBlobPreservesGifSequenceState(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ firstBg := imagick.NewPixelWand() ++ secondBg := imagick.NewPixelWand() ++ defer firstBg.Destroy() ++ defer secondBg.Destroy() ++ if got := firstBg.SetColor("red"); got != true { ++ t.Fatalf("first background SetColor = %v, want true", got) ++ } ++ if got := secondBg.SetColor("blue"); got != true { ++ t.Fatalf("second background SetColor = %v, want true", got) ++ } ++ ++ seq := imagick.NewMagickWand() ++ defer seq.Destroy() ++ requireNoError(t, "first NewImage", seq.NewImage(4, 3, firstBg)) ++ requireNoError(t, "first SetImageFormat", seq.SetImageFormat("GIF")) ++ requireNoError(t, "first SetImageDelay", seq.SetImageDelay(7)) ++ requireNoError(t, "second NewImage", seq.NewImage(5, 6, secondBg)) ++ requireNoError(t, "second SetImageFormat", seq.SetImageFormat("GIF")) ++ requireNoError(t, "second SetImageDelay", seq.SetImageDelay(11)) ++ ++ if got := seq.GetNumberImages(); got != 2 { ++ t.Fatalf("sequence image count before encode = %d, want 2", got) ++ } ++ if got := seq.GetImageWidth(); got != 5 { ++ t.Fatalf("current sequence width before encode = %d, want 5", got) ++ } ++ if got := seq.GetImageHeight(); got != 6 { ++ t.Fatalf("current sequence height before encode = %d, want 6", got) ++ } ++ if got := seq.GetImageFormat(); got != "GIF" { ++ t.Fatalf("current sequence format before encode = %q, want %q", got, "GIF") ++ } ++ if got := seq.GetImageDelay(); got != 11 { ++ t.Fatalf("current sequence delay before encode = %d, want 11", got) ++ } ++ if got := seq.GetIteratorIndex(); got != 1 { ++ t.Fatalf("current sequence iterator index before encode = %d, want 1", got) ++ } ++ ++ seq.SetFirstIterator() ++ if got := seq.GetImageWidth(); got != 4 { ++ t.Fatalf("first sequence width before encode = %d, want 4", got) ++ } ++ if got := seq.GetImageHeight(); got != 3 { ++ t.Fatalf("first sequence height before encode = %d, want 3", got) ++ } ++ if got := seq.GetImageDelay(); got != 7 { ++ t.Fatalf("first sequence delay before encode = %d, want 7", got) ++ } ++ if got := seq.GetIteratorIndex(); got != 0 { ++ t.Fatalf("first sequence iterator index before encode = %d, want 0", got) ++ } ++ ++ gifBlob, err := seq.GetImagesBlob() ++ requireNoError(t, "GetImagesBlob", err) ++ ++ if len(gifBlob) <= 6 { ++ t.Fatalf("GIF sequence blob length = %d, want more than signature length 6", len(gifBlob)) ++ } ++ if got := string(gifBlob[:3]); got != "GIF" { ++ t.Fatalf("GIF sequence signature = %q, want %q", got, "GIF") ++ } ++ ++ decoded := imagick.NewMagickWand() ++ defer decoded.Destroy() ++ requireNoError(t, "ReadImageBlob GIF sequence", decoded.ReadImageBlob(gifBlob)) ++ if got := decoded.GetNumberImages(); got != 2 { ++ t.Fatalf("decoded GIF image count at initial iterator = %d, want 2", got) ++ } ++ if got := decoded.GetImageFormat(); got != "GIF" { ++ t.Fatalf("decoded GIF current format at initial iterator = %q, want %q", got, "GIF") ++ } ++ ++ ++ decoded.SetFirstIterator() ++ if got := decoded.GetImageWidth(); got != 4 { ++ t.Fatalf("decoded GIF first width = %d, want 4", got) ++ } ++ if got := decoded.GetImageHeight(); got != 3 { ++ t.Fatalf("decoded GIF first height = %d, want 3", got) ++ } ++ ++ if got := decoded.NextImage(); got != true { ++ t.Fatalf("decoded GIF NextImage = %v, want true", got) ++ } ++ if got := decoded.GetImageWidth(); got != 5 { ++ t.Fatalf("decoded GIF second width = %d, want 5", got) ++ } ++ if got := decoded.GetImageHeight(); got != 6 { ++ t.Fatalf("decoded GIF second height = %d, want 6", got) ++ } ++ ++} ++ ++func TestGetImagesBlobForJpegSequenceReturnsValidFirstImageBlob(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ firstBg := imagick.NewPixelWand() ++ secondBg := imagick.NewPixelWand() ++ defer firstBg.Destroy() ++ defer secondBg.Destroy() ++ if got := firstBg.SetColor("yellow"); got != true { ++ t.Fatalf("first JPEG background SetColor = %v, want true", got) ++ } ++ if got := secondBg.SetColor("black"); got != true { ++ t.Fatalf("second JPEG background SetColor = %v, want true", got) ++ } ++ ++ seq := imagick.NewMagickWand() ++ defer seq.Destroy() ++ requireNoError(t, "first JPEG NewImage", seq.NewImage(8, 4, firstBg)) ++ requireNoError(t, "first JPEG SetImageFormat", seq.SetImageFormat("JPEG")) ++ requireNoError(t, "second JPEG NewImage", seq.NewImage(9, 5, secondBg)) ++ requireNoError(t, "second JPEG SetImageFormat", seq.SetImageFormat("JPEG")) ++ seq.SetFirstIterator() ++ ++ if got := seq.GetNumberImages(); got != 2 { ++ t.Fatalf("JPEG source image count = %d, want 2", got) ++ } ++ if got := seq.GetImageWidth(); got != 8 { ++ t.Fatalf("JPEG source first width = %d, want 8", got) ++ } ++ if got := seq.GetImageHeight(); got != 4 { ++ t.Fatalf("JPEG source first height = %d, want 4", got) ++ } ++ if got := seq.GetImageFormat(); got != "JPEG" { ++ t.Fatalf("JPEG source first format = %q, want %q", got, "JPEG") ++ } ++ ++ jpegBlob, err := seq.GetImagesBlob() ++ requireNoError(t, "GetImagesBlob JPEG", err) ++ ++ requireBlobPrefix(t, "JPEG fallback", jpegBlob, []byte("\xff\xd8\xff")) ++ ++ decoded := imagick.NewMagickWand() ++ defer decoded.Destroy() ++ requireNoError(t, "ReadImageBlob JPEG fallback", decoded.ReadImageBlob(jpegBlob)) ++ if got := decoded.GetNumberImages(); got != 1 { ++ t.Fatalf("decoded JPEG fallback image count = %d, want 1", got) ++ } ++ if got := decoded.GetImageWidth(); got != 8 { ++ t.Fatalf("decoded JPEG fallback width = %d, want 8", got) ++ } ++ if got := decoded.GetImageHeight(); got != 4 { ++ t.Fatalf("decoded JPEG fallback height = %d, want 4", got) ++ } ++ if got := decoded.GetImageFormat(); got != "JPEG" { ++ t.Fatalf("decoded JPEG fallback format = %q, want %q", got, "JPEG") ++ } ++} ++ ++func TestEmptyBlobInputsReturnExactPublicErrorMessage(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ readWand := imagick.NewMagickWand() ++ defer readWand.Destroy() ++ readErr := readWand.ReadImageBlob([]byte{}) ++ if readErr == nil { ++ t.Fatalf("ReadImageBlob empty error = nil, want message %q", "zero-length blob not permitted") ++ } ++ if got := readErr.Error(); got != "zero-length blob not permitted" { ++ t.Fatalf("ReadImageBlob empty error message = %q, want %q", got, "zero-length blob not permitted") ++ } ++ if got := readWand.GetNumberImages(); got != 0 { ++ t.Fatalf("read wand image count after empty blob = %d, want 0", got) ++ } ++ ++ pingWand := imagick.NewMagickWand() ++ defer pingWand.Destroy() ++ pingErr := pingWand.PingImageBlob([]byte{}) ++ if pingErr == nil { ++ t.Fatalf("PingImageBlob empty error = nil, want message %q", "zero-length blob not permitted") ++ } ++ if got := pingErr.Error(); got != "zero-length blob not permitted" { ++ t.Fatalf("PingImageBlob empty error message = %q, want %q", got, "zero-length blob not permitted") ++ } ++ if got := pingWand.GetNumberImages(); got != 0 { ++ t.Fatalf("ping wand image count after empty blob = %d, want 0", got) ++ } ++} ++ ++func TestBlobReturningMethodsRejectFreshWandWithNilBlobAndError(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ mw := imagick.NewMagickWand() ++ defer mw.Destroy() ++ if got := mw.GetNumberImages(); got != 0 { ++ t.Fatalf("fresh wand image count = %d, want 0", got) ++ } ++ if got := mw.GetImageWidth(); got != 0 { ++ t.Fatalf("fresh wand width = %d, want 0", got) ++ } ++ if got := mw.GetImageHeight(); got != 0 { ++ t.Fatalf("fresh wand height = %d, want 0", got) ++ } ++ if got := mw.GetImageFormat(); got != "" { ++ t.Fatalf("fresh wand format = %q, want empty string", got) ++ } ++ ++ blob, err := mw.GetImageBlob() ++ if blob != nil { ++ t.Fatalf("GetImageBlob on fresh wand blob = %v, want nil", blob) ++ } ++ if got := len(blob); got != 0 { ++ t.Fatalf("GetImageBlob on fresh wand blob length = %d, want 0", got) ++ } ++ ++ if err == nil { ++ t.Fatalf("GetImageBlob on fresh wand error = nil, want non-nil") ++ } ++ ++ seqBlob, seqErr := mw.GetImagesBlob() ++ if seqBlob != nil { ++ t.Fatalf("GetImagesBlob on fresh wand blob = %v, want nil", seqBlob) ++ } ++ if got := len(seqBlob); got != 0 { ++ t.Fatalf("GetImagesBlob on fresh wand blob length = %d, want 0", got) ++ } ++ ++ if seqErr == nil { ++ t.Fatalf("GetImagesBlob on fresh wand error = nil, want non-nil") ++ } ++} ++ ++func TestTwoWandsMaintainIndependentBlobState(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ a, aBg := newSolidWand(t, 3, 2, "#336699", "PNG") ++ defer a.Destroy() ++ defer aBg.Destroy() ++ blob, err := a.GetImageBlob() ++ requireNoError(t, "GetImageBlob", err) ++ ++ requireBlobPrefix(t, "independence source PNG", blob, []byte("\x89PNG\r\n\x1a\n")) ++ ++ b := imagick.NewMagickWand() ++ defer b.Destroy() ++ if got := a.GetNumberImages(); got != 1 { ++ t.Fatalf("wand a image count after creating a = %d, want 1", got) ++ } ++ if got := a.GetImageWidth(); got != 3 { ++ t.Fatalf("wand a width after creating a = %d, want 3", got) ++ } ++ if got := a.GetImageHeight(); got != 2 { ++ t.Fatalf("wand a height after creating a = %d, want 2", got) ++ } ++ if got := a.GetImageFormat(); got != "PNG" { ++ t.Fatalf("wand a format after creating a = %q, want %q", got, "PNG") ++ } ++ if got := b.GetNumberImages(); got != 0 { ++ t.Fatalf("wand b image count before read = %d, want 0", got) ++ } ++ if got := b.GetImageWidth(); got != 0 { ++ t.Fatalf("wand b width before read = %d, want 0", got) ++ } ++ if got := b.GetImageHeight(); got != 0 { ++ t.Fatalf("wand b height before read = %d, want 0", got) ++ } ++ if got := b.GetImageFormat(); got != "" { ++ t.Fatalf("wand b format before read = %q, want empty string", got) ++ } ++ ++ requireNoError(t, "ReadImageBlob into b", b.ReadImageBlob(blob)) ++ if got := b.GetNumberImages(); got != 1 { ++ t.Fatalf("wand b image count after read = %d, want 1", got) ++ } ++ if got := b.GetImageWidth(); got != 3 { ++ t.Fatalf("wand b width after read = %d, want 3", got) ++ } ++ if got := b.GetImageHeight(); got != 2 { ++ t.Fatalf("wand b height after read = %d, want 2", got) ++ } ++ if got := b.GetImageFormat(); got != "PNG" { ++ t.Fatalf("wand b format after read = %q, want %q", got, "PNG") ++ } ++} ++ ++func TestDestroyIsIdempotentForBlobWorkflowWand(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ mw, bg := newSolidWand(t, 3, 2, "#336699", "PNG") ++ defer bg.Destroy() ++ if got := mw.IsVerified(); got != true { ++ t.Fatalf("wand verified before Destroy = %v, want true", got) ++ } ++ blob, err := mw.GetImageBlob() ++ requireNoError(t, "GetImageBlob before Destroy", err) ++ ++ requireBlobPrefix(t, "blob before Destroy", blob, []byte("\x89PNG\r\n\x1a\n")) ++ ++ mw.Destroy() ++ if got := mw.IsVerified(); got != false { ++ t.Fatalf("wand verified after first Destroy = %v, want false", got) ++ } ++ mw.Destroy() ++ if got := mw.IsVerified(); got != false { ++ t.Fatalf("wand verified after second Destroy = %v, want false", got) ++ } ++} ++ ++func TestBlobWorkflowConstructUseDestroyCyclesStayResourceBounded(t *testing.T) { ++ ++ ++ initialize(t) ++ ++ for i := 0; i < 20; i++ { ++ runBlobLifecycleCycle(t) ++ } ++ runtime.GC() ++ time.Sleep(100 * time.Millisecond) ++ startRSS := vmRSSKB(t) ++ startFDs := countFDs(t) ++ startGoroutines := runtime.NumGoroutine() ++ ++ for i := 0; i < 120; i++ { ++ runBlobLifecycleCycle(t) ++ if i%20 == 0 { ++ runtime.GC() ++ } ++ } ++ runtime.GC() ++ time.Sleep(200 * time.Millisecond) ++ endRSS := vmRSSKB(t) ++ endFDs := countFDs(t) ++ endGoroutines := runtime.NumGoroutine() ++ ++ if got := int64(endRSS) - int64(startRSS); got > 12288 { ++ t.Fatalf("VmRSS growth after 120 blob lifecycle cycles = %d KiB, want <= 12288 KiB", got) ++ } ++ if got := endFDs - startFDs; got > 2 { ++ t.Fatalf("FD count growth after 120 blob lifecycle cycles = %d, want <= 2", got) ++ } ++ if got := endGoroutines - startGoroutines; got > 2 { ++ t.Fatalf("goroutine count growth after 120 blob lifecycle cycles = %d, want <= 2", got) ++ } ++} ++ ++func runBlobLifecycleCycle(t *testing.T) { ++ t.Helper() ++ bg := imagick.NewPixelWand() ++ defer bg.Destroy() ++ if got := bg.SetColor("white"); got != true { ++ t.Fatalf("cycle background SetColor = %v, want true", got) ++ } ++ mw := imagick.NewMagickWand() ++ defer mw.Destroy() ++ requireNoError(t, "cycle NewImage", mw.NewImage(128, 128, bg)) ++ requireNoError(t, "cycle SetImageFormat", mw.SetImageFormat("PNG")) ++ blob, err := mw.GetImageBlob() ++ requireNoError(t, "cycle GetImageBlob", err) ++ ++ requireBlobPrefix(t, "cycle PNG", blob, []byte("\x89PNG\r\n\x1a\n")) ++} ++ ++func vmRSSKB(t *testing.T) uint64 { ++ t.Helper() ++ f, err := os.Open("/proc/self/status") ++ requireNoError(t, "open /proc/self/status", err) ++ defer f.Close() ++ ++ scanner := bufio.NewScanner(f) ++ for scanner.Scan() { ++ line := scanner.Text() ++ if !strings.HasPrefix(line, "VmRSS:") { ++ continue ++ } ++ fields := strings.Fields(line) ++ if len(fields) != 3 { ++ t.Fatalf("VmRSS fields = %v, want [VmRSS: kB]", fields) ++ } ++ if fields[2] != "kB" { ++ t.Fatalf("VmRSS unit = %q, want %q", fields[2], "kB") ++ } ++ value, err := strconv.ParseUint(fields[1], 10, 64) ++ requireNoError(t, "parse VmRSS", err) ++ return value ++ } ++ requireNoError(t, "scan /proc/self/status", scanner.Err()) ++ t.Fatal("VmRSS entry missing from /proc/self/status") ++ return 0 ++} ++ ++func countFDs(t *testing.T) int { ++ t.Helper() ++ entries, err := os.ReadDir("/proc/self/fd") ++ requireNoError(t, "read /proc/self/fd", 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,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 GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GONOSUMDB='*' ++ ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001324/tests/test.sh b/tasks/format-code-task-001324/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8fb2d2687dff307493062530d4c098bbb9382a96 --- /dev/null +++ b/tasks/format-code-task-001324/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/blob_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-001324/tests/test_command.sh b/tasks/format-code-task-001324/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001324/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-001341/environment/Dockerfile b/tasks/format-code-task-001341/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b6f159c591bca25826bddb2d1e683ba14459a7e5 --- /dev/null +++ b/tasks/format-code-task-001341/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6ceae874dd31d8c63b723d5e1cfc3ad5bcdc90119defd1f0de683551162c324b diff --git a/tasks/format-code-task-001341/environment/setup/files/blocklist b/tasks/format-code-task-001341/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001341/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001341/environment/setup/setup.sh b/tasks/format-code-task-001341/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001341/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001341/tests/test.patch b/tasks/format-code-task-001341/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ccdb52d81aec93d9bfca236fcd7e2b9bbfa2c22 --- /dev/null +++ b/tasks/format-code-task-001341/tests/test.patch @@ -0,0 +1,286 @@ +diff --git a/usercase-test-coderl/gcs_retriever_stateful_test.go b/usercase-test-coderl/gcs_retriever_stateful_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/gcs_retriever_stateful_test.go +@@ -0,0 +1,254 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "fmt" ++ "net/http" ++ "net/http/httptest" ++ "net/http/httputil" ++ "net/url" ++ "reflect" ++ "strings" ++ "sync/atomic" ++ "testing" ++ ++ "github.com/google/bulk_fhir_tools/testhelpers" ++ gcsretriever "github.com/google/cql/retriever/gcs" ++ r4pb "github.com/google/fhir/go/proto/google/fhir/proto/r4/core/resources/bundle_and_contained_resource_go_proto" ++) ++ ++const bundleWithPatientEncounterObservation = `{ ++ "resourceType": "Bundle", ++ "type": "transaction", ++ "entry": [ ++ {"fullUrl": "fullUrl-patient", "resource": {"resourceType": "Patient", "id": "1"}}, ++ {"fullUrl": "fullUrl-encounter", "resource": {"resourceType": "Encounter", "id": "1"}}, ++ {"fullUrl": "fullUrl-observation", "resource": {"resourceType": "Observation", "id": "1"}} ++ ] ++}` ++ ++const bundleWithSecondPatientOnly = `{ ++ "resourceType": "Bundle", ++ "type": "transaction", ++ "entry": [ ++ {"fullUrl": "fullUrl-patient", "resource": {"resourceType": "Patient", "id": "2"}} ++ ] ++}` ++ ++func TestGCSRetrieverLoadsOnceAndRetrievesRequestedFHIRTypes(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ server := testhelpers.NewGCSServer(t) ++ server.AddObject("TestBucket", "TestFile", testhelpers.GCSObjectEntry{ ++ Data: []byte(bundleWithPatientEncounterObservation), ++ }) ++ endpoint, downloads := countingProxy(t, server.URL(), "/TestBucket/TestFile") ++ ++ ret, err := gcsretriever.New("gs://TestBucket/TestFile", endpoint) ++ if err != nil { ++ t.Fatalf("New(%q) returned unexpected error: %v", "gs://TestBucket/TestFile", err) ++ } ++ ++ assertInt32AtLeast(t, downloads.Load(), 1, "downloads after New") ++ downloadsAfterNew := downloads.Load() ++ ++ patients, err := ret.Retrieve(ctx, "Patient") ++ if err != nil { ++ t.Fatalf("Retrieve(ctx, %q) returned unexpected error: %v", "Patient", err) ++ } ++ assertSummary(t, patients, []string{"Patient:1"}, "Patient resources") ++ assertInt32(t, downloads.Load(), downloadsAfterNew, "downloads after Patient retrieve") ++ ++ encounters, err := ret.Retrieve(ctx, "Encounter") ++ if err != nil { ++ t.Fatalf("Retrieve(ctx, %q) returned unexpected error: %v", "Encounter", err) ++ } ++ assertSummary(t, encounters, []string{"Encounter:1"}, "Encounter resources") ++ assertInt32(t, downloads.Load(), downloadsAfterNew, "downloads after Encounter retrieve") ++ ++ conditions, err := ret.Retrieve(ctx, "Condition") ++ if err != nil { ++ t.Fatalf("Retrieve(ctx, %q) returned unexpected error: %v", "Condition", err) ++ } ++ assertSummary(t, conditions, []string{}, "Condition resources") ++ assertInt32(t, downloads.Load(), downloadsAfterNew, "downloads after Condition retrieve") ++ ++ patientsAgain, err := ret.Retrieve(ctx, "Patient") ++ if err != nil { ++ t.Fatalf("second Retrieve(ctx, %q) returned unexpected error: %v", "Patient", err) ++ } ++ assertSummary(t, patientsAgain, []string{"Patient:1"}, "Patient resources on repeated retrieve") ++ assertInt32(t, downloads.Load(), downloadsAfterNew, "downloads after repeated Patient retrieve") ++} ++ ++func TestNewRejectsMalformedGCSAccessAndInvalidBundleInputs(t *testing.T) { ++ ++ ++ server := testhelpers.NewGCSServer(t) ++ server.AddObject("TestBucket", "InvalidFile", testhelpers.GCSObjectEntry{Data: []byte(`not json`)}) ++ ++ ret, err := gcsretriever.New("not-a-gs-path", server.URL()) ++ ++ assertNilRetrieverAndErrorIdentifies(t, ret, err, [][]string{{"pars"}, {"path"}}, "malformed path") ++ ++ ret, err = gcsretriever.New("gs://TestBucket/TestFile", "://bad-endpoint") ++ ++ assertNilRetrieverAndErrorIdentifies(t, ret, err, [][]string{{"gcs", "access", "client", "endpoint"}}, "client creation") ++ ++ ret, err = gcsretriever.New("gs://TestBucket/MissingFile", server.URL()) ++ ++ assertNilRetrieverAndErrorIdentifies(t, ret, err, [][]string{{"gcs", "access", "reader", "object", "file", "missing", "not found"}}, "missing object") ++ ++ ret, err = gcsretriever.New("gs://TestBucket/InvalidFile", server.URL()) ++ ++ assertNilRetrieverAndErrorIdentifies(t, ret, err, [][]string{{"pars", "invalid", "json", "bundle"}}, "invalid bundle") ++} ++ ++func TestSeparateRetrieversKeepLoadedBundlesIndependent(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ server := testhelpers.NewGCSServer(t) ++ server.AddObject("TestBucket", "TestFile", testhelpers.GCSObjectEntry{ ++ Data: []byte(bundleWithPatientEncounterObservation), ++ }) ++ server.AddObject("OtherBucket", "OtherFile", testhelpers.GCSObjectEntry{ ++ Data: []byte(bundleWithSecondPatientOnly), ++ }) ++ ++ a, err := gcsretriever.New("gs://TestBucket/TestFile", server.URL()) ++ if err != nil { ++ t.Fatalf("New(%q) returned unexpected error: %v", "gs://TestBucket/TestFile", err) ++ } ++ b, err := gcsretriever.New("gs://OtherBucket/OtherFile", server.URL()) ++ if err != nil { ++ t.Fatalf("New(%q) returned unexpected error: %v", "gs://OtherBucket/OtherFile", err) ++ } ++ ++ aPatients, err := a.Retrieve(ctx, "Patient") ++ if err != nil { ++ t.Fatalf("a.Retrieve(ctx, %q) returned unexpected error: %v", "Patient", err) ++ } ++ assertSummary(t, aPatients, []string{"Patient:1"}, "first retriever Patient resources") ++ ++ bPatients, err := b.Retrieve(ctx, "Patient") ++ if err != nil { ++ t.Fatalf("b.Retrieve(ctx, %q) returned unexpected error: %v", "Patient", err) ++ } ++ assertSummary(t, bPatients, []string{"Patient:2"}, "second retriever Patient resources") ++ ++ aEncounters, err := a.Retrieve(ctx, "Encounter") ++ if err != nil { ++ t.Fatalf("a.Retrieve(ctx, %q) returned unexpected error: %v", "Encounter", err) ++ } ++ assertSummary(t, aEncounters, []string{"Encounter:1"}, "first retriever Encounter resources") ++ ++ bEncounters, err := b.Retrieve(ctx, "Encounter") ++ if err != nil { ++ t.Fatalf("b.Retrieve(ctx, %q) returned unexpected error: %v", "Encounter", err) ++ } ++ assertSummary(t, bEncounters, []string{}, "second retriever Encounter resources") ++} ++ ++func TestConstructRetrieveCyclesRemainUsable(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ server := testhelpers.NewGCSServer(t) ++ server.AddObject("TestBucket", "TestFile", testhelpers.GCSObjectEntry{ ++ Data: []byte(bundleWithPatientEncounterObservation), ++ }) ++ ++ ++ for i := 0; i < 8; i++ { ++ ret, err := gcsretriever.New("gs://TestBucket/TestFile", server.URL()) ++ if err != nil { ++ t.Fatalf("cycle %d: New returned unexpected error: %v", i, err) ++ } ++ patients, err := ret.Retrieve(ctx, "Patient") ++ if err != nil { ++ t.Fatalf("cycle %d: Retrieve(ctx, %q) returned unexpected error: %v", i, "Patient", err) ++ } ++ assertSummary(t, patients, []string{"Patient:1"}, fmt.Sprintf("cycle %d Patient resources", i)) ++ } ++} ++ ++func countingProxy(t *testing.T, target string, downloadPath string) (string, *atomic.Int32) { ++ t.Helper() ++ targetURL, err := url.Parse(target) ++ if err != nil { ++ t.Fatalf("url.Parse(%q) failed: %v", target, err) ++ } ++ proxy := httputil.NewSingleHostReverseProxy(targetURL) ++ var downloads atomic.Int32 ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ if r.Method == http.MethodGet && strings.HasPrefix(r.URL.Path, downloadPath) { ++ downloads.Add(1) ++ } ++ proxy.ServeHTTP(w, r) ++ })) ++ t.Cleanup(server.Close) ++ return server.URL, &downloads ++} ++ ++func assertSummary(t *testing.T, got []*r4pb.ContainedResource, want []string, label string) { ++ t.Helper() ++ if gotSummary := resourceSummary(got); !reflect.DeepEqual(gotSummary, want) { ++ t.Fatalf("%s summary = %#v, want %#v", label, gotSummary, want) ++ } ++} ++ ++func resourceSummary(resources []*r4pb.ContainedResource) []string { ++ out := make([]string, 0, len(resources)) ++ for _, r := range resources { ++ switch v := r.GetOneofResource().(type) { ++ case *r4pb.ContainedResource_Patient: ++ out = append(out, "Patient:"+v.Patient.GetId().GetValue()) ++ case *r4pb.ContainedResource_Encounter: ++ out = append(out, "Encounter:"+v.Encounter.GetId().GetValue()) ++ case *r4pb.ContainedResource_Observation: ++ out = append(out, "Observation:"+v.Observation.GetId().GetValue()) ++ default: ++ out = append(out, fmt.Sprintf("%T", v)) ++ } ++ } ++ return out ++} ++ ++func assertNilRetrieverAndErrorIdentifies(t *testing.T, ret *gcsretriever.Retriever, err error, wantAnyByGroup [][]string, label string) { ++ t.Helper() ++ if ret != nil { ++ t.Fatalf("%s: retriever = %#v, want nil", label, ret) ++ } ++ if err == nil { ++ t.Fatalf("%s: error = nil, want non-nil error identifying %v", label, wantAnyByGroup) ++ } ++ got := strings.ToLower(err.Error()) ++ for _, group := range wantAnyByGroup { ++ found := false ++ for _, want := range group { ++ if strings.Contains(got, strings.ToLower(want)) { ++ found = true ++ break ++ } ++ } ++ if !found { ++ t.Fatalf("%s: error = %q, want one of %v", label, err.Error(), group) ++ } ++ } ++} ++ ++func assertInt32(t *testing.T, got, want int32, label string) { ++ t.Helper() ++ if got != want { ++ t.Fatalf("%s = %d, want %d", label, got, want) ++ } ++} ++ ++func assertInt32AtLeast(t *testing.T, got, wantMin int32, label string) { ++ t.Helper() ++ if got < wantMin { ++ t.Fatalf("%s = %d, want at least %d", label, got, wantMin) ++ } ++} +diff --git 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 GOPATH="${GOPATH:-/root/go}" ++export GOMODCACHE="${GOMODCACHE:-/root/go/pkg/mod}" ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001341/tests/test.sh b/tasks/format-code-task-001341/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f3f7bbddb2dc66fde47f22e93e334e114cf16640 --- /dev/null +++ b/tasks/format-code-task-001341/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/gcs_retriever_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-001341/tests/test_command.sh b/tasks/format-code-task-001341/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001341/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-001347/environment/Dockerfile b/tasks/format-code-task-001347/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c619e33ea5e609ad76d7ed0c2ac6ebfefaebdb9f --- /dev/null +++ b/tasks/format-code-task-001347/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3386711d695396e7d8e01b9d442e004aac7f48cb8e9e84fc883d5175bf4b2c1d diff --git a/tasks/format-code-task-001347/environment/setup/files/blocklist b/tasks/format-code-task-001347/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001347/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001347/environment/setup/setup.sh b/tasks/format-code-task-001347/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001347/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001347/tests/test.patch b/tasks/format-code-task-001347/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b013340e9705e6426c110866c10e4a03d067306 --- /dev/null +++ b/tasks/format-code-task-001347/tests/test.patch @@ -0,0 +1,60 @@ +diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go +index f586ca8d412..2113453f739 100644 +--- a/github/github-stringify_test.go ++++ b/github/github-stringify_test.go +@@ -1781,19 +1781,22 @@ func TestWebHookCommit_String(t *testing.T) { + + func TestWebHookPayload_String(t *testing.T) { + v := WebHookPayload{ +- After: String(""), +- Before: String(""), +- Compare: String(""), +- Created: Bool(false), +- Deleted: Bool(false), +- Forced: Bool(false), +- HeadCommit: &WebHookCommit{}, +- Pusher: &User{}, +- Ref: String(""), +- Repo: &Repository{}, +- Sender: &User{}, +- } +- want := `github.WebHookPayload{After:"", Before:"", Compare:"", Created:false, Deleted:false, Forced:false, HeadCommit:github.WebHookCommit{}, Pusher:github.User{}, Ref:"", Repo:github.Repository{}, Sender:github.User{}}` ++ Action: String(""), ++ After: String(""), ++ Before: String(""), ++ Compare: String(""), ++ Created: Bool(false), ++ Deleted: Bool(false), ++ Forced: Bool(false), ++ HeadCommit: &WebHookCommit{}, ++ Installation: &Installation{}, ++ Organization: &Organization{}, ++ Pusher: &User{}, ++ Ref: String(""), ++ Repo: &Repository{}, ++ Sender: &User{}, ++ } ++ want := `github.WebHookPayload{Action:"", After:"", Before:"", Compare:"", Created:false, Deleted:false, Forced:false, HeadCommit:github.WebHookCommit{}, Installation:github.Installation{}, Organization:github.Organization{}, Pusher:github.User{}, Ref:"", Repo:github.Repository{}, Sender:github.User{}}` + if got := v.String(); got != want { + t.Errorf("WebHookPayload.String = %v, want %v", got, want) + } +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+3RwWrCQBDG8T37FIN3k921SV7Bo2Chx5C4IQZNFpKN0LdvGigtQutFKeL/d5lh ++d2Bn+aJybE4ur7pzrO5FT7Ikmevkss69Say2mc2mSaWNSfVaSXK3jX4Yh1D0Iqr3Pvw1d+3+QUXf +++YdqCPnet23RuWg43O6Na/kbbb/yT+c585Jao0TfboXfPXn+eydz8GXlFrWXz1aiuG7CYSxjWfVj ++J8vX6fCtKjfeH7fF+8kXLt+FvunqpazOi//+AQAAAAAAAAAAAAAAAPC8PgCqqbXpACgAAA== +diff --git 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-001347/tests/test.sh b/tasks/format-code-task-001347/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bd3684b34e5de1a4c630b4d44006c42eb1971239 --- /dev/null +++ b/tasks/format-code-task-001347/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' +github/github-stringify_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-001347/tests/test_command.sh b/tasks/format-code-task-001347/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001347/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001349/environment/Dockerfile b/tasks/format-code-task-001349/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..af796cad456804cb3215b0f11a823700f05af352 --- /dev/null +++ b/tasks/format-code-task-001349/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:07be268ca3fe9b835d757f2e9a91fda530e160d9c8cd60c9f163ef174e705a5e diff --git a/tasks/format-code-task-001349/environment/setup/files/blocklist b/tasks/format-code-task-001349/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001349/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001349/environment/setup/setup.sh b/tasks/format-code-task-001349/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001349/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001349/tests/test.patch b/tasks/format-code-task-001349/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1d22134bd0f28fec417e5a3651db555aa9bc49a0 --- /dev/null +++ b/tasks/format-code-task-001349/tests/test.patch @@ -0,0 +1,83 @@ +diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go +index fae13c0ef97..487104fb0d1 100644 +--- a/github/github-accessors_test.go ++++ b/github/github-accessors_test.go +@@ -15237,6 +15237,13 @@ func TestProtection_GetRequiredPullRequestReviews(tt *testing.T) { + p.GetRequiredPullRequestReviews() + } + ++func TestProtection_GetRequiredSignatures(tt *testing.T) { ++ p := &Protection{} ++ p.GetRequiredSignatures() ++ p = nil ++ p.GetRequiredSignatures() ++} ++ + func TestProtection_GetRequiredStatusChecks(tt *testing.T) { + p := &Protection{} + p.GetRequiredStatusChecks() +@@ -15258,6 +15265,16 @@ func TestProtection_GetRestrictions(tt *testing.T) { + p.GetRestrictions() + } + ++func TestProtection_GetURL(tt *testing.T) { ++ var zeroValue string ++ p := &Protection{URL: &zeroValue} ++ p.GetURL() ++ p = &Protection{} ++ p.GetURL() ++ p = nil ++ p.GetURL() ++} ++ + func TestProtectionChanges_GetAdminEnforced(tt *testing.T) { + p := &ProtectionChanges{} + p.GetAdminEnforced() +@@ -20639,6 +20656,26 @@ func TestRequiredStatusCheck_GetAppID(tt *testing.T) { + r.GetAppID() + } + ++func TestRequiredStatusChecks_GetContextsURL(tt *testing.T) { ++ var zeroValue string ++ r := &RequiredStatusChecks{ContextsURL: &zeroValue} ++ r.GetContextsURL() ++ r = &RequiredStatusChecks{} ++ r.GetContextsURL() ++ r = nil ++ r.GetContextsURL() ++} ++ ++func TestRequiredStatusChecks_GetURL(tt *testing.T) { ++ var zeroValue string ++ r := &RequiredStatusChecks{URL: &zeroValue} ++ r.GetURL() ++ r = &RequiredStatusChecks{} ++ r.GetURL() ++ r = nil ++ r.GetURL() ++} ++ + func TestRequiredStatusChecksEnforcementLevelChanges_GetFrom(tt *testing.T) { + var zeroValue string + r := &RequiredStatusChecksEnforcementLevelChanges{From: &zeroValue} +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+3RsU7DMBQF0Mz9Cqt7EyeNkw/owMJQFZijJLYSC2qr9nPFwMfjZqAIBFlaAeKe ++xZbflWz5pl3QT7JR5pgl18KjWohpjT6u0z4XBS/qkldVmfA8r3idMHG1F70TPLWOscRZS9/l5uZ/ ++VHrun5Snprf7fWtk6sfL3THXfyHW5/7Ldey/rAqeMH65J3ztn/ffSzYV3ym5GCw7bVmaDZrG0GVs ++5YJhy/t4uHWWVE/amuZG0U4dgnZK3unBtBSc8i+fQw+72+n0LUwx6jej6h/9ab6xhtQz+blcnC/Z ++6rj46a8CAAAAAAAAAAAAAAAAAAAAAPh1XgGBrkx6ACgAAA== +diff --git 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-001349/tests/test.sh b/tasks/format-code-task-001349/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..30d82edbf0d87cf27695cc90c1ddc5faec907a94 --- /dev/null +++ b/tasks/format-code-task-001349/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' +github/github-accessors_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-001349/tests/test_command.sh b/tasks/format-code-task-001349/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001349/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001378/environment/Dockerfile b/tasks/format-code-task-001378/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5bdc4efb8096c775ac1f6f4ebf644dcb356d40fe --- /dev/null +++ b/tasks/format-code-task-001378/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2c844460117ded2051b0b522708a7c2b2e00d83fbe1cfb6cc13114e012d322c3 diff --git a/tasks/format-code-task-001378/environment/setup/files/blocklist b/tasks/format-code-task-001378/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001378/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001378/environment/setup/setup.sh b/tasks/format-code-task-001378/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001378/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001378/tests/test.patch b/tasks/format-code-task-001378/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..70b9d9639a02b9bab736bc23a74c2e0f05876a1b --- /dev/null +++ b/tasks/format-code-task-001378/tests/test.patch @@ -0,0 +1,421 @@ +diff --git a/pkg/action/fsck_test.go b/pkg/action/fsck_test.go +index e4c39c64..407e56e5 100644 +--- a/pkg/action/fsck_test.go ++++ b/pkg/action/fsck_test.go +@@ -4,8 +4,13 @@ import ( + "bytes" + "context" + "flag" ++ "io" ++ "io/ioutil" + "os" ++ "path/filepath" ++ "strconv" + "strings" ++ "syscall" + "testing" + + "github.com/gopasspw/gopass/pkg/ctxutil" +@@ -40,7 +45,10 @@ func TestFsck(t *testing.T) { + // fsck + c := cli.NewContext(app, flag.NewFlagSet("default", flag.ContinueOnError), nil) + assert.NoError(t, act.Fsck(ctx, c)) +- assert.Equal(t, "Extra recipients on foo: [0xFEEDBEEF]\nPushed changes to git remote", strings.TrimSpace(buf.String())) ++ got := buf.String() ++ assert.Contains(t, got, "Extra recipients on foo: [0xFEEDBEEF]") ++ assert.Contains(t, got, "Pushed changes to git remote") ++ assert.True(t, firstOutputLineBefore(got, "Extra recipients on foo"), "fsck should print startup output before longer checks") + buf.Reset() + + // fsck fo +@@ -49,6 +57,139 @@ func TestFsck(t *testing.T) { + c = cli.NewContext(app, fs, nil) + + assert.NoError(t, act.Fsck(ctx, c)) +- assert.Equal(t, "Extra recipients on foo: [0xFEEDBEEF]\nPushed changes to git remote", strings.TrimSpace(buf.String())) ++ got = buf.String() ++ assert.Contains(t, got, "Extra recipients on foo: [0xFEEDBEEF]") ++ assert.Contains(t, got, "Pushed changes to git remote") + buf.Reset() + } ++ ++func TestFsckPrintsStartupAndProgress(t *testing.T) { ++ u := gptest.NewUnitTester(t) ++ defer u.Remove() ++ addFsckEntries(t, u, "alpha", "beta", "gamma") ++ ++ ctx := context.Background() ++ ctx = ctxutil.WithTerminal(ctx, false) ++ act, err := newMock(ctx, u) ++ assert.NoError(t, err) ++ ++ color.NoColor = true ++ app := cli.NewApp() ++ c := cli.NewContext(app, flag.NewFlagSet("default", flag.ContinueOnError), nil) ++ ++ got, err := captureProcessStdout(t, func() error { ++ return act.Fsck(ctx, c) ++ }) ++ assert.NoError(t, err) ++ assert.True(t, firstOutputLineBefore(got, "Extra recipients on foo"), "fsck should print startup output before longer checks") ++ ++ assert.True(t, hasVisibleProgressUpdate(got, len(u.Entries)+3), "fsck should report checked/total progress, got %q", got) ++} ++ ++func TestFsckSuppressesProgressWhenOutputHidden(t *testing.T) { ++ u := gptest.NewUnitTester(t) ++ defer u.Remove() ++ addFsckEntries(t, u, "alpha", "beta", "gamma") ++ ++ ctx := context.Background() ++ ctx = ctxutil.WithTerminal(ctx, false) ++ ctx = out.WithHidden(ctx, true) ++ act, err := newMock(ctx, u) ++ assert.NoError(t, err) ++ ++ color.NoColor = true ++ app := cli.NewApp() ++ c := cli.NewContext(app, flag.NewFlagSet("default", flag.ContinueOnError), nil) ++ ++ got, err := captureProcessStdout(t, func() error { ++ return act.Fsck(ctx, c) ++ }) ++ assert.NoError(t, err) ++ assert.False(t, hasVisibleProgressUpdate(got, 1), "hidden output should not leak progress, got %q", got) ++} ++ ++func addFsckEntries(t *testing.T, u *gptest.Unit, names ...string) { ++ for _, name := range names { ++ fn := filepath.Join(u.StoreDir(""), name+".txt") ++ assert.NoError(t, ioutil.WriteFile(fn, []byte("secret"), 0600)) ++ } ++} ++ ++func firstOutputLineBefore(output, later string) bool { ++ for _, line := range strings.Split(output, "\n") { ++ line = strings.TrimSpace(line) ++ if line == "" { ++ continue ++ } ++ return !strings.Contains(line, later) ++ } ++ return false ++} ++ ++func hasVisibleProgressUpdate(output string, minTotal int) bool { ++ fields := strings.FieldsFunc(output, func(r rune) bool { ++ return r < '0' || r > '9' ++ }) ++ for i := 0; i+1 < len(fields); i++ { ++ current, err := strconv.Atoi(fields[i]) ++ if err != nil { ++ continue ++ } ++ total, err := strconv.Atoi(fields[i+1]) ++ if err != nil { ++ continue ++ } ++ if current > 0 && total >= minTotal && current <= total { ++ return true ++ } ++ } ++ return false ++} ++ ++func captureProcessStdout(t *testing.T, fn func() error) (string, error) { ++ t.Helper() ++ ++ oldOut := out.Stdout ++ oldStdout := stdout ++ defer func() { ++ out.Stdout = oldOut ++ stdout = oldStdout ++ }() ++ ++ origFD, err := syscall.Dup(int(os.Stdout.Fd())) ++ if err != nil { ++ return "", err ++ } ++ defer syscall.Close(origFD) ++ ++ r, w, err := os.Pipe() ++ if err != nil { ++ return "", err ++ } ++ ++ var buf bytes.Buffer ++ done := make(chan error, 1) ++ go func() { ++ _, copyErr := io.Copy(&buf, r) ++ done <- copyErr ++ }() ++ ++ if err := syscall.Dup2(int(w.Fd()), int(os.Stdout.Fd())); err != nil { ++ _ = r.Close() ++ _ = w.Close() ++ return "", err ++ } ++ out.Stdout = os.Stdout ++ stdout = os.Stdout ++ ++ runErr := fn() ++ ++ _ = syscall.Dup2(origFD, int(os.Stdout.Fd())) ++ _ = w.Close() ++ copyErr := <-done ++ _ = r.Close() ++ if copyErr != nil { ++ return buf.String(), copyErr ++ } ++ return buf.String(), runErr ++} +diff --git a/pkg/backend/storage/fs/fsck_test.go b/pkg/backend/storage/fs/fsck_test.go +new file mode 100644 +index 00000000..f3e37056 +--- /dev/null ++++ b/pkg/backend/storage/fs/fsck_test.go +@@ -0,0 +1,28 @@ ++package fs ++ ++import ( ++ "context" ++ "io/ioutil" ++ "os" ++ "path/filepath" ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++) ++ ++func TestFsckRemovesEmptyDirectories(t *testing.T) { ++ dir, err := ioutil.TempDir("", "gopass-fsck-") ++ assert.NoError(t, err) ++ defer os.RemoveAll(dir) ++ ++ emptyDir := filepath.Join(dir, "stale-empty-dir") ++ assert.NoError(t, os.MkdirAll(emptyDir, 0700)) ++ ++ s := New(dir) ++ ++ err = s.fsckCheckDir(context.Background(), emptyDir) ++ assert.NoError(t, err) ++ ++ _, statErr := os.Stat(emptyDir) ++ assert.True(t, os.IsNotExist(statErr), "empty directory should be removed") ++} +diff --git a/pkg/store/root/fsck_test.go b/pkg/store/root/fsck_test.go +index 1c29b52f..93b61a0d 100644 +--- a/pkg/store/root/fsck_test.go ++++ b/pkg/store/root/fsck_test.go +@@ -1,13 +1,22 @@ + package root + + import ( ++ "bytes" + "context" ++ "errors" ++ "os" ++ "path/filepath" ++ "strings" + "testing" + ++ "github.com/gopasspw/gopass/pkg/backend" + "github.com/gopasspw/gopass/pkg/ctxutil" + "github.com/gopasspw/gopass/pkg/out" ++ storepkg "github.com/gopasspw/gopass/pkg/store" ++ "github.com/gopasspw/gopass/pkg/tree" + "github.com/gopasspw/gopass/tests/gptest" + ++ "github.com/fatih/color" + "github.com/stretchr/testify/assert" + ) + +@@ -24,3 +33,150 @@ func TestFsck(t *testing.T) { + + assert.NoError(t, rs.Fsck(ctx, "")) + } ++ ++func TestFsckContinuesAfterSubStoreFailureAndReturnsAllFailures(t *testing.T) { ++ u := gptest.NewUnitTester(t) ++ defer u.Remove() ++ ++ ctx := context.Background() ++ rs, err := createRootStore(ctx, u) ++ assert.NoError(t, err) ++ ++ var seen []string ++ alphaErr := errors.New("alpha injected failure") ++ betaErr := errors.New("beta injected failure") ++ ++ rs.mounts = map[string]storepkg.Store{ ++ "alpha": &recordingStore{name: "alpha", err: alphaErr, seen: &seen}, ++ "beta": &recordingStore{name: "beta", err: betaErr, seen: &seen}, ++ } ++ ++ buf := &bytes.Buffer{} ++ oldOut := out.Stdout ++ out.Stdout = buf ++ defer func() { ++ out.Stdout = oldOut ++ }() ++ color.NoColor = true ++ ++ err = rs.Fsck(ctx, "") ++ assert.Error(t, err) ++ ++ assert.Contains(t, seen, "alpha:") ++ assert.Contains(t, seen, "beta:") ++ ++ errText := err.Error() ++ assert.Contains(t, errText, "alpha injected failure") ++ assert.Contains(t, errText, "beta injected failure") ++ ++ assert.NotEmpty(t, buf.String(), "fsck should report mounted-store failures") ++} ++ ++func TestFsckPrefixesMountedStoreOutputWithAlias(t *testing.T) { ++ u := gptest.NewUnitTester(t) ++ defer u.Remove() ++ ++ ctx := context.Background() ++ ctx = backend.WithCryptoBackend(ctx, backend.Plain) ++ ctx = backend.WithRCSBackend(ctx, backend.Noop) ++ ++ rs, err := createRootStore(ctx, u) ++ assert.NoError(t, err) ++ ++ assert.NoError(t, u.InitStore("alpha")) ++ assert.NoError(t, u.InitStore("beta")) ++ assert.NoError(t, os.Chmod(filepath.Join(u.StoreDir("alpha"), "foo.txt"), 0644)) ++ assert.NoError(t, os.Chmod(filepath.Join(u.StoreDir("beta"), "foo.txt"), 0644)) ++ ++ assert.NoError(t, rs.AddMount(ctx, "alpha", u.StoreDir("alpha"))) ++ assert.NoError(t, rs.AddMount(ctx, "beta", u.StoreDir("beta"))) ++ ++ buf := &bytes.Buffer{} ++ oldOut := out.Stdout ++ out.Stdout = buf ++ defer func() { ++ out.Stdout = oldOut ++ }() ++ color.NoColor = true ++ ++ assert.NoError(t, rs.Fsck(ctx, "")) ++ ++ got := buf.String() ++ assertOutputLineWithPrefixContains(t, got, "alpha", u.StoreDir("alpha")) ++ assertOutputLineWithPrefixContains(t, got, "beta", u.StoreDir("beta")) ++} ++ ++func assertOutputLineWithPrefixContains(t *testing.T, output, alias, text string) { ++ t.Helper() ++ prefix := "[" + alias + "]" ++ for _, line := range strings.Split(output, "\n") { ++ if strings.HasPrefix(line, prefix) && strings.Contains(line, text) { ++ return ++ } ++ } ++ t.Fatalf("expected output line for %s to contain %q, got %q", alias, text, output) ++} ++ ++type recordingStore struct { ++ name string ++ err error ++ seen *[]string ++} ++ ++func (r *recordingStore) String() string { return r.name } ++ ++func (r *recordingStore) GetTemplate(context.Context, string) ([]byte, error) { return nil, nil } ++func (r *recordingStore) HasTemplate(context.Context, string) bool { return false } ++func (r *recordingStore) ListTemplates(context.Context, string) []string { return nil } ++func (r *recordingStore) LookupTemplate(context.Context, string) ([]byte, bool) { ++ return nil, false ++} ++func (r *recordingStore) RemoveTemplate(context.Context, string) error { return nil } ++func (r *recordingStore) SetTemplate(context.Context, string, []byte) error { return nil } ++func (r *recordingStore) TemplateTree(context.Context) (tree.Tree, error) { return nil, nil } ++ ++func (r *recordingStore) AddRecipient(context.Context, string) error { return nil } ++func (r *recordingStore) GetRecipients(context.Context, string) ([]string, error) { ++ return nil, nil ++} ++func (r *recordingStore) RemoveRecipient(context.Context, string) error { return nil } ++func (r *recordingStore) SaveRecipients(context.Context) error { return nil } ++func (r *recordingStore) SetRecipients(context.Context, []string) error { return nil } ++func (r *recordingStore) Recipients(context.Context) []string { return nil } ++func (r *recordingStore) ImportMissingPublicKeys(context.Context) error { return nil } ++func (r *recordingStore) ExportMissingPublicKeys(context.Context, []string) (bool, error) { ++ return false, nil ++} ++ ++func (r *recordingStore) Fsck(ctx context.Context, path string) error { ++ *r.seen = append(*r.seen, r.name+":"+path) ++ return r.err ++} ++func (r *recordingStore) Path() string { return r.name } ++func (r *recordingStore) URL() string { return r.name } ++func (r *recordingStore) RCS() backend.RCS { return nil } ++func (r *recordingStore) Crypto() backend.Crypto { return nil } ++func (r *recordingStore) Storage() backend.Storage { return nil } ++func (r *recordingStore) GitInit(context.Context, string, string) error { return nil } ++func (r *recordingStore) Alias() string { return r.name } ++func (r *recordingStore) Copy(context.Context, string, string) error { return nil } ++func (r *recordingStore) Delete(context.Context, string) error { return nil } ++func (r *recordingStore) Equals(storepkg.Store) bool { return false } ++func (r *recordingStore) Exists(context.Context, string) bool { return false } ++func (r *recordingStore) Get(context.Context, string) (storepkg.Secret, error) { ++ return nil, nil ++} ++func (r *recordingStore) GetRevision(context.Context, string, string) (storepkg.Secret, error) { ++ return nil, nil ++} ++func (r *recordingStore) Init(context.Context, string, ...string) error { return nil } ++func (r *recordingStore) Initialized(context.Context) bool { return true } ++func (r *recordingStore) IsDir(context.Context, string) bool { return false } ++func (r *recordingStore) List(context.Context, string) ([]string, error) { return nil, nil } ++func (r *recordingStore) ListRevisions(context.Context, string) ([]backend.Revision, error) { ++ return nil, nil ++} ++func (r *recordingStore) Move(context.Context, string, string) error { return nil } ++func (r *recordingStore) Set(context.Context, string, storepkg.Secret) error { return nil } ++func (r *recordingStore) Prune(context.Context, string) error { return nil } ++func (r *recordingStore) Valid() bool { 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,33 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++export GOROOT=/opt/go-1.10 ++export GOPATH=/root/go ++export GO111MODULE=off ++export PATH=$GOROOT/bin:$PATH ++ ++ ++mkdir -p /root/go/src/github.com/gopasspw ++ln -sfn /testbed /root/go/src/github.com/gopasspw/gopass ++ ++ ++rm -rf /root/.cache/go-build ++ ++cd /root/go/src/github.com/gopasspw/gopass ++ ++case "${1:-}" in ++ base) ++ go test -count=1 -v -run '^TestAction$' ./pkg/action/ ++ ;; ++ new) ++ go test -count=1 -v -run '^(TestFsck|TestFsckPrintsStartupAndProgress|TestFsckSuppressesProgressWhenOutputHidden)$' ./pkg/action/ ++ go test -count=1 -v -run '^TestFsckRemovesEmptyDirectories$' ./pkg/backend/storage/fs/ ++ go test -count=1 -v -run '^(TestFsckContinuesAfterSubStoreFailureAndReturnsAllFailures|TestFsckPrefixesMountedStoreOutputWithAlias)$' ./pkg/store/root/ ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001378/tests/test.sh b/tasks/format-code-task-001378/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..105d105c267d35bc6e5449001a91c31b66edc0d6 --- /dev/null +++ b/tasks/format-code-task-001378/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/action/fsck_test.go +pkg/backend/storage/fs/fsck_test.go +pkg/store/root/fsck_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-001378/tests/test_command.sh b/tasks/format-code-task-001378/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001378/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-001379/environment/Dockerfile b/tasks/format-code-task-001379/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..39ed2a93898630ec05e819719c24cef4007c1244 --- /dev/null +++ b/tasks/format-code-task-001379/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d9b91daecf76904db51394bd39802e06d55a9386fc3223cad28ba425d2751d1a diff --git a/tasks/format-code-task-001379/environment/setup/files/blocklist b/tasks/format-code-task-001379/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001379/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001379/environment/setup/setup.sh b/tasks/format-code-task-001379/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001379/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001379/tests/test.patch b/tasks/format-code-task-001379/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ef7a47ec9305162b79ce64025964ff3ab9c9748f --- /dev/null +++ b/tasks/format-code-task-001379/tests/test.patch @@ -0,0 +1,55 @@ +diff --git a/tests/unit/details.test.js b/tests/unit/details.test.js +index edd757a..b297a08 100644 +--- a/tests/unit/details.test.js ++++ b/tests/unit/details.test.js +@@ -88,12 +88,24 @@ describe('onEntryData', () => { + }); + + test('nested values', () => { +- expect.assertions(3); +- return details.onEntryData(loginElement, { hallo: { holla: 'waldfee' } }).then(() => { +- expect(document.getElementsByClassName('detail-key')[0].innerText).toBe('hallo:'); +- expect(document.getElementsByClassName('detail-key')[1].innerText).toBe('holla:'); +- expect(document.getElementsByClassName('detail-clickable-value')[0].innerText).toBe('waldfee'); +- }); ++ expect.assertions(9); ++ return details ++ .onEntryData(loginElement, { hallo: { holla: 'waldfee', list: ['wald', 'fee'] } }) ++ .then(() => { ++ let keys = document.getElementsByClassName('detail-key'); ++ expect(keys.length).toBe(3); ++ expect(keys[0].innerText).toBe('hallo:'); ++ expect(keys[1].innerText).toBe('holla:'); ++ expect(keys[2].innerText).toBe('list:'); ++ ++ let values = document.getElementsByClassName('detail-clickable-value'); ++ expect(values.length).toBe(3); ++ expect(values[0].innerText).toBe('waldfee'); ++ expect(values[1].innerText).toBe('wald'); ++ expect(values[2].innerText).toBe('fee'); ++ ++ expect(document.getElementsByClassName('detail-nested').length).toBe(2); ++ }); + }); + }); + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RTQ7CIBAFYNaeYi5QClTqzqs0VWrEUGoEjMcX60Jjom40Rn3fBsIM4efxRbLO ++NJ3fl+xdRDbTehyz23GcS62EmglV64oJKWtRMdJvu9GVFGK7I2K7YYiP+p7VvxS/5B+7EJvl0Pet ++NzysX3fGs/xlpS/5S5Xzn9ZSMhKvu8J9f57/0tAY/KIzE7/tyfr8H85RUfihaJOx8TxdJW9IzUvT ++7UufnMvNB9rkjXTaHcrkbczF2FoX+GmJb8Lk048DAAAAAAAAAAAAAAAAAAAAAPhxR9XshsYAKAAA +diff --git 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-001379/tests/test.sh b/tasks/format-code-task-001379/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..68dda0bf0d5e49ea5ad4c9fe0f9783507d0f42f4 --- /dev/null +++ b/tasks/format-code-task-001379/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/details.test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001379/tests/test_command.sh b/tasks/format-code-task-001379/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001379/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001382/environment/Dockerfile b/tasks/format-code-task-001382/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..dd0e9f4c361c1ec1a22bda9f20de7f49bca23f1d --- /dev/null +++ b/tasks/format-code-task-001382/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a7e2cd1f453e06ffa8a0e994858747b9fc936c7a3ac80ca3f03025179a98b282 diff --git a/tasks/format-code-task-001382/environment/setup/files/blocklist b/tasks/format-code-task-001382/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001382/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001382/environment/setup/setup.sh b/tasks/format-code-task-001382/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001382/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001382/tests/test.patch b/tasks/format-code-task-001382/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6dce124a641670893956a3f017b8fb8ce151cf01 --- /dev/null +++ b/tasks/format-code-task-001382/tests/test.patch @@ -0,0 +1,88 @@ +diff --git a/storage/cache/redis_test.go b/storage/cache/redis_test.go +index 97aceb79f..b2ed32e7c 100644 +--- a/storage/cache/redis_test.go ++++ b/storage/cache/redis_test.go +@@ -16,12 +16,16 @@ package cache + + import ( + "context" ++ "fmt" ++ "math" + "os" + "testing" ++ "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" + "github.com/zhenghaoz/gorse/base/log" ++ "google.golang.org/protobuf/proto" + ) + + var ( +@@ -55,6 +59,43 @@ func (suite *RedisTestSuite) SetupSuite() { + suite.NoError(err) + } + ++func (suite *RedisTestSuite) TestEscapeCharacters() { ++ ts := time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC) ++ ctx := context.Background() ++ for _, c := range []string{"-", ":", "."} { ++ suite.Run(c, func() { ++ collection := fmt.Sprintf("a%s1", c) ++ subset := fmt.Sprintf("b%s2", c) ++ id := fmt.Sprintf("c%s3", c) ++ err := suite.AddDocuments(ctx, collection, subset, []Document{{ ++ Id: id, ++ Score: math.MaxFloat64, ++ Categories: []string{"a", "b"}, ++ Timestamp: ts, ++ }}) ++ suite.NoError(err) ++ documents, err := suite.SearchDocuments(ctx, collection, subset, []string{"b"}, 0, -1) ++ suite.NoError(err) ++ suite.Equal([]Document{{Id: id, Score: math.MaxFloat64, Categories: []string{"a", "b"}, Timestamp: ts}}, documents) ++ ++ err = suite.UpdateDocuments(ctx, []string{collection}, id, DocumentPatch{Score: proto.Float64(1)}) ++ suite.NoError(err) ++ documents, err = suite.SearchDocuments(ctx, collection, subset, []string{"b"}, 0, -1) ++ suite.NoError(err) ++ suite.Equal([]Document{{Id: id, Score: 1, Categories: []string{"a", "b"}, Timestamp: ts}}, documents) ++ ++ err = suite.DeleteDocuments(ctx, []string{collection}, DocumentCondition{ ++ Subset: proto.String(subset), ++ Id: proto.String(id), ++ }) ++ suite.NoError(err) ++ documents, err = suite.SearchDocuments(ctx, collection, subset, []string{"b"}, 0, -1) ++ suite.NoError(err) ++ suite.Empty(documents) ++ }) ++ } ++} ++ + func TestRedis(t *testing.T) { + suite.Run(t, new(RedisTestSuite)) + } +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+3RwU7cMBAG4JzzFFOKqvbgOMk2XgECqbceEXBH2XjYtZq1V7YTAU9fJwiBQJQL ++CFX838VOYk/s+YvVYHp9yXaU2Xspk2XTzGPydJznVVOXtVKqrBdZWVWqXGTUvNuJHhlCbD1R5p2L ++/1r32vf/VPGQf+QQLzu33bZWF2Hzdv94Lf+mqu7zb5ZKpfx/qkWVUfl2R3jZJ8+/0zQHv2Kd51/p ++PDUj0hlrE6Z594e+G9v1g+Ywvz3n1ncb2jo99PyDzBVZF6ntPbf6hvxgrbHrnK93LpU5/XXx+3hP ++ul2UfqoowlTx8VwE9iN7oYq6UGI8kCtjD/enfXt5qv2F7tZ2vaFdKkwnJDWP0g59T/XJt+qI4oZt ++TsnzqiSEbnnrrLllukkXEGI+llosD+YtoWfeUZ1fmenqZ4OdqlHqwJojTU3J124eSYwk0uXoIj3c ++NaeQITrfrll2bbdhmX90kAAAAAAAAAAAAAAAAAAAAADwKf0FRkITOAAoAAA= +diff --git 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-001382/tests/test.sh b/tasks/format-code-task-001382/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca84baeee00e6edcde521842d9ac5e2def5a62de --- /dev/null +++ b/tasks/format-code-task-001382/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' +storage/cache/redis_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-001382/tests/test_command.sh b/tasks/format-code-task-001382/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001382/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001511/environment/Dockerfile b/tasks/format-code-task-001511/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e644b6217932c8144652ef8b43126843c8e30ad4 --- /dev/null +++ b/tasks/format-code-task-001511/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:92a083b70ac2b68c63d2d979be7a92010c2ce0356683426ef98d8fb09310ddf4 diff --git a/tasks/format-code-task-001511/environment/setup/files/blocklist b/tasks/format-code-task-001511/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001511/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001511/environment/setup/setup.sh b/tasks/format-code-task-001511/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001511/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001511/tests/test.patch b/tasks/format-code-task-001511/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a00dd1668f2df9405b9bfdd68583344740d43c75 --- /dev/null +++ b/tasks/format-code-task-001511/tests/test.patch @@ -0,0 +1,156 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000000..d6ba68cc9e3 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/helpers/test_service.py::test_async_set_service_schema_mixed_case_service tests/helpers/test_service.py::test_async_set_service_schema_mixed_case_domain tests/test_core.py::test_serviceregistry_supports_response_mixed_case -v"] ++} +diff --git a/tests/helpers/test_service.py b/tests/helpers/test_service.py +index 674d2e1af4c..2f331d14606 100644 +--- a/tests/helpers/test_service.py ++++ b/tests/helpers/test_service.py +@@ -762,6 +762,85 @@ async def test_async_get_all_descriptions_dynamically_created_services( + } + + ++async def test_async_set_service_schema_mixed_case_service( ++ hass: HomeAssistant, ++) -> None: ++ """Test async_set_service_schema with a mixed-case service name. ++ ++ Regression test for ++ https://github.com/home-assistant/core/issues/95957 - services with ++ upper case characters fail to register schema. ++ """ ++ logger = hass.components.logger ++ await async_setup_component(hass, logger.DOMAIN, {logger.DOMAIN: {}}) ++ ++ ++ hass.services.async_register( ++ logger.DOMAIN, ++ "Callibrate", ++ lambda x: None, ++ None, ++ SupportsResponse.OPTIONAL, ++ ) ++ ++ ++ service.async_set_service_schema( ++ hass, ++ logger.DOMAIN, ++ "Callibrate", ++ {"description": "calibrate the sensor", "fields": {}}, ++ ) ++ ++ descriptions = await service.async_get_all_descriptions(hass) ++ ++ ++ assert "callibrate" in descriptions[logger.DOMAIN] ++ ++ ++ ++ assert ( ++ descriptions[logger.DOMAIN]["callibrate"]["description"] ++ == "calibrate the sensor" ++ ) ++ assert descriptions[logger.DOMAIN]["callibrate"]["response"] == { ++ "optional": True ++ } ++ ++ ++async def test_async_set_service_schema_mixed_case_domain( ++ hass: HomeAssistant, ++) -> None: ++ """Test async_set_service_schema with a mixed-case domain name.""" ++ logger = hass.components.logger ++ await async_setup_component(hass, logger.DOMAIN, {logger.DOMAIN: {}}) ++ ++ ++ hass.services.async_register( ++ "Logger", ++ "mixed_domain_service", ++ lambda x: None, ++ None, ++ ) ++ ++ ++ ++ service.async_set_service_schema( ++ hass, ++ "Logger", ++ "mixed_domain_service", ++ {"description": "domain-cased schema"}, ++ ) ++ ++ descriptions = await service.async_get_all_descriptions(hass) ++ ++ assert "logger" in descriptions ++ assert "mixed_domain_service" in descriptions["logger"] ++ assert ( ++ descriptions["logger"]["mixed_domain_service"]["description"] ++ == "domain-cased schema" ++ ) ++ ++ + async def test_call_with_required_features(hass: HomeAssistant, mock_entities) -> None: + """Test service calls invoked only if entity has required features.""" + test_service_mock = AsyncMock(return_value=None) +diff --git a/tests/test_core.py b/tests/test_core.py +index 7e0766c8ac5..fb3acd5c621 100644 +--- a/tests/test_core.py ++++ b/tests/test_core.py +@@ -1426,6 +1426,39 @@ async def test_serviceregistry_return_response_optional( + assert response_data == expected_response_data + + ++async def test_serviceregistry_supports_response_mixed_case( ++ hass: HomeAssistant, ++) -> None: ++ """Test supports_response is case-insensitive (regression test).""" ++ ++ async def service_handler(call: ServiceCall) -> ServiceResponse: ++ return {"foo": "bar"} ++ ++ hass.services.async_register( ++ "test_domain", ++ "Test_Service", ++ service_handler, ++ supports_response=SupportsResponse.OPTIONAL, ++ ) ++ ++ ++ ++ assert ( ++ hass.services.supports_response("test_domain", "Test_Service") ++ == SupportsResponse.OPTIONAL ++ ) ++ ++ assert ( ++ hass.services.supports_response("test_domain", "test_service") ++ == SupportsResponse.OPTIONAL ++ ) ++ ++ assert ( ++ hass.services.supports_response("Test_Domain", "Test_Service") ++ == SupportsResponse.OPTIONAL ++ ) ++ ++ + async def test_config_defaults() -> None: + """Test config defaults.""" + hass = Mock() +diff --git 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/helpers/test_service.py::test_async_set_service_schema_mixed_case_service tests/helpers/test_service.py::test_async_set_service_schema_mixed_case_domain tests/test_core.py::test_serviceregistry_supports_response_mixed_case -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001511/tests/test.sh b/tasks/format-code-task-001511/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..85109f46bee5d1bd6ce4afad7439764c094b22a4 --- /dev/null +++ b/tasks/format-code-task-001511/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/helpers/test_service.py +tests/test_core.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-001511/tests/test_command.sh b/tasks/format-code-task-001511/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001511/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001517/environment/Dockerfile b/tasks/format-code-task-001517/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8c1f84370d2b706f81cd9935f54fda9200816419 --- /dev/null +++ b/tasks/format-code-task-001517/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2f07c8d1a6e423aabf2c0f5d06c713c1513412dd1fc9a601d1c7ef7ad59a4e9f diff --git a/tasks/format-code-task-001517/environment/setup/files/blocklist b/tasks/format-code-task-001517/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001517/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001517/environment/setup/setup.sh b/tasks/format-code-task-001517/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001517/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001517/tests/test.patch b/tasks/format-code-task-001517/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9c4f99261a3caec7ea7f37d6fd67e0848f1fcc3b --- /dev/null +++ b/tasks/format-code-task-001517/tests/test.patch @@ -0,0 +1,37 @@ +diff --git a/gowsdl_test.go b/gowsdl_test.go +index 5b3d45d5..f3b238c1 100644 +--- a/gowsdl_test.go ++++ b/gowsdl_test.go +@@ -83,10 +83,10 @@ func TestAttributeRef(t *testing.T) { + Status []struct { + Value string ` + "`" + `xml:",chardata" json:"-,"` + "`" + ` + +- Code string ` + "`" + `xml:"code,attr,omitempty" json:"code,omitempty"` + "`" + ` ++ Code string ` + "`" + `xml:"http://www.mnb.hu/webservices/ code,attr,omitempty" json:"code,omitempty"` + "`" + ` + } ` + "`" + `xml:"status,omitempty" json:"status,omitempty"` + "`" + ` + +- ResponseCode string ` + "`" + `xml:"responseCode,attr,omitempty" json:"responseCode,omitempty"` + "`" + ` ++ ResponseCode string ` + "`" + `xml:"http://www.mnb.hu/webservices/ responseCode,attr,omitempty" json:"responseCode,omitempty"` + "`" + ` + }` + actual = string(bytes.ReplaceAll([]byte(actual), []byte("\t"), []byte(" "))) + expected = string(bytes.ReplaceAll([]byte(expected), []byte("\t"), []byte(" "))) +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+3S3wqCMBTH8V37FIuum06cPo44JymkQv55/syLiqK8USL6fm7OYTuwA78pO1Qn ++lxbN6IutBJPEmLlOnuvcaxNqnURJHE1zWsfaCGk22+jB0PXZWUpxbtv+09zS/Y9S9/z7ouvTvK3r ++rHGqK9d7YzF/o2/5GzOd6ygOAyGD9VZ478/z3+98WzW+zbrSy52cP4EtnHds5bWVh1EqXynlfXtR ++AAAAAAAAAAAAAAAAAC8ue9YM/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 ++# Verifier for the opensource-code dataset. Exit 0 means resolved. ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001517/tests/test.sh b/tasks/format-code-task-001517/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6146ad6288dfee1ad3ca6485983c38dea0b56e39 --- /dev/null +++ b/tasks/format-code-task-001517/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' +gowsdl_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-001517/tests/test_command.sh b/tasks/format-code-task-001517/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001517/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001520/environment/Dockerfile b/tasks/format-code-task-001520/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2de858005bd3507f06894b4ebe34764f690a5853 --- /dev/null +++ b/tasks/format-code-task-001520/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1cc0652cdf01917267852a4e9e58c034122db5af4c5ff279863d3db70d216950 diff --git a/tasks/format-code-task-001520/environment/setup/files/blocklist b/tasks/format-code-task-001520/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001520/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001520/environment/setup/setup.sh b/tasks/format-code-task-001520/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001520/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001520/tests/test.patch b/tasks/format-code-task-001520/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8f5f72343895b8a4a1d9cbbcc3ccc7def35a5134 --- /dev/null +++ b/tasks/format-code-task-001520/tests/test.patch @@ -0,0 +1,179 @@ +diff --git a/test/data/expected_buildkite_pipeline.yaml b/test/data/expected_buildkite_pipeline.yaml +index 887f2d8e54..fd7935509b 100644 +--- a/test/data/expected_buildkite_pipeline.yaml ++++ b/test/data/expected_buildkite_pipeline.yaml +@@ -460,6 +460,48 @@ steps: + automatic: true + agents: + queue: cpu ++- label: ':spark: Spark Keras Rossmann Run (test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/keras_spark_rossmann_run.py --num-proc 2 --data-dir file:///data --epochs 3 --sample-rate 0.01" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: cpu ++- label: ':spark: Spark Keras Rossmann Estimator (test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/keras_spark_rossmann_estimator.py --num-proc 2 --work-dir /work --data-dir file:///data --epochs 3 --sample-rate 0.01" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: cpu ++- label: ':spark: Spark Keras MNIST (test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/keras_spark_mnist.py --num-proc 2 --work-dir /work --data-dir /data --epochs 3" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: cpu + - label: ':spark: PyTests Spark Estimators (test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0)' + command: bash -c "cd /horovod/test && pytest --forked -v --capture=no test_spark_keras.py test_spark_torch.py" + plugins: +@@ -474,6 +516,20 @@ steps: + automatic: true + agents: + queue: cpu ++- label: ':spark: Spark Torch MNIST (test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/pytorch_spark_mnist.py --num-proc 2 --work-dir /work --data-dir /data --epochs 3" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: cpu + - label: ':tensorflow: Single Keras MNIST (test-cpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_4_0-mxnet1_5_0-pyspark2_4_0)' + command: bash -c " python /horovod/examples/keras_mnist_advanced.py --epochs 3 --batch-size 64" + plugins: +@@ -600,6 +656,20 @@ steps: + automatic: true + agents: + queue: cpu ++- label: ':spark: Spark Torch MNIST (test-cpu-gloo-py3_7-tf2_2_0-keras2_3_1-torch1_5_0-mxnet1_5_0-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/pytorch_spark_mnist.py --num-proc 2 --work-dir /work --data-dir /data --epochs 3" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-cpu-gloo-py3_7-tf2_2_0-keras2_3_1-torch1_5_0-mxnet1_5_0-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: cpu + - label: ':fire: Single PyTorch MNIST (test-cpu-gloo-py3_7-tf2_2_0-keras2_3_1-torch1_5_0-mxnet1_5_0-pyspark2_4_0)' + command: bash -c " python /horovod/examples/pytorch_mnist.py --epochs 3" + plugins: +@@ -1974,6 +2044,62 @@ steps: + automatic: true + agents: + queue: 2x-gpu-g4 ++- label: ':spark: Spark Keras Rossmann Run (test-gpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/keras_spark_rossmann_run.py --num-proc 2 --data-dir file:///data --epochs 3 --sample-rate 0.01" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-gpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: 2x-gpu-g4 ++- label: ':spark: Spark Keras Rossmann Estimator (test-gpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/keras_spark_rossmann_estimator.py --num-proc 2 --work-dir /work --data-dir file:///data --epochs 3 --sample-rate 0.01" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-gpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: 2x-gpu-g4 ++- label: ':spark: Spark Keras MNIST (test-gpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/keras_spark_mnist.py --num-proc 2 --work-dir /work --data-dir /data --epochs 3" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-gpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: 2x-gpu-g4 ++- label: ':spark: Spark Torch MNIST (test-gpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0)' ++ command: bash -c "OMP_NUM_THREADS=1 python /horovod/examples/pytorch_spark_mnist.py --num-proc 2 --work-dir /work --data-dir /data --epochs 3" ++ plugins: ++ - docker-compose#v2.6.0: ++ run: test-gpu-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0 ++ config: docker-compose.test.yml ++ pull-retries: 3 ++ - ecr#v1.2.0: ++ login: true ++ timeout_in_minutes: 10 ++ retry: ++ automatic: true ++ agents: ++ queue: 2x-gpu-g4 + - label: ':tensorflow: Test TensorFlow MNIST (test-gpu-openmpi-gloo-py3_6-tf1_15_0-keras2_3_1-torch1_3_0-mxnet1_4_1-pyspark2_4_0)' + command: horovodrun -np 2 -H localhost:2 --gloo python /horovod/examples/tensorflow_mnist.py + plugins: +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+3SsQ6CMBAG4M48xRlnoQULk4Obkzq4OBmQJhCFEqhG396mgxoTddEY9f+Wa9om ++veY/P9uV23yl6n3A3oVbiZSuWrfVrYUMRchjHoUJ40LIJGEk39bRlV1n0paItVqbR/eenX8p/5K/ ++UZ1ZrXVVpXXud8Xr3niWv5DROf8wjm3+w1gMGfHXtXDfn+ff7wVZWQdZ2hXeOic3BJnKPXVodGto ++vlxMZtP5eDEZnY+urrnqNUdT6DqiQUV2aXfIjZKbrE1plN8cabD3Pv1VAAAAAAAAAAAAAAAAAAAA ++AICfcwIjqy4YACgAAA== +diff --git 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-001520/tests/test.sh b/tasks/format-code-task-001520/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3272216df80016176599df6db0692f8240908228 --- /dev/null +++ b/tasks/format-code-task-001520/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/data/expected_buildkite_pipeline.yaml +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-001520/tests/test_command.sh b/tasks/format-code-task-001520/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001520/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001529/environment/Dockerfile b/tasks/format-code-task-001529/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..af4d1c1c3b83f8f9e8d96c4940b8b1a6e60d5cc8 --- /dev/null +++ b/tasks/format-code-task-001529/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:631239f7eaddb7b4cf1358f2c5fc431b1c433fccca074e5478447a37b35e3435 diff --git a/tasks/format-code-task-001529/environment/setup/files/blocklist b/tasks/format-code-task-001529/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001529/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001529/environment/setup/setup.sh b/tasks/format-code-task-001529/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001529/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001529/tests/test.patch b/tasks/format-code-task-001529/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..df87baaaceedcb562022a2cc169290ff60ed794f --- /dev/null +++ b/tasks/format-code-task-001529/tests/test.patch @@ -0,0 +1,51 @@ +diff --git a/tests/test_modeling_tf_openai.py b/tests/test_modeling_tf_openai.py +index 87e105843478..4dc684adb77f 100644 +--- a/tests/test_modeling_tf_openai.py ++++ b/tests/test_modeling_tf_openai.py +@@ -246,14 +246,6 @@ def test_openai_gpt_sequence_classification_model(self): + config_and_inputs = self.model_tester.prepare_config_and_inputs() + self.model_tester.create_and_check_openai_gpt_for_sequence_classification(*config_and_inputs) + +- def test_mixed_precision(self): +- # TODO JP: Make OpenAIGPT float16 compliant +- pass +- +- def test_xla_mode(self): +- # TODO JP: Make OpenAIGPT XLA compliant +- pass +- + @slow + def test_model_from_pretrained(self): + for model_name in TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,16 @@ ++H4sIAAAAAAAAA+2WbW/bNhCA/Zm/4uYCg4VZii3HDZChw4puaYMla5HlW10ItHSyiEiiSlJ++fc7 ++SkriOHaaD33BMD4wIOl0vBce7+RgXos8ibBcHvW+FSPiZDptrsTutbkfT8NROJlMwpdhbzQeT09O ++ejD9ZhFtUWvDFUBPSWme0vvS+/8owX39DWoTxbIoeJkEOvt6Pr5Q/8nkOLyr/2hK8vHxy/GoB6Ov ++F8Jh/uf1f/HT0VyUR3OuMxYn0ByCOSZMy1rFePd8FCztEbGqPDZiyQ0yhmuModqYTJbgx9Bnoqik ++MqA3+vbWYKmlSnO5Aq7BpLfyG1RcB4VYYxJVCmOhBRkhlaJi7AX4vg9nYg3jU/ir0byUCeYBHc6q ++NhjlUmu4vHoPOuOJXIlyYVfQuvMSrs8gDI5/GZKz4OZ+LSy4KDEBDttGBhrzdAjrIWzoZyNJhqB5 ++UeUYrVAsMuOR1QIpxQRMxk3nUYNd7VP8otxnMOdzzDVd5UIY7cFScBtvQMYorVOgfbT2EFoLS1RN ++/omgrTD5BmRpJCCPMyia4OOcazJHjQkaDfwtSyQdsta8QN3GlvElQimb2DrLAy1hgYYboyDOML7R ++QFJbVAo7QVhJdUN3qvXrBSxVsgCjeKlTqQqKK2gi0IGssOSifaINj0watSLoSjpgQFyfvSfp6/O3 ++H66bfR/uSi8u3yFP9r/7Q9bzHO17vV/hTKp/8HONZYxvbOYiFTE3tHVD5h0KvQu2NiLXu7G+4bXm +++QUvFzVf4GWnfkH7d+t6v7tWw2Nsf2IPD+qrJx0FUZSI2ETRx1l/e9ms/4k9J/PHvg6H/Exfe3Ow ++Z449Uau9+lutHJ7CFRZyST2I6wqVKLA0PIdmBvj3M+D1h/Oume8aeGdMBNvrA+qHqJK5iDewovmh ++Oh+imwTj8FdrilpNYZXzGO0yEPqwdWtwkcs5zzu7AWu6DKI/t/yeNufjd/p4GBG3A6KRJJjCfUiD ++9uK12paieuzgVosxkVL/2kbWtmMHRTWEWX873Vm/s0V2Hmzjq4fhDbxdW4fyPejhWdu/x29X86u6 ++nTO6qWbXd/SxIBGjDwRZEWbQPgcFzebBx8brrN8sav+MPB42QbWZ9Yedpr/cuvdL6Wd0GlFZ4SfP ++Y30If/t5zH70F9bhcDgcDofD4XA4HA6Hw+FwOBwOh8PhcDi+D/8Cfl1UZAAoAAA= +diff --git 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-001529/tests/test.sh b/tasks/format-code-task-001529/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86334ab39a02de2b1d6af9ddf1e050b623a87d84 --- /dev/null +++ b/tasks/format-code-task-001529/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_modeling_tf_openai.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-001529/tests/test_command.sh b/tasks/format-code-task-001529/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001529/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001543/environment/Dockerfile b/tasks/format-code-task-001543/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f312f2130d9a579a5cc017b9c39295c3b3e9ec06 --- /dev/null +++ b/tasks/format-code-task-001543/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a7c25545d1273c8d2134dfa263dea2f7a00f6bd29f96f48d416958928e3854c5 diff --git a/tasks/format-code-task-001543/environment/setup/files/blocklist b/tasks/format-code-task-001543/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001543/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001543/environment/setup/setup.sh b/tasks/format-code-task-001543/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001543/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001543/tests/test.patch b/tasks/format-code-task-001543/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f21b9788885e9469d0ff9dcf3fe28eff4d64a777 --- /dev/null +++ b/tasks/format-code-task-001543/tests/test.patch @@ -0,0 +1,144 @@ +diff --git a/hyperspy/tests/misc/test_utils.py b/hyperspy/tests/misc/test_utils.py +index e9a7b73ce6..16bb33d68f 100644 +--- a/hyperspy/tests/misc/test_utils.py ++++ b/hyperspy/tests/misc/test_utils.py +@@ -1,17 +1,7 @@ +-from hyperspy.misc.utils import signal_range_from_roi, slugify, parse_quantity ++from hyperspy.misc.utils import slugify, parse_quantity + from hyperspy import roi + + +-def test_signal_range_from_roi(): +- sr = roi.SpanROI(20, 50) +- left, right = signal_range_from_roi(sr) +- assert left == 20 +- assert right == 50 +- left, right = signal_range_from_roi((20, 50)) +- assert left == 20 +- assert right == 50 +- +- + def test_slugify(): + assert slugify('a') == 'a' + assert slugify('1a') == '1a' +diff --git a/hyperspy/tests/utils/test_roi.py b/hyperspy/tests/utils/test_roi.py +index 4f65316f75..0d48a1278e 100644 +--- a/hyperspy/tests/utils/test_roi.py ++++ b/hyperspy/tests/utils/test_roi.py +@@ -76,6 +76,10 @@ def test_point1d_image(self): + np.testing.assert_equal( + sr.data, s.data[:, int(35 / scale), ...]) + ++ def test_point1d_getitem(self): ++ r = Point1DROI(35) ++ assert (35,) == tuple(r) ++ + def test_point2d_image(self): + s = self.s_i + r = Point2DROI(35, 40) +@@ -96,6 +100,10 @@ def test_point2d_image_sig(self): + np.testing.assert_equal( + sr.data, s.data[..., int(2 / scale), int(1 / scale)]) + ++ def test_point2d_getitem(self): ++ r = Point2DROI(1, 2) ++ assert tuple(r) == (1, 2) ++ + def test_span_spectrum_nav(self): + s = self.s_s + r = SpanROI(15, 30) +@@ -139,6 +147,10 @@ def test_span_spectrum_nav_boundary_roi(self): + assert w2._pos[0] == 0 + assert w2._size[0] == 12 + ++ def test_spanroi_getitem(self): ++ r = SpanROI(15, 30) ++ assert tuple(r) == (15, 30) ++ + def test_widget_initialisation(self): + s = Signal1D(np.arange(2 * 4 * 6).reshape(2, 4, 6)) + s.axes_manager[0].scale = 0.5 +@@ -173,6 +185,10 @@ def test_rect_image(self): + np.testing.assert_equal( + sr.data, s.data[n[1][0]:n[1][1], n[0][0]:n[0][1], ...]) + ++ def test_rectroi_getitem(self): ++ r = RectangularROI(left=2.3, top=5.6, right=3.5, bottom=12.2) ++ assert tuple(r) == (2.3, 3.5, 5.6, 12.2) ++ + def test_rect_image_boundary_roi(self): + s = self.s_i + r = RectangularROI(0, 0, 100, 100) +@@ -280,6 +296,18 @@ def test_circle_spec(self): + assert np.sum(r_signal.sum().data) == (n**2 - 3 * 4) * 4 + assert np.sum(r_ann_signal.sum().data) == 4 * 5 * 4 + ++ def test_circle_getitem(self): ++ r = CircleROI(20, 25, 20) ++ assert tuple(r) == (20, 25, 20) ++ ++ def test_annulus_getitem(self): ++ r_ann = CircleROI(20, 25, 20, 15) ++ assert tuple(r_ann) == (20, 25, 20, 15) ++ ++ def test_2d_line_getitem(self): ++ r = Line2DROI(10, 10, 150, 50, 5) ++ assert tuple(r) == (10, 10, 150, 50, 5) ++ + def test_2d_line_spec_plot(self): + r = Line2DROI(10, 10, 150, 50, 5) + s = self.s_s +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+1aTWzcxhUe7o92l5IsWZZiK23SgSRXWv1Q+6OVEKdprNipLbRWhcpI4S0CgiJn ++tbS45IaclbRBDi5qoC6QAg6KIjm2QA4NfOg1x957cZAaidkARdFTb2ocIIFPfTNc7o/WtqpCVn8y ++HyDOzJvHN8P33gy/4UrZqJmWoRJ7ex49LWQAS4UCLwH7S17PFnLZ7OJCvrCYQxmoZRYRLjy1GbWh ++5lHNxRi5jkOfpHdQ//8olFb8vbJZ8Z5GFhwm/gv5JYh/bimfE/E/DnTFX1WrdV3Ty0RVjyoXDhX/ ++Bbb+C9m8WP/HgifGX3cqVY2qJXNX0at1WnbsuXw2NwdV4tG5F5SMkldA+6AxWIAXFxYeF/98dmGx ++M/65/NJSFuHMcTjgax7/P/b3y6z81qXJ6z+NI/S39k65UT7okRB6FxmoiAzJiFhSMcLLaCWmRyRU ++iRdBgUsSxQQvk1BGL6LXpxAqpiKIyCRBUncigTlXersfZL1MBmUfSVx/tntmJGVE7kSDelhK6O3p ++WDDSicoAH3uweFJCfISTRqw5wgw5eX2i22ZxiAxd//Yj5MMRdAkZ8ZvI6CHD4WjFETJChtRToVY9 ++Uo+kE29eCfIfV63apmljWtYorjj2FqnPwWqBlePhkuPiNb5gcF7JZmawZhu4otGq5VDL3ABhYQYH ++q+vvzPJq+oyfWt7RTKptWMRPXXBcp0ZNm/j9y17d1lcocXlPW5M6rn+CNy8Ru9FOXta8MldMNm9J ++NrVTLUX5R2SbuJ7ZGM2mGgwG4guOZRGdmo7tJy9olsUtRNcJ9eUrNT45Vk9c0apV0970TzSEYbu3 ++UXnNJDt+8vuk7vFaCqZQCarya5pVI0E9uU7eqBFbJ/5A03hDIL8CPl6nLjOaUpd3ifeK5pGOnSYS ++JufzcPk5pCdBRQlSNHILlSRDupksRm+hXakYW0fpiD+krvHYGMsuNT36A/jTI23WYvDHwv5gDS6/ ++lt5FKdRa7r+IvIV+CYvjLemOFCZiHY0jGgs1aE9YK0UmkBuV0DXQ2EG70WtoR0pLq+mYH/dqVfBx ++j0sqzjZpeOJV12VxA1fxWjrqxzxilfyYCS6DR1d1S/M8VfXY5DC+8XByniXfBjHmu7butu26Wncx ++3PDmaPdjK8H4o9DtzcDlqxtoLxLrH/lscOSdxDsn3qP3Bie++mz4+feTd0+lP0eR/pG/Dg7vxaF8 ++6PWB/s8GTqFfDZyNvi+djabjflJVba0CbwtfVtWKY9QsVu9T1TdqmhX08Kn4/Y1n0YllqWpacs+y ++GTB/nnfZknSfCy9nWEc/m9pN9GUknhrZQ3B5gML+9DN+QlUNR4eBkswJsFI8v+98ta42W6NqsEoV ++GJG4LKHhuXdc8Kqfaor8RCiTzwfqqub6vXpzEXj+QFtD0TZ0P8aeyU+UNU+j1PUTHqFBZbNRiTKt ++kdZiVzTIXkXdgPz1Y6zux4NGSq1ULV51v8EcJLdi5A+qjmtuqi0Jf/APYGNjTmDuepj8TuDt77rL ++PCHBZ7fhsheVJOk+Wv8LQjfRx2joz+iZvZ54/7nPUUJakW5c/Ecf6jt1+8XfxO71nr2fHLjd+97V ++3y797sXfv/zByx9e/MPEx+OX7iUv7w0w5S+fRdL0XZS+H5VvvXB760/RsU8HRz8ZHP9ocPzGyqen ++8SenZz46PXM3NvxFrCc+cve5uS8QlHuD6JvKjZV7sTN7oyg2zmcs8N+KJ28iRzPGAfwvt5jJ7jv/ ++FaAi+N9xYGxs7EjpDNiTzUrVcSlu2zkfIWKbqSyP4++Zux3ikLdg/prSLAxzah9bZpNhezDrmJps ++kqbJWTzZpE2s0UGcOgXAgCZnZdyOyU4mxfRDLsXq7XYea6Lj7hbBCmbWoFhBI3zcLhMh52JqwLRY ++0eJdvBUQrLaOpmSfqTYqxrRDMtZ4gkqz0SJkXSZCOtYxjZaoxdEm0+f4rWYJ2w7FjZfjVFtcZ3nM ++GmoMjfdmt84s3uzuYtkSdq86Nkmnw9zZn4ZdRIdnbyOT4Z4Ve/8ts2EvtsxtnlYa7H2BaJY/D7Q1 ++btZTwEK5DjTOq9YnPXzBdHWL/Ng0YMrYcMAEI29Km34whyku5jZ/knk9DUZ2yqZexiXNtDy8QXSt ++5hFYeiSYCjY9e5I2ZtIcubGGHskssObhJp2QIQxhCJpCiFeTR4fhagrwS627laY00NlHRJhqqKC0 ++xDJX5gQPd3POqf1W2hLBICXc5qVZzJhvWz8DdeudAp5BjE5PpUMX89s6lMiuTqoUT7WI9ixuEu1u ++e+N8ZPBvHSLSmQbQ8ijRDOyU2kLSZaEKTy93elbp9FyXZ+SDt+iniq73v7dlVrRNcpTfgQ/x/S+X ++z4NeFl7/4vvfseCx8S8RjdbcI8mDw8d/MQOUUMT/GHBg/F2yCdsUcVXqarZnaex1fMikOFT8C3mU ++yeVyC3kR/+PAvxd/VTVtk6rqv3ZEPOD8l8kt5PbFfyFfyInz33GAsS+1VvU0oH/EUI0SnZrW3E0g ++vtPTWzus1mBKrmYCT1x16ArTrBCbEoMzqamxq2UTGJKHtcYZ0NwwLZPWMUsoZZ91pscp9TZQX37O ++42dOkHq6uWXSOZ59mJ+dHFsZS/+nCdL/OdrWP//+CRGswOle8cpHN8ZB+38+s9T6/48s53+LuYxY ++/8cB3cDhDwqy59RcneDWDwzbLC02THteg1P4tkaJvHbt6uUfrq4tX7380thjf4g4N9FSG8PBD8d4 ++roIbH5rmqrj1kbF5mubWvPmK6elBJtYonI3hBbNfg8sDFdcxmcLcttgkBAQEBAQEBAQEBAQEBAQE ++BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAS+HvgnIXMyoQBQAAA= +diff --git 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-001543/tests/test.sh b/tasks/format-code-task-001543/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..653ae7b401b1ff2a95e0501286f00420e263a219 --- /dev/null +++ b/tasks/format-code-task-001543/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' +hyperspy/tests/misc/test_utils.py +hyperspy/tests/utils/test_roi.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-001543/tests/test_command.sh b/tasks/format-code-task-001543/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001543/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001544/environment/Dockerfile b/tasks/format-code-task-001544/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..16e169cefe66d8038bab0ae26925d11a03e3cc49 --- /dev/null +++ b/tasks/format-code-task-001544/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0cd8543e33c6979eda2190cd64a0b4109bb34da57c599d625d7aed2aa85c9488 diff --git a/tasks/format-code-task-001544/environment/setup/files/blocklist b/tasks/format-code-task-001544/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001544/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001544/environment/setup/setup.sh b/tasks/format-code-task-001544/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001544/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001544/tests/test.patch b/tasks/format-code-task-001544/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c6113411c158c884b26d08678afba182a9329e59 --- /dev/null +++ b/tasks/format-code-task-001544/tests/test.patch @@ -0,0 +1,74 @@ +diff --git a/tests/h/schemas/api/user_test.py b/tests/h/schemas/api/user_test.py +index 31bf690a8a8..b22146324d2 100644 +--- a/tests/h/schemas/api/user_test.py ++++ b/tests/h/schemas/api/user_test.py +@@ -56,13 +56,13 @@ def test_it_raises_when_username_format_invalid(self, schema, payload): + with pytest.raises(ValidationError): + schema.validate(payload) + +- def test_it_raises_when_email_missing(self, schema, payload): ++ def test_it_raises_when_email_and_identities_missing(self, schema, payload): + del payload['email'] + + with pytest.raises(ValidationError): + schema.validate(payload) + +- def test_it_raises_when_email_empty(self, schema, payload): ++ def test_it_raises_when_email_empty_and_identities_missing(self, schema, payload): + payload['email'] = '' + + with pytest.raises(ValidationError): +@@ -102,6 +102,12 @@ def test_it_raises_when_display_name_too_long(self, schema, payload): + with pytest.raises(ValidationError): + schema.validate(payload) + ++ def test_it_allows_missing_email_if_identities_present(self, schema, payload): ++ payload['identities'] = [{'provider': 'foo', 'provider_unique_id': 'bar'}] ++ del payload['email'] ++ ++ schema.validate(payload) ++ + def test_it_allows_valid_identities(self, schema, payload): + payload['identities'] = [{'provider': 'foo', 'provider_unique_id': 'bar'}] + +@@ -109,6 +115,13 @@ def test_it_allows_valid_identities(self, schema, payload): + + assert 'identities' in appstruct + ++ def test_it_raises_when_email_missing_and_identities_empty(self, schema, payload): ++ del payload['email'] ++ payload['identities'] = [] ++ ++ with pytest.raises(ValidationError, match=".*identities.*too short.*"): ++ schema.validate(payload) ++ + def test_it_raises_when_identities_not_an_array(self, schema, payload): + payload['identities'] = 'dragnabit' + +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+2TTW/bMAyGc9avYNMBaQ+242ROBwy5bN2hl2EosF7WIVAsplZrS6oke8h+fSXn ++o9mGrZcWwzA+F1sUJZIvqXTZylosUHXZ4KUYB86Kov8Gfv72/3kxySfT8exsMhuM83w2LgZQvFhG ++B7TOcwswsFr7P/k9tf+Pkj7236Pzi1I3DVciddXzxXii//l0Ntn3vzjLQ/9fzyb5AMbPl8Lv+c/7 ++f3yULaXKltxVzKGHBBkrBfTDsETB2DF8dgif1r7SCqZpnsOJrxCM1bdY+pEDtDwJU2O4l8saoUPr ++pFanTGCXuG/SlxWY/vS0Px5vfG+R++iqOtCtd1LgPiI4DdKDa20nO3RgMaTl2NWHj1eL84vL+TDT ++xm9mNZ4fMrmCL3AEiYDhq53XEL6+hZCmYhDYhU+aTcgDP7aSzOnWlnhg7RXhpZddyHIYE75QYUrq ++GgQaVAJVKUNmJyHtxmiPKsgGRhpwd9I44HUoT6wTuTmE4pTFze0SkuS+lVHpROngY1oP17s0Q1Xb ++xejWaeXKChs+n0/SIs1Hu52gMi+raM3T6d7aSOdbhfP5OH3zaC51HV4z2u1S4ErbZh/P8kaK7crd ++17yO8dZbw3dtMP3F6i1XLmoTpuH6QN3E1e2NXO3cGl3eReEuWxX7AOGN3YSaY4FBuFh6qdWqr5d3 ++WgoHFfJuDefvftRYaQ8KUYS5qNBiUHIziKGVW7n6K7Mq22jlMm5k1jq0i7iRmjUkHRzGY3/7xREE ++QRAEQRAEQRAEQRAEQRAEQRAEQRAEQTwvD19Cum8AKAAA +diff --git 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-001544/tests/test.sh b/tasks/format-code-task-001544/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0d08b24b2adb6dd163d1106212cd704264a156d --- /dev/null +++ b/tasks/format-code-task-001544/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/h/schemas/api/user_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001544/tests/test_command.sh b/tasks/format-code-task-001544/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001544/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001572/environment/Dockerfile b/tasks/format-code-task-001572/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fe16b3b3b247a7250a5da11a37ffd946a703aa50 --- /dev/null +++ b/tasks/format-code-task-001572/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f4a0097404bed4ddfcbf0598d6ccb66dca61cfd4ed3278939950b150df05d948 diff --git a/tasks/format-code-task-001572/environment/setup/files/blocklist b/tasks/format-code-task-001572/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001572/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001572/environment/setup/setup.sh b/tasks/format-code-task-001572/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001572/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001572/tests/test.patch b/tasks/format-code-task-001572/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f3924c0b34e2fb9001a57da0146220548cac4dcc --- /dev/null +++ b/tasks/format-code-task-001572/tests/test.patch @@ -0,0 +1,173 @@ +diff --git a/test/messages/deployment-list.test.js b/test/messages/deployment-list.test.js +new file mode 100644 +index 00000000..c8bbbe2c +--- /dev/null ++++ b/test/messages/deployment-list.test.js +@@ -0,0 +1,144 @@ ++const DeploymentList = require('../../lib/messages/deployment-list'); ++ ++const baseDeployment = () => ({ ++ creator: { ++ login: 'gimenete', ++ url: 'https://github.com/gimenete', ++ avatarUrl: 'https://avatars.githubusercontent.com/u/123?v=4', ++ }, ++ ref: { name: 'foobar' }, ++ commit: { ++ message: 'Initial commit', ++ abbreviatedOid: 'c877632', ++ commitUrl: 'https://github.com/Test-slack-github/test2/commit/c877632', ++ }, ++ description: null, ++ task: 'deploy', ++ environment: 'production', ++ state: 'ACTIVE', ++ createdAt: '2018-09-20T14:35:25Z', ++ latestStatus: null, ++}); ++ ++describe('DeploymentList', () => { ++ test('renders one attachment per deployment, in order', () => { ++ const deployments = [ ++ { ...baseDeployment(), ref: { name: 'a' } }, ++ { ...baseDeployment(), ref: { name: 'b' } }, ++ { ...baseDeployment(), ref: { name: 'c' } }, ++ ]; ++ const { attachments } = new DeploymentList(deployments).toJSON(); ++ expect(attachments).toHaveLength(3); ++ expect(attachments.map(a => a.title_link)).toBeDefined(); ++ expect(attachments.map(a => a.fallback)).toEqual([ ++ 'gimenete triggered a deploy on production from a', ++ 'gimenete triggered a deploy on production from b', ++ 'gimenete triggered a deploy on production from c', ++ ]); ++ }); ++ ++ test('renders an empty attachments array for no deployments', () => { ++ expect(new DeploymentList([]).toJSON()).toEqual({ attachments: [] }); ++ }); ++ ++ test('builds the attachment from the deployment fields', () => { ++ const deployment = { ++ ...baseDeployment(), ++ description: 'Shipping the thing', ++ task: 'deploy:web', ++ environment: 'staging', ++ ref: { name: 'release-1.8' }, ++ commit: { ++ message: 'Fix the bug', ++ abbreviatedOid: '07ba0b8', ++ commitUrl: 'https://github.com/owner/repo/commit/07ba0b8', ++ }, ++ creator: { ++ login: 'octocat', ++ url: 'https://github.com/octocat', ++ avatarUrl: 'https://avatars.example/octocat.png', ++ }, ++ }; ++ const [attachment] = new DeploymentList([deployment]).toJSON().attachments; ++ ++ expect(attachment.fallback).toEqual('octocat triggered a deploy:web on staging from release-1.8'); ++ expect(attachment.pretext).toEqual('Shipping the thing'); ++ expect(attachment.author_name).toEqual('octocat'); ++ expect(attachment.author_link).toEqual('https://github.com/octocat'); ++ expect(attachment.author_icon).toEqual('https://avatars.example/octocat.png'); ++ expect(attachment.title).toEqual('release-1.8 Fix the bug'); ++ expect(attachment.title_link).toEqual('https://github.com/owner/repo/commit/07ba0b8'); ++ expect(attachment.footer).toEqual('Created'); ++ expect(attachment.footer_icon).toEqual('https://assets-cdn.github.com/favicon.ico'); ++ }); ++ ++ test('converts createdAt into unix seconds', () => { ++ const deployment = { ...baseDeployment(), createdAt: '2018-09-20T14:35:25Z' }; ++ const [attachment] = new DeploymentList([deployment]).toJSON().attachments; ++ expect(attachment.ts).toEqual(new Date('2018-09-20T14:35:25Z').getTime() / 1000); ++ }); ++ ++ test('omits pretext when the description is empty', () => { ++ const deployment = { ...baseDeployment(), description: null }; ++ const [attachment] = new DeploymentList([deployment]).toJSON().attachments; ++ expect(attachment.pretext == null || attachment.pretext === '').toBe(true); ++ }); ++ ++ test('includes Task, Environment and State short fields in order', () => { ++ const deployment = { ++ ...baseDeployment(), ++ task: 'deploy', ++ environment: 'production', ++ state: 'ACTIVE', ++ latestStatus: null, ++ }; ++ const [attachment] = new DeploymentList([deployment]).toJSON().attachments; ++ expect(attachment.fields).toEqual([ ++ { title: 'Task', value: 'deploy', short: true }, ++ { title: 'Environment', value: 'production', short: true }, ++ { title: 'State', value: 'ACTIVE', short: true }, ++ ]); ++ }); ++ ++ test('appends a Latest Status field when latestStatus is present', () => { ++ const deployment = { ++ ...baseDeployment(), ++ latestStatus: { state: 'SUCCESS', description: 'Deployed!' }, ++ }; ++ const [attachment] = new DeploymentList([deployment]).toJSON().attachments; ++ expect(attachment.fields).toContainEqual({ ++ title: 'Latest Status', ++ value: 'SUCCESS Deployed!', ++ short: true, ++ }); ++ ++ expect(attachment.fields[attachment.fields.length - 1]).toEqual({ ++ title: 'Latest Status', ++ value: 'SUCCESS Deployed!', ++ short: true, ++ }); ++ }); ++ ++ test('does not add a Latest Status field when latestStatus is null', () => { ++ const deployment = { ...baseDeployment(), latestStatus: null }; ++ const [attachment] = new DeploymentList([deployment]).toJSON().attachments; ++ expect(attachment.fields.some(field => field.title === 'Latest Status')).toBe(false); ++ }); ++ ++ test('maps each deployment state to its color', () => { ++ const colorsByState = { ++ ABANDONED: '#24292f', ++ ACTIVE: '#36a64f', ++ DESTROYED: '#cb2431', ++ ERROR: '#cb2431', ++ FAILURE: '#cb2431', ++ INACTIVE: '#24292f', ++ PENDING: '#dbab09', ++ }; ++ Object.keys(colorsByState).forEach((state) => { ++ const [attachment] = new DeploymentList([{ ...baseDeployment(), state }]) ++ .toJSON().attachments; ++ expect(attachment.color).toEqual(colorsByState[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,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++./node_modules/.bin/jest \ ++ test/messages/Message.test.js \ ++ test/messages/deployment-status.test.js \ ++ test/messages/subscription-list.test.js ++ ++ ++./node_modules/.bin/jest test/messages/deployment-list.test.js diff --git a/tasks/format-code-task-001572/tests/test.sh b/tasks/format-code-task-001572/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0f6a0bde8cc0d3900c60f513bd79aaf7583b51a6 --- /dev/null +++ b/tasks/format-code-task-001572/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/messages/deployment-list.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-001572/tests/test_command.sh b/tasks/format-code-task-001572/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001572/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001575/environment/Dockerfile b/tasks/format-code-task-001575/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b0961202d6921def004263bd27d282d92c99062a --- /dev/null +++ b/tasks/format-code-task-001575/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e7b7729906691a57a6051217c90136eef4ba76182105ddf15749115c8394e6ea diff --git a/tasks/format-code-task-001575/environment/setup/files/blocklist b/tasks/format-code-task-001575/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001575/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001575/environment/setup/setup.sh b/tasks/format-code-task-001575/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001575/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001575/tests/test.patch b/tasks/format-code-task-001575/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..76e04f979591b50b65338b03b208549785600d2d --- /dev/null +++ b/tasks/format-code-task-001575/tests/test.patch @@ -0,0 +1,54 @@ +diff --git a/internal/pkg/postprocessor/extractor/html_test.go b/internal/pkg/postprocessor/extractor/html_test.go +index a60e5c99..6d1e6040 100644 +--- a/internal/pkg/postprocessor/extractor/html_test.go ++++ b/internal/pkg/postprocessor/extractor/html_test.go +@@ -101,6 +101,7 @@ func TestHTMLAssetsAttributes(t *testing.T) { + } + } + ++ + func TestHTMLAssetsMeta(t *testing.T) { + html := ` + +@@ -111,6 +112,10 @@ func TestHTMLAssetsMeta(t *testing.T) { + + + ++ ++ ++ ++ + + + experiment +@@ -122,8 +127,8 @@ func TestHTMLAssetsMeta(t *testing.T) { + if err != nil { + t.Errorf("HTMLAssets error = %v", err) + } +- if len(assets) != 2 { +- t.Errorf("We couldn't extract all meta & link assets. Received %d, expected 2", len(assets)) ++ if len(assets) != 5 { ++ t.Errorf("We couldn't extract all meta & link assets. Received %d, expected 5", len(assets)) + } + } + +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+3RTW7CMBCG4aw5xexYEccB1xdhj0JiUVSwI9tBPX7dSFWrSi0bUFXxPpsZ+Uce ++66v30/E07Jy/qOpemsIaM9fie517bVrdllNNW9a1NnZdibnbRF9MKXdRpIoh5N/OXdv/p+rP/LNL ++edeH87nzQ52eb/fGtfy1Xn/kv7GtLflvnrStpLndCD978Pz7Qebg925YHIK8t7K6SK2OPrvou5Ma ++Xw5qDCmPMfQupRCVe82x63PpZBUnL8ttubVc/PVXAAAAAAAAAAAAAAAAgIfzBjVRbeEAKAAA +diff --git 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-001575/tests/test.sh b/tasks/format-code-task-001575/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7edfdd742cbc80ac5363ec961d40637dbd79bd9b --- /dev/null +++ b/tasks/format-code-task-001575/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/pkg/postprocessor/extractor/html_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-001575/tests/test_command.sh b/tasks/format-code-task-001575/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001575/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001581/environment/Dockerfile b/tasks/format-code-task-001581/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1922c375c0b6dd45cebf32f8d5b37316f6ac967f --- /dev/null +++ b/tasks/format-code-task-001581/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5370662d6fe228b1578c1b8ae8f1e761479d726f45f4750f5072b4fb56cc5430 diff --git a/tasks/format-code-task-001581/environment/setup/files/blocklist b/tasks/format-code-task-001581/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001581/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001581/environment/setup/setup.sh b/tasks/format-code-task-001581/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001581/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001581/tests/test.patch b/tasks/format-code-task-001581/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..72e91906da14492938d17a45665eba3e53612075 --- /dev/null +++ b/tasks/format-code-task-001581/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/db/kvstore4trie_test.go b/db/kvstore4trie_test.go +new file mode 100644 +index 0000000000..c38db5bc41 +--- /dev/null ++++ b/db/kvstore4trie_test.go +@@ -0,0 +1,29 @@ ++ ++ ++ ++ ++ ++ ++package db ++ ++import ( ++ "testing" ++ ++ "github.com/pkg/errors" ++ ++ "github.com/stretchr/testify/require" ++) ++ ++func TestKVStoreForTrie_ErrNotExist(t *testing.T) { ++ store, err := NewKVStoreForTrie("test", NewMemKVStore()) ++ require.NoError(t, err) ++ require.NoError(t, store.Put([]byte("key"), []byte("value1"))) ++ require.NoError(t, store.Flush()) ++ ++ require.NoError(t, store.Delete([]byte("key"))) ++ _, err = store.Get([]byte("key")) ++ require.Equal(t, ErrNotExist, errors.Cause(err)) ++ ++ _, err = store.Get([]byte("key1")) ++ require.Equal(t, ErrNotExist, errors.Cause(err)) ++} +diff --git a/state/factory/factory_test.go b/state/factory/factory_test.go +index bf3b798575..c113757d96 100644 +--- a/state/factory/factory_test.go ++++ b/state/factory/factory_test.go +@@ -671,6 +671,30 @@ func testGetDB(ws WorkingSet, t *testing.T) { + require.Equal(memDB, ws.GetDB()) + } + ++func TestDeleteAndPutSameKey(t *testing.T) { ++ testDeleteAndPutSameKey := func(t *testing.T, ws WorkingSet) { ++ key := hash.Hash160b([]byte("test")) ++ acc := state.Account{ ++ Nonce: 1, ++ } ++ require.NoError(t, ws.PutState(key, acc)) ++ require.NoError(t, ws.DelState(key)) ++ require.Equal(t, state.ErrStateNotExist, errors.Cause(ws.State(key, &acc))) ++ require.Equal(t, state.ErrStateNotExist, errors.Cause(ws.State(hash.Hash160b([]byte("other")), &acc))) ++ } ++ t.Run("workingSet", func(t *testing.T) { ++ sf, err := NewFactory(config.Default, InMemTrieOption()) ++ require.NoError(t, err) ++ ws, err := sf.NewWorkingSet() ++ require.NoError(t, err) ++ testDeleteAndPutSameKey(t, ws) ++ }) ++ t.Run("stateTx", func(t *testing.T) { ++ ws := newStateTX(0, db.NewMemKVStore(), nil) ++ testDeleteAndPutSameKey(t, ws) ++ }) ++} ++ + func BenchmarkInMemRunAction(b *testing.B) { + cfg := config.Default + sf, err := NewFactory(cfg, InMemTrieOption()) +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+3S3W/aMBAA8Dz7r7jBXhPjsWRPPCCVbRLbqATtK8rHBbwmNrIvVfnvZ6AqVaV+ ++TCpqp90vD3bOPtvJOSk63VRLNNcyOpVB8CVN923wsN33VfpJqWz3ZNEg9AZZBOnJTnRP5yl3AJGz ++lp6a99z4Pyo51p/Q07K0bZubKvHr19vjufpn6fBYfxXi6nOmhhEMXu8Ij/vP69//IAttZJH7tfBI ++EKMQZQX7y1BgJUQf5iHcbeDb7Hy8+A5+2zbaXEFtHdBae9g4jFtbdQ3u+vY3liTwZmMd3aaM5O7f ++yZU9hpVSP2dnFz8mI1vXor2qtIN4A72PhwzpXSlXmtZdkYQLKbWlkHpYuycaA7Gvzd0ZX5R2eIlL ++67C3/8K/T1pZ2O0I8TWEUGdopCCRVSEhdp2BRRibXs4pTP5q3cJpXE6c+2VpcqM9PZIdLh+hrPMy ++pG3vLXSGDRKOTXXe0TxvcYpb8dZXhTHGGGOMMcYYY4wxxhhjjDHGGGOMvUN/AJZyBGoAKAAA +diff --git 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-001581/tests/test.sh b/tasks/format-code-task-001581/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e48735583f877f2ce35a3e8cda28af6bc13d13fc --- /dev/null +++ b/tasks/format-code-task-001581/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' +db/kvstore4trie_test.go +state/factory/factory_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-001581/tests/test_command.sh b/tasks/format-code-task-001581/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001581/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001712/environment/Dockerfile b/tasks/format-code-task-001712/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6676c83885891c2fe8e9a6b0563ea114187d5fb3 --- /dev/null +++ b/tasks/format-code-task-001712/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:164b6e702756eb8a037aad01ff5b765bdb32a8b714b3339a6367a507920a8d65 diff --git a/tasks/format-code-task-001712/environment/setup/files/blocklist b/tasks/format-code-task-001712/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001712/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001712/environment/setup/setup.sh b/tasks/format-code-task-001712/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001712/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001712/tests/test.patch b/tasks/format-code-task-001712/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7057083c824b883b77d6db31fb620cf62028f2fb --- /dev/null +++ b/tasks/format-code-task-001712/tests/test.patch @@ -0,0 +1,369 @@ +diff --git a/usercase-test-coderl/node_key_iterator_test.go b/usercase-test-coderl/node_key_iterator_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/node_key_iterator_test.go +@@ -0,0 +1,340 @@ ++package usercase_test_coderl ++ ++import ( ++ "testing" ++ ++ "github.com/krotik/eliasdb/graph" ++ "github.com/krotik/eliasdb/graph/data" ++ "github.com/krotik/eliasdb/graph/graphstorage" ++ graphutil "github.com/krotik/eliasdb/graph/util" ++ "github.com/krotik/eliasdb/storage" ++) ++ ++type nodeSpec struct { ++ key string ++ kind string ++} ++ ++func newManagerWithNodes(t *testing.T, storageName string, nodes []nodeSpec) (*graph.Manager, graphstorage.Storage) { ++ t.Helper() ++ ++ gs := graphstorage.NewMemoryGraphStorage(storageName) ++ gm := graph.NewGraphManager(gs) ++ ++ for _, spec := range nodes { ++ node := data.NewGraphNode() ++ node.SetAttr("key", spec.key) ++ node.SetAttr("kind", spec.kind) ++ if err := gm.StoreNode("main", node); err != nil { ++ t.Fatalf("StoreNode(%q, %q) error = %v, want nil", spec.key, spec.kind, err) ++ } ++ } ++ ++ return gm, gs ++} ++ ++func assertNilIteratorAndNilError(t *testing.T, it *graph.NodeKeyIterator, err error) { ++ t.Helper() ++ ++ if it != nil { ++ t.Fatalf("iterator nil = false, want true") ++ } ++ if err != nil { ++ t.Fatalf("error = %v, want nil", err) ++ } ++} ++ ++func assertReadingGraphError(t *testing.T, got error) { ++ t.Helper() ++ ++ ge, ok := got.(*graphutil.GraphError) ++ if !ok { ++ t.Fatalf("error type = %T, want *util.GraphError", got) ++ } ++ if ge.Type != graphutil.ErrReading { ++ t.Fatalf("GraphError.Type = %v, want %v", ge.Type, graphutil.ErrReading) ++ } ++ ++} ++ ++func TestNodeKeyIteratorSessionScansOnlyRequestedKind(t *testing.T) { ++ ++ ++ gm, gs := newManagerWithNodes(t, "accept-session", []nodeSpec{ ++ {key: "123", kind: "mykind"}, ++ {key: "789", kind: "mykind"}, ++ {key: "456", kind: "mykind2"}, ++ }) ++ defer gs.Close() ++ ++ it, err := gm.NodeKeyIterator("main", "mykind") ++ if err != nil { ++ t.Fatalf("NodeKeyIterator error = %v, want nil", err) ++ } ++ if it == nil { ++ t.Fatalf("iterator nil = true, want false") ++ } ++ if it.HasNext() != true { ++ t.Fatalf("fresh HasNext() = false, want true") ++ } ++ if it.LastError != nil { ++ t.Fatalf("fresh LastError = %v, want nil", it.LastError) ++ } ++ if it.Error() != nil { ++ t.Fatalf("fresh Error() = %v, want nil", it.Error()) ++ } ++ ++ if got := it.Next(); got != "123" { ++ t.Fatalf("first Next() = %q, want %q", got, "123") ++ } ++ if it.HasNext() != true { ++ t.Fatalf("HasNext() after first Next = false, want true") ++ } ++ if it.LastError != nil { ++ t.Fatalf("LastError after first Next = %v, want nil", it.LastError) ++ } ++ if it.Error() != nil { ++ t.Fatalf("Error() after first Next = %v, want nil", it.Error()) ++ } ++ ++ if got := it.Next(); got != "789" { ++ t.Fatalf("second Next() = %q, want %q", got, "789") ++ } ++ if it.HasNext() != false { ++ t.Fatalf("HasNext() after second Next = true, want false") ++ } ++ if it.LastError != nil { ++ t.Fatalf("LastError after second Next = %v, want nil", it.LastError) ++ } ++ if it.Error() != nil { ++ t.Fatalf("Error() after second Next = %v, want nil", it.Error()) ++ } ++ ++ if got := it.Next(); got != "" { ++ t.Fatalf("third Next() = %q, want empty string", got) ++ } ++ if it.HasNext() != false { ++ t.Fatalf("HasNext() after exhaustion = true, want false") ++ } ++ if it.LastError != nil { ++ t.Fatalf("LastError after exhaustion = %v, want nil", it.LastError) ++ } ++ if it.Error() != nil { ++ t.Fatalf("Error() after exhaustion = %v, want nil", it.Error()) ++ } ++ ++ if got := it.Next(); got != "" { ++ t.Fatalf("fourth Next() = %q, want empty string", got) ++ } ++ if it.HasNext() != false { ++ t.Fatalf("HasNext() after repeated exhaustion = true, want false") ++ } ++ if it.LastError != nil { ++ t.Fatalf("LastError after repeated exhaustion = %v, want nil", it.LastError) ++ } ++ if it.Error() != nil { ++ t.Fatalf("Error() after repeated exhaustion = %v, want nil", it.Error()) ++ } ++} ++ ++func TestNodeKeyIteratorMissingStorageReturnsNilNil(t *testing.T) { ++ ++ ++ gm, gs := newManagerWithNodes(t, "accept-missing", []nodeSpec{ ++ {key: "123", kind: "mykind"}, ++ {key: "789", kind: "mykind"}, ++ {key: "456", kind: "mykind2"}, ++ }) ++ defer gs.Close() ++ ++ it, err := gm.NodeKeyIterator("main", "missingkind") ++ assertNilIteratorAndNilError(t, it, err) ++ ++ it, err = gm.NodeKeyIterator("missingpart", "mykind") ++ assertNilIteratorAndNilError(t, it, err) ++} ++ ++func TestNodeKeyIteratorCreationFailureReturnsReadingGraphError(t *testing.T) { ++ ++ ++ gm, gs := newManagerWithNodes(t, "accept-create-fail", []nodeSpec{ ++ {key: "123", kind: "mykind"}, ++ {key: "789", kind: "mykind"}, ++ {key: "456", kind: "mykind2"}, ++ }) ++ defer gs.Close() ++ ++ msm := nodeStorageManager(t, gs, "main", "mykind") ++ msm.AccessMap[3] = storage.AccessCacheAndFetchSeriousError ++ defer delete(msm.AccessMap, 3) ++ ++ it, err := gm.NodeKeyIterator("main", "mykind") ++ if it != nil { ++ t.Fatalf("iterator nil = false, want true") ++ } ++ assertReadingGraphError(t, err) ++} ++ ++func TestNodeKeyIteratorNextFailureSetsLastErrorAndError(t *testing.T) { ++ ++ ++ gm, gs := newManagerWithNodes(t, "accept-next-fail", []nodeSpec{ ++ {key: "123", kind: "mykind"}, ++ {key: "789", kind: "mykind"}, ++ {key: "456", kind: "mykind2"}, ++ }) ++ defer gs.Close() ++ ++ it, err := gm.NodeKeyIterator("main", "mykind") ++ if err != nil { ++ t.Fatalf("NodeKeyIterator error = %v, want nil", err) ++ } ++ if it == nil { ++ t.Fatalf("iterator nil = true, want false") ++ } ++ if it.HasNext() != true { ++ t.Fatalf("fresh HasNext() = false, want true") ++ } ++ if it.LastError != nil { ++ t.Fatalf("fresh LastError = %v, want nil", it.LastError) ++ } ++ if it.Error() != nil { ++ t.Fatalf("fresh Error() = %v, want nil", it.Error()) ++ } ++ ++ msm := nodeStorageManager(t, gs, "main", "mykind") ++ msm.AccessMap[3] = storage.AccessCacheAndFetchSeriousError ++ defer delete(msm.AccessMap, 3) ++ ++ if got := it.Next(); got != "" { ++ t.Fatalf("Next() after read failure = %q, want empty string", got) ++ } ++ if it.HasNext() != false { ++ t.Fatalf("HasNext() after read failure = true, want false") ++ } ++ assertReadingGraphError(t, it.LastError) ++ assertReadingGraphError(t, it.Error()) ++} ++ ++func TestNodeKeyIteratorInstancesKeepIndependentState(t *testing.T) { ++ ++ ++ gm, gs := newManagerWithNodes(t, "accept-independent", []nodeSpec{ ++ {key: "123", kind: "mykind"}, ++ {key: "789", kind: "mykind"}, ++ {key: "456", kind: "mykind2"}, ++ }) ++ defer gs.Close() ++ ++ a, err := gm.NodeKeyIterator("main", "mykind") ++ if err != nil { ++ t.Fatalf("iterator a error = %v, want nil", err) ++ } ++ b, err := gm.NodeKeyIterator("main", "mykind") ++ if err != nil { ++ t.Fatalf("iterator b error = %v, want nil", err) ++ } ++ if a == nil { ++ t.Fatalf("iterator a nil = true, want false") ++ } ++ if b == nil { ++ t.Fatalf("iterator b nil = true, want false") ++ } ++ ++ if got := a.Next(); got != "123" { ++ t.Fatalf("iterator a first Next() = %q, want %q", got, "123") ++ } ++ if a.HasNext() != true { ++ t.Fatalf("iterator a HasNext() after first Next = false, want true") ++ } ++ if b.HasNext() != true { ++ t.Fatalf("iterator b fresh HasNext() = false, want true") ++ } ++ if got := b.Next(); got != "123" { ++ t.Fatalf("iterator b first Next() = %q, want %q", got, "123") ++ } ++ if got := a.Next(); got != "789" { ++ t.Fatalf("iterator a second Next() = %q, want %q", got, "789") ++ } ++ if got := b.Next(); got != "789" { ++ t.Fatalf("iterator b second Next() = %q, want %q", got, "789") ++ } ++ if a.HasNext() != false { ++ t.Fatalf("iterator a exhausted HasNext() = true, want false") ++ } ++ if b.HasNext() != false { ++ t.Fatalf("iterator b exhausted HasNext() = true, want false") ++ } ++} ++ ++func TestNodeKeyIteratorSessionBeforeStorageCleanup(t *testing.T) { ++ ++ ++ gm, gs := newManagerWithNodes(t, "accept-cleanup", []nodeSpec{ ++ {key: "123", kind: "mykind"}, ++ {key: "789", kind: "mykind"}, ++ {key: "456", kind: "mykind2"}, ++ }) ++ defer gs.Close() ++ ++ it, err := gm.NodeKeyIterator("main", "mykind") ++ if err != nil { ++ t.Fatalf("NodeKeyIterator error = %v, want nil", err) ++ } ++ if it == nil { ++ t.Fatalf("iterator nil = true, want false") ++ } ++ if got := it.Next(); got != "123" { ++ t.Fatalf("first Next() before cleanup = %q, want %q", got, "123") ++ } ++ if got := it.Next(); got != "789" { ++ t.Fatalf("second Next() before cleanup = %q, want %q", got, "789") ++ } ++ if got := it.Next(); got != "" { ++ t.Fatalf("third Next() before cleanup = %q, want empty string", got) ++ } ++ ++} ++ ++func TestNodeKeyIteratorRepeatedCyclesReturnSpecResults(t *testing.T) { ++ ++ ++ ++ ++ for i := 0; i < 150; i++ { ++ gm, gs := newManagerWithNodes(t, "accept-leak", []nodeSpec{ ++ {key: "123", kind: "mykind"}, ++ {key: "789", kind: "mykind"}, ++ {key: "456", kind: "mykind2"}, ++ }) ++ it, err := gm.NodeKeyIterator("main", "mykind") ++ if err != nil { ++ t.Fatalf("cycle %d NodeKeyIterator error = %v, want nil", i, err) ++ } ++ if it == nil { ++ t.Fatalf("cycle %d iterator nil = true, want false", i) ++ } ++ if got := it.Next(); got != "123" { ++ t.Fatalf("cycle %d first Next() = %q, want %q", i, got, "123") ++ } ++ if got := it.Next(); got != "789" { ++ t.Fatalf("cycle %d second Next() = %q, want %q", i, got, "789") ++ } ++ if got := it.Next(); got != "" { ++ t.Fatalf("cycle %d third Next() = %q, want empty string", i, got) ++ } ++ ++ _ = gs.Close() ++ } ++} ++ ++func nodeStorageManager(t *testing.T, gs graphstorage.Storage, part string, kind string) *storage.MemoryStorageManager { ++ t.Helper() ++ ++ sm := gs.StorageManager(part+kind+graph.StorageSuffixNodes, false) ++ msm, ok := sm.(*storage.MemoryStorageManager) ++ if !ok { ++ t.Fatalf("storage manager type = %T, want *storage.MemoryStorageManager", sm) ++ } ++ return msm ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++exec go test -mod=mod -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001712/tests/test.sh b/tasks/format-code-task-001712/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8910e708e9736ae5657eb2bff98eea6fb04a61e5 --- /dev/null +++ b/tasks/format-code-task-001712/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/node_key_iterator_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001712/tests/test_command.sh b/tasks/format-code-task-001712/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001712/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-001723/environment/Dockerfile b/tasks/format-code-task-001723/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1a8945263bf05ad48742c2d3cac85f6b992757f1 --- /dev/null +++ b/tasks/format-code-task-001723/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d53d53b73770f31d99ddfeba028fab03313c58a1d6aa93615632cdbd0acf9ed3 diff --git a/tasks/format-code-task-001723/environment/setup/files/blocklist b/tasks/format-code-task-001723/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001723/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001723/environment/setup/setup.sh b/tasks/format-code-task-001723/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001723/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001723/tests/test.patch b/tasks/format-code-task-001723/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f62e20113fb4512860a273e3abeb1cd2d45562b0 --- /dev/null +++ b/tasks/format-code-task-001723/tests/test.patch @@ -0,0 +1,47 @@ +diff --git a/controlplane/kubeadm/internal/workload_cluster_conditions_test.go b/controlplane/kubeadm/internal/workload_cluster_conditions_test.go +index ed0ba4edc665..569ab7274676 100644 +--- a/controlplane/kubeadm/internal/workload_cluster_conditions_test.go ++++ b/controlplane/kubeadm/internal/workload_cluster_conditions_test.go +@@ -527,13 +527,13 @@ func TestUpdateStaticPodConditions(t *testing.T) { + injectClient: &fakeClient{ + listErr: errors.New("failed to list nodes"), + }, +- expectedKCPCondition: conditions.UnknownCondition(controlplanev1.ControlPlaneComponentsHealthyCondition, controlplanev1.ControlPlaneComponentsInspectionFailedReason, "Failed to list nodes which are hosting control plane components"), ++ expectedKCPCondition: conditions.UnknownCondition(controlplanev1.ControlPlaneComponentsHealthyCondition, controlplanev1.ControlPlaneComponentsInspectionFailedReason, "Failed to list nodes which are hosting control plane components: failed to list nodes"), + expectedMachineConditions: map[string]clusterv1.Conditions{ + "m1": { +- *conditions.UnknownCondition(controlplanev1.MachineAPIServerPodHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component"), +- *conditions.UnknownCondition(controlplanev1.MachineControllerManagerPodHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component"), +- *conditions.UnknownCondition(controlplanev1.MachineSchedulerPodHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component"), +- *conditions.UnknownCondition(controlplanev1.MachineEtcdPodHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component"), ++ *conditions.UnknownCondition(controlplanev1.MachineAPIServerPodHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component: failed to list nodes"), ++ *conditions.UnknownCondition(controlplanev1.MachineControllerManagerPodHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component: failed to list nodes"), ++ *conditions.UnknownCondition(controlplanev1.MachineSchedulerPodHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component: failed to list nodes"), ++ *conditions.UnknownCondition(controlplanev1.MachineEtcdPodHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component: failed to list nodes"), + }, + }, + }, +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+3SO2/bMBAAYM/6FVdkrR60ZXnKkLoainYIIqWrQImHmChFCnwI/fml1RYOisZe ++YhRF7lsoUHenE49ZH6QSHeo5X11LEe2222WN/lyXZ7ZdF+uqZGwX4xirinIF26t19ExwnluAlTXG ++n4u79P4/lZ3m79H5bjDjyLXI3OH1vnFp/rtyd5p/yeL8y2rNVlC8Xgsve+Pzv3mX91LnPXeHZBCw ++XIIeRZLcQK1dsAjfQo/LJUEL8ZocAyCmcCvRAY8BfOZS8V5hzEEfi2yyMttU75fMlE/SoZ1j8swy ++VmXlz/3Bq98bMa09oEMYw7E0wmQxlTrORSkUwD3kwdlcmYGr/Fk3S+MJfp+M9dDWTdvdNU3ddp8f ++P9T79svtmaxfHbyQ3N3df2rqh6/1w6Uap7/7S6m63X88V+B4VknyZGA50iwfjPbWqElxjUswF2Mu ++tUerYzakNmhoY+jjJLjHxnMvh3sj9kYL6aXRDtIZ0sEE7W8ZpF6OaIKHTVG45F9fM0IIIYQQQggh ++hBBCCCGEEEIIIYQQciU/APVDXUAAKAAA +diff --git 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-001723/tests/test.sh b/tasks/format-code-task-001723/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6087eddc201bfc3c30208ea7600fb349a58654f5 --- /dev/null +++ b/tasks/format-code-task-001723/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +controlplane/kubeadm/internal/workload_cluster_conditions_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-001723/tests/test_command.sh b/tasks/format-code-task-001723/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001723/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001724/tests/test.patch b/tasks/format-code-task-001724/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2713ddb440fbf1ff39b8fe3712b4db02b7fe7f68 --- /dev/null +++ b/tasks/format-code-task-001724/tests/test.patch @@ -0,0 +1,220 @@ +diff --git a/controlplane/kubeadm/internal/workload_cluster_coredns_test.go b/controlplane/kubeadm/internal/workload_cluster_coredns_test.go +index f799f6bfb3fb..19cd4fb9ffd8 100644 +--- a/controlplane/kubeadm/internal/workload_cluster_coredns_test.go ++++ b/controlplane/kubeadm/internal/workload_cluster_coredns_test.go +@@ -65,7 +65,6 @@ func TestUpdateCoreDNS(t *testing.T) { + "BadCoreFileKey": "", + }, + } +- expectedImage := "k8s.gcr.io/some-folder/coredns:1.6.2" + depl := &appsv1.Deployment{ + TypeMeta: v1.TypeMeta{ + Kind: "Deployment", +@@ -83,13 +82,19 @@ func TestUpdateCoreDNS(t *testing.T) { + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: coreDNSKey, +- Image: expectedImage, ++ Image: "k8s.gcr.io/some-folder/coredns:1.6.2", + }}, + }, + }, + }, + } + ++ deplWithImage := func(image string) *appsv1.Deployment { ++ d := depl.DeepCopy() ++ d.Spec.Template.Spec.Containers[0].Image = image ++ return d ++ } ++ + expectedCorefile := "coredns-core-file" + cm := &corev1.ConfigMap{ + ObjectMeta: v1.ObjectMeta{ +@@ -123,6 +128,7 @@ kind: ClusterConfiguration + objs []runtime.Object + expectErr bool + expectUpdates bool ++ expectImage string + }{ + { + name: "returns early without error if skip core dns annotation is present", +@@ -280,6 +286,131 @@ kind: ClusterConfiguration + objs: []runtime.Object{depl, cm, kubeadmCM}, + expectErr: false, + expectUpdates: true, ++ expectImage: "k8s.gcr.io/some-repo/coredns:1.7.2", ++ }, ++ { ++ name: "updates everything successfully to v1.8.0 with a custom repo should not change the image name", ++ kcp: &controlplanev1.KubeadmControlPlane{ ++ Spec: controlplanev1.KubeadmControlPlaneSpec{ ++ KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ++ ClusterConfiguration: &kubeadmv1.ClusterConfiguration{ ++ DNS: kubeadmv1.DNS{ ++ Type: kubeadmv1.CoreDNS, ++ ImageMeta: kubeadmv1.ImageMeta{ ++ ++ ImageRepository: "k8s.gcr.io/some-repo", ++ ImageTag: "1.8.0", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ migrator: &fakeMigrator{ ++ migratedCorefile: "updated-core-file", ++ }, ++ objs: []runtime.Object{deplWithImage("k8s.gcr.io/some-repo/coredns:1.7.0"), cm, kubeadmCM}, ++ expectErr: false, ++ expectUpdates: true, ++ expectImage: "k8s.gcr.io/some-repo/coredns:1.8.0", ++ }, ++ { ++ name: "kubeadm defaults, upgrade from Kubernetes v1.18.x to v1.19.y (from k8s.gcr.io/coredns:1.6.7 to k8s.gcr.io/coredns:1.7.0)", ++ kcp: &controlplanev1.KubeadmControlPlane{ ++ Spec: controlplanev1.KubeadmControlPlaneSpec{ ++ KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ++ ClusterConfiguration: &kubeadmv1.ClusterConfiguration{ ++ DNS: kubeadmv1.DNS{ ++ Type: kubeadmv1.CoreDNS, ++ ImageMeta: kubeadmv1.ImageMeta{ ++ ImageRepository: "k8s.gcr.io", ++ ImageTag: "1.7.0", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ migrator: &fakeMigrator{ ++ migratedCorefile: "updated-core-file", ++ }, ++ objs: []runtime.Object{deplWithImage("k8s.gcr.io/coredns:1.6.7"), cm, kubeadmCM}, ++ expectErr: false, ++ expectUpdates: true, ++ expectImage: "k8s.gcr.io/coredns:1.7.0", ++ }, ++ { ++ name: "kubeadm defaults, upgrade from Kubernetes v1.19.x to v1.20.y (stay on k8s.gcr.io/coredns:1.7.0)", ++ kcp: &controlplanev1.KubeadmControlPlane{ ++ Spec: controlplanev1.KubeadmControlPlaneSpec{ ++ KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ++ ClusterConfiguration: &kubeadmv1.ClusterConfiguration{ ++ DNS: kubeadmv1.DNS{ ++ Type: kubeadmv1.CoreDNS, ++ ImageMeta: kubeadmv1.ImageMeta{ ++ ImageRepository: "k8s.gcr.io", ++ ImageTag: "1.7.0", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ migrator: &fakeMigrator{ ++ migratedCorefile: "updated-core-file", ++ }, ++ objs: []runtime.Object{deplWithImage("k8s.gcr.io/coredns:1.7.0"), cm, kubeadmCM}, ++ expectErr: false, ++ expectUpdates: false, ++ }, ++ { ++ name: "kubeadm defaults, upgrade from Kubernetes v1.20.x to v1.21.y (from k8s.gcr.io/coredns:1.7.0 to k8s.gcr.io/coredns/coredns:v1.8.0)", ++ kcp: &controlplanev1.KubeadmControlPlane{ ++ Spec: controlplanev1.KubeadmControlPlaneSpec{ ++ KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ++ ClusterConfiguration: &kubeadmv1.ClusterConfiguration{ ++ DNS: kubeadmv1.DNS{ ++ Type: kubeadmv1.CoreDNS, ++ ImageMeta: kubeadmv1.ImageMeta{ ++ ImageRepository: "k8s.gcr.io", ++ ImageTag: "v1.8.0", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ migrator: &fakeMigrator{ ++ migratedCorefile: "updated-core-file", ++ }, ++ objs: []runtime.Object{deplWithImage("k8s.gcr.io/coredns:1.7.0"), cm, kubeadmCM}, ++ expectErr: false, ++ expectUpdates: true, ++ expectImage: "k8s.gcr.io/coredns/coredns:v1.8.0", ++ }, ++ { ++ name: "kubeadm defaults, upgrade from Kubernetes v1.21.x to v1.22.y (stay on k8s.gcr.io/coredns/coredns:v1.8.0)", ++ kcp: &controlplanev1.KubeadmControlPlane{ ++ Spec: controlplanev1.KubeadmControlPlaneSpec{ ++ KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ++ ClusterConfiguration: &kubeadmv1.ClusterConfiguration{ ++ DNS: kubeadmv1.DNS{ ++ Type: kubeadmv1.CoreDNS, ++ ImageMeta: kubeadmv1.ImageMeta{ ++ ImageRepository: "k8s.gcr.io", ++ ImageTag: "v1.8.0", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ migrator: &fakeMigrator{ ++ migratedCorefile: "updated-core-file", ++ }, ++ objs: []runtime.Object{deplWithImage("k8s.gcr.io/coredns/coredns:v1.8.0"), cm, kubeadmCM}, ++ expectErr: false, ++ expectUpdates: false, + }, + } + +@@ -303,8 +434,8 @@ kind: ClusterConfiguration + // assert kubeadmConfigMap + var expectedKubeadmConfigMap corev1.ConfigMap + g.Expect(fakeClient.Get(context.TODO(), ctrlclient.ObjectKey{Name: kubeadmConfigKey, Namespace: metav1.NamespaceSystem}, &expectedKubeadmConfigMap)).To(Succeed()) +- g.Expect(expectedKubeadmConfigMap.Data).To(HaveKeyWithValue("ClusterConfiguration", ContainSubstring("1.7.2"))) +- g.Expect(expectedKubeadmConfigMap.Data).To(HaveKeyWithValue("ClusterConfiguration", ContainSubstring("k8s.gcr.io/some-repo"))) ++ g.Expect(expectedKubeadmConfigMap.Data).To(HaveKeyWithValue("ClusterConfiguration", ContainSubstring(tt.kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.ImageTag))) ++ g.Expect(expectedKubeadmConfigMap.Data).To(HaveKeyWithValue("ClusterConfiguration", ContainSubstring(tt.kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.ImageRepository))) + + // assert CoreDNS corefile + var expectedConfigMap corev1.ConfigMap +@@ -315,10 +446,10 @@ kind: ClusterConfiguration + + // assert CoreDNS deployment + var actualDeployment appsv1.Deployment +- g.Expect(fakeClient.Get(context.TODO(), ctrlclient.ObjectKey{Name: coreDNSKey, Namespace: metav1.NamespaceSystem}, &actualDeployment)).To(Succeed()) +- // ensure the image is updated and the volumes point to the corefile +- g.Expect(actualDeployment.Spec.Template.Spec.Containers[0].Image).To(Equal("k8s.gcr.io/some-repo/coredns:1.7.2")) +- ++ g.Eventually(func() string { ++ g.Expect(fakeClient.Get(context.TODO(), ctrlclient.ObjectKey{Name: coreDNSKey, Namespace: metav1.NamespaceSystem}, &actualDeployment)).To(Succeed()) ++ return actualDeployment.Spec.Template.Spec.Containers[0].Image ++ }, "5s").Should(Equal(tt.expectImage)) + } + }) + } +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+3RsQ7CIBAG4M4+xb1AC1jbTk46u6izoYWosQVDwecXu2hM1EVjjP+33CUc4cif ++1WHfqo02J5Z8Co+qohhqdF+HXhRjIaoy52WcE6LkVULFxza6EXovHVHirPXP5l6d/6jsmr/Xvd80 ++tuukUVm/e98br/IX+U3+eR7zn5SCJ8Tft8Jjf55/o2gIvtZqtLV0aSk9UdrYYPxUUMYaa7yz7bGV ++RrNDqLVUHdsbr52RLaPUBUOreG19VNLrmXV6vliOvv0vAAAAAAAAAAAAAAAAAAAAAIB/cAZt1I/i ++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-001724/tests/test_command.sh b/tasks/format-code-task-001724/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001724/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001725/environment/Dockerfile b/tasks/format-code-task-001725/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c507cc36a757ddf37057921d594bb872fed5057a --- /dev/null +++ b/tasks/format-code-task-001725/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:42f79e16e53b3d392f6a862a828a668b5149992ea8469e3f122e03e1ed6afeba diff --git a/tasks/format-code-task-001725/environment/setup/files/blocklist b/tasks/format-code-task-001725/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001725/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001725/environment/setup/setup.sh b/tasks/format-code-task-001725/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001725/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001725/tests/test.patch b/tasks/format-code-task-001725/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fe9935021967bbbdd68d1fe6a54f0c214168147a --- /dev/null +++ b/tasks/format-code-task-001725/tests/test.patch @@ -0,0 +1,218 @@ +diff --git a/cmd/clusterctl/client/init_test.go b/cmd/clusterctl/client/init_test.go +index 3d3f2e29d..3c79992ac 100644 +--- a/cmd/clusterctl/client/init_test.go ++++ b/cmd/clusterctl/client/init_test.go +@@ -545,6 +545,143 @@ func Test_clusterctlClient_Init(t *testing.T) { + } + } + ++func Test_clusterctlClient_Init_idempotent(t *testing.T) { ++ type args struct { ++ coreProvider string ++ bootstrapProvider []string ++ controlPlaneProvider []string ++ infrastructureProvider []string ++ } ++ type want struct { ++ provider Provider ++ version string ++ targetNamespace string ++ } ++ tests := []struct { ++ name string ++ client *fakeClient ++ args args ++ want []want ++ wantErr bool ++ }{ ++ { ++ ++ ++ ++ name: "Init (with a fully initialized cluster) same explicit versions skips all providers", ++ client: fakeFullyInitializedCluster(), ++ args: args{ ++ coreProvider: fmt.Sprintf("%s:v1.0.0", config.ClusterAPIProviderName), ++ bootstrapProvider: []string{fmt.Sprintf("%s:v2.0.0", config.KubeadmBootstrapProviderName)}, ++ controlPlaneProvider: []string{fmt.Sprintf("%s:v2.0.0", config.KubeadmControlPlaneProviderName)}, ++ infrastructureProvider: []string{"infra:v3.0.0"}, ++ }, ++ want: nil, ++ wantErr: false, ++ }, ++ { ++ ++ ++ ++ name: "Init (with a fully initialized cluster) same default versions (no version specified) skips all providers", ++ client: fakeFullyInitializedCluster(), ++ args: args{ ++ coreProvider: config.ClusterAPIProviderName, ++ bootstrapProvider: []string{config.KubeadmBootstrapProviderName}, ++ controlPlaneProvider: []string{config.KubeadmControlPlaneProviderName}, ++ infrastructureProvider: []string{"infra"}, ++ }, ++ want: nil, ++ wantErr: false, ++ }, ++ { ++ ++ ++ name: "Init (with capi installed) idempotent on capi, installs other providers", ++ client: fakeIdempotentCapiInstalledCluster(), ++ args: args{ ++ coreProvider: fmt.Sprintf("%s:v1.0.0", config.ClusterAPIProviderName), ++ bootstrapProvider: []string{fmt.Sprintf("%s:v2.0.0", config.KubeadmBootstrapProviderName)}, ++ controlPlaneProvider: []string{fmt.Sprintf("%s:v2.0.0", config.KubeadmControlPlaneProviderName)}, ++ infrastructureProvider: []string{"infra:v3.0.0"}, ++ }, ++ want: []want{ ++ { ++ provider: bootstrapProviderConfig, ++ version: "v2.0.0", ++ targetNamespace: "ns2", ++ }, ++ { ++ provider: controlPlaneProviderConfig, ++ version: "v2.0.0", ++ targetNamespace: "ns3", ++ }, ++ { ++ provider: infraProviderConfig, ++ version: "v3.0.0", ++ targetNamespace: "ns4", ++ }, ++ }, ++ wantErr: false, ++ }, ++ { ++ ++ ++ name: "Init (with capi installed) errors when explicit core version diverges", ++ client: fakeIdempotentCapiInstalledCluster(), ++ args: args{ ++ coreProvider: fmt.Sprintf("%s:v1.1.0", config.ClusterAPIProviderName), ++ }, ++ wantErr: true, ++ }, ++ { ++ ++ ++ ++ name: "Init (with a fully initialized cluster) errors when bootstrap version diverges", ++ client: fakeFullyInitializedCluster(), ++ args: args{ ++ coreProvider: fmt.Sprintf("%s:v1.0.0", config.ClusterAPIProviderName), ++ bootstrapProvider: []string{fmt.Sprintf("%s:v2.1.0", config.KubeadmBootstrapProviderName)}, ++ controlPlaneProvider: []string{fmt.Sprintf("%s:v2.0.0", config.KubeadmControlPlaneProviderName)}, ++ infrastructureProvider: []string{"infra:v3.0.0"}, ++ }, ++ wantErr: true, ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ g := NewWithT(t) ++ ++ input := cluster.Kubeconfig{Path: "kubeconfig", Context: "mgmt-context"} ++ g.Expect(tt.client.clusters[input].ProviderInventory().EnsureCustomResourceDefinitions()).To(Succeed()) ++ ++ got, err := tt.client.Init(InitOptions{ ++ Kubeconfig: Kubeconfig{Path: "kubeconfig", Context: "mgmt-context"}, ++ CoreProvider: tt.args.coreProvider, ++ BootstrapProviders: tt.args.bootstrapProvider, ++ ControlPlaneProviders: tt.args.controlPlaneProvider, ++ InfrastructureProviders: tt.args.infrastructureProvider, ++ }) ++ if tt.wantErr { ++ g.Expect(err).To(HaveOccurred()) ++ return ++ } ++ g.Expect(err).NotTo(HaveOccurred()) ++ ++ g.Expect(got).To(HaveLen(len(tt.want))) ++ for i, gItem := range got { ++ w := tt.want[i] ++ g.Expect(gItem.Name()).To(Equal(w.provider.Name())) ++ g.Expect(gItem.Type()).To(Equal(w.provider.Type())) ++ g.Expect(gItem.Version()).To(Equal(w.version)) ++ g.Expect(gItem.TargetNamespace()).To(Equal(w.targetNamespace)) ++ } ++ }) ++ } ++} ++ + var ( + capiProviderConfig = config.NewProvider(config.ClusterAPIProviderName, "url", clusterctlv1.CoreProviderType) + bootstrapProviderConfig = config.NewProvider(config.KubeadmBootstrapProviderName, "url", clusterctlv1.BootstrapProviderType) +@@ -754,6 +891,47 @@ func fakeInitializedCluster() *fakeClient { + return client + } + ++ ++ ++ ++ ++ ++func fakeIdempotentCapiInstalledCluster() *fakeClient { ++ client := fakeEmptyCluster() ++ ++ input := cluster.Kubeconfig{ ++ Path: "kubeconfig", ++ Context: "mgmt-context", ++ } ++ p := client.clusters[input].Proxy() ++ fp := p.(*test.FakeProxy) ++ ++ fp.WithProviderInventory(capiProviderConfig.Name(), capiProviderConfig.Type(), "v1.0.0", "ns1") ++ ++ return client ++} ++ ++ ++ ++ ++func fakeFullyInitializedCluster() *fakeClient { ++ client := fakeEmptyCluster() ++ ++ input := cluster.Kubeconfig{ ++ Path: "kubeconfig", ++ Context: "mgmt-context", ++ } ++ p := client.clusters[input].Proxy() ++ fp := p.(*test.FakeProxy) ++ ++ fp.WithProviderInventory(capiProviderConfig.Name(), capiProviderConfig.Type(), "v1.0.0", "ns1") ++ fp.WithProviderInventory(bootstrapProviderConfig.Name(), bootstrapProviderConfig.Type(), "v2.0.0", "ns2") ++ fp.WithProviderInventory(controlPlaneProviderConfig.Name(), controlPlaneProviderConfig.Type(), "v2.0.0", "ns3") ++ fp.WithProviderInventory(infraProviderConfig.Name(), infraProviderConfig.Type(), "v3.0.0", "ns4") ++ ++ return client ++} ++ + func componentsYAML(ns string) []byte { + var namespaceYaml = []byte("apiVersion: v1\n" + + "kind: Namespace\n" + +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..f4d734d41 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./cmd/clusterctl/client/ -run Test_clusterctlClient_Init_idempotent -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 ./cmd/clusterctl/client/ -run Test_clusterctlClient_Init_idempotent -count=1 ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001725/tests/test.sh b/tasks/format-code-task-001725/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..daf93c0fb4bd50e5b39bc3fb3c523b288c7db70a --- /dev/null +++ b/tasks/format-code-task-001725/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' +cmd/clusterctl/client/init_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-001725/tests/test_command.sh b/tasks/format-code-task-001725/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001725/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001740/environment/Dockerfile b/tasks/format-code-task-001740/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7d095df6e5099ddbf1b0ede03bf82259988916b3 --- /dev/null +++ b/tasks/format-code-task-001740/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:21ffa3d1639216a33545c2c78b11db6cc2bb180b2b31ae1578c7a7f54a5741f6 diff --git a/tasks/format-code-task-001740/environment/setup/files/blocklist b/tasks/format-code-task-001740/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001740/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001740/environment/setup/setup.sh b/tasks/format-code-task-001740/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001740/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001740/tests/test.patch b/tasks/format-code-task-001740/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..910f739ae6a18d71c69ac2dcff5c67dece109fde --- /dev/null +++ b/tasks/format-code-task-001740/tests/test.patch @@ -0,0 +1,166 @@ +diff --git a/pkg/apis/kops/validation/kindnet_test.go b/pkg/apis/kops/validation/kindnet_test.go +new file mode 100644 +index 0000000000..fc945773ce +--- /dev/null ++++ b/pkg/apis/kops/validation/kindnet_test.go +@@ -0,0 +1,135 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package validation ++ ++import ( ++ "testing" ++ ++ "k8s.io/apimachinery/pkg/util/validation/field" ++ "k8s.io/kops/pkg/apis/kops" ++ "k8s.io/kops/upup/pkg/fi" ++) ++ ++func Test_Validate_Networking_Kindnet(t *testing.T) { ++ grid := []struct { ++ Input kops.KindnetNetworkingSpec ++ ExpectedErrors []string ++ }{ ++ { ++ ++ Input: kops.KindnetNetworkingSpec{ ++ Masquerade: &kops.KindnetMasqueradeSpec{ ++ Enabled: fi.PtrTo(true), ++ }, ++ }, ++ }, ++ { ++ ++ Input: kops.KindnetNetworkingSpec{ ++ Masquerade: &kops.KindnetMasqueradeSpec{ ++ Enabled: fi.PtrTo(true), ++ NonMasqueradeCIDRs: []string{"10.0.0.0/24", "2001:db8::/64"}, ++ }, ++ }, ++ }, ++ { ++ ++ Input: kops.KindnetNetworkingSpec{ ++ Masquerade: &kops.KindnetMasqueradeSpec{ ++ Enabled: fi.PtrTo(true), ++ NonMasqueradeCIDRs: []string{"", "10.0.0.0/24", ""}, ++ }, ++ }, ++ }, ++ { ++ ++ Input: kops.KindnetNetworkingSpec{ ++ Masquerade: &kops.KindnetMasqueradeSpec{ ++ Enabled: fi.PtrTo(true), ++ NonMasqueradeCIDRs: []string{"a.b.c.d/24", "2001:db8::/64"}, ++ }, ++ }, ++ ExpectedErrors: []string{"Invalid value::networking.kindnet"}, ++ }, ++ { ++ ++ Input: kops.KindnetNetworkingSpec{ ++ Masquerade: &kops.KindnetMasqueradeSpec{ ++ Enabled: fi.PtrTo(false), ++ NonMasqueradeCIDRs: []string{"a.b.c.d/24", "2001:db8::/64"}, ++ }, ++ }, ++ ExpectedErrors: []string{}, ++ }, ++ { ++ ++ Input: kops.KindnetNetworkingSpec{}, ++ ExpectedErrors: []string{}, ++ }, ++ } ++ ++ for _, g := range grid { ++ cluster := &kops.Cluster{ ++ Spec: kops.ClusterSpec{ ++ KubernetesVersion: "1.27.0", ++ Networking: kops.NetworkingSpec{ ++ NetworkCIDR: "10.0.0.0/8", ++ NonMasqueradeCIDR: "100.64.0.0/10", ++ PodCIDR: "100.96.0.0/11", ++ ServiceClusterIPRange: "100.64.0.0/13", ++ Subnets: []kops.ClusterSubnetSpec{ ++ { ++ Name: "sg-test", ++ CIDR: "10.11.0.0/16", ++ Type: "Public", ++ }, ++ }, ++ Kindnet: &g.Input, ++ }, ++ }, ++ } ++ ++ errs := validateNetworking(cluster, &cluster.Spec.Networking, field.NewPath("networking"), true, &cloudProviderConstraints{}) ++ testErrors(t, g.Input, errs, g.ExpectedErrors) ++ } ++} ++ ++func Test_Validate_Networking_Kindnet_MutuallyExclusive(t *testing.T) { ++ cluster := &kops.Cluster{ ++ Spec: kops.ClusterSpec{ ++ KubernetesVersion: "1.27.0", ++ Networking: kops.NetworkingSpec{ ++ NetworkCIDR: "10.0.0.0/8", ++ NonMasqueradeCIDR: "100.64.0.0/10", ++ PodCIDR: "100.96.0.0/11", ++ ServiceClusterIPRange: "100.64.0.0/13", ++ Subnets: []kops.ClusterSubnetSpec{ ++ { ++ Name: "sg-test", ++ CIDR: "10.11.0.0/16", ++ Type: "Public", ++ }, ++ }, ++ Kubenet: &kops.KubenetNetworkingSpec{}, ++ Kindnet: &kops.KindnetNetworkingSpec{}, ++ }, ++ }, ++ } ++ ++ errs := validateNetworking(cluster, &cluster.Spec.Networking, field.NewPath("networking"), true, &cloudProviderConstraints{}) ++ testErrors(t, "kindnet+kubenet", errs, []string{"Forbidden::networking.kindnet"}) ++} +diff --git 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 ./pkg/apis/kops/validation/ ++ ++ ++go test ./pkg/apis/kops/validation/ -run 'Test_Validate_Networking_Kindnet' diff --git a/tasks/format-code-task-001740/tests/test.sh b/tasks/format-code-task-001740/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fbbf22aad097088e66af2d6428cf87cdedc65988 --- /dev/null +++ b/tasks/format-code-task-001740/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/apis/kops/validation/kindnet_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-001740/tests/test_command.sh b/tasks/format-code-task-001740/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001740/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001747/environment/Dockerfile b/tasks/format-code-task-001747/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..123a30a10f1014681a91ed375baeb37874ebec20 --- /dev/null +++ b/tasks/format-code-task-001747/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:67b6084fb692d5e2d7ef8de43739968df772f4c76b1a4aea6ca6ec15c87b4c4b diff --git a/tasks/format-code-task-001747/environment/setup/files/blocklist b/tasks/format-code-task-001747/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001747/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001747/environment/setup/setup.sh b/tasks/format-code-task-001747/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001747/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001747/tests/test.patch b/tasks/format-code-task-001747/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..80bd231390e55a8dbd2e7ccf2395e9819edc66e1 --- /dev/null +++ b/tasks/format-code-task-001747/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/pkg/virt-launcher/virtwrap/converter/converter_test.go b/pkg/virt-launcher/virtwrap/converter/converter_test.go +index 8043cd330091..9487bb095cfa 100644 +--- a/pkg/virt-launcher/virtwrap/converter/converter_test.go ++++ b/pkg/virt-launcher/virtwrap/converter/converter_test.go +@@ -1067,6 +1067,7 @@ var _ = Describe("Converter", func() { + It("should use virtio-transitional models if requested", func() { + v1.SetObjectDefaults_VirtualMachineInstance(vmi) + vmi.Spec.Domain.Devices.Rng = &v1.Rng{} ++ vmi.Spec.Domain.Devices.DisableHotplug = false + c.UseVirtioTransitional = true + dom := vmiToDomain(vmi, c) + testutils.ExpectVirtioTransitionalOnly(&dom.Spec) +@@ -1313,7 +1314,7 @@ var _ = Describe("Converter", func() { + Expect(dom.Spec.Devices.Controllers).To(ContainElement(api.Controller{ + Type: "scsi", + Index: "0", +- Model: "virtio-scsi", ++ Model: "virtio-non-transitional", + })) + }) + +@@ -1325,7 +1326,7 @@ var _ = Describe("Converter", func() { + Expect(dom.Spec.Devices.Controllers).ToNot(ContainElement(api.Controller{ + Type: "scsi", + Index: "0", +- Model: "virtio-scsi", ++ Model: "virtio-non-transitional", + })) + }) + +@@ -2769,7 +2770,7 @@ var _ = Describe("Converter", func() { + for _, controller := range domain.Spec.Devices.Controllers { + if controller.Type == "scsi" { + foundScsiController = true +- Expect(controller.Model).To(Equal("virtio-scsi")) ++ Expect(controller.Model).To(Equal("virtio-non-transitional")) + + } + } +diff --git a/tests/vmi_controller_test.go b/tests/vmi_controller_test.go +index fc0e0574ee82..9d7daf018f32 100644 +--- a/tests/vmi_controller_test.go ++++ b/tests/vmi_controller_test.go +@@ -39,7 +39,7 @@ var _ = Describe("Controller devices", func() { + if controller.Type == "scsi" { + found = true + Expect(controller.Index).To(Equal("0")) +- Expect(controller.Model).To(Equal("virtio-scsi")) ++ Expect(controller.Model).To(Equal("virtio-non-transitional")) + } + } + Expect(found).To(Equal(enabled)) +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+3Sy27bMBAFUK/1FQNv0hagHnYVr7gwjCQF+giQtGtDkUYyEYoUKErt55eW2zgo ++2qaLBEWQezYUH9JcaBjfDEpXWzZjMnsqabDK82kMfh2n5yxfZIs0XS5X2SzNsny1nFH+ZInuGXpf ++OKKZs9b/7dxD+89UfOy/595vS9u2hanifvd4NR7q/+kiP/Y/C+vZ29M09D99vAh/9sL7X1Y0Nf6G ++qyjq2ZPgKOJvnXWeLi7PP6wvrqVobSVHNpV1x61Pl9dfPm7enW3eyzfhjXJnaS6lpKvBGGUaKq0Z ++2Xl2NBjlaV+jp3BgHjV2mpEY2Utb1ySastZF08sTwSdhmURpB+NlRsINhj6Hw+tOUZx0t00yKueF ++LgZT7thNs6+u6JK7csnPMPN7oTa27ZTex1LGc+MKr6z5kenVNCRjq8LlN95Zrdlt94txY1//W+SS ++hKWk4jExg9Yh6eGbv4uyDvvhxjV8+CdUK809heyqVlwdyv3vSwEAAAAAAAAAAAAAAAAAAAAAz8Z3 ++6lpsvwAoAAA= +diff --git 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-001747/tests/test.sh b/tasks/format-code-task-001747/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f186df8c48a22eb6371375d66ef6ffa8a900b6a6 --- /dev/null +++ b/tasks/format-code-task-001747/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/virt-launcher/virtwrap/converter/converter_test.go +tests/vmi_controller_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001747/tests/test_command.sh b/tasks/format-code-task-001747/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001747/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001749/environment/Dockerfile b/tasks/format-code-task-001749/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b0b759cd93099dab0efbb505eee142520649408b --- /dev/null +++ b/tasks/format-code-task-001749/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:398f5fe97f21429aab8b8c70f8ac9b630f8800adb6ae490b9a98ae02706558b4 diff --git a/tasks/format-code-task-001749/environment/setup/files/blocklist b/tasks/format-code-task-001749/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001749/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001749/environment/setup/setup.sh b/tasks/format-code-task-001749/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001749/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001749/tests/test.patch b/tasks/format-code-task-001749/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..031f4fe05ed8059b76c7d5a05e55c4007fe22d7d --- /dev/null +++ b/tasks/format-code-task-001749/tests/test.patch @@ -0,0 +1,74 @@ +diff --git a/pkg/kudoctl/cmd/init_test.go b/pkg/kudoctl/cmd/init_test.go +index 5ed060d09..035f840ae 100644 +--- a/pkg/kudoctl/cmd/init_test.go ++++ b/pkg/kudoctl/cmd/init_test.go +@@ -15,7 +15,7 @@ import ( + v1 "k8s.io/api/core/v1" + "k8s.io/api/extensions/v1beta1" + rbacv1 "k8s.io/api/rbac/v1" +- extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ++ extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apiextfake "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +@@ -281,21 +281,21 @@ func MockCRD(client *kube.Client, crdName string, apiVersion string) { + getAction, _ := action.(testing2.GetAction) + if getAction != nil { + if getAction.GetName() == crdName { +- crd := &extv1.CustomResourceDefinition{ ++ crd := &extv1beta1.CustomResourceDefinition{ + TypeMeta: metav1.TypeMeta{ + APIVersion: apiVersion, + }, + ObjectMeta: metav1.ObjectMeta{ + Name: crdName, + }, +- Spec: extv1.CustomResourceDefinitionSpec{ +- Versions: []extv1.CustomResourceDefinitionVersion{ ++ Spec: extv1beta1.CustomResourceDefinitionSpec{ ++ Versions: []extv1beta1.CustomResourceDefinitionVersion{ + { + Name: apiVersion, + }, + }, + }, +- Status: extv1.CustomResourceDefinitionStatus{}, ++ Status: extv1beta1.CustomResourceDefinitionStatus{}, + } + return true, crd, nil + } +diff --git a/pkg/kudoctl/kudoinit/prereq/webhook_test.go b/pkg/kudoctl/kudoinit/prereq/webhook_test.go +index 193ca9c60..e90d2c322 100644 +--- a/pkg/kudoctl/kudoinit/prereq/webhook_test.go ++++ b/pkg/kudoctl/kudoinit/prereq/webhook_test.go +@@ -4,7 +4,7 @@ import ( + "testing" + + "github.com/stretchr/testify/assert" +- apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ++ apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apiextensionsfake "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +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+3ST0+DMBgGcM58ihpNdoJSBJaY7GB2UC+ymN0X/tStGVCk7ZzGDy8QDdNE52GL ++MT6/ywtPW3iTt25qRJEveLWh1rF4rXEY9rX1ufbPLPSZ7wXnXjS2PMYij1kkPFpHO4zSSUOI1Uip ++v9u3b/2Pcof5a670IpNlmVS5q1aH+8e++QeRP8zfb3MWRF5gEe9wLXztn8//9ISmoqJpola24po4 ++3EhSi5rfJ6Kws5z01yLluc23tWw0uYrv4ng+obLWdCnf09nl/Po96z54cdYl9lKS7jhxNsTJpKn0 ++hBGX1uslXZtcZrqgWZlT4jSmIqN5u/OmEnpatvdxK5RWL7uRNLo2+kP0lJRFPMS3/PFtpX+dFoJX ++/V6RFOKZj37QTldFe4LWDW/4w25rsz4Z2b89MQAAAAAAAAAAAAAAAAAAAACAwSuCoFPUACgAAA== +diff --git 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-001749/tests/test.sh b/tasks/format-code-task-001749/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bb5c791560ee82fd001b21e78d2be18be8b14f7e --- /dev/null +++ b/tasks/format-code-task-001749/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/kudoctl/cmd/init_test.go +pkg/kudoctl/kudoinit/prereq/webhook_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-001749/tests/test_command.sh b/tasks/format-code-task-001749/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001749/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001771/environment/Dockerfile b/tasks/format-code-task-001771/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1d98cbfa595264ae2a8f3eeb26fe43f1e0416956 --- /dev/null +++ b/tasks/format-code-task-001771/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:47e49e6845805111a5273ceb29399efefa9f10bed173bedf851981457284fca2 diff --git a/tasks/format-code-task-001771/environment/setup/files/blocklist b/tasks/format-code-task-001771/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001771/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001771/environment/setup/setup.sh b/tasks/format-code-task-001771/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001771/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001771/tests/test.patch b/tasks/format-code-task-001771/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..52acdbdc15880b17de240ac99f30c6403d4e87ea --- /dev/null +++ b/tasks/format-code-task-001771/tests/test.patch @@ -0,0 +1,113 @@ +diff --git a/leo/unittests/test_gui.py b/leo/unittests/test_gui.py +index e11519082..9939654d0 100644 +--- a/leo/unittests/test_gui.py ++++ b/leo/unittests/test_gui.py +@@ -9,6 +9,9 @@ import time + from leo.core import leoGlobals as g + from leo.core.leoTest2 import LeoUnitTest, create_app + from leo.core.leoQt import QtCore ++from leo.core.leoFrame import StringTextWrapper ++from leo.plugins.qt_frame import LeoQtFrame ++from leo.plugins.qt_text import QHeadlineWrapper + + #@+others + #@+node:ekr.20210910084607.2: ** class TestNullGui(LeoUnitTest) +@@ -127,5 +130,73 @@ class TestQtGui(LeoUnitTest): + result = c.frame.log.put_html_links(s) + self.assertEqual(result, expected, msg=repr(s)) + #@-others ++ ++class TestWrapperCompatibility(LeoUnitTest): ++ """Focused tests for shared wrapper compatibility calls.""" ++ ++ ++ def make_qt_status_line(self): ++ status_line = object.__new__(LeoQtFrame.QtStatusLineClass) ++ status_line.textWidget1 = object() ++ return status_line ++ ++ def make_qheadline_wrapper(self): ++ wrapper = object.__new__(QHeadlineWrapper) ++ wrapper.widget = object() ++ return wrapper ++ ++ ++ def test_string_text_wrapper_enable_disable_are_safe_noops(self): ++ wrapper = StringTextWrapper(None, 'body') ++ ++ wrapper.disable() ++ wrapper.enable() ++ self.assertEqual(wrapper.getAllText(), '') ++ ++ ++ def test_qt_status_line_enable_disable_focus_are_safe_noops(self): ++ status_line = self.make_qt_status_line() ++ ++ status_line.disable() ++ status_line.disable(None) ++ status_line.disable("gray") ++ status_line.enable() ++ status_line.enable("blue") ++ status_line.enable(None) ++ status_line.setFocus() ++ ++ ++ def test_qt_status_line_is_enabled_returns_stable_boolean(self): ++ status_line = self.make_qt_status_line() ++ ++ self.assertIsInstance(status_line.isEnabled(), bool) ++ for action in (status_line.enable, status_line.disable, status_line.enable, status_line.disable): ++ action() ++ self.assertIsInstance(status_line.isEnabled(), bool) ++ ++ ++ def test_qheadline_wrapper_scroll_methods_are_compatible_noops(self): ++ wrapper = self.make_qheadline_wrapper() ++ first_x = wrapper.getXScrollPosition() ++ first_y = wrapper.getYScrollPosition() ++ self.assertIsInstance(first_x, int) ++ self.assertIsInstance(first_y, int) ++ ++ wrapper.setXScrollPosition(3) ++ wrapper.setXScrollPosition(5) ++ wrapper.setYScrollPosition(4) ++ wrapper.setYScrollPosition(6) ++ self.assertEqual(wrapper.getXScrollPosition(), first_x) ++ self.assertEqual(wrapper.getXScrollPosition(), first_x) ++ self.assertEqual(wrapper.getYScrollPosition(), first_y) ++ ++ ++ def test_qheadline_wrapper_flash_character_is_safe_noop(self): ++ wrapper = self.make_qheadline_wrapper() ++ ++ wrapper.flashCharacter(0) ++ wrapper.flashCharacter(1, "yellow", "blue", 1, 1) ++ wrapper.flashCharacter(2) ++ + #@-others + #@-leo +diff --git 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 ++ ++ ++export QT_QPA_PLATFORM=offscreen ++ ++ ++case "${1:-}" in ++ base) ++ python -m pytest leo/unittests/test_gui.py -x -v -k 'not TestWrapperCompatibility' ++ ;; ++ new) ++ python -m pytest leo/unittests/test_gui.py::TestWrapperCompatibility -x -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001771/tests/test.sh b/tasks/format-code-task-001771/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..08403cabb92d78011cf2c287917442f097b3da77 --- /dev/null +++ b/tasks/format-code-task-001771/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' +leo/unittests/test_gui.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-001771/tests/test_command.sh b/tasks/format-code-task-001771/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001771/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-001776/environment/Dockerfile b/tasks/format-code-task-001776/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..35fa13e7db5deb3ec174e5d95f23c4bdd48e7b3b --- /dev/null +++ b/tasks/format-code-task-001776/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bc5a0c22a92232561dd55d768aee8bacc23585950d76da53819c63cda2b1f95d diff --git a/tasks/format-code-task-001776/environment/setup/files/blocklist b/tasks/format-code-task-001776/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001776/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001776/environment/setup/setup.sh b/tasks/format-code-task-001776/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001776/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001776/tests/test.patch b/tasks/format-code-task-001776/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..81f67811966b0b60a645b35bef8e252b2f12e834 --- /dev/null +++ b/tasks/format-code-task-001776/tests/test.patch @@ -0,0 +1,256 @@ +diff --git a/cmd/boulder-wfe/config_test.go b/cmd/boulder-wfe/config_test.go +new file mode 100644 +index 000000000..7fc130853 +--- /dev/null ++++ b/cmd/boulder-wfe/config_test.go +@@ -0,0 +1,19 @@ ++package main ++ ++import ( ++ "reflect" ++ "testing" ++) ++ ++func TestWFEConfigDoesNotExposeAcceptRevocationReason(t *testing.T) { ++ configType := reflect.TypeOf(config{}) ++ wfeField, ok := configType.FieldByName("WFE") ++ if !ok { ++ t.Fatal("config type does not expose WFE section") ++ } ++ ++ ++ if _, ok := wfeField.Type.FieldByName("AcceptRevocationReason"); ok { ++ t.Fatal("WFE config still exposes AcceptRevocationReason") ++ } ++} +diff --git a/cmd/boulder-wfe2/config_test.go b/cmd/boulder-wfe2/config_test.go +new file mode 100644 +index 000000000..7fc130853 +--- /dev/null ++++ b/cmd/boulder-wfe2/config_test.go +@@ -0,0 +1,19 @@ ++package main ++ ++import ( ++ "reflect" ++ "testing" ++) ++ ++func TestWFEConfigDoesNotExposeAcceptRevocationReason(t *testing.T) { ++ configType := reflect.TypeOf(config{}) ++ wfeField, ok := configType.FieldByName("WFE") ++ if !ok { ++ t.Fatal("config type does not expose WFE section") ++ } ++ ++ ++ if _, ok := wfeField.Type.FieldByName("AcceptRevocationReason"); ok { ++ t.Fatal("WFE config still exposes AcceptRevocationReason") ++ } ++} +diff --git a/wfe/wfe_test.go b/wfe/wfe_test.go +index 5fffc28cf..6caaa8420 100644 +--- a/wfe/wfe_test.go ++++ b/wfe/wfe_test.go +@@ -1530,7 +1530,6 @@ func TestRevokeCertificateCertKey(t *testing.T) { + revokeRequestJSON, err := makeRevokeRequestJSON(nil) + test.AssertNotError(t, err, "Failed to make revokeRequestJSON") + +- wfe.AcceptRevocationReason = true + wfe.SA = &mockSANoSuchRegistration{mocks.NewStorageAuthority(fc)} + responseWriter := httptest.NewRecorder() + +@@ -1541,6 +1540,15 @@ func TestRevokeCertificateCertKey(t *testing.T) { + test.AssertEquals(t, responseWriter.Body.String(), "") + } + ++func assertRevocationReasonProblem(t *testing.T, body string) { ++ var prob probs.ProblemDetails ++ err := json.Unmarshal([]byte(body), &prob) ++ test.AssertNotError(t, err, "failed to unmarshal revocation reason problem") ++ test.AssertEquals(t, prob.Type, probs.ProblemType(probs.V1ErrorNS)+probs.MalformedProblem) ++ test.AssertEquals(t, prob.Detail, "unsupported revocation reason code provided") ++ test.AssertEquals(t, prob.HTTPStatus, http.StatusBadRequest) ++} ++ + func TestRevokeCertificateReasons(t *testing.T) { + wfe, fc := setupWFE(t) + keyPemBytes, err := ioutil.ReadFile("test/238.key") +@@ -1556,7 +1564,6 @@ func TestRevokeCertificateReasons(t *testing.T) { + revokeRequestJSON, err := makeRevokeRequestJSON(&keyComp) + test.AssertNotError(t, err, "Failed to make revokeRequestJSON") + +- wfe.AcceptRevocationReason = true + ra := wfe.RA.(*MockRegistrationAuthority) + wfe.SA = &mockSANoSuchRegistration{mocks.NewStorageAuthority(fc)} + responseWriter := httptest.NewRecorder() +@@ -1568,6 +1575,19 @@ func TestRevokeCertificateReasons(t *testing.T) { + test.AssertEquals(t, responseWriter.Body.String(), "") + test.AssertEquals(t, ra.lastRevocationReason, revocation.Reason(1)) + ++ ++ responseWriter = httptest.NewRecorder() ++ affiliationChanged := revocation.Reason(3) ++ revokeRequestJSON, err = makeRevokeRequestJSON(&affiliationChanged) ++ test.AssertNotError(t, err, "Failed to make revokeRequestJSON") ++ ++ result, _ = signer.Sign(revokeRequestJSON) ++ wfe.RevokeCertificate(ctx, newRequestEvent(), responseWriter, ++ makePostRequest(result.FullSerialize())) ++ test.AssertEquals(t, responseWriter.Code, 200) ++ test.AssertEquals(t, responseWriter.Body.String(), "") ++ test.AssertEquals(t, ra.lastRevocationReason, revocation.Reason(3)) ++ + // No reason + responseWriter = httptest.NewRecorder() + revokeRequestJSON, err = makeRevokeRequestJSON(nil) +@@ -1590,7 +1610,18 @@ func TestRevokeCertificateReasons(t *testing.T) { + wfe.RevokeCertificate(ctx, newRequestEvent(), responseWriter, + makePostRequest(result.FullSerialize())) + test.AssertEquals(t, responseWriter.Code, 400) +- test.AssertUnmarshaledEquals(t, responseWriter.Body.String(), `{"type":"`+probs.V1ErrorNS+`malformed","detail":"unsupported revocation reason code provided","status":400}`) ++ assertRevocationReasonProblem(t, responseWriter.Body.String()) ++ ++ responseWriter = httptest.NewRecorder() ++ unsupported = revocation.Reason(6) ++ revokeRequestJSON, err = makeRevokeRequestJSON(&unsupported) ++ test.AssertNotError(t, err, "Failed to make revokeRequestJSON") ++ ++ result, _ = signer.Sign(revokeRequestJSON) ++ wfe.RevokeCertificate(ctx, newRequestEvent(), responseWriter, ++ makePostRequest(result.FullSerialize())) ++ test.AssertEquals(t, responseWriter.Code, 400) ++ assertRevocationReasonProblem(t, responseWriter.Body.String()) + + responseWriter = httptest.NewRecorder() + unsupported = revocation.Reason(100) +@@ -1601,7 +1632,7 @@ func TestRevokeCertificateReasons(t *testing.T) { + wfe.RevokeCertificate(ctx, newRequestEvent(), responseWriter, + makePostRequest(result.FullSerialize())) + test.AssertEquals(t, responseWriter.Code, 400) +- test.AssertUnmarshaledEquals(t, responseWriter.Body.String(), `{"type":"`+probs.V1ErrorNS+`malformed","detail":"unsupported revocation reason code provided","status":400}`) ++ assertRevocationReasonProblem(t, responseWriter.Body.String()) + } + + // Valid revocation request for existing, non-revoked cert, signed with account +diff --git a/wfe2/wfe_test.go b/wfe2/wfe_test.go +index d6dd68855..34b0052c0 100644 +--- a/wfe2/wfe_test.go ++++ b/wfe2/wfe_test.go +@@ -2573,7 +2573,6 @@ func (msa mockSANoSuchRegistration) GetRegistrationByKey(ctx context.Context, jw + // key. + func TestRevokeCertificateCertKey(t *testing.T) { + wfe, fc := setupWFE(t) +- wfe.AcceptRevocationReason = true + wfe.SA = &mockSANoSuchRegistration{mocks.NewStorageAuthority(fc)} + responseWriter := httptest.NewRecorder() + +@@ -2593,9 +2592,16 @@ func TestRevokeCertificateCertKey(t *testing.T) { + test.AssertEquals(t, responseWriter.Body.String(), "") + } + ++func assertRevocationReasonProblem(t *testing.T, body string) { ++ var prob probs.ProblemDetails ++ err := json.Unmarshal([]byte(body), &prob) ++ test.AssertNotError(t, err, "failed to unmarshal revocation reason problem") ++ test.AssertEquals(t, prob.Type, probs.ProblemType(probs.V2ErrorNS)+probs.BadRevocationReasonProblem) ++ test.AssertEquals(t, prob.HTTPStatus, http.StatusBadRequest) ++} ++ + func TestRevokeCertificateReasons(t *testing.T) { + wfe, fc := setupWFE(t) +- wfe.AcceptRevocationReason = true + ra := wfe.RA.(*MockRegistrationAuthority) + wfe.SA = &mockSANoSuchRegistration{mocks.NewStorageAuthority(fc)} + responseWriter := httptest.NewRecorder() +@@ -2607,13 +2613,15 @@ func TestRevokeCertificateReasons(t *testing.T) { + reason0 := revocation.Reason(0) + reason1 := revocation.Reason(1) + reason2 := revocation.Reason(2) ++ reason3 := revocation.Reason(3) ++ reason6 := revocation.Reason(6) + reason100 := revocation.Reason(100) + + testCases := []struct { + Name string + Reason *revocation.Reason + ExpectedHTTPCode int +- ExpectedBody string ++ ExpectedProblem bool + ExpectedReason *revocation.Reason + }{ + { +@@ -2627,17 +2635,29 @@ func TestRevokeCertificateReasons(t *testing.T) { + ExpectedHTTPCode: http.StatusOK, + ExpectedReason: &reason0, + }, ++ { ++ Name: "Another valid reason", ++ Reason: &reason3, ++ ExpectedHTTPCode: http.StatusOK, ++ ExpectedReason: &reason3, ++ }, + { + Name: "Unsupported reason", + Reason: &reason2, + ExpectedHTTPCode: http.StatusBadRequest, +- ExpectedBody: `{"type":"` + probs.V2ErrorNS + `badRevocationReason","detail":"unsupported revocation reason code provided: cACompromise (2). Supported reasons: unspecified (0), keyCompromise (1), affiliationChanged (3), superseded (4), cessationOfOperation (5)","status":400}`, ++ ExpectedProblem: true, ++ }, ++ { ++ Name: "Another unsupported reason", ++ Reason: &reason6, ++ ExpectedHTTPCode: http.StatusBadRequest, ++ ExpectedProblem: true, + }, + { + Name: "Non-existent reason", + Reason: &reason100, + ExpectedHTTPCode: http.StatusBadRequest, +- ExpectedBody: `{"type":"` + probs.V2ErrorNS + `badRevocationReason","detail":"unsupported revocation reason code provided: unknown (100). Supported reasons: unspecified (0), keyCompromise (1), affiliationChanged (3), superseded (4), cessationOfOperation (5)","status":400}`, ++ ExpectedProblem: true, + }, + } + +@@ -2651,10 +2671,10 @@ func TestRevokeCertificateReasons(t *testing.T) { + makePostRequestWithPath("revoke-cert", jwsBody)) + + test.AssertEquals(t, responseWriter.Code, tc.ExpectedHTTPCode) +- if tc.ExpectedBody != "" { +- test.AssertUnmarshaledEquals(t, responseWriter.Body.String(), tc.ExpectedBody) ++ if tc.ExpectedProblem { ++ assertRevocationReasonProblem(t, responseWriter.Body.String()) + } else { +- test.AssertEquals(t, responseWriter.Body.String(), tc.ExpectedBody) ++ test.AssertEquals(t, responseWriter.Body.String(), "") + } + if tc.ExpectedReason != nil { + test.AssertEquals(t, ra.lastRevocationReason, *tc.ExpectedReason) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,23 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++ ++ ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 ./wfe/ ./wfe2/ ++ ;; ++ new) ++ go test -v -count=1 ./wfe/ -run '^(TestRevokeCertificateCertKey|TestRevokeCertificateReasons)$' ++ go test -v -count=1 ./wfe2/ -run '^(TestRevokeCertificateCertKey|TestRevokeCertificateReasons)$' ++ go test -v -count=1 ./cmd/boulder-wfe/ -run '^TestWFEConfigDoesNotExposeAcceptRevocationReason$' ++ go test -v -count=1 ./cmd/boulder-wfe2/ -run '^TestWFEConfigDoesNotExposeAcceptRevocationReason$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001776/tests/test.sh b/tasks/format-code-task-001776/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..74f18a5dd96c344b6cffaf1a83fe6bbb48cde543 --- /dev/null +++ b/tasks/format-code-task-001776/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/boulder-wfe/config_test.go +cmd/boulder-wfe2/config_test.go +wfe/wfe_test.go +wfe2/wfe_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001776/tests/test_command.sh b/tasks/format-code-task-001776/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001776/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-001778/environment/Dockerfile b/tasks/format-code-task-001778/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3a663d4ca88dc0753fa89cc5cedef26360445134 --- /dev/null +++ b/tasks/format-code-task-001778/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e0523d7366cffaba790e36a8d073edffe69feb5a5e0c48ecd4d90a96ec93b624 diff --git a/tasks/format-code-task-001778/environment/setup/files/blocklist b/tasks/format-code-task-001778/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001778/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001778/environment/setup/setup.sh b/tasks/format-code-task-001778/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001778/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001778/tests/test.patch b/tasks/format-code-task-001778/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fc732cc5730b1c502654a3631c98c9576e8f1e8c --- /dev/null +++ b/tasks/format-code-task-001778/tests/test.patch @@ -0,0 +1,631 @@ +diff --git a/internal/binder/function/funcs_array_context_test.go b/internal/binder/function/funcs_array_context_test.go +new file mode 100644 +index 00000000..2945b2cb +--- /dev/null ++++ b/internal/binder/function/funcs_array_context_test.go +@@ -0,0 +1,78 @@ ++package function ++ ++import ( ++ "strings" ++ "testing" ++ ++ "github.com/lf-edge/ekuiper/internal/conf" ++ kctx "github.com/lf-edge/ekuiper/internal/topo/context" ++ "github.com/lf-edge/ekuiper/internal/topo/state" ++ "github.com/lf-edge/ekuiper/pkg/api" ++) ++ ++type namedFunctionExecutorForContextTest interface { ++ ++ ExecWithName(args []interface{}, ctx api.FunctionContext, name string) (interface{}, bool) ++} ++ ++func executeArrayFunctionForContextTest(t *testing.T, name string, args []interface{}) string { ++ t.Helper() ++ ++ contextLogger := conf.Log.WithField("rule", "testExec") ++ ctx := kctx.WithValue(kctx.Background(), kctx.LoggerKey, contextLogger) ++ tempStore, _ := state.CreateStore("contextRule", api.AtMostOnce) ++ fctx := kctx.NewDefaultFuncContext(ctx.WithMeta("contextRule", "test", tempStore), 2) ++ ++ fn, err := Function(name) ++ if err != nil { ++ t.Fatalf("Function(%q) returned error: %v", name, err) ++ } ++ named, ok := fn.(namedFunctionExecutorForContextTest) ++ if !ok { ++ t.Fatalf("Function(%q) does not support named execution", name) ++ } ++ result, ok := named.ExecWithName(args, fctx, name) ++ if ok { ++ t.Fatalf("%s(%v) succeeded with result %#v; want validation error", name, args, result) ++ } ++ errResult, ok := result.(error) ++ if !ok { ++ t.Fatalf("%s(%v) returned %#v; want error result", name, args, result) ++ } ++ return errResult.Error() ++} ++ ++func assertArrayValidationNamesCallback(t *testing.T, got, callback string) { ++ t.Helper() ++ const oldGeneric = "validate function arguments failed." ++ ++ if got == oldGeneric { ++ t.Fatalf("error is still the old generic-only message: %q", got) ++ } ++ if !strings.Contains(got, callback) { ++ t.Fatalf("error %q does not identify failing callback function %q", got, callback) ++ } ++} ++ ++func TestArrayFunctionArgumentValidationErrorIncludesFunctionName(t *testing.T) { ++ tests := []struct { ++ callback string ++ args []interface{} ++ }{ ++ { ++ callback: "pow", ++ args: []interface{}{"pow", []interface{}{0, -0.4, 1.2}}, ++ }, ++ { ++ callback: "power", ++ args: []interface{}{"power", []interface{}{1, 2, 3}}, ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.callback, func(t *testing.T) { ++ got := executeArrayFunctionForContextTest(t, "array_map", tt.args) ++ assertArrayValidationNamesCallback(t, got, tt.callback) ++ }) ++ } ++} +diff --git a/internal/binder/function/funcs_array_test.go b/internal/binder/function/funcs_array_test.go +index 7a547989..c9e71323 100644 +--- a/internal/binder/function/funcs_array_test.go ++++ b/internal/binder/function/funcs_array_test.go +@@ -18,6 +18,7 @@ import ( + "errors" + "fmt" + "reflect" ++ "strings" + "testing" + + "github.com/stretchr/testify/assert" +@@ -797,11 +798,41 @@ func TestArrayCommonFunctions(t *testing.T) { + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result, _ := fe.ExecWithName(tt.args, fctx, tt.name) ++ if assertArrayMapCallbackValidationForContext(t, tt.name, tt.args, tt.result, result) { ++ return ++ } + assert.Equal(t, tt.result, result) + }) + } + } + ++func assertArrayMapCallbackValidationForContext(t *testing.T, name string, args []interface{}, expected, actual interface{}) bool { ++ t.Helper() ++ if name != "array_map" { ++ return false ++ } ++ expectedErr, ok := expected.(error) ++ if !ok || expectedErr.Error() != "validate function arguments failed." { ++ return false ++ } ++ actualErr, ok := actual.(error) ++ if !ok { ++ t.Fatalf("array_map(%v) returned %#v; want validation error", args, actual) ++ } ++ callback, ok := args[0].(string) ++ if !ok { ++ return false ++ } ++ got := actualErr.Error() ++ if got == expectedErr.Error() { ++ return true ++ } ++ if !strings.Contains(got, callback) { ++ t.Fatalf("array_map(%v) error %q does not identify callback function %q", args, got, callback) ++ } ++ return true ++} ++ + func TestArrayShuffle(t *testing.T) { + contextLogger := conf.Log.WithField("rule", "testExec") + ctx := kctx.WithValue(kctx.Background(), kctx.LoggerKey, contextLogger) +diff --git a/internal/topo/planner/analyzer_context_test.go b/internal/topo/planner/analyzer_context_test.go +new file mode 100644 +index 00000000..6b4d9c14 +--- /dev/null ++++ b/internal/topo/planner/analyzer_context_test.go +@@ -0,0 +1,80 @@ ++package planner ++ ++import ( ++ "encoding/json" ++ "strings" ++ "testing" ++ ++ "github.com/lf-edge/ekuiper/internal/pkg/store" ++ "github.com/lf-edge/ekuiper/internal/xsql" ++ "github.com/lf-edge/ekuiper/pkg/api" ++ "github.com/lf-edge/ekuiper/pkg/ast" ++) ++ ++func analyzeSQLForContextTest(t *testing.T, sql string) string { ++ t.Helper() ++ ++ ++ streamStore, err := store.GetKV("stream") ++ if err != nil { ++ t.Fatalf("get stream store: %v", err) ++ } ++ streamSQL := `CREATE STREAM src1 ( ++ id1 BIGINT, ++ temp BIGINT, ++ name string, ++ next STRUCT(NAME STRING, NID BIGINT) ++ ) WITH (DATASOURCE="src1", FORMAT="json", KEY="ts");` ++ streamInfo, err := json.Marshal(&xsql.StreamInfo{ ++ StreamType: ast.TypeStream, ++ Statement: streamSQL, ++ }) ++ if err != nil { ++ t.Fatalf("marshal stream info: %v", err) ++ } ++ if err := streamStore.Set("src1", string(streamInfo)); err != nil { ++ t.Fatalf("set stream info: %v", err) ++ } ++ ++ _, err = PlanSQLWithSourcesAndSinks(&api.Rule{ ++ Id: "context_validation_rule", ++ Sql: sql, ++ Options: &api.RuleOption{ ++ SendError: true, ++ }, ++ }, nil, nil) ++ if err == nil { ++ t.Fatalf("PlanSQLWithSourcesAndSinks(%q) succeeded; want validation error", sql) ++ } ++ return err.Error() ++} ++ ++func assertHavingContext(t *testing.T, got string, tokens ...string) { ++ t.Helper() ++ const oldGeneric = "Not allowed to call non-aggregate functions in HAVING clause." ++ ++ if got == oldGeneric { ++ t.Fatalf("error is still the old generic-only message: %q", got) ++ } ++ for _, token := range tokens { ++ if !strings.Contains(got, token) { ++ t.Fatalf("error %q does not include HAVING expression token %q", got, token) ++ } ++ } ++} ++ ++func TestAnalyzerValidationErrorIncludesHavingExpressionContext(t *testing.T) { ++ t.Run("simple having expression", func(t *testing.T) { ++ got := analyzeSQLForContextTest(t, ++ `SELECT count(*) FROM src1 HAVING sin(temp) > 0.3`, ++ ) ++ assertHavingContext(t, got, "sin", "temp") ++ }) ++ ++ t.Run("compound having expression", func(t *testing.T) { ++ got := analyzeSQLForContextTest(t, ++ `SELECT sum(temp) FROM src1 HAVING sum(temp) > 10 OR cos(temp) > 0`, ++ ) ++ assertHavingContext(t, got, "cos", "temp") ++ }) ++} +diff --git a/internal/topo/planner/analyzer_test.go b/internal/topo/planner/analyzer_test.go +index 02ff3008..2a3ed979 100644 +--- a/internal/topo/planner/analyzer_test.go ++++ b/internal/topo/planner/analyzer_test.go +@@ -60,6 +60,101 @@ func (e *errorStruct) Serr() string { + return e.err + } + ++func plannerValidationErrorMatches(expected, actual, sql string) bool { ++ if expected == actual { ++ return true ++ } ++ if expected == "" || actual == "" { ++ return false ++ } ++ if plannerGenericClause(expected) != "" { ++ return plannerValidationErrorHasSQLContext(actual, sql, expected) ++ } ++ return false ++} ++ ++func plannerGenericClause(expected string) string { ++ switch expected { ++ case "Not allowed to call aggregate functions in WHERE clause.": ++ return "WHERE" ++ case "Not allowed to call aggregate functions in GROUP BY clause.": ++ return "GROUP BY" ++ case "Not allowed to call non-aggregate functions in HAVING clause.": ++ return "HAVING" ++ default: ++ return "" ++ } ++} ++ ++func plannerValidationErrorHasSQLContext(actual, sql, expected string) bool { ++ tokens := plannerClauseTokens(sql, plannerGenericClause(expected)) ++ if len(tokens) == 0 { ++ return false ++ } ++ needed := 2 ++ if len(tokens) < needed { ++ needed = len(tokens) ++ } ++ found := 0 ++ actualLower := strings.ToLower(actual) ++ for _, token := range tokens { ++ if strings.Contains(actualLower, strings.ToLower(token)) { ++ found++ ++ } ++ } ++ return found >= needed ++} ++ ++func plannerClauseTokens(sql, clause string) []string { ++ expr := plannerClauseExpression(sql, clause) ++ return plannerSignificantTokens(expr) ++} ++ ++func plannerClauseExpression(sql, clause string) string { ++ upper := strings.ToUpper(sql) ++ idx := strings.Index(upper, clause) ++ if idx < 0 { ++ return "" ++ } ++ start := idx + len(clause) ++ end := len(sql) ++ for _, marker := range []string{" WHERE ", " GROUP BY ", " HAVING ", " ORDER BY ", " LIMIT "} { ++ next := strings.Index(upper[start:], marker) ++ if next >= 0 && start+next < end { ++ end = start + next ++ } ++ } ++ return sql[start:end] ++} ++ ++func plannerSignificantTokens(expr string) []string { ++ seen := map[string]bool{} ++ var tokens []string ++ for _, token := range strings.FieldsFunc(expr, func(r rune) bool { ++ return !(r == '_' || r >= '0' && r <= '9' || r >= 'A' && r <= 'Z' || r >= 'a' && r <= 'z') ++ }) { ++ if token == "" || plannerAllDigits(token) { ++ continue ++ } ++ lower := strings.ToLower(token) ++ if seen[lower] || lower == "and" || lower == "or" || lower == "true" || lower == "false" || lower == "as" { ++ continue ++ } ++ seen[lower] = true ++ tokens = append(tokens, token) ++ } ++ return tokens ++} ++ ++func plannerAllDigits(s string) bool { ++ for _, r := range s { ++ if r < '0' || r > '9' { ++ return false ++ } ++ } ++ return s != "" ++} ++ + var tests = []struct { + sql string + r *errorStruct +@@ -261,7 +356,10 @@ func Test_validation(t *testing.T) { + CheckpointInterval: 0, + SendError: true, + }, store) +- assert.Equal(t, tt.r.err, testx.Errstring(err), tt.sql) ++ actual := testx.Errstring(err) ++ if !plannerValidationErrorMatches(tt.r.err, actual, tt.sql) { ++ assert.Equal(t, tt.r.err, actual, tt.sql) ++ } + } + } + +@@ -321,7 +419,10 @@ func Test_validationSchemaless(t *testing.T) { + if tt.sql == "SELECT sum(temp) as temp1, count(temp) as temp FROM src1" { + serr = "" + } +- require.Equal(t, serr, testx.Errstring(err)) ++ actual := testx.Errstring(err) ++ if !plannerValidationErrorMatches(serr, actual, tt.sql) { ++ require.Equal(t, serr, actual) ++ } + } + } + +diff --git a/internal/xsql/func_invoker_test.go b/internal/xsql/func_invoker_test.go +index c5ea8509..e9832af7 100644 +--- a/internal/xsql/func_invoker_test.go ++++ b/internal/xsql/func_invoker_test.go +@@ -29,7 +29,8 @@ func TestInvoke(t *testing.T) { + return + } + err = validateFuncs("sum", []ast.Expr{}) +- if err == nil || err.Error() != "Expect 1 arguments but found 0." { ++ ++ if err == nil || !validationErrorMatchesContext("Expect 1 arguments but found 0.", err.Error(), "SELECT sum() FROM tbl") { + t.Error(err) + } + err = validateFuncs("window_start", []ast.Expr{}) +diff --git a/internal/xsql/funcs_validator_test.go b/internal/xsql/funcs_validator_test.go +index 098921cb..adfc1a00 100644 +--- a/internal/xsql/funcs_validator_test.go ++++ b/internal/xsql/funcs_validator_test.go +@@ -509,7 +509,8 @@ func TestFuncValidator(t *testing.T) { + for i, tt := range tests { + // fmt.Printf("Parsing SQL %q.\n", tt.s) + stmt, err := NewParser(strings.NewReader(tt.s)).Parse() +- if !reflect.DeepEqual(tt.err, testx.Errstring(err)) { ++ gotErr := testx.Errstring(err) ++ if !validationErrorMatchesContext(tt.err, gotErr, tt.s) { + t.Errorf("%d. %q: error mismatch:\n exp=%s\n got=%s\n\n", i, tt.s, tt.err, err) + } else if tt.err == "" && !reflect.DeepEqual(tt.stmt, stmt) { + t.Errorf("%d. %q\n\nstmt mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", i, tt.s, tt.stmt, stmt) +diff --git a/internal/xsql/parser_test.go b/internal/xsql/parser_test.go +index 8773edcb..153c7ce6 100644 +--- a/internal/xsql/parser_test.go ++++ b/internal/xsql/parser_test.go +@@ -3301,7 +3301,8 @@ func TestParser_ParseStatement(t *testing.T) { + for i, tt := range tests { + // fmt.Printf("Parsing SQL %q.\n", tt.s) + stmt, err := NewParser(strings.NewReader(tt.s)).Parse() +- if !reflect.DeepEqual(tt.err, testx.Errstring(err)) { ++ gotErr := testx.Errstring(err) ++ if !validationErrorMatchesContext(tt.err, gotErr, tt.s) { + t.Errorf("%d. %q: error mismatch:\n exp=%s\n got=%s\n\n", i, tt.s, tt.err, err) + } else if tt.err == "" && !reflect.DeepEqual(tt.stmt, stmt) { + t.Errorf("%d. %q\n\nstmt mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", i, tt.s, tt.stmt, stmt) +diff --git a/internal/xsql/sqlValidator_context_test.go b/internal/xsql/sqlValidator_context_test.go +new file mode 100644 +index 00000000..f535607e +--- /dev/null ++++ b/internal/xsql/sqlValidator_context_test.go +@@ -0,0 +1,194 @@ ++package xsql ++ ++import ( ++ "regexp" ++ "strings" ++ "testing" ++) ++ ++var validationFunctionCallRE = regexp.MustCompile(`(?is)\bselect\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\(`) ++ ++func validationErrorMatchesContext(expected, actual, sql string) bool { ++ if expected == actual { ++ return true ++ } ++ if expected == "" || actual == "" { ++ return false ++ } ++ if validationGenericClause(expected) != "" { ++ return validationErrorHasSQLContext(actual, sql, expected) ++ } ++ if strings.Contains(actual, expected) { ++ name := firstValidationFunctionName(sql) ++ return name == "" || strings.Contains(strings.ToLower(actual), strings.ToLower(name)) ++ } ++ return false ++} ++ ++func validationGenericClause(expected string) string { ++ switch expected { ++ case "Not allowed to call aggregate functions in WHERE clause.": ++ return "WHERE" ++ case "Not allowed to call aggregate functions in GROUP BY clause.": ++ return "GROUP BY" ++ default: ++ return "" ++ } ++} ++ ++func validationErrorHasSQLContext(actual, sql, expected string) bool { ++ tokens := validationClauseTokens(sql, validationGenericClause(expected)) ++ if len(tokens) == 0 { ++ return false ++ } ++ needed := 2 ++ if len(tokens) < needed { ++ needed = len(tokens) ++ } ++ found := 0 ++ actualLower := strings.ToLower(actual) ++ for _, token := range tokens { ++ if strings.Contains(actualLower, strings.ToLower(token)) { ++ found++ ++ } ++ } ++ return found >= needed ++} ++ ++func validationClauseTokens(sql, clause string) []string { ++ expr := validationClauseExpression(sql, clause) ++ return validationSignificantTokens(expr) ++} ++ ++func validationClauseExpression(sql, clause string) string { ++ upper := strings.ToUpper(sql) ++ idx := strings.Index(upper, clause) ++ if idx < 0 { ++ return "" ++ } ++ start := idx + len(clause) ++ end := len(sql) ++ for _, marker := range []string{" WHERE ", " GROUP BY ", " HAVING ", " ORDER BY ", " LIMIT "} { ++ next := strings.Index(upper[start:], marker) ++ if next >= 0 && start+next < end { ++ end = start + next ++ } ++ } ++ return sql[start:end] ++} ++ ++func validationSignificantTokens(expr string) []string { ++ seen := map[string]bool{} ++ var tokens []string ++ for _, token := range strings.FieldsFunc(expr, func(r rune) bool { ++ return !(r == '_' || r >= '0' && r <= '9' || r >= 'A' && r <= 'Z' || r >= 'a' && r <= 'z') ++ }) { ++ if token == "" || validationAllDigits(token) { ++ continue ++ } ++ lower := strings.ToLower(token) ++ if seen[lower] || lower == "and" || lower == "or" || lower == "true" || lower == "false" || lower == "as" { ++ continue ++ } ++ seen[lower] = true ++ tokens = append(tokens, token) ++ } ++ return tokens ++} ++ ++func validationAllDigits(s string) bool { ++ for _, r := range s { ++ if r < '0' || r > '9' { ++ return false ++ } ++ } ++ return s != "" ++} ++ ++func firstValidationFunctionName(sql string) string { ++ matches := validationFunctionCallRE.FindStringSubmatch(sql) ++ if len(matches) < 2 { ++ return "" ++ } ++ return matches[1] ++} ++ ++func validateSQLForContextTest(t *testing.T, sql string) string { ++ t.Helper() ++ parser := NewParser(strings.NewReader(sql)) ++ _, err := parser.Parse() ++ if err == nil { ++ t.Fatalf("Parse(%q) succeeded; want validation error", sql) ++ } ++ return err.Error() ++} ++ ++func assertContextualValidationError(t *testing.T, got, oldGeneric string, tokens ...string) { ++ t.Helper() ++ if got == oldGeneric { ++ t.Fatalf("error is still the old generic-only message: %q", got) ++ } ++ for _, token := range tokens { ++ if !strings.Contains(got, token) { ++ t.Fatalf("error %q does not include offending-expression token %q", got, token) ++ } ++ } ++} ++ ++func TestValidationErrorIncludesWhereExpressionContext(t *testing.T) { ++ got := validateSQLForContextTest(t, ++ `SELECT temp FROM src1 WHERE sum(temp) > 10 AND device = "demo"`, ++ ) ++ ++ assertContextualValidationError(t, got, ++ "Not allowed to call aggregate functions in WHERE clause.", ++ "sum", "temp", ++ ) ++} ++ ++func TestValidationErrorIncludesGroupByExpressionContext(t *testing.T) { ++ got := validateSQLForContextTest(t, ++ `SELECT temp FROM src1 GROUP BY max(temp + 1)`, ++ ) ++ ++ assertContextualValidationError(t, got, ++ "Not allowed to call aggregate functions in GROUP BY clause.", ++ "max", "temp", ++ ) ++} ++ ++func parseSQLFunctionValidationErrorForContextTest(t *testing.T, sql string) string { ++ t.Helper() ++ _, err := NewParser(strings.NewReader(sql)).Parse() ++ if err == nil { ++ t.Fatalf("Parse(%q) succeeded; want validation error", sql) ++ } ++ return err.Error() ++} ++ ++func assertFunctionValidationContext(t *testing.T, got, functionName string, reasonTokens ...string) { ++ t.Helper() ++ if !strings.Contains(got, functionName) { ++ t.Fatalf("error %q does not identify function %q", got, functionName) ++ } ++ for _, token := range reasonTokens { ++ if !strings.Contains(got, token) { ++ t.Fatalf("error %q does not preserve underlying reason token %q", got, token) ++ } ++ } ++} ++ ++func TestFunctionValidationErrorIncludesNameAndUnderlyingReason(t *testing.T) { ++ got := parseSQLFunctionValidationErrorForContextTest(t, `SELECT sum() FROM tbl`) ++ assertFunctionValidationContext(t, got, ++ "sum", ++ "Expect 1 arguments but found 0.", ++ ) ++ ++ got = parseSQLFunctionValidationErrorForContextTest(t, `SELECT abs(true) FROM tbl`) ++ assertFunctionValidationContext(t, got, ++ "abs", ++ "Expect number", ++ "parameter 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,30 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++mkdir -p /tmp/kuiper_base/{etc,data,log,plugins} ++cp -r /testbed/etc/* /tmp/kuiper_base/etc/ 2>/dev/null || true ++export KuiperBaseKey=/tmp/kuiper_base ++ ++ ++packages=( ++ ./internal/binder/function/ ++ ./internal/topo/planner/ ++ ./internal/xsql/ ++) ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 "${packages[@]}" \ ++ -run '^TestArrayCommonFunctions$|^Test_validation$|^TestInvoke$|^TestFuncValidator$|^TestParser_ParseStatement$' ++ ;; ++ new) ++ go test -v -count=1 "${packages[@]}" \ ++ -run '^TestArrayFunctionArgumentValidationErrorIncludesFunctionName$|^TestAnalyzerValidationErrorIncludesHavingExpressionContext$|^TestValidationErrorIncludesWhereExpressionContext$|^TestValidationErrorIncludesGroupByExpressionContext$|^TestFunctionValidationErrorIncludesNameAndUnderlyingReason$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001778/tests/test.sh b/tasks/format-code-task-001778/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4173b3648af08ab062a8f853a3868d8683a8ef48 --- /dev/null +++ b/tasks/format-code-task-001778/tests/test.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/binder/function/funcs_array_context_test.go +internal/binder/function/funcs_array_test.go +internal/topo/planner/analyzer_context_test.go +internal/topo/planner/analyzer_test.go +internal/xsql/func_invoker_test.go +internal/xsql/funcs_validator_test.go +internal/xsql/parser_test.go +internal/xsql/sqlValidator_context_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-001778/tests/test_command.sh b/tasks/format-code-task-001778/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001778/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-001782/environment/Dockerfile b/tasks/format-code-task-001782/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c55da82d918442ef24b21d002eece3742bfee5f9 --- /dev/null +++ b/tasks/format-code-task-001782/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e3f152fb0419ddf5da1cd8a4eab219c88e94ffac25cb74d0e41acd4a4732787d diff --git a/tasks/format-code-task-001782/environment/setup/files/blocklist b/tasks/format-code-task-001782/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001782/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001782/environment/setup/setup.sh b/tasks/format-code-task-001782/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001782/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001782/tests/test.patch b/tasks/format-code-task-001782/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a88787abe06a03d597fb6ad67fd9d5a82b8848c --- /dev/null +++ b/tasks/format-code-task-001782/tests/test.patch @@ -0,0 +1,560 @@ +diff --git a/plugins/defaultplugins/aclplugin/acl_config_modify_test.go b/plugins/defaultplugins/aclplugin/acl_config_modify_test.go +new file mode 100644 +index 000000000..a90f7408b +--- /dev/null ++++ b/plugins/defaultplugins/aclplugin/acl_config_modify_test.go +@@ -0,0 +1,518 @@ ++package aclplugin ++ ++import ( ++ "bytes" ++ "fmt" ++ "sync" ++ "testing" ++ ++ govppmock "git.fd.io/govpp.git/adapter/mock" ++ govppapi "git.fd.io/govpp.git/api" ++ "git.fd.io/govpp.git/core" ++ "github.com/ligato/cn-infra/logging" ++ "github.com/ligato/cn-infra/logging/logrus" ++ "github.com/ligato/cn-infra/logging/measure" ++ "github.com/ligato/vpp-agent/idxvpp/nametoidx" ++ "github.com/ligato/vpp-agent/plugins/defaultplugins/aclplugin/aclidx" ++ aclapi "github.com/ligato/vpp-agent/plugins/defaultplugins/common/bin_api/acl" ++ "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" ++ "github.com/ligato/vpp-agent/plugins/defaultplugins/ifplugin/ifaceidx" ++ "github.com/lunixbochs/struc" ++ ++ . "github.com/onsi/gomega" ++) ++ ++const modifyACLTestVPPACLIndex uint32 = 99 ++ ++type aclSetRequest struct { ++ swIfIndex uint32 ++ nInput uint8 ++ acls []uint32 ++} ++ ++type aclBindingRecorder struct { ++ lock sync.Mutex ++ current map[uint32]*aclapi.ACLInterfaceListDetails ++ setRequests []aclSetRequest ++ errors []error ++} ++ ++type recordingLogger struct { ++ logging.Logger ++ lock sync.Mutex ++ emptyInterfaceListDebugCalls int ++} ++ ++func (l *recordingLogger) Debugf(format string, args ...interface{}) { ++ l.lock.Lock() ++ for _, arg := range args { ++ if interfaces, ok := arg.([]uint32); ok && len(interfaces) == 0 { ++ l.emptyInterfaceListDebugCalls++ ++ } ++ } ++ l.lock.Unlock() ++ l.Logger.Debugf(format, args...) ++} ++ ++func (l *recordingLogger) emptyInterfaceListCalls() int { ++ l.lock.Lock() ++ defer l.lock.Unlock() ++ return l.emptyInterfaceListDebugCalls ++} ++ ++func newACLBindingRecorder(initial map[uint32]*aclapi.ACLInterfaceListDetails) *aclBindingRecorder { ++ current := make(map[uint32]*aclapi.ACLInterfaceListDetails, len(initial)) ++ for swIfIndex, details := range initial { ++ current[swIfIndex] = cloneACLInterfaceDetails(details) ++ } ++ return &aclBindingRecorder{current: current} ++} ++ ++func (r *aclBindingRecorder) replyHandler(adapter *govppmock.VppAdapter) govppmock.ReplyHandler { ++ return func(request govppmock.MessageDTO) (reply []byte, msgID uint16, ok bool) { ++ switch request.MsgName { ++ case (&aclapi.ACLAddReplace{}).GetMessageName(): ++ reply, msgID, ok = r.replyBytes(adapter, request, &aclapi.ACLAddReplaceReply{ACLIndex: modifyACLTestVPPACLIndex}) ++ case (&aclapi.ACLInterfaceListDump{}).GetMessageName(): ++ dump := &aclapi.ACLInterfaceListDump{} ++ if err := decodeVPPRequest(request.Data, dump); err != nil { ++ r.recordError(err) ++ reply, msgID, ok = r.replyBytes(adapter, request, &aclapi.ACLInterfaceListDetails{}) ++ break ++ } ++ reply, msgID, ok = r.replyBytes(adapter, request, r.currentDetails(dump.SwIfIndex)) ++ case (&aclapi.ACLInterfaceSetACLList{}).GetMessageName(): ++ set := &aclapi.ACLInterfaceSetACLList{} ++ if err := decodeVPPRequest(request.Data, set); err != nil { ++ r.recordError(err) ++ reply, msgID, ok = r.replyBytes(adapter, request, &aclapi.ACLInterfaceSetACLListReply{}) ++ break ++ } ++ r.recordSetRequest(set) ++ reply, msgID, ok = r.replyBytes(adapter, request, &aclapi.ACLInterfaceSetACLListReply{}) ++ default: ++ return nil, 0, false ++ } ++ return reply, msgID, ok ++ } ++} ++ ++func (r *aclBindingRecorder) replyBytes(adapter *govppmock.VppAdapter, request govppmock.MessageDTO, msg govppapi.Message) ([]byte, uint16, bool) { ++ reply, err := adapter.ReplyBytes(request, msg) ++ if err != nil { ++ r.recordError(err) ++ return nil, 0, false ++ } ++ msgID, err := adapter.GetMsgID(msg.GetMessageName(), msg.GetCrcString()) ++ if err != nil { ++ r.recordError(err) ++ return nil, 0, false ++ } ++ return reply, msgID, true ++} ++ ++func (r *aclBindingRecorder) currentDetails(swIfIndex uint32) *aclapi.ACLInterfaceListDetails { ++ r.lock.Lock() ++ defer r.lock.Unlock() ++ ++ if details, ok := r.current[swIfIndex]; ok { ++ return cloneACLInterfaceDetails(details) ++ } ++ return &aclapi.ACLInterfaceListDetails{SwIfIndex: swIfIndex} ++} ++ ++func (r *aclBindingRecorder) recordSetRequest(set *aclapi.ACLInterfaceSetACLList) { ++ r.lock.Lock() ++ defer r.lock.Unlock() ++ ++ acls := append([]uint32(nil), set.Acls...) ++ r.setRequests = append(r.setRequests, aclSetRequest{ ++ swIfIndex: set.SwIfIndex, ++ nInput: set.NInput, ++ acls: acls, ++ }) ++ r.current[set.SwIfIndex] = &aclapi.ACLInterfaceListDetails{ ++ SwIfIndex: set.SwIfIndex, ++ NInput: set.NInput, ++ Acls: acls, ++ } ++} ++ ++func (r *aclBindingRecorder) recordedSetRequests() []aclSetRequest { ++ r.lock.Lock() ++ defer r.lock.Unlock() ++ ++ out := make([]aclSetRequest, 0, len(r.setRequests)) ++ for _, req := range r.setRequests { ++ out = append(out, aclSetRequest{ ++ swIfIndex: req.swIfIndex, ++ nInput: req.nInput, ++ acls: append([]uint32(nil), req.acls...), ++ }) ++ } ++ return out ++} ++ ++func (r *aclBindingRecorder) recordError(err error) { ++ r.lock.Lock() ++ defer r.lock.Unlock() ++ r.errors = append(r.errors, err) ++} ++ ++func (r *aclBindingRecorder) recordedErrors() []error { ++ r.lock.Lock() ++ defer r.lock.Unlock() ++ return append([]error(nil), r.errors...) ++} ++ ++func decodeVPPRequest(data []byte, msg interface{}) error { ++ buf := bytes.NewReader(data) ++ header := &core.VppRequestHeader{} ++ if err := struc.Unpack(buf, header); err != nil { ++ return fmt.Errorf("decode VPP request header: %v", err) ++ } ++ if err := struc.Unpack(buf, msg); err != nil { ++ return fmt.Errorf("decode VPP request body: %v", err) ++ } ++ return nil ++} ++ ++func cloneACLInterfaceDetails(details *aclapi.ACLInterfaceListDetails) *aclapi.ACLInterfaceListDetails { ++ if details == nil { ++ return nil ++ } ++ return &aclapi.ACLInterfaceListDetails{ ++ SwIfIndex: details.SwIfIndex, ++ NInput: details.NInput, ++ Acls: append([]uint32(nil), details.Acls...), ++ } ++} ++ ++type testGovPPMux struct { ++ conn *core.Connection ++} ++ ++func (m *testGovPPMux) NewAPIChannel() (*govppapi.Channel, error) { ++ return m.conn.NewAPIChannel() ++} ++ ++func (m *testGovPPMux) NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (*govppapi.Channel, error) { ++ return m.conn.NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize) ++} ++ ++func newModifyACLTestPlugin(t *testing.T, names map[string]uint32, initial map[uint32]*aclapi.ACLInterfaceListDetails) (*ACLConfigurator, *aclBindingRecorder, func()) { ++ t.Helper() ++ g := NewGomegaWithT(t) ++ ++ adapter := &govppmock.VppAdapter{} ++ conn, err := core.Connect(adapter) ++ g.Expect(err).To(Succeed()) ++ ++ rec := newACLBindingRecorder(initial) ++ adapter.MockReplyHandler(rec.replyHandler(adapter)) ++ baseLogger := logrus.NewLogger("acl-modify-test") ++ baseLogger.SetLevel(logging.DebugLevel) ++ logRecorder := &recordingLogger{Logger: baseLogger} ++ ++ nameIndex := nametoidx.NewNameToIdx(logRecorder, "test", "test-sw_if_indexes", ifaceidx.IndexMetadata) ++ swIfIndexes := ifaceidx.NewSwIfIndex(nameIndex) ++ for name, index := range names { ++ swIfIndexes.RegisterName(name, index, nil) ++ } ++ ++ aclNameIndex := nametoidx.NewNameToIdx(logRecorder, "test", "test-acl_indexes", nil) ++ aclIndexes := aclidx.NewAclIndex(aclNameIndex) ++ aclIndexes.RegisterName("acl-under-test", modifyACLTestVPPACLIndex+1, nil) ++ ++ plugin := &ACLConfigurator{ ++ Log: logRecorder, ++ GoVppmux: &testGovPPMux{conn: conn}, ++ ACLL3L4Indexes: aclIndexes, ++ ACLL2Indexes: aclidx.NewAclIndex(nametoidx.NewNameToIdx(logRecorder, "test", "test-l2_acl_indexes", nil)), ++ SwIfIndexes: swIfIndexes, ++ Stopwatch: measure.NewStopwatch("acl-modify-test", logRecorder), ++ } ++ g.Expect(plugin.Init()).To(Succeed()) ++ ++ return plugin, rec, func() { ++ g.Expect(plugin.Close()).To(Succeed()) ++ conn.Disconnect() ++ } ++} ++ ++func testACL(ingress []string, egress []string) *acl.AccessLists_Acl { ++ return &acl.AccessLists_Acl{ ++ AclName: "acl-under-test", ++ Rules: []*acl.AccessLists_Acl_Rule{ ++ { ++ AclAction: acl.AclAction_PERMIT, ++ Match: &acl.AccessLists_Acl_Rule_Match{ ++ IpRule: &acl.AccessLists_Acl_Rule_Match_IpRule{ ++ Ip: &acl.AccessLists_Acl_Rule_Match_IpRule_Ip{ ++ SourceNetwork: "192.0.2.0/24", ++ DestinationNetwork: "198.51.100.0/24", ++ }, ++ }, ++ }, ++ }, ++ }, ++ Interfaces: &acl.AccessLists_Acl_Interfaces{ ++ Ingress: ingress, ++ Egress: egress, ++ }, ++ } ++} ++ ++func ingressACLDetails(swIfIndex uint32) *aclapi.ACLInterfaceListDetails { ++ return &aclapi.ACLInterfaceListDetails{ ++ SwIfIndex: swIfIndex, ++ NInput: 1, ++ Acls: []uint32{modifyACLTestVPPACLIndex}, ++ } ++} ++ ++func egressACLDetails(swIfIndex uint32) *aclapi.ACLInterfaceListDetails { ++ return &aclapi.ACLInterfaceListDetails{ ++ SwIfIndex: swIfIndex, ++ NInput: 0, ++ Acls: []uint32{modifyACLTestVPPACLIndex}, ++ } ++} ++ ++func expectedIngressSet(swIfIndex uint32) aclSetRequest { ++ return aclSetRequest{swIfIndex: swIfIndex, nInput: 1, acls: []uint32{modifyACLTestVPPACLIndex}} ++} ++ ++func expectedEgressSet(swIfIndex uint32) aclSetRequest { ++ return aclSetRequest{swIfIndex: swIfIndex, nInput: 0, acls: []uint32{modifyACLTestVPPACLIndex}} ++} ++ ++func expectedUnset(swIfIndex uint32) aclSetRequest { ++ return aclSetRequest{swIfIndex: swIfIndex, nInput: 0, acls: nil} ++} ++ ++func expectACLSetRequests(t *testing.T, actual []aclSetRequest, expected map[uint32]aclSetRequest) { ++ t.Helper() ++ g := NewGomegaWithT(t) ++ ++ g.Expect(actual).To(HaveLen(len(expected))) ++ ++ seen := map[uint32]aclSetRequest{} ++ for _, req := range actual { ++ if _, exists := seen[req.swIfIndex]; exists { ++ t.Fatalf("interface %d received more than one binding operation", req.swIfIndex) ++ } ++ seen[req.swIfIndex] = req ++ } ++ ++ for swIfIndex, expectedReq := range expected { ++ req, ok := seen[swIfIndex] ++ g.Expect(ok).To(BeTrue()) ++ g.Expect(req.nInput).To(Equal(expectedReq.nInput)) ++ g.Expect(req.acls).To(ConsistOf(uint32SliceToInterfaces(expectedReq.acls)...)) ++ } ++} ++ ++func expectNoEmptyInterfaceBindingWrapperCalls(t *testing.T, plugin *ACLConfigurator) { ++ t.Helper() ++ g := NewGomegaWithT(t) ++ logger, ok := plugin.Log.(*recordingLogger) ++ g.Expect(ok).To(BeTrue()) ++ g.Expect(logger.emptyInterfaceListCalls()).To(Equal(0)) ++} ++ ++func uint32SliceToInterfaces(values []uint32) []interface{} { ++ out := make([]interface{}, 0, len(values)) ++ for _, value := range values { ++ out = append(out, value) ++ } ++ return out ++} ++ ++func TestModifyACLUpdatesOnlyChangedIngressBindings(t *testing.T) { ++ plugin, rec, cleanup := newModifyACLTestPlugin(t, map[string]uint32{ ++ "ifA": 101, ++ "ifB": 102, ++ "ifC": 103, ++ "ifD": 104, ++ }, map[uint32]*aclapi.ACLInterfaceListDetails{ ++ 101: ingressACLDetails(101), ++ 102: ingressACLDetails(102), ++ 103: ingressACLDetails(103), ++ }) ++ defer cleanup() ++ ++ err := plugin.ModifyACL( ++ testACL([]string{"ifA", "ifB", "ifC"}, nil), ++ testACL([]string{"ifB", "ifC", "ifD"}, nil), ++ ) ++ ++ g := NewGomegaWithT(t) ++ g.Expect(err).To(Succeed()) ++ g.Expect(rec.recordedErrors()).To(BeEmpty()) ++ expectACLSetRequests(t, rec.recordedSetRequests(), map[uint32]aclSetRequest{ ++ 101: expectedUnset(101), ++ 104: expectedIngressSet(104), ++ }) ++} ++ ++func TestModifyACLUpdatesOnlyChangedEgressBindings(t *testing.T) { ++ plugin, rec, cleanup := newModifyACLTestPlugin(t, map[string]uint32{ ++ "ifA": 201, ++ "ifB": 202, ++ "ifE": 205, ++ }, map[uint32]*aclapi.ACLInterfaceListDetails{ ++ 201: egressACLDetails(201), ++ 202: egressACLDetails(202), ++ }) ++ defer cleanup() ++ ++ err := plugin.ModifyACL( ++ testACL(nil, []string{"ifA", "ifB"}), ++ testACL(nil, []string{"ifB", "ifE"}), ++ ) ++ ++ g := NewGomegaWithT(t) ++ g.Expect(err).To(Succeed()) ++ g.Expect(rec.recordedErrors()).To(BeEmpty()) ++ expectACLSetRequests(t, rec.recordedSetRequests(), map[uint32]aclSetRequest{ ++ 201: expectedUnset(201), ++ 205: expectedEgressSet(205), ++ }) ++} ++ ++func TestModifyACLMixedIngressEgressDiff(t *testing.T) { ++ plugin, rec, cleanup := newModifyACLTestPlugin(t, map[string]uint32{ ++ "if1": 301, ++ "if2": 302, ++ "if3": 303, ++ "if4": 304, ++ "if5": 305, ++ "if6": 306, ++ }, map[uint32]*aclapi.ACLInterfaceListDetails{ ++ 301: ingressACLDetails(301), ++ 302: ingressACLDetails(302), ++ 304: egressACLDetails(304), ++ 305: egressACLDetails(305), ++ }) ++ defer cleanup() ++ ++ err := plugin.ModifyACL( ++ testACL([]string{"if1", "if2"}, []string{"if4", "if5"}), ++ testACL([]string{"if2", "if3"}, []string{"if5", "if6"}), ++ ) ++ ++ g := NewGomegaWithT(t) ++ g.Expect(err).To(Succeed()) ++ g.Expect(rec.recordedErrors()).To(BeEmpty()) ++ expectACLSetRequests(t, rec.recordedSetRequests(), map[uint32]aclSetRequest{ ++ 301: expectedUnset(301), ++ 303: expectedIngressSet(303), ++ 304: expectedUnset(304), ++ 306: expectedEgressSet(306), ++ }) ++} ++ ++func TestModifyACLSameBindingsSkipsInterfaceVPPCalls(t *testing.T) { ++ plugin, rec, cleanup := newModifyACLTestPlugin(t, map[string]uint32{ ++ "if10": 410, ++ "if11": 411, ++ "if12": 412, ++ "if13": 413, ++ }, map[uint32]*aclapi.ACLInterfaceListDetails{ ++ 410: ingressACLDetails(410), ++ 411: ingressACLDetails(411), ++ 412: egressACLDetails(412), ++ 413: egressACLDetails(413), ++ }) ++ defer cleanup() ++ ++ err := plugin.ModifyACL( ++ testACL([]string{"if10", "if11"}, []string{"if12", "if13"}), ++ testACL([]string{"if10", "if11"}, []string{"if12", "if13"}), ++ ) ++ ++ g := NewGomegaWithT(t) ++ g.Expect(err).To(Succeed()) ++ g.Expect(rec.recordedErrors()).To(BeEmpty()) ++ expectACLSetRequests(t, rec.recordedSetRequests(), map[uint32]aclSetRequest{}) ++ expectNoEmptyInterfaceBindingWrapperCalls(t, plugin) ++} ++ ++func TestModifyACLSameBindingSetDifferentOrderSkipsInterfaceVPPCalls(t *testing.T) { ++ plugin, rec, cleanup := newModifyACLTestPlugin(t, map[string]uint32{ ++ "if20": 420, ++ "if21": 421, ++ "if22": 422, ++ "if23": 423, ++ }, map[uint32]*aclapi.ACLInterfaceListDetails{ ++ 420: ingressACLDetails(420), ++ 421: ingressACLDetails(421), ++ 422: egressACLDetails(422), ++ 423: egressACLDetails(423), ++ }) ++ defer cleanup() ++ ++ err := plugin.ModifyACL( ++ testACL([]string{"if20", "if21"}, []string{"if22", "if23"}), ++ testACL([]string{"if21", "if20"}, []string{"if23", "if22"}), ++ ) ++ ++ g := NewGomegaWithT(t) ++ g.Expect(err).To(Succeed()) ++ g.Expect(rec.recordedErrors()).To(BeEmpty()) ++ expectACLSetRequests(t, rec.recordedSetRequests(), map[uint32]aclSetRequest{}) ++ expectNoEmptyInterfaceBindingWrapperCalls(t, plugin) ++} ++ ++func TestModifyACLNoEmptyBindingOperationsForOneSidedDiff(t *testing.T) { ++ tests := []struct { ++ name string ++ names map[string]uint32 ++ initial map[uint32]*aclapi.ACLInterfaceListDetails ++ oldACL *acl.AccessLists_Acl ++ newACL *acl.AccessLists_Acl ++ expected map[uint32]aclSetRequest ++ }{ ++ { ++ name: "ingress add without empty remove", ++ names: map[string]uint32{"if1": 501, "if2": 502}, ++ initial: map[uint32]*aclapi.ACLInterfaceListDetails{ ++ 501: ingressACLDetails(501), ++ }, ++ oldACL: testACL([]string{"if1"}, nil), ++ newACL: testACL([]string{"if1", "if2"}, nil), ++ expected: map[uint32]aclSetRequest{ ++ 502: expectedIngressSet(502), ++ }, ++ }, ++ { ++ name: "egress remove without empty add", ++ names: map[string]uint32{"if3": 503, "if4": 504}, ++ initial: map[uint32]*aclapi.ACLInterfaceListDetails{ ++ 503: egressACLDetails(503), ++ 504: egressACLDetails(504), ++ }, ++ oldACL: testACL(nil, []string{"if3", "if4"}), ++ newACL: testACL(nil, []string{"if4"}), ++ expected: map[uint32]aclSetRequest{ ++ 503: expectedUnset(503), ++ }, ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ plugin, rec, cleanup := newModifyACLTestPlugin(t, tt.names, tt.initial) ++ defer cleanup() ++ ++ err := plugin.ModifyACL(tt.oldACL, tt.newACL) ++ ++ g := NewGomegaWithT(t) ++ g.Expect(err).To(Succeed()) ++ g.Expect(rec.recordedErrors()).To(BeEmpty()) ++ expectACLSetRequests(t, rec.recordedSetRequests(), tt.expected) ++ expectNoEmptyInterfaceBindingWrapperCalls(t, plugin) ++ }) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,31 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++ ++ ++set +u ++dev-switch go 1.23 ++ ++mkdir -p /root/go/src/github.com/ligato ++ln -sfn /testbed /root/go/src/github.com/ligato/vpp-agent ++ ++export GOPATH=/root/go ++export GO111MODULE=off ++ ++cd /root/go/src/github.com/ligato/vpp-agent ++set -u ++ ++ ++case "${1:-}" in ++ base) ++ go test -tags=mockvpp -count=1 ./plugins/defaultplugins/aclplugin/ -run '^$' ++ ;; ++ new) ++ go test -tags=mockvpp -count=1 ./plugins/defaultplugins/aclplugin/ -run 'TestModifyACL(UpdatesOnlyChangedIngressBindings|UpdatesOnlyChangedEgressBindings|MixedIngressEgressDiff|SameBindingsSkipsInterfaceVPPCalls|SameBindingSetDifferentOrderSkipsInterfaceVPPCalls|NoEmptyBindingOperationsForOneSidedDiff)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001782/tests/test.sh b/tasks/format-code-task-001782/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1e0bad2f09cca43219b379353cc5feea3257b89 --- /dev/null +++ b/tasks/format-code-task-001782/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' +plugins/defaultplugins/aclplugin/acl_config_modify_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-001782/tests/test_command.sh b/tasks/format-code-task-001782/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001782/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-001785/environment/Dockerfile b/tasks/format-code-task-001785/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..116ea8676131c6982ea947733060c42dc2212d55 --- /dev/null +++ b/tasks/format-code-task-001785/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:77cb84fdb6737784b022e7b4e306beaa634f710cc8c17e41f5bc07a97a4a2140 diff --git a/tasks/format-code-task-001785/environment/setup/files/blocklist b/tasks/format-code-task-001785/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001785/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001785/environment/setup/setup.sh b/tasks/format-code-task-001785/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001785/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001785/tests/test.patch b/tasks/format-code-task-001785/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a343b0440724189ce596a6396d4694edd9619f40 --- /dev/null +++ b/tasks/format-code-task-001785/tests/test.patch @@ -0,0 +1,61 @@ +diff --git a/test/unit/action/channel.spec.js b/test/unit/action/channel.spec.js +index 7f284d7dc..734a5612f 100644 +--- a/test/unit/action/channel.spec.js ++++ b/test/unit/action/channel.spec.js +@@ -262,6 +262,7 @@ describe('Action Channels Unit Tests', () => { + store.selectedChannel = { + channelPoint: 'some-channel-point', + status: 'open', ++ active: true, + }; + sandbox.stub(channel, 'closeChannel'); + }); +@@ -271,6 +272,27 @@ describe('Action Channels Unit Tests', () => { + expect(nav.goChannels, 'was called once'); + expect(channel.closeChannel, 'was called with', { + channelPoint: 'some-channel-point', ++ force: false, ++ }); ++ }); ++ ++ it('should force close inactive open channel', async () => { ++ store.selectedChannel.active = false; ++ await channel.closeSelectedChannel(); ++ expect(nav.goChannels, 'was called once'); ++ expect(channel.closeChannel, 'was called with', { ++ channelPoint: 'some-channel-point', ++ force: true, ++ }); ++ }); ++ ++ it('should force close pending-open channel', async () => { ++ store.selectedChannel.status = 'pending-open'; ++ await channel.closeSelectedChannel(); ++ expect(nav.goChannels, 'was called once'); ++ expect(channel.closeChannel, 'was called with', { ++ channelPoint: 'some-channel-point', ++ force: 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,5 @@ ++H4sIAAAAAAAAA+3R22oDIRAGYK/zFL7Aegg1Pk7YdYfGsqtbDyGPX5GWlkKbm4QS+n83M6KMyi+m ++6pf5SOEs2b2oxhrTa/O99l6bvdZWa6UtU1obaxg3d3vRFzWXMXHOUozlt3PX9h+U+My/UC5HF9d1 ++DLPIp9vdcS1/3cJ+z19Ze2j5Px32lnF1uyf87J/n72beg59o3oXtwtfoTiMfBrr40koiV1P2Z+r9 ++a/WJ+DROtAwuJpKJnn0ulPiQuOhzZKZSN/GSP9Y1+CJHV3wMso0OgRaRN3LtyO6vPw8AAAAAAAAA ++AAAAAAAAAAAA8ODeAGsJ1O4AKAAA +diff --git 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-001785/tests/test.sh b/tasks/format-code-task-001785/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d85119032386b628fef1ae807ec9f43162dd625f --- /dev/null +++ b/tasks/format-code-task-001785/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/action/channel.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-001785/tests/test_command.sh b/tasks/format-code-task-001785/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001785/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001915/environment/Dockerfile b/tasks/format-code-task-001915/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..71b6572cc318d11464c2a6cee82c63d37a93dfe5 --- /dev/null +++ b/tasks/format-code-task-001915/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4cd75509e963ce469aa1c13d0cd29def139fefceca5954bbc52a2f0309d07e81 diff --git a/tasks/format-code-task-001915/environment/setup/files/blocklist b/tasks/format-code-task-001915/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001915/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001915/environment/setup/setup.sh b/tasks/format-code-task-001915/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001915/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001915/tests/test.patch b/tasks/format-code-task-001915/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b110c8813e7087e593021b209551740a7001d5b0 --- /dev/null +++ b/tasks/format-code-task-001915/tests/test.patch @@ -0,0 +1,112 @@ +diff --git a/tests/playwright-test/esm.spec.ts b/tests/playwright-test/esm.spec.ts +index 662fe68dac217..1aa89000e545c 100644 +--- a/tests/playwright-test/esm.spec.ts ++++ b/tests/playwright-test/esm.spec.ts +@@ -128,8 +128,10 @@ test('should respect path resolver in experimental mode', async ({ runInlineTest + const result = await runInlineTest({ + 'package.json': JSON.stringify({ type: 'module' }), + 'playwright.config.ts': ` ++ // Make sure that config can use the path mapping. ++ import { foo } from 'util/b.js'; + export default { +- projects: [{name: 'foo'}], ++ projects: [{ name: foo }], + }; + `, + 'tsconfig.json': `{ +@@ -147,7 +149,8 @@ test('should respect path resolver in experimental mode', async ({ runInlineTest + import { foo } from 'util/b.js'; + import { test, expect } from '@playwright/test'; + test('check project name', ({}, testInfo) => { +- expect(testInfo.project.name).toBe(foo); ++ expect(testInfo.project.name).toBe('foo'); ++ expect(foo).toBe('foo'); + }); + `, + 'foo/bar/util/b.ts': ` +diff --git a/tests/playwright-test/resolver.spec.ts b/tests/playwright-test/resolver.spec.ts +index 4092263648064..5a0e91b099412 100644 +--- a/tests/playwright-test/resolver.spec.ts ++++ b/tests/playwright-test/resolver.spec.ts +@@ -641,3 +641,55 @@ test('should respect tsconfig project references', async ({ runInlineTest }) => + expect(result.exitCode).toBe(0); + expect(result.passed).toBe(1); + }); ++ ++test('should respect --tsconfig option', async ({ runInlineTest }) => { ++ const result = await runInlineTest({ ++ 'playwright.config.ts': ` ++ import { foo } from '~/foo'; ++ export default { ++ testDir: './tests' + foo, ++ }; ++ `, ++ 'tsconfig.json': `{ ++ "compilerOptions": { ++ "baseUrl": ".", ++ "paths": { ++ "~/*": ["./does-not-exist/*"], ++ }, ++ }, ++ }`, ++ 'tsconfig.special.json': `{ ++ "compilerOptions": { ++ "baseUrl": ".", ++ "paths": { ++ "~/*": ["./mapped-from-root/*"], ++ }, ++ }, ++ }`, ++ 'mapped-from-root/foo.ts': ` ++ export const foo = 42; ++ `, ++ 'tests42/tsconfig.json': `{ ++ "compilerOptions": { ++ "baseUrl": ".", ++ "paths": { ++ "~/*": ["../should-be-ignored/*"], ++ }, ++ }, ++ }`, ++ 'tests42/a.test.ts': ` ++ import { foo } from '~/foo'; ++ import { test, expect } from '@playwright/test'; ++ test('test', ({}) => { ++ expect(foo).toBe(42); ++ }); ++ `, ++ 'should-be-ignored/foo.ts': ` ++ export const foo = 43; ++ `, ++ }, { tsconfig: 'tsconfig.special.json' }); ++ ++ expect(result.passed).toBe(1); ++ expect(result.exitCode).toBe(0); ++ expect(result.output).not.toContain(`Could not`); ++}); +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+2TTY/TMBCGe86vGLTSCgRJmrZpTyshEAcOcGDhhtRN7GljlNiRx+lu/j22W7aw ++WnY5dIUQ8xwSO56P1zOTrB5UK9eod/nkqZh6VmUZ356777guyllRLKdFufTfi6JcLSdQPpminxjI ++VRZgYo1xD9k9dv6Pkh3775DcWpiuq7TMqDldjkf6X8xX89v+L+ah/4tlMZvA9HQSfs9/3v+zZ3mt ++dF5X1CSEDlJMEiEhDkONMknO4AshfDQSYTaF9LCavQRpTU9wpbreWAcVEVp3BTRqV93AQCihHoFM ++h/Du8gOEePTKR/PDdYixAFF5O4rnrakkWnCqQzM4yhKJu5SulRMN6H3yoOVNmFZwDUJvzTcUDp77 ++ie1V68N8Hnu8FFb1zqcdrMAXie47sIOGOOTB/7327W5b8M+6xagqGGifWmKPWqIWCimUICrO+7Ya ++r63aNi4NH/K9Y1ynB8fzcwh51CG0394p4I+kbxtrOjV0UFtz7csVa0EjOexCdoKNsRCuYzRqFwUo ++vd0L8Ve5gaOY22ziEDOpepdu8XiQjtAq31YzaDlzy0UQ8smXItTOT3wwjbffhNolscRZ/qd3zoP9 ++ujNy8M7566NDjJCLVu2Df00A0lQYvVHbi/uDH/fZ3i5zFP3uN0fqMupRPGxlkUy7Q/uLaZpaDLOK ++9qJV5JK//esxDMMwDMMwDMMwDMMwDMMwDMMwDMMwDMOchO/rMVyUACgAAA== +diff --git 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-001915/tests/test.sh b/tasks/format-code-task-001915/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9f2d31a1a47134b3078a863bf9a837ba6307c1c9 --- /dev/null +++ b/tasks/format-code-task-001915/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/playwright-test/esm.spec.ts +tests/playwright-test/resolver.spec.ts +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-001915/tests/test_command.sh b/tasks/format-code-task-001915/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001915/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001923/environment/Dockerfile b/tasks/format-code-task-001923/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9c30fc83169094f9bbe4b5a8c354e4d77501c2c4 --- /dev/null +++ b/tasks/format-code-task-001923/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3cb867c541d0d9f1e78d4a44eaf475369c1b77d63b02f58e5db94d80ac179771 diff --git a/tasks/format-code-task-001923/environment/setup/files/blocklist b/tasks/format-code-task-001923/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001923/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001923/environment/setup/setup.sh b/tasks/format-code-task-001923/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001923/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001923/tests/test.patch b/tasks/format-code-task-001923/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5d402fbf313bd0fdaf7d7057d61db2a08799c7b4 --- /dev/null +++ b/tasks/format-code-task-001923/tests/test.patch @@ -0,0 +1,112 @@ +diff --git a/pkg/util/cache/reload_contract_test.go b/pkg/util/cache/reload_contract_test.go +new file mode 100644 +index 0000000000..cdb9c4ef0c +--- /dev/null ++++ b/pkg/util/cache/reload_contract_test.go +@@ -0,0 +1,95 @@ ++package cache_test ++ ++import ( ++ "context" ++ "errors" ++ "sync/atomic" ++ "testing" ++ ++ "github.com/stretchr/testify/require" ++ ++ "github.com/milvus-io/milvus/pkg/v2/util/cache" ++) ++ ++func TestReloadFailureIsVisibleAndRetryable(t *testing.T) { ++ reloadErr := errors.New("reload unavailable") ++ var attempts atomic.Int32 ++ ++ builder := cache.NewCacheBuilder[string, string]() ++ builder.WithLoader(func(context.Context, string) (string, error) { return "before", nil }) ++ builder.WithReloader(func(context.Context, string) (string, error) { ++ if attempts.Add(1) == 1 { ++ return "", reloadErr ++ } ++ return "after", nil ++ }) ++ c := builder.Build() ++ ++ missing, err := c.Do(context.Background(), "segment", func(_ context.Context, value string) error { ++ require.Equal(t, "before", value) ++ return nil ++ }) ++ require.True(t, missing) ++ require.NoError(t, err) ++ require.True(t, c.MarkItemNeedReload(context.Background(), "segment")) ++ ++ called := false ++ missing, err = c.Do(context.Background(), "segment", func(_ context.Context, value string) error { ++ called = true ++ require.Equal(t, "before", value) ++ return nil ++ }) ++ require.False(t, missing) ++ require.ErrorIs(t, err, reloadErr) ++ require.False(t, called, "a failed reload must not run the operation on stale data") ++ ++ missing, err = c.Do(context.Background(), "segment", func(_ context.Context, value string) error { ++ require.Equal(t, "after", value) ++ return nil ++ }) ++ require.False(t, missing) ++ require.NoError(t, err) ++ require.Equal(t, int32(2), attempts.Load(), "a failed reload must remain retryable") ++} ++ ++func TestReloadCancellationIsReturnedAndDoesNotClearMarker(t *testing.T) { ++ var attempts atomic.Int32 ++ builder := cache.NewCacheBuilder[string, string]() ++ builder.WithLoader(func(context.Context, string) (string, error) { return "before", nil }) ++ builder.WithReloader(func(ctx context.Context, _ string) (string, error) { ++ attempts.Add(1) ++ if err := ctx.Err(); err != nil { ++ return "", err ++ } ++ return "after", nil ++ }) ++ c := builder.Build() ++ ++ _, err := c.Do(context.Background(), "segment", func(_ context.Context, _ string) error { return nil }) ++ require.NoError(t, err) ++ require.True(t, c.MarkItemNeedReload(context.Background(), "segment")) ++ ++ ctx, cancel := context.WithCancel(context.Background()) ++ cancel() ++ called := false ++ missing, err := c.Do(ctx, "segment", func(_ context.Context, _ string) error { ++ called = true ++ return nil ++ }) ++ require.False(t, missing) ++ require.ErrorIs(t, err, context.Canceled) ++ require.False(t, called) ++ ++ missing, err = c.Do(context.Background(), "segment", func(_ context.Context, value string) error { ++ require.Equal(t, "after", value) ++ return nil ++ }) ++ require.False(t, missing) ++ require.NoError(t, err) ++ require.Equal(t, int32(2), attempts.Load()) ++} ++ ++func TestMarkItemNeedReloadOnlyMarksResidentItems(t *testing.T) { ++ c := cache.NewCacheBuilder[string, string]().Build() ++ require.False(t, c.MarkItemNeedReload(context.Background(), "missing")) ++} ++ +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++cd pkg ++go test ./util/cache -run 'TestReload(FailureIsVisibleAndRetryable|CancellationIsReturnedAndDoesNotClearMarker)|TestMarkItemNeedReloadOnlyMarksResidentItems' -count=1 diff --git a/tasks/format-code-task-001923/tests/test.sh b/tasks/format-code-task-001923/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8f2c05d8d2d8f3dd73d49d3a85e3ab25276a79cb --- /dev/null +++ b/tasks/format-code-task-001923/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/util/cache/reload_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-001923/tests/test_command.sh b/tasks/format-code-task-001923/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001923/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001924/environment/Dockerfile b/tasks/format-code-task-001924/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..227c464c1ef40760ed8de710175f33d6276b5b1f --- /dev/null +++ b/tasks/format-code-task-001924/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d1408f3e22070e5eb53ae1d9266467bdaefad373bd1e5c30bd6ec9174d1ec267 diff --git a/tasks/format-code-task-001924/environment/setup/files/blocklist b/tasks/format-code-task-001924/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001924/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001924/environment/setup/setup.sh b/tasks/format-code-task-001924/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001924/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001924/tests/test.patch b/tasks/format-code-task-001924/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..23e36e6e83484411d830af260db1d8356b3c9db4 --- /dev/null +++ b/tasks/format-code-task-001924/tests/test.patch @@ -0,0 +1,574 @@ +diff --git a/client/client_grpc_index_test.go b/client/client_grpc_index_test.go +index 1ed497ce..744cb9d2 100644 +--- a/client/client_grpc_index_test.go ++++ b/client/client_grpc_index_test.go +@@ -64,6 +64,7 @@ func TestGrpcClientCreateIndex(t *testing.T) { + return resp, err + } + assert.Equal(t, testCollectionName, req.CollectionName) ++ assert.Equal(t, "test-index", req.IndexName) + + resp.State = common.IndexState_InProgress + if time.Since(start) > time.Duration(buildTime)*time.Millisecond { +@@ -76,7 +77,7 @@ func TestGrpcClientCreateIndex(t *testing.T) { + return resp, err + }) + +- assert.Nil(t, c.CreateIndex(ctx, testCollectionName, fieldName, idx, false)) ++ assert.Nil(t, c.CreateIndex(ctx, testCollectionName, fieldName, idx, false, WithIndexName("test-index"))) + assert.True(t, flag) + + mock.DelInjection(MGetIndexState) +diff --git a/client/v2/client_grpc_index_test.go b/client/v2/client_grpc_index_test.go +deleted file mode 100644 +index 56e195cf..00000000 +--- a/client/v2/client_grpc_index_test.go ++++ /dev/null +@@ -1,470 +0,0 @@ +-// Copyright (C) 2019-2021 Zilliz. All rights reserved. +-// +-// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +-// with the License. You may obtain a copy of the License at +-// +-// http://www.apache.org/licenses/LICENSE-2.0 +-// +-// Unless required by applicable law or agreed to in writing, software distributed under the License +-// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +-// or implied. See the License for the specific language governing permissions and limitations under the License. +- +-package v2 +- +-import ( +- "context" +- "errors" +- "log" +- "math/rand" +- "net" +- "testing" +- "time" +- +- "google.golang.org/grpc" +- "google.golang.org/grpc/test/bufconn" +- +- "github.com/golang/protobuf/proto" +- common "github.com/milvus-io/milvus-proto/go-api/commonpb" +- server "github.com/milvus-io/milvus-proto/go-api/milvuspb" +- "github.com/milvus-io/milvus-sdk-go/v2/client" +- "github.com/milvus-io/milvus-sdk-go/v2/entity" +- "github.com/stretchr/testify/assert" +-) +- +-const ( +- bufSzie = 1024 * 1024 +-) +- +-var ( +- lis *bufconn.Listener +- mock *client.MockServer +-) +- +-// TestMain establishes mock grpc server to testing client behavior +-func TestMain(m *testing.M) { +- rand.Seed(time.Now().Unix()) +- lis = bufconn.Listen(bufSzie) +- s := grpc.NewServer() +- mock = &client.MockServer{ +- Injections: make(map[client.ServiceMethod]client.TestInjection), +- } +- server.RegisterMilvusServiceServer(s, mock) +- go func() { +- if err := s.Serve(lis); err != nil { +- log.Fatalf("Server exited with error: %v", err) +- } +- }() +- m.Run() +- // lis.Close() +-} +- +-// use bufconn dialer +-func bufDialer(context.Context, string) (net.Conn, error) { +- return lis.Dial() +-} +- +-func testClient(ctx context.Context, t *testing.T) Client { +- c, err := NewGrpcClient(ctx, "bufnet", grpc.WithBlock(), +- grpc.WithInsecure(), grpc.WithContextDialer(bufDialer)) +- +- if !assert.Nil(t, err) || !assert.NotNil(t, c) { +- t.FailNow() +- } +- return c +-} +- +-func TestGrpcClient_CreateIndex(t *testing.T) { +- ctx := context.Background() +- c := testClient(ctx, t) +- +- const ( +- collectionName = "coll_index" +- defaultIndexName = "_default_idx_101" +- indexName = "indexName" +- emptyIndexName = "" +- fieldName = "fieldName" +- ) +- +- var ( +- flag = false +- count = 0 +- ) +- +- idx, err := entity.NewIndexHNSW(entity.L2, 16, 64) +- assert.Nil(t, err) +- if !assert.NotNil(t, idx) { +- t.FailNow() +- } +- mock.SetInjection(client.MCreateIndex, func(_ context.Context, raw proto.Message) (proto.Message, error) { +- req, ok := raw.(*server.CreateIndexRequest) +- if !ok { +- return client.BadRequestStatus() +- } +- assert.Equal(t, collectionName, req.GetCollectionName()) +- assert.Equal(t, fieldName, req.GetFieldName()) +- //assert.Equal(t, defaultIndexName, req.GetIndexName()) +- return client.SuccessStatus() +- }) +- +- mock.SetInjection(client.MDescribeIndex, func(_ context.Context, message proto.Message) (proto.Message, error) { +- var err2 error +- req, ok := message.(*server.DescribeIndexRequest) +- resp := &server.DescribeIndexResponse{} +- if !ok { +- resp.Status, err2 = client.BadRequestStatus() +- return resp.Status, err2 +- } +- assert.Equal(t, collectionName, req.GetCollectionName()) +- assert.Equal(t, fieldName, req.GetFieldName()) +- //assert.Equal(t, defaultIndexName, req.GetIndexName()) +- +- count++ +- +- if req.GetIndexName() == emptyIndexName { +- resp.IndexDescriptions = []*server.IndexDescription{ +- { +- IndexName: defaultIndexName, +- IndexID: 1, +- Params: entity.MapKvPairs(idx.Params()), +- FieldName: req.GetFieldName(), +- IndexedRows: 9000, +- TotalRows: 10000, +- State: common.IndexState_InProgress, +- IndexStateFailReason: "", +- }, +- { +- IndexName: indexName, +- IndexID: 2, +- Params: entity.MapKvPairs(idx.Params()), +- FieldName: req.GetFieldName(), +- IndexedRows: 2500, +- TotalRows: 3000, +- State: common.IndexState_InProgress, +- IndexStateFailReason: "", +- }, +- } +- } else { +- resp.IndexDescriptions = []*server.IndexDescription{ +- { +- IndexName: req.GetIndexName(), +- IndexID: 0, +- Params: entity.MapKvPairs(idx.Params()), +- FieldName: req.GetFieldName(), +- IndexedRows: 9000, +- TotalRows: 10000, +- State: common.IndexState_InProgress, +- IndexStateFailReason: "", +- }, +- } +- } +- +- if count >= 10 { +- for i := range resp.GetIndexDescriptions() { +- resp.IndexDescriptions[i].State = common.IndexState_Finished +- } +- flag = true +- } +- +- resp.Status, err2 = client.SuccessStatus() +- return resp, err2 +- }) +- +- t.Run("normal", func(t *testing.T) { +- err = c.CreateIndex(ctx, true, idx, SetCollectionNameForCreateIndex(collectionName), +- SetFieldNameForCreateIndex(fieldName), SetIndexNameForCreateIndex(defaultIndexName)) +- assert.NoError(t, err) +- }) +- +- t.Run("sync mode", func(t *testing.T) { +- err = c.CreateIndex(ctx, false, idx, SetCollectionNameForCreateIndex(collectionName), +- SetFieldNameForCreateIndex(fieldName), SetIndexNameForCreateIndex(defaultIndexName)) +- assert.NoError(t, err) +- assert.True(t, flag) +- }) +- +- t.Run("empty collection name", func(t *testing.T) { +- err = c.CreateIndex(ctx, false, idx, +- SetFieldNameForCreateIndex(fieldName), SetIndexNameForCreateIndex(defaultIndexName)) +- assert.Error(t, err) +- }) +- +- t.Run("empty field name", func(t *testing.T) { +- err = c.CreateIndex(ctx, false, idx, SetCollectionNameForCreateIndex(collectionName), +- SetIndexNameForCreateIndex(defaultIndexName)) +- assert.Error(t, err) +- }) +- +- t.Run("empty index name", func(t *testing.T) { +- count = 0 +- flag = false +- err = c.CreateIndex(ctx, false, idx, SetCollectionNameForCreateIndex(collectionName), +- SetFieldNameForCreateIndex(fieldName)) +- assert.NoError(t, err) +- assert.True(t, flag) +- }) +- +- t.Run("index failed", func(t *testing.T) { +- mock.SetInjection(client.MDescribeIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- var err2 error +- req, ok := message.(*server.DescribeIndexRequest) +- resp := &server.DescribeIndexResponse{} +- if !ok { +- resp.Status, err2 = client.BadRequestStatus() +- return resp, err2 +- } +- resp.IndexDescriptions = []*server.IndexDescription{ +- { +- IndexName: req.GetIndexName(), +- IndexID: 1, +- Params: nil, +- FieldName: req.GetFieldName(), +- IndexedRows: 1000, +- TotalRows: 0, +- State: common.IndexState_Failed, +- IndexStateFailReason: "", +- }, +- } +- return resp, err2 +- }) +- +- err = c.CreateIndex(ctx, false, idx, SetCollectionNameForCreateIndex(collectionName), +- SetFieldNameForCreateIndex(fieldName), SetIndexNameForCreateIndex(defaultIndexName)) +- assert.Error(t, err) +- }) +- +- t.Run("bad status", func(t *testing.T) { +- mock.SetInjection(client.MDescribeIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- var err2 error +- resp := &server.DescribeIndexResponse{} +- resp.Status, err2 = client.BadStatus() +- return resp, err2 +- }) +- err = c.CreateIndex(ctx, false, idx, SetCollectionNameForCreateIndex(collectionName), +- SetFieldNameForCreateIndex(fieldName), SetIndexNameForCreateIndex(defaultIndexName)) +- assert.Error(t, err) +- +- mock.SetInjection(client.MCreateIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- return client.BadStatus() +- }) +- +- err = c.CreateIndex(ctx, false, idx, SetCollectionNameForCreateIndex(collectionName), +- SetFieldNameForCreateIndex(fieldName), SetIndexNameForCreateIndex(defaultIndexName)) +- assert.Error(t, err) +- }) +- +- t.Run("error", func(t *testing.T) { +- mock.SetInjection(client.MDescribeIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- var err2 error +- resp := &server.DescribeIndexResponse{} +- resp.Status, err2 = client.BadRequestStatus() +- return resp, err2 +- }) +- mock.SetInjection(client.MCreateIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- return client.SuccessStatus() +- }) +- +- err = c.CreateIndex(ctx, false, idx, SetCollectionNameForCreateIndex(collectionName), +- SetFieldNameForCreateIndex(fieldName), SetIndexNameForCreateIndex(defaultIndexName)) +- assert.Error(t, err) +- +- mock.SetInjection(client.MCreateIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- return client.BadRequestStatus() +- }) +- +- err = c.CreateIndex(ctx, false, idx, SetCollectionNameForCreateIndex(collectionName), +- SetFieldNameForCreateIndex(fieldName), SetIndexNameForCreateIndex(defaultIndexName)) +- assert.Error(t, err) +- }) +-} +- +-func TestGrpcClient_DescribeIndex(t *testing.T) { +- ctx := context.Background() +- c := testClient(ctx, t) +- +- const ( +- collectionName = "coll_index" +- defaultIndexName = "_default_idx_101" +- indexName = "indexName" +- emptyIndexName = "" +- fieldName = "fieldName" +- ) +- +- idx, err := entity.NewIndexHNSW(entity.L2, 16, 64) +- assert.Nil(t, err) +- if !assert.NotNil(t, idx) { +- t.FailNow() +- } +- +- t.Run("normal", func(t *testing.T) { +- mock.SetInjection(client.MDescribeIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- var err2 error +- req, ok := message.(*server.DescribeIndexRequest) +- resp := &server.DescribeIndexResponse{} +- if !ok { +- resp.Status, err2 = client.BadRequestStatus() +- return resp, err2 +- } +- assert.Equal(t, collectionName, req.GetCollectionName()) +- +- if req.GetIndexName() == emptyIndexName { +- resp.IndexDescriptions = []*server.IndexDescription{ +- { +- IndexName: defaultIndexName, +- IndexID: 1, +- Params: entity.MapKvPairs(idx.Params()), +- FieldName: req.GetFieldName(), +- IndexedRows: 9000, +- TotalRows: 10000, +- State: common.IndexState_InProgress, +- IndexStateFailReason: "", +- }, +- { +- IndexName: indexName, +- IndexID: 2, +- Params: entity.MapKvPairs(idx.Params()), +- FieldName: req.GetFieldName(), +- IndexedRows: 2500, +- TotalRows: 3000, +- State: common.IndexState_InProgress, +- IndexStateFailReason: "", +- }, +- } +- } else { +- resp.IndexDescriptions = []*server.IndexDescription{ +- { +- IndexName: req.GetIndexName(), +- IndexID: 1, +- Params: entity.MapKvPairs(idx.Params()), +- FieldName: req.GetFieldName(), +- IndexedRows: 9000, +- TotalRows: 10000, +- State: common.IndexState_InProgress, +- IndexStateFailReason: "", +- }, +- } +- } +- resp.Status, err2 = client.SuccessStatus() +- return resp, err2 +- }) +- +- indexes, err := c.DescribeIndex(ctx, SetCollectionNameForDescribeIndex(collectionName), +- SetIndexNameForDescribeIndex(indexName)) +- assert.NoError(t, err) +- assert.Equal(t, 1, len(indexes)) +- assert.Equal(t, indexName, indexes[0].GetIndexName()) +- }) +- +- t.Run("empty collection name", func(t *testing.T) { +- indexes, err := c.DescribeIndex(ctx, +- SetIndexNameForDescribeIndex(indexName)) +- assert.Error(t, err) +- assert.Equal(t, 0, len(indexes)) +- }) +- +- t.Run("empty index name", func(t *testing.T) { +- indexes, err := c.DescribeIndex(ctx, SetCollectionNameForDescribeIndex(collectionName)) +- assert.NoError(t, err) +- assert.Equal(t, 2, len(indexes)) +- }) +- +- t.Run("bad status", func(t *testing.T) { +- mock.SetInjection(client.MDescribeIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- return &server.DescribeIndexResponse{ +- Status: &common.Status{ +- ErrorCode: common.ErrorCode_IndexNotExist, +- Reason: "index not exist", +- }, +- }, nil +- }) +- indexes, err := c.DescribeIndex(ctx, SetCollectionNameForDescribeIndex(collectionName)) +- assert.Error(t, err) +- assert.Equal(t, 0, len(indexes)) +- }) +- +- t.Run("error", func(t *testing.T) { +- mock.SetInjection(client.MDescribeIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- return &server.DescribeIndexResponse{ +- Status: &common.Status{ +- ErrorCode: common.ErrorCode_UnexpectedError, +- Reason: "", +- }, +- }, errors.New("error") +- }) +- indexes, err := c.DescribeIndex(ctx, SetCollectionNameForDescribeIndex(collectionName)) +- assert.Error(t, err) +- assert.Equal(t, 0, len(indexes)) +- }) +-} +- +-func TestGrpcClient_DropIndex(t *testing.T) { +- ctx := context.Background() +- c := testClient(ctx, t) +- +- const ( +- collectionName = "coll_index" +- defaultIndexName = "_default_idx_101" +- indexName = "indexName" +- emptyIndexName = "" +- fieldName = "fieldName" +- ) +- +- idx, err := entity.NewIndexHNSW(entity.L2, 16, 64) +- assert.Nil(t, err) +- if !assert.NotNil(t, idx) { +- t.FailNow() +- } +- +- mock.SetInjection(client.MDropIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- req, ok := message.(*server.DropIndexRequest) +- if !ok { +- return client.BadRequestStatus() +- } +- assert.Equal(t, collectionName, req.GetCollectionName()) +- +- return client.SuccessStatus() +- }) +- +- t.Run("normal", func(t *testing.T) { +- err = c.DropIndex(ctx, SetCollectionNameForDropIndex(collectionName), SetFieldNameForDroIndex(fieldName), +- SetIndexNameForDropIndex(indexName)) +- assert.NoError(t, err) +- }) +- +- t.Run("empty collection name", func(t *testing.T) { +- err = c.DropIndex(ctx, SetFieldNameForDroIndex(fieldName), +- SetIndexNameForDropIndex(indexName)) +- assert.Error(t, err) +- }) +- +- t.Run("empty field name", func(t *testing.T) { +- err = c.DropIndex(ctx, SetCollectionNameForDropIndex(collectionName), SetIndexNameForDropIndex(indexName)) +- assert.NoError(t, err) +- }) +- +- t.Run("empty index name", func(t *testing.T) { +- err = c.DropIndex(ctx, SetCollectionNameForDropIndex(collectionName), SetFieldNameForDroIndex(fieldName)) +- assert.NoError(t, err) +- +- err = c.DropIndex(ctx, SetCollectionNameForDropIndex(collectionName)) +- assert.NoError(t, err) +- }) +- +- t.Run("bad status", func(t *testing.T) { +- mock.SetInjection(client.MDropIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- return client.BadStatus() +- }) +- err = c.DropIndex(ctx, SetCollectionNameForDropIndex(collectionName)) +- assert.Error(t, err) +- }) +- +- t.Run("error", func(t *testing.T) { +- mock.SetInjection(client.MDropIndex, func(ctx context.Context, message proto.Message) (proto.Message, error) { +- return &common.Status{ +- ErrorCode: common.ErrorCode_UnexpectedError, +- Reason: "fail", +- }, errors.New("error") +- }) +- err = c.DropIndex(ctx, SetCollectionNameForDropIndex(collectionName)) +- assert.Error(t, err) +- }) +-} +diff --git a/test/base/milvus_client.go b/test/base/milvus_client.go +index 0da54d76..45d2e018 100644 +--- a/test/base/milvus_client.go ++++ b/test/base/milvus_client.go +@@ -4,9 +4,7 @@ import ( + "context" + "log" + +- server "github.com/milvus-io/milvus-proto/go-api/milvuspb" + "github.com/milvus-io/milvus-sdk-go/v2/client" +- v2 "github.com/milvus-io/milvus-sdk-go/v2/client/v2" + "github.com/milvus-io/milvus-sdk-go/v2/entity" + + "google.golang.org/grpc" +@@ -26,12 +24,12 @@ func postResponse(funcName string, err error, res ...interface{}) { + } + + type MilvusClient struct { +- mClient v2.Client ++ mClient client.Client + } + + func NewMilvusClient(ctx context.Context, addr string, dialOptions ...grpc.DialOption) (*MilvusClient, error) { + preRequest("NewGrpcClient", addr, dialOptions) +- mClient, err := v2.NewGrpcClient(ctx, addr, dialOptions...) ++ mClient, err := client.NewGrpcClient(ctx, addr, dialOptions...) + postResponse("NewGrpcClient", err, mClient) + return &MilvusClient{ + mClient, +@@ -120,18 +118,18 @@ func (mc *MilvusClient) GetPersistentSegmentInfo(ctx context.Context, collName s + + // TODO collName, indexName, fieldName in CreateIndexRequestOption + // Create Index +-func (mc *MilvusClient) CreateIndex(ctx context.Context, async bool, idx entity.Index, opts ...v2.CreateIndexRequestOption) error { ++func (mc *MilvusClient) CreateIndex(ctx context.Context, collectionName string, fieldName string, async bool, idx entity.Index, opts ...client.IndexOption) error { + preRequest("CreateIndex", async, idx, opts) +- err := mc.mClient.CreateIndex(ctx, async, idx, opts...) ++ err := mc.mClient.CreateIndex(ctx, collectionName, fieldName, idx, async, opts...) + postResponse("CreateIndex", err) + return err + } + + // TODO milvuspb server IndexDescription + //Describe Index +-func (mc *MilvusClient) DescribeIndex(ctx context.Context, opts ...v2.DescribeIndexRequestOption) ([]*server.IndexDescription, error) { ++func (mc *MilvusClient) DescribeIndex(ctx context.Context, collectionName string, fieldName string, opts ...client.IndexOption) ([]entity.Index, error) { + preRequest("DescribeIndex", opts) +- indexes, err := mc.mClient.DescribeIndex(ctx, opts...) ++ indexes, err := mc.mClient.DescribeIndex(ctx, collectionName, fieldName, opts...) + postResponse("DescribeIndex", err, indexes) + return indexes, 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+2TwU7cMBCG9+ynGJZLe0iyzrKs1KqHAhLqrWpXXCPHns1aTeKV7aQg9eHrOLAL ++aIELqEKd7+JoZjz+PX+clp2uVYFtn03eillguVjENfB4jd98kXO+PDmdz0Md56d8NoHFmym6R+e8 ++sAATa4x/ru6l/Dsl3fvv0flCmqYRrUrd5vXOeMF/ns/ynf98OQ/+D+sEZq8n4Wn+c/+Pj7JSt1kp ++3IZJBfEnKFEx5tBDgowdw0rYCv0nkLXG1mfjUlR2KwvdKrwuhj1pZULpj66FGEss1sKjgiHnQgz8 ++Bm87wFbIX6JCVpmYhqSHRJqu9V84JDa0mK5C+DIccB43nFsMvb4Nff88zFygk1aXh3PWbA/FL9HH ++8E8fmj6ROxsexXdrKovOTSG9vXR2fxyD9GFumDW67jtXjDXjIK7Q6vVNvPSu7u7eEN7YVtfo4MPj ++ndDoysa5ra1poM/Bh5gI4xtLPg4ziy82aNoLOOBSnz9r1CoIC93vFP0WDiw2pkf1GfpR+64RKG1R ++emNvQJmgujUe8Fo7z6J7R5Ds/5tst4sxlBsD0691DT5qG81ex5vHMzSqdMr+9QsgCIIgCIIgCIIg ++CIIgCIIgCIIgCIIgCIJ43/wFwVnZCwAoAAA= +diff --git 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-001924/tests/test.sh b/tasks/format-code-task-001924/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..438ec9c4d4910842664af7bcd2922310729e2545 --- /dev/null +++ b/tasks/format-code-task-001924/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' +client/client_grpc_index_test.go +client/v2/client_grpc_index_test.go +test/base/milvus_client.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-001924/tests/test_command.sh b/tasks/format-code-task-001924/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001924/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001947/environment/Dockerfile b/tasks/format-code-task-001947/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ea2f8f36b6755ba7d237b5359cfad83bcfc04fe0 --- /dev/null +++ b/tasks/format-code-task-001947/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3b900a7538362b1000e17ef622818f4c5e5f5b4c1cd571e2c847bf963db44d97 diff --git a/tasks/format-code-task-001947/environment/setup/files/blocklist b/tasks/format-code-task-001947/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001947/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001947/environment/setup/setup.sh b/tasks/format-code-task-001947/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001947/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001947/tests/test.patch b/tasks/format-code-task-001947/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..192f448f465fbf6eb3eaae7cf6d6e7de2cb3d8fa --- /dev/null +++ b/tasks/format-code-task-001947/tests/test.patch @@ -0,0 +1,96 @@ +diff --git a/mne/tests/test_filter.py b/mne/tests/test_filter.py +index 47effe4ac..7fa592351 100644 +--- a/mne/tests/test_filter.py ++++ b/mne/tests/test_filter.py +@@ -490,6 +490,78 @@ def test_resample_below_1_sample(): + assert epochs.get_data().shape[2] == 1 + + ++def test_resample_noop_raw(): ++ """Test Raw.resample is a no-op when sfreq already equals target.""" ++ rng = np.random.RandomState(0) ++ x = rng.randn(2, 200) ++ sfreq = 250.0 ++ raw = RawArray(x.copy(), create_info(2, sfreq, "eeg")) ++ original_n_times = raw.n_times ++ result = raw.resample(sfreq) ++ assert result is raw ++ assert raw.info["sfreq"] == sfreq ++ assert raw.n_times == original_n_times ++ ++ assert_array_equal(raw.get_data(), x) ++ ++ ++def test_resample_noop_epochs_preloaded(): ++ """Test Epochs.resample no-op preserves data identity.""" ++ rng = np.random.RandomState(0) ++ x = rng.randn(1, 10000) ++ sfreq = 1000.0 ++ raw = RawArray(x, create_info(1, sfreq, "eeg")) ++ events = np.array([[400, 0, 1], [2000, 0, 1], [3000, 0, 1]]) ++ epochs = Epochs( ++ raw, ++ events, ++ {"test": 1}, ++ 0, ++ 0.2, ++ proj=False, ++ picks="eeg", ++ baseline=None, ++ preload=True, ++ verbose=False, ++ ) ++ original_data_copy = epochs._data.copy() ++ original_times = epochs.times.copy() ++ result = epochs.resample(sfreq) ++ assert result is epochs ++ assert epochs.info["sfreq"] == sfreq ++ ++ assert_array_equal(epochs._data, original_data_copy) ++ assert_array_equal(epochs.times, original_times) ++ ++ ++def test_resample_noop_stc(): ++ """Test SourceEstimate.resample is a no-op when sfreq matches.""" ++ from mne import SourceEstimate ++ ++ rng = np.random.RandomState(0) ++ vertices = [np.arange(5), 5 + np.arange(5)] ++ data = rng.randn(10, 20) ++ tstep = 0.01 ++ stc = SourceEstimate(data.copy(), vertices=vertices, tmin=0.0, tstep=tstep) ++ original_data_copy = stc.data.copy() ++ target_sfreq = 1.0 / tstep ++ result = stc.resample(target_sfreq) ++ assert result is stc ++ assert stc.tstep == tstep ++ ++ assert_array_equal(stc.data, original_data_copy) ++ ++ ++def test_resample_different_sfreq_still_resamples(): ++ """Regression: resampling with a different sfreq still works.""" ++ x = np.zeros((1, 1000)) ++ raw = RawArray(x, create_info(1, 1000.0, "eeg")) ++ n_orig = raw.n_times ++ raw.resample(500, npad=10) ++ assert raw.info["sfreq"] == 500.0 ++ assert raw.n_times != n_orig ++ ++ + @pytest.mark.slowtest + def test_filters(): + """Test low-, band-, high-pass, and band-stop filters plus resampling.""" +diff --git 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/tests/test_filter.py -k "test_resample_noop or test_resample_different_sfreq_still" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001947/tests/test.sh b/tasks/format-code-task-001947/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..224177cb6b25362c21eea5866c54bbbe8dea89e6 --- /dev/null +++ b/tasks/format-code-task-001947/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' +mne/tests/test_filter.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-001947/tests/test_command.sh b/tasks/format-code-task-001947/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001947/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001949/environment/Dockerfile b/tasks/format-code-task-001949/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..797897b96addcc16c7e84aca14980e0e8af829f0 --- /dev/null +++ b/tasks/format-code-task-001949/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e0822a17d8bd42cd057f253b49c3d421092000a9dcd4c5693e7b4b3f6b755ed3 diff --git a/tasks/format-code-task-001949/environment/setup/files/blocklist b/tasks/format-code-task-001949/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001949/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001949/environment/setup/setup.sh b/tasks/format-code-task-001949/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001949/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001949/tests/test.patch b/tasks/format-code-task-001949/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fde43f124895d2c0a4703ba100259c12e6c55fc9 --- /dev/null +++ b/tasks/format-code-task-001949/tests/test.patch @@ -0,0 +1,103 @@ +diff --git a/mne/time_frequency/tests/test_tfr.py b/mne/time_frequency/tests/test_tfr.py +index 4279d9f89..a1b65c3ae 100644 +--- a/mne/time_frequency/tests/test_tfr.py ++++ b/mne/time_frequency/tests/test_tfr.py +@@ -421,6 +421,76 @@ def test_io(): + assert_array_equal(tfr.data, read_tfr.data) + + ++@requires_h5py ++@requires_pandas ++def test_io_epochstfr_metadata_roundtrip(): ++ """Test that EpochsTFR.save preserves metadata, events and event_id.""" ++ from pandas import DataFrame ++ tempdir = _TempDir() ++ fname = op.join(tempdir, 'test-tfr.h5') ++ info = create_info(['MEG 001', 'MEG 002', 'MEG 003'], 1000., ++ ['mag', 'mag', 'mag']) ++ data = np.zeros((5, 3, 2, 3)) ++ times = np.array([.1, .2, .3]) ++ freqs = np.array([.10, .20]) ++ ++ ++ ++ meta = DataFrame(dict(RT=np.array([0.11, 0.22, 0.33, 0.44, 0.55]), ++ Trial=['face', 'place', 'face', 'place', 'face'])) ++ events = np.array([[10, 0, 1], ++ [20, 0, 2], ++ [30, 0, 1], ++ [40, 0, 2], ++ [50, 0, 1]]) ++ event_id = {'face': 1, 'place': 2} ++ ++ tfr = EpochsTFR(info, data=data, times=times, freqs=freqs, ++ comment='test', method='crazy-tfr', ++ events=events, event_id=event_id, metadata=meta) ++ tfr.save(fname, True) ++ read_tfr = read_tfrs(fname)[0] ++ ++ ++ assert_array_equal(tfr.data, read_tfr.data) ++ ++ assert read_tfr.events is not None ++ assert_array_equal(read_tfr.events, events) ++ ++ assert read_tfr.event_id == event_id ++ ++ assert read_tfr.metadata is not None ++ assert_metadata_equal(read_tfr.metadata, meta) ++ ++ ++@requires_h5py ++@requires_pandas ++def test_io_epochstfr_metadata_none_roundtrip(): ++ """EpochsTFR with metadata=None should round-trip with metadata None.""" ++ tempdir = _TempDir() ++ fname = op.join(tempdir, 'test-tfr.h5') ++ info = create_info(['MEG 001', 'MEG 002', 'MEG 003'], 1000., ++ ['mag', 'mag', 'mag']) ++ data = np.zeros((4, 3, 2, 3)) ++ times = np.array([.1, .2, .3]) ++ freqs = np.array([.10, .20]) ++ ++ events = np.array([[5, 0, 7], ++ [15, 0, 7], ++ [25, 0, 8], ++ [35, 0, 8]]) ++ event_id = {'seven': 7, 'eight': 8} ++ ++ tfr = EpochsTFR(info, data=data, times=times, freqs=freqs, ++ events=events, event_id=event_id, metadata=None) ++ tfr.save(fname, True) ++ read_tfr = read_tfrs(fname)[0] ++ ++ assert read_tfr.metadata is None ++ assert_array_equal(read_tfr.events, events) ++ assert read_tfr.event_id == event_id ++ ++ + def test_plot(): + """Test TFR plotting.""" + import matplotlib.pyplot as plt +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..1bf0846de +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest mne/time_frequency/tests/test_tfr.py::test_io_epochstfr_metadata_roundtrip mne/time_frequency/tests/test_tfr.py::test_io_epochstfr_metadata_none_roundtrip -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/time_frequency/tests/test_tfr.py::test_io_epochstfr_metadata_roundtrip mne/time_frequency/tests/test_tfr.py::test_io_epochstfr_metadata_none_roundtrip -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001949/tests/test.sh b/tasks/format-code-task-001949/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bd3d7532a894aa7a7b58116c170ae867cfddb407 --- /dev/null +++ b/tasks/format-code-task-001949/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/time_frequency/tests/test_tfr.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-001949/tests/test_command.sh b/tasks/format-code-task-001949/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001949/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001976/environment/Dockerfile b/tasks/format-code-task-001976/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..59d44fdc0a0bdae7a7d92ae1a12d6a28e31ee8d5 --- /dev/null +++ b/tasks/format-code-task-001976/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cfa668f57ee0ee8ed1575c8d95d2ee6c95dea23229879c973e33c08092829e7b diff --git a/tasks/format-code-task-001976/environment/setup/files/blocklist b/tasks/format-code-task-001976/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001976/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001976/environment/setup/setup.sh b/tasks/format-code-task-001976/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001976/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001976/tests/test.patch b/tasks/format-code-task-001976/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1eb15a8cd77ab582e0e0ef15d58b8d216e15f0d6 --- /dev/null +++ b/tasks/format-code-task-001976/tests/test.patch @@ -0,0 +1,625 @@ +diff --git a/usercase-test-coderl/config_loader_test.go b/usercase-test-coderl/config_loader_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/config_loader_test.go +@@ -0,0 +1,563 @@ ++package usercase_test_coderl ++ ++ ++ ++ ++import ( ++ "encoding/json" ++ "fmt" ++ "io/ioutil" ++ "os" ++ "os/exec" ++ "path/filepath" ++ "reflect" ++ "strings" ++ "testing" ++ ++ "github.com/hellofresh/janus/pkg/config" ++) ++ ++const fixturesDir = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++type specSnapshot struct { ++ Port int `json:"port"` ++ WebPort int `json:"webPort"` ++ DatabaseDSN string `json:"databaseDsn"` ++ RequestID bool `json:"requestId"` ++ TLSPort int `json:"tlsPort"` ++ WebTLSPort int `json:"webTlsPort"` ++ BackendFlushIntervalNanos int64 `json:"backendFlushIntervalNanos"` ++ RespondingIdleTimeoutNanos int64 `json:"respondingIdleTimeoutNanos"` ++ ClusterUpdateFrequencyNanos int64 `json:"clusterUpdateFrequencyNanos"` ++ CredentialsAlgorithm string `json:"credentialsAlgorithm"` ++ CredentialsTimeoutNanos int64 `json:"credentialsTimeoutNanos"` ++ BasicUsers map[string]string `json:"basicUsers"` ++ StatsDSN string `json:"statsDsn"` ++ StatsErrorsSection string `json:"statsErrorsSection"` ++ StatsAutoDiscoverWhiteList []string `json:"statsAutoDiscoverWhiteList"` ++ GithubOrganizations []string `json:"githubOrganizations"` ++ GithubTeams map[string]string `json:"githubTeams"` ++ JanusAdminTeam string `json:"janusAdminTeam"` ++ TracingServiceName string `json:"tracingServiceName"` ++ TracingSamplingStrategy string `json:"tracingSamplingStrategy"` ++ TracingSamplingParam float64 `json:"tracingSamplingParam"` ++ TracingIsPublicEndpoint bool `json:"tracingIsPublicEndpoint"` ++} ++ ++type helperPayload struct { ++ Spec *specSnapshot `json:"spec,omitempty"` ++ First *specSnapshot `json:"first,omitempty"` ++ Noise *specSnapshot `json:"noise,omitempty"` ++ Second *specSnapshot `json:"second,omitempty"` ++ NilSpec bool `json:"nilSpec,omitempty"` ++ ErrorMessage string `json:"errorMessage,omitempty"` ++ ErrorHasPrefix bool `json:"errorHasPrefix,omitempty"` ++} ++ ++func TestLoadExplicitPathAppliesPartialTomlAndDefaults(t *testing.T) { ++ ++ ++ path := filepath.Join(fixturesDir, "explicit_config.toml") ++ ++ payload := runHelper(t, "", nil, "load-explicit", path) ++ ++ expected := &specSnapshot{ ++ Port: 9000, ++ WebPort: 9001, ++ DatabaseDSN: "file:///tmp/apis", ++ RequestID: true, ++ TLSPort: 8433, ++ WebTLSPort: 8444, ++ BackendFlushIntervalNanos: 20000000, ++ RespondingIdleTimeoutNanos: 180000000000, ++ ClusterUpdateFrequencyNanos: 10000000000, ++ CredentialsAlgorithm: "HS256", ++ CredentialsTimeoutNanos: 3600000000000, ++ BasicUsers: map[string]string{"admin": "admin"}, ++ StatsDSN: "log://", ++ StatsErrorsSection: "error-log", ++ GithubTeams: map[string]string{}, ++ TracingServiceName: "janus", ++ TracingSamplingStrategy: "probabilistic", ++ TracingSamplingParam: 0.15, ++ TracingIsPublicEndpoint: true, ++ } ++ assertSnapshotEqual(t, expected, payload.Spec) ++} ++ ++func TestLoadEmptyPathFindsJanusInCurrentDirectory(t *testing.T) { ++ ++ ++ tmp := t.TempDir() ++ copyFixture(t, "current_search_config.toml", filepath.Join(tmp, "janus.toml")) ++ ++ payload := runHelper(t, tmp, map[string]string{"HOME": t.TempDir()}, "load-empty") ++ ++ expected := &specSnapshot{ ++ Port: 9100, ++ WebPort: 8081, ++ DatabaseDSN: "file:///current-apis", ++ RequestID: true, ++ TLSPort: 8433, ++ WebTLSPort: 8444, ++ BackendFlushIntervalNanos: 20000000, ++ RespondingIdleTimeoutNanos: 180000000000, ++ ClusterUpdateFrequencyNanos: 10000000000, ++ CredentialsAlgorithm: "HS256", ++ CredentialsTimeoutNanos: 3600000000000, ++ BasicUsers: map[string]string{"admin": "admin"}, ++ StatsDSN: "log://", ++ StatsErrorsSection: "error-log", ++ GithubTeams: map[string]string{}, ++ TracingServiceName: "janus", ++ TracingSamplingStrategy: "probabilistic", ++ TracingSamplingParam: 0.15, ++ TracingIsPublicEndpoint: true, ++ } ++ assertSnapshotEqual(t, expected, payload.Spec) ++} ++ ++func TestLoadEmptyPathFindsJanusInHomeDirectory(t *testing.T) { ++ ++ ++ cwd := t.TempDir() ++ home := t.TempDir() ++ copyFixture(t, "home_search_config.toml", filepath.Join(home, "janus.toml")) ++ ++ payload := runHelper(t, cwd, map[string]string{"HOME": home}, "load-empty") ++ ++ expected := &specSnapshot{ ++ Port: 8080, ++ WebPort: 9202, ++ DatabaseDSN: "file:///home-apis", ++ RequestID: true, ++ TLSPort: 8433, ++ WebTLSPort: 8444, ++ BackendFlushIntervalNanos: 20000000, ++ RespondingIdleTimeoutNanos: 180000000000, ++ ClusterUpdateFrequencyNanos: 10000000000, ++ CredentialsAlgorithm: "HS256", ++ CredentialsTimeoutNanos: 3600000000000, ++ BasicUsers: map[string]string{"admin": "admin"}, ++ StatsDSN: "log://", ++ StatsErrorsSection: "error-log", ++ GithubTeams: map[string]string{}, ++ TracingServiceName: "janus", ++ TracingSamplingStrategy: "probabilistic", ++ TracingSamplingParam: 0.15, ++ TracingIsPublicEndpoint: true, ++ } ++ assertSnapshotEqual(t, expected, payload.Spec) ++} ++ ++func TestLoadReturnsNilSpecAndPrefixedErrorForMissingFile(t *testing.T) { ++ ++ ++ missingPath := filepath.Join(t.TempDir(), "missing.toml") ++ payload := runHelper(t, "", nil, "load-missing", missingPath) ++ ++ if !payload.NilSpec { ++ t.Fatalf("Load missing file returned non-nil specification") ++ } ++ if !payload.ErrorHasPrefix { ++ t.Fatalf("Load missing file error %q does not start with config file not found:", payload.ErrorMessage) ++ } ++ ++ if payload.ErrorMessage == "" { ++ t.Fatalf("Load missing file returned an empty error message") ++ } ++} ++ ++func TestLoadEnvWithNoRelevantEnvironmentReturnsDefaults(t *testing.T) { ++ ++ ++ payload := runHelper(t, "", nil, "load-env-default") ++ ++ expected := &specSnapshot{ ++ Port: 8080, ++ WebPort: 8081, ++ DatabaseDSN: "file:///etc/janus", ++ RequestID: true, ++ TLSPort: 8433, ++ WebTLSPort: 8444, ++ BackendFlushIntervalNanos: 20000000, ++ RespondingIdleTimeoutNanos: 180000000000, ++ ClusterUpdateFrequencyNanos: 10000000000, ++ CredentialsAlgorithm: "HS256", ++ CredentialsTimeoutNanos: 3600000000000, ++ BasicUsers: map[string]string{"admin": "admin"}, ++ StatsDSN: "log://", ++ StatsErrorsSection: "error-log", ++ GithubTeams: map[string]string{}, ++ TracingServiceName: "janus", ++ TracingSamplingStrategy: "probabilistic", ++ TracingSamplingParam: 0.15, ++ TracingIsPublicEndpoint: true, ++ } ++ assertSnapshotEqual(t, expected, payload.Spec) ++} ++ ++func TestLoadEnvParsesScalarSliceMapAndDurationVariables(t *testing.T) { ++ ++ ++ env := map[string]string{ ++ "PORT": "8001", ++ "STATS_AUTO_DISCOVER_WHITE_LIST": "api,foo,bar", ++ "BASIC_USERS": "admin:admin,test:test", ++ "GITHUB_ORGANIZATIONS": "hellofresh,tests", ++ "GITHUB_TEAMS": "hellofresh:tests,tests:devs", ++ "JANUS_ADMIN_TEAM": "janus-owners", ++ "TOKEN_TIMEOUT": "2h", ++ } ++ ++ payload := runHelper(t, "", env, "load-env-custom") ++ ++ expected := &specSnapshot{ ++ Port: 8001, ++ WebPort: 8081, ++ DatabaseDSN: "file:///etc/janus", ++ RequestID: true, ++ TLSPort: 8001, ++ WebTLSPort: 8001, ++ BackendFlushIntervalNanos: 20000000, ++ RespondingIdleTimeoutNanos: 180000000000, ++ ClusterUpdateFrequencyNanos: 10000000000, ++ CredentialsAlgorithm: "HS256", ++ CredentialsTimeoutNanos: 7200000000000, ++ BasicUsers: map[string]string{"admin": "admin", "test": "test"}, ++ StatsDSN: "log://", ++ StatsErrorsSection: "error-log", ++ StatsAutoDiscoverWhiteList: []string{"api", "foo", "bar"}, ++ GithubOrganizations: []string{"hellofresh", "tests"}, ++ GithubTeams: map[string]string{"hellofresh": "tests", "tests": "devs"}, ++ JanusAdminTeam: "janus-owners", ++ TracingServiceName: "janus", ++ TracingSamplingStrategy: "probabilistic", ++ TracingSamplingParam: 0.15, ++ TracingIsPublicEndpoint: true, ++ } ++ assertSnapshotEqual(t, expected, payload.Spec) ++} ++ ++func TestLoadEnvInvalidDurationReturnsNilSpecAndError(t *testing.T) { ++ ++ ++ payload := runHelper(t, "", map[string]string{"TOKEN_TIMEOUT": "definitely-not-a-duration"}, "load-env-bad-duration") ++ ++ if !payload.NilSpec { ++ t.Fatalf("LoadEnv invalid duration returned non-nil specification") ++ } ++ ++ if payload.ErrorMessage == "" { ++ t.Fatalf("LoadEnv invalid duration returned an empty error message") ++ } ++} ++ ++func TestLoadEnvReferentialTransparencyForSameEnvironment(t *testing.T) { ++ payload := runHelper(t, "", nil, "load-env-repeat-default") ++ expected := defaultSnapshotLiteral() ++ ++ assertSnapshotEqual(t, expected, payload.First) ++ assertSnapshotEqual(t, expected, payload.Second) ++} ++ ++func TestLoadExplicitPathIsReadFromCallerProvidedFile(t *testing.T) { ++ tmp := t.TempDir() ++ path := filepath.Join(tmp, "config.toml") ++ copyFixture(t, "explicit_config.toml", path) ++ ++ payload := runHelper(t, "", nil, "load-explicit", path) ++ ++ ++ if payload.Spec == nil || payload.Spec.Port != 9000 || payload.Spec.WebPort != 9001 || payload.Spec.DatabaseDSN != "file:///tmp/apis" { ++ t.Fatalf("sanity check failed: helper did not load the explicit config: %#v", payload.Spec) ++ } ++} ++ ++func TestLoadEnvNoGlobalStateAcrossDifferentEnvironments(t *testing.T) { ++ payload := runHelper(t, "", nil, "load-env-no-global-state") ++ ++ assertSnapshotEqual(t, defaultSnapshotLiteral(), payload.First) ++ assertSnapshotEqual(t, customEnvSnapshotLiteral(), payload.Noise) ++ assertSnapshotEqual(t, defaultSnapshotLiteral(), payload.Second) ++} ++ ++func TestLoadEnvDefaultsInArbitraryWorkingDirectory(t *testing.T) { ++ tmp := t.TempDir() ++ ++ payload := runHelper(t, tmp, nil, "load-env-default") ++ ++ ++ if payload.Spec == nil { ++ t.Fatalf("LoadEnv returned nil specification in isolated cwd") ++ } ++ assertSnapshotEqual(t, defaultSnapshotLiteral(), payload.Spec) ++} ++ ++func TestUsercaseHelperProcess(t *testing.T) { ++ if os.Getenv("USERCASE_HELPER_PROCESS") != "1" { ++ return ++ } ++ ++ args := os.Args ++ for len(args) > 0 && args[0] != "--" { ++ args = args[1:] ++ } ++ if len(args) < 2 { ++ fmt.Fprintln(os.Stderr, "missing helper scenario") ++ os.Exit(2) ++ } ++ scenario := args[1] ++ rest := args[2:] ++ ++ payload := runScenario(scenario, rest) ++ if err := json.NewEncoder(os.Stdout).Encode(payload); err != nil { ++ fmt.Fprintln(os.Stderr, err) ++ os.Exit(2) ++ } ++ os.Exit(0) ++} ++ ++func runScenario(scenario string, args []string) helperPayload { ++ switch scenario { ++ case "load-explicit": ++ spec, err := config.Load(args[0]) ++ mustNoError(err) ++ return helperPayload{Spec: snapshot(spec)} ++ case "load-empty": ++ spec, err := config.Load("") ++ mustNoError(err) ++ return helperPayload{Spec: snapshot(spec)} ++ case "load-missing": ++ spec, err := config.Load(args[0]) ++ return helperPayload{ ++ NilSpec: spec == nil, ++ ErrorMessage: errString(err), ++ ErrorHasPrefix: strings.HasPrefix(errString(err), "config file not found:"), ++ } ++ case "load-env-default": ++ spec, err := config.LoadEnv() ++ mustNoError(err) ++ return helperPayload{Spec: snapshot(spec)} ++ case "load-env-custom": ++ spec, err := config.LoadEnv() ++ mustNoError(err) ++ return helperPayload{Spec: snapshot(spec)} ++ case "load-env-bad-duration": ++ spec, err := config.LoadEnv() ++ return helperPayload{ ++ NilSpec: spec == nil, ++ ErrorMessage: errString(err), ++ } ++ case "load-env-repeat-default": ++ first, err := config.LoadEnv() ++ mustNoError(err) ++ second, err := config.LoadEnv() ++ mustNoError(err) ++ return helperPayload{First: snapshot(first), Second: snapshot(second)} ++ case "load-env-no-global-state": ++ os.Clearenv() ++ first, err := config.LoadEnv() ++ mustNoError(err) ++ setCustomEnv() ++ noise, err := config.LoadEnv() ++ mustNoError(err) ++ os.Clearenv() ++ second, err := config.LoadEnv() ++ mustNoError(err) ++ return helperPayload{First: snapshot(first), Noise: snapshot(noise), Second: snapshot(second)} ++ default: ++ fmt.Fprintf(os.Stderr, "unknown helper scenario %q\n", scenario) ++ os.Exit(2) ++ } ++ return helperPayload{} ++} ++ ++func runHelper(t *testing.T, dir string, env map[string]string, scenario string, args ...string) helperPayload { ++ t.Helper() ++ cmdArgs := append([]string{"-test.run=TestUsercaseHelperProcess", "--", scenario}, args...) ++ cmd := exec.Command(os.Args[0], cmdArgs...) ++ if dir != "" { ++ cmd.Dir = dir ++ } ++ ++ cmd.Env = []string{ ++ "USERCASE_HELPER_PROCESS=1", ++ "PATH=" + os.Getenv("PATH"), ++ } ++ for k, v := range env { ++ cmd.Env = append(cmd.Env, k+"="+v) ++ } ++ ++ out, err := cmd.CombinedOutput() ++ if err != nil { ++ t.Fatalf("helper %s failed: %v\n%s", scenario, err, out) ++ } ++ ++ var payload helperPayload ++ if err := json.Unmarshal(out, &payload); err != nil { ++ t.Fatalf("helper %s returned invalid JSON: %v\n%s", scenario, err, out) ++ } ++ return payload ++} ++ ++func snapshot(s *config.Specification) *specSnapshot { ++ if s == nil { ++ return nil ++ } ++ return &specSnapshot{ ++ Port: s.Port, ++ WebPort: s.Web.Port, ++ DatabaseDSN: s.Database.DSN, ++ RequestID: s.RequestID, ++ TLSPort: s.TLS.Port, ++ WebTLSPort: s.Web.TLS.Port, ++ BackendFlushIntervalNanos: s.BackendFlushInterval.Nanoseconds(), ++ RespondingIdleTimeoutNanos: s.RespondingTimeouts.IdleTimeout.Nanoseconds(), ++ ClusterUpdateFrequencyNanos: s.Cluster.UpdateFrequency.Nanoseconds(), ++ CredentialsAlgorithm: s.Web.Credentials.Algorithm, ++ CredentialsTimeoutNanos: s.Web.Credentials.Timeout.Nanoseconds(), ++ BasicUsers: s.Web.Credentials.Basic.Users, ++ StatsDSN: s.Stats.DSN, ++ StatsErrorsSection: s.Stats.ErrorsSection, ++ StatsAutoDiscoverWhiteList: s.Stats.AutoDiscoverWhiteList, ++ GithubOrganizations: s.Web.Credentials.Github.Organizations, ++ GithubTeams: s.Web.Credentials.Github.Teams, ++ JanusAdminTeam: s.Web.Credentials.JanusAdminTeam, ++ TracingServiceName: s.Tracing.ServiceName, ++ TracingSamplingStrategy: s.Tracing.SamplingStrategy, ++ TracingSamplingParam: s.Tracing.SamplingParam, ++ TracingIsPublicEndpoint: s.Tracing.IsPublicEndpoint, ++ } ++} ++ ++func defaultSnapshotLiteral() *specSnapshot { ++ return &specSnapshot{ ++ Port: 8080, ++ WebPort: 8081, ++ DatabaseDSN: "file:///etc/janus", ++ RequestID: true, ++ TLSPort: 8433, ++ WebTLSPort: 8444, ++ BackendFlushIntervalNanos: 20000000, ++ RespondingIdleTimeoutNanos: 180000000000, ++ ClusterUpdateFrequencyNanos: 10000000000, ++ CredentialsAlgorithm: "HS256", ++ CredentialsTimeoutNanos: 3600000000000, ++ BasicUsers: map[string]string{"admin": "admin"}, ++ StatsDSN: "log://", ++ StatsErrorsSection: "error-log", ++ GithubTeams: map[string]string{}, ++ TracingServiceName: "janus", ++ TracingSamplingStrategy: "probabilistic", ++ TracingSamplingParam: 0.15, ++ TracingIsPublicEndpoint: true, ++ } ++} ++ ++func customEnvSnapshotLiteral() *specSnapshot { ++ return &specSnapshot{ ++ Port: 8001, ++ WebPort: 8081, ++ DatabaseDSN: "file:///etc/janus", ++ RequestID: true, ++ TLSPort: 8001, ++ WebTLSPort: 8001, ++ BackendFlushIntervalNanos: 20000000, ++ RespondingIdleTimeoutNanos: 180000000000, ++ ClusterUpdateFrequencyNanos: 10000000000, ++ CredentialsAlgorithm: "HS256", ++ CredentialsTimeoutNanos: 7200000000000, ++ BasicUsers: map[string]string{"admin": "admin", "test": "test"}, ++ StatsDSN: "log://", ++ StatsErrorsSection: "error-log", ++ StatsAutoDiscoverWhiteList: []string{"api", "foo", "bar"}, ++ GithubOrganizations: []string{"hellofresh", "tests"}, ++ GithubTeams: map[string]string{"hellofresh": "tests", "tests": "devs"}, ++ JanusAdminTeam: "janus-owners", ++ TracingServiceName: "janus", ++ TracingSamplingStrategy: "probabilistic", ++ TracingSamplingParam: 0.15, ++ TracingIsPublicEndpoint: true, ++ } ++} ++ ++func assertSnapshotEqual(t *testing.T, expected, actual *specSnapshot) { ++ t.Helper() ++ expected = normalizeSnapshotForFairComparison(expected) ++ actual = normalizeSnapshotForFairComparison(actual) ++ if expected != nil && actual != nil && expected.Port == 8001 && expected.TLSPort == 8001 && expected.WebTLSPort == 8001 { ++ ++ if actual.TLSPort != 8433 && actual.TLSPort != 8001 { ++ t.Fatalf("unexpected TLS port for custom env: got %d", actual.TLSPort) ++ } ++ if actual.WebTLSPort != 8444 && actual.WebTLSPort != 8001 { ++ t.Fatalf("unexpected web TLS port for custom env: got %d", actual.WebTLSPort) ++ } ++ expected.TLSPort = actual.TLSPort ++ expected.WebTLSPort = actual.WebTLSPort ++ } ++ if !reflect.DeepEqual(expected, actual) { ++ t.Fatalf("unexpected spec snapshot\nexpected: %#v\nactual: %#v", expected, actual) ++ } ++} ++ ++func normalizeSnapshotForFairComparison(snapshot *specSnapshot) *specSnapshot { ++ if snapshot == nil { ++ return nil ++ } ++ normalized := *snapshot ++ ++ if len(normalized.StatsAutoDiscoverWhiteList) == 0 { ++ normalized.StatsAutoDiscoverWhiteList = nil ++ } ++ if len(normalized.GithubOrganizations) == 0 { ++ normalized.GithubOrganizations = nil ++ } ++ if len(normalized.GithubTeams) == 0 { ++ normalized.GithubTeams = nil ++ } ++ return &normalized ++} ++ ++func copyFixture(t *testing.T, name, dst string) { ++ t.Helper() ++ data := readFile(t, filepath.Join(fixturesDir, name)) ++ if err := ioutil.WriteFile(dst, data, 0644); err != nil { ++ t.Fatalf("write %s: %v", dst, err) ++ } ++} ++ ++func readFile(t *testing.T, path string) []byte { ++ t.Helper() ++ data, err := ioutil.ReadFile(path) ++ if err != nil { ++ t.Fatalf("read %s: %v", path, err) ++ } ++ return data ++} ++ ++func setCustomEnv() { ++ os.Clearenv() ++ os.Setenv("PORT", "8001") ++ os.Setenv("STATS_AUTO_DISCOVER_WHITE_LIST", "api,foo,bar") ++ os.Setenv("BASIC_USERS", "admin:admin,test:test") ++ os.Setenv("GITHUB_ORGANIZATIONS", "hellofresh,tests") ++ os.Setenv("GITHUB_TEAMS", "hellofresh:tests,tests:devs") ++ os.Setenv("JANUS_ADMIN_TEAM", "janus-owners") ++ os.Setenv("TOKEN_TIMEOUT", "2h") ++} ++ ++func mustNoError(err error) { ++ if err != nil { ++ fmt.Fprintln(os.Stderr, err) ++ os.Exit(2) ++ } ++} ++ ++func errString(err error) string { ++ if err == nil { ++ return "" ++ } ++ return err.Error() ++} +diff --git a/usercase-test-coderl/fixtures/current_search_config.toml b/usercase-test-coderl/fixtures/current_search_config.toml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/current_search_config.toml +@@ -0,0 +1,4 @@ ++port = 9100 ++ ++[database] ++dsn = "file:///current-apis" +diff --git a/usercase-test-coderl/fixtures/explicit_config.toml b/usercase-test-coderl/fixtures/explicit_config.toml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/explicit_config.toml +@@ -0,0 +1,7 @@ ++port = 9000 ++ ++[web] ++port = 9001 ++ ++[database] ++dsn = "file:///tmp/apis" +diff --git a/usercase-test-coderl/fixtures/home_search_config.toml b/usercase-test-coderl/fixtures/home_search_config.toml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/home_search_config.toml +@@ -0,0 +1,5 @@ ++[web] ++port = 9202 ++ ++[database] ++dsn = "file:///home-apis" +diff --git 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" ++export GO111MODULE=on ++export GOPROXY=off ++export GOSUMDB=off ++export GONOSUMDB='*' ++export GOVCS='*:off' ++export GOTOOLCHAIN=local ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001976/tests/test.sh b/tasks/format-code-task-001976/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1673c518b10ee223341cdf3b5088b9d76ed063a3 --- /dev/null +++ b/tasks/format-code-task-001976/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/config_loader_test.go +usercase-test-coderl/fixtures/current_search_config.toml +usercase-test-coderl/fixtures/explicit_config.toml +usercase-test-coderl/fixtures/home_search_config.toml +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001976/tests/test_command.sh b/tasks/format-code-task-001976/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001976/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-001977/environment/Dockerfile b/tasks/format-code-task-001977/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8249a20ea0f8028c4f29a45fd2b7ded2c2daf3d4 --- /dev/null +++ b/tasks/format-code-task-001977/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:51bbc07769fc7589b6d44edc868ea50d2d79d7b7ef7764c98c7e19dfef142dc2 diff --git a/tasks/format-code-task-001977/environment/setup/files/blocklist b/tasks/format-code-task-001977/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001977/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001977/environment/setup/setup.sh b/tasks/format-code-task-001977/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001977/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001977/tests/test.patch b/tasks/format-code-task-001977/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..aba5f710db21c288fa88ec4ef7bda0261224e953 --- /dev/null +++ b/tasks/format-code-task-001977/tests/test.patch @@ -0,0 +1,257 @@ +diff --git a/test/test_new_api.js b/test/test_new_api.js +new file mode 100644 +index 0000000..42e31e3 +--- /dev/null ++++ b/test/test_new_api.js +@@ -0,0 +1,229 @@ ++'use strict'; ++ ++ ++ ++var rbush = require('../rbush.js'), ++ t = require('tape'); ++ ++function sortedEqual(t, a, b, compare) { ++ compare = compare || function (x, y) { ++ return x.minX - y.minX || x.minY - y.minY || x.maxX - y.maxX || x.maxY - y.maxY; ++ }; ++ t.same(a.slice().sort(compare), b.slice().sort(compare)); ++} ++ ++function makeData() { ++ var arr = [ ++ [0,0,0,0],[10,10,10,10],[20,20,20,20],[25,0,25,0],[35,10,35,10],[45,20,45,20],[0,25,0,25],[10,35,10,35], ++ [20,45,20,45],[25,25,25,25],[35,35,35,35],[45,45,45,45],[50,0,50,0],[60,10,60,10],[70,20,70,20],[75,0,75,0], ++ [85,10,85,10],[95,20,95,20],[50,25,50,25],[60,35,60,35],[70,45,70,45],[75,25,75,25],[85,35,85,35],[95,45,95,45], ++ [0,50,0,50],[10,60,10,60],[20,70,20,70],[25,50,25,50],[35,60,35,60],[45,70,45,70],[0,75,0,75],[10,85,10,85], ++ [20,95,20,95],[25,75,25,75],[35,85,35,85],[45,95,45,95],[50,50,50,50],[60,60,60,60],[70,70,70,70],[75,50,75,50], ++ [85,60,85,60],[95,70,95,70],[50,75,50,75],[60,85,60,85],[70,95,70,95],[75,75,75,75],[85,85,85,85],[95,95,95,95] ++ ]; ++ return arr.map(function (a) { ++ return {minX: a[0], minY: a[1], maxX: a[2], maxY: a[3]}; ++ }); ++} ++ ++t('toBBox with custom format constructor returns object with minX/minY/maxX/maxY', function (t) { ++ var tree = rbush(4, ['.minLng', '.minLat', '.maxLng', '.maxLat']); ++ t.same(tree.toBBox({minLng: 1, minLat: 2, maxLng: 3, maxLat: 4}), ++ {minX: 1, minY: 2, maxX: 3, maxY: 4}); ++ t.end(); ++}); ++ ++t('default toJSON of empty tree has minX/minY/maxX/maxY and no bbox array', function (t) { ++ var tree = rbush(); ++ var d = tree.toJSON(); ++ t.equal(d.minX, Infinity, 'minX is Infinity'); ++ t.equal(d.minY, Infinity, 'minY is Infinity'); ++ t.equal(d.maxX, -Infinity, 'maxX is -Infinity'); ++ t.equal(d.maxY, -Infinity, 'maxY is -Infinity'); ++ t.equal(d.bbox, undefined, 'no bbox array property'); ++ t.equal(d.leaf, true); ++ t.same(d.children, []); ++ t.end(); ++}); ++ ++t('toJSON after inserting one object item: node carries minX/minY/maxX/maxY, no bbox', function (t) { ++ var tree = rbush(4); ++ tree.insert({minX: 1, minY: 2, maxX: 3, maxY: 4}); ++ var d = tree.toJSON(); ++ t.equal(d.bbox, undefined, 'no bbox array property on top-level node'); ++ t.equal(d.minX, 1, 'minX matches'); ++ t.equal(d.minY, 2, 'minY matches'); ++ t.equal(d.maxX, 3, 'maxX matches'); ++ t.equal(d.maxY, 4, 'maxY matches'); ++ t.equal(d.leaf, true); ++ t.equal(d.children.length, 1); ++ t.end(); ++}); ++ ++t('toJSON after load: internal nodes use minX/minY/maxX/maxY (no bbox array property)', function (t) { ++ var data = makeData(); ++ var tree = rbush(4).load(data); ++ var d = tree.toJSON(); ++ t.equal(d.bbox, undefined, 'no bbox property on root'); ++ t.equal(typeof d.minX, 'number', 'root has numeric minX'); ++ t.equal(typeof d.minY, 'number', 'root has numeric minY'); ++ t.equal(typeof d.maxX, 'number', 'root has numeric maxX'); ++ t.equal(typeof d.maxY, 'number', 'root has numeric maxY'); ++ ++ function checkNoBBox(node) { ++ t.equal(node.bbox, undefined, 'inner node has no bbox property'); ++ if (!node.leaf) { ++ node.children.forEach(checkNoBBox); ++ } ++ } ++ checkNoBBox(d); ++ t.end(); ++}); ++ ++t('search with object-form bbox returns inserted items intersecting the query', function (t) { ++ var data = makeData(); ++ var tree = rbush(4).load(data); ++ var result = tree.search({minX: 40, minY: 20, maxX: 80, maxY: 70}); ++ sortedEqual(t, result, [ ++ {minX:70,minY:20,maxX:70,maxY:20},{minX:75,minY:25,maxX:75,maxY:25}, ++ {minX:45,minY:45,maxX:45,maxY:45},{minX:50,minY:50,maxX:50,maxY:50}, ++ {minX:60,minY:60,maxX:60,maxY:60},{minX:70,minY:70,maxX:70,maxY:70}, ++ {minX:45,minY:20,maxX:45,maxY:20},{minX:45,minY:70,maxX:45,maxY:70}, ++ {minX:75,minY:50,maxX:75,maxY:50},{minX:50,minY:25,maxX:50,maxY:25}, ++ {minX:60,minY:35,maxX:60,maxY:35},{minX:70,minY:45,maxX:70,maxY:45} ++ ]); ++ t.end(); ++}); ++ ++t('search returns empty array when no items intersect', function (t) { ++ var data = makeData(); ++ var result = rbush(4).load(data).search({minX: 200, minY: 200, maxX: 210, maxY: 210}); ++ t.same(result, []); ++ t.end(); ++}); ++ ++t('collides returns true when search would find items', function (t) { ++ var data = makeData(); ++ var tree = rbush(4).load(data); ++ t.same(tree.collides({minX: 40, minY: 20, maxX: 80, maxY: 70}), true); ++ t.end(); ++}); ++ ++t('collides returns false when nothing intersects', function (t) { ++ var data = makeData(); ++ var tree = rbush(4).load(data); ++ t.same(tree.collides({minX: 200, minY: 200, maxX: 210, maxY: 210}), false); ++ t.end(); ++}); ++ ++t('all() returns every loaded object item', function (t) { ++ var data = makeData(); ++ var tree = rbush(4).load(data); ++ sortedEqual(t, tree.all(), data); ++ t.end(); ++}); ++ ++t('remove deletes the requested object from the tree', function (t) { ++ var data = makeData(); ++ var tree = rbush(4).load(data); ++ ++ tree.remove(data[0]); ++ tree.remove(data[1]); ++ tree.remove(data[data.length - 1]); ++ ++ var expected = data.slice(2, data.length - 1); ++ sortedEqual(t, tree.all(), expected); ++ t.end(); ++}); ++ ++t('clear empties the tree and yields object-format empty node', function (t) { ++ var data = makeData(); ++ var tree = rbush(4).load(data).clear(); ++ var d = tree.toJSON(); ++ t.equal(d.bbox, undefined, 'cleared root has no bbox array property'); ++ t.equal(d.minX, Infinity); ++ t.equal(d.maxX, -Infinity); ++ t.same(d.children, []); ++ t.equal(d.leaf, true); ++ t.same(tree.all(), []); ++ t.end(); ++}); ++ ++t('insert items one by one yields a tree whose all() matches load()', function (t) { ++ var data = makeData(); ++ var tree = rbush(4); ++ for (var i = 0; i < data.length; i++) { ++ tree.insert(data[i]); ++ } ++ sortedEqual(t, tree.all(), data); ++ ++ t.equal(tree.search({minX: -1, minY: -1, maxX: 1000, maxY: 1000}).length, data.length); ++ t.end(); ++}); ++ ++t('custom toBBox override returning object works with search', function (t) { ++ var tree = rbush(4); ++ tree.toBBox = function (item) { ++ return {minX: item.minLng, minY: item.minLat, maxX: item.maxLng, maxY: item.maxLat}; ++ }; ++ tree.compareMinX = function (a, b) { return a.minLng - b.minLng; }; ++ tree.compareMinY = function (a, b) { return a.minLat - b.minLat; }; ++ ++ var data = [ ++ {minLng: -115, minLat: 45, maxLng: -105, maxLat: 55}, ++ {minLng: 105, minLat: 45, maxLng: 115, maxLat: 55}, ++ {minLng: 105, minLat: -55, maxLng: 115, maxLat: -45}, ++ {minLng: -115, minLat: -55, maxLng: -105, maxLat: -45} ++ ]; ++ tree.load(data); ++ ++ function byLngLat(a, b) { ++ return a.minLng - b.minLng || a.minLat - b.minLat; ++ } ++ ++ sortedEqual(t, tree.search({minX: -180, minY: -90, maxX: 180, maxY: 90}), data, byLngLat); ++ sortedEqual(t, tree.search({minX: -180, minY: -90, maxX: 0, maxY: 90}), [ ++ {minLng: -115, minLat: 45, maxLng: -105, maxLat: 55}, ++ {minLng: -115, minLat: -55, maxLng: -105, maxLat: -45} ++ ], byLngLat); ++ t.end(); ++}); ++ ++t('fromJSON + toJSON round trip preserves contents', function (t) { ++ var data = makeData(); ++ var tree = rbush(4).load(data); ++ var jsonStr = JSON.stringify(tree.toJSON()); ++ var tree2 = rbush(4).fromJSON(JSON.parse(jsonStr)); ++ sortedEqual(t, tree2.all(), data); ++ sortedEqual(t, tree2.search({minX: 0, minY: 0, maxX: 100, maxY: 100}), data); ++ t.end(); ++}); ++ ++t('format constructor + load + search of object-form items works end to end', function (t) { ++ var data = [ ++ {x1: 0, y1: 0, x2: 5, y2: 5}, ++ {x1: 10, y1: 10, x2: 15, y2: 15}, ++ {x1: 20, y1: 20, x2: 25, y2: 25}, ++ {x1: 30, y1: 30, x2: 35, y2: 35}, ++ {x1: 40, y1: 40, x2: 45, y2: 45} ++ ]; ++ var tree = rbush(4, ['.x1', '.y1', '.x2', '.y2']); ++ ++ t.same(tree.toBBox({x1: 1, y1: 2, x2: 3, y2: 4}), {minX: 1, minY: 2, maxX: 3, maxY: 4}, ++ 'toBBox returns minX/minY/maxX/maxY object'); ++ tree.load(data); ++ var found = tree.search({minX: 12, minY: 12, maxX: 22, maxY: 22}); ++ function bySource(a, b) { return a.x1 - b.x1; } ++ sortedEqual(t, found, [ ++ {x1: 10, y1: 10, x2: 15, y2: 15}, ++ {x1: 20, y1: 20, x2: 25, y2: 25} ++ ], bySource); ++ t.end(); ++}); ++ ++t('search and collides return empty / false on an empty tree', function (t) { ++ var tree = rbush(4); ++ t.same(tree.search({minX: 0, minY: 0, maxX: 100, maxY: 100}), []); ++ t.same(tree.collides({minX: 0, minY: 0, maxX: 100, maxY: 100}), false); ++ t.end(); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..d59d2ed +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node test/test_new_api.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/test_new_api.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001977/tests/test.sh b/tasks/format-code-task-001977/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..43836d20b76387ee7d43323c59b518bf58e30919 --- /dev/null +++ b/tasks/format-code-task-001977/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test_new_api.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-001977/tests/test_command.sh b/tasks/format-code-task-001977/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001977/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001982/environment/Dockerfile b/tasks/format-code-task-001982/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a56f07bda50c7f1e49c0688a54ea74f3fd36697f --- /dev/null +++ b/tasks/format-code-task-001982/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a2e82be09118e30d0448dbb6d0044badf781e7f30e6dcfb8f32a73abac11908f diff --git a/tasks/format-code-task-001982/environment/setup/files/blocklist b/tasks/format-code-task-001982/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001982/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001982/environment/setup/setup.sh b/tasks/format-code-task-001982/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001982/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001982/tests/test.patch b/tasks/format-code-task-001982/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fff38dc6682bfbbdeb5050a2a3f635ce39aecdb6 --- /dev/null +++ b/tasks/format-code-task-001982/tests/test.patch @@ -0,0 +1,212 @@ +diff --git a/src/olympia/reviewers/tests/test_review_reports.py b/src/olympia/reviewers/tests/test_review_reports.py +index 36ed0d3c8107..f950393c1904 100644 +--- a/src/olympia/reviewers/tests/test_review_reports.py ++++ b/src/olympia/reviewers/tests/test_review_reports.py +@@ -43,55 +43,67 @@ def create_and_review_addon(self, user, weight, verdict, content_review): + + def generate_review_data(self): + with freeze_time(self.last_week_begin): +- reviewer1 = user_factory(display_name='Volunteer A') +- reviewer2 = user_factory(display_name='Staff B') +- reviewer3 = user_factory(display_name='Volunteer Content C') +- reviewer4 = user_factory(display_name='Staff Content D') +- grant_permission(reviewer2, '', name='Staff') +- grant_permission(reviewer4, '', name='No Reviewer Incentives') ++ self.reviewer1 = user_factory(display_name='Volunteer A') ++ self.reviewer2 = user_factory(display_name='Staff B') ++ self.reviewer3 = user_factory(display_name=None) ++ self.reviewer4 = user_factory(display_name='Staff Content D') ++ self.reviewer5 = user_factory(display_name='Deleted') ++ grant_permission(self.reviewer2, '', name='Staff') ++ grant_permission(self.reviewer4, '', name='No Reviewer Incentives') + + data = [ +- (reviewer1, 178, amo.AUTO_APPROVED, False), +- (reviewer1, 95, amo.AUTO_APPROVED, False), +- (reviewer1, 123, amo.NOT_AUTO_APPROVED, False), +- (reviewer1, 328, amo.AUTO_APPROVED, False), +- (reviewer1, 450, amo.AUTO_APPROVED, False), +- (reviewer1, 999, amo.NOT_AUTO_APPROVED, False), +- (reviewer1, 131, amo.AUTO_APPROVED, False), +- (reviewer1, 74, amo.NOT_AUTO_APPROVED, False), +- (reviewer1, 15, amo.AUTO_APPROVED, False), +- +- (reviewer2, 951, amo.NOT_AUTO_APPROVED, False), +- (reviewer2, 8421, amo.AUTO_APPROVED, False), +- (reviewer2, 281, amo.AUTO_APPROVED, False), +- (reviewer2, 54, amo.NOT_AUTO_APPROVED, False), +- (reviewer2, 91, amo.NOT_AUTO_APPROVED, False), +- (reviewer2, 192, amo.AUTO_APPROVED, False), +- (reviewer2, 222, amo.NOT_AUTO_APPROVED, False), +- +- (reviewer3, 178, amo.AUTO_APPROVED, True), +- (reviewer3, 95, amo.AUTO_APPROVED, True), +- (reviewer3, 123, amo.NOT_AUTO_APPROVED, True), +- (reviewer3, 328, amo.AUTO_APPROVED, True), +- (reviewer3, 450, amo.AUTO_APPROVED, True), +- (reviewer3, 999, amo.NOT_AUTO_APPROVED, True), +- (reviewer3, 131, amo.AUTO_APPROVED, True), +- (reviewer3, 74, amo.NOT_AUTO_APPROVED, True), +- (reviewer3, 15, amo.AUTO_APPROVED, True), +- (reviewer3, 48, amo.AUTO_APPROVED, True), +- (reviewer3, 87, amo.NOT_AUTO_APPROVED, True), +- (reviewer3, 265, amo.AUTO_APPROVED, True), +- +- (reviewer4, 951, amo.NOT_AUTO_APPROVED, True), +- (reviewer4, 8421, amo.AUTO_APPROVED, True), +- (reviewer4, 281, amo.AUTO_APPROVED, True), +- (reviewer4, 54, amo.NOT_AUTO_APPROVED, True), +- (reviewer4, 91, amo.NOT_AUTO_APPROVED, True), +- (reviewer4, 192, amo.AUTO_APPROVED, True), +- (reviewer4, 222, amo.NOT_AUTO_APPROVED, True), +- (reviewer4, 192, amo.AUTO_APPROVED, True), +- (reviewer4, 444, amo.NOT_AUTO_APPROVED, True), +- (reviewer4, 749, amo.AUTO_APPROVED, True), ++ (self.reviewer1, 178, amo.AUTO_APPROVED, False), ++ (self.reviewer1, 95, amo.AUTO_APPROVED, False), ++ (self.reviewer1, 123, amo.NOT_AUTO_APPROVED, False), ++ (self.reviewer1, 328, amo.AUTO_APPROVED, False), ++ (self.reviewer1, 450, amo.AUTO_APPROVED, False), ++ (self.reviewer1, 999, amo.NOT_AUTO_APPROVED, False), ++ (self.reviewer1, 131, amo.AUTO_APPROVED, False), ++ (self.reviewer1, 74, amo.NOT_AUTO_APPROVED, False), ++ (self.reviewer1, 15, amo.AUTO_APPROVED, False), ++ ++ (self.reviewer2, 951, amo.NOT_AUTO_APPROVED, False), ++ (self.reviewer2, 8421, amo.AUTO_APPROVED, False), ++ (self.reviewer2, 281, amo.AUTO_APPROVED, False), ++ (self.reviewer2, 54, amo.NOT_AUTO_APPROVED, False), ++ (self.reviewer2, 91, amo.NOT_AUTO_APPROVED, False), ++ (self.reviewer2, 192, amo.AUTO_APPROVED, False), ++ (self.reviewer2, 222, amo.NOT_AUTO_APPROVED, False), ++ ++ (self.reviewer3, 178, amo.AUTO_APPROVED, True), ++ (self.reviewer3, 95, amo.AUTO_APPROVED, True), ++ (self.reviewer3, 123, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer3, 328, amo.AUTO_APPROVED, True), ++ (self.reviewer3, 450, amo.AUTO_APPROVED, True), ++ (self.reviewer3, 999, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer3, 131, amo.AUTO_APPROVED, True), ++ (self.reviewer3, 74, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer3, 15, amo.AUTO_APPROVED, True), ++ (self.reviewer3, 48, amo.AUTO_APPROVED, True), ++ (self.reviewer3, 87, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer3, 265, amo.AUTO_APPROVED, True), ++ ++ (self.reviewer4, 951, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer4, 8421, amo.AUTO_APPROVED, True), ++ (self.reviewer4, 281, amo.AUTO_APPROVED, True), ++ (self.reviewer4, 54, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer4, 91, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer4, 192, amo.AUTO_APPROVED, True), ++ (self.reviewer4, 222, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer4, 192, amo.AUTO_APPROVED, True), ++ (self.reviewer4, 444, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer4, 749, amo.AUTO_APPROVED, True), ++ ++ (self.reviewer5, 523, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer5, 126, amo.AUTO_APPROVED, True), ++ (self.reviewer5, 246, amo.AUTO_APPROVED, False), ++ (self.reviewer5, 8740, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer5, 346, amo.NOT_AUTO_APPROVED, False), ++ (self.reviewer5, 985, amo.AUTO_APPROVED, False), ++ (self.reviewer5, 123, amo.NOT_AUTO_APPROVED, True), ++ (self.reviewer5, 93, amo.AUTO_APPROVED, True), ++ (self.reviewer5, 22, amo.NOT_AUTO_APPROVED, False), ++ (self.reviewer5, 165, amo.AUTO_APPROVED, True), + ] + for review_action in data: + self.create_and_review_addon(review_action[0], +@@ -99,6 +111,8 @@ def generate_review_data(self): + review_action[2], + review_action[3]) + ++ self.reviewer5.delete() ++ + def test_report_addon_reviewer(self): + self.generate_review_data() + command = Command() +@@ -136,6 +150,7 @@ def test_report_addon_reviewer(self): + assert 'Weekly Add-on Reviews Report' in html + assert 'Volunteer A' in html + assert 'Staff B' in html ++ assert 'Deleted' not in html + + to = 'addon-reviewers@mozilla.org' + subject = '%s %s-%s' % ( +@@ -156,7 +171,8 @@ def test_report_content_reviewer(self): + expected = [ + ('Weekly Content Reviews, 10 Reviews or More', + ['Name', 'Staff', 'Points', 'Add-ons Reviewed'], +- ((u'Volunteer Content C', u'', '120', u'12'), ++ ((u'Firefox user {}'.format(self.reviewer3.id), ++ u'', '120', u'12'), + (u'Staff Content D', u'*', '-', u'10'))), + ('Weekly Volunteer Contribution Ratio', + ['Group', 'Add-ons Reviewed'], +@@ -172,14 +188,16 @@ def test_report_content_reviewer(self): + if not self.last_week_begin < self.this_quarter_begin: + expected[2] = ('Quarterly contributions', + ['Name', 'Points', 'Add-ons Reviewed'], +- ((u'Volunteer Content C', u'120', u'12'),)) ++ ((u'Firefox user {}'.format(self.reviewer3.id), ++ u'120', u'12'),)) + assert data == expected + + html = command.generate_report_html('content', data) + + assert 'Weekly Add-on Content Reviews Report' in html +- assert 'Volunteer Content C' in html ++ assert 'Firefox user {}'.format(self.reviewer3.id) in html + assert 'Staff Content D' in html ++ assert 'Deleted' not in html + + to = 'addon-content-reviewers@mozilla.com' + subject = '%s %s-%s' % ( +@@ -217,6 +235,7 @@ def test_empty_report_addon_reviewer(self): + assert 'Weekly Add-on Reviews Report' in html + assert 'Volunteer A' not in html + assert 'Staff B' not in html ++ assert 'Deleted' not in html + + to = 'addon-reviewers@mozilla.org' + subject = '%s %s-%s' % ( +@@ -248,8 +267,9 @@ def test_empty_report_content_reviewer(self): + html = command.generate_report_html('content', data) + + assert 'Weekly Add-on Content Reviews Report' in html +- assert 'Volunteer Content C' not in html ++ assert 'Firefox user' not in html + assert 'Staff Content D' not in html ++ assert 'Deleted' not in html + + to = 'addon-content-reviewers@mozilla.org' + subject = '%s %s-%s' % ( +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+2TXW+bMBSGc82vOE2rarsgBJqPKVWqUUKbTEmoEiptV8gJTmINDMOGLf9+hrQ0 ++2rT2ptU07TwXGHyOOa/9HrdWOYvCgPLCaLwVbUW/261Gxa9j9W52LdNqW32z32m0TbPXthrQfTNF ++R+RCkgygkSWJfC7vpfg/SuvJf0mFDNZJHBMetsTu9Wq84L/Z6Vi1/23LVP53eu1eA9qvJ+HP/Of+ ++n54YK8aNFRE7bR1C1QQrGmraKSyphDyFu73cJRwuWj0oGIF0r3pFoz/SJJNwZ/vjYfNs7M1co1VF ++yr8Nzsr5pkYLEkHz7F0VAMaZBP19Uzt8bqNkpcLqty2zW5ZzecGyhMeUSyhIxsgqoqIu9MUfe/Oq ++nMjWj7OjT/b81guWru9P5rfLYOaN7qfuUFApGd+KoNxMnWv79rW9dJfByL2x76d+cL+YDuO9+BYN ++DKN0d/AxStYk2iVCGkm0j1NGHhfP3JljO2M3mHqO7U+8+bBOHZimZZqHDYg8ozArtY+ugQnIcs6V ++EI1t4ASqUiSMGQc9h7IgpCoI1pUR0sLgeRRdgtxRroGiyg4DQTYUdF18Zam+zQiXuqzOBc6rLBFR ++msKFtmFHAmIar8l6R8PfJKTbTKU/xa+gLq1knJvH9eskPaz16ikcdnuo52SUSAohUZqIoKBqcEpD ++1T2V+qdlFJrOwrV9t3YBJjcw93xwP0+W/hIejhucsb2wHd9dgPIUcrn5EK864HjTabn44TvYUk4z ++EgVrdtk8Pr5S0yLn5SZAXeqt6t+qA9J9OYBeCFDN8+itkdGC0e80E1XTH57BYVINpe9C9bT2t28o ++giAIgiAIgiAIgiAIgiAIgiAIgiAIgiDI8/wE6NBM9wAoAAA= +diff --git 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-001982/tests/test.sh b/tasks/format-code-task-001982/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c214463b873e9191c362956a77e39cc094324a72 --- /dev/null +++ b/tasks/format-code-task-001982/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/olympia/reviewers/tests/test_review_reports.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-001982/tests/test_command.sh b/tasks/format-code-task-001982/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001982/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001983/environment/Dockerfile b/tasks/format-code-task-001983/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..caecc8272dede1654d69f8bcc74b1a9aff9f1c9a --- /dev/null +++ b/tasks/format-code-task-001983/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:97271459157be990d5b9b8d149a3a4a8ceccd7289e948c1e9d52e8b37af6b11c diff --git a/tasks/format-code-task-001983/environment/setup/files/blocklist b/tasks/format-code-task-001983/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001983/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001983/environment/setup/setup.sh b/tasks/format-code-task-001983/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001983/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001983/tests/test.patch b/tasks/format-code-task-001983/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2122c3febf3a00c73940ac3c3cb5df045ad1b7cc --- /dev/null +++ b/tasks/format-code-task-001983/tests/test.patch @@ -0,0 +1,45 @@ +diff --git a/src/olympia/files/tests/test_models.py b/src/olympia/files/tests/test_models.py +index 61f4d716aa0c..ddfda3fbbdd5 100644 +--- a/src/olympia/files/tests/test_models.py ++++ b/src/olympia/files/tests/test_models.py +@@ -317,10 +317,13 @@ def test_webext_permissions_list_string_only(self): + {u'iamadict': u'hmm'}, + [u'iamalistinalist', u'indeedy'], + 13, ++ u'laststring!', ++ u'iamstring', ++ u'iamnutherstring', + u'laststring!'] + WebextPermission.objects.create(permissions=permissions, file=file_) + +- # Strings only plz. ++ + assert file_.webext_permissions_list == [ + u'iamstring', u'iamnutherstring', u'laststring!'] + +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+3TW2+bMBQA4DzzK85Y1W0PQExzqVa1EiOsyZSELjBpe0IkOAmaMRSbKPz7GXc3 ++ber60mqadr4HjO/HPmCvm5xlCeUHp/dU+sp4ONSl8mup38nQJWTsnvXdQa9PyHA86sHwySL6SSNk ++WgP06rKUfxr3UP8/yv6Rf0mFTDZlUaQ8s8X+8fZ4IP+kPxh8y787IqqdDEaE9KD/eCHc7z/P/yYD ++nfg1zQzjOUTqMiQs2uj9HPIt8FJCymqaZi3UDec53xmq+RkUrbhlYDXQXQtYFMwomAd+DMSEKyej ++B4c3jIF7dUouQO4pN0DRs7JEpFsKliU+55W1q1MuLZmuGRVwqkcJRmkFZ8Y27yLy1e6SdmtAydqi ++ylPIUjU+FbSLMJeQlVTwFxLoMRfS+D0yfxV4cQATL/beeFEAs7ewDGMIPs6iOPq+qD/1Vp4fByuI ++ghgauT0HP5zPu5ldJdlRTuuUJZv8wtQ3RSU0FVSt+nUMeqxKdW83Xjy9NE+m4SJwbN3jrHP++qRr ++Nw16SBmYJy91B+RchW69Mo276o6Va9Xt2mObnHfrrxquD60SslNbdTmCbc6ocfMpnoZLvZWoNzB5 ++5y2vw0QFHc+W11GyCCcf5sGloFKqbIlET6xauS85WEX31jWomc7XkzvdqkJ/BHfPpCgzyoQ6AFhH ++sA7G3/5GEUIIIYQQQgghhBBCCCGEEEIIIYTQ/b4A9Q+/qAAoAAA= +diff --git 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-001983/tests/test.sh b/tasks/format-code-task-001983/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2da3387810d7c2b68287b64e890b7dcabefcc744 --- /dev/null +++ b/tasks/format-code-task-001983/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/olympia/files/tests/test_models.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001983/tests/test_command.sh b/tasks/format-code-task-001983/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001983/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001984/environment/Dockerfile b/tasks/format-code-task-001984/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..84f002d8f9d84a76dc64854fad4d2de2e0b36c8e --- /dev/null +++ b/tasks/format-code-task-001984/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:36436a93ab92e28880ba5a739fa2e8b959806e92c7e45b7fbe814bb7422dda3b diff --git a/tasks/format-code-task-001984/environment/setup/files/blocklist b/tasks/format-code-task-001984/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001984/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001984/environment/setup/setup.sh b/tasks/format-code-task-001984/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001984/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001984/tests/test.patch b/tasks/format-code-task-001984/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e858944e13276ef17b0b11db607c52eeb818914e --- /dev/null +++ b/tasks/format-code-task-001984/tests/test.patch @@ -0,0 +1,85 @@ +diff --git a/tests/data/dags/simple_test_dag b/tests/data/dags/simple_test_dag +index 1f085945e25..ff3a8faf155 100644 +--- a/tests/data/dags/simple_test_dag ++++ b/tests/data/dags/simple_test_dag +@@ -18,5 +18,6 @@ with DAG('bqetl_test_dag', default_args=default_args, schedule_interval='@daily' + email=['test@example.com'], + date_partition_parameter='submission_date', + depends_on_past=True, ++ arguments=['--append_table'], + dag=dag, + ) +diff --git a/tests/data/test_sql/test/incremental_query_v1/metadata.yaml b/tests/data/test_sql/test/incremental_query_v1/metadata.yaml +index 66004d17e41..bce4108e0de 100644 +--- a/tests/data/test_sql/test/incremental_query_v1/metadata.yaml ++++ b/tests/data/test_sql/test/incremental_query_v1/metadata.yaml +@@ -11,3 +11,4 @@ labels: + scheduling: + dag_name: "bqetl_events" + depends_on_past: false ++ arguments: ["--append_table"] +diff --git a/tests/data/test_sql/test/non_incremental_query_v1/metadata.yaml b/tests/data/test_sql/test/non_incremental_query_v1/metadata.yaml +index 6f66eec9cbe..1178f80ce8b 100644 +--- a/tests/data/test_sql/test/non_incremental_query_v1/metadata.yaml ++++ b/tests/data/test_sql/test/non_incremental_query_v1/metadata.yaml +@@ -10,4 +10,5 @@ labels: + review_bug: 1999999 + scheduling: + dag_name: "bqetl_core" +- depends_on_past: true +\ No newline at end of file ++ depends_on_past: true ++ arguments: ["--append_table"] +diff --git a/tests/query_scheduling/test_dag_collection.py b/tests/query_scheduling/test_dag_collection.py +index 742ddee2eff..6027b033bcc 100644 +--- a/tests/query_scheduling/test_dag_collection.py ++++ b/tests/query_scheduling/test_dag_collection.py +@@ -226,6 +226,7 @@ def test_to_airflow(self, tmp_path, bigquery_client): + "dag_name": "bqetl_test_dag", + "depends_on_past": True, + "param": "test_param", ++ "arguments": ["--append_table"], + }, + ) + +diff --git a/tests/query_scheduling/test_task.py b/tests/query_scheduling/test_task.py +index 2cd6395e0ca..f9b58d5feca 100644 +--- a/tests/query_scheduling/test_task.py ++++ b/tests/query_scheduling/test_task.py +@@ -42,6 +42,7 @@ def test_of_query(self): + assert task.dag_name == "bqetl_events" + assert task.depends_on_past is False + assert task.public_json ++ assert task.arguments == ["--append_table"] + + def test_of_non_existing_query(self): + with pytest.raises(FileNotFoundError): +@@ -101,6 +102,7 @@ def test_task_instantiation(self): + assert task.depends_on_past is False + assert task.task_name == "test__incremental_query__v1" + assert task.public_json is False ++ assert task.arguments == [] + + def test_task_instantiation_custom_name(self): + query_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+3Sy26DMBAFUNb5ilH2PMtj1W9BBltghdgED0j8fQ1R1apSk02ituo9CzzSDMLi ++TtTMepC1MkscPEviVUWxn97Xc6/TIkvTsqySlyxIfJXkARVPu9Ens2MxEQWTtXxr7l7/j4o+8mfl ++uG7t+SyMjFz/uG/cyz8r0vf8yyqvfP556deAksdd4Xv/PP9W0h58o+QhtiNft2DZ9qHRJh5X7q2h ++8Ey+8h3aHi6+zGpaa9f2Ss6DNt31LRbuFI3rzRkpOr9jw6Ba1tZs0+FC4YmOxjJpw6qbxNY5UhgK ++59TEr+MgtDn89I8CAAAAAAAAAAAAAAAAAAAAAPiF3gAeMLCRACgAAA== +diff --git 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-001984/tests/test.sh b/tasks/format-code-task-001984/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7d83f2bd74118b7748f0f1375daa38b4ba462ddc --- /dev/null +++ b/tasks/format-code-task-001984/tests/test.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/data/dags/simple_test_dag +tests/data/test_sql/test/incremental_query_v1/metadata.yaml +tests/data/test_sql/test/non_incremental_query_v1/metadata.yaml +tests/query_scheduling/test_dag_collection.py +tests/query_scheduling/test_task.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-001984/tests/test_command.sh b/tasks/format-code-task-001984/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001984/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001985/environment/Dockerfile b/tasks/format-code-task-001985/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..aa5721ff6759fa1333f50a2b3ed45f851f8aec84 --- /dev/null +++ b/tasks/format-code-task-001985/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5de2a32a9231b9a97921a4c33689d6d671633c91f6343b95feefe887a54a3117 diff --git a/tasks/format-code-task-001985/environment/setup/files/blocklist b/tasks/format-code-task-001985/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001985/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001985/environment/setup/setup.sh b/tasks/format-code-task-001985/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001985/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001985/tests/test.patch b/tasks/format-code-task-001985/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b29ead0552590ae41a9b17ec98b919d7943f309 --- /dev/null +++ b/tasks/format-code-task-001985/tests/test.patch @@ -0,0 +1,113 @@ +diff --git a/tests/test_repository.py b/tests/test_repository.py +index 6ee0fff0ef..dc1ab47e00 100644 +--- a/tests/test_repository.py ++++ b/tests/test_repository.py +@@ -13,7 +13,7 @@ + import responses + from dateutil.relativedelta import relativedelta + +-from bugbug import repository ++from bugbug import repository, rust_code_analysis_server + + + @pytest.fixture +@@ -795,3 +795,78 @@ def test_calculate_experiences(): + assert commits["commit6"].touched_prev_90_days_component_sum == 2 + assert commits["commit6"].touched_prev_90_days_component_max == 2 + assert commits["commit6"].touched_prev_90_days_component_min == 2 ++ ++ ++def test_get_touched_functions(): ++ ++ responses.add_passthru("http://127.0.0.1") ++ ++ repository.code_analysis_server = rust_code_analysis_server.RustCodeAnalysisServer() ++ ++ ++ touched_functions = repository.get_touched_functions( ++ "file.cpp", ++ [], ++ [], ++ """void func1() { ++ int i = 1; ++} ++ ++void func2() { ++ int i = 2; ++}""", ++ ) ++ ++ assert touched_functions == set() ++ ++ ++ touched_functions = repository.get_touched_functions( ++ "file.cpp", ++ [], ++ [1], ++ """void func1() { ++ int i = 1; ++} ++ ++void func2() { ++ int i = 2; ++}""", ++ ) ++ ++ assert touched_functions == {("func1", 1, 3)} ++ ++ ++ touched_functions = repository.get_touched_functions( ++ "file.cpp", ++ [2, 5, 6, 7, 8], ++ [6], ++ """void func1() { ++ int i = 1; ++} ++ ++void func3() { ++ int i = 3; ++} ++ ++void func4() { ++ int i = 4; ++}""", ++ ) ++ ++ assert touched_functions == {("func3", 5, 7), ("func1", 1, 3)} ++ ++ ++ touched_functions = repository.get_touched_functions( ++ "file.cpp", ++ [6], ++ [6], ++ """void func1() { ++ int i = 1; ++} ++ ++void func2() { ++ int i = 2; ++}""", ++ ) ++ ++ assert touched_functions == {("func2", 5, 7)} +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+3SXWvDIBQG4FznV7juOh/aJoHCfkvIh12EVYMeQ/PvF1PYRqHrTcsoe58bRY9G ++8p609eqjr6WesuhR8kVVFOu4uBzXOS9ELsrttiirKOe85CJixcNe9IN31FjGImsM/VZ3a/9Jpd/5 ++k3RUd+Z4bHSfuuF+37iVv+DVV/67UMd3pVjyz+/3hOv+ef6vL1mrdNY2boi7nq1N0Mo+dsbbTrLM ++jHRujCm0SChtOlJTQzIe57DBEsM23smDOpG30r1tWFh251NWjsYpMnZOx3m/X9feJdVkfDfIvj54 ++vVxntGPJiSVT/Ne/AwAAAAAAAAAAAAAAAAAAAADgqXwC9IxIcAAoAAA= +diff --git 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-001985/tests/test.sh b/tasks/format-code-task-001985/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..76cdb1df5e7c2f4f373a3b01cc051cbce34543eb --- /dev/null +++ b/tasks/format-code-task-001985/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_repository.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-001985/tests/test_command.sh b/tasks/format-code-task-001985/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001985/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002100/environment/Dockerfile b/tasks/format-code-task-002100/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..31f62a18a85340f341b1c5bf89e931177e0a5483 --- /dev/null +++ b/tasks/format-code-task-002100/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ce6535ac21057ced3a73209c6f0ca6d0abdc35e37879d3f18f22fc834321e427 diff --git a/tasks/format-code-task-002100/environment/setup/files/blocklist b/tasks/format-code-task-002100/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002100/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002100/environment/setup/setup.sh b/tasks/format-code-task-002100/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002100/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002100/tests/test.patch b/tasks/format-code-task-002100/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0c5c9b514ad611f2726a6b395c2dba1739433770 --- /dev/null +++ b/tasks/format-code-task-002100/tests/test.patch @@ -0,0 +1,229 @@ +diff --git a/table_test.go b/table_test.go +index 8b4b660..4e79f9b 100644 +--- a/table_test.go ++++ b/table_test.go +@@ -19,7 +19,6 @@ import ( + ) + + func ExampleShort() { +- + data := [][]string{ + []string{"A", "The Good", "500"}, + []string{"B", "The Very very Bad Man", "288"}, +@@ -35,10 +34,17 @@ func ExampleShort() { + } + table.Render() + ++ // Output: +------+-----------------------+--------+ ++ // | NAME | SIGN | RATING | ++ // +------+-----------------------+--------+ ++ // | A | The Good | 500 | ++ // | B | The Very very Bad Man | 288 | ++ // | C | The Ugly | 120 | ++ // | D | The Gopher | 800 | ++ // +------+-----------------------+--------+ + } + + func ExampleLong() { +- + data := [][]string{ + []string{"Learn East has computers with adapted keyboards with enlarged print etc", " Some Data ", " Another Data"}, + []string{"Instead of lining up the letters all ", "the way across, he splits the keyboard in two", "Like most ergonomic keyboards", "See Data"}, +@@ -53,7 +59,6 @@ func ExampleLong() { + table.Append(v) + } + table.Render() +- + } + + func ExampleCSV() { +@@ -62,10 +67,19 @@ func ExampleCSV() { + table.SetRowSeparator("=") + + table.Render() ++ ++ // Output: *============*===========*=========* ++ // | FIRST NAME | LAST NAME | SSN | ++ // *============*===========*=========* ++ // | John | Barry | 123456 | ++ // | Kathy | Smith | 687987 | ++ // | Bob | McCornick | 3979870 | ++ // *============*===========*=========* + } + + func TestCSVInfo(t *testing.T) { +- table, err := NewCSV(os.Stdout, "test_info.csv", true) ++ buf := &bytes.Buffer{} ++ table, err := NewCSV(buf, "test_info.csv", true) + if err != nil { + t.Error(err) + return +@@ -73,10 +87,23 @@ func TestCSVInfo(t *testing.T) { + table.SetAlignment(ALIGN_LEFT) + table.SetBorder(false) + table.Render() ++ ++ got := buf.String() ++ want := ` FIELD | TYPE | NULL | KEY | DEFAULT | EXTRA +++----------+--------------+------+-----+---------+----------------+ ++ user_id | smallint(5) | NO | PRI | NULL | auto_increment ++ username | varchar(10) | NO | | NULL | ++ password | varchar(100) | NO | | NULL | ++` ++ ++ if got != want { ++ t.Errorf("CSV info failed\ngot:\n[%s]\nwant:\n[%s]\n", got, want) ++ } + } + + func TestCSVSeparator(t *testing.T) { +- table, err := NewCSV(os.Stdout, "test.csv", true) ++ buf := &bytes.Buffer{} ++ table, err := NewCSV(buf, "test.csv", true) + if err != nil { + t.Error(err) + return +@@ -92,6 +119,22 @@ func TestCSVSeparator(t *testing.T) { + table.SetRowSeparator("-") + table.SetAlignment(ALIGN_LEFT) + table.Render() ++ ++ want := `*------------*-----------*---------* ++‡ FIRST NAME ‡ LAST NAME ‡ SSN ‡ ++*------------*-----------*---------* ++‡ John ‡ Barry ‡ 123456 ‡ ++*------------*-----------*---------* ++‡ Kathy ‡ Smith ‡ 687987 ‡ ++*------------*-----------*---------* ++‡ Bob ‡ McCornick ‡ 3979870 ‡ ++*------------*-----------*---------* ++` ++ ++ got := buf.String() ++ if got != want { ++ t.Errorf("CSV info failed\ngot:\n[%s]\nwant:\n[%s]\n", got, want) ++ } + } + + func TestNoBorder(t *testing.T) { +@@ -462,3 +505,97 @@ func TestAutoMergeRows(t *testing.T) { + t.Errorf("\ngot:\n%s\nwant:\n%s\n", got, want) + } + } ++ ++func TestClearRows(t *testing.T) { ++ data := [][]string{ ++ []string{"1/1/2014", "Domain name", "2233", "$10.98"}, ++ } ++ ++ var buf bytes.Buffer ++ table := NewWriter(&buf) ++ table.SetAutoWrapText(false) ++ table.SetHeader([]string{"Date", "Description", "CV2", "Amount"}) ++ table.SetFooter([]string{"", "", "Total", "$145.93"}) ++ table.AppendBulk(data) ++ table.Render() ++ ++ originalWant := `+----------+-------------+-------+---------+ ++| DATE | DESCRIPTION | CV2 | AMOUNT | +++----------+-------------+-------+---------+ ++| 1/1/2014 | Domain name | 2233 | $10.98 | +++----------+-------------+-------+---------+ ++| TOTAL | $145 93 | +++----------+-------------+-------+---------+ ++` ++ want := originalWant ++ ++ got := buf.String() ++ if got != want { ++ t.Errorf("table clear rows failed\ngot:\n%s\nwant:\n%s\n", got, want) ++ } ++ ++ buf.Reset() ++ table.ClearRows() ++ table.Render() ++ ++ want = `+----------+-------------+-------+---------+ ++| DATE | DESCRIPTION | CV2 | AMOUNT | +++----------+-------------+-------+---------+ +++----------+-------------+-------+---------+ ++| TOTAL | $145 93 | +++----------+-------------+-------+---------+ ++` ++ ++ got = buf.String() ++ if got != want { ++ t.Errorf("table clear failed\ngot:\n%s\nwant:\n%s\n", got, want) ++ } ++ ++ buf.Reset() ++ table.AppendBulk(data) ++ table.Render() ++ ++ want = `+----------+-------------+-------+---------+ ++| DATE | DESCRIPTION | CV2 | AMOUNT | +++----------+-------------+-------+---------+ ++| 1/1/2014 | Domain name | 2233 | $10.98 | +++----------+-------------+-------+---------+ ++| TOTAL | $145 93 | +++----------+-------------+-------+---------+ ++` ++ ++ got = buf.String() ++ if got != want { ++ t.Errorf("table clear rows failed\ngot:\n%s\nwant:\n%s\n", got, want) ++ } ++} ++ ++func TestClearFooters(t *testing.T) { ++ data := [][]string{ ++ []string{"1/1/2014", "Domain name", "2233", "$10.98"}, ++ } ++ ++ var buf bytes.Buffer ++ table := NewWriter(&buf) ++ table.SetAutoWrapText(false) ++ table.SetHeader([]string{"Date", "Description", "CV2", "Amount"}) ++ table.SetFooter([]string{"", "", "Total", "$145.93"}) ++ table.AppendBulk(data) ++ table.Render() ++ ++ buf.Reset() ++ table.ClearFooter() ++ table.Render() ++ ++ want := `+----------+-------------+-------+---------+ ++| DATE | DESCRIPTION | CV2 | AMOUNT | +++----------+-------------+-------+---------+ ++| 1/1/2014 | Domain name | 2233 | $10.98 | +++----------+-------------+-------+---------+ ++` ++ ++ got := buf.String() ++ if got != want { ++ t.Errorf("table clear rows failed\ngot:\n%s\nwant:\n%s\n", got, want) ++ } ++} +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+3Sy0rDQBQG4K7zFAfc6CKXKU276kKw1IVSEV2XNpkmY5KZMpdW395JsVUEzaZF ++pP9H4AxJzswhf6KlE3U+53IT904l8UZpuqve97pbs7Sf9AcsGbJRL2EsHY16lJ5soi+csQtN1NNK ++2d/e63r+T0Wf+Vtu7DxTTbOQeWTK453RlX/K2CH/dNj3+Q+Gic8/Od4IPzvz/LOcdsEveR4EFzSR ++xmlO09nD9dMtmbemFrIi/iqMNXS5VkL6atWhh7alyEoquL+tueH2KmiqXGgK1xS3nywuVGx0FhfC ++lm4Z+d8rVjWvXKVkpYJaUmhW8nO77p7YLpY132phuW4nfnSS2m5DzghZ7EdvVM79wJqHfuVqbmit ++1QvP/IDTGWPsfnbzfDcZq9Xqo2O8P5r81W5I4YbCTDlpx4y6R/nrIAEAAAAAAAAAAAAAAAAAAADg ++LL0Dlv1D7QAoAAA= +diff --git 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-002100/tests/test.sh b/tasks/format-code-task-002100/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bfa04fe0687bd26c974696dad4aea3ed85df9796 --- /dev/null +++ b/tasks/format-code-task-002100/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' +table_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-002100/tests/test_command.sh b/tasks/format-code-task-002100/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002100/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002107/environment/Dockerfile b/tasks/format-code-task-002107/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3f1ca5e8b3d6fa18413e32f9e6339692365353b9 --- /dev/null +++ b/tasks/format-code-task-002107/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:975d2ca8c404c7f762ca783066dbf76cb7a5f0f4622707f9aef00a889ddbb125 diff --git a/tasks/format-code-task-002107/environment/setup/files/blocklist b/tasks/format-code-task-002107/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002107/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002107/environment/setup/setup.sh b/tasks/format-code-task-002107/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002107/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002107/tests/test.patch b/tasks/format-code-task-002107/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e8ad5909969d9114b682580dd9b22fb35c5ad6f6 --- /dev/null +++ b/tasks/format-code-task-002107/tests/test.patch @@ -0,0 +1,261 @@ +diff --git a/usercase-test-coderl/test_select_best_combination.py b/usercase-test-coderl/test_select_best_combination.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_select_best_combination.py +@@ -0,0 +1,234 @@ ++ ++ ++ ++ ++ ++ ++ ++import json ++import os ++import socket ++import subprocess ++import sys ++ ++import pytest ++ ++from GGanalysis.ScoredItem import ScoredItem, select_best_combination ++ ++ ++def _pack(item): ++ return { ++ "dist": item.score_dist.dist.tolist(), ++ "sub": {key: value.tolist() for key, value in item.sub_stats_exp.items()}, ++ } ++ ++ ++def _as_plain_list(value): ++ if hasattr(value, "tolist"): ++ return value.tolist() ++ return list(value) ++ ++ ++def _assert_scored_item(actual, expected_dist, expected_sub_stats): ++ packed = _pack(actual) ++ assert packed["dist"] == pytest.approx(expected_dist) ++ assert set(packed["sub"]) == set(expected_sub_stats) ++ for key, expected_values in expected_sub_stats.items(): ++ assert packed["sub"][key] == pytest.approx(expected_values) ++ ++ ++def _query_ab_items(): ++ a = ScoredItem([0.2, 0.8], {"atk": [0, 10]}, stats_score={"atk": 1}) ++ b = ScoredItem([0.5, 0.5], {"atk": [0, 20]}, stats_score={"atk": 1}) ++ return [a, b] ++ ++ ++def _query_three_items(): ++ return [ ++ ScoredItem([0.5, 0.5], {"x": [0, 1]}, stats_score={"x": 1}), ++ ScoredItem([0.25, 0.75], {"x": [0, 2]}, stats_score={"x": 1}), ++ ScoredItem([1.0], {"x": [0]}, stats_score={"x": 1}), ++ ] ++ ++ ++def _snapshot_items(items): ++ return [ ++ { ++ "dist": item.score_dist.dist.tolist(), ++ "sub": {key: _as_plain_list(value) for key, value in item.sub_stats_exp.items()}, ++ "stats_score": dict(item.stats_score), ++ "drop_p": item.drop_p, ++ "null_mark": item.null_mark, ++ } ++ for item in items ++ ] ++ ++ ++def test_two_items_default_choose_one_keeps_best_with_tie_to_earlier_item(): ++ ++ ++ ++ actual = select_best_combination(_query_ab_items()) ++ ++ _assert_scored_item( ++ actual, ++ [0.1, 0.9], ++ {"atk": [0.0, 11.11111111111111]}, ++ ) ++ ++ ++def test_two_items_choose_two_sums_both_independent_draws(): ++ ++ ++ ++ actual = select_best_combination(_query_ab_items(), 2) ++ ++ _assert_scored_item( ++ actual, ++ [0.1, 0.5, 0.4], ++ {"atk": [0.0, 12.0, 30.0]}, ++ ) ++ ++ ++def test_three_items_choose_two_handles_more_inputs_and_zero_score_item(): ++ ++ ++ ++ actual = select_best_combination(_query_three_items(), 2) ++ ++ _assert_scored_item( ++ actual, ++ [0.125, 0.5, 0.375], ++ {"x": [0.0, 1.75, 3.0]}, ++ ) ++ ++ ++def test_three_uneven_items_choose_one_preserves_multiple_substat_expectations(): ++ ++ ++ ++ items = [ ++ ScoredItem( ++ [0.1, 0.2, 0.7], ++ {"crit": [0, 4, 8], "hp": [0, 1, 2]}, ++ stats_score={"crit": 1, "hp": 0.5}, ++ ), ++ ScoredItem( ++ [0.6, 0.4], ++ {"crit": [0, 10], "hp": [0, 3]}, ++ stats_score={"crit": 1, "hp": 0.5}, ++ ), ++ ScoredItem( ++ [0.3, 0.3, 0.4], ++ {"crit": [0, 5, 9], "hp": [0, 2, 4]}, ++ stats_score={"crit": 1, "hp": 0.5}, ++ ), ++ ] ++ ++ actual = select_best_combination(items, 1) ++ ++ _assert_scored_item( ++ actual, ++ [0.018, 0.16199999999999998, 0.82], ++ { ++ "crit": [0.0, 5.0, 8.146341463414634], ++ "hp": [0.0, 1.4074074074074077, 2.292682926829268], ++ }, ++ ) ++ ++ ++def test_single_item_choose_one_returns_that_item_distribution(): ++ ++ ++ ++ items = [ ++ ScoredItem([0.25, 0.0, 0.75], {"atk": [0, 5, 25]}, stats_score={"atk": 1}) ++ ] ++ ++ actual = select_best_combination(items, 1) ++ ++ _assert_scored_item( ++ actual, ++ [0.25, 0.0, 0.75], ++ {"atk": [0.0, 0.0, 25.0]}, ++ ) ++ ++ ++def test_chose_num_greater_than_two_raises_specific_value_error(): ++ with pytest.raises(ValueError, match="^chose_num should not greater than 2!$"): ++ select_best_combination(_query_ab_items(), 3) ++ ++ ++def test_referential_transparency_for_same_input(): ++ items = _query_three_items() ++ ++ first = _pack(select_best_combination(items, 2)) ++ second = _pack(select_best_combination(items, 2)) ++ ++ assert first["dist"] == pytest.approx([0.125, 0.5, 0.375]) ++ assert first["sub"]["x"] == pytest.approx([0.0, 1.75, 3.0]) ++ assert second["dist"] == pytest.approx([0.125, 0.5, 0.375]) ++ assert second["sub"]["x"] == pytest.approx([0.0, 1.75, 3.0]) ++ assert first["dist"] == pytest.approx(second["dist"]) ++ assert first["sub"]["x"] == pytest.approx(second["sub"]["x"]) ++ ++ ++def test_does_not_mutate_input_list_or_scored_items(): ++ items = _query_ab_items() ++ original_list_ids = [id(item) for item in items] ++ original_snapshot = _snapshot_items(items) ++ ++ actual = select_best_combination(items, 1) ++ ++ _assert_scored_item(actual, [0.1, 0.9], {"atk": [0.0, 11.11111111111111]}) ++ assert [id(item) for item in items] == original_list_ids ++ assert _snapshot_items(items) == original_snapshot ++ ++ ++def test_fresh_process_result_matches_in_process_result(): ++ items = _query_ab_items() ++ in_process = _pack(select_best_combination(items, 2)) ++ script = """ ++import json ++import sys ++sys.path.insert(0, "/workspace/repo") ++from GGanalysis.ScoredItem import ScoredItem, select_best_combination ++a = ScoredItem([0.2, 0.8], {"atk": [0, 10]}, stats_score={"atk": 1}) ++b = ScoredItem([0.5, 0.5], {"atk": [0, 20]}, stats_score={"atk": 1}) ++out = select_best_combination([a, b], 2) ++sys.stdout.write(json.dumps({ ++ "dist": out.score_dist.dist.tolist(), ++ "sub": {key: value.tolist() for key, value in out.sub_stats_exp.items()}, ++}, sort_keys=True)) ++""" ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ ++ assert in_process["dist"] == pytest.approx([0.1, 0.5, 0.4]) ++ assert in_process["sub"]["atk"] == pytest.approx([0.0, 12.0, 30.0]) ++ assert fresh_process["dist"] == pytest.approx([0.1, 0.5, 0.4]) ++ assert fresh_process["sub"]["atk"] == pytest.approx([0.0, 12.0, 30.0]) ++ assert fresh_process["dist"] == pytest.approx(in_process["dist"]) ++ assert fresh_process["sub"]["atk"] == pytest.approx(in_process["sub"]["atk"]) ++ ++ ++def test_no_undeclared_relative_file_or_socket_side_effects(tmp_path, monkeypatch): ++ def blocked_socket(*args, **kwargs): ++ raise AssertionError("select_best_combination must not open network sockets") ++ ++ monkeypatch.chdir(tmp_path) ++ monkeypatch.setattr(socket, "socket", blocked_socket) ++ before = sorted(os.listdir(tmp_path)) ++ ++ actual = select_best_combination(_query_ab_items(), 1) ++ ++ _assert_scored_item(actual, [0.1, 0.9], {"atk": [0.0, 11.11111111111111]}) ++ after = sorted(os.listdir(tmp_path)) ++ assert after == before == [] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec /usr/local/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_select_best_combination.py -v diff --git a/tasks/format-code-task-002107/tests/test.sh b/tasks/format-code-task-002107/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..748053823c84e1d83781123f2e33d8726db31fe5 --- /dev/null +++ b/tasks/format-code-task-002107/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_select_best_combination.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-002107/tests/test_command.sh b/tasks/format-code-task-002107/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002107/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-002109/environment/Dockerfile b/tasks/format-code-task-002109/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..714d27c92721a82f4a77e1751bf7073262f607c0 --- /dev/null +++ b/tasks/format-code-task-002109/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f8662da35884ebba51dd05106547bebe2a38274b628115ffa1fd685ef2679c7c diff --git a/tasks/format-code-task-002109/environment/setup/files/blocklist b/tasks/format-code-task-002109/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002109/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002109/environment/setup/setup.sh b/tasks/format-code-task-002109/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002109/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002109/tests/test.patch b/tasks/format-code-task-002109/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..333d589d20ff1df28657b21a742e7aab714e20ea --- /dev/null +++ b/tasks/format-code-task-002109/tests/test.patch @@ -0,0 +1,151 @@ +diff --git a/runtime/tests/checker/builtinfunctions_test.go b/runtime/tests/checker/builtinfunctions_test.go +index 8ac83f726..55d0b826d 100644 +--- a/runtime/tests/checker/builtinfunctions_test.go ++++ b/runtime/tests/checker/builtinfunctions_test.go +@@ -132,6 +132,42 @@ func TestCheckAddressFromBytes(t *testing.T) { + runInvalidCase(t, "typo: [1]", &sema.IncorrectArgumentLabelError{}) + } + ++func TestCheckAddressFromString(t *testing.T) { ++ t.Parallel() ++ ++ t.Run("valid string argument", func(t *testing.T) { ++ t.Parallel() ++ ++ checker, err := ParseAndCheck(t, `let address = Address.fromString("0x1")`) ++ ++ require.NoError(t, err) ++ ++ resType := RequireGlobalValue(t, checker.Elaboration, "address") ++ ++ ++ assert.Equal(t, ++ &sema.OptionalType{Type: sema.TheAddressType}, ++ resType, ++ ) ++ }) ++ ++ t.Run("non-string argument", func(t *testing.T) { ++ t.Parallel() ++ ++ _, err := ParseAndCheck(t, `let address = Address.fromString(1)`) ++ errs := RequireCheckerErrors(t, err, 1) ++ assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) ++ }) ++ ++ t.Run("missing argument", func(t *testing.T) { ++ t.Parallel() ++ ++ _, err := ParseAndCheck(t, `let address = Address.fromString()`) ++ errs := RequireCheckerErrors(t, err, 1) ++ assert.IsType(t, &sema.ArgumentCountError{}, errs[0]) ++ }) ++} ++ + func TestCheckToBigEndianBytes(t *testing.T) { + + t.Parallel() +diff --git a/runtime/tests/interpreter/builtinfunctions_test.go b/runtime/tests/interpreter/builtinfunctions_test.go +index 96a009449..acabdebed 100644 +--- a/runtime/tests/interpreter/builtinfunctions_test.go ++++ b/runtime/tests/interpreter/builtinfunctions_test.go +@@ -235,6 +235,79 @@ func TestInterpretAddressFromBytes(t *testing.T) { + runInvalidCase(t, "[12, 34, 56, 11, 22, 33, 44, 55, 66, 77, 88, 99, 111]") + } + ++func TestInterpretAddressFromString(t *testing.T) { ++ ++ t.Parallel() ++ ++ runValidCase := func(t *testing.T, expected []byte, input string) { ++ t.Run(input, func(t *testing.T) { ++ t.Parallel() ++ ++ code := fmt.Sprintf(` ++ fun test(): Address? { ++ return Address.fromString("%s") ++ } ++ `, ++ input, ++ ) ++ ++ inter := parseCheckAndInterpret(t, code) ++ res, err := inter.Invoke("test") ++ ++ require.NoError(t, err) ++ ++ someVal, ok := res.(*interpreter.SomeValue) ++ require.True(t, ok, "expected Some, got %T", res) ++ ++ addressVal, ok := someVal.InnerValue(inter, interpreter.EmptyLocationRange).(interpreter.AddressValue) ++ require.True(t, ok) ++ ++ require.Equal(t, expected, addressVal.ToAddress().Bytes()) ++ }) ++ } ++ ++ runInvalidCase := func(t *testing.T, input string) { ++ t.Run("invalid:"+input, func(t *testing.T) { ++ t.Parallel() ++ ++ code := fmt.Sprintf(` ++ fun test(): Address? { ++ return Address.fromString("%s") ++ } ++ `, ++ input, ++ ) ++ ++ inter := parseCheckAndInterpret(t, code) ++ res, err := inter.Invoke("test") ++ ++ require.NoError(t, err) ++ ++ require.Equal(t, interpreter.Nil, res) ++ }) ++ } ++ ++ ++ runValidCase(t, []byte{0xf8, 0xd6, 0xe0, 0x58, 0x6b, 0x0a, 0x20, 0xc7}, "0xf8d6e0586b0a20c7") ++ runValidCase(t, []byte{0x43, 0x61, 0x64, 0x65, 0x6E, 0x63, 0x65, 0x21}, "0x436164656E636521") ++ runValidCase(t, []byte{0x1}, "0x01") ++ runValidCase(t, []byte{}, "0x0") ++ ++ ++ runInvalidCase(t, "42") ++ runInvalidCase(t, "436164656E636521") ++ ++ ++ runInvalidCase(t, "0xZZZ") ++ runInvalidCase(t, "0xGG") ++ ++ ++ runInvalidCase(t, "0x436164656E63652146757265766572") ++ ++ ++ runInvalidCase(t, "") ++} ++ + func TestInterpretToBigEndianBytes(t *testing.T) { + + t.Parallel() +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..c0ad0958c +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1 @@ ++{ "test_commands": ["go test ./runtime/tests/interpreter/ -run TestInterpretAddressFromString -timeout 120s && go test ./runtime/tests/checker/ -run TestCheckAddressFromString -timeout 120s"] } +diff --git 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 ./runtime/tests/interpreter/ -run TestInterpretAddressFromString -timeout 120s && go test ./runtime/tests/checker/ -run TestCheckAddressFromString -timeout 120s ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002109/tests/test.sh b/tasks/format-code-task-002109/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7e0bb6f075885805b30969cc9222193d5c33db94 --- /dev/null +++ b/tasks/format-code-task-002109/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' +runtime/tests/checker/builtinfunctions_test.go +runtime/tests/interpreter/builtinfunctions_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-002109/tests/test_command.sh b/tasks/format-code-task-002109/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002109/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002131/environment/Dockerfile b/tasks/format-code-task-002131/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1d09a03a6bd0ecce0d9374972795a1d5213f0b8d --- /dev/null +++ b/tasks/format-code-task-002131/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:64c2751cef0c6f47c39731c25c5d2dffbcfd36e3313456e68465bb8777078961 diff --git a/tasks/format-code-task-002131/environment/setup/files/blocklist b/tasks/format-code-task-002131/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002131/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002131/environment/setup/setup.sh b/tasks/format-code-task-002131/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002131/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002131/tests/test.patch b/tasks/format-code-task-002131/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..11e86bdb8b1c53112950f34ccf54ea7788e61e0c --- /dev/null +++ b/tasks/format-code-task-002131/tests/test.patch @@ -0,0 +1,247 @@ +diff --git a/src/openapi-formats.test.ts b/src/openapi-formats.test.ts +new file mode 100644 +index 0000000..da619a8 +--- /dev/null ++++ b/src/openapi-formats.test.ts +@@ -0,0 +1,219 @@ ++import { OpenAPIValidator } from './index'; ++ ++const headers = { accept: 'application/json' }; ++ ++const meta = { ++ openapi: '3.0.0', ++ info: { ++ title: 'api', ++ version: '1.0.0', ++ }, ++}; ++ ++ ++function captureWarn(fn: () => T): { result: T; warn: jest.Mock } { ++ const origWarn = console.warn; ++ const mock = jest.fn(); ++ console.warn = mock; ++ try { ++ const result = fn(); ++ return { result, warn: mock }; ++ } finally { ++ console.warn = origWarn; ++ } ++} ++ ++describe('OpenAPI default formats', () => { ++ describe('issue reproduction (int32 + byte in requestBody)', () => { ++ const buildPaths = () => ({ ++ '/foo': { ++ post: { ++ operationId: 'foo', ++ responses: { 200: { description: 'ok' } }, ++ requestBody: { ++ content: { ++ 'application/json': { ++ schema: { ++ type: 'object', ++ properties: { ++ foo: { type: 'integer', format: 'int32' }, ++ bar: { type: 'string', format: 'byte' }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }); ++ ++ test('constructor does not warn about int32 or byte formats', () => { ++ const { result, warn } = captureWarn( ++ () => new OpenAPIValidator({ definition: { ...meta, paths: buildPaths() } as any }), ++ ); ++ expect(result).toBeInstanceOf(OpenAPIValidator); ++ expect(warn).not.toHaveBeenCalled(); ++ }); ++ ++ test('valid int32 + valid base64 byte passes validation', () => { ++ const validator = new OpenAPIValidator({ definition: { ...meta, paths: buildPaths() } as any }); ++ const valid = validator.validateRequest({ ++ path: '/foo', ++ method: 'post', ++ headers: { ...headers, 'content-type': 'application/json' }, ++ body: { foo: 100, bar: 'aGVsbG8=' }, ++ }); ++ expect(valid.errors).toBeFalsy(); ++ }); ++ ++ test('integer larger than int32 max fails validation (signed 32-bit range enforced)', () => { ++ const validator = new OpenAPIValidator({ definition: { ...meta, paths: buildPaths() } as any }); ++ const valid = validator.validateRequest({ ++ path: '/foo', ++ method: 'post', ++ headers: { ...headers, 'content-type': 'application/json' }, ++ body: { foo: 9999999999, bar: 'aGVsbG8=' }, ++ }); ++ expect(valid.valid).toBe(false); ++ expect(valid.errors).toBeTruthy(); ++ expect(valid.errors!.some((e) => e.keyword === 'format' && (e.params as any).format === 'int32')).toBe(true); ++ }); ++ ++ test('non-base64 string fails byte format validation', () => { ++ const validator = new OpenAPIValidator({ definition: { ...meta, paths: buildPaths() } as any }); ++ const valid = validator.validateRequest({ ++ path: '/foo', ++ method: 'post', ++ headers: { ...headers, 'content-type': 'application/json' }, ++ body: { foo: 1, bar: 'not!base64!' }, ++ }); ++ expect(valid.valid).toBe(false); ++ expect(valid.errors).toBeTruthy(); ++ expect(valid.errors!.some((e) => e.keyword === 'format' && (e.params as any).format === 'byte')).toBe(true); ++ }); ++ }); ++ ++ describe('all OpenAPI 3.0 formats register without warnings', () => { ++ const formatPath = ( ++ type: 'integer' | 'number' | 'string', ++ format: string, ++ ) => ({ ++ '/x': { ++ post: { ++ operationId: `op_${format}`, ++ responses: { 200: { description: 'ok' } }, ++ requestBody: { ++ content: { ++ 'application/json': { ++ schema: { ++ type: 'object', ++ properties: { x: { type, format } as any }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }); ++ ++ test.each([ ++ ['integer', 'int32'], ++ ['integer', 'int64'], ++ ['number', 'float'], ++ ['number', 'double'], ++ ['string', 'byte'], ++ ['string', 'binary'], ++ ['string', 'password'], ++ ])('format %s/%s does not produce a console.warn', (type, format) => { ++ const { result, warn } = captureWarn( ++ () => ++ new OpenAPIValidator({ ++ definition: { ...meta, paths: formatPath(type as any, format) } as any, ++ }), ++ ); ++ expect(result).toBeInstanceOf(OpenAPIValidator); ++ expect(warn).not.toHaveBeenCalled(); ++ }); ++ }); ++ ++ describe('int64 numeric range', () => { ++ const buildPaths = () => ({ ++ '/n': { ++ post: { ++ operationId: 'opInt64', ++ responses: { 200: { description: 'ok' } }, ++ requestBody: { ++ content: { ++ 'application/json': { ++ schema: { ++ type: 'object', ++ properties: { ++ n: { type: 'integer', format: 'int64' }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }); ++ ++ test('int64 in range passes', () => { ++ const validator = new OpenAPIValidator({ definition: { ...meta, paths: buildPaths() } as any }); ++ const valid = validator.validateRequest({ ++ path: '/n', ++ method: 'post', ++ headers: { ...headers, 'content-type': 'application/json' }, ++ body: { n: 1234567890 }, ++ }); ++ expect(valid.errors).toBeFalsy(); ++ }); ++ }); ++ ++ describe('byte format validation', () => { ++ const buildPaths = () => ({ ++ '/b': { ++ post: { ++ operationId: 'opByte', ++ responses: { 200: { description: 'ok' } }, ++ requestBody: { ++ content: { ++ 'application/json': { ++ schema: { ++ type: 'object', ++ properties: { ++ b: { type: 'string', format: 'byte' }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }); ++ ++ test('valid base64 string passes', () => { ++ const validator = new OpenAPIValidator({ definition: { ...meta, paths: buildPaths() } as any }); ++ const valid = validator.validateRequest({ ++ path: '/b', ++ method: 'post', ++ headers: { ...headers, 'content-type': 'application/json' }, ++ body: { b: 'YWJjZA==' }, ++ }); ++ expect(valid.errors).toBeFalsy(); ++ }); ++ ++ test('string with non-base64 chars fails', () => { ++ const validator = new OpenAPIValidator({ definition: { ...meta, paths: buildPaths() } as any }); ++ const valid = validator.validateRequest({ ++ path: '/b', ++ method: 'post', ++ headers: { ...headers, 'content-type': 'application/json' }, ++ body: { b: '!!!not-base64!!!' }, ++ }); ++ expect(valid.valid).toBe(false); ++ expect(valid.errors).toBeTruthy(); ++ expect(valid.errors!.some((e) => e.keyword === 'format' && (e.params as any).format === 'byte')).toBe(true); ++ }); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..1d2bdd7 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest src/openapi-formats.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 ++npx jest src/openapi-formats.test.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002131/tests/test.sh b/tasks/format-code-task-002131/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a56cd82676e5df264a172135f7f3315bc1db5784 --- /dev/null +++ b/tasks/format-code-task-002131/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/openapi-formats.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-002131/tests/test_command.sh b/tasks/format-code-task-002131/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002131/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002136/environment/Dockerfile b/tasks/format-code-task-002136/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5edb393f4903bbf43895ec218fa5802cb5b69cf1 --- /dev/null +++ b/tasks/format-code-task-002136/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ee6aad2bcd2813ccaba7fb1bfff8154a51427ebe575e91a60fb1437e23eac58f diff --git a/tasks/format-code-task-002136/environment/setup/files/blocklist b/tasks/format-code-task-002136/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002136/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002136/environment/setup/setup.sh b/tasks/format-code-task-002136/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002136/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002136/tests/test.patch b/tasks/format-code-task-002136/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e05a3072512af6ec2515bf380be4ee78b26b50bd --- /dev/null +++ b/tasks/format-code-task-002136/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/udata/harvest/tests/test_api.py b/udata/harvest/tests/test_api.py +index 8f67f75d6b..3845ef8417 100644 +--- a/udata/harvest/tests/test_api.py ++++ b/udata/harvest/tests/test_api.py +@@ -295,7 +295,7 @@ def test_create_source_with_config_with_custom_key(self, api): + assert source['config'] == {'custom': 'value'} + + def test_update_source(self, api): +- '''It should update a source''' ++ '''It should update a source if owner or orga member''' + user = api.login() + source = HarvestSourceFactory(owner=user) + new_url = faker.url() +@@ -307,11 +307,31 @@ def test_update_source(self, api): + } + api_url = url_for('api.harvest_source', ident=str(source.id)) + response = api.put(api_url, data) ++ assert200(response) ++ assert response.json['url'] == new_url + ++ ++ source.organization = OrganizationFactory(members=[Member(user=user)]) ++ source.save() ++ api_url = url_for('api.harvest_source', ident=str(source.id)) ++ response = api.put(api_url, data) + assert200(response) + +- source = response.json +- assert source['url'] == new_url ++ def test_update_source_require_permission(self, api): ++ '''It should not update a source if not the owner''' ++ api.login() ++ source = HarvestSourceFactory() ++ new_url: str = faker.url() ++ data = { ++ 'name': source.name, ++ 'description': source.description, ++ 'url': new_url, ++ 'backend': 'factory', ++ } ++ api_url: str = url_for('api.harvest_source', ident=str(source.id)) ++ response = api.put(api_url, data) ++ ++ assert403(response) + + def test_validate_source(self, api): + '''It should allow to validate a source if admin''' +@@ -388,6 +408,16 @@ def test_delete_source(self, api): + deleted_sources = HarvestSource.objects(deleted__exists=True) + assert len(deleted_sources) == 1 + ++ def test_delete_source_require_permission(self, api): ++ '''It should not delete a source if not the owner''' ++ api.login() ++ source = HarvestSourceFactory() ++ ++ url = url_for('api.harvest_source', ident=str(source.id)) ++ response = api.delete(url) ++ ++ assert403(response) ++ + def test_schedule_source(self, api): + '''It should allow to schedule a source if admin''' + api.login(AdminFactory()) +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+3SzU6EMBAHcM59ijGeoRSFPZh4MHr0GTZl2wWy0DblI+7bWyBmjYnuZdUY/79L ++25kpTBiScmxatdVm4tF3SYNNni9r8HFd9iLP0qzYZGKuE6JIi4jyb+vonbEfpCeKvLXDV3Xn8n9U ++cpr/oPthu7NdJ41K+vpy7zg3/5usOM1/jovbQoiI0su18Ll/Pv+domXwpVaMXdOT6Uev6dmayj4+ ++UNOTH41pTMWaPV2Rq7x2FL9QNxcouieu9MTN2LZ3NNTaMAq6g2o8xS4k5SC5KtfoeiWO99YfwtLa ++ysmhJj5Jz8OBrwVJ2IasKtfk2xP2DWPuOHdK4xKrpZ/CaWm+X/9d6ZrEHSme2G9/VQAAAAAAAAAA ++AAAAAAAAAACAn/EKKRcBGwAoAAA= +diff --git 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-002136/tests/test.sh b/tasks/format-code-task-002136/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..24ef962cc4c7d912fc46d12a3a5c2d16e88c2b10 --- /dev/null +++ b/tasks/format-code-task-002136/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +udata/harvest/tests/test_api.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002136/tests/test_command.sh b/tasks/format-code-task-002136/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002136/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002138/environment/Dockerfile b/tasks/format-code-task-002138/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..01aff7463eb9fd708f90c372ce620bc91cac7476 --- /dev/null +++ b/tasks/format-code-task-002138/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f8ddffbe5d8e5bd82a585bf213cfacc11929c4d4422b24ab6090139ba204ce6b diff --git a/tasks/format-code-task-002138/environment/setup/files/blocklist b/tasks/format-code-task-002138/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002138/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002138/environment/setup/setup.sh b/tasks/format-code-task-002138/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002138/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002138/tests/test.patch b/tasks/format-code-task-002138/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..962f4d10060e6904156d06ab4408f05d463c353e --- /dev/null +++ b/tasks/format-code-task-002138/tests/test.patch @@ -0,0 +1,92 @@ +diff --git a/common/lib/xmodule/xmodule/tests/test_word_cloud.py b/common/lib/xmodule/xmodule/tests/test_word_cloud.py +index 835815a215fe..3b56ee36cf47 100644 +--- a/common/lib/xmodule/xmodule/tests/test_word_cloud.py ++++ b/common/lib/xmodule/xmodule/tests/test_word_cloud.py +@@ -23,7 +23,9 @@ class WordCloudBlockTest(TestCase): + raw_field_data = { + 'all_words': {'cat': 10, 'dog': 5, 'mom': 1, 'dad': 2}, + 'top_words': {'cat': 10, 'dog': 5, 'dad': 2}, +- 'submitted': False ++ 'submitted': False, ++ 'display_name': 'Word Cloud Block', ++ 'instructions': 'Enter some random words that comes to your mind' + } + + def test_xml_import_export_cycle(self): +@@ -102,3 +104,21 @@ def test_good_ajax_request(self): + ) + + self.assertEqual(100.0, sum(i['percent'] for i in response['top_words'])) ++ ++ def test_indexibility(self): ++ """ ++ Test indexibility of Word Cloud ++ """ ++ ++ module_system = get_test_system() ++ block = WordCloudBlock(module_system, DictFieldData(self.raw_field_data), Mock()) ++ self.assertEqual( ++ block.index_dictionary(), ++ { ++ 'content_type': 'Word Cloud', ++ 'content': { ++ 'display_name': 'Word Cloud Block', ++ 'instructions': 'Enter some random words that comes to your mind' ++ } ++ } ++ ) +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,39 @@ ++H4sIAAAAAAAAA+1a3W8bxxHfO36IPFEfsOUktRF7y7glKVsnUvyQrVhu2Yhx3NqUYDIPYVtcj7yj ++dfbxjr07WqYqG2xgIDJgFH4JkocWMNAgsZF/RjQEWDiggIE+5Y2FUaDwU3fvgx+yLNutpDbt/kju ++3u3Ozszu7M3sjcSWG5IscKJyYxrsF+IIs+m0VSNsr63rRHomkZiNp1PJBIgnEhnUBNP7plEfGrrB ++axACTVWN3ehe1f89BduzP8fVmxW+sixy3N7uhTewf2oG0yVS8USS2P8g8BL71yRFqvEyp4uGISlX ++dbZSbxrLqjKVTCRYRPZGMrCBM6nUy+w/k4jPDNp/ZiaezgAY36c5D+D/3P7fjIwwuP7zeuTauzQA ++f+3v9Dv1syoFwBdAACUgUAItUyXKqukSjWqP7Kl5S14K0ED0ir6vEe23lMvigR/sgK/R79vu3YOh ++vaEpBUTqmqc7IrjTCKQjIwYE7+owAIIPl4P6Dt5R4LU5+l+XozAkBISgwPyRlqjSsDBcCgmh0ogw ++UhoV6AKIja4uMJftpw8uXOOVqyp0H0JYVTWoNRQF3cCbNVVoyCJcUTWBq8hqQ4CGqBs6VBW5yTLf ++YWH5GGV6l3hj2fRX1FpNVUxGsFjy9bpueuSabg4JYpVvyMbqUbuHFcpsma9cFxVBZ/XfypIhJlcD ++czWxpmrNuRht+nP5CxfzOdObz17OxejVw864iqoYmlRm+YaxvHpsWyOuRcUwmnVRXx3Dek7pYkUT ++janrYrMYGzOHOE5QKxxnevSmbgYMsVavSrJoeutIew1bwAxwHG5CNEN8WcftSHlJU/iaaAav5JYW ++uSuLi0XTj+aGlEeMDM0MLmSL2Z9lC7mCOXoxXyhmL13KLXDZpaWCyRRyH1zJFblf5D4x/R8Xclyx ++9Ag8w6v2PDKNNSyLwnSfd3zBI9abzwPnbCOc145ZpgVAx+ve8VAU1aFpytsBuPADarjF4M8WGGtZ ++ny1wZGPw+zQ0vr5w/527+Xv5J6Hw41C4HTq5GTr5JHT6ceh0O8RuhtgnoczjUKYdOrMZOtMKbgHP ++ncBnY5+O3fegz8UHgfZE9OG59sRse/zM5viZNji7Cc5ugLPb6XztiR89DLUnUu3x9OZ4ug0ymyCz ++ATJITd/o1iF2a/xox+cZ93cALjy+EboV7Ix6DtGt0Q4DRk+gWQRHWn780X6w0wNB8D3C7jt8b2S8 ++Iv4n4sl0L/6nkuj8l04nZkn8PwiEw+G9CDeYjVSrq5oBkQN3L103zlQ1tQaxy4ZODw5KDNP12nDe ++aom6Lj7GOi4+GmMdH99/xSAZLO5mbWcfRb4+2mM2DSN2uIvgy17Ei8ReYyQKijsMY7qBBKn6OwYi ++RJzIGZlzGqxGOzqitsjL42nkdI8eR1FM7UZYp+8Wc4thBiMWEhx1BL8YcZ1h27v64y4iQfPoRT3E ++L7ItEkcYOxCirqLWEJn/9OYk2Hf0+X/daJT1/cgCvcn7fzqB8z8zs8kMef8/CLxg/33IAr25/dOJ ++FLH/gWBX+1thhK8Y/17659X5n3R60P4ziUw6Sc5/BwE3//PB3ci1z6lt+R/aqZ8dBy/kfzx3QIkW ++vKj0WHkL32q6gDYQ7O4Z6JwY8Slyydo9MMkmEqcQRQ2dwKSyhA5DTdZOVAzsKC/6jWGxsi2WugNu ++0QbVI1jbllQR6OuWqtq7hqefSvD0XlAHR2iBwd4CWMOT8OYrfWIAZnYYK/IhKj5DqvQrca17fXcb ++83VQpZDSgcHs1C1qjUIi6MG5+tDvBBYxgYrPqS/Qmt+l14AE1qivqD+gAY+o/CMQ85i+Kq9d1c2h ++6vUV68JbbSgVHWsIYev5j3dKWdgPdO8hrjfNoRUNH3y11dNuM3tOViu8rJ9nBbGiaryhar0mhxrn ++8PR3UPGPFnh6+O37qS+PbByefBBBBf6GJq28SYw2g1gpQ1Vl3fThsXqM1vD20kKYA7bRb6A2jCoz ++2JW2emwXVfDy6Blb8l+Ch+6d+HKiHTy+GTzeoangqQ4YKP7mAcwJt+/p2Fvro9oIGvodNoxG2xp6 ++ZFExA0iKzJdlEa2r11pNv72q2jiWZy+qo2jA1U57y9maehYVLdChvb63O8At/s6AwPB66vfNO837 ++2U9vt27/Kfog9ZD6arZ99NTm0VOt21tjh+9n762sj24NT2x4JyzVBrYCVtPa9ni58dNWANbKa0OW ++6hreIdoRdyFd/UKKuMJ1dcRGGsUkQ5aOW95Aa8GSFPN2c2waJrBmY5Fb7C0ai2FfUuuoo5T+E+Ak ++tbbA+xvg/S0wvuF+O94AdaQDusUERQWRMV4oLAEE/3XY1V3skYxXxP94ZqYv/set/E8ykSLx/yAQ ++Dof/pbDdl/Dp+nyGEcRql1N0EnvU03By0vatsTkrRYFJuu49isc6HRg/7fKyQo9u93e78VgnJEUn ++qy776gB/F5poNDTFUm4HWmYbmcPVapaqEAWJqEUH5+dhAvKKAN2QYbX/Mv7rPnEOD6eD6WvqTtRe ++mn5X/ZLlqfO6fpB5l77nH58gOJw4Q9Nl9eW9k/Gq97/ZZO//P5Kz+P0vlSH534PBez+cLkvKdJnX ++l5mKAN1jJMO8B3OK3tDEficAJR02dFGA0bomTkkKWjpZRrc3JB5t9RtT+opkVJZjTO8a2u+NSXv4 ++zPlp1DWtNGQZrq1BA+cYkaDd8s9u3tlKNjPiTcvjLPw8m7+wyBVyxeLF/IUCd3lx4eNLufntf8Bw ++yZc+KX60mF/KFj+aD7/0nDy3Q8/cyd7QMMO4c5mq4Wkhavgr65m1k83TslSedtTt1pba9pPVy5yj ++yOqMnLoJp2641yoM84Kg1g19Puy2TSkqchjVPmFTFdhbRKepDhV1znppr2vqDUkQNZK6JSAgICAg ++ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIPgfxT8B44Y56QBQAAA= +diff --git 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-002138/tests/test.sh b/tasks/format-code-task-002138/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9623b3e06b820e1bfe82ffbfac8d72215b92be7a --- /dev/null +++ b/tasks/format-code-task-002138/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' +common/lib/xmodule/xmodule/tests/test_word_cloud.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-002138/tests/test_command.sh b/tasks/format-code-task-002138/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002138/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002152/environment/Dockerfile b/tasks/format-code-task-002152/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..43989def57114864f9164e4bb8d940df07c536ee --- /dev/null +++ b/tasks/format-code-task-002152/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:06f034d260f7ab24ca73da1ce8093a74d785f67100b5de3b7183b069dd8c47cb diff --git a/tasks/format-code-task-002152/environment/setup/files/blocklist b/tasks/format-code-task-002152/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002152/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002152/environment/setup/setup.sh b/tasks/format-code-task-002152/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002152/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002152/tests/test.patch b/tasks/format-code-task-002152/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f0e5799ea286e63c254490f51a3ee628d323c01e --- /dev/null +++ b/tasks/format-code-task-002152/tests/test.patch @@ -0,0 +1,172 @@ +diff --git a/hypershift-operator/controllers/hostedcluster/createorupdate_annotation_enforcer_test.go b/hypershift-operator/controllers/hostedcluster/createorupdate_annotation_enforcer_test.go +index 21b89d3ef31..2f79f4d9aa6 100644 +--- a/hypershift-operator/controllers/hostedcluster/createorupdate_annotation_enforcer_test.go ++++ b/hypershift-operator/controllers/hostedcluster/createorupdate_annotation_enforcer_test.go +@@ -16,73 +16,109 @@ import ( + ) + + func TestCreateOrUpdateWithAnnotationFactory(t *testing.T) { +- ++ req := reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "clusters", Name: "example"}} ++ annotationValue := req.String() + testCases := []struct { + name string +- mutateFN func(m *metav1.ObjectMeta) controllerutil.MutateFn +- verify func(*testing.T, *corev1.ConfigMap) ++ obj crclient.Object ++ expected crclient.Object ++ mutateFN func(crclient.Object) controllerutil.MutateFn + }{ + { + name: "No annotations", +- mutateFN: func(m *metav1.ObjectMeta) controllerutil.MutateFn { ++ obj: &corev1.ConfigMap{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "foo", ++ Namespace: "bar", ++ }, ++ }, ++ mutateFN: func(_ crclient.Object) controllerutil.MutateFn { + return func() error { return nil } + }, ++ expected: &corev1.ConfigMap{ ++ TypeMeta: metav1.TypeMeta{ ++ Kind: "ConfigMap", ++ APIVersion: "v1", ++ }, ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "foo", ++ Namespace: "bar", ++ Annotations: map[string]string{ ++ hostedClusterAnnotation: annotationValue, ++ }, ++ }, ++ }, + }, + { + name: "Existing annotations are kept", +- mutateFN: func(m *metav1.ObjectMeta) controllerutil.MutateFn { ++ obj: &corev1.ConfigMap{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "foo", ++ Namespace: "bar", ++ }, ++ }, ++ mutateFN: func(o crclient.Object) controllerutil.MutateFn { + return func() error { +- m.Annotations = map[string]string{ ++ o.SetAnnotations(map[string]string{ + "foo": "bar", +- } ++ }) + return nil + } + }, +- verify: func(t *testing.T, cm *corev1.ConfigMap) { +- if cm.Annotations["foo"] != "bar" { +- t.Errorf("expected 'foo' annotation to be kept, but it's gone. Annotations: %+v", cm.Annotations) +- } ++ expected: &corev1.ConfigMap{ ++ TypeMeta: metav1.TypeMeta{ ++ Kind: "ConfigMap", ++ APIVersion: "v1", ++ }, ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "foo", ++ Namespace: "bar", ++ Annotations: map[string]string{ ++ hostedClusterAnnotation: annotationValue, ++ "foo": "bar", ++ }, ++ }, + }, + }, +- } +- +- for _, tc := range testCases { +- t.Run(tc.name, func(t *testing.T) { +- obj := &corev1.ConfigMap{ ++ { ++ name: "Do not annotate cluster scoped resources", ++ obj: &corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + Name: "foo", + }, +- } +- +- // expectedObj is the original object + mutateFN + the annotation +- expectedObj := obj.DeepCopy() +- tc.mutateFN(&expectedObj.ObjectMeta)() +- if expectedObj.Annotations == nil { +- expectedObj.Annotations = map[string]string{} +- } +- expectedObj.Annotations[hostedClusterAnnotation] = "/foo" ++ }, ++ mutateFN: func(_ crclient.Object) controllerutil.MutateFn { ++ return func() error { return nil } ++ }, ++ expected: &corev1.Namespace{ ++ TypeMeta: metav1.TypeMeta{ ++ Kind: "Namespace", ++ APIVersion: "v1", ++ }, ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "foo", ++ }, ++ }, ++ }, ++ } + ++ for _, tc := range testCases { ++ t.Run(tc.name, func(t *testing.T) { ++ obj := tc.obj + client := fake.NewClientBuilder().WithObjects(obj).Build() + providerFactory := createOrUpdateWithAnnotationFactory(upsert.New(false)) +- req := reconcile.Request{NamespacedName: types.NamespacedName{Namespace: obj.Namespace, Name: obj.Name}} +- +- if _, err := providerFactory(req)(context.Background(), client, obj, tc.mutateFN(&obj.ObjectMeta)); err != nil { ++ if _, err := providerFactory(req)(context.Background(), client, obj, tc.mutateFN(obj)); err != nil { + t.Fatalf("CreateOrUpdate failed: %v", err) + } + +- actual := &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "foo"}} +- if err := client.Get(context.Background(), crclient.ObjectKeyFromObject(actual), actual); err != nil { ++ if err := client.Get(context.Background(), crclient.ObjectKeyFromObject(obj), obj); err != nil { + t.Fatalf("failed to get object from client after running CreateOrUpdate: %v", err) + } +- actual.ResourceVersion = "" +- actual.TypeMeta = metav1.TypeMeta{} +- if diff := cmp.Diff(actual, expectedObj); diff != "" { ++ actualMeta := obj.(metav1.Object) ++ actualMeta.SetResourceVersion("") ++ if diff := cmp.Diff(tc.expected, obj); diff != "" { + t.Errorf("actual differs from expected: %v", diff) + } +- +- if tc.verify != nil { +- tc.verify(t, actual) +- } + }) + } + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3Rv27CMBAG8Mw8hV8gcQw1mSukrl1adUTGdutIwYfsCxJvX5OFComygKq232+5 ++U/wnl3zNZuwHt/ZxL6t7aYtO66kW53XqlZ6ruWq16spzpXS3qIS+20RfjJlNEqJKRPzdvmvrv1Rz ++yp995rWl7dZE1+Rwu3dcy18t9Sn/xTH/h2WrK9HeboTL/nn+1okp+I13sw8Sx1Y0Mhx2PuXQv3NN ++pTNMSVqKnGgYyoIMlNk7O5Sf55MUdRqjeClHV8kb9s/pdedKfes5PMZIbLin+GRsueYg6v3spz8a ++AAAAAAAAAAAAAAAAAAAAAOCP+ARoNPOaACgAAA== +diff --git 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-002152/tests/test.sh b/tasks/format-code-task-002152/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1b6887930e4d252d000e4c5bb64577d36b7eced --- /dev/null +++ b/tasks/format-code-task-002152/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' +hypershift-operator/controllers/hostedcluster/createorupdate_annotation_enforcer_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-002152/tests/test_command.sh b/tasks/format-code-task-002152/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002152/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002154/environment/Dockerfile b/tasks/format-code-task-002154/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c680fc5c330ff31e6f94f8977d101cdf731233e8 --- /dev/null +++ b/tasks/format-code-task-002154/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c6796a9ac7a920fe8891f325a69b492c8ddc4e1e5b24d21da697fc180e57724c diff --git a/tasks/format-code-task-002154/environment/setup/files/blocklist b/tasks/format-code-task-002154/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002154/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002154/environment/setup/setup.sh b/tasks/format-code-task-002154/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002154/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002154/tests/test.patch b/tasks/format-code-task-002154/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..90883404a2ce103a3aa7bcb6851d04ac1db545a9 --- /dev/null +++ b/tasks/format-code-task-002154/tests/test.patch @@ -0,0 +1,94 @@ +diff --git a/test/integration/buildpod_admission_test.go b/test/integration/buildpod_admission_test.go +index 35b9f03b5bcf..bc9b18c2c681 100644 +--- a/test/integration/buildpod_admission_test.go ++++ b/test/integration/buildpod_admission_test.go +@@ -12,6 +12,7 @@ import ( + watchapi "k8s.io/apimachinery/pkg/watch" + kclientset "k8s.io/client-go/kubernetes" + kapi "k8s.io/kubernetes/pkg/apis/core" ++ kapiv1 "k8s.io/kubernetes/pkg/apis/core/v1" + + buildtestutil "github.com/openshift/origin/pkg/build/admission/testutil" + buildapi "github.com/openshift/origin/pkg/build/apis/build" +@@ -107,6 +108,40 @@ func TestBuildDefaultAnnotations(t *testing.T) { + } + } + ++func TestBuildOverrideTolerations(t *testing.T) { ++ tolerations := []kapi.Toleration{ ++ { ++ Key: "mykey1", ++ Value: "myvalue1", ++ Effect: "NoSchedule", ++ Operator: "Equal", ++ }, ++ { ++ Key: "mykey2", ++ Value: "myvalue2", ++ Effect: "NoSchedule", ++ Operator: "Equal", ++ }, ++ } ++ ++ oclient, kclientset, fn := setupBuildOverridesAdmissionTest(t, &overridesapi.BuildOverridesConfig{ ++ Tolerations: tolerations, ++ }) ++ ++ defer fn() ++ ++ _, pod := runBuildPodAdmissionTest(t, oclient, kclientset, buildPodAdmissionTestDockerBuild()) ++ for i, toleration := range tolerations { ++ tol := v1.Toleration{} ++ if err := kapiv1.Convert_core_Toleration_To_v1_Toleration(&toleration, &tol, nil); err != nil { ++ t.Errorf("Unable to convert core.Toleration to v1.Toleration: %v", err) ++ } ++ if !reflect.DeepEqual(pod.Spec.Tolerations[i], tol) { ++ t.Errorf("Resulting pod did not get expected tolerations, expected: %#v, actual: %#v", toleration, pod.Spec.Tolerations[i]) ++ } ++ } ++} ++ + func TestBuildOverrideForcePull(t *testing.T) { + oclient, kclientset, fn := setupBuildOverridesAdmissionTest(t, &overridesapi.BuildOverridesConfig{ + ForcePull: 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,25 @@ ++H4sIAAAAAAAAA+1Z63PTOBDvZ/0VS7gZHlfbcR4Oj+FDaAPkKEkvSXncYzqKrdgijmQkuWk47v72 ++WzmhpBwcpJQwd/g3nWlsrXZX+u0rrTvOeRodM3Hi7XwtVBGtZrP4jXj/d/HZb9Z8v9VsBX6wU/X9 ++wG/sQPOrebSGXBuqAHaUlObf5D61/h+F+45/ecJUSheXHwcb8N+s1nzkv14L/JL/beAD/J8wEUl1 ++iWGwOf+NZjMo+d8GPs7/9JZ2ubyMMNic/2bQKvN/K/gk/9N8zJRghukLh8LG/Neq1Ua15H8b2IR/ ++vKmYi3jjONicf7/RKue/reAi/GsVbhQDm/NfqwX1kv9t4KL8bzIdbM5/vd4q57+t4Av5pxmf0TDh ++gqmPf3HcnP+g2miV/G8Dl8l/Nv3wbHAB/oN6Of9tBZfNf0rHLH3vq8LG/NdRvlbyvw18Jf4jGbqx ++XNmwBAeNxsf492tB8z3+8SPyX93GBXzn/Hs3yZ7MForHiYFa1W/AKGHw+Ix0aOcmkUq7hBzwkAnN ++IshFxBQYlGtnSD6D1couPGVKcymg5lbhuhWorJYqN+6ShcxhRhcgpIFcM1TANUx4yoCdhiwzwAWE ++cpalnIqQwZybpDCyUuGSFysFcmwoylKUzvBpsi4F1BACiMSY7I7nzedzlxZeulJheC6ltHfQ3ev0 ++hh0HPSXkSKRMa1DsVc4VHnC8AJqhHyEdo3cpnYNUQGPFcM1I6+dccYOpsAtaTsycKkYiro3i49yc ++u6C3XuFJ1wXwiqiASnsI3WEF7reH3eEuedYdPeofjeBZezBo90bdzhD6A9jr9/a7o26/h08PoN17 ++AY+7vf1dYHg9aISdZsr6jg5ye3UscsmQsXPGJ3LpjM5YyCc8xBOJOKcxg9jmvMCDQMbUjGtLnkbX ++IpLyGTfUFM//OI5LbnqEeB4c0nBq9SyzvvCAzZgwqAN08bRcAr3Qhs12IaMYIGgOTSCVxlaO2CrS ++LGWhwThb0q4ZqkBil3pdkp2zQ7510vyPsFb/MdvNMSbgDMlxdXJ5Nj7R/2u1anD2/z+/XrN//w+w ++DZT1fwu4esUbc+GNqU4IZh04LJeQ8YxNKE8JCSMo4mLMIkKuQlfgbaUpPJTgu7fdFvBJUc5pqhiN ++FmBrEaa/rf1Y8TIlX2JWv62r2m77y3dvObj3BsGtv8IVcNCCzIwXS/safr9rC40oSniYqxSciR4e ++FNVcYzmPUhwrZJwyFwMV9+BP4YibcpGfOnQWBQ0XCXXj1+BI9H2WnYksXxeaZ9OIK3CyddPFgo0F ++5/T15EM7wdk756rj2IKeObZnSWGr3j2fTDghWJOlMvCwP+j3R/fWTaxWDtujR+vvLQV3frBv3+1d ++yqzu3juWuclyK/9Owvf9J/39o4POPTmZrL1uPu309vuDzvPDzqD7pNMboVvI3QN+CsvRruiyWNvH ++POVmgb1J5+wOYAiwoAFMhDIqSnSaJVhuDSQUm1detEPDIEyooqHBRo865wkPEyzqgofatkXB5tgp ++kOaT5SCg4ToXYZoXCvGgP94gdoBwOFzTb9r39/Y7Dx4+6v70+OBJr3/482A4Onr67PmLX+g4jNgk ++TvjLaToTMnultMlP5qeL1zgs1hvNoHXr9vHxFypwjt9cg98K1s+ueTX6xtiD8nERYnks1UtuIw2v ++hYVezARGoL3PIV5Nnq2YgrlUU41tipGz2Kr88Mdy8c9iYl5TKjPsogmfmApRM4zwzxH1JM5oXFRI ++KsDRZy5vtBW9HuSi6OQY0jGzI5dhsSr6PFiNNuE/X2PhhLemo0JiWegB5wQchbZG+HDftpg+hoTi ++ERvJlKnVYIGpkwuD4fmtq2CJEiVKfH/4Gx3Tse8AKAAA +diff --git 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-002154/tests/test.sh b/tasks/format-code-task-002154/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..62afe53319d0dd535d3f7e72be0b6afb60494c00 --- /dev/null +++ b/tasks/format-code-task-002154/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/integration/buildpod_admission_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-002154/tests/test_command.sh b/tasks/format-code-task-002154/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002154/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002163/environment/Dockerfile b/tasks/format-code-task-002163/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8cf90c1a5010a0e44f38c1069454d16b29e10403 --- /dev/null +++ b/tasks/format-code-task-002163/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:80eb278d62e22625bff46435332d2e8a37938df5c3770064829986384ce4f65a diff --git a/tasks/format-code-task-002163/environment/setup/files/blocklist b/tasks/format-code-task-002163/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002163/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002163/environment/setup/setup.sh b/tasks/format-code-task-002163/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002163/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002163/tests/test.patch b/tasks/format-code-task-002163/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4f105ea5ab7f937f71dac9ab8350b60afadc9fed --- /dev/null +++ b/tasks/format-code-task-002163/tests/test.patch @@ -0,0 +1,177 @@ +diff --git a/pkg/yurthub/proxy/local/local_test.go b/pkg/yurthub/proxy/local/local_test.go +index 6d08ce372e6..a1274de6a4a 100644 +--- a/pkg/yurthub/proxy/local/local_test.go ++++ b/pkg/yurthub/proxy/local/local_test.go +@@ -66,7 +66,7 @@ func TestServeHTTPForWatch(t *testing.T) { + return false + } + +- lp := NewLocalProxy(cacheM, fn) ++ lp := NewLocalProxy(cacheM, fn, 0) + + testcases := map[string]struct { + userAgent string +@@ -160,7 +160,7 @@ func TestServeHTTPForWatchWithHealthyChange(t *testing.T) { + return cnt > 2 // after 6 seconds, become healthy + } + +- lp := NewLocalProxy(cacheM, fn) ++ lp := NewLocalProxy(cacheM, fn, 0) + + testcases := map[string]struct { + userAgent string +@@ -230,7 +230,98 @@ func TestServeHTTPForWatchWithHealthyChange(t *testing.T) { + t.Errorf("Got error %v, unable to remove path %s", err, rootDir) + } + } ++func TestServeHTTPForWatchWithMinRequestTimeout(t *testing.T) { ++ dStorage, err := disk.NewDiskStorage(rootDir) ++ if err != nil { ++ t.Errorf("failed to create disk storage, %v", err) ++ } ++ sWrapper := cachemanager.NewStorageWrapper(dStorage) ++ serializerM := serializer.NewSerializerManager() ++ cacheM, _ := cachemanager.NewCacheManager(sWrapper, serializerM, nil, nil) ++ ++ fn := func() bool { ++ return false ++ } ++ ++ lp := NewLocalProxy(cacheM, fn, 10*time.Second) ++ ++ testcases := map[string]struct { ++ userAgent string ++ accept string ++ verb string ++ path string ++ code int ++ floor time.Duration ++ ceil time.Duration ++ }{ ++ "watch request": { ++ userAgent: "kubelet", ++ accept: "application/json", ++ verb: "GET", ++ path: "/api/v1/nodes?watch=true&timeoutSeconds=5", ++ code: http.StatusOK, ++ floor: 5 * time.Second, ++ ceil: 6 * time.Second, ++ }, ++ "watch request without timeout": { ++ userAgent: "kubelet", ++ accept: "application/json", ++ verb: "GET", ++ path: "/api/v1/nodes?watch=true", ++ code: http.StatusOK, ++ floor: 10 * time.Second, ++ ceil: 20 * time.Second, ++ }, ++ } + ++ resolver := newTestRequestInfoResolver() ++ ++ for k, tt := range testcases { ++ t.Run(k, func(t *testing.T) { ++ req, _ := http.NewRequest(tt.verb, tt.path, nil) ++ if len(tt.accept) != 0 { ++ req.Header.Set("Accept", tt.accept) ++ } ++ ++ if len(tt.userAgent) != 0 { ++ req.Header.Set("User-Agent", tt.userAgent) ++ } ++ req.RemoteAddr = "127.0.0.1" ++ ++ var start, end time.Time ++ var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { ++ start = time.Now() ++ lp.ServeHTTP(w, req) ++ end = time.Now() ++ }) ++ ++ handler = proxyutil.WithRequestClientComponent(handler) ++ handler = proxyutil.WithRequestContentType(handler) ++ handler = filters.WithRequestInfo(handler, resolver) ++ ++ resp := httptest.NewRecorder() ++ handler.ServeHTTP(resp, req) ++ result := resp.Result() ++ if result.StatusCode != tt.code { ++ t.Errorf("got status code %d, but expect %d", result.StatusCode, tt.code) ++ } ++ ++ if tt.floor.Seconds() != 0 { ++ if start.Add(tt.floor).After(end) { ++ t.Errorf("exec time is less than floor time %v", tt.floor) ++ } ++ } ++ ++ if start.Add(tt.ceil).Before(end) { ++ t.Errorf("exec time is more than ceil time %v", tt.ceil) ++ } ++ }) ++ } ++ ++ if err = os.RemoveAll(rootDir); err != nil { ++ t.Errorf("Got error %v, unable to remove path %s", err, rootDir) ++ } ++} + func TestServeHTTPForPost(t *testing.T) { + dStorage, err := disk.NewDiskStorage(rootDir) + if err != nil { +@@ -244,7 +335,7 @@ func TestServeHTTPForPost(t *testing.T) { + return false + } + +- lp := NewLocalProxy(cacheM, fn) ++ lp := NewLocalProxy(cacheM, fn, 0) + + testcases := map[string]struct { + userAgent string +@@ -324,7 +415,7 @@ func TestServeHTTPForDelete(t *testing.T) { + return false + } + +- lp := NewLocalProxy(cacheM, fn) ++ lp := NewLocalProxy(cacheM, fn, 0) + + testcases := map[string]struct { + userAgent string +@@ -391,7 +482,7 @@ func TestServeHTTPForGetReqCache(t *testing.T) { + return false + } + +- lp := NewLocalProxy(cacheM, fn) ++ lp := NewLocalProxy(cacheM, fn, 0) + + testcases := map[string]struct { + userAgent string +@@ -531,7 +622,7 @@ func TestServeHTTPForListReqCache(t *testing.T) { + return false + } + +- lp := NewLocalProxy(cacheM, fn) ++ lp := NewLocalProxy(cacheM, fn, 0) + + testcases := map[string]struct { + userAgent 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+3RTQrCMBAF4K49xVygSaYa68azlP5hxbYpbVL09saCKIK6qYj4vs0MZCAzPJG5 ++fV0kZTvK4FOUF2s9Ve+xTj3rSC1VFPHazzHrWAekP7bRHTfYtCcKemPsq7l37z9K3PK35WCT3DRN ++2hZiqOb7413+zKtr/hwvY5//as0ckJpvhef+PP+8oCn4rCwWO0OXlsKRwty41m6ZQrtvSuN8u1ED ++CdkddvLkelu5THa9OZ5kbfK0lkKIxbdvAQAAAAAAAAAAAAAAAAAAAAD4N2cbLuX3ACgAAA== +diff --git 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-002163/tests/test.sh b/tasks/format-code-task-002163/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a65a533a86516d7d1ea278432ee3508312f69144 --- /dev/null +++ b/tasks/format-code-task-002163/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/yurthub/proxy/local/local_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-002163/tests/test_command.sh b/tasks/format-code-task-002163/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002163/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002197/environment/Dockerfile b/tasks/format-code-task-002197/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2ae20b5e0d58ed9308255eb033bb1480c933f902 --- /dev/null +++ b/tasks/format-code-task-002197/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4aa5def542cae7f463eec8d46218b57a385f90586a8da3db44c6485464f4acaa diff --git a/tasks/format-code-task-002197/environment/setup/files/blocklist b/tasks/format-code-task-002197/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002197/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002197/environment/setup/setup.sh b/tasks/format-code-task-002197/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002197/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002197/tests/test.patch b/tasks/format-code-task-002197/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f8d88823eb9d529e156661527c34d8e8c1b40a21 --- /dev/null +++ b/tasks/format-code-task-002197/tests/test.patch @@ -0,0 +1,169 @@ +diff --git a/pandas/tests/reshape/test_merge.py b/pandas/tests/reshape/test_merge.py +index d3257243d7..a015e8e2a6 100644 +--- a/pandas/tests/reshape/test_merge.py ++++ b/pandas/tests/reshape/test_merge.py +@@ -1403,3 +1403,142 @@ class TestMergeOnIndexes(object): + how=how, + sort=sort) + tm.assert_frame_equal(result, expected) ++ ++ ++class TestMergeValidate(object): ++ ++ def setup_method(self, method): ++ self.left_unique = DataFrame({'a': [1, 2, 3, 4], ++ 'left_val': [10, 20, 30, 40]}) ++ self.right_unique = DataFrame({'a': [1, 2, 3, 4], ++ 'right_val': [100, 200, 300, 400]}) ++ self.left_dup = DataFrame({'a': [1, 1, 2, 3], ++ 'left_val': [10, 11, 20, 30]}) ++ self.right_dup = DataFrame({'a': [1, 2, 2, 3], ++ 'right_val': [100, 200, 201, 300]}) ++ ++ def test_validate_one_to_one_passes(self): ++ result = pd.merge(self.left_unique, self.right_unique, ++ on='a', validate='one_to_one') ++ assert len(result) == 4 ++ assert list(result['a']) == [1, 2, 3, 4] ++ ++ def test_validate_one_to_one_raises_left_dup(self): ++ with pytest.raises(ValueError) as excinfo: ++ pd.merge(self.left_dup, self.right_unique, ++ on='a', validate='one_to_one') ++ msg = str(excinfo.value).lower() ++ assert 'left' in msg ++ ++ def test_validate_one_to_one_raises_right_dup(self): ++ with pytest.raises(ValueError) as excinfo: ++ pd.merge(self.left_unique, self.right_dup, ++ on='a', validate='one_to_one') ++ msg = str(excinfo.value).lower() ++ assert 'right' in msg ++ ++ def test_validate_one_to_many_passes_when_left_unique(self): ++ ++ result = pd.merge(self.left_unique, self.right_dup, ++ on='a', validate='one_to_many') ++ assert len(result) == 4 ++ ++ def test_validate_one_to_many_raises_left_dup(self): ++ with pytest.raises(ValueError) as excinfo: ++ pd.merge(self.left_dup, self.right_unique, ++ on='a', validate='one_to_many') ++ msg = str(excinfo.value).lower() ++ assert 'left' in msg ++ ++ def test_validate_many_to_one_passes_when_right_unique(self): ++ ++ result = pd.merge(self.left_dup, self.right_unique, ++ on='a', validate='many_to_one') ++ assert len(result) == 4 ++ ++ def test_validate_many_to_one_raises_right_dup(self): ++ with pytest.raises(ValueError) as excinfo: ++ pd.merge(self.left_unique, self.right_dup, ++ on='a', validate='many_to_one') ++ msg = str(excinfo.value).lower() ++ assert 'right' in msg ++ ++ def test_validate_many_to_many_passes_with_dups(self): ++ ++ result = pd.merge(self.left_dup, self.right_dup, ++ on='a', validate='many_to_many') ++ ++ assert isinstance(result, DataFrame) ++ ++ def test_validate_short_alias_1_to_1_passes(self): ++ result = pd.merge(self.left_unique, self.right_unique, ++ on='a', validate='1:1') ++ assert len(result) == 4 ++ ++ def test_validate_short_alias_1_to_1_raises(self): ++ with pytest.raises(ValueError): ++ pd.merge(self.left_dup, self.right_unique, ++ on='a', validate='1:1') ++ ++ def test_validate_short_alias_1_to_m_raises_left_dup(self): ++ with pytest.raises(ValueError): ++ pd.merge(self.left_dup, self.right_unique, ++ on='a', validate='1:m') ++ ++ def test_validate_short_alias_m_to_1_raises_right_dup(self): ++ with pytest.raises(ValueError): ++ pd.merge(self.left_unique, self.right_dup, ++ on='a', validate='m:1') ++ ++ def test_validate_short_alias_m_to_m_passes(self): ++ result = pd.merge(self.left_dup, self.right_dup, ++ on='a', validate='m:m') ++ assert isinstance(result, DataFrame) ++ ++ def test_validate_invalid_string_raises(self): ++ with pytest.raises(ValueError): ++ pd.merge(self.left_unique, self.right_unique, ++ on='a', validate='jibberish') ++ ++ def test_validate_default_none_no_check(self): ++ ++ result = pd.merge(self.left_dup, self.right_dup, on='a') ++ assert isinstance(result, DataFrame) ++ ++ def test_validate_via_dataframe_method(self): ++ ++ with pytest.raises(ValueError): ++ self.left_dup.merge(self.right_unique, ++ on='a', validate='one_to_one') ++ ++ result = self.left_unique.merge(self.right_unique, ++ on='a', validate='one_to_one') ++ assert len(result) == 4 ++ ++ def test_validate_multi_key_combination_unique(self): ++ ++ ++ ++ left = DataFrame({'a': [1, 1, 2, 2], ++ 'b': [1, 2, 1, 2], ++ 'left_val': [10, 11, 12, 13]}) ++ right = DataFrame({'a': [1, 1, 2, 2], ++ 'b': [1, 2, 1, 2], ++ 'right_val': [20, 21, 22, 23]}) ++ result = pd.merge(left, right, on=['a', 'b'], validate='one_to_one') ++ assert len(result) == 4 ++ ++ def test_validate_with_left_index_right_index(self): ++ ++ left = DataFrame({'left_val': [10, 20, 30]}, index=[1, 2, 3]) ++ right = DataFrame({'right_val': [100, 200, 300]}, index=[1, 2, 3]) ++ result = pd.merge(left, right, left_index=True, right_index=True, ++ validate='one_to_one') ++ assert len(result) == 3 ++ ++ ++ right_dup_idx = DataFrame({'right_val': [100, 101, 200, 300]}, ++ index=[1, 1, 2, 3]) ++ with pytest.raises(ValueError): ++ pd.merge(left, right_dup_idx, left_index=True, right_index=True, ++ validate='one_to_one') +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..4776f9edb9 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/reshape/test_merge.py::TestMergeValidate -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/reshape/test_merge.py::TestMergeValidate -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002197/tests/test.sh b/tasks/format-code-task-002197/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3e91e3c7a18c3d93011c6271f54e9083375cc412 --- /dev/null +++ b/tasks/format-code-task-002197/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/reshape/test_merge.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-002197/tests/test_command.sh b/tasks/format-code-task-002197/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002197/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002198/environment/Dockerfile b/tasks/format-code-task-002198/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..32f31f4e80e565169c6ae40053324ab10552f294 --- /dev/null +++ b/tasks/format-code-task-002198/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7c36c2a46efc69f3f3e9866194e72b6a8aba4a3f3489a5567a19616f1c3dd565 diff --git a/tasks/format-code-task-002198/environment/setup/files/blocklist b/tasks/format-code-task-002198/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002198/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002198/environment/setup/setup.sh b/tasks/format-code-task-002198/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002198/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002198/tests/test.patch b/tasks/format-code-task-002198/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7f379e1ed72d27c4175bb1f03d182dd6c6909502 --- /dev/null +++ b/tasks/format-code-task-002198/tests/test.patch @@ -0,0 +1,107 @@ +diff --git a/pandas/tests/tseries/test_frequencies.py b/pandas/tests/tseries/test_frequencies.py +index 54d12317b0..f5a6ca3644 100644 +--- a/pandas/tests/tseries/test_frequencies.py ++++ b/pandas/tests/tseries/test_frequencies.py +@@ -855,3 +855,80 @@ def test_is_superperiod_subperiod(): + + assert (frequencies.is_superperiod(offsets.Micro(), offsets.Nano())) + assert (frequencies.is_subperiod(offsets.Nano(), offsets.Micro())) ++ ++ ++ ++def test_to_offset_Y_alias(): ++ result = frequencies.to_offset('Y') ++ expected = frequencies.to_offset('A') ++ assert result == expected ++ assert isinstance(result, offsets.YearEnd) ++ ++ ++def test_to_offset_YS_alias(): ++ result = frequencies.to_offset('YS') ++ expected = frequencies.to_offset('AS') ++ assert result == expected ++ assert isinstance(result, offsets.YearBegin) ++ ++ ++def test_to_offset_BY_alias(): ++ result = frequencies.to_offset('BY') ++ expected = frequencies.to_offset('BA') ++ assert result == expected ++ assert isinstance(result, offsets.BYearEnd) ++ ++ ++def test_to_offset_BYS_alias(): ++ result = frequencies.to_offset('BYS') ++ expected = frequencies.to_offset('BAS') ++ assert result == expected ++ assert isinstance(result, offsets.BYearBegin) ++ ++ ++def test_date_range_freq_Y(): ++ result = date_range('2017-01-01', periods=3, freq='Y') ++ expected = date_range('2017-01-01', periods=3, freq='A') ++ tm.assert_index_equal(result, expected) ++ ++ ++def test_date_range_freq_YS(): ++ result = date_range('2017-01-01', periods=3, freq='YS') ++ expected = date_range('2017-01-01', periods=3, freq='AS') ++ tm.assert_index_equal(result, expected) ++ ++ ++def test_date_range_freq_BY(): ++ result = date_range('2017-01-01', periods=3, freq='BY') ++ expected = date_range('2017-01-01', periods=3, freq='BA') ++ tm.assert_index_equal(result, expected) ++ ++ ++def test_date_range_freq_BYS(): ++ result = date_range('2017-01-01', periods=3, freq='BYS') ++ expected = date_range('2017-01-01', periods=3, freq='BAS') ++ tm.assert_index_equal(result, expected) ++ ++ ++def test_period_str_to_code_Y(): ++ assert frequencies._period_str_to_code('Y') == 1000 ++ assert (frequencies._period_str_to_code('Y') == ++ frequencies._period_str_to_code('A')) ++ ++ ++def test_period_str_to_code_Y_month(): ++ ++ assert (frequencies._period_str_to_code('Y-DEC') == ++ frequencies._period_str_to_code('A-DEC')) ++ assert (frequencies._period_str_to_code('Y-JAN') == ++ frequencies._period_str_to_code('A-JAN')) ++ assert (frequencies._period_str_to_code('Y-MAY') == ++ frequencies._period_str_to_code('A-MAY')) ++ ++ ++def test_A_alias_still_works(): ++ ++ assert frequencies.to_offset('A') == offsets.YearEnd() ++ assert frequencies.to_offset('AS') == offsets.YearBegin() ++ assert frequencies.to_offset('BA') == offsets.BYearEnd() ++ assert frequencies.to_offset('BAS') == offsets.BYearBegin() +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..0a810da3ba +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/tseries/test_frequencies.py -k \"Y_alias or YS_alias or BY_alias or BYS_alias or date_range_freq or period_str_to_code_Y or A_alias_still\" -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/tseries/test_frequencies.py -k "Y_alias or YS_alias or BY_alias or BYS_alias or date_range_freq or period_str_to_code_Y or A_alias_still" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002198/tests/test.sh b/tasks/format-code-task-002198/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..19f72dd5aa5d824048230ba5f5d5c26fdff9540c --- /dev/null +++ b/tasks/format-code-task-002198/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/tseries/test_frequencies.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-002198/tests/test_command.sh b/tasks/format-code-task-002198/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002198/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002199/environment/Dockerfile b/tasks/format-code-task-002199/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..224719a86912013e94794a442e60fb59a36ff4c0 --- /dev/null +++ b/tasks/format-code-task-002199/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4984443aff409d9270ad428a5185473f9a7ebb510d7f1793a6fe2703d67ab15c diff --git a/tasks/format-code-task-002199/environment/setup/files/blocklist b/tasks/format-code-task-002199/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002199/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002199/environment/setup/setup.sh b/tasks/format-code-task-002199/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002199/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002199/tests/test.patch b/tasks/format-code-task-002199/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b3935ad122a7b08447cafd48936c76e27656ab79 --- /dev/null +++ b/tasks/format-code-task-002199/tests/test.patch @@ -0,0 +1,116 @@ +diff --git a/pandas/tests/io/test_pytables.py b/pandas/tests/io/test_pytables.py +index 2fe3cf1f34..3b56d34d7a 100644 +--- a/pandas/tests/io/test_pytables.py ++++ b/pandas/tests/io/test_pytables.py +@@ -5695,3 +5695,89 @@ class TestTimezones(Base): + store.append('df', df) + result = store.select('df') + assert_frame_equal(result, df) ++ ++ def test_fixed_tz_aware_index_roundtrip_issue(self): ++ ++ ++ time = Timestamp('2000-01-01 01:00:00', tz='US/Eastern') ++ df = DataFrame(data=[0], index=[time]) ++ with ensure_clean_path(self.path) as path: ++ df.to_hdf(path, 'df') ++ df2 = pd.read_hdf(path) ++ ++ ++ assert df2.index[0].value == df.index[0].value ++ assert df2.index[0] == df.index[0] ++ assert df2.index[0].tzinfo is not None ++ ++ def test_fixed_tz_aware_index_roundtrip_multi(self): ++ ++ ++ ++ rng = date_range('2000-01-01 01:00:00', periods=5, freq='H', ++ tz='US/Eastern') ++ df = DataFrame({'a': list(range(5))}, index=rng) ++ with ensure_clean_path(self.path) as path: ++ df.to_hdf(path, 'df') ++ df2 = pd.read_hdf(path) ++ for i in range(len(df.index)): ++ assert df.index[i].value == df2.index[i].value ++ assert df.index[i] == df2.index[i] ++ ++ def test_fixed_tz_aware_index_roundtrip_non_us_tz(self): ++ ++ ++ time = Timestamp('2000-06-01 12:00:00', tz='Europe/Berlin') ++ df = DataFrame(data=[0], index=[time]) ++ with ensure_clean_path(self.path) as path: ++ df.to_hdf(path, 'df') ++ df2 = pd.read_hdf(path) ++ assert df2.index[0].value == df.index[0].value ++ assert df2.index[0] == df.index[0] ++ ++ assert df2.index.tz is not None ++ ++ def test_fixed_tz_aware_index_roundtrip_utc(self): ++ ++ ++ ++ time = Timestamp('2000-01-01 06:00:00', tz='UTC') ++ df = DataFrame(data=[0], index=[time]) ++ with ensure_clean_path(self.path) as path: ++ df.to_hdf(path, 'df') ++ df2 = pd.read_hdf(path) ++ assert df2.index[0].value == df.index[0].value ++ assert df2.index[0] == df.index[0] ++ ++ def test_fixed_naive_index_roundtrip_preserved(self): ++ ++ ++ rng = date_range('2000-01-01', periods=3, freq='H') ++ df = DataFrame({'a': [1, 2, 3]}, index=rng) ++ with ensure_clean_path(self.path) as path: ++ df.to_hdf(path, 'df') ++ df2 = pd.read_hdf(path) ++ assert (df2.index.asi8 == df.index.asi8).all() ++ assert df2.index.tz is None ++ ++ def test_fixed_tz_aware_series_roundtrip(self): ++ ++ rng = date_range('2000-01-01 01:00:00', periods=3, freq='H', ++ tz='Asia/Tokyo') ++ s = Series([1, 2, 3], index=rng) ++ with ensure_clean_path(self.path) as path: ++ s.to_hdf(path, 's') ++ s2 = pd.read_hdf(path) ++ assert (s2.index.asi8 == s.index.asi8).all() ++ assert s.index[0].value == s2.index[0].value ++ assert s.index[0] == s2.index[0] ++ ++ def test_fixed_tz_aware_index_roundtrip_preserves_freq(self): ++ ++ ++ rng = date_range('2000-01-01', periods=5, freq='H', tz='US/Eastern') ++ df = DataFrame({'a': list(range(5))}, index=rng) ++ with ensure_clean_path(self.path) as path: ++ df.to_hdf(path, 'df') ++ df2 = pd.read_hdf(path) ++ assert df2.index.freq == df.index.freq +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..b138c2d573 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/io/test_pytables.py -k 'test_fixed_tz_aware or test_fixed_naive_index_roundtrip_preserved' -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/io/test_pytables.py -k 'test_fixed_tz_aware or test_fixed_naive_index_roundtrip_preserved' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002199/tests/test.sh b/tasks/format-code-task-002199/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c4eb1d7231c03ccff7a8ecefbba4b86e65e0473f --- /dev/null +++ b/tasks/format-code-task-002199/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/io/test_pytables.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-002199/tests/test_command.sh b/tasks/format-code-task-002199/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002199/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002303/environment/Dockerfile b/tasks/format-code-task-002303/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8118eb9373e01c6b26deb7bb2c6ed19d2a400af8 --- /dev/null +++ b/tasks/format-code-task-002303/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:42f9a66ac2c737dbf2feda2a2ac046425ed2643151c4ec12cf37e0eb0922eec1 diff --git a/tasks/format-code-task-002303/environment/setup/files/blocklist b/tasks/format-code-task-002303/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002303/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002303/environment/setup/setup.sh b/tasks/format-code-task-002303/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002303/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002303/tests/test.patch b/tasks/format-code-task-002303/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..859adb8e21c3680253913bf2b6f08be049ec2023 --- /dev/null +++ b/tasks/format-code-task-002303/tests/test.patch @@ -0,0 +1,286 @@ +diff --git a/usercase-test-coderl/ascii8_stateful.test.js b/usercase-test-coderl/ascii8_stateful.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/ascii8_stateful.test.js +@@ -0,0 +1,260 @@ ++const assert = require("assert"); ++const fs = require("fs"); ++const path = require("path"); ++const vm = require("vm"); ++const zlib = require("zlib"); ++ ++const REPO_ROOT = "/workspace/repo"; ++ ++function loadWebMSX() { ++ const context = { ++ console: { log() {}, warn() {}, error() {}, info() {} }, ++ window: {}, ++ WMSX_IMAGES_PATH: "", ++ btoa: str => Buffer.from(str, "binary").toString("base64"), ++ atob: str => Buffer.from(str, "base64").toString("binary"), ++ JSZip: { ++ compressions: { ++ DEFLATE: { ++ compress: arr => Array.from(zlib.deflateRawSync(Buffer.from(arr))), ++ uncompress: str => Array.from(zlib.inflateRawSync(Buffer.from(Array.from(str, ch => ch.charCodeAt(0) & 0xff)))) ++ } ++ } ++ } ++ }; ++ context.window = context; ++ vm.createContext(context); ++ ++ [ ++ "src/main/WMSX.js", ++ "src/main/util/Util.js", ++ "src/main/util/SHA1.js", ++ "src/main/util/EmbeddedFiles.js", ++ "src/main/msx/rom/ROMDatabase.js", ++ "src/main/msx/rom/ROM.js", ++ "src/main/msx/slots/SlotCreator.js", ++ "src/main/msx/slots/SlotFormats.js", ++ "src/main/msx/slots/Slot.js", ++ "src/main/msx/slots/SlotNormal.js", ++ "src/main/msx/slots/SlotPlainROM.js", ++ "src/main/msx/slots/cartridges/CartridgeASCII8K.js", ++ "src/main/msx/slots/cartridges/CartridgeASCII16K.js" ++ ].forEach(rel => { ++ vm.runInContext(fs.readFileSync(path.join(REPO_ROOT, rel), "utf8"), context, { filename: rel }); ++ }); ++ ++ const wmsx = context.wmsx; ++ wmsx.Util.log = function() {}; ++ wmsx.Configurator = { adaptROMSourceForOldState: source => source }; ++ wmsx.CartridgePAC = { isPACFileContentValid: () => false }; ++ wmsx.SlotCreator.setUserROMFormats({ getForROM: () => null }); ++ return wmsx; ++} ++ ++function makeAscii8Bytes(size, starts) { ++ const bankStarts = starts || [0x41, 0x11, 0x22, 0x33]; ++ const bytes = new Array(size).fill(0); ++ bytes[0] = 0x41; ++ bytes[1] = 0x42; ++ for (let bank = 0; bank < bankStarts.length && bank * 8192 < size; bank++) { ++ bytes[bank * 8192] = bankStarts[bank]; ++ } ++ return bytes; ++} ++ ++function makeROM(wmsx, name, bytes, formatHint) { ++ return new wmsx.ROM(name, bytes.slice(), null, formatHint); ++} ++ ++function sampleROM(wmsx, formatHint) { ++ return makeROM(wmsx, "ascii8.rom", makeAscii8Bytes(32768), formatHint); ++} ++ ++function readProbe(cart) { ++ return [ ++ cart.read(0x0000), cart.read(0x3fff), ++ cart.read(0x4000), cart.read(0x5fff), ++ cart.read(0x6000), cart.read(0x7fff), ++ cart.read(0x8000), cart.read(0x9fff), ++ cart.read(0xa000), cart.read(0xbfff), ++ cart.read(0xc000) ++ ]; ++} ++ ++function mappedStarts(cart) { ++ return [cart.read(0x4000), cart.read(0x6000), cart.read(0x8000), cart.read(0xa000)]; ++} ++ ++function test(name, fn) { ++ try { ++ fn(); ++ console.log("ok - " + name); ++ } catch (err) { ++ console.error("not ok - " + name); ++ throw err; ++ } ++} ++ ++test("ASCII8 user option and automatic acceptance boundaries", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ assert.strictEqual(wmsx.SlotFormatsUserOptions.includes("ASCII8"), true); ++ ++ assert.strictEqual(!!wmsx.SlotFormats.ASCII8.priorityForRom(sampleROM(wmsx)), true); ++ ++ assert.strictEqual(!!wmsx.SlotFormats.ASCII8.priorityForRom(makeROM(wmsx, "badlen.rom", makeAscii8Bytes(24577))), false); ++ const noHeader = makeAscii8Bytes(32768); ++ noHeader[0] = 0x00; ++ noHeader[1] = 0x00; ++ ++ assert.strictEqual(!!wmsx.SlotFormats.ASCII8.priorityForRom(makeROM(wmsx, "noheader.rom", noHeader)), false); ++}); ++ ++test("SlotCreator can create ASCII8 cartridge from public ROM with explicit user format hint", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ const cart = wmsx.SlotCreator.createFromROM(sampleROM(wmsx, "ASCII8")); ++ assert.strictEqual(cart.format.name, "ASCII8"); ++ assert.strictEqual(cart instanceof wmsx.CartridgeASCII8K, true); ++ cart.reset(); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 65, 0, 65, 0, 65, 0, 65, 0, 255]); ++}); ++ ++test("reset maps all four pages to bank zero and outside reads to 0xff", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ const cart = new wmsx.CartridgeASCII8K(sampleROM(wmsx)); ++ ++ ["powerOn", "reset", "write", "read", "saveState", "loadState"].forEach(method => { ++ assert.strictEqual(typeof cart[method], "function"); ++ }); ++ cart.reset(); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 65, 0, 65, 0, 65, 0, 65, 0, 255]); ++}); ++ ++test("powerOn resets all pages to bank zero", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ const cart = new wmsx.CartridgeASCII8K(sampleROM(wmsx)); ++ cart.powerOn(); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 65, 0, 65, 0, 65, 0, 65, 0, 255]); ++}); ++ ++test("writes update the addressed 8 KiB page and use modulo bank selection", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ const cart = new wmsx.CartridgeASCII8K(sampleROM(wmsx)); ++ cart.reset(); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 65, 0, 65, 0, 65, 0, 65, 0, 255]); ++ cart.write(0x6000, 2); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 34, 0, 65, 0, 65, 0, 65, 0, 255]); ++ cart.write(0x6800, 3); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 34, 0, 51, 0, 65, 0, 65, 0, 255]); ++ cart.write(0x7000, 5); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 34, 0, 51, 0, 17, 0, 65, 0, 255]); ++}); ++ ++test("writes below 0x6000 are ignored", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ const cart = new wmsx.CartridgeASCII8K(sampleROM(wmsx)); ++ cart.reset(); ++ cart.write(0x6000, 2); ++ cart.write(0x6800, 3); ++ cart.write(0x7000, 5); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 34, 0, 51, 0, 17, 0, 65, 0, 255]); ++ cart.write(0x5fff, 3); ++ assert.deepStrictEqual(readProbe(cart), [255, 255, 34, 0, 51, 0, 17, 0, 65, 0, 255]); ++}); ++ ++test("saveState serializes format, ROM state, ROM bytes, selected offsets, and bank count", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ const cart = new wmsx.CartridgeASCII8K(sampleROM(wmsx)); ++ cart.reset(); ++ cart.write(0x6000, 2); ++ cart.write(0x6800, 3); ++ cart.write(0x7000, 5); ++ const state = cart.saveState(); ++ const serialized = JSON.stringify(state); ++ const parsed = JSON.parse(serialized); ++ ++ ++ assert.strictEqual(serialized.includes("ASCII8"), true); ++ ++ const loaded = new wmsx.CartridgeASCII8K(); ++ loaded.loadState(parsed); ++ ++ assert.deepStrictEqual(readProbe(loaded), [255, 255, 34, 0, 51, 0, 17, 0, 65, 0, 255]); ++ ++ loaded.write(0x6000, 5); ++ ++ assert.strictEqual(loaded.read(0x4000), 17); ++ ++ const viaCreator = wmsx.SlotCreator.recreateFromSaveState(parsed); ++ ++ assert.deepStrictEqual(mappedStarts(viaCreator), [34, 51, 17, 65]); ++}); ++ ++test("loadState and recreateFromSaveState preserve mapped reads and reusable slot", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ const cart = new wmsx.CartridgeASCII8K(sampleROM(wmsx)); ++ cart.reset(); ++ cart.write(0x6000, 2); ++ cart.write(0x6800, 3); ++ cart.write(0x7000, 5); ++ const state = cart.saveState(); ++ ++ const loaded = new wmsx.CartridgeASCII8K(); ++ loaded.loadState(state); ++ assert.deepStrictEqual(readProbe(loaded), [255, 255, 34, 0, 51, 0, 17, 0, 65, 0, 255]); ++ ++ const reusable = new wmsx.CartridgeASCII8K(makeROM(wmsx, "reusable.rom", makeAscii8Bytes(32768, [0x41, 0xaa, 0xbb, 0xcc]))); ++ reusable.reset(); ++ const recreated = wmsx.CartridgeASCII8K.recreateFromSaveState(state, reusable); ++ assert.strictEqual(recreated === reusable, true); ++ assert.deepStrictEqual(readProbe(recreated), [255, 255, 34, 0, 51, 0, 17, 0, 65, 0, 255]); ++ ++ const viaCreator = wmsx.SlotCreator.recreateFromSaveState(state, recreated); ++ assert.strictEqual(viaCreator === recreated, true); ++ assert.deepStrictEqual(readProbe(viaCreator), [255, 255, 34, 0, 51, 0, 17, 0, 65, 0, 255]); ++}); ++ ++test("separate ASCII8 instances keep independent selected-bank state", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ const a = new wmsx.CartridgeASCII8K(makeROM(wmsx, "a.rom", makeAscii8Bytes(32768))); ++ const b = new wmsx.CartridgeASCII8K(makeROM(wmsx, "b.rom", makeAscii8Bytes(32768))); ++ a.reset(); ++ b.reset(); ++ a.write(0x6000, 2); ++ b.write(0x6800, 3); ++ assert.deepStrictEqual([a.read(0x4000), a.read(0x6000), a.read(0x8000), a.read(0xa000)], [34, 65, 65, 65]); ++ assert.deepStrictEqual([b.read(0x4000), b.read(0x6000), b.read(0x8000), b.read(0xa000)], [65, 51, 65, 65]); ++}); ++ ++test("repeated construct-use-save-recreate cycles preserve ASCII8 behavior", () => { ++ ++ ++ const wmsx = loadWebMSX(); ++ ++ for (let i = 0; i < 500; i++) { ++ const cart = wmsx.SlotCreator.createFromROM(sampleROM(wmsx, "ASCII8")); ++ cart.reset(); ++ cart.write(0x6000, 2); ++ assert.strictEqual(cart.read(0x4000), 34); ++ const state = cart.saveState(); ++ const recreated = wmsx.CartridgeASCII8K.recreateFromSaveState(state); ++ assert.strictEqual(recreated.read(0x4000), 34); ++ } ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++exec node --expose-gc /workspace/repo/usercase-test-coderl/ascii8_stateful.test.js diff --git a/tasks/format-code-task-002303/tests/test.sh b/tasks/format-code-task-002303/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..00405aeb41443b5df7af7441bcb81551e0bc26c8 --- /dev/null +++ b/tasks/format-code-task-002303/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/ascii8_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-002303/tests/test_command.sh b/tasks/format-code-task-002303/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002303/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-002304/environment/Dockerfile b/tasks/format-code-task-002304/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0722c6eea5a3622eb1184a186a09759e2675fab8 --- /dev/null +++ b/tasks/format-code-task-002304/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:955d67381a3674e12e151f602e503a16ee74e5e92442e36f21ee4a2a04802c22 diff --git a/tasks/format-code-task-002304/environment/setup/files/blocklist b/tasks/format-code-task-002304/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002304/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002304/environment/setup/setup.sh b/tasks/format-code-task-002304/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002304/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002304/tests/test.patch b/tasks/format-code-task-002304/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a7c3255dd801bd3fad04b95a1ba2c18f0291716a --- /dev/null +++ b/tasks/format-code-task-002304/tests/test.patch @@ -0,0 +1,41 @@ +diff --git a/vumi/transports/dmark/tests/test_dmark_ussd.py b/vumi/transports/dmark/tests/test_dmark_ussd.py +index 7ba9688de..e47636d7e 100644 +--- a/vumi/transports/dmark/tests/test_dmark_ussd.py ++++ b/vumi/transports/dmark/tests/test_dmark_ussd.py +@@ -89,13 +89,13 @@ def assert_nack(self, nack, reply, reason): + + @inlineCallbacks + def test_inbound_begin(self): +- user_content = "Who are you?" ++ user_content = "SHOULD BE IGNORED" + d = self.tx_helper.mk_request(ussdRequestString=user_content) + [msg] = yield self.tx_helper.wait_for_dispatched_inbound(1) + self.assert_inbound_message( + msg, + session_event=TransportUserMessage.SESSION_NEW, +- content=user_content) ++ content=None) + + reply_content = "We are the Knights Who Say ... Ni!" + reply = msg.reply(reply_content) +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+3SPU/EIBwG8M58CqwddJCW9noYEwcHk1uMDu4NPRqP2JcL0Ea/vQWHMyZ6y13U +++PwGKPxJITywetStqpp+SqNjyWaiLEM/+9yHb17mnAuRFaKIMs6XmYhoebQTfTBaJw2lkRkG9926 ++ffU/iu3yd4111XroOtkrZjeH22Nf/nmR7/Jf+PwXS15GNDvcEb72z/M/PUlr3ae1tBuyVjQ8grpR ++pHnZDsbRh5vH1XWcrO7vblO2ffXPZF5+lfj5mDSTbGmcnIUC1b129OI8Ju/Dp3ao53LOBOOXxBk9 ++D6ax08wZ2Vv/d8tUJ80z83va0FZhohqtVeSnbwYAAAAAAAAAAAAAAAAAAAAA4Pd7A1ZXUPcAKAAA +diff --git 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-002304/tests/test.sh b/tasks/format-code-task-002304/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..04906fc0ea5cc7d5224ded0a9027642ecc921202 --- /dev/null +++ b/tasks/format-code-task-002304/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' +vumi/transports/dmark/tests/test_dmark_ussd.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-002304/tests/test_command.sh b/tasks/format-code-task-002304/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002304/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002332/environment/Dockerfile b/tasks/format-code-task-002332/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..db12098f5f7fd3d20db76b4e07bc84250c8db64c --- /dev/null +++ b/tasks/format-code-task-002332/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2a73b43207eb7e20d3c17a2a9b501014b411596a6f1c7a9faecce0af652b2c09 diff --git a/tasks/format-code-task-002332/environment/setup/files/blocklist b/tasks/format-code-task-002332/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002332/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002332/environment/setup/setup.sh b/tasks/format-code-task-002332/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002332/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002332/tests/test.patch b/tasks/format-code-task-002332/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..622bb3cbb794f8a4af40476bd49358cac32e5b1d --- /dev/null +++ b/tasks/format-code-task-002332/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..96ac954f0 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest tests/export_extension_bug --no-colors"] ++} +diff --git a/tests/export_extension_bug/jsfmt.spec.js b/tests/export_extension_bug/jsfmt.spec.js +new file mode 100644 +index 000000000..1d70c19e9 +--- /dev/null ++++ b/tests/export_extension_bug/jsfmt.spec.js +@@ -0,0 +1,58 @@ ++"use strict"; ++ ++const prettier = require("../../"); ++ ++function format(code) { ++ return prettier.format(code, { parser: "babylon" }); ++} ++ ++describe("export extension specifier handling", () => { ++ test("default + named specifiers preserve separation (the bug)", () => { ++ const out = format("export foo, {bar} from './baz';\n"); ++ ++ expect(out).not.toMatch(/export\s*\{\s*foo\s*,\s*bar\s*\}/); ++ expect(out).toMatch(/export\s+foo\s*,\s*\{\s*bar\s*\}\s+from\s+"\.\/baz"/); ++ }); ++ ++ test("default-only specifier is preserved", () => { ++ const out = format("export foo from './baz';\n"); ++ expect(out.trim()).toBe('export foo from "./baz";'); ++ }); ++ ++ test("namespace specifier is preserved with '* as'", () => { ++ const out = format("export * as ns from './baz';\n"); ++ expect(out.trim()).toBe('export * as ns from "./baz";'); ++ }); ++ ++ test("named-only specifier is preserved with braces", () => { ++ const out = format("export {bar} from './baz';\n"); ++ expect(out.trim()).toBe('export { bar } from "./baz";'); ++ }); ++ ++ test("batch (export *) is preserved", () => { ++ const out = format("export * from './baz';\n"); ++ expect(out.trim()).toBe('export * from "./baz";'); ++ }); ++ ++ test("default + namespace specifiers do not wrap namespace in braces", () => { ++ const out = format("export foo, * as ns from './baz';\n"); ++ ++ expect(out).not.toMatch(/\{[^}]*\*\s*as[^}]*\}/); ++ ++ expect(out).toMatch(/\* as ns/); ++ expect(out).toMatch(/\bfoo\b/); ++ expect(out).toMatch(/from\s+"\.\/baz"/); ++ }); ++ ++ test("default + named with multiple named identifiers", () => { ++ const out = format("export foo, {bar, baz} from './qux';\n"); ++ expect(out).not.toMatch(/export\s*\{\s*foo\s*,\s*bar/); ++ expect(out).toMatch(/export\s+foo\s*,\s*\{[^}]*bar[^}]*baz[^}]*\}/); ++ }); ++ ++ test("output is idempotent for the issue's exact case", () => { ++ const first = format("export foo, {bar} from './baz';\n"); ++ const second = format(first); ++ expect(second).toBe(first); ++ }); ++}); +diff --git 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/export_extension_bug --no-colors ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002332/tests/test.sh b/tasks/format-code-task-002332/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..384f86b3ff64c87f001c2fad14e0b2fda3aedb93 --- /dev/null +++ b/tasks/format-code-task-002332/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/export_extension_bug/jsfmt.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-002332/tests/test_command.sh b/tasks/format-code-task-002332/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002332/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002335/environment/Dockerfile b/tasks/format-code-task-002335/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6eb45a67cfabd70de2c60e96d2e8b183e74339bd --- /dev/null +++ b/tasks/format-code-task-002335/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:11bc86c6521257eff3b7c1182535d833bf17fbbf4de7f9a34e7844ebb5e1ce4c diff --git a/tasks/format-code-task-002335/environment/setup/files/blocklist b/tasks/format-code-task-002335/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002335/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002335/environment/setup/setup.sh b/tasks/format-code-task-002335/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002335/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002335/tests/test.patch b/tasks/format-code-task-002335/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..42323ce89c36e686143e332e35ad141ea55b68fe --- /dev/null +++ b/tasks/format-code-task-002335/tests/test.patch @@ -0,0 +1,168 @@ +diff --git a/usercase-test-coderl/test_saliency_meter_state.py b/usercase-test-coderl/test_saliency_meter_state.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_saliency_meter_state.py +@@ -0,0 +1,140 @@ ++ ++ ++ ++ ++ ++ ++ ++import sys ++ ++import pytest ++import torch ++ ++sys.path.insert(0, "/workspace/repo") ++ ++from InvPT.evaluation.eval_sal import SaliencyMeter as InvPTSaliencyMeter ++from TaskPrompter.evaluation.eval_sal import SaliencyMeter as TaskPrompterSaliencyMeter ++ ++ ++PERFECT_PREDS = torch.tensor([[[0.0, 255.0], [0.0, 255.0]]]) ++PERFECT_TARGET = torch.tensor([[[0, 1], [0, 1]]]) ++SINGLETON_IGNORE_PREDS = torch.tensor([[[255.0, 0.0], [255.0, 0.0]]]) ++SINGLETON_IGNORE_TARGET = torch.tensor([[[[1, 255], [0, 1]]]]) ++ALL_POSITIVE_PREDS = torch.tensor([[[255.0, 255.0], [255.0, 255.0]]]) ++ALL_NEGATIVE_TARGET = torch.tensor([[[0, 0], [0, 0]]]) ++ ++ ++def _scaled_score(meter_cls, value): ++ if meter_cls is TaskPrompterSaliencyMeter: ++ return value * 100 ++ return value ++ ++ ++@pytest.mark.parametrize( ++ ("meter_cls", "expected_score"), ++ [ ++ (TaskPrompterSaliencyMeter, {"maxF": 100.0}), ++ (InvPTSaliencyMeter, {"maxF": 1.0}), ++ ], ++) ++def test_threshold_point_six_perfect_session_accumulates_counts(meter_cls, expected_score): ++ ++ ++ meter = meter_cls(threshold_step=0.6, beta_squared=1) ++ ++ ++ assert set(meter.get_score(verbose=False)) == {"maxF"} ++ ++ meter.update(PERFECT_PREDS, PERFECT_TARGET) ++ assert meter.get_score(verbose=False) == expected_score ++ ++ meter.update(ALL_POSITIVE_PREDS, ALL_NEGATIVE_TARGET) ++ ++ assert meter.get_score(verbose=False)["maxF"] == pytest.approx(_scaled_score(meter_cls, 0.5)) ++ ++ ++@pytest.mark.parametrize( ++ ("meter_cls", "expected_maxf"), ++ [ ++ (TaskPrompterSaliencyMeter, 66.66666865348816), ++ (InvPTSaliencyMeter, 0.6666666865348816), ++ ], ++) ++def test_threshold_point_five_counts_zero_predictions_as_positive(meter_cls, expected_maxf): ++ ++ ++ meter = meter_cls(threshold_step=0.5, beta_squared=1) ++ ++ meter.update(PERFECT_PREDS, PERFECT_TARGET) ++ ++ assert meter.get_score(verbose=False)["maxF"] == pytest.approx(expected_maxf) ++ ++ meter.update(PERFECT_PREDS, PERFECT_TARGET) ++ ++ assert meter.get_score(verbose=False)["maxF"] == pytest.approx(expected_maxf) ++ ++ ++@pytest.mark.parametrize( ++ ("meter_cls", "expected_score"), ++ [ ++ (TaskPrompterSaliencyMeter, {"maxF": 50.0}), ++ (InvPTSaliencyMeter, {"maxF": 0.5}), ++ ], ++) ++def test_singleton_channel_target_is_squeezed_and_ignore_index_is_masked(meter_cls, expected_score): ++ ++ ++ meter = meter_cls(ignore_index=255, threshold_step=0.6, beta_squared=1) ++ ++ meter.update(SINGLETON_IGNORE_PREDS, SINGLETON_IGNORE_TARGET) ++ ++ assert meter.get_score(verbose=False) == expected_score ++ ++ ++@pytest.mark.parametrize("meter_cls", [TaskPrompterSaliencyMeter, InvPTSaliencyMeter]) ++def test_incompatible_update_shapes_raise_assertion_error(meter_cls): ++ ++ ++ meter = meter_cls(threshold_step=0.6, beta_squared=1) ++ bad_target = torch.tensor([[[0, 1], [0, 1], [0, 1]]]) ++ ++ with pytest.raises(AssertionError): ++ meter.update(PERFECT_PREDS, bad_target) ++ ++ ++@pytest.mark.parametrize("meter_cls", [TaskPrompterSaliencyMeter, InvPTSaliencyMeter]) ++def test_separate_instances_keep_independent_accumulated_counts(meter_cls): ++ ++ ++ a = meter_cls(threshold_step=0.6, beta_squared=1) ++ b = meter_cls(threshold_step=0.6, beta_squared=1) ++ ++ a.update(PERFECT_PREDS, PERFECT_TARGET) ++ ++ assert a.get_score(verbose=False)["maxF"] == pytest.approx(_scaled_score(meter_cls, 1.0)) ++ ++ b.update(ALL_POSITIVE_PREDS, ALL_NEGATIVE_TARGET) ++ assert b.get_score(verbose=False)["maxF"] == pytest.approx(0.0) ++ assert a.get_score(verbose=False)["maxF"] == pytest.approx(_scaled_score(meter_cls, 1.0)) ++ ++ b.update(PERFECT_PREDS, PERFECT_TARGET) ++ assert b.get_score(verbose=False)["maxF"] == pytest.approx(_scaled_score(meter_cls, 0.5)) ++ assert a.get_score(verbose=False)["maxF"] == pytest.approx(_scaled_score(meter_cls, 1.0)) ++ ++ ++@pytest.mark.parametrize("meter_cls", [TaskPrompterSaliencyMeter, InvPTSaliencyMeter]) ++def test_repeated_create_update_drop_cycles_do_not_retain_session_objects(meter_cls): ++ ++ ++ scores = [] ++ ++ for _ in range(120): ++ meter = meter_cls(threshold_step=0.6, beta_squared=1) ++ meter.update(PERFECT_PREDS, PERFECT_TARGET) ++ score = meter.get_score(verbose=False)["maxF"] ++ ++ assert score == pytest.approx(_scaled_score(meter_cls, 1.0)) ++ scores.append(score) ++ del meter ++ ++ assert len(scores) == 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,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:-}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++python -m pytest /workspace/repo/usercase-test-coderl/test_saliency_meter_state.py -v diff --git a/tasks/format-code-task-002335/tests/test.sh b/tasks/format-code-task-002335/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e3b2d6fe918f693577a0dfb9a661421f97c53716 --- /dev/null +++ b/tasks/format-code-task-002335/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_saliency_meter_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-002335/tests/test_command.sh b/tasks/format-code-task-002335/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002335/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-002351/environment/Dockerfile b/tasks/format-code-task-002351/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..70e7a84409bd06f4f8e9280676d95a2ab1a0d6a4 --- /dev/null +++ b/tasks/format-code-task-002351/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c6120629c5318d3f719318fc92b37ea9c8830f2ecb524801402257c2e9cf4137 diff --git a/tasks/format-code-task-002351/environment/setup/files/blocklist b/tasks/format-code-task-002351/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002351/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002351/environment/setup/setup.sh b/tasks/format-code-task-002351/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002351/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002351/tests/test.patch b/tasks/format-code-task-002351/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7954c0615b69586b1ca72223a0890bfd51230bef --- /dev/null +++ b/tasks/format-code-task-002351/tests/test.patch @@ -0,0 +1,84 @@ +diff --git a/tests/providers/aws/services/ec2/ec2_securitygroup_default_restrict_traffic/ec2_securitygroup_default_restrict_traffic_test.py b/tests/providers/aws/services/ec2/ec2_securitygroup_default_restrict_traffic/ec2_securitygroup_default_restrict_traffic_test.py +index b52361fc7a..01cfc895d9 100644 +--- a/tests/providers/aws/services/ec2/ec2_securitygroup_default_restrict_traffic/ec2_securitygroup_default_restrict_traffic_test.py ++++ b/tests/providers/aws/services/ec2/ec2_securitygroup_default_restrict_traffic/ec2_securitygroup_default_restrict_traffic_test.py +@@ -127,6 +127,58 @@ def test_ec2_non_compliant_sg_ingress_rule(self): + assert result[0].region == AWS_REGION_US_EAST_1 + assert result[0].resource_id == default_sg_id + ++ @mock_aws ++ def test_ec2_non_compliant_sg_ingress_rule_but_unused(self): ++ ++ ec2_client = client("ec2", region_name=AWS_REGION_US_EAST_1) ++ default_sg = ec2_client.describe_security_groups(GroupNames=["default"])[ ++ "SecurityGroups" ++ ][0] ++ default_sg_id = default_sg["GroupId"] ++ default_sg["GroupName"] ++ ec2_client.authorize_security_group_ingress( ++ GroupId=default_sg_id, ++ IpPermissions=[ ++ {"IpProtocol": "-1", "IpRanges": [{"CidrIp": "10.0.0.16/0"}]} ++ ], ++ ) ++ ec2_client.revoke_security_group_egress( ++ GroupId=default_sg_id, ++ IpPermissions=[ ++ { ++ "IpProtocol": "-1", ++ "IpRanges": [{"CidrIp": "0.0.0.0/0"}], ++ "Ipv6Ranges": [], ++ "PrefixListIds": [], ++ "UserIdGroupPairs": [], ++ } ++ ], ++ ) ++ ++ from prowler.providers.aws.services.ec2.ec2_service import EC2 ++ ++ aws_provider = set_mocked_aws_provider( ++ audited_regions=[AWS_REGION_US_EAST_1], scan_unused_services=False ++ ) ++ ++ with mock.patch( ++ "prowler.providers.common.provider.Provider.get_global_provider", ++ return_value=aws_provider, ++ ), mock.patch( ++ "prowler.providers.aws.services.ec2.ec2_securitygroup_default_restrict_traffic.ec2_securitygroup_default_restrict_traffic.ec2_client", ++ new=EC2(aws_provider), ++ ): ++ ++ from prowler.providers.aws.services.ec2.ec2_securitygroup_default_restrict_traffic.ec2_securitygroup_default_restrict_traffic import ( ++ ec2_securitygroup_default_restrict_traffic, ++ ) ++ ++ check = ec2_securitygroup_default_restrict_traffic() ++ result = check.execute() ++ ++ ++ assert len(result) == 0 ++ + @mock_aws + def test_ec2_non_compliant_sg_egress_rule(self): + # Create EC2 Mocked Resources +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+3S22rDIAAG4FznKRy7bkyy2DyOGDWL0MTgISVvP5OblsJWBi3b2P+BBzyg+Ft0 ++0ZwU19NCs2cpk5axvU1u271fsbqqjmVTszReVaxlGWFPu9GV6INwhGTO2vDVunvzf1RxyT9oH7i0 ++4ygmVfjhcWfcy79mzSX/sk75N8eyzUj5uCt87p/n//pCOzPRTvghl4rsn6DTKp/XMNjpjRxGkrpp ++kGyVp7Ozi1HaeSrOnnrtFiO1p1rWW+Fey+hMWN+djTNXuhfxFLhLW52RgQcn+t7Ibyzl27HFvJLD ++kv/0WwEAAAAAAAAAAAAAAAAAAAAA/DYfaoiyAgAoAAA= +diff --git 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-002351/tests/test.sh b/tasks/format-code-task-002351/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2a86b0bc5dd4ca5ee9ec65ba95f3efdca77cd2da --- /dev/null +++ b/tasks/format-code-task-002351/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/providers/aws/services/ec2/ec2_securitygroup_default_restrict_traffic/ec2_securitygroup_default_restrict_traffic_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002351/tests/test_command.sh b/tasks/format-code-task-002351/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002351/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002356/environment/Dockerfile b/tasks/format-code-task-002356/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7177ee3256aaedb30f5d8fe092d4aa8f84219ecd --- /dev/null +++ b/tasks/format-code-task-002356/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a39c94c3d3c0e8fc9e9912d55afb4282e2676cb9e614afb56106a8bb7b2853df diff --git a/tasks/format-code-task-002356/environment/setup/files/blocklist b/tasks/format-code-task-002356/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002356/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002356/environment/setup/setup.sh b/tasks/format-code-task-002356/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002356/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002356/tests/test.patch b/tasks/format-code-task-002356/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9f2e34434bd7cdc9e6e01ced8fac69e5c727f1c0 --- /dev/null +++ b/tasks/format-code-task-002356/tests/test.patch @@ -0,0 +1,245 @@ +diff --git a/usercase-test-coderl/test_numeric_literal_formatting.py b/usercase-test-coderl/test_numeric_literal_formatting.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_numeric_literal_formatting.py +@@ -0,0 +1,214 @@ ++ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++from pathlib import Path ++ ++import pytest ++ ++import black ++ ++ ++REPO_SRC = "/workspace/repo/src" ++ ++ ++def test_decimal_float_missing_leading_zero_is_normalized() -> None: ++ ++ ++ ++ actual = black.format_str("x = .1\n", mode=black.Mode()) ++ ++ assert actual == "x = 0.1\n" ++ ++ ++def test_decimal_float_missing_fractional_digits_gets_trailing_zero() -> None: ++ ++ ++ ++ actual = black.format_str("x = 1.\n", mode=black.Mode()) ++ ++ assert actual == "x = 1.0\n" ++ ++ ++def test_scientific_uppercase_e_and_plus_are_normalized() -> None: ++ ++ ++ ++ actual = black.format_str("x = 1E+1\n", mode=black.Mode()) ++ ++ assert actual == "x = 1e1\n" ++ ++ ++def test_scientific_uppercase_e_and_minus_are_normalized() -> None: ++ ++ ++ ++ actual = black.format_str("x = 1E-1\n", mode=black.Mode()) ++ ++ assert actual == "x = 1e-1\n" ++ ++ ++def test_complex_integer_suffix_is_lowercase() -> None: ++ ++ ++ ++ actual = black.format_str("x = 123456789J\n", mode=black.Mode()) ++ ++ assert actual == "x = 123456789j\n" ++ ++ ++def test_complex_missing_leading_zero_preserves_float_rule() -> None: ++ ++ ++ ++ actual = black.format_str("x = .1J\n", mode=black.Mode()) ++ ++ assert actual == "x = 0.1j\n" ++ ++ ++def test_complex_missing_fractional_digits_preserves_float_rule() -> None: ++ ++ ++ ++ actual = black.format_str("x = 1.J\n", mode=black.Mode()) ++ ++ assert actual == "x = 1.0j\n" ++ ++ ++def test_complex_scientific_suffix_preserves_exponent_rule() -> None: ++ ++ ++ ++ actual = black.format_str("x = 1E+1J\n", mode=black.Mode()) ++ ++ assert actual == "x = 1e1j\n" ++ ++ ++def test_hex_prefix_and_hex_digits_are_normalized() -> None: ++ ++ ++ ++ actual = black.format_str("x = 0XB1acc\n", mode=black.Mode()) ++ ++ assert actual == "x = 0xB1ACC\n" ++ ++ ++def test_binary_prefix_is_lowercase() -> None: ++ ++ ++ ++ actual = black.format_str("x = 0B1011\n", mode=black.Mode()) ++ ++ assert actual == "x = 0b1011\n" ++ ++ ++def test_octal_prefix_is_lowercase() -> None: ++ ++ ++ ++ actual = black.format_str("x = 0O777\n", mode=black.Mode()) ++ ++ assert actual == "x = 0o777\n" ++ ++ ++def test_hex_underscore_digits_are_uppercased() -> None: ++ ++ ++ ++ actual = black.format_str("x = 0xdead_beef\n", mode=black.Mode()) ++ ++ ++ ++ assert actual.startswith("x = 0x") ++ assert actual.endswith("\n") ++ literal = actual.removeprefix("x = ").strip() ++ digits = literal[2:] ++ assert digits ++ assert all(ch == "_" or ch.isdigit() or "A" <= ch <= "F" for ch in digits) ++ assert any("A" <= ch <= "F" for ch in digits) ++ ++ ++def test_normalized_numeric_output_remains_valid_ordinary_python_source() -> None: ++ actual = black.format_str("x = .1\n", mode=black.Mode()) ++ ++ ++ ++ assert actual == "x = 0.1\n" ++ compile(actual, "", "exec") ++ ++ ++def test_referential_transparency_for_same_source_and_mode() -> None: ++ source = "x = 1E+1\n" ++ mode = black.Mode() ++ ++ assert black.format_str(source, mode=mode) == black.format_str(source, mode=mode) ++ ++ ++def test_format_str_does_not_mutate_caller_owned_inputs() -> None: ++ source = "x = .1\n" ++ mode = black.Mode(line_length=100, target_versions={black.TargetVersion.PY310}) ++ source_before = copy.deepcopy(source) ++ mode_before = copy.deepcopy(mode) ++ ++ actual = black.format_str(source, mode=mode) ++ ++ assert actual == "x = 0.1\n" ++ assert source == source_before ++ assert mode == mode_before ++ ++ ++def test_same_input_matches_in_fresh_python_process(tmp_path: Path) -> None: ++ source = "x = 0XB1acc\n" ++ mode = black.Mode() ++ in_process = black.format_str(source, mode=mode) ++ version_shim = tmp_path / "_black_version.py" ++ version_shim.write_text('version = "0.0.0-fixture"\n', encoding="utf-8") ++ script = """ ++import json ++import black ++out = black.format_str("x = 0XB1acc\\n", mode=black.Mode()) ++print(json.dumps(out)) ++""" ++ env = os.environ.copy() ++ env["PYTHONPATH"] = os.pathsep.join([str(tmp_path), REPO_SRC]) ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ env=env, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ text=True, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ ++ assert in_process == "x = 0xB1ACC\n" ++ assert fresh_process == in_process ++ ++ ++def test_format_str_has_no_cwd_or_network_side_effects( ++ monkeypatch: pytest.MonkeyPatch, tmp_path: Path ++) -> None: ++ def raise_on_socket(*args: object, **kwargs: object) -> None: ++ raise AssertionError("black.format_str attempted to create a socket") ++ ++ monkeypatch.chdir(tmp_path) ++ monkeypatch.setattr(socket, "socket", raise_on_socket) ++ before = sorted(path.relative_to(tmp_path) for path in tmp_path.rglob("*")) ++ ++ actual = black.format_str("x = 1E-1\n", mode=black.Mode()) ++ ++ after = sorted(path.relative_to(tmp_path) for path in tmp_path.rglob("*")) ++ assert actual == "x = 1e-1\n" ++ assert after == before +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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 ++ ++version_shim="$(mktemp -d)" ++printf 'version = "0.0.0-fixture"\n' > "${version_shim}/_black_version.py" ++export PYTHONPATH="${version_shim}:/workspace/repo/src${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest -c /dev/null /workspace/repo/usercase-test-coderl/test_numeric_literal_formatting.py -v diff --git a/tasks/format-code-task-002356/tests/test.sh b/tasks/format-code-task-002356/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e90b8cfc979fee0c39eb1d37e99265fab6c84f45 --- /dev/null +++ b/tasks/format-code-task-002356/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_numeric_literal_formatting.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-002356/tests/test_command.sh b/tasks/format-code-task-002356/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002356/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-002358/environment/Dockerfile b/tasks/format-code-task-002358/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..25b52809f2b624072a92f39d34e1615f7db7aa17 --- /dev/null +++ b/tasks/format-code-task-002358/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5836efd2a85f6ca64926354eb30116cea2db889162ed37f4baaf1441ab8f9939 diff --git a/tasks/format-code-task-002358/environment/setup/files/blocklist b/tasks/format-code-task-002358/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002358/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002358/environment/setup/setup.sh b/tasks/format-code-task-002358/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002358/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002358/tests/test.patch b/tasks/format-code-task-002358/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2f3f632bc1ce859df01d4f31ae987c8fb79c4c3b --- /dev/null +++ b/tasks/format-code-task-002358/tests/test.patch @@ -0,0 +1,578 @@ +diff --git a/usercase-test-coderl/slice_helpers_test.go b/usercase-test-coderl/slice_helpers_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/slice_helpers_test.go +@@ -0,0 +1,551 @@ ++package usercase_test_coderl ++ ++ ++ ++ ++ ++ ++ ++import ( ++ "bytes" ++ "errors" ++ "fmt" ++ "os" ++ "os/exec" ++ "path/filepath" ++ "reflect" ++ "runtime" ++ stdslices "slices" ++ "sync" ++ "sync/atomic" ++ "testing" ++ "time" ++ ++ bfslices "github.com/PsionicAlch/byteforge/functions/slices" ++) ++ ++type namedInts []int ++ ++type intVisit struct { ++ Index int ++ Value int ++} ++ ++type stringVisit struct { ++ Index int ++ Value string ++} ++ ++type callbackPanic struct { ++ Label string ++} ++ ++func TestMapDoublesIntsInOriginalOrder(t *testing.T) { ++ ++ ++ ++ ++ actual := bfslices.Map([]int{0, 1, 2, 3, 4, 5}, func(n int) int { ++ return n * 2 ++ }) ++ expected := []int{0, 2, 4, 6, 8, 10} ++ ++ if !stdslices.Equal(actual, expected) { ++ t.Fatalf("Map doubled ints = %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestMapConvertsIntsToStrings(t *testing.T) { ++ ++ ++ ++ ++ actual := bfslices.Map([]int{0, 1, 2}, func(n int) string { ++ return fmt.Sprint(n) ++ }) ++ expected := []string{"0", "1", "2"} ++ ++ if !stdslices.Equal(actual, expected) { ++ t.Fatalf("Map ints to strings = %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestFilterEvenIntsPreservesNamedSliceTypeAndOrder(t *testing.T) { ++ ++ ++ ++ ++ input := namedInts{1, 2, 3, 4, 5, 6} ++ actual := bfslices.Filter(input, func(n int) bool { ++ return n%2 == 0 ++ }) ++ var typed namedInts = actual ++ expected := namedInts{2, 4, 6} ++ ++ if !stdslices.Equal(typed, expected) { ++ t.Fatalf("Filter even named ints = %#v, want %#v", typed, expected) ++ } ++} ++ ++func TestForEachCallsCallbackOncePerElementInAscendingIndexOrder(t *testing.T) { ++ ++ ++ ++ ++ var actual []intVisit ++ bfslices.ForEach([]int{10, 20, 30}, func(i int, v int) { ++ actual = append(actual, intVisit{Index: i, Value: v}) ++ }) ++ expected := []intVisit{{Index: 0, Value: 10}, {Index: 1, Value: 20}, {Index: 2, Value: 30}} ++ ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("ForEach visits = %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestParallelMapWithPositiveWorkersSquaresInOriginalOrder(t *testing.T) { ++ ++ ++ ++ ++ actual, maxActive := parallelMapWithObservedConcurrency(t, []int{1, 2, 3, 4}, 2, []int{2}) ++ expected := []int{1, 4, 9, 16} ++ ++ if !stdslices.Equal(actual, expected) { ++ t.Fatalf("ParallelMap squares = %#v, want %#v", actual, expected) ++ } ++ if maxActive != 2 { ++ t.Fatalf("ParallelMap max active callbacks = %d, want 2", maxActive) ++ } ++} ++ ++func TestParallelFilterWithPositiveWorkersKeepsGreaterThanTwoInOriginalOrder(t *testing.T) { ++ ++ ++ ++ ++ actual, maxActive := parallelFilterWithObservedConcurrency(t, []int{1, 2, 3, 4, 5}, 2, []int{2}) ++ expected := []int{3, 4, 5} ++ ++ if !stdslices.Equal(actual, expected) { ++ t.Fatalf("ParallelFilter > 2 = %#v, want %#v", actual, expected) ++ } ++ if maxActive != 2 { ++ t.Fatalf("ParallelFilter max active callbacks = %d, want 2", maxActive) ++ } ++} ++ ++func TestParallelForEachWithPositiveWorkersVisitsEveryPairBeforeReturning(t *testing.T) { ++ ++ ++ ++ ++ actual, maxActive := parallelForEachWithObservedConcurrency(t, []string{"a", "b", "c"}, 2, []int{2}) ++ expected := map[int]string{0: "a", 1: "b", 2: "c"} ++ ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("ParallelForEach visits = %#v, want %#v", actual, expected) ++ } ++ if maxActive != 2 { ++ t.Fatalf("ParallelForEach max active callbacks = %d, want 2", maxActive) ++ } ++} ++ ++func TestParallelHelpersUseGOMAXPROCSForOmittedAndNonPositiveWorkers(t *testing.T) { ++ ++ ++ ++ ++ old := runtime.GOMAXPROCS(2) ++ defer runtime.GOMAXPROCS(old) ++ ++ mapOmitted, mapOmittedMax := parallelMapWithObservedConcurrency(t, []int{1, 2, 3}, 2, nil) ++ mapZero, mapZeroMax := parallelMapWithObservedConcurrency(t, []int{1, 2, 3}, 2, []int{0}) ++ filterNegative, filterNegativeMax := parallelFilterWithObservedConcurrency(t, []int{1, 2, 3, 4}, 2, []int{-5}) ++ foreachOmitted, foreachOmittedMax := parallelForEachWithObservedConcurrency(t, []string{"x", "y", "z"}, 2, nil) ++ ++ if !stdslices.Equal(mapOmitted, []int{1, 4, 9}) { ++ t.Fatalf("ParallelMap omitted workers = %#v, want %#v", mapOmitted, []int{1, 4, 9}) ++ } ++ if mapOmittedMax != 2 { ++ t.Fatalf("ParallelMap omitted max active callbacks = %d, want 2", mapOmittedMax) ++ } ++ if !stdslices.Equal(mapZero, []int{1, 4, 9}) { ++ t.Fatalf("ParallelMap zero workers = %#v, want %#v", mapZero, []int{1, 4, 9}) ++ } ++ if mapZeroMax != 2 { ++ t.Fatalf("ParallelMap zero max active callbacks = %d, want 2", mapZeroMax) ++ } ++ if !stdslices.Equal(filterNegative, []int{3, 4}) { ++ t.Fatalf("ParallelFilter negative workers = %#v, want %#v", filterNegative, []int{3, 4}) ++ } ++ if filterNegativeMax != 2 { ++ t.Fatalf("ParallelFilter negative max active callbacks = %d, want 2", filterNegativeMax) ++ } ++ if !reflect.DeepEqual(foreachOmitted, map[int]string{0: "x", 1: "y", 2: "z"}) { ++ t.Fatalf("ParallelForEach omitted workers visits = %#v, want %#v", foreachOmitted, map[int]string{0: "x", 1: "y", 2: "z"}) ++ } ++ if foreachOmittedMax != 2 { ++ t.Fatalf("ParallelForEach omitted max active callbacks = %d, want 2", foreachOmittedMax) ++ } ++} ++ ++func TestEmptyInputsCompleteImmediately(t *testing.T) { ++ ++ ++ ++ ++ mapped := bfslices.Map([]int{}, func(n int) int { return n + 1 }) ++ parallelMapped := bfslices.ParallelMap([]int{}, func(n int) int { return n + 1 }, 2) ++ filtered := bfslices.Filter(namedInts{}, func(n int) bool { return true }) ++ parallelFiltered := bfslices.ParallelFilter(namedInts{}, func(n int) bool { return true }, 2) ++ forEachCalls := 0 ++ parallelForEachCalls := 0 ++ ++ bfslices.ForEach([]int{}, func(_ int, _ int) { forEachCalls++ }) ++ bfslices.ParallelForEach([]int{}, func(_ int, _ int) { parallelForEachCalls++ }, 2) ++ ++ var typedFiltered namedInts = filtered ++ var typedParallelFiltered namedInts = parallelFiltered ++ if !stdslices.Equal(mapped, []int{}) { ++ t.Fatalf("Map empty = %#v, want %#v", mapped, []int{}) ++ } ++ if !stdslices.Equal(parallelMapped, []int{}) { ++ t.Fatalf("ParallelMap empty = %#v, want %#v", parallelMapped, []int{}) ++ } ++ if !stdslices.Equal(typedFiltered, namedInts{}) { ++ t.Fatalf("Filter empty = %#v, want %#v", typedFiltered, namedInts{}) ++ } ++ if !stdslices.Equal(typedParallelFiltered, namedInts{}) { ++ t.Fatalf("ParallelFilter empty = %#v, want %#v", typedParallelFiltered, namedInts{}) ++ } ++ if forEachCalls != 0 { ++ t.Fatalf("ForEach empty callback count = %d, want 0", forEachCalls) ++ } ++ if parallelForEachCalls != 0 { ++ t.Fatalf("ParallelForEach empty callback count = %d, want 0", parallelForEachCalls) ++ } ++} ++ ++func TestSequentialHelpersDoNotRecoverOrConvertCallbackPanics(t *testing.T) { ++ ++ ++ ++ ++ expectPanicValue(t, callbackPanic{Label: "map-boom"}, func() { ++ _ = bfslices.Map([]int{1}, func(int) int { ++ panic(callbackPanic{Label: "map-boom"}) ++ }) ++ }) ++ expectPanicValue(t, callbackPanic{Label: "filter-boom"}, func() { ++ _ = bfslices.Filter([]int{1}, func(int) bool { ++ panic(callbackPanic{Label: "filter-boom"}) ++ }) ++ }) ++ expectPanicValue(t, callbackPanic{Label: "foreach-boom"}, func() { ++ bfslices.ForEach([]int{1}, func(int, int) { ++ panic(callbackPanic{Label: "foreach-boom"}) ++ }) ++ }) ++} ++ ++func TestParallelHelpersDoNotRecoverCallbackPanics(t *testing.T) { ++ ++ ++ ++ ++ if mode := os.Getenv("TST_PARALLEL_PANIC_HELPER"); mode != "" { ++ runParallelPanicMode(mode) ++ return ++ } ++ ++ cases := []struct { ++ mode string ++ want string ++ }{ ++ {mode: "map", want: "parallel-map-boom"}, ++ {mode: "filter", want: "parallel-filter-boom"}, ++ {mode: "foreach", want: "parallel-foreach-boom"}, ++ } ++ ++ for _, tc := range cases { ++ cmd := exec.Command(os.Args[0], "-test.run=^TestParallelHelpersDoNotRecoverCallbackPanics$") ++ cmd.Env = append(os.Environ(), "TST_PARALLEL_PANIC_HELPER="+tc.mode) ++ output, err := cmd.CombinedOutput() ++ var exitErr *exec.ExitError ++ if !errors.As(err, &exitErr) { ++ t.Fatalf("parallel %s panic process error = %v, want non-zero exit; output:\n%s", tc.mode, err, output) ++ } ++ if !bytes.Contains(output, []byte(tc.want)) { ++ t.Fatalf("parallel %s panic output = %q, want substring %q", tc.mode, output, tc.want) ++ } ++ } ++} ++ ++func TestHelpersAreReferentiallyTransparentForDeterministicCallbacks(t *testing.T) { ++ firstMap := bfslices.Map([]int{3, 4, 5}, func(n int) string { ++ return fmt.Sprintf("n=%d", n*3) ++ }) ++ secondMap := bfslices.Map([]int{3, 4, 5}, func(n int) string { ++ return fmt.Sprintf("n=%d", n*3) ++ }) ++ if !stdslices.Equal(firstMap, []string{"n=9", "n=12", "n=15"}) { ++ t.Fatalf("first Map deterministic result = %#v, want %#v", firstMap, []string{"n=9", "n=12", "n=15"}) ++ } ++ if !stdslices.Equal(secondMap, []string{"n=9", "n=12", "n=15"}) { ++ t.Fatalf("second Map deterministic result = %#v, want %#v", secondMap, []string{"n=9", "n=12", "n=15"}) ++ } ++ ++ firstFilter := bfslices.ParallelFilter([]int{1, 2, 3, 4, 5}, func(n int) bool { ++ return n%2 == 1 ++ }, 2) ++ secondFilter := bfslices.ParallelFilter([]int{1, 2, 3, 4, 5}, func(n int) bool { ++ return n%2 == 1 ++ }, 2) ++ if !stdslices.Equal(firstFilter, []int{1, 3, 5}) { ++ t.Fatalf("first ParallelFilter deterministic result = %#v, want %#v", firstFilter, []int{1, 3, 5}) ++ } ++ if !stdslices.Equal(secondFilter, []int{1, 3, 5}) { ++ t.Fatalf("second ParallelFilter deterministic result = %#v, want %#v", secondFilter, []int{1, 3, 5}) ++ } ++} ++ ++func TestHelpersDoNotMutateInputSlices(t *testing.T) { ++ mapInput := []int{2, 4, 6} ++ filterInput := namedInts{1, 2, 3, 4} ++ foreachInput := []string{"left", "right"} ++ mapOriginal := append([]int(nil), mapInput...) ++ filterOriginal := append(namedInts(nil), filterInput...) ++ foreachOriginal := append([]string(nil), foreachInput...) ++ ++ _ = bfslices.Map(mapInput, func(n int) int { return n * 10 }) ++ _ = bfslices.ParallelMap(mapInput, func(n int) int { return n + 10 }, 2) ++ _ = bfslices.Filter(filterInput, func(n int) bool { return n > 1 }) ++ _ = bfslices.ParallelFilter(filterInput, func(n int) bool { return n < 4 }, 2) ++ bfslices.ForEach(foreachInput, func(_ int, _ string) {}) ++ bfslices.ParallelForEach(foreachInput, func(_ int, _ string) {}, 2) ++ ++ if !stdslices.Equal(mapInput, mapOriginal) { ++ t.Fatalf("map input mutated to %#v, want %#v", mapInput, mapOriginal) ++ } ++ if !stdslices.Equal(filterInput, filterOriginal) { ++ t.Fatalf("filter input mutated to %#v, want %#v", filterInput, filterOriginal) ++ } ++ if !stdslices.Equal(foreachInput, foreachOriginal) { ++ t.Fatalf("foreach input mutated to %#v, want %#v", foreachInput, foreachOriginal) ++ } ++} ++ ++func TestHelpersHaveNoInProcessGlobalStateDependency(t *testing.T) { ++ firstMap := bfslices.ParallelMap([]int{2, 3, 4}, func(n int) int { ++ return n * n ++ }, 2) ++ noiseMap := bfslices.Map([]int{10, 11}, func(n int) int { ++ return -n ++ }) ++ noiseFilter := bfslices.ParallelFilter([]int{7, 8, 9}, func(n int) bool { ++ return n != 8 ++ }, 1) ++ var noiseVisits []intVisit ++ bfslices.ForEach([]int{40, 50}, func(i int, v int) { ++ noiseVisits = append(noiseVisits, intVisit{Index: i, Value: v}) ++ }) ++ var parallelNoiseMu sync.Mutex ++ parallelNoiseVisits := map[int]string{} ++ bfslices.ParallelForEach([]string{"q", "r"}, func(i int, v string) { ++ parallelNoiseMu.Lock() ++ parallelNoiseVisits[i] = v ++ parallelNoiseMu.Unlock() ++ }, 2) ++ secondMap := bfslices.ParallelMap([]int{2, 3, 4}, func(n int) int { ++ return n * n ++ }, 2) ++ ++ if !stdslices.Equal(firstMap, []int{4, 9, 16}) { ++ t.Fatalf("first ParallelMap result = %#v, want %#v", firstMap, []int{4, 9, 16}) ++ } ++ if !stdslices.Equal(noiseMap, []int{-10, -11}) { ++ t.Fatalf("noise Map result = %#v, want %#v", noiseMap, []int{-10, -11}) ++ } ++ if !stdslices.Equal(noiseFilter, []int{7, 9}) { ++ t.Fatalf("noise ParallelFilter result = %#v, want %#v", noiseFilter, []int{7, 9}) ++ } ++ if !reflect.DeepEqual(noiseVisits, []intVisit{{Index: 0, Value: 40}, {Index: 1, Value: 50}}) { ++ t.Fatalf("noise ForEach visits = %#v, want %#v", noiseVisits, []intVisit{{Index: 0, Value: 40}, {Index: 1, Value: 50}}) ++ } ++ if !reflect.DeepEqual(parallelNoiseVisits, map[int]string{0: "q", 1: "r"}) { ++ t.Fatalf("noise ParallelForEach visits = %#v, want %#v", parallelNoiseVisits, map[int]string{0: "q", 1: "r"}) ++ } ++ if !stdslices.Equal(secondMap, []int{4, 9, 16}) { ++ t.Fatalf("second ParallelMap result after noise = %#v, want %#v", secondMap, []int{4, 9, 16}) ++ } ++} ++ ++func TestHelpersDoNotCreateRelativeFilesystemSideEffectsOrMutateGOMAXPROCS(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 temp failed: %v", err) ++ } ++ defer func() { ++ if err := os.Chdir(oldWd); err != nil { ++ t.Fatalf("restore cwd failed: %v", err) ++ } ++ }() ++ ++ beforeFiles := snapshotFiles(t, tmp) ++ beforeProcs := runtime.GOMAXPROCS(0) ++ ++ _ = bfslices.Map([]int{1, 2}, func(n int) int { return n + 1 }) ++ _ = bfslices.ParallelMap([]int{1, 2}, func(n int) int { return n + 2 }, 2) ++ _ = bfslices.Filter([]int{1, 2, 3}, func(n int) bool { return n > 1 }) ++ _ = bfslices.ParallelFilter([]int{1, 2, 3}, func(n int) bool { return n < 3 }, 2) ++ bfslices.ForEach([]int{1, 2}, func(_ int, _ int) {}) ++ bfslices.ParallelForEach([]int{1, 2}, func(_ int, _ int) {}, 2) ++ ++ afterFiles := snapshotFiles(t, tmp) ++ afterProcs := runtime.GOMAXPROCS(0) ++ ++ if !reflect.DeepEqual(beforeFiles, []string{}) { ++ t.Fatalf("initial cwd snapshot = %#v, want %#v", beforeFiles, []string{}) ++ } ++ if !reflect.DeepEqual(afterFiles, []string{}) { ++ t.Fatalf("final cwd snapshot = %#v, want %#v", afterFiles, []string{}) ++ } ++ if afterProcs != beforeProcs { ++ t.Fatalf("GOMAXPROCS after helper calls = %d, want %d", afterProcs, beforeProcs) ++ } ++} ++ ++func expectPanicValue(t *testing.T, expected callbackPanic, fn func()) { ++ t.Helper() ++ defer func() { ++ actual := recover() ++ if actual != expected { ++ t.Fatalf("recovered panic = %#v, want %#v", actual, expected) ++ } ++ }() ++ fn() ++ t.Fatalf("callback did not panic; want %#v", expected) ++} ++ ++func runParallelPanicMode(mode string) { ++ switch mode { ++ case "map": ++ _ = bfslices.ParallelMap([]int{1, 2}, func(int) int { ++ panic("parallel-map-boom") ++ }, 2) ++ case "filter": ++ _ = bfslices.ParallelFilter([]int{1, 2}, func(int) bool { ++ panic("parallel-filter-boom") ++ }, 2) ++ case "foreach": ++ bfslices.ParallelForEach([]int{1, 2}, func(int, int) { ++ panic("parallel-foreach-boom") ++ }, 2) ++ default: ++ panic("unknown parallel panic mode") ++ } ++} ++ ++func parallelMapWithObservedConcurrency(t *testing.T, input []int, target int64, workers []int) ([]int, int64) { ++ t.Helper() ++ recorder := newConcurrencyRecorder(target) ++ actual := bfslices.ParallelMap(input, func(n int) int { ++ recorder.enter() ++ return n * n ++ }, workers...) ++ return actual, recorder.max() ++} ++ ++func parallelFilterWithObservedConcurrency(t *testing.T, input []int, target int64, workers []int) ([]int, int64) { ++ t.Helper() ++ recorder := newConcurrencyRecorder(target) ++ actual := bfslices.ParallelFilter(input, func(n int) bool { ++ recorder.enter() ++ return n > 2 ++ }, workers...) ++ return actual, recorder.max() ++} ++ ++func parallelForEachWithObservedConcurrency(t *testing.T, input []string, target int64, workers []int) (map[int]string, int64) { ++ t.Helper() ++ recorder := newConcurrencyRecorder(target) ++ var mu sync.Mutex ++ actual := map[int]string{} ++ bfslices.ParallelForEach(input, func(i int, v string) { ++ recorder.enter() ++ mu.Lock() ++ actual[i] = v ++ mu.Unlock() ++ }, workers...) ++ return actual, recorder.max() ++} ++ ++type concurrencyRecorder struct { ++ active atomic.Int64 ++ peak atomic.Int64 ++ target int64 ++ release chan struct{} ++ once sync.Once ++} ++ ++func newConcurrencyRecorder(target int64) *concurrencyRecorder { ++ return &concurrencyRecorder{ ++ target: target, ++ release: make(chan struct{}), ++ } ++} ++ ++func (r *concurrencyRecorder) enter() { ++ current := r.active.Add(1) ++ for { ++ peak := r.peak.Load() ++ if current <= peak || r.peak.CompareAndSwap(peak, current) { ++ break ++ } ++ } ++ if current >= r.target { ++ r.once.Do(func() { close(r.release) }) ++ } ++ select { ++ case <-r.release: ++ case <-time.After(500 * time.Millisecond): ++ r.once.Do(func() { close(r.release) }) ++ } ++ r.active.Add(-1) ++} ++ ++func (r *concurrencyRecorder) max() int64 { ++ return r.peak.Load() ++} ++ ++func snapshotFiles(t *testing.T, root string) []string { ++ t.Helper() ++ files := []string{} ++ if err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error { ++ if err != nil { ++ return err ++ } ++ if path == root { ++ return nil ++ } ++ rel, err := filepath.Rel(root, path) ++ if err != nil { ++ return err ++ } ++ if d.IsDir() { ++ files = append(files, rel+"/") ++ return nil ++ } ++ files = append(files, rel) ++ return nil ++ }); err != nil { ++ t.Fatalf("WalkDir failed: %v", err) ++ } ++ stdslices.Sort(files) ++ 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,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 GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002358/tests/test.sh b/tasks/format-code-task-002358/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0bd29bde1bd888f569a3f1a6863689777d85184 --- /dev/null +++ b/tasks/format-code-task-002358/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/slice_helpers_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-002358/tests/test_command.sh b/tasks/format-code-task-002358/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002358/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-002359/environment/Dockerfile b/tasks/format-code-task-002359/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..482a7228211ed5afd9ce92e81a7bd1bfa5d4894e --- /dev/null +++ b/tasks/format-code-task-002359/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:00e54dd42441f6f13dc19de052455ddcfa4f267c19de211152828730ea67ce80 diff --git a/tasks/format-code-task-002359/environment/setup/files/blocklist b/tasks/format-code-task-002359/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002359/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002359/environment/setup/setup.sh b/tasks/format-code-task-002359/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002359/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002359/tests/test.patch b/tasks/format-code-task-002359/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..94ba4ddabe6fcc6732f9dba96154f1d0e4c3ca10 --- /dev/null +++ b/tasks/format-code-task-002359/tests/test.patch @@ -0,0 +1,119 @@ +diff --git a/psychopy/tests/test_misc/test_event.py b/psychopy/tests/test_misc/test_event.py +index 565cfa0f46..b0e664fb6c 100644 +--- a/psychopy/tests/test_misc/test_event.py ++++ b/psychopy/tests/test_misc/test_event.py +@@ -24,14 +24,37 @@ + + travis = bool(str(os.environ.get('TRAVIS')).lower() == 'true') + +-class DelayedFakeKey(threading.Thread): +- def __init__(self, key, delay=.01): ++ ++class DelayedFakeKeys(threading.Thread): ++ def __init__(self, keys, modifiers=0, delay=.01): ++ threading.Thread.__init__(self, None, 'fake key', None) ++ if isinstance(keys, (str, unicode)): ++ self.keys = [keys] ++ else: ++ self.keys = keys ++ self.modifiers = modifiers ++ self.delay = delay ++ ++ def run(self): ++ core.wait(self.delay) ++ [event._onPygletKey(key, modifiers=self.modifiers, emulated=True) ++ for key in self.keys] ++ ++ ++class DelayedAddFakeKeysToBuffer(threading.Thread): ++ def __init__(self, keys, modifiers=0, delay=.01): + threading.Thread.__init__(self, None, 'fake key', None) +- self.key = key ++ if isinstance(keys, (str, unicode)): ++ self.keys = [keys] ++ else: ++ self.keys = keys ++ self.modifiers = modifiers + self.delay = delay ++ + def run(self): + core.wait(self.delay) +- event._onPygletKey(symbol=self.key, modifiers=0, emulated=True) ++ fake_events = [(key, self.modifiers, -1) for key in self.keys] ++ event._keyBuffer.extend(fake_events) + + class _baseTest(object): + #this class allows others to be created that inherit all the tests for +@@ -135,22 +158,48 @@ def test_keys(self): + + # waitKeys implicitly clears events, so use a thread to add a delayed key press + assert event.waitKeys(maxWait=-1) is None +- keyThread = DelayedFakeKey(k) ++ keyThread = DelayedFakeKeys(k) + keyThread.start() + assert event.waitKeys(maxWait=.1) == [k] +- keyThread = DelayedFakeKey(k) ++ keyThread = DelayedFakeKeys(k) + keyThread.start() + assert event.waitKeys(maxWait=.1, keyList=[k]) == [k] + + # test time-stamped waitKeys + c = core.Clock() + delay=0.01 +- keyThread = DelayedFakeKey(k, delay=delay) ++ keyThread = DelayedFakeKeys(k, delay=delay) + keyThread.start() + result = event.waitKeys(maxWait=.1, keyList=[k], timeStamped=c) + assert result[0][0] == k + assert result[0][1] - delay < .01 # should be ~0 except for execution time + ++ def test_waitKeys_clearEvents_True(self): ++ key = 'x' ++ DelayedAddFakeKeysToBuffer(key).start() ++ key_events = event.waitKeys(clearEvents=True) ++ assert key_events == [key] ++ ++ def test_waitKeys_clearEvents_False(self): ++ keys = ['x', 'y', 'z'] ++ [event._onPygletKey(symbol=key, modifiers=0, emulated=True) ++ for key in keys] ++ ++ key_events = event.waitKeys(keyList=keys[1:], clearEvents=False) ++ assert 'x' not in key_events ++ assert 'y' in key_events ++ assert 'z' in key_events ++ ++ def test_waitKeys_keyList_clearEvents_True(self): ++ keys = ['x', 'y', 'z'] ++ DelayedAddFakeKeysToBuffer(keys).start() ++ key_events = event.waitKeys(keyList=keys[:-1], clearEvents=True) ++ ++ assert 'x' in key_events ++ assert 'y' in key_events ++ assert 'z' not in key_events ++ assert 'z' in event.getKeys() ++ + def test_xydist(self): + assert event.xydist([0,0], [1,1]) == np.sqrt(2) + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3ST0vDMBgG8J77Kd6Tt9YkW7uTguDQwVBBYXgq/RPpYE1Ck5b12xs7UBF0l42h ++Pr/L+9Im6VuexEW33lSZVP15cCzMmyXJWL2vdex5IrgQfhX3zzlPGQ8oOdpEn3TW5S1R0Grtflq3 ++7/0vFX/k76R1WambJldVbOvDfWNf/jydvec/ZROf/zQVIiB2uBG+98/zLysagy9kFcqt0a2jh+eb ++5fwpe7y9ur5fZavFnS8XLNz2L0XUdoqinMzgaq0mFDVvrd9Oxg5lrc0wHmZ3d6lZ23LXyV4qF5uB ++op7E5RkPT/3bAAAAAAAAAAAAAAAAAAAAAAB/wiv4n3njACgAAA== +diff --git 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-002359/tests/test.sh b/tasks/format-code-task-002359/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..456dee151638c04e027cf3d6aa6dcd7476e6b67a --- /dev/null +++ b/tasks/format-code-task-002359/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' +psychopy/tests/test_misc/test_event.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002359/tests/test_command.sh b/tasks/format-code-task-002359/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002359/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002360/environment/Dockerfile b/tasks/format-code-task-002360/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1e4f7c95e3d84589dfee9e8c4a09a0023797723a --- /dev/null +++ b/tasks/format-code-task-002360/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d73efe0f73ead7f09a2b3739404611e74a9e2cc38a9e3624c839c135a95b3285 diff --git a/tasks/format-code-task-002360/environment/setup/files/blocklist b/tasks/format-code-task-002360/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002360/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002360/environment/setup/setup.sh b/tasks/format-code-task-002360/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002360/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002360/tests/test.patch b/tasks/format-code-task-002360/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ae25e8d74ac7185e57c9cd0c936338b8580d113c --- /dev/null +++ b/tasks/format-code-task-002360/tests/test.patch @@ -0,0 +1,398 @@ +diff --git a/sdk/go/property/values_contract_test.go b/sdk/go/property/values_contract_test.go +new file mode 100644 +index 0000000000..2e0b7b1556 +--- /dev/null ++++ b/sdk/go/property/values_contract_test.go +@@ -0,0 +1,363 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package property_test ++ ++import ( ++ "reflect" ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ ++ "github.com/pulumi/pulumi/sdk/v3/go/common/resource/archive" ++ "github.com/pulumi/pulumi/sdk/v3/go/common/resource/asset" ++ "github.com/pulumi/pulumi/sdk/v3/go/common/resource/urn" ++ "github.com/pulumi/pulumi/sdk/v3/go/property" ++) ++ ++func mustAsset(t *testing.T, text string) *asset.Asset { ++ t.Helper() ++ a, err := asset.FromText(text) ++ require.NoError(t, err) ++ return a ++} ++ ++func mustArchive(t *testing.T, name, text string) *archive.Archive { ++ t.Helper() ++ a, err := archive.FromAssets(map[string]interface{}{name: mustAsset(t, text)}) ++ require.NoError(t, err) ++ return a ++} ++ ++func TestZeroValueIsNull(t *testing.T) { ++ t.Parallel() ++ ++ var zero property.Value ++ assert.True(t, zero.IsNull()) ++ assert.True(t, property.New(property.Null).IsNull()) ++ assert.True(t, property.New(property.Null).Equals(zero)) ++ assert.True(t, zero.Equals(property.New(property.Null))) ++} ++ ++func TestNilNormalization(t *testing.T) { ++ t.Parallel() ++ ++ var zero property.Value ++ ++ t.Run("array", func(t *testing.T) { ++ t.Parallel() ++ v := property.New(property.Array(nil)) ++ assert.True(t, v.IsNull()) ++ assert.False(t, v.IsArray()) ++ assert.True(t, v.Equals(zero)) ++ ++ ++ assert.True(t, property.New(property.Array{}).IsArray()) ++ assert.False(t, property.New(property.Array{}).IsNull()) ++ }) ++ ++ t.Run("map", func(t *testing.T) { ++ t.Parallel() ++ v := property.New(property.Map(nil)) ++ assert.True(t, v.IsNull()) ++ assert.False(t, v.IsMap()) ++ ++ assert.True(t, property.New(property.Map{}).IsMap()) ++ assert.False(t, property.New(property.Map{}).IsNull()) ++ }) ++ ++ t.Run("asset", func(t *testing.T) { ++ t.Parallel() ++ v := property.New((*asset.Asset)(nil)) ++ assert.True(t, v.IsNull()) ++ assert.False(t, v.IsAsset()) ++ }) ++ ++ t.Run("archive", func(t *testing.T) { ++ t.Parallel() ++ v := property.New((*archive.Archive)(nil)) ++ assert.True(t, v.IsNull()) ++ assert.False(t, v.IsArchive()) ++ }) ++} ++ ++func TestPrimitiveContent(t *testing.T) { ++ t.Parallel() ++ ++ b := property.New(true) ++ assert.True(t, b.IsBool()) ++ assert.Equal(t, true, b.AsBool()) ++ assert.False(t, b.IsNumber()) ++ assert.False(t, b.IsString()) ++ assert.False(t, b.IsNull()) ++ ++ n := property.New(3.5) ++ assert.True(t, n.IsNumber()) ++ assert.Equal(t, 3.5, n.AsNumber()) ++ assert.False(t, n.IsBool()) ++ ++ s := property.New("hello") ++ assert.True(t, s.IsString()) ++ assert.Equal(t, "hello", s.AsString()) ++ assert.False(t, s.IsNumber()) ++} ++ ++func TestArrayContent(t *testing.T) { ++ t.Parallel() ++ ++ v := property.New(property.Array{property.New("a"), property.New(true)}) ++ assert.True(t, v.IsArray()) ++ arr := v.AsArray() ++ require.Len(t, arr, 2) ++ assert.Equal(t, "a", arr[0].AsString()) ++ assert.Equal(t, true, arr[1].AsBool()) ++} ++ ++func TestMapContent(t *testing.T) { ++ t.Parallel() ++ ++ v := property.New(property.Map{"k": property.New(1.0)}) ++ assert.True(t, v.IsMap()) ++ m := v.AsMap() ++ require.Contains(t, m, property.MapKey("k")) ++ assert.Equal(t, 1.0, m["k"].AsNumber()) ++} ++ ++func TestAssetContent(t *testing.T) { ++ t.Parallel() ++ ++ a := mustAsset(t, "some text") ++ v := property.New(a) ++ assert.True(t, v.IsAsset()) ++ assert.True(t, v.AsAsset().Equals(a)) ++ assert.False(t, v.IsArchive()) ++} ++ ++func TestArchiveContent(t *testing.T) { ++ t.Parallel() ++ ++ a := mustArchive(t, "f.txt", "some text") ++ v := property.New(a) ++ assert.True(t, v.IsArchive()) ++ assert.True(t, v.AsArchive().Equals(a)) ++ assert.False(t, v.IsAsset()) ++} ++ ++func TestComputedContent(t *testing.T) { ++ t.Parallel() ++ ++ v := property.New(property.Computed) ++ assert.True(t, v.IsComputed()) ++ assert.False(t, v.IsNull()) ++ assert.False(t, v.IsString()) ++ assert.True(t, v.HasComputed()) ++} ++ ++func TestResourceReferenceContent(t *testing.T) { ++ t.Parallel() ++ ++ ref := property.ResourceReference{ ++ URN: urn.URN("urn:pulumi:stack::proj::type::name"), ++ ID: property.New("id-1"), ++ PackageVersion: "1.2.3", ++ } ++ v := property.New(ref) ++ assert.True(t, v.IsResourceReference()) ++ got := v.AsResourceReference() ++ assert.Equal(t, urn.URN("urn:pulumi:stack::proj::type::name"), got.URN) ++ assert.Equal(t, "1.2.3", got.PackageVersion) ++ assert.Equal(t, "id-1", got.ID.AsString()) ++} ++ ++func TestNotComparable(t *testing.T) { ++ t.Parallel() ++ assert.False(t, reflect.TypeOf(property.Value{}).Comparable()) ++} ++ ++func TestImmutability(t *testing.T) { ++ t.Parallel() ++ ++ base := property.New("a") ++ ++ secret := base.WithSecret(true) ++ assert.True(t, secret.Secret()) ++ assert.False(t, base.Secret(), "WithSecret must not mutate the receiver") ++ ++ deps := []urn.URN{"urn:a"} ++ withDeps := base.WithDependencies(deps) ++ assert.Equal(t, deps, withDeps.Dependencies()) ++ assert.Empty(t, base.Dependencies(), "WithDependencies must not mutate the receiver") ++} ++ ++func TestSecretReportingIsShallow(t *testing.T) { ++ t.Parallel() ++ ++ assert.False(t, property.New("a").Secret()) ++ assert.False(t, property.New("a").HasSecrets()) ++ ++ leafSecret := property.New("a").WithSecret(true) ++ assert.True(t, leafSecret.Secret()) ++ assert.True(t, leafSecret.HasSecrets()) ++ ++ nestedInArray := property.New(property.Array{leafSecret}) ++ assert.False(t, nestedInArray.Secret(), "Secret() must not look inside nested values") ++ assert.True(t, nestedInArray.HasSecrets()) ++ ++ nestedInMap := property.New(property.Map{"k": leafSecret}) ++ assert.False(t, nestedInMap.Secret()) ++ assert.True(t, nestedInMap.HasSecrets()) ++} ++ ++func TestComputedReporting(t *testing.T) { ++ t.Parallel() ++ ++ assert.False(t, property.New("a").HasComputed()) ++ assert.True(t, property.New(property.Array{property.New(property.Computed)}).HasComputed()) ++ assert.True(t, property.New(property.Map{"k": property.New(property.Computed)}).HasComputed()) ++} ++ ++func TestEqualsContent(t *testing.T) { ++ t.Parallel() ++ ++ assert.True(t, property.New("a").Equals(property.New("a"))) ++ assert.False(t, property.New("a").Equals(property.New("b"))) ++ ++ assert.True(t, property.New(1.0).Equals(property.New(1.0))) ++ assert.False(t, property.New(1.0).Equals(property.New(2.0))) ++ ++ assert.True(t, property.New(true).Equals(property.New(true))) ++ assert.False(t, property.New(true).Equals(property.New(false))) ++ ++ ++ assert.False(t, property.New("a").Equals(property.New(1.0))) ++ assert.False(t, property.New(true).Equals(property.New("true"))) ++ assert.False(t, property.New(property.Null).Equals(property.New("a"))) ++} ++ ++func TestEqualsSecretSensitive(t *testing.T) { ++ t.Parallel() ++ ++ a := property.New("a") ++ assert.False(t, a.WithSecret(true).Equals(a)) ++ assert.False(t, a.Equals(a.WithSecret(true))) ++ assert.True(t, a.WithSecret(true).Equals(a.WithSecret(true))) ++} ++ ++func TestEqualsDependencySensitive(t *testing.T) { ++ t.Parallel() ++ ++ a := property.New("a") ++ assert.False(t, a.WithDependencies([]urn.URN{"u1"}).Equals(a)) ++ assert.True(t, ++ a.WithDependencies([]urn.URN{"u1", "u2"}).Equals(a.WithDependencies([]urn.URN{"u1", "u2"}))) ++ ++ assert.False(t, ++ a.WithDependencies([]urn.URN{"u1", "u2"}).Equals(a.WithDependencies([]urn.URN{"u2", "u1"}))) ++} ++ ++func TestEqualsArrays(t *testing.T) { ++ t.Parallel() ++ ++ mk := func(elems ...property.Value) property.Value { return property.New(property.Array(elems)) } ++ ++ assert.True(t, mk(property.New("a"), property.New(1.0)).Equals(mk(property.New("a"), property.New(1.0)))) ++ assert.False(t, mk(property.New("a")).Equals(mk(property.New("a"), property.New(1.0)))) ++ assert.False(t, mk(property.New("a")).Equals(mk(property.New("b")))) ++ ++ ++ assert.False(t, mk(property.New("a").WithSecret(true)).Equals(mk(property.New("a")))) ++} ++ ++func TestEqualsMaps(t *testing.T) { ++ t.Parallel() ++ ++ m := func(kv property.Map) property.Value { return property.New(kv) } ++ ++ assert.True(t, m(property.Map{"a": property.New(1.0)}).Equals(m(property.Map{"a": property.New(1.0)}))) ++ assert.False(t, m(property.Map{"a": property.New(1.0)}).Equals(m(property.Map{"a": property.New(2.0)}))) ++ ++ assert.False(t, m(property.Map{"a": property.New(1.0)}).Equals(m(property.Map{"b": property.New(1.0)}))) ++ assert.False(t, ++ m(property.Map{"a": property.New(1.0)}).Equals(m(property.Map{"a": property.New(1.0), "b": property.New(2.0)}))) ++} ++ ++func TestEqualsComputedDefault(t *testing.T) { ++ t.Parallel() ++ ++ c := property.New(property.Computed) ++ assert.True(t, c.Equals(property.New(property.Computed))) ++ assert.False(t, c.Equals(property.New("a"))) ++ assert.False(t, property.New("a").Equals(c)) ++ assert.False(t, c.Equals(property.New(property.Null))) ++} ++ ++func TestEqualsRelaxComputed(t *testing.T) { ++ t.Parallel() ++ ++ c := property.New(property.Computed) ++ assert.True(t, c.Equals(property.New("a"), property.EqualRelaxComputed)) ++ assert.True(t, property.New("a").Equals(c, property.EqualRelaxComputed)) ++ assert.True(t, c.Equals(property.New(property.Computed), property.EqualRelaxComputed)) ++ ++ ++ assert.False(t, c.WithSecret(true).Equals(property.New("a"), property.EqualRelaxComputed)) ++ ++ ++ relaxed := property.New(property.Array{property.New(property.Computed)}) ++ concrete := property.New(property.Array{property.New("a")}) ++ assert.False(t, relaxed.Equals(concrete)) ++ assert.True(t, relaxed.Equals(concrete, property.EqualRelaxComputed)) ++} ++ ++func TestEqualsAssetsAndArchives(t *testing.T) { ++ t.Parallel() ++ ++ a1 := property.New(mustAsset(t, "a")) ++ a2 := property.New(mustAsset(t, "a")) ++ a3 := property.New(mustAsset(t, "b")) ++ assert.True(t, a1.Equals(a2)) ++ assert.False(t, a1.Equals(a3)) ++ ++ r1 := property.New(mustArchive(t, "f", "a")) ++ r2 := property.New(mustArchive(t, "f", "a")) ++ r3 := property.New(mustArchive(t, "f", "b")) ++ assert.True(t, r1.Equals(r2)) ++ assert.False(t, r1.Equals(r3)) ++ ++ ++ assert.False(t, a1.Equals(r1)) ++} ++ ++func TestEqualsResourceReferences(t *testing.T) { ++ t.Parallel() ++ ++ mkRef := func(u urn.URN, id property.Value, version string) property.Value { ++ return property.New(property.ResourceReference{URN: u, ID: id, PackageVersion: version}) ++ } ++ ++ base := mkRef("urn:a", property.New("id-1"), "1.0.0") ++ ++ assert.True(t, base.Equals(mkRef("urn:a", property.New("id-1"), "1.0.0"))) ++ assert.False(t, base.Equals(mkRef("urn:b", property.New("id-1"), "1.0.0"))) ++ assert.False(t, base.Equals(mkRef("urn:a", property.New("id-2"), "1.0.0"))) ++ assert.False(t, base.Equals(mkRef("urn:a", property.New("id-1"), "2.0.0"))) ++ ++ ++ computedID := mkRef("urn:a", property.New(property.Computed), "1.0.0") ++ assert.True(t, computedID.Equals(base)) ++ assert.True(t, base.Equals(computedID)) ++ ++ assert.False(t, computedID.Equals(mkRef("urn:b", property.New("id-1"), "1.0.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,24 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++unset GOROOT ++cd /testbed/sdk ++ ++ ++go test ./go/common/resource/ ./go/common/resource/archive/ ./go/common/resource/urn/ -count=1 ++ ++ ++go test ./go/property/ -count=1 diff --git a/tasks/format-code-task-002360/tests/test.sh b/tasks/format-code-task-002360/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d8c7163867978e344e5b74522998baa4a642797 --- /dev/null +++ b/tasks/format-code-task-002360/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' +sdk/go/property/values_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-002360/tests/test_command.sh b/tasks/format-code-task-002360/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002360/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002366/environment/Dockerfile b/tasks/format-code-task-002366/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7ca36bb5bf62428d1d728b767199332002a85137 --- /dev/null +++ b/tasks/format-code-task-002366/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:330db7caf388582fb608516a80c05fa1f1440186579043dc74df9b5eedf0dd6e diff --git a/tasks/format-code-task-002366/environment/setup/files/blocklist b/tasks/format-code-task-002366/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002366/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002366/environment/setup/setup.sh b/tasks/format-code-task-002366/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002366/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002366/tests/test.patch b/tasks/format-code-task-002366/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9ac7d70dccbc28e57f3ccdf32bf248b951e7ace9 --- /dev/null +++ b/tasks/format-code-task-002366/tests/test.patch @@ -0,0 +1,100 @@ +diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py +index c98c201..4170ae9 100644 +--- a/pvlib/tests/test_pvsystem.py ++++ b/pvlib/tests/test_pvsystem.py +@@ -2059,6 +2059,73 @@ def test_Array_get_irradiance(solar_pos): + assert_series_equal(expected, expected, check_less_precise=5) + + ++def test_PVSystem_get_irradiance_float_zenith_reproduction(): ++ ++ ++ test_sys = pvsystem.PVSystem() ++ result = test_sys.get_irradiance(0.0, 0.0, 0.0, 0.0, 0.0) ++ ++ for key in ('poa_global', 'poa_direct', 'poa_diffuse', ++ 'poa_sky_diffuse', 'poa_ground_diffuse'): ++ assert result[key] == 0.0 ++ ++ ++def test_PVSystem_get_irradiance_float_zenith_nonzero(): ++ ++ ++ ++ ++ system = pvsystem.PVSystem(surface_tilt=30, surface_azimuth=180) ++ result_default = system.get_irradiance(30.0, 180.0, 800.0, 600.0, 100.0) ++ for key in ('poa_global', 'poa_direct', 'poa_diffuse', ++ 'poa_sky_diffuse', 'poa_ground_diffuse'): ++ assert np.isfinite(result_default[key]) ++ ++ assert result_default['poa_global'] > 0 ++ ++ ++def test_Array_get_irradiance_float_zenith(): ++ ++ ++ array = pvsystem.Array( ++ pvsystem.FixedMount(surface_tilt=30, surface_azimuth=180)) ++ result = array.get_irradiance(30.0, 180.0, 800.0, 600.0, 100.0) ++ for key in ('poa_global', 'poa_direct', 'poa_diffuse', ++ 'poa_sky_diffuse', 'poa_ground_diffuse'): ++ assert np.isfinite(result[key]) ++ ++ ++def test_Array_get_irradiance_float_zenith_default_dni_extra(): ++ ++ ++ ++ ++ ++ array = pvsystem.Array( ++ pvsystem.FixedMount(surface_tilt=30, surface_azimuth=180)) ++ result_default = array.get_irradiance(30.0, 180.0, 800.0, 600.0, 100.0) ++ result_explicit = array.get_irradiance( ++ 30.0, 180.0, 800.0, 600.0, 100.0, dni_extra=1367.0) ++ for key in ('poa_global', 'poa_direct', 'poa_diffuse', ++ 'poa_sky_diffuse', 'poa_ground_diffuse'): ++ ++ ++ assert np.isclose(result_default[key], result_explicit[key], ++ rtol=0.1, atol=10.0) ++ ++ ++def test_Array_get_irradiance_float_zenith_with_dni_extra(): ++ ++ ++ array = pvsystem.Array( ++ pvsystem.FixedMount(surface_tilt=30, surface_azimuth=180)) ++ result = array.get_irradiance( ++ 30.0, 180.0, 800.0, 600.0, 100.0, dni_extra=1400.0) ++ for key in ('poa_global', 'poa_direct', 'poa_diffuse', ++ 'poa_sky_diffuse', 'poa_ground_diffuse'): ++ assert np.isfinite(result[key]) ++ ++ + def test_PVSystem___repr__(): + system = pvsystem.PVSystem( + module='blah', inverter='blarg', name='pv ftw', +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..b78c420 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pvlib/tests/test_pvsystem.py -k float_zenith -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 pvlib/tests/test_pvsystem.py::test_PVSystem_get_irradiance_float_zenith_reproduction pvlib/tests/test_pvsystem.py::test_PVSystem_get_irradiance_float_zenith_nonzero pvlib/tests/test_pvsystem.py::test_Array_get_irradiance_float_zenith pvlib/tests/test_pvsystem.py::test_Array_get_irradiance_float_zenith_default_dni_extra pvlib/tests/test_pvsystem.py::test_Array_get_irradiance_float_zenith_with_dni_extra ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002366/tests/test.sh b/tasks/format-code-task-002366/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8c9ef4f7fb3777df69a65031af1397a259df853a --- /dev/null +++ b/tasks/format-code-task-002366/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' +pvlib/tests/test_pvsystem.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-002366/tests/test_command.sh b/tasks/format-code-task-002366/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002366/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002394/environment/Dockerfile b/tasks/format-code-task-002394/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9cd7c83aaee0d876f01e595f0b76f8ae0d20d9c8 --- /dev/null +++ b/tasks/format-code-task-002394/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:06ee446d80acabd755bc1d2f12b04f6e28b013c6240fa7efe761bd6b40c7c033 diff --git a/tasks/format-code-task-002394/environment/setup/files/blocklist b/tasks/format-code-task-002394/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002394/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002394/environment/setup/setup.sh b/tasks/format-code-task-002394/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002394/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002394/tests/test.patch b/tasks/format-code-task-002394/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b2e6eacb6a8521f10c4940f0f08260d418b1f7e3 --- /dev/null +++ b/tasks/format-code-task-002394/tests/test.patch @@ -0,0 +1,68 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..9ff2e37f4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/unit/email/test_init.py -k \"test_redact_ip_localhost_no_user_returns_true or test_redact_ip_non_localhost_no_user_returns_false\""] ++} +diff --git a/tests/unit/email/test_init.py b/tests/unit/email/test_init.py +index 677fc984b..e77bf74ac 100644 +--- a/tests/unit/email/test_init.py ++++ b/tests/unit/email/test_init.py +@@ -98,6 +98,41 @@ def test_redact_ip_email_not_found(): + assert email._redact_ip(request, "doesn't matter") is False + + ++def test_redact_ip_localhost_no_user_returns_true(): ++ ++ ++ ++ user_email = pretend.stub(user_id="the_users_id") ++ request = pretend.stub( ++ unauthenticated_userid=None, ++ user=None, ++ remote_addr="127.0.0.1", ++ db=pretend.stub( ++ query=lambda a: pretend.stub( ++ filter=lambda a: pretend.stub(one=lambda: user_email) ++ ) ++ ), ++ ) ++ assert email._redact_ip(request, "anything") is True ++ ++ ++def test_redact_ip_non_localhost_no_user_returns_false(): ++ ++ ++ user_email = pretend.stub(user_id="the_users_id") ++ request = pretend.stub( ++ unauthenticated_userid=None, ++ user=None, ++ remote_addr="8.8.8.8", ++ db=pretend.stub( ++ query=lambda a: pretend.stub( ++ filter=lambda a: pretend.stub(one=lambda: user_email) ++ ) ++ ), ++ ) ++ assert email._redact_ip(request, "anything") is False ++ ++ + class TestSendEmailToUser: + @pytest.mark.parametrize( + ("name", "username", "primary_email", "address", "expected"), +diff --git 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 tests/unit/email/test_init.py::test_redact_ip_localhost_no_user_returns_true tests/unit/email/test_init.py::test_redact_ip_non_localhost_no_user_returns_false ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002394/tests/test.sh b/tasks/format-code-task-002394/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ef2768441c1fb058759e3e0b9f5b7bc860c59363 --- /dev/null +++ b/tasks/format-code-task-002394/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/unit/email/test_init.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002394/tests/test_command.sh b/tasks/format-code-task-002394/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002394/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002500/environment/Dockerfile b/tasks/format-code-task-002500/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..601fadeec1bd2b7820bcef57bef476a87e93dba2 --- /dev/null +++ b/tasks/format-code-task-002500/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2bdea960faac2ed59d0fede20d3c5dba89a3637a13ae317ebafefbf9e54f380d diff --git a/tasks/format-code-task-002500/environment/setup/files/blocklist b/tasks/format-code-task-002500/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002500/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002500/environment/setup/setup.sh b/tasks/format-code-task-002500/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002500/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002500/tests/test.patch b/tasks/format-code-task-002500/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ca7870b10b1025935a3d9e7efec7a9290dcd772 --- /dev/null +++ b/tasks/format-code-task-002500/tests/test.patch @@ -0,0 +1,189 @@ +diff --git a/RealmSwift/Tests/ObjectCreationTests.swift b/RealmSwift/Tests/ObjectCreationTests.swift +index 4963f306bb..5be1769644 100644 +--- a/RealmSwift/Tests/ObjectCreationTests.swift ++++ b/RealmSwift/Tests/ObjectCreationTests.swift +@@ -115,6 +115,41 @@ class ObjectCreationTests: TestCase { + let valueDict = defaultSwiftObjectValuesWithReplacements(["intCol": 200]) + verifySwiftObjectWithDictionaryLiteral(objectWithKVCObject, dictionary: valueDict, boolObjectValue: false, boolObjectListValues: []) + } ++ ++ func testGenericInit() { ++ final class GenericDefaultObject: Object { ++ dynamic var intValue = 7 ++ dynamic var stringValue = "realm" ++ } ++ ++ final class GenericTokenObject: Object { ++ dynamic var token = "seed" ++ ++ required init() { ++ super.init() ++ } ++ ++ init(token: String) { ++ self.token = token ++ super.init() ++ } ++ } ++ ++ func createObject() -> T { ++ return T() ++ } ++ ++ let genericDefault: GenericDefaultObject = createObject() ++ let directDefault = GenericDefaultObject() ++ XCTAssertTrue(type(of: genericDefault) == GenericDefaultObject.self) ++ XCTAssertEqual(genericDefault.intValue, directDefault.intValue) ++ XCTAssertEqual(genericDefault.stringValue, directDefault.stringValue) ++ ++ let genericToken: GenericTokenObject = createObject() ++ let directToken = GenericTokenObject() ++ XCTAssertTrue(type(of: genericToken) == GenericTokenObject.self) ++ XCTAssertEqual(genericToken.token, directToken.token) ++ } + + // MARK: Creation tests + +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,138 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++ ++ ++write_base_probe() { ++ cat > /tmp/realm_fixturea_base_probe.swift <<'SWIFT' ++import Foundation ++ ++public class RLMObjectBase: NSObject { ++ public override init() { super.init() } ++} ++ ++public class Object: RLMObjectBase { ++ public required override init() { ++ super.init() ++ } ++} ++ ++final class ProbeObject: Object { ++ var value = 42 ++} ++ ++func createObject() -> T { return T() } ++let object: ProbeObject = createObject() ++precondition(type(of: object) == ProbeObject.self) ++precondition(object.value == ProbeObject().value) ++SWIFT ++} ++ ++extract_object_init_decl() { ++ ++ ++ awk ' ++ BEGIN { active = 1; depth = 0 } ++ /^[[:space:]]*#if[[:space:]]+/ { ++ depth++ ++ parent[depth] = active ++ cond[depth] = ($0 ~ /^[[:space:]]*#if[[:space:]]+true[[:space:]]*$/) ++ active = parent[depth] && cond[depth] ++ next ++ } ++ /^[[:space:]]*#else/ { ++ active = parent[depth] && !cond[depth] ++ next ++ } ++ /^[[:space:]]*#endif/ { ++ active = parent[depth] ++ delete parent[depth] ++ delete cond[depth] ++ depth-- ++ next ++ } ++ active && /override/ && /init[[:space:]]*\([[:space:]]*\)/ { ++ line = $0 ++ sub(/^[[:space:]]+/, "", line) ++ sub(/[[:space:]]*\{.*/, "", line) ++ print line ++ exit ++ } ++ ' RealmSwift/Object.swift ++} ++ ++write_new_probe() { ++ local init_decl="$1" ++ cat > /tmp/realm_fixturea_generic_init_probe.swift <() -> T { ++ return T() ++} ++ ++let genericDefault: GenericDefaultObject = createObject() ++let directDefault = GenericDefaultObject() ++precondition(type(of: genericDefault) == GenericDefaultObject.self) ++precondition(genericDefault.intValue == directDefault.intValue) ++precondition(genericDefault.stringValue == directDefault.stringValue) ++ ++let genericToken: GenericTokenObject = createObject() ++let directToken = GenericTokenObject() ++precondition(type(of: genericToken) == GenericTokenObject.self) ++precondition(genericToken.token == directToken.token) ++SWIFT ++} ++ ++case "${1:-}" in ++ base) ++ swift --version ++ write_base_probe ++ swift /tmp/realm_fixturea_base_probe.swift ++ ;; ++ new) ++ test -f RealmSwift/Object.swift ++ test -f RealmSwift/Tests/ObjectCreationTests.swift ++ grep -q 'func testGenericInit()' RealmSwift/Tests/ObjectCreationTests.swift ++ init_decl="$(extract_object_init_decl)" ++ if [ -z "$init_decl" ]; then ++ echo "Object no-argument initializer declaration not found" >&2 ++ exit 1 ++ fi ++ write_new_probe "$init_decl" ++ swift /tmp/realm_fixturea_generic_init_probe.swift ++ ;; ++ *) ++ echo "usage: $0 base|new" >&2 ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002500/tests/test.sh b/tasks/format-code-task-002500/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c8aa333a38b2a182039248e416a01f960ac3a237 --- /dev/null +++ b/tasks/format-code-task-002500/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' +RealmSwift/Tests/ObjectCreationTests.swift +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002500/tests/test_command.sh b/tasks/format-code-task-002500/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002500/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-002507/environment/Dockerfile b/tasks/format-code-task-002507/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8e91fec770e10a9bf5fe4170a3f1b5a9fd4c0b2e --- /dev/null +++ b/tasks/format-code-task-002507/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:06b300a9cf76f29f52e8065d8742a6a3d90edd7258382ba73ac3e8f34accb262 diff --git a/tasks/format-code-task-002507/environment/setup/files/blocklist b/tasks/format-code-task-002507/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002507/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002507/environment/setup/setup.sh b/tasks/format-code-task-002507/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002507/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002507/tests/test.patch b/tasks/format-code-task-002507/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b1e066c8ac7b356ad74cd2a1dc6a79312c4d0d1e --- /dev/null +++ b/tasks/format-code-task-002507/tests/test.patch @@ -0,0 +1,46 @@ +diff --git a/tests/units/test_state.py b/tests/units/test_state.py +index e4c7b51747f..8772c159283 100644 +--- a/tests/units/test_state.py ++++ b/tests/units/test_state.py +@@ -111,7 +111,7 @@ class TestState(BaseState): + key: str + map_key: str = "a" + array: list[float] = [1, 2, 3.14] +- mapping: dict[str, list[int]] = {"a": [1, 2, 3], "b": [4, 5, 6]} ++ mapping: rx.Field[dict[str, list[int]]] = rx.field({"a": [1, 2, 3], "b": [4, 5, 6]}) + obj: Object = Object() + complex: dict[int, Object] = {1: Object(), 2: Object()} + fig: Figure = Figure() +@@ -3869,6 +3869,12 @@ async def test_get_var_value(state_manager: StateManager, substate_token: str): + with pytest.raises(UnretrievableVarValueError): + await state.get_var_value(rx.Var("undefined")) + ++ ++ assert await state.get_var_value(TestState.mapping) == { ++ "a": [1, 2, 3], ++ "b": [4, 5, 6], ++ } ++ + + @pytest.mark.asyncio + async def test_async_computed_var_get_state(mock_app: rx.App, token: str): +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+3S3QqCMBQH8F37FCe6dh/q7HFCU1DIKW5KvX1T6IOgukmi+v8utgM7sLOdw/Oh ++3hfb0oyCLUV6G63n3bvf51jpSKlUSx3HTPpIRoz0YhXdGKzLeiLWt617lvfq/Evxa/9dad121zZN ++Zgpuq/fd8ar/Kk4u/U82Pk8laaQYyfeV8Nif93+9EnltRJ7ZKtgVNA9BXhbBORB8nGZjyumOrmoN ++hQ35yJ/StFgxmNqv8/D4r3Ql744UHigcg0+/DQAAAAAAAAAAAAAAAAAAAADg150AMoeyyAAoAAA= +diff --git 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-002507/tests/test.sh b/tasks/format-code-task-002507/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9220c88ea6ee6dcc1f7b630018655586f4274a2f --- /dev/null +++ b/tasks/format-code-task-002507/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/units/test_state.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-002507/tests/test_command.sh b/tasks/format-code-task-002507/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002507/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002508/environment/Dockerfile b/tasks/format-code-task-002508/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9ecafa30830b5106c474bb71d012b34cfb94f686 --- /dev/null +++ b/tasks/format-code-task-002508/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0bdfeaa152009a2a6bac3c9bc75eafd7f8723d9edcd0904c832a632d238261d4 diff --git a/tasks/format-code-task-002508/environment/setup/files/blocklist b/tasks/format-code-task-002508/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002508/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002508/environment/setup/setup.sh b/tasks/format-code-task-002508/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002508/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002508/tests/test.patch b/tasks/format-code-task-002508/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..55c6eb597f83a9eac40a1de98d8c23485dd84236 --- /dev/null +++ b/tasks/format-code-task-002508/tests/test.patch @@ -0,0 +1,190 @@ +diff --git a/unittests/test_amber_nve.py b/unittests/test_amber_nve.py +new file mode 100644 +index 000000000..a43645b88 +--- /dev/null ++++ b/unittests/test_amber_nve.py +@@ -0,0 +1,163 @@ ++ ++ ++ ++ ++ ++import os ++import pytest ++ ++import unittests.utility as test_util ++from reframe.core.exceptions import SanityError ++ ++from hpctestlib.apps.amber.nve import amber_nve_check ++ ++ ++ ++ ++BENCHMARKS = { ++ 'Cellulose_production_NVE': (-443246.0, 5.0E-05), ++ 'FactorIX_production_NVE': (-234188.0, 1.0E-04), ++ 'JAC_production_NVE_4fs': (-44810.0, 1.0E-03), ++ 'JAC_production_NVE': (-58138.0, 5.0E-04), ++} ++ ++ ++@pytest.fixture ++def generic_system(make_exec_ctx_g): ++ yield from make_exec_ctx_g(test_util.TEST_CONFIG_FILE, 'generic') ++ ++ ++@pytest.fixture ++def local_exec_ctx(generic_system): ++ partition = test_util.partition_by_name('default') ++ environ = test_util.environment_by_name('builtin', partition) ++ yield partition, environ ++ ++ ++def _all_variants(): ++ ++ class _T(amber_nve_check): ++ pass ++ ++ return [_T(_rfm_use_params=True) for _ in range(len(_T.param_space))] ++ ++ ++def _variant(benchmark, variant): ++ for t in _all_variants(): ++ if t.benchmark == benchmark and t.variant == variant: ++ t.num_tasks = 1 ++ t.valid_systems = ['*'] ++ t.valid_prog_environs = ['*'] ++ return t ++ ++ raise AssertionError(f'no variant for {benchmark!r}/{variant!r}') ++ ++ ++def _write_out(path, etot, perf=42.0, perf_info=True): ++ ++ ++ ++ lines = [ ++ " Etot = %s EKtot = 100.0" % etot, ++ " A V E R A G E S O V E R", ++ " Etot = %s EKtot = 100.0" % etot, ++ " R M S F L U C T U A T I O N S", ++ " Etot = %s EKtot = 100.0" % (etot + 123456.0), ++ ] ++ if perf_info: ++ lines += [ ++ "| Final Performance Info:", ++ "| ns/day = %s seconds/ns = 100.0" % perf, ++ "| ns/day = %s seconds/ns = 100.0" % perf, ++ ] ++ ++ with open(path, 'w') as f: ++ f.write("\n".join(lines) + "\n") ++ ++ ++def test_variant_count(generic_system): ++ insts = _all_variants() ++ assert len(insts) == 8 ++ keys = {(t.benchmark, t.variant) for t in insts} ++ expected = {(b, v) for b in BENCHMARKS for v in ('mpi', 'cuda')} ++ assert keys == expected ++ ++ ++def test_run_only(generic_system): ++ import reframe as rfm ++ assert issubclass(amber_nve_check, rfm.RunOnlyRegressionTest) ++ ++ ++def test_tags(generic_system): ++ for t in _all_variants(): ++ assert t.tags == {'sciapp', 'chemistry'} ++ ++ ++@pytest.mark.parametrize('benchmark', list(BENCHMARKS)) ++def test_variant_tooling(generic_system, benchmark): ++ mpi = _variant(benchmark, 'mpi') ++ assert mpi.executable == 'pmemd.MPI' ++ assert mpi.input_file == 'mdin.CPU' ++ assert mpi.output_file == 'amber.out' ++ assert mpi.executable_opts == ['-O', '-i', 'mdin.CPU', '-o', 'amber.out'] ++ ++ cuda = _variant(benchmark, 'cuda') ++ assert cuda.executable == 'pmemd.cuda.MPI' ++ assert cuda.input_file == 'mdin.GPU' ++ assert cuda.output_file == 'amber.out' ++ assert cuda.executable_opts == ['-O', '-i', 'mdin.GPU', '-o', 'amber.out'] ++ ++ ++def test_num_tasks_required(generic_system): ++ t = _all_variants()[0] ++ with pytest.raises(AttributeError): ++ t.num_tasks ++ ++ ++@pytest.mark.parametrize('benchmark', list(BENCHMARKS)) ++def test_sanity_within_tolerance(local_exec_ctx, benchmark): ++ part, env = local_exec_ctx ++ ref, tol = BENCHMARKS[benchmark] ++ t = _variant(benchmark, 'mpi') ++ t.setup(part, env) ++ ++ etot = ref + 0.4 * abs(ref * tol) ++ _write_out(os.path.join(t.stagedir, t.output_file), etot) ++ t.check_sanity() ++ ++ ++@pytest.mark.parametrize('benchmark', list(BENCHMARKS)) ++def test_sanity_outside_tolerance(local_exec_ctx, benchmark): ++ part, env = local_exec_ctx ++ ref, tol = BENCHMARKS[benchmark] ++ t = _variant(benchmark, 'mpi') ++ t.setup(part, env) ++ ++ etot = ref + 2.0 * abs(ref * tol) ++ _write_out(os.path.join(t.stagedir, t.output_file), etot) ++ with pytest.raises(SanityError): ++ t.check_sanity() ++ ++ ++def test_sanity_requires_performance_info(local_exec_ctx): ++ part, env = local_exec_ctx ++ ref, tol = BENCHMARKS['Cellulose_production_NVE'] ++ t = _variant('Cellulose_production_NVE', 'mpi') ++ t.setup(part, env) ++ ++ _write_out(os.path.join(t.stagedir, t.output_file), ref, perf_info=False) ++ with pytest.raises(SanityError): ++ t.check_sanity() ++ ++ ++def test_performance_metric(local_exec_ctx): ++ part, env = local_exec_ctx ++ ref, tol = BENCHMARKS['Cellulose_production_NVE'] ++ t = _variant('Cellulose_production_NVE', 'mpi') ++ t.setup(part, env) ++ _write_out(os.path.join(t.stagedir, t.output_file), ref, perf=37.5) ++ t.check_performance() ++ vals = dict(t.perfvalues) ++ assert vals, 'no performance variables were recorded' ++ assert any(abs(v[0] - 37.5) < 1e-6 and v[-1] == 'ns/day' ++ for v in vals.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 unittests/test_meta.py -q ++ ++ ++python -m pytest unittests/test_amber_nve.py -q diff --git a/tasks/format-code-task-002508/tests/test.sh b/tasks/format-code-task-002508/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ec458e7886b5612fb0e023c4a941f55d5243158 --- /dev/null +++ b/tasks/format-code-task-002508/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' +unittests/test_amber_nve.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-002508/tests/test_command.sh b/tasks/format-code-task-002508/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002508/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002509/environment/Dockerfile b/tasks/format-code-task-002509/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3f9c54c2c0440d246b944bd6f5be82b65e92be9c --- /dev/null +++ b/tasks/format-code-task-002509/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bf560a91c5c1d8c81f4f7e9230063653544e3ba8a1aa60dc7a2e231bfd569db7 diff --git a/tasks/format-code-task-002509/environment/setup/files/blocklist b/tasks/format-code-task-002509/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002509/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002509/environment/setup/setup.sh b/tasks/format-code-task-002509/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002509/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002509/tests/test.patch b/tasks/format-code-task-002509/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fa82f8d6e5ad7427de4de79a424a7e3828d87bf8 --- /dev/null +++ b/tasks/format-code-task-002509/tests/test.patch @@ -0,0 +1,258 @@ +diff --git a/x/ecocredit/params_validate_hidden_test.go b/x/ecocredit/params_validate_hidden_test.go +new file mode 100644 +index 0000000..d1184b9 +--- /dev/null ++++ b/x/ecocredit/params_validate_hidden_test.go +@@ -0,0 +1,75 @@ ++package ecocredit_test ++ ++import ( ++ "testing" ++ ++ sdk "github.com/cosmos/cosmos-sdk/types" ++ sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ++ "github.com/stretchr/testify/require" ++ ++ "github.com/regen-network/regen-ledger/x/ecocredit" ++) ++ ++func TestParamsValidateAcceptsDefaultParams(t *testing.T) { ++ params := ecocredit.DefaultGenesisState().Params ++ require.NoError(t, params.Validate()) ++} ++ ++func TestParamsValidateRejectsInvalidFields(t *testing.T) { ++ tests := []struct { ++ name string ++ mutate func(*ecocredit.Params) ++ }{ ++ { ++ name: "invalid credit type definition", ++ mutate: func(params *ecocredit.Params) { ++ params.CreditTypes = []*ecocredit.CreditType{{ ++ Name: "carbon", ++ Abbreviation: "C", ++ Unit: "metric ton CO2 equivalent", ++ Precision: 7, ++ }} ++ }, ++ }, ++ { ++ name: "invalid allowed creator address", ++ mutate: func(params *ecocredit.Params) { ++ params.AllowedClassCreators = []string{"not-a-valid-regen-address"} ++ }, ++ }, ++ { ++ name: "invalid credit class fee", ++ mutate: func(params *ecocredit.Params) { ++ params.CreditClassFee = sdk.Coins{{Denom: "bad denom", Amount: sdk.NewInt(1)}} ++ }, ++ }, ++ } ++ ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ params := ecocredit.DefaultGenesisState().Params ++ tc.mutate(¶ms) ++ ++ require.Error(t, params.Validate()) ++ }) ++ } ++} ++ ++func TestParamsValidateInvalidAllowedClassCreatorError(t *testing.T) { ++ for _, invalidAddress := range []string{ ++ "not-a-valid-regen-address", ++ "regen1thisisnotavalidbech32address", ++ } { ++ t.Run(invalidAddress, func(t *testing.T) { ++ params := ecocredit.DefaultGenesisState().Params ++ params.AllowedClassCreators = []string{invalidAddress} ++ ++ err := params.Validate() ++ ++ require.Error(t, err) ++ codespace, code, _ := sdkerrors.ABCIInfo(err, false) ++ require.Equal(t, sdkerrors.ErrInvalidAddress.Codespace(), codespace) ++ require.Equal(t, sdkerrors.ErrInvalidAddress.ABCICode(), code) ++ }) ++ } ++} +diff --git a/x/ecocredit/genesis_validate_hidden_test.go b/x/ecocredit/genesis_validate_hidden_test.go +new file mode 100644 +index 0000000..2c5618a +--- /dev/null ++++ b/x/ecocredit/genesis_validate_hidden_test.go +@@ -0,0 +1,124 @@ ++package ecocredit_test ++ ++import ( ++ "bytes" ++ "testing" ++ ++ sdk "github.com/cosmos/cosmos-sdk/types" ++ sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ++ "github.com/stretchr/testify/require" ++ ++ "github.com/regen-network/regen-ledger/x/ecocredit" ++) ++ ++func TestGenesisValidateRejectsInvalidParams(t *testing.T) { ++ for _, invalidAddress := range []string{ ++ "definitely-not-a-bech32-address", ++ "regen1alternateinvalidcreator", ++ } { ++ t.Run("invalid allowed class creator address "+invalidAddress, func(t *testing.T) { ++ genesisState := ecocredit.DefaultGenesisState() ++ genesisState.Params.AllowedClassCreators = []string{invalidAddress} ++ ++ err := genesisState.Validate() ++ ++ require.Error(t, err) ++ codespace, code, _ := sdkerrors.ABCIInfo(err, false) ++ require.Equal(t, sdkerrors.ErrInvalidAddress.Codespace(), codespace) ++ require.Equal(t, sdkerrors.ErrInvalidAddress.ABCICode(), code) ++ }) ++ } ++ ++ for _, precision := range []uint32{7, 5} { ++ t.Run("invalid credit type precision", func(t *testing.T) { ++ genesisState := ecocredit.DefaultGenesisState() ++ genesisState.Params.CreditTypes = []*ecocredit.CreditType{{ ++ Name: "carbon", ++ Abbreviation: "C", ++ Unit: "metric ton CO2 equivalent", ++ Precision: precision, ++ }} ++ ++ err := genesisState.Validate() ++ ++ require.Error(t, err) ++ }) ++ } ++} ++ ++func TestGenesisValidateRejectsUnknownClassInfoCreditType(t *testing.T) { ++ for _, abbreviation := range []string{"F", "XYZ", "NO"} { ++ t.Run(abbreviation, func(t *testing.T) { ++ genesisState := ecocredit.DefaultGenesisState() ++ creditType := *genesisState.Params.CreditTypes[0] ++ creditType.Abbreviation = abbreviation ++ genesisState.ClassInfo = []*ecocredit.ClassInfo{ ++ validClassInfoWithCreditType(&creditType), ++ } ++ ++ err := genesisState.Validate() ++ ++ require.Error(t, err) ++ }) ++ } ++} ++ ++func TestGenesisValidateRejectsMismatchedClassInfoCreditType(t *testing.T) { ++ tests := []struct { ++ name string ++ mutate func(*ecocredit.CreditType) ++ }{ ++ { ++ name: "name mismatch", ++ mutate: func(creditType *ecocredit.CreditType) { ++ creditType.Name = "forest carbon" ++ }, ++ }, ++ { ++ name: "alternate name mismatch", ++ mutate: func(creditType *ecocredit.CreditType) { ++ creditType.Name = "soil carbon" ++ }, ++ }, ++ { ++ name: "unit mismatch", ++ mutate: func(creditType *ecocredit.CreditType) { ++ creditType.Unit = "kilogram CO2 equivalent" ++ }, ++ }, ++ { ++ name: "alternate unit mismatch", ++ mutate: func(creditType *ecocredit.CreditType) { ++ creditType.Unit = "pound CO2 equivalent" ++ }, ++ }, ++ } ++ ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ genesisState := ecocredit.DefaultGenesisState() ++ creditType := *genesisState.Params.CreditTypes[0] ++ tc.mutate(&creditType) ++ genesisState.ClassInfo = []*ecocredit.ClassInfo{ ++ validClassInfoWithCreditType(&creditType), ++ } ++ ++ err := genesisState.Validate() ++ ++ require.Error(t, err) ++ }) ++ } ++} ++ ++func validClassInfoWithCreditType(creditType *ecocredit.CreditType) *ecocredit.ClassInfo { ++ addr1 := sdk.AccAddress(bytes.Repeat([]byte{1}, 20)).String() ++ addr2 := sdk.AccAddress(bytes.Repeat([]byte{2}, 20)).String() ++ ++ return &ecocredit.ClassInfo{ ++ ClassId: "1", ++ Admin: addr1, ++ Issuers: []string{addr1, addr2}, ++ Metadata: []byte("meta-data"), ++ CreditType: creditType, ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,42 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++run_base() { ++ cd /testbed/x/ecocredit || exit 1 ++ local hidden_files=(genesis_validate_hidden_test.go params_validate_hidden_test.go) ++ local moved=() ++ restore_hidden_files() { ++ local f ++ for f in "${moved[@]}"; do ++ if [ -f "$f.fixturea-hidden" ]; then ++ mv "$f.fixturea-hidden" "$f" ++ fi ++ done ++ } ++ trap restore_hidden_files RETURN ++ for f in "${hidden_files[@]}"; do ++ if [ -f "$f" ]; then ++ mv "$f" "$f.fixturea-hidden" ++ moved+=("$f") ++ fi ++ done ++ go test -v -count=1 -run "TestGenesisValidate|TestGenesisDefaultParams" ./... ++ local rc=$? ++ restore_hidden_files ++ trap - RETURN ++ return "$rc" ++} ++ ++case "${1:-}" in ++ base) ++ run_base ++ ;; ++ new) ++ cd /testbed/x/ecocredit && go test -v -count=1 -run "TestParamsValidateAcceptsDefaultParams|TestParamsValidateRejectsInvalidFields|TestParamsValidateInvalidAllowedClassCreatorError|TestGenesisValidateRejectsInvalidParams|TestGenesisValidateRejectsUnknownClassInfoCreditType|TestGenesisValidateRejectsMismatchedClassInfoCreditType" ./... ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002509/tests/test.sh b/tasks/format-code-task-002509/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aac8aefe759dc12a7426ddc0aec7788751d71693 --- /dev/null +++ b/tasks/format-code-task-002509/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/ecocredit/params_validate_hidden_test.go +x/ecocredit/genesis_validate_hidden_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002509/tests/test_command.sh b/tasks/format-code-task-002509/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002509/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-002536/environment/Dockerfile b/tasks/format-code-task-002536/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e709263eec334129daf282256d65cf78942d3f85 --- /dev/null +++ b/tasks/format-code-task-002536/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e01972ba1480bdde754e4b4539cf420f119ce9cd968c1d7be7bf0ddf59bdbb18 diff --git a/tasks/format-code-task-002536/environment/setup/files/blocklist b/tasks/format-code-task-002536/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002536/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002536/environment/setup/setup.sh b/tasks/format-code-task-002536/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002536/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002536/tests/test.patch b/tasks/format-code-task-002536/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d618c4afbb23f5d4aea0d38af75a28763d91d676 --- /dev/null +++ b/tasks/format-code-task-002536/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/rotkehlchen/tests/exchanges/test_kraken.py b/rotkehlchen/tests/exchanges/test_kraken.py +index b4bd8a9a96..3a91927534 100644 +--- a/rotkehlchen/tests/exchanges/test_kraken.py ++++ b/rotkehlchen/tests/exchanges/test_kraken.py +@@ -4,6 +4,7 @@ + from pathlib import Path + from typing import TYPE_CHECKING, cast + from unittest.mock import patch ++from uuid import uuid4 + + import gevent + import pytest +@@ -13,7 +14,7 @@ + from rotkehlchen.accounting.structures.balance import Balance + from rotkehlchen.api.v1.types import IncludeExcludeFilterData + from rotkehlchen.api.websockets.typedefs import WSMessageType +-from rotkehlchen.assets.asset import Asset ++from rotkehlchen.assets.asset import Asset, CustomAsset + from rotkehlchen.assets.converters import asset_from_kraken + from rotkehlchen.constants import ONE, ZERO + from rotkehlchen.constants.assets import ( +@@ -34,6 +35,7 @@ + ) + from rotkehlchen.constants.limits import FREE_HISTORY_EVENTS_LIMIT + from rotkehlchen.constants.resolver import strethaddress_to_identifier ++from rotkehlchen.db.custom_assets import DBCustomAssets + from rotkehlchen.db.filtering import HistoryEventFilterQuery + from rotkehlchen.db.history_events import DBHistoryEvents + from rotkehlchen.db.settings import ModifiableDBSettings +@@ -1106,3 +1108,36 @@ def test_kraken_informational_fees(rotkehlchen_api_server_with_exchanges: 'APISe + notes='margin', + ), + ] ++ ++ ++@pytest.mark.parametrize('use_clean_caching_directory', [True]) ++def test_kraken_event_serialization_with_custom_asset(database): ++ """Regression test for https://github.com/rotki/rotki/issues/9200""" ++ custom_asset = CustomAsset.initialize( ++ identifier=str(uuid4()), ++ name='Gold Bar', ++ custom_asset_type='inheritance', ++ ) ++ DBCustomAssets(database).add_custom_asset(custom_asset) ++ for event_type, event_subtype, expected_notes in ( ++ (HistoryEventType.TRADE, HistoryEventSubType.SPEND, 'Swap 1 Gold Bar in Kraken'), ++ (HistoryEventType.TRADE, HistoryEventSubType.RECEIVE, 'Receive 1 Gold Bar as a result of a Kraken swap'), # noqa: E501 ++ (HistoryEventType.TRADE, HistoryEventSubType.FEE, 'Spend 1 Gold Bar as Kraken trading fee'), # noqa: E501 ++ (HistoryEventType.STAKING, HistoryEventSubType.REWARD, 'Gain 1 Gold Bar from Kraken staking'), # noqa: E501 ++ (HistoryEventType.STAKING, HistoryEventSubType.FEE, 'Spend 1 Gold Bar as Kraken staking fee'), # noqa: E501 ++ (HistoryEventType.WITHDRAWAL, HistoryEventSubType.REMOVE_ASSET, 'Withdraw 1 Gold Bar from Kraken'), # noqa: E501 ++ (HistoryEventType.WITHDRAWAL, HistoryEventSubType.FEE, 'Spend 1 Gold Bar as Kraken withdrawal fee'), # noqa: E501 ++ (HistoryEventType.DEPOSIT, HistoryEventSubType.DEPOSIT_ASSET, 'Deposit 1 Gold Bar to Kraken'), # noqa: E501 ++ ): ++ event = HistoryEvent( ++ event_identifier='foo', ++ sequence_index=1, ++ timestamp=TimestampMS(10000000000), ++ location=Location.KRAKEN, ++ event_type=event_type, ++ event_subtype=event_subtype, ++ asset=custom_asset, ++ balance=Balance(amount=FVal(1)), ++ location_label='my kraken', ++ ) ++ assert event.serialize()['notes'] == expected_notes +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+3S0WrDIBQG4Fz3KXyBpCaZCfRlxJrDlCRa1Gbtnn4uu2gZbL1pGWX/d3P0KCj+ ++VvujnQZJbtkWj8KzXoi1Zt/rOq5Fw1su2r7tC17XHe8KJh52oyvHmFRgrAjep9/23Vp/UtUl/0Qx ++Se3nWbmhiuZ+Z9zKv+HNJf/Pfv3S5Rbj97vCz/55/npga/B7GjaHczLetaycWR7mJgs+jWQmbcit ++u+KWTtoo90rx67uMQY3kqsN5t7uaS1rIJRkpWDXZd5Wsd/LNJiN1fm4/SxUjJVaeWLls/voFAAAA ++AAAAAAAAAAAAAAAAAACe1wfRbvuzACgAAA== +diff --git 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-002536/tests/test.sh b/tasks/format-code-task-002536/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..97464eb332589d8c186117cb0d5c45275e5eab97 --- /dev/null +++ b/tasks/format-code-task-002536/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' +rotkehlchen/tests/exchanges/test_kraken.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-002536/tests/test_command.sh b/tasks/format-code-task-002536/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002536/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002537/environment/Dockerfile b/tasks/format-code-task-002537/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..74bf5efd4e8c3bc34cb80211f6bf4e5928c8a41d --- /dev/null +++ b/tasks/format-code-task-002537/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bddcf08a5c1fc90d638bb9319362bc0bc8a6a92fc0f4bff55cc334f563459bd8 diff --git a/tasks/format-code-task-002537/environment/setup/files/blocklist b/tasks/format-code-task-002537/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002537/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002537/environment/setup/setup.sh b/tasks/format-code-task-002537/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002537/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002538/environment/Dockerfile b/tasks/format-code-task-002538/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..85e130dce28028aeb7ff267b33a90246897f9927 --- /dev/null +++ b/tasks/format-code-task-002538/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5f2de1ad0285b6c38e813cd341a441df80953e4e3078641d421d5b98e696de43 diff --git a/tasks/format-code-task-002538/environment/setup/files/blocklist b/tasks/format-code-task-002538/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002538/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002538/environment/setup/setup.sh b/tasks/format-code-task-002538/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002538/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002538/tests/test.patch b/tasks/format-code-task-002538/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..26f9591a9fd09f368ee5e02265a0389b7e803677 --- /dev/null +++ b/tasks/format-code-task-002538/tests/test.patch @@ -0,0 +1,53 @@ +diff --git a/tests/test_job.py b/tests/test_job.py +index 87342ebba..1491f7f98 100644 +--- a/tests/test_job.py ++++ b/tests/test_job.py +@@ -272,6 +272,26 @@ def test_custom_meta_is_persisted(self): + job2 = Job.fetch(job.id) + self.assertEqual(job2.meta['foo'], 'bar') + ++ def test_custom_meta_is_rewriten_by_save_meta(self): ++ """New meta data can be stored by save_meta.""" ++ job = Job.create(func=fixtures.say_hello, args=('Lionel',)) ++ job.save() ++ serialized = job.to_dict() ++ ++ job.meta['foo'] = 'bar' ++ job.save_meta() ++ ++ raw_meta = self.testconn.hget(job.key, 'meta') ++ self.assertEqual(loads(raw_meta)['foo'], 'bar') ++ ++ job2 = Job.fetch(job.id) ++ self.assertEqual(job2.meta['foo'], 'bar') ++ ++ ++ serialized2 = job2.to_dict() ++ serialized2.pop('meta') ++ self.assertDictEqual(serialized, serialized2) ++ + def test_result_ttl_is_persisted(self): + """Ensure that job's result_ttl is set properly""" + job = Job.create(func=fixtures.say_hello, args=('Lionel',), result_ttl=10) +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+3SzUrEMBAH8J77FCN70UM/17Y3b77AguelbYZtZJvUJC2sT2/ahVUE3YO7iPj/ ++UZowDTOhM3Ezyr3YspqS4FpSryqKZfU+r8s+K/IsK8uizPMg9bu0Cqi42o0+GK2rDVFgtHbfnTv3 ++/Y+K3/vv2Lptq/u+ViK23eVqnOv/uqpO/S9KH8/uy/U6oPRyV/jaP+//6iZppEqa2nZhK2gZgoZF ++GK7oUdnRMG1YSEv+MaNSUu1CMwciy2ZiQ1Ekau61kq9MB7aUPySCp0SN+/2c48kyuY5pMBzNk+Zo ++8qNGt3p0Vgo+1SOrSTryBSc5+TSGB+1flp29C60eTevP6sEl5mU7Z1guXbdOTrXjudBmVOQbuWNH ++c0obDgfXaUVRT37nI8fwccifdRMPB4qm8Ld/PwAAAAAAAAAAAAAAAAAAAADAj7wBTQr9FgAoAAA= +diff --git 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-002538/tests/test.sh b/tasks/format-code-task-002538/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b8d14a43dd0ed6622f065f28a2138d8927592aa5 --- /dev/null +++ b/tasks/format-code-task-002538/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_job.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002538/tests/test_command.sh b/tasks/format-code-task-002538/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002538/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002552/environment/Dockerfile b/tasks/format-code-task-002552/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ee8a290402022e2d24d520312936530cbbc7d3ca --- /dev/null +++ b/tasks/format-code-task-002552/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2dcbed218c61011d847ef2e3b37aa70f153a3f2f833f5cc1c85ea8b48860f207 diff --git a/tasks/format-code-task-002552/environment/setup/files/blocklist b/tasks/format-code-task-002552/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002552/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002552/environment/setup/setup.sh b/tasks/format-code-task-002552/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002552/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002552/tests/test.patch b/tasks/format-code-task-002552/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4758a6d352ac7841206d3f40d0abeb29aa896bca --- /dev/null +++ b/tasks/format-code-task-002552/tests/test.patch @@ -0,0 +1,114 @@ +diff --git a/miio/tests/test_miot_models.py b/miio/tests/test_miot_models.py +index eaf8d9e..1d6d9f8 100644 +--- a/miio/tests/test_miot_models.py ++++ b/miio/tests/test_miot_models.py +@@ -138,6 +138,87 @@ def test_action(): + assert act.plain_name == "dummy-action" + + ++def test_action_in_null_parses(): ++ """Null `in` value (seen in real Roidmi V66 spec) must parse without crashing. ++ ++ Either reference's approach (coerce at parse time) or deferred-coercion in ++ fill_from_parent is acceptable; user-observable end-state is empty list ++ after MiotService finishes constructing. ++ """ ++ data = """ ++ { ++ "iid": 1, ++ "type": "urn:miot-spec-v2:action:dummy-action:0000001:dummy:1", ++ "description": "Description", ++ "in": null, ++ "out": [] ++ }""" ++ act = MiotAction.parse_raw(data) ++ assert act.inputs in (None, []) ++ assert act.outputs == [] ++ ++ ++def test_action_out_null_parses(): ++ """Null `out` value must parse without crashing.""" ++ data = """ ++ { ++ "iid": 1, ++ "type": "urn:miot-spec-v2:action:dummy-action:0000001:dummy:1", ++ "description": "Description", ++ "in": [], ++ "out": null ++ }""" ++ act = MiotAction.parse_raw(data) ++ assert act.inputs == [] ++ assert act.outputs in (None, []) ++ ++ ++def test_action_both_in_out_null_parses(): ++ """Both `in` and `out` null must parse without crashing.""" ++ data = """ ++ { ++ "iid": 1, ++ "type": "urn:miot-spec-v2:action:dummy-action:0000001:dummy:1", ++ "description": "Description", ++ "in": null, ++ "out": null ++ }""" ++ act = MiotAction.parse_raw(data) ++ assert act.inputs in (None, []) ++ assert act.outputs in (None, []) ++ ++ ++def test_service_with_action_having_null_in_out_parses(): ++ """Repro for the Roidmi V66 issue: service whose action has null `in`/`out`. ++ ++ Previously this raised a pydantic ValidationError (NoneType is not iterable) ++ during MiotService.__init__ -> fill_from_parent. ++ """ ++ data = """ ++ { ++ "iid": 1, ++ "description": "test service", ++ "type": "urn:miot-spec-v2:service:device-information:00000001:dummy:1", ++ "properties": [], ++ "actions": [ ++ { ++ "iid": 1, ++ "type": "urn:miot-spec-v2:action:start-sweep:00000004:dummy:1", ++ "description": "Start Sweep", ++ "in": null, ++ "out": null ++ } ++ ], ++ "events": [] ++ } ++ """ ++ serv = MiotService.parse_raw(data) ++ assert len(serv.actions) == 1 ++ ++ assert serv.actions[0].inputs == [] ++ assert serv.actions[0].outputs == [] ++ ++ + @pytest.mark.parametrize( + ("urn_string", "unexpected"), + [ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..f0d9573 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest miio/tests/test_miot_models.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 miio/tests/test_miot_models.py::test_action_in_null_parses miio/tests/test_miot_models.py::test_action_out_null_parses miio/tests/test_miot_models.py::test_action_both_in_out_null_parses miio/tests/test_miot_models.py::test_service_with_action_having_null_in_out_parses ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002552/tests/test.sh b/tasks/format-code-task-002552/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b1ad0238c9ef421605e37a6d26dd3abcf233fa2 --- /dev/null +++ b/tasks/format-code-task-002552/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' +miio/tests/test_miot_models.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-002552/tests/test_command.sh b/tasks/format-code-task-002552/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002552/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002555/environment/Dockerfile b/tasks/format-code-task-002555/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..17fd297a48d046a6c6c912de9194f1ecf67b5c3e --- /dev/null +++ b/tasks/format-code-task-002555/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fbd39e51b729bbd727088431a823f35b3e9eb7662ea51e25b97579567fc025e6 diff --git a/tasks/format-code-task-002555/environment/setup/files/blocklist b/tasks/format-code-task-002555/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002555/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002555/environment/setup/setup.sh b/tasks/format-code-task-002555/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002555/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002555/tests/test.patch b/tasks/format-code-task-002555/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..248b13bc04393b9ff73b519f3479d81a4af24233 --- /dev/null +++ b/tasks/format-code-task-002555/tests/test.patch @@ -0,0 +1,558 @@ +diff --git a/usercase-test-coderl/test_notification_helpers.py b/usercase-test-coderl/test_notification_helpers.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_notification_helpers.py +@@ -0,0 +1,532 @@ ++import copy ++import json ++import subprocess ++import sys ++ ++import pytest ++from django.conf import settings ++ ++ ++ ++if not settings.configured: ++ settings.configure( ++ SECRET_KEY="fixture-notification-helpers", ++ INSTALLED_APPS=[ ++ "django.contrib.auth", ++ "django.contrib.contenttypes", ++ "webpush", ++ ], ++ DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}, ++ DEFAULT_AUTO_FIELD="django.db.models.AutoField", ++ USE_TZ=True, ++ WEBPUSH_SETTINGS={}, ++ ) ++ ++import django ++ ++django.setup() ++ ++from django.contrib.auth import get_user_model ++from django.db import connection ++ ++from webpush import ( ++ send_group_notification, ++ send_notification_to_group, ++ send_notification_to_user, ++ send_user_notification, ++) ++from webpush.models import Group as WebPushGroup ++from webpush.models import PushInformation, SubscriptionInfo ++import webpush.utils as webpush_utils ++ ++ ++User = get_user_model() ++ ++ ++def _create_schema(): ++ with connection.schema_editor() as schema: ++ for model in (User, WebPushGroup, SubscriptionInfo, PushInformation): ++ schema.create_model(model) ++ ++ ++_create_schema() ++ ++ ++@pytest.fixture(autouse=True) ++def clean_database(): ++ _clear_database() ++ yield ++ _clear_database() ++ ++ ++def _clear_database(): ++ PushInformation.objects.all().delete() ++ SubscriptionInfo.objects.all().delete() ++ WebPushGroup.objects.all().delete() ++ with connection.cursor() as cursor: ++ cursor.execute('DELETE FROM "%s"' % User._meta.db_table) ++ ++ ++@pytest.fixture ++def captured_webpush(monkeypatch): ++ calls = [] ++ ++ def fake_webpush(subscription_info, data, ttl=0, **kwargs): ++ calls.append( ++ { ++ "subscription_info": subscription_info, ++ "data": data, ++ "ttl": ttl, ++ "kwargs": kwargs, ++ } ++ ) ++ return "sent-%d" % len(calls) ++ ++ monkeypatch.setattr(webpush_utils, "webpush", fake_webpush) ++ return calls ++ ++ ++def _subscription(browser, endpoint, auth, p256dh): ++ return SubscriptionInfo.objects.create( ++ browser=browser, ++ endpoint=endpoint, ++ auth=auth, ++ p256dh=p256dh, ++ ) ++ ++ ++def _make_user_graph(): ++ alice = User.objects.create_user(id=101, username="alice") ++ first = _subscription( ++ "Firefox", ++ "https://push.example.com/alice-1", ++ "auth-a1", ++ "key-a1", ++ ) ++ second = _subscription( ++ "Chrome", ++ "https://push.example.com/alice-2", ++ "auth-a2", ++ "key-a2", ++ ) ++ PushInformation.objects.create(user=alice, subscription=first) ++ PushInformation.objects.create(user=alice, subscription=second) ++ return alice ++ ++ ++def _make_group_graph(): ++ alice = User.objects.create_user(id=101, username="alice") ++ bob = User.objects.create_user(id=202, username="bob") ++ group = WebPushGroup.objects.create(name="my_group") ++ first = _subscription( ++ "Edge", ++ "https://push.example.com/team-1", ++ "auth-t1", ++ "key-t1", ++ ) ++ second = _subscription( ++ "Brave", ++ "https://push.example.com/team-2", ++ "auth-t2", ++ "key-t2", ++ ) ++ PushInformation.objects.create(user=alice, group=group, subscription=first) ++ PushInformation.objects.create(user=bob, group=group, subscription=second) ++ return alice, bob, group ++ ++ ++def _normalized(calls): ++ return sorted(calls, key=lambda call: call["subscription_info"]["endpoint"]) ++ ++ ++def _contract_calls(calls, decode_json=False): ++ ++ normalized = [] ++ for call in _normalized(calls): ++ data = json.loads(call["data"]) if decode_json else call["data"] ++ subscription_info = call["subscription_info"] ++ normalized.append( ++ { ++ "subscription_info": { ++ "endpoint": subscription_info["endpoint"], ++ "keys": { ++ "p256dh": subscription_info["keys"]["p256dh"], ++ "auth": subscription_info["keys"]["auth"], ++ }, ++ }, ++ "data": data, ++ "ttl": call["ttl"], ++ } ++ ) ++ return normalized ++ ++ ++def test_send_user_notification_serializes_payload_and_dispatches_every_user_subscription(captured_webpush): ++ ++ ++ ++ user = _make_user_graph() ++ ++ result = send_user_notification(user, {"head": "Welcome!", "body": "Hello World"}, ttl=1000) ++ ++ assert result is None ++ ++ assert _contract_calls(captured_webpush, decode_json=True) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-1", ++ "keys": {"p256dh": "key-a1", "auth": "auth-a1"}, ++ }, ++ "data": {"head": "Welcome!", "body": "Hello World"}, ++ "ttl": 1000, ++ }, ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-2", ++ "keys": {"p256dh": "key-a2", "auth": "auth-a2"}, ++ }, ++ "data": {"head": "Welcome!", "body": "Hello World"}, ++ "ttl": 1000, ++ }, ++ ] ++ ++ ++def test_send_user_notification_preserves_rich_payload_keys_and_default_ttl(captured_webpush): ++ ++ ++ ++ bob = User.objects.create_user(id=202, username="bob") ++ subscription = _subscription( ++ "Safari", ++ "https://push.example.com/bob-1", ++ "auth-b1", ++ "key-b1", ++ ) ++ PushInformation.objects.create(user=bob, subscription=subscription) ++ ++ result = send_user_notification( ++ bob, ++ { ++ "head": "Welcome!", ++ "body": "Hello World", ++ "icon": "https://example.com/icon.png", ++ "url": "https://example.com", ++ }, ++ ) ++ ++ assert result is None ++ ++ assert _contract_calls(captured_webpush, decode_json=True) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/bob-1", ++ "keys": {"p256dh": "key-b1", "auth": "auth-b1"}, ++ }, ++ "data": { ++ "head": "Welcome!", ++ "body": "Hello World", ++ "icon": "https://example.com/icon.png", ++ "url": "https://example.com", ++ }, ++ "ttl": 0, ++ } ++ ] ++ ++ ++def test_send_group_notification_dispatches_to_every_subscription_in_named_group(captured_webpush): ++ ++ ++ ++ _make_group_graph() ++ ++ result = send_group_notification("my_group", {"head": "Welcome!", "body": "Hello World"}, ttl=1000) ++ ++ assert result is None ++ ++ assert _contract_calls(captured_webpush, decode_json=True) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/team-1", ++ "keys": {"p256dh": "key-t1", "auth": "auth-t1"}, ++ }, ++ "data": {"head": "Welcome!", "body": "Hello World"}, ++ "ttl": 1000, ++ }, ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/team-2", ++ "keys": {"p256dh": "key-t2", "auth": "auth-t2"}, ++ }, ++ "data": {"head": "Welcome!", "body": "Hello World"}, ++ "ttl": 1000, ++ }, ++ ] ++ ++ ++def test_send_group_notification_excludes_matching_user_id_only(captured_webpush): ++ ++ ++ ++ _make_group_graph() ++ ++ result = send_group_notification( ++ "my_group", ++ {"head": "Group", "body": "Only Bob"}, ++ ttl=1000, ++ exclude_user_id=101, ++ ) ++ ++ assert result is None ++ ++ assert _contract_calls(captured_webpush, decode_json=True) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/team-2", ++ "keys": {"p256dh": "key-t2", "auth": "auth-t2"}, ++ }, ++ "data": {"head": "Group", "body": "Only Bob"}, ++ "ttl": 1000, ++ } ++ ] ++ ++ ++def test_send_notification_to_user_forwards_already_serialized_payload_without_double_encoding(captured_webpush): ++ ++ ++ ++ user = _make_user_graph() ++ ++ result = send_notification_to_user(user, '{"already":"serialized","n":7}', ttl=55) ++ ++ assert result is None ++ ++ assert _contract_calls(captured_webpush) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-1", ++ "keys": {"p256dh": "key-a1", "auth": "auth-a1"}, ++ }, ++ "data": '{"already":"serialized","n":7}', ++ "ttl": 55, ++ }, ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-2", ++ "keys": {"p256dh": "key-a2", "auth": "auth-a2"}, ++ }, ++ "data": '{"already":"serialized","n":7}', ++ "ttl": 55, ++ }, ++ ] ++ ++ ++def test_send_notification_to_group_forwards_serialized_payload_and_exclusion(captured_webpush): ++ ++ ++ ++ _make_group_graph() ++ ++ result = send_notification_to_group("my_group", '{"raw":true}', ttl=66, exclude_user_id=202) ++ ++ assert result is None ++ ++ assert _contract_calls(captured_webpush) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/team-1", ++ "keys": {"p256dh": "key-t1", "auth": "auth-t1"}, ++ }, ++ "data": '{"raw":true}', ++ "ttl": 66, ++ } ++ ] ++ ++ ++def test_send_user_notification_non_serializable_payload_raises_type_error_before_sending(captured_webpush): ++ ++ ++ ++ user = _make_user_graph() ++ ++ ++ with pytest.raises(TypeError): ++ send_user_notification(user, {"bad": {1, 2}}) ++ ++ assert captured_webpush == [] ++ ++ ++def test_send_group_notification_missing_group_raises_group_does_not_exist(captured_webpush): ++ ++ ++ ++ ++ with pytest.raises(WebPushGroup.DoesNotExist): ++ send_group_notification("missing", {"head": "x"}) ++ ++ assert captured_webpush == [] ++ ++ ++def test_referential_transparency_same_user_send_returns_same_value(captured_webpush): ++ user = _make_user_graph() ++ ++ first = send_notification_to_user(user, '{"same":1}', ttl=12) ++ second = send_notification_to_user(user, '{"same":1}', ttl=12) ++ ++ assert first is None ++ assert second is None ++ ++ assert _contract_calls(captured_webpush) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-1", ++ "keys": {"p256dh": "key-a1", "auth": "auth-a1"}, ++ }, ++ "data": '{"same":1}', ++ "ttl": 12, ++ }, ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-1", ++ "keys": {"p256dh": "key-a1", "auth": "auth-a1"}, ++ }, ++ "data": '{"same":1}', ++ "ttl": 12, ++ }, ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-2", ++ "keys": {"p256dh": "key-a2", "auth": "auth-a2"}, ++ }, ++ "data": '{"same":1}', ++ "ttl": 12, ++ }, ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-2", ++ "keys": {"p256dh": "key-a2", "auth": "auth-a2"}, ++ }, ++ "data": '{"same":1}', ++ "ttl": 12, ++ }, ++ ] ++ ++ ++def test_payload_input_is_not_mutated_by_json_serializing_helper(captured_webpush): ++ payload = { ++ "head": "Welcome!", ++ "body": "Hello World", ++ "actions": [{"title": "Open", "url": "https://example.com"}], ++ } ++ original = copy.deepcopy(payload) ++ user = _make_user_graph() ++ ++ send_user_notification(user, payload, ttl=1000) ++ ++ ++ assert [call["data"] for call in _contract_calls(captured_webpush, decode_json=True)] == [original, original] ++ ++ ++def _capture_current_process_user_send(captured_webpush): ++ user = _make_user_graph() ++ send_user_notification(user, {"head": "Welcome!", "body": "Hello World"}, ttl=1000) ++ return _normalized(captured_webpush) ++ ++ ++def test_no_global_state_matches_fresh_process_for_same_user_send(captured_webpush): ++ in_process = _capture_current_process_user_send(captured_webpush) ++ script = r''' ++import json ++import sys ++sys.path.insert(0, "/workspace/repo") ++from django.conf import settings ++settings.configure( ++ SECRET_KEY="fixture-notification-helpers", ++ INSTALLED_APPS=["django.contrib.auth", "django.contrib.contenttypes", "webpush"], ++ DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}, ++ DEFAULT_AUTO_FIELD="django.db.models.AutoField", ++ USE_TZ=True, ++ WEBPUSH_SETTINGS={}, ++) ++import django ++django.setup() ++from django.contrib.auth import get_user_model ++from django.db import connection ++from webpush import send_user_notification ++from webpush.models import Group as WebPushGroup, PushInformation, SubscriptionInfo ++import webpush.utils as webpush_utils ++User = get_user_model() ++with connection.schema_editor() as schema: ++ for model in (User, WebPushGroup, SubscriptionInfo, PushInformation): ++ schema.create_model(model) ++calls = [] ++def fake_webpush(subscription_info, data, ttl=0, **kwargs): ++ calls.append({"subscription_info": subscription_info, "data": data, "ttl": ttl, "kwargs": kwargs}) ++ return "sent-%d" % len(calls) ++webpush_utils.webpush = fake_webpush ++user = User.objects.create_user(id=101, username="alice") ++first = SubscriptionInfo.objects.create(browser="Firefox", endpoint="https://push.example.com/alice-1", auth="auth-a1", p256dh="key-a1") ++second = SubscriptionInfo.objects.create(browser="Chrome", endpoint="https://push.example.com/alice-2", auth="auth-a2", p256dh="key-a2") ++PushInformation.objects.create(user=user, subscription=first) ++PushInformation.objects.create(user=user, subscription=second) ++send_user_notification(user, {"head": "Welcome!", "body": "Hello World"}, ttl=1000) ++sys.stdout.write(json.dumps(sorted(calls, key=lambda call: call["subscription_info"]["endpoint"]), sort_keys=True)) ++''' ++ ++ fresh = json.loads( ++ subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ text=True, ++ ).stdout ++ ) ++ ++ ++ assert _contract_calls(in_process, decode_json=True) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-1", ++ "keys": {"p256dh": "key-a1", "auth": "auth-a1"}, ++ }, ++ "data": {"head": "Welcome!", "body": "Hello World"}, ++ "ttl": 1000, ++ }, ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-2", ++ "keys": {"p256dh": "key-a2", "auth": "auth-a2"}, ++ }, ++ "data": {"head": "Welcome!", "body": "Hello World"}, ++ "ttl": 1000, ++ }, ++ ] ++ ++ assert _contract_calls(fresh, decode_json=True) == _contract_calls(in_process, decode_json=True) ++ ++ ++def test_send_user_notification_dispatches_from_arbitrary_working_directory(tmp_path, monkeypatch, captured_webpush): ++ user = _make_user_graph() ++ monkeypatch.chdir(tmp_path) ++ ++ send_user_notification(user, {"head": "Side", "body": "Effects"}, ttl=4) ++ ++ ++ assert _contract_calls(captured_webpush, decode_json=True) == [ ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-1", ++ "keys": {"p256dh": "key-a1", "auth": "auth-a1"}, ++ }, ++ "data": {"head": "Side", "body": "Effects"}, ++ "ttl": 4, ++ }, ++ { ++ "subscription_info": { ++ "endpoint": "https://push.example.com/alice-2", ++ "keys": {"p256dh": "key-a2", "auth": "auth-a2"}, ++ }, ++ "data": {"head": "Side", "body": "Effects"}, ++ "ttl": 4, ++ }, ++ ] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_notification_helpers.py -v diff --git a/tasks/format-code-task-002555/tests/test.sh b/tasks/format-code-task-002555/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ee95dcc8f49bded1eb9e88aac98a5e3aad3c9be8 --- /dev/null +++ b/tasks/format-code-task-002555/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_notification_helpers.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-002555/tests/test_command.sh b/tasks/format-code-task-002555/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002555/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-002563/environment/Dockerfile b/tasks/format-code-task-002563/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..65076180b30fa962897120294979b872f4dd7c18 --- /dev/null +++ b/tasks/format-code-task-002563/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f67d672ea8140e70089e182b8290d734814348e230a9b611a4e7f116b88b65c9 diff --git a/tasks/format-code-task-002563/environment/setup/files/blocklist b/tasks/format-code-task-002563/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002563/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002563/environment/setup/setup.sh b/tasks/format-code-task-002563/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002563/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002563/tests/test.patch b/tasks/format-code-task-002563/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a0f2350007372749e717d59420d0d82a5767c997 --- /dev/null +++ b/tasks/format-code-task-002563/tests/test.patch @@ -0,0 +1,318 @@ +diff --git a/tests/unit/states/postgres_test.py b/tests/unit/states/postgres_test.py +index 3a669170e2d5..12a212ac2185 100644 +--- a/tests/unit/states/postgres_test.py ++++ b/tests/unit/states/postgres_test.py +@@ -3,7 +3,7 @@ + # Import Salt Testing libs + from salttesting import skipIf, TestCase + from salttesting.helpers import ensure_in_syspath +-from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch ++from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, MagicMock, patch + + ensure_in_syspath('../../') + +@@ -44,11 +44,275 @@ + + + @skipIf(NO_MOCK, NO_MOCK_REASON) +-@patch.multiple(postgres, ++@patch.multiple(postgres_user, + __grains__={'os_family': 'Linux'}, + __salt__=SALT_STUB) + @patch('salt.utils.which', Mock(return_value='/usr/bin/pgsql')) +-class PostgresTestCase(TestCase): ++class PostgresUserTestCase(TestCase): ++ ++ @patch.dict(SALT_STUB, { ++ 'postgres.role_get': Mock(return_value=None), ++ 'postgres.user_create': MagicMock(), ++ }) ++ def test_present__creation(self): ++ ++ with patch.dict(OPTS, {'test': True}): ++ ret = postgres_user.present('foo') ++ self.assertEqual( ++ ret, ++ {'comment': 'User foo is set to be created', ++ 'changes': {}, 'name': 'foo', 'result': None} ++ ) ++ self.assertEqual(SALT_STUB['postgres.user_create'].call_count, 0) ++ ++ ++ ret = postgres_user.present('foo') ++ self.assertEqual( ++ ret, ++ {'comment': 'The user foo has been created', ++ 'changes': {'foo': 'Present'}, 'name': 'foo', 'result': True} ++ ) ++ SALT_STUB['postgres.user_create'].assert_called_once_with(username='foo', ++ superuser=None, ++ encrypted=True, ++ runas=None, ++ inherit=None, ++ rolepassword=None, ++ port=None, ++ replication=None, ++ host=None, ++ createroles=None, ++ user=None, ++ groups=None, ++ maintenance_db=None, ++ login=None, ++ password=None, ++ createdb=None) ++ ++ @patch.dict(SALT_STUB, { ++ 'postgres.role_get': Mock(return_value={ ++ 'can create databases': False, ++ 'can create roles': False, ++ 'can login': False, ++ 'can update system catalogs': False, ++ 'connections': None, ++ 'defaults variables': {}, ++ 'expiry time': None, ++ 'inherits privileges': True, ++ 'replication': False, ++ 'superuser': False, ++ }), ++ 'postgres.user_update': MagicMock(), ++ }) ++ def test_present__update(self): ++ ++ with patch.dict(OPTS, {'test': True}): ++ ret = postgres_user.present('foo', login=True, replication=False) ++ self.assertEqual( ++ ret, ++ {'comment': 'User foo is set to be updated', ++ 'changes': {'foo': {'login': True}}, 'name': 'foo', 'result': None} ++ ) ++ self.assertEqual(SALT_STUB['postgres.user_update'].call_count, 0) ++ ++ ++ ret = postgres_user.present('foo', login=True, replication=False) ++ self.assertEqual( ++ ret, ++ {'comment': 'The user foo has been updated', ++ 'changes': {'foo': {'login': True}}, 'name': 'foo', 'result': True} ++ ) ++ SALT_STUB['postgres.user_update'].assert_called_once_with(username='foo', ++ superuser=None, ++ encrypted=True, ++ runas=None, ++ inherit=None, ++ rolepassword=None, ++ port=None, ++ replication=False, ++ host=None, ++ createroles=None, ++ user=None, ++ groups=None, ++ maintenance_db=None, ++ login=True, ++ password=None, ++ createdb=None) ++ ++ @patch.dict(SALT_STUB, { ++ 'postgres.role_get': Mock(return_value={ ++ 'can create databases': False, ++ 'can create roles': False, ++ 'can login': False, ++ 'can update system catalogs': False, ++ 'connections': None, ++ 'defaults variables': {}, ++ 'expiry time': None, ++ 'inherits privileges': True, ++ 'replication': False, ++ 'superuser': False, ++ }), ++ 'postgres.user_update': MagicMock(), ++ }) ++ def test_present__no_update(self): ++ ++ with patch.dict(OPTS, {'test': True}): ++ ret = postgres_user.present('foo', login=False, replication=False) ++ self.assertEqual( ++ ret, ++ {'comment': 'User foo is already present', ++ 'changes': {}, 'name': 'foo', 'result': True} ++ ) ++ self.assertEqual(SALT_STUB['postgres.user_update'].call_count, 0) ++ ++ ++ ret = postgres_user.present('foo', login=False, replication=False) ++ self.assertEqual( ++ ret, ++ {'comment': 'User foo is already present', ++ 'changes': {}, 'name': 'foo', 'result': True} ++ ) ++ self.assertEqual(SALT_STUB['postgres.user_update'].call_count, 0) ++ ++ ++@skipIf(NO_MOCK, NO_MOCK_REASON) ++@patch.multiple(postgres_group, ++ __grains__={'os_family': 'Linux'}, ++ __salt__=SALT_STUB) ++@patch('salt.utils.which', Mock(return_value='/usr/bin/pgsql')) ++class PostgresGroupTestCase(TestCase): ++ ++ @patch.dict(SALT_STUB, { ++ 'postgres.role_get': Mock(return_value=None), ++ 'postgres.group_create': MagicMock(), ++ }) ++ def test_present__creation(self): ++ ++ with patch.dict(OPTS, {'test': True}): ++ ret = postgres_group.present('foo') ++ self.assertEqual( ++ ret, ++ {'comment': 'Group foo is set to be created', ++ 'changes': {}, 'name': 'foo', 'result': None} ++ ) ++ self.assertEqual(SALT_STUB['postgres.group_create'].call_count, 0) ++ ++ ++ ret = postgres_group.present('foo') ++ self.assertEqual( ++ ret, ++ {'comment': 'The group foo has been created', ++ 'changes': {}, 'name': 'foo', 'result': True} ++ ) ++ SALT_STUB['postgres.group_create'].assert_called_once_with(superuser=None, ++ replication=None, ++ encrypted=True, ++ runas=None, ++ inherit=None, ++ rolepassword=None, ++ port=None, ++ groupname='foo', ++ host=None, ++ createroles=None, ++ user=None, ++ groups=None, ++ maintenance_db=None, ++ login=None, ++ password=None, ++ createdb=None) ++ ++ @patch.dict(SALT_STUB, { ++ 'postgres.role_get': Mock(return_value={ ++ 'can create databases': False, ++ 'can create roles': False, ++ 'can login': False, ++ 'can update system catalogs': False, ++ 'connections': None, ++ 'defaults variables': {}, ++ 'expiry time': None, ++ 'inherits privileges': True, ++ 'replication': False, ++ 'superuser': False, ++ }), ++ 'postgres.group_update': MagicMock(), ++ }) ++ def test_present__update(self): ++ ++ with patch.dict(OPTS, {'test': True}): ++ ret = postgres_group.present('foo', login=True, replication=False) ++ self.assertEqual( ++ ret, ++ {'comment': 'Group foo is set to be updated', ++ 'changes': {'foo': {'login': True}}, 'name': 'foo', 'result': None} ++ ) ++ self.assertEqual(SALT_STUB['postgres.group_update'].call_count, 0) ++ ++ ++ ret = postgres_group.present('foo', login=True, replication=False) ++ self.assertEqual( ++ ret, ++ {'comment': 'The group foo has been updated', ++ 'changes': {'foo': {'login': True}}, 'name': 'foo', 'result': True} ++ ) ++ SALT_STUB['postgres.group_update'].assert_called_once_with(superuser=None, ++ replication=False, ++ encrypted=True, ++ runas=None, ++ inherit=None, ++ rolepassword=None, ++ port=None, ++ groupname='foo', ++ host=None, ++ createroles=None, ++ user=None, ++ groups=None, ++ maintenance_db=None, ++ login=True, ++ password=None, ++ createdb=None) ++ ++ @patch.dict(SALT_STUB, { ++ 'postgres.role_get': Mock(return_value={ ++ 'can create databases': False, ++ 'can create roles': False, ++ 'can login': False, ++ 'can update system catalogs': False, ++ 'connections': None, ++ 'defaults variables': {}, ++ 'expiry time': None, ++ 'inherits privileges': True, ++ 'replication': False, ++ 'superuser': False, ++ }), ++ 'postgres.group_update': MagicMock(), ++ }) ++ def test_present__no_update(self): ++ ++ with patch.dict(OPTS, {'test': True}): ++ ret = postgres_group.present('foo', login=False, replication=False) ++ self.assertEqual( ++ ret, ++ {'comment': 'Group foo is already present', ++ 'changes': {}, 'name': 'foo', 'result': True} ++ ) ++ self.assertEqual(SALT_STUB['postgres.group_update'].call_count, 0) ++ ++ ++ ret = postgres_group.present('foo', login=False, replication=False) ++ self.assertEqual( ++ ret, ++ {'comment': 'Group foo is already present', ++ 'changes': {}, 'name': 'foo', 'result': True} ++ ) ++ self.assertEqual(SALT_STUB['postgres.group_update'].call_count, 0) ++ ++ ++@skipIf(NO_MOCK, NO_MOCK_REASON) ++@patch.multiple(postgres_extension, ++ __grains__={'os_family': 'Linux'}, ++ __salt__=SALT_STUB) ++@patch('salt.utils.which', Mock(return_value='/usr/bin/pgsql')) ++class PostgresExtensionTestCase(TestCase): + + @patch.dict(SALT_STUB, { + 'postgres.create_metadata': Mock(side_effect=[ +@@ -221,4 +485,4 @@ def test_absent_failedtest(self): + + if __name__ == '__main__': + from integration import run_tests +- run_tests(PostgresTestCase, needs_daemon=False) ++ run_tests(PostgresExtensionTestCase, needs_daemon=False) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SQWuDMBgGYM/+ig/xsB00Sa0Kgx56GPQytsPuojVMoSZioqz/ftFLx9jWS8s2 ++9j6HJOYTvpA3cTW2h7qQamLetXAnT9Nldj7Oy1qkK86zTIhk7XEh0jz3KL3aid4ZjS0HIm/Q2n73 ++37n6HxWf8rfS2GKvu65UdWyay/U4l/8qSU758zn/dcYzj/jljvC1f57/vqYl+ErWvnzt9WDpafu8 ++2wTh7vHhnsX9cX4aVavuwnk/8OVUHigIb5YCtaq1FEV9aZvbz2tuuz/aRiuKOnIr14vmwbDR1Zm7 ++fffFem3syyBNMZdcU4om/6evBgAAAAAAAAAAAAAAAAAAAADg13sD+2jlMQAoAAA= +diff --git 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-002563/tests/test.sh b/tasks/format-code-task-002563/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..50b467bcdb0ef96da90cb8ee02eb6ca18ba03584 --- /dev/null +++ b/tasks/format-code-task-002563/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/states/postgres_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002563/tests/test_command.sh b/tasks/format-code-task-002563/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002563/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002564/environment/Dockerfile b/tasks/format-code-task-002564/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e202f2146ea41bae0991598ced2f9cc4972f771a --- /dev/null +++ b/tasks/format-code-task-002564/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2a8c115371a0426961864b31abdb72b8b302794829dd22006d3f6cb229afe906 diff --git a/tasks/format-code-task-002564/environment/setup/files/blocklist b/tasks/format-code-task-002564/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002564/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002564/environment/setup/setup.sh b/tasks/format-code-task-002564/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002564/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002564/tests/test.patch b/tasks/format-code-task-002564/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a3abf8f23e609f9da84efea4ef9abd241848cdd9 --- /dev/null +++ b/tasks/format-code-task-002564/tests/test.patch @@ -0,0 +1,77 @@ +diff --git a/tests/unit/utils/vmware_test/connection_test.py b/tests/unit/utils/vmware_test/connection_test.py +index 1f0d7b671e90..364cc4c5a12d 100644 +--- a/tests/unit/utils/vmware_test/connection_test.py ++++ b/tests/unit/utils/vmware_test/connection_test.py +@@ -22,7 +22,7 @@ + import salt.utils.vmware + # Import Third Party Libs + try: +- from pyVmomi import vim ++ from pyVmomi import vim, vmodl + HAS_PYVMOMI = True + except ImportError: + HAS_PYVMOMI = False +@@ -667,6 +667,40 @@ def test_unauthenticated_service_instance(self): + self.assertEqual(mock_get_si.call_count, 2) + + ++@skipIf(NO_MOCK, NO_MOCK_REASON) ++@skipIf(not HAS_PYVMOMI, 'The \'pyvmomi\' library is missing') ++class DisconnectTestCase(TestCase): ++ '''Tests for salt.utils.vmware.disconnect''' ++ ++ def setUp(self): ++ self.mock_si = MagicMock() ++ ++ def test_disconnect(self): ++ mock_disconnect = MagicMock() ++ with patch('salt.utils.vmware.Disconnect', mock_disconnect): ++ salt.utils.vmware.disconnect( ++ service_instance=self.mock_si) ++ mock_disconnect.assert_called_once_with(self.mock_si) ++ ++ def test_disconnect_raise_vim_fault(self): ++ exc = vim.fault.VimFault() ++ exc.msg = 'VimFault msg' ++ with patch('salt.utils.vmware.Disconnect', MagicMock(side_effect=exc)): ++ with self.assertRaises(excs.VMwareApiError) as excinfo: ++ salt.utils.vmware.disconnect( ++ service_instance=self.mock_si) ++ self.assertEqual(excinfo.exception.strerror, 'VimFault msg') ++ ++ def test_disconnect_raise_runtime_fault(self): ++ exc = vmodl.RuntimeFault() ++ exc.msg = 'RuntimeFault msg' ++ with patch('salt.utils.vmware.Disconnect', MagicMock(side_effect=exc)): ++ with self.assertRaises(excs.VMwareRuntimeError) as excinfo: ++ salt.utils.vmware.disconnect( ++ service_instance=self.mock_si) ++ self.assertEqual(excinfo.exception.strerror, 'RuntimeFault msg') ++ ++ + @skipIf(NO_MOCK, NO_MOCK_REASON) + @skipIf(not HAS_PYVMOMI, 'The \'pyvmomi\' library is missing') + class IsConnectionToAVCenterTestCase(TestCase): +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,7 @@ ++H4sIAAAAAAAAA+3STUvDMBgH8J37KR7ZRQ9r+rJuJwUPwk46dBdPo2ue2UKbjCbtGOzDm1Z8QdAd ++3BDx/zs0aRKePPRff9UUpVyyasXgVAJnmiT96Hwe+3mYRGEUB9F07M6F4SSIBpScrKMPGmPTmmhQ ++a22/O3do/4/y3/O3bOwy01WVKumb/Hh3HMo/niZv+U/Gsct/PImCAQXHa+Fr/zz/4ZlYFUqsUpN7 ++maT+J1ix9Lwh3SjT1Ezznc21otgPQyoMpZktWqZzxSxZ0lrXZHO3rktJD2lpKdOSXTm+8CS3I7Mt ++bJbTpi8Sv1SJroTbEqopS9rvydYNd/fdN8qVYnJ5PLGlrhNaFyV788fF7O52fr2YXb7291ZwVHXT ++7mj3MKJRhRWNLUoj2mqb1rzs1kWmlWLXuVb9u7/Z0aj1fvvjAwAAAAAAAAAAAAAAAAAAAAD80DO0 ++u9N0ACgAAA== +diff --git 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-002564/tests/test.sh b/tasks/format-code-task-002564/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..83f9ac9fc677324c8d0ceb6ee07d626821925fcd --- /dev/null +++ b/tasks/format-code-task-002564/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/utils/vmware_test/connection_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002564/tests/test_command.sh b/tasks/format-code-task-002564/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002564/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002590/environment/Dockerfile b/tasks/format-code-task-002590/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f3b1cf6db5d49d5496d775d1c9cc245b30517be3 --- /dev/null +++ b/tasks/format-code-task-002590/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c3e7b43617ac69253c4a00f1a62878392e40fb4262f2baab1485fb0e4d1733bb diff --git a/tasks/format-code-task-002590/environment/setup/files/blocklist b/tasks/format-code-task-002590/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002590/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002590/environment/setup/setup.sh b/tasks/format-code-task-002590/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002590/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002590/tests/test.patch b/tasks/format-code-task-002590/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..67a3fbe06a67807930b0742232499589fc72c4f7 --- /dev/null +++ b/tasks/format-code-task-002590/tests/test.patch @@ -0,0 +1,349 @@ +diff --git a/usercase-test-coderl/spritemap.test.js b/usercase-test-coderl/spritemap.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/spritemap.test.js +@@ -0,0 +1,324 @@ ++const assert = require('assert'); ++const fs = require('fs'); ++const path = require('path'); ++const vm = require('vm'); ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++function loadIioInBrowserVm() { ++ let imageCount = 0; ++ const context = { ++ console, ++ setTimeout, ++ clearTimeout, ++ window: { ++ addEventListener() {}, ++ attachEvent() {}, ++ setTimeout, ++ clearTimeout, ++ }, ++ document: {}, ++ }; ++ ++ context.global = context; ++ context.Image = class FakeImage { ++ constructor() { ++ this.id = ++imageCount; ++ this.src = ''; ++ this.onload = null; ++ } ++ }; ++ context.__imageCount = () => imageCount; ++ ++ vm.createContext(context); ++ [ ++ 'src/core/core.js', ++ 'src/core/Interface.js', ++ 'src/libs/key.js', ++ 'src/libs/convert.js', ++ 'src/data/Vector.js', ++ 'src/data/SpriteMap.js', ++ ].forEach((file) => { ++ const source = fs.readFileSync(path.join('/workspace/repo', file), 'utf8'); ++ vm.runInContext(source, context, { filename: file }); ++ }); ++ ++ return context; ++} ++ ++function runFixture(source) { ++ const context = loadIioInBrowserVm(); ++ context.__result = undefined; ++ vm.runInContext(` ++ function __findSheetImage(map) { ++ var names = Object.getOwnPropertyNames(map); ++ for (var i = 0; i < names.length; i += 1) { ++ if (map[names[i]] instanceof Image) return map[names[i]]; ++ } ++ return null; ++ } ++ __result = (function () { ${source} })(); ++ `, context); ++ return JSON.parse(JSON.stringify(context.__result)); ++} ++ ++function test(name, fn) { ++ try { ++ fn(); ++ console.log(`ok - ${name}`); ++ } catch (error) { ++ console.error(`not ok - ${name}`); ++ throw error; ++ } ++} ++ ++test('constructor stores sheet image and invokes onLoad from the image', () => { ++ ++ ++ ++ ++ const actual = runFixture(` ++ var loadCount = 0; ++ var loadSrc = ''; ++ var map = new iio.SpriteMap('assets/hero-sheet.png', function () { ++ loadCount += 1; ++ loadSrc = this.src; ++ }); ++ var sheet = __findSheetImage(map); ++ var beforeLoad = { ++ hasExposedImage: sheet instanceof Image, ++ imgSrc: sheet && sheet.src, ++ onloadType: sheet && typeof sheet.onload ++ }; ++ sheet.onload.call(sheet); ++ return { ++ beforeLoad: beforeLoad, ++ afterLoad: { loadCount: loadCount, loadSrc: loadSrc } ++ }; ++ `); ++ ++ assert.deepStrictEqual(actual, { ++ beforeLoad: { ++ ++ hasExposedImage: true, ++ imgSrc: 'assets/hero-sheet.png', ++ onloadType: 'function', ++ }, ++ afterLoad: { ++ loadCount: 1, ++ loadSrc: 'assets/hero-sheet.png', ++ }, ++ }); ++}); ++ ++test('sprite merges config objects and generates sequential frames', () => { ++ ++ ++ ++ ++ const actual = runFixture(` ++ var map = new iio.SpriteMap('assets/hero-sheet.png'); ++ var sheet = __findSheetImage(map); ++ var walk = map.sprite( ++ { width: 16, height: 32 }, ++ { name: 'walk', origin: [0, 64], numFrames: 3 } ++ ); ++ return { ++ name: walk.name, ++ numFrames: walk.numFrames, ++ frames: walk.frames.map(function (frame) { ++ return { ++ x: frame.x, ++ y: frame.y, ++ w: frame.w, ++ h: frame.h, ++ usesMapImage: frame.src === sheet ++ }; ++ }) ++ }; ++ `); ++ ++ assert.deepStrictEqual(actual, { ++ name: 'walk', ++ numFrames: 3, ++ frames: [ ++ ++ { x: 0, y: 64, w: 16, h: 32, usesMapImage: true }, ++ { x: 16, y: 64, w: 16, h: 32, usesMapImage: true }, ++ { x: 32, y: 64, w: 16, h: 32, usesMapImage: true }, ++ ], ++ }); ++}); ++ ++test('sprite defaults omitted numFrames to one frame', () => { ++ ++ ++ ++ ++ const actual = runFixture(` ++ var map = new iio.SpriteMap('assets/hero-sheet.png'); ++ var sheet = __findSheetImage(map); ++ var idle = map.sprite({ width: 8, height: 8, name: 'idle', origin: [24, 10] }); ++ return { ++ name: idle.name, ++ numFrames: idle.numFrames, ++ frames: idle.frames.map(function (frame) { ++ return { ++ x: frame.x, ++ y: frame.y, ++ w: frame.w, ++ h: frame.h, ++ usesMapImage: frame.src === sheet ++ }; ++ }) ++ }; ++ `); ++ ++ assert.deepStrictEqual(actual, { ++ name: 'idle', ++ numFrames: 1, ++ frames: [ ++ ++ { x: 24, y: 10, w: 8, h: 8, usesMapImage: true }, ++ ], ++ }); ++}); ++ ++test('sprite uses explicit frames while completing only missing fields', () => { ++ ++ ++ ++ ++ const actual = runFixture(` ++ var map = new iio.SpriteMap('assets/hero-sheet.png'); ++ var sheet = __findSheetImage(map); ++ var explicitSrc = { id: 999 }; ++ var suppliedFrames = [ ++ { x: 5, y: 6 }, ++ { x: 7, y: 8, w: 9, h: 10, src: explicitSrc } ++ ]; ++ var jump = map.sprite( ++ { width: 12, height: 14 }, ++ { name: 'jump', frames: suppliedFrames } ++ ); ++ return { ++ name: jump.name, ++ frameCount: jump.frames.length, ++ frames: jump.frames.map(function (frame) { ++ return { ++ x: frame.x, ++ y: frame.y, ++ w: frame.w, ++ h: frame.h, ++ usesMapImage: frame.src === sheet, ++ usesExplicitSrc: frame.src === explicitSrc ++ }; ++ }) ++ }; ++ `); ++ ++ assert.deepStrictEqual(actual, { ++ name: 'jump', ++ ++ frameCount: 2, ++ frames: [ ++ ++ { x: 5, y: 6, w: 12, h: 14, usesMapImage: true, usesExplicitSrc: false }, ++ { x: 7, y: 8, w: 9, h: 10, usesMapImage: false, usesExplicitSrc: true }, ++ ], ++ }); ++}); ++ ++test('two SpriteMap instances keep independent image state', () => { ++ ++ ++ ++ ++ const actual = runFixture(` ++ var a = new iio.SpriteMap('a.png'); ++ var b = new iio.SpriteMap('b.png'); ++ var aSheet = __findSheetImage(a); ++ var bSheet = __findSheetImage(b); ++ var aAnim = a.sprite({ width: 2, height: 3, name: 'a', origin: [4, 5] }); ++ var bAnim = b.sprite({ width: 6, height: 7, name: 'b', origin: [8, 9] }); ++ return { ++ aSrc: aSheet && aSheet.src, ++ bSrc: bSheet && bSheet.src, ++ differentImages: aSheet !== bSheet, ++ aFrame: { ++ x: aAnim.frames[0].x, ++ y: aAnim.frames[0].y, ++ w: aAnim.frames[0].w, ++ h: aAnim.frames[0].h, ++ usesOwnImage: aAnim.frames[0].src === aSheet, ++ usesOtherImage: aAnim.frames[0].src === bSheet ++ }, ++ bFrame: { ++ x: bAnim.frames[0].x, ++ y: bAnim.frames[0].y, ++ w: bAnim.frames[0].w, ++ h: bAnim.frames[0].h, ++ usesOwnImage: bAnim.frames[0].src === bSheet, ++ usesOtherImage: bAnim.frames[0].src === aSheet ++ } ++ }; ++ `); ++ ++ assert.deepStrictEqual(actual, { ++ ++ aSrc: 'a.png', ++ bSrc: 'b.png', ++ differentImages: true, ++ aFrame: { x: 4, y: 5, w: 2, h: 3, usesOwnImage: true, usesOtherImage: false }, ++ bFrame: { x: 8, y: 9, w: 6, h: 7, usesOwnImage: true, usesOtherImage: false }, ++ }); ++}); ++ ++test('repeated construct and sprite cycles allocate one image per map only', () => { ++ ++ ++ ++ ++ const actual = runFixture(` ++ var lastFrame = null; ++ var allFramesUseMapImage = true; ++ for (var i = 0; i < 120; i += 1) { ++ var map = new iio.SpriteMap('sheet-' + i + '.png'); ++ var sheet = __findSheetImage(map); ++ var anim = map.sprite({ width: 3, height: 4, name: 'cycle', origin: [i, 2] }); ++ allFramesUseMapImage = allFramesUseMapImage && anim.frames[0].src === sheet; ++ lastFrame = { ++ x: anim.frames[0].x, ++ y: anim.frames[0].y, ++ w: anim.frames[0].w, ++ h: anim.frames[0].h, ++ src: anim.frames[0].src.src ++ }; ++ } ++ return { ++ enoughImagesForConstructedMaps: __imageCount() >= 120, ++ allFramesUseMapImage: allFramesUseMapImage, ++ lastFrame: lastFrame ++ }; ++ `); ++ ++ assert.deepStrictEqual(actual, { ++ ++ enoughImagesForConstructedMaps: true, ++ allFramesUseMapImage: true, ++ lastFrame: { ++ x: 119, ++ y: 2, ++ w: 3, ++ h: 4, ++ src: 'sheet-119.png', ++ }, ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++exec node /workspace/repo/usercase-test-coderl/spritemap.test.js diff --git a/tasks/format-code-task-002590/tests/test.sh b/tasks/format-code-task-002590/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..941e1340d63b0bf28a0d55beda31133bbf8d222e --- /dev/null +++ b/tasks/format-code-task-002590/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/spritemap.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-002590/tests/test_command.sh b/tasks/format-code-task-002590/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002590/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-002597/environment/Dockerfile b/tasks/format-code-task-002597/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9c5f0a807a376066155a56b63f21b09b42fca829 --- /dev/null +++ b/tasks/format-code-task-002597/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:458613973f61cbaf918f96d40099a0cfddb3d357823c79bcbd17d65bc6ab8ed7 diff --git a/tasks/format-code-task-002597/environment/setup/files/blocklist b/tasks/format-code-task-002597/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002597/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002597/environment/setup/setup.sh b/tasks/format-code-task-002597/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002597/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002597/tests/test.patch b/tasks/format-code-task-002597/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..819fc1dfdde78ceb3a0bacd50f81f1ea8b688cad --- /dev/null +++ b/tasks/format-code-task-002597/tests/test.patch @@ -0,0 +1,345 @@ +diff --git a/usercase-test-coderl/getbpm_acceptance_test.go b/usercase-test-coderl/getbpm_acceptance_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/getbpm_acceptance_test.go +@@ -0,0 +1,315 @@ ++package usercase_test_coderl ++ ++ ++ ++ ++ ++ ++import ( ++ "encoding/binary" ++ "math" ++ "os" ++ "path/filepath" ++ "reflect" ++ "testing" ++ ++ trackeraudio "github.com/schollz/collidertracker/internal/audio" ++ "github.com/schollz/collidertracker/internal/getbpm" ++ "github.com/schollz/collidertracker/internal/model" ++ "github.com/schollz/collidertracker/internal/types" ++) ++ ++type expectedTiming struct { ++ beats float64 ++ bpm float64 ++} ++ ++func writeSilentWAV(t *testing.T, path string, seconds float64) { ++ t.Helper() ++ ++ const sampleRate = 44100 ++ frames := int(math.Round(seconds * sampleRate)) ++ dataBytes := frames * 2 ++ ++ f, err := os.Create(path) ++ if err != nil { ++ t.Fatalf("create wav: %v", err) ++ } ++ defer f.Close() ++ ++ mustWrite := func(data any) { ++ t.Helper() ++ var err error ++ switch v := data.(type) { ++ case []byte: ++ _, err = f.Write(v) ++ default: ++ err = binary.Write(f, binary.LittleEndian, v) ++ } ++ if err != nil { ++ t.Fatalf("write wav: %v", err) ++ } ++ } ++ ++ mustWrite([]byte("RIFF")) ++ mustWrite(uint32(36 + dataBytes)) ++ mustWrite([]byte("WAVE")) ++ mustWrite([]byte("fmt ")) ++ mustWrite(uint32(16)) ++ mustWrite(uint16(1)) ++ mustWrite(uint16(1)) ++ mustWrite(uint32(sampleRate)) ++ mustWrite(uint32(sampleRate * 2)) ++ mustWrite(uint16(2)) ++ mustWrite(uint16(16)) ++ mustWrite([]byte("data")) ++ mustWrite(uint32(dataBytes)) ++ mustWrite(make([]byte, dataBytes)) ++} ++ ++func makeWAV(t *testing.T, name string, seconds float64) string { ++ t.Helper() ++ path := filepath.Join(t.TempDir(), name) ++ writeSilentWAV(t, path, seconds) ++ return path ++} ++ ++func assertTiming(t *testing.T, path string, expected expectedTiming) { ++ t.Helper() ++ beats, bpm, err := getbpm.GetBPM(path) ++ if err != nil { ++ t.Fatalf("GetBPM(%q) err = %v", path, err) ++ } ++ ++ if math.Abs(beats-expected.beats) > 0.25 || math.Abs(bpm-expected.bpm) > 0.25 { ++ t.Fatalf("GetBPM(%q) = beats %.10f bpm %.10f, want about beats %.10f bpm %.10f", path, beats, bpm, expected.beats, expected.bpm) ++ } ++} ++ ++func assertEqualSlices(t *testing.T, onsets []float64, duration float64, slices int) { ++ t.Helper() ++ if len(onsets) != slices { ++ t.Fatalf("onsets length = %d, want inferred slice count %d", len(onsets), slices) ++ } ++ if slices == 0 { ++ return ++ } ++ if math.Abs(onsets[0]) > 1e-9 { ++ t.Fatalf("first equal slice = %.10f, want 0", onsets[0]) ++ } ++ step := duration / float64(slices) ++ for i, onset := range onsets { ++ want := float64(i) * step ++ if math.Abs(onset-want) > 1e-6 { ++ t.Fatalf("onset %d = %.10f, want equal slice position %.10f", i, onset, want) ++ } ++ } ++} ++ ++func TestGetBPMExplicitBeatsThenBPMMetadata(t *testing.T) { ++ ++ ++ path := makeWAV(t, "amen_beats8_bpm172.wav", 8*60.0/172.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 8, bpm: 172}) ++} ++ ++func TestGetBPMExplicitBPMThenBeatsMetadataCaseInsensitive(t *testing.T) { ++ ++ ++ path := makeWAV(t, "HANDS_BPM176_BEATS32.WAV", 32*60.0/176.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 32, bpm: 176}) ++} ++ ++func TestGetBPMTempoOnlyFallsBackWhenParsedBeatCountIsUnsuitable(t *testing.T) { ++ ++ ++ path := makeWAV(t, "Break120.wav", 6.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 16, bpm: 160}) ++} ++ ++func TestGetBPMTempoBelowRangeFallsBackToDurationGuess(t *testing.T) { ++ ++ ++ path := makeWAV(t, "Break078.wav", 3.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 8, bpm: 160}) ++} ++ ++func TestGetBPMTempoAboveRangeFallsBackToDurationGuess(t *testing.T) { ++ ++ ++ path := makeWAV(t, "tempo_bpm205_beats16.wav", 6.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 16, bpm: 160}) ++} ++ ++func TestGetBPMExplicitNonBoundaryBeatsFallsBackToDurationGuess(t *testing.T) { ++ ++ ++ path := makeWAV(t, "odd_beats15_bpm150.wav", 6.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 16, bpm: 160}) ++} ++ ++func TestGetBPMDurationOnlyMissingFilenameMetadata(t *testing.T) { ++ ++ ++ path := makeWAV(t, "strega.wav", 28.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 56, bpm: 120}) ++} ++ ++func TestGetBPMPrefersPowerOfTwoBeatCountsWhenDurationMatchesTie(t *testing.T) { ++ ++ ++ path := makeWAV(t, "tie.wav", 6.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 16, bpm: 160}) ++} ++ ++func TestGetBPMUsesMultipleEnvironmentVariable(t *testing.T) { ++ ++ ++ t.Setenv("MULTIPLE", "4") ++ path := makeWAV(t, "multiple.wav", 7.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 16, bpm: 137}) ++} ++ ++func TestGetBPMZeroMultipleFallsBackToDefaultMultiplier(t *testing.T) { ++ ++ ++ t.Setenv("MULTIPLE", "0") ++ path := makeWAV(t, "multiple.wav", 7.0) ++ ++ assertTiming(t, path, expectedTiming{beats: 14, bpm: 120}) ++} ++ ++func TestSelectFileInitializesSamplerMetadataAndEqualSlices(t *testing.T) { ++ ++ ++ currentDir := t.TempDir() ++ saveDir := t.TempDir() ++ audioPath := filepath.Join(currentDir, "Break120.wav") ++ writeSilentWAV(t, audioPath, 6.0) ++ ++ m := model.NewModel(0, saveDir, false) ++ m.Files = []string{"Break120.wav"} ++ m.CurrentDir = currentDir ++ m.CurrentRow = 0 ++ m.CurrentPhrase = 1 ++ m.FileSelectRow = 2 ++ m.CurrentTrack = 0 ++ ++ trackeraudio.SelectFile(m) ++ ++ metadata, ok := m.FileMetadata[audioPath] ++ if !ok { ++ t.Fatalf("metadata missing for selected file %q", audioPath) ++ } ++ expectedWaveform := filepath.Join(saveDir, "waveforms", "Break120_waveform.wav") ++ if metadata.BPM != 160 || metadata.Slices != 32 || metadata.SliceType != 0 || metadata.Playthrough != 0 || metadata.SyncToBPM != 1 || metadata.WaveformFile != expectedWaveform { ++ t.Fatalf("metadata = %#v, want BPM 160 Slices 32 SliceType 0 Playthrough 0 SyncToBPM 1 WaveformFile %q", metadata, expectedWaveform) ++ } ++ ++ assertEqualSlices(t, metadata.Onsets, 6.0, 32) ++ ++ phrasesData := m.GetCurrentPhrasesData() ++ if got := (*phrasesData)[1][2][int(types.ColFilename)]; got != 0 { ++ t.Fatalf("selected phrase file index = %d, want 0", got) ++ } ++ if !reflect.DeepEqual(m.SamplerPhrasesFiles, []string{audioPath}) { ++ t.Fatalf("sampler phrase files = %#v, want %#v", m.SamplerPhrasesFiles, []string{audioPath}) ++ } ++} ++ ++func TestGetBPMReturnsSpecificErrorWhenWAVCannotBeOpened(t *testing.T) { ++ path := filepath.Join(t.TempDir(), "missing.wav") ++ ++ _, _, err := getbpm.GetBPM(path) ++ ++ if err == nil { ++ t.Fatalf("GetBPM missing file err = nil, want non-nil error") ++ } ++} ++ ++func TestGetBPMReferentialTransparency(t *testing.T) { ++ path := makeWAV(t, "stable.wav", 9.0) ++ ++ beats1, bpm1, err1 := getbpm.GetBPM(path) ++ beats2, bpm2, err2 := getbpm.GetBPM(path) ++ if err1 != nil || err2 != nil { ++ t.Fatalf("GetBPM repeated errors = %v, %v", err1, err2) ++ } ++ if beats1 != beats2 || bpm1 != bpm2 { ++ t.Fatalf("GetBPM repeated result changed: first %.10f/%.10f second %.10f/%.10f", beats1, bpm1, beats2, bpm2) ++ } ++} ++ ++func TestGetBPMDoesNotMutateCallerInput(t *testing.T) { ++ pathBytes := []byte(makeWAV(t, "immutable.wav", 3.0)) ++ before := append([]byte(nil), pathBytes...) ++ ++ assertTiming(t, string(pathBytes), expectedTiming{beats: 8, bpm: 160}) ++ if !reflect.DeepEqual(pathBytes, before) { ++ t.Fatalf("caller input mutated: got %q want %q", string(pathBytes), string(before)) ++ } ++} ++ ++func TestGetBPMNoGlobalStateWithNoiseInjection(t *testing.T) { ++ target := makeWAV(t, "target.wav", 9.0) ++ noiseA := makeWAV(t, "amen_beats8_bpm172.wav", 8*60.0/172.0) ++ noiseB := makeWAV(t, "Break078.wav", 3.0) ++ ++ beats1, bpm1, err := getbpm.GetBPM(target) ++ if err != nil { ++ t.Fatalf("target first call err = %v", err) ++ } ++ assertTiming(t, noiseA, expectedTiming{beats: 8, bpm: 172}) ++ assertTiming(t, noiseB, expectedTiming{beats: 8, bpm: 160}) ++ beats2, bpm2, err := getbpm.GetBPM(target) ++ if err != nil { ++ t.Fatalf("target second call err = %v", err) ++ } ++ if beats1 != 18 || bpm1 != 120 || beats2 != 18 || bpm2 != 120 { ++ t.Fatalf("target timing around noise = first %.10f/%.10f second %.10f/%.10f, want both 18/120", beats1, bpm1, beats2, bpm2) ++ } ++} ++ ++func TestGetBPMDoesNotCreateUndeclaredFilesInWorkingDirectory(t *testing.T) { ++ workDir := t.TempDir() ++ path := filepath.Join(workDir, "pure.wav") ++ writeSilentWAV(t, path, 3.0) ++ ++ before := directoryEntries(t, workDir) ++ originalWD, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("getwd: %v", err) ++ } ++ if err := os.Chdir(workDir); err != nil { ++ t.Fatalf("chdir: %v", err) ++ } ++ defer os.Chdir(originalWD) ++ ++ assertTiming(t, path, expectedTiming{beats: 8, bpm: 160}) ++ after := directoryEntries(t, workDir) ++ if !reflect.DeepEqual(before, after) { ++ t.Fatalf("working directory entries changed: before %#v after %#v", before, after) ++ } ++} ++ ++func directoryEntries(t *testing.T, dir string) []string { ++ t.Helper() ++ entries, err := os.ReadDir(dir) ++ if err != nil { ++ t.Fatalf("readdir: %v", err) ++ } ++ names := make([]string, len(entries)) ++ for i, entry := range entries { ++ names[i] = entry.Name() ++ } ++ 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,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 GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GONOPROXY='*' ++export GONOSUMDB='*' ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002597/tests/test.sh b/tasks/format-code-task-002597/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0494e48dd96ce68894413eec9c48aeebdc9f4d35 --- /dev/null +++ b/tasks/format-code-task-002597/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/getbpm_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-002597/tests/test_command.sh b/tasks/format-code-task-002597/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002597/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-002599/environment/Dockerfile b/tasks/format-code-task-002599/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..807d3287a7c1f9e485028eaff2413d7d9eec0b36 --- /dev/null +++ b/tasks/format-code-task-002599/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fbbe13ffb36178bc4f36171523df24f4fad477170f4b08587945b8340ea2e6ff diff --git a/tasks/format-code-task-002599/environment/setup/files/blocklist b/tasks/format-code-task-002599/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002599/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002599/environment/setup/setup.sh b/tasks/format-code-task-002599/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002599/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002599/tests/test.patch b/tasks/format-code-task-002599/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c92c63663c9e28349288092d7c303a1c4e194de3 --- /dev/null +++ b/tasks/format-code-task-002599/tests/test.patch @@ -0,0 +1,325 @@ +diff --git a/usercase-test-coderl/test_importers.py b/usercase-test-coderl/test_importers.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_importers.py +@@ -0,0 +1,293 @@ ++ ++ ++ ++import json ++ ++from pybossa.importers import ImportReport, Importer ++ ++ ++DEFAULT_IMPORTERS = ["csv", "gdocs", "epicollect", "s3", "localCSV", "iiif"] ++DEFAULT_AUTOIMPORTERS = ["csv", "gdocs", "epicollect", "localCSV", "iiif"] ++REGISTERED_IMPORTERS = [ ++ "csv", ++ "gdocs", ++ "epicollect", ++ "s3", ++ "localCSV", ++ "iiif", ++ "flickr", ++ "dropbox", ++ "twitter", ++ "youtube", ++] ++REGISTERED_AUTOIMPORTERS = [ ++ "csv", ++ "gdocs", ++ "epicollect", ++ "localCSV", ++ "iiif", ++ "flickr", ++ "twitter", ++ "youtube", ++] ++ ++ ++def assert_names_match(actual_names, expected_names): ++ ++ actual_names = list(actual_names) ++ assert set(actual_names) == set(expected_names) ++ assert len(actual_names) == len(expected_names) ++ ++ ++class TaskRepoStub: ++ def __init__(self, existing=None): ++ self.existing = set(existing or []) ++ self.saved = [] ++ ++ def get_task_by(self, project_id, info): ++ key = (project_id, json.dumps(info, sort_keys=True)) ++ return object() if key in self.existing else None ++ ++ def save(self, task): ++ self.saved.append(task) ++ ++ ++def task_key(project_id, info): ++ return (project_id, json.dumps(info, sort_keys=True)) ++ ++ ++def install_fake_flickr_importer(monkeypatch, payload, metadata): ++ init_calls = [] ++ ++ class FakeFlickrImporter: ++ def __init__(self, **kwargs): ++ init_calls.append(kwargs) ++ ++ def count_tasks(self): ++ return len(payload) ++ ++ def tasks(self): ++ return list(payload) ++ ++ def import_metadata(self): ++ return metadata ++ ++ monkeypatch.setattr("pybossa.importers.importer.BulkTaskFlickrImport", FakeFlickrImporter) ++ return init_calls ++ ++ ++def test_default_and_registered_importer_names(): ++ ++ ++ ++ importer = Importer() ++ assert_names_match(importer.get_all_importer_names(), DEFAULT_IMPORTERS) ++ assert_names_match(importer.get_autoimporter_names(), DEFAULT_AUTOIMPORTERS) ++ ++ importer.register_flickr_importer({"api_key": "api-123"}) ++ importer.register_dropbox_importer() ++ importer.register_twitter_importer({"consumer_key": "twitter-key"}) ++ importer.register_youtube_importer({"api_key": "youtube-key"}) ++ ++ assert_names_match(importer.get_all_importer_names(), REGISTERED_IMPORTERS) ++ assert_names_match(importer.get_autoimporter_names(), REGISTERED_AUTOIMPORTERS) ++ ++ ++def test_importer_instances_keep_independent_registries(): ++ ++ ++ ++ a = Importer() ++ b = Importer() ++ ++ a.register_flickr_importer({"api_key": "api-123"}) ++ a.register_dropbox_importer() ++ ++ assert_names_match(a.get_all_importer_names(), [ ++ "csv", ++ "gdocs", ++ "epicollect", ++ "s3", ++ "localCSV", ++ "iiif", ++ "flickr", ++ "dropbox", ++ ]) ++ assert_names_match(a.get_autoimporter_names(), [ ++ "csv", ++ "gdocs", ++ "epicollect", ++ "localCSV", ++ "iiif", ++ "flickr", ++ ]) ++ assert_names_match(b.get_all_importer_names(), DEFAULT_IMPORTERS) ++ assert_names_match(b.get_autoimporter_names(), DEFAULT_AUTOIMPORTERS) ++ ++ ++def test_count_tasks_to_import_merges_registered_flickr_credentials(monkeypatch): ++ ++ ++ ++ init_calls = install_fake_flickr_importer( ++ monkeypatch, ++ [ ++ {"info": {"question": "question"}}, ++ {"info": {"question": "second question"}}, ++ ], ++ {"source": "flickr", "page": 1}, ++ ) ++ ++ importer = Importer() ++ importer.register_flickr_importer({"api_key": "api-123"}) ++ ++ count = importer.count_tasks_to_import(type="flickr", album_id="album-456") ++ ++ assert init_calls == [{"api_key": "api-123", "album_id": "album-456"}] ++ assert count == 2 ++ ++ ++def test_flickr_unavailable_before_registration(): ++ ++ ++ ++ importer = Importer() ++ ++ ++ assert "flickr" not in set(importer.get_all_importer_names()) ++ assert "flickr" not in set(importer.get_autoimporter_names()) ++ ++ ++def test_create_tasks_saves_one_new_task_and_returns_singular_report_with_metadata(monkeypatch): ++ ++ ++ ++ install_fake_flickr_importer( ++ monkeypatch, ++ [ ++ { ++ "info": {"question": "question"}, ++ "state": "ongoing", ++ "n_answers": 5, ++ "priority_0": 0.25, ++ } ++ ], ++ {"source": "flickr", "page": 1}, ++ ) ++ ++ importer = Importer() ++ importer.register_flickr_importer({"api_key": "api-123"}) ++ repo = TaskRepoStub() ++ ++ report = importer.create_tasks(repo, 17, type="flickr", album_id="album-456") ++ ++ assert report.message == "1 new task was imported successfully" ++ assert report.metadata == {"source": "flickr", "page": 1} ++ assert report.total == 1 ++ assert len(repo.saved) == 1 ++ saved = repo.saved[0] ++ assert saved.project_id == 17 ++ assert saved.info == {"question": "question"} ++ assert saved.state == "ongoing" ++ assert saved.n_answers == 5 ++ assert saved.priority_0 == 0.25 ++ ++ ++def test_create_tasks_saves_two_new_tasks_and_returns_plural_report(monkeypatch): ++ ++ ++ ++ install_fake_flickr_importer( ++ monkeypatch, ++ [ ++ { ++ "info": {"question": "question"}, ++ "state": "ongoing", ++ "n_answers": 5, ++ "priority_0": 0.25, ++ }, ++ { ++ "info": {"question": "second question"}, ++ "state": "completed", ++ "n_answers": 2, ++ "quorum": 1, ++ }, ++ ], ++ {"source": "flickr", "page": 2}, ++ ) ++ ++ importer = Importer() ++ importer.register_flickr_importer({"api_key": "api-123"}) ++ repo = TaskRepoStub() ++ ++ report = importer.create_tasks(repo, 17, type="flickr", album_id="album-456") ++ ++ assert report.message == "2 new tasks were imported successfully" ++ assert report.metadata == {"source": "flickr", "page": 2} ++ assert report.total == 2 ++ assert len(repo.saved) == 2 ++ ++ saved_by_question = {task.info["question"]: task for task in repo.saved} ++ assert set(saved_by_question) == {"question", "second question"} ++ first = saved_by_question["question"] ++ assert first.project_id == 17 ++ assert first.info == {"question": "question"} ++ assert first.state == "ongoing" ++ assert first.n_answers == 5 ++ second = saved_by_question["second question"] ++ assert second.project_id == 17 ++ assert second.info == {"question": "second question"} ++ assert second.state == "completed" ++ assert second.n_answers == 2 ++ assert second.quorum == 1 ++ ++ ++def test_create_tasks_returns_empty_report_for_duplicates_and_empty_sources(monkeypatch): ++ ++ ++ ++ install_fake_flickr_importer( ++ monkeypatch, ++ [ ++ { ++ "info": {"question": "question"}, ++ "state": "ongoing", ++ } ++ ], ++ {"source": "flickr", "page": 3}, ++ ) ++ duplicate_repo = TaskRepoStub(existing=[task_key(17, {"question": "question"})]) ++ duplicate_importer = Importer() ++ duplicate_importer.register_flickr_importer({"api_key": "api-123"}) ++ ++ duplicate_report = duplicate_importer.create_tasks( ++ duplicate_repo, 17, type="flickr", album_id="album-456" ++ ) ++ ++ assert duplicate_report.message == "It looks like there were no new records to import" ++ assert duplicate_report.metadata is None ++ assert duplicate_report.total == 0 ++ assert duplicate_repo.saved == [] ++ ++ install_fake_flickr_importer(monkeypatch, [], {"source": "flickr", "page": 4}) ++ empty_repo = TaskRepoStub() ++ empty_importer = Importer() ++ empty_importer.register_flickr_importer({"api_key": "api-123"}) ++ ++ empty_report = empty_importer.create_tasks(empty_repo, 17, type="flickr", album_id="album-456") ++ ++ assert empty_report.message == "It looks like there were no new records to import" ++ assert empty_report.metadata is None ++ assert empty_report.total == 0 ++ assert empty_repo.saved == [] ++ ++ ++def test_import_report_exposes_message_metadata_and_total(): ++ ++ ++ ++ report = ImportReport("1 new task was imported successfully", {"source": "flickr"}, 1) ++ ++ assert report.message == "1 new task was imported successfully" ++ assert report.metadata == {"source": "flickr"} ++ assert report.total == 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,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 PIP_NO_INDEX=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_importers.py -v diff --git a/tasks/format-code-task-002599/tests/test.sh b/tasks/format-code-task-002599/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..40f7ed99f824a5efe48e7fd95af7d4ca1bba76e5 --- /dev/null +++ b/tasks/format-code-task-002599/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_importers.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-002599/tests/test_command.sh b/tasks/format-code-task-002599/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002599/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-002702/environment/Dockerfile b/tasks/format-code-task-002702/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fa1cba05624ca0527216032edb2aaa185ea60ccd --- /dev/null +++ b/tasks/format-code-task-002702/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bd73817fd15d73a33f2a4e77405508991ce2810af40dad53db0654be0a90e71d diff --git a/tasks/format-code-task-002702/environment/setup/files/blocklist b/tasks/format-code-task-002702/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002702/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002702/environment/setup/setup.sh b/tasks/format-code-task-002702/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002702/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002702/tests/test.patch b/tasks/format-code-task-002702/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7dde864854502aac9f8afc66b1cb5661d4bfb2b7 --- /dev/null +++ b/tasks/format-code-task-002702/tests/test.patch @@ -0,0 +1,81 @@ +diff --git a/test/inputs.test.js b/test/inputs.test.js +index 3766d0c3..9a3b7c1d 100644 +--- a/test/inputs.test.js ++++ b/test/inputs.test.js +@@ -122,3 +122,24 @@ test('funny-numeric-forms', t => { + t.equal(a.format('numeric'), b.format('numeric'), 'dd/mm/yyyy') + t.end(); + }); ++ ++test('invalid calendar dates are not normalized into valid dates', t => { ++ t.equal(spacetime('February 30 2018').isValid(), false, 'reported impossible date is invalid'); ++ t.equal(spacetime('Feb 29 2015').isValid(), false, 'non-leap-year leap day is invalid'); ++ t.equal(spacetime('April 31 2018').isValid(), false, '31st day in a 30-day month is invalid'); ++ t.equal(spacetime('2018-02-30').isValid(), false, 'numeric impossible date is invalid'); ++ t.equal(spacetime('February 28 2018').isValid(), true, 'ordinary valid date remains valid'); ++ t.equal(spacetime('Feb 29 2016').isValid(), true, 'valid leap day remains valid'); ++ t.equal(spacetime('2018-04-30').isValid(), true, 'numeric valid date remains valid'); ++ t.end(); ++}); ++ ++test('validity is exposed through isValid not valid boolean field', t => { ++ var valid = spacetime('February 28 2018'); ++ var invalid = spacetime('February 30 2018'); ++ t.equal(valid.isValid(), true, 'valid instance still reports through isValid'); ++ t.equal(invalid.isValid(), false, 'invalid instance still reports through isValid'); ++ t.notEqual(typeof valid.valid, 'boolean', 'valid instance does not expose boolean .valid'); ++ t.notEqual(typeof invalid.valid, 'boolean', 'invalid instance does not expose boolean .valid'); ++ t.end(); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,47 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++npm install 2>&1 ++ ++case "${1:-}" in ++ base) ++ PATTERN='^(inputs|hour-inputs|null input|arr-input|obj-input|date-input|self-input|inputs-in-comparisons|iso-string-input|funny-numeric-forms)$' ++ ;; ++ new) ++ PATTERN='^(invalid calendar dates are not normalized into valid dates|validity is exposed through isValid not valid boolean field)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac ++ ++TMP_FILE="test/.fixturea-inputs.${1}.test.js" ++trap 'rm -f "$TMP_FILE"' EXIT ++python3 - "$PATTERN" test/inputs.test.js "$TMP_FILE" <<'PY' ++import re ++import sys ++pattern = re.compile(sys.argv[1]) ++source = open(sys.argv[2]).read().splitlines(True) ++out = [] ++i = 0 ++while i < len(source): ++ line = source[i] ++ m = re.match(r"(test\(['\"])(.*?)(['\"],\s*t\s*=>\s*\{)", line) ++ if not m: ++ out.append(line) ++ i += 1 ++ continue ++ block = [line] ++ depth = line.count('{') - line.count('}') ++ i += 1 ++ while i < len(source) and depth > 0: ++ block.append(source[i]) ++ depth += source[i].count('{') - source[i].count('}') ++ i += 1 ++ if pattern.match(m.group(2)): ++ out.extend(block) ++open(sys.argv[3], 'w').writelines(out) ++PY ++TESTENV=dev npx tape "$TMP_FILE" diff --git a/tasks/format-code-task-002702/tests/test.sh b/tasks/format-code-task-002702/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..448cab9fd4efdf8d4320c39480605dea2e30e8b4 --- /dev/null +++ b/tasks/format-code-task-002702/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/inputs.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-002702/tests/test_command.sh b/tasks/format-code-task-002702/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002702/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-002732/environment/Dockerfile b/tasks/format-code-task-002732/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c5fae9586e65d47f6ce9b605596832ecd17ff82f --- /dev/null +++ b/tasks/format-code-task-002732/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:20bceaf0ca70f4c2e8c5e99f89932b6a422a13153f41695d20bc69626a6f511b diff --git a/tasks/format-code-task-002732/environment/setup/files/blocklist b/tasks/format-code-task-002732/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002732/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002732/environment/setup/setup.sh b/tasks/format-code-task-002732/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002732/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002732/tests/test.patch b/tasks/format-code-task-002732/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9a3f831b074f2aabc2b82d32763eefd7ee8473d5 --- /dev/null +++ b/tasks/format-code-task-002732/tests/test.patch @@ -0,0 +1,112 @@ +diff --git a/central/graphql/resolvers/node_cve_core_test.go b/central/graphql/resolvers/node_cve_core_test.go +index fcaad95b94704..2eea19b0d87f5 100644 +--- a/central/graphql/resolvers/node_cve_core_test.go ++++ b/central/graphql/resolvers/node_cve_core_test.go +@@ -278,7 +278,7 @@ func (s *NodeCVECoreResolverTestSuite) TestNodeCVECountBySeverity() { + s.Require().NoError(err) + expectedQ = tryUnsuppressedQuery(expectedQ) + expectedQ = noOrphanedCVEsQuery(s.T(), expectedQ) +- cbs := nodecve.NewCountByNodeCVESeverity(7, 3, 6, 2, 5, 1, 4, 0) ++ cbs := nodecve.NewCountByNodeCVESeverity(7, 3, 6, 2, 5, 1, 4, 0, 0, 0) + + s.nodeCVEView.EXPECT().CountBySeverity(s.ctx, expectedQ).Return(cbs, nil) + response, err := s.resolver.NodeCVECountBySeverity(s.ctx, *q) +@@ -312,7 +312,7 @@ func (s *NodeCVECoreResolverTestSuite) TestNodeCVECountBySeverityWithQuery() { + expectedQ := search.NewQueryBuilder().AddStrings(search.Node, "node").ProtoQuery() + expectedQ = tryUnsuppressedQuery(expectedQ) + expectedQ = noOrphanedCVEsQuery(s.T(), expectedQ) +- cbs := nodecve.NewCountByNodeCVESeverity(7, 3, 6, 2, 5, 1, 4, 0) ++ cbs := nodecve.NewCountByNodeCVESeverity(7, 3, 6, 2, 5, 1, 4, 0, 0, 0) + + s.nodeCVEView.EXPECT().CountBySeverity(s.ctx, expectedQ).Return(cbs, nil) + response, err := s.resolver.NodeCVECountBySeverity(s.ctx, *q) +@@ -402,7 +402,7 @@ func (s *NodeCVECoreResolverTestSuite) TestNodeCVESubResolvers() { + s.Equal(ts, response.FirstDiscoveredInSystem(s.ctx).Time) + + // CountByNodeCVESeverity +- sev := nodecve.NewCountByNodeCVESeverity(7, 3, 6, 2, 5, 1, 4, 0) ++ sev := nodecve.NewCountByNodeCVESeverity(7, 3, 6, 2, 5, 1, 4, 0, 0, 0) + cveCoreMock.EXPECT().GetNodeCountBySeverity().Return(sev) + sevResolver, err := response.AffectedNodeCountBySeverity(s.ctx) + s.NoError(err) +diff --git a/central/views/imagecve/view_test.go b/central/views/imagecve/view_test.go +index 0ce8aed957d6e..de4afbb1e31c4 100644 +--- a/central/views/imagecve/view_test.go ++++ b/central/views/imagecve/view_test.go +@@ -1201,6 +1201,29 @@ func TestImageCVEEdgeIsJoinedLast(t *testing.T) { + assert.ElementsMatch(t, []string{"sha2"}, imageIDs) + } + ++func TestImageCVEUnknownSeverity(t *testing.T) { ++ ctx := sac.WithAllAccess(context.Background()) ++ testDB := pgtest.ForT(t) ++ ++ ++ imageStore := imageDS.GetTestPostgresDataStore(t, testDB.DB) ++ ++ ++ images := testImages() ++ for _, image := range images { ++ assert.NoError(t, imageStore.UpsertImage(ctx, image)) ++ } ++ ++ cveView := NewCVEView(testDB.DB) ++ query := search.NewQueryBuilder(). ++ AddExactMatches(search.ImageSHA, "sha1"). ++ ProtoQuery() ++ counts, err := cveView.CountBySeverity(ctx, query) ++ assert.NoError(t, err) ++ assert.Equal(t, 3, counts.GetUnknownSeverityCount().GetTotal()) ++ assert.Equal(t, 1, counts.GetUnknownSeverityCount().GetFixable()) ++} ++ + func testImages() []*storage.Image { + t1, err := protocompat.ConvertTimeToTimestampOrError(time.Unix(0, 1000)) + utils.CrashOnError(err) +@@ -1231,6 +1254,21 @@ func testImages() []*storage.Image { + }, + Severity: storage.VulnerabilitySeverity_CRITICAL_VULNERABILITY_SEVERITY, + }, ++ { ++ Cve: "cve-2025-1", ++ SetFixedBy: &storage.EmbeddedVulnerability_FixedBy{ ++ FixedBy: "1.6", ++ }, ++ Severity: storage.VulnerabilitySeverity_UNKNOWN_VULNERABILITY_SEVERITY, ++ }, ++ { ++ Cve: "cve-2025-2", ++ Severity: storage.VulnerabilitySeverity_UNKNOWN_VULNERABILITY_SEVERITY, ++ }, ++ { ++ Cve: "cve-2025-3", ++ Severity: storage.VulnerabilitySeverity_UNKNOWN_VULNERABILITY_SEVERITY, ++ }, + }, + }, + { +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+3S8WubQBQH8PzsX/FgUDaomrMaoZD+UsIYjDWL6X4Vow9zVO+Su9Ns0D9+z7A1 ++oXTtLyll9H2CKL7z+fVeglUnmypH1Yej1zImaZLsz+TxeX8tkmgcpXE6uaB1QkxEPILk1RId6awr ++DMDIaO2eW/dS/T8VHObv0Lq81G1bqCqw69O946X509AP8xd0X8STKB3B+HQR/u2dz7+sYD/4FVae ++9wFmynYGYa6tqw1m37+CtGA6paSqvU2dS2uwqH6BvwYRpcGYfgL8DSTxRQxXYYV9qLqmgejqTMD9 ++PdAjpWvKhnYZDYgJtIVUMGy58zz8udHGwfwmW35ezLJ8frNYTodOfyu32WwxHTZ+iLaklCAuQekK ++87KnQxvMh+xBreFjq8s7f1VYrKBT0sFQsJ88Kg1X4Pfgl7pTbkp56YP27b5Rq+sfs2tqtECrm54y ++BmGJypmiCWtTbNbbJjR/SjZ8iBFdgmyLGilG2EvcHWIY3HaSnjjawnNwRV1Trp10a7DbJpfKIXV3 ++UqujhLTKPi4/nfvL8G4KfqvulN6pDCmddDQVJ1vUnYOkPfqOIaANH/J6b/2XY4wxxhhjjDHGGGOM ++McYYY4wxxhhjJ/Qb2Q90BgAoAAA= +diff --git 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-002732/tests/test.sh b/tasks/format-code-task-002732/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3d80e239f98164f1d80df624dae73220a83d2a63 --- /dev/null +++ b/tasks/format-code-task-002732/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' +central/graphql/resolvers/node_cve_core_test.go +central/views/imagecve/view_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-002732/tests/test_command.sh b/tasks/format-code-task-002732/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002732/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002735/environment/Dockerfile b/tasks/format-code-task-002735/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f02461ddf273bf712d5435fbc62bd020fa7063e --- /dev/null +++ b/tasks/format-code-task-002735/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9a2a751dac60731e0af6f4d2e8e4c4152506a56c80c4db9fbf7d953d3cf7186a diff --git a/tasks/format-code-task-002735/environment/setup/files/blocklist b/tasks/format-code-task-002735/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002735/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002735/environment/setup/setup.sh b/tasks/format-code-task-002735/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002735/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002735/tests/test.patch b/tasks/format-code-task-002735/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e19b8020eb2544bce553d06b8194cc3678a41be8 --- /dev/null +++ b/tasks/format-code-task-002735/tests/test.patch @@ -0,0 +1,335 @@ +diff --git a/usercase-test-coderl/st_distance_sphere_test.rb b/usercase-test-coderl/st_distance_sphere_test.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/st_distance_sphere_test.rb +@@ -0,0 +1,309 @@ ++# frozen_string_literal: true ++ ++ ++ ++ ++ ++require "json" ++gem "minitest", "~> 5.0" ++require "minitest" ++def Minitest.load_plugins; end ++require "minitest/mock" ++require "minitest/autorun" ++require "open3" ++require "rbconfig" ++require "socket" ++require "tmpdir" ++ ++$LOAD_PATH.unshift File.expand_path("../lib", __dir__) ++require "activerecord-mysql2rgeo-adapter" ++ ++class Place < ActiveRecord::Base ++ self.table_name = "places" ++end ++ ++class StDistanceSphereAcceptanceTest < Minitest::Test ++ EWKT_POINT = "SRID=4326;POINT(-72.099 42.099)" ++ ++ class FakeMysqlConnection ++ def quote(value) ++ "'#{value.to_s.gsub("'", "''")}'" ++ end ++ ++ def quote_table_name(name) ++ "`#{name}`" ++ end ++ ++ def quote_column_name(name) ++ "`#{name}`" ++ end ++ end ++ ++ def test_table_attribute_receiver_with_ewkt_rhs_returns_distance_sphere_node ++ ++ ++ receiver = lonlat ++ node = receiver.st_distance_sphere(EWKT_POINT) ++ ++ ++ assert_distance_sphere_node(node, expression_count: 2, spatial_arguments: [true, true]) ++ assert_equal receiver, node.expressions[0] ++ assert_equal EWKT_POINT, node.expressions[1] ++ ++ ++ sql = sql_for(node) ++ assert_match(/\AST_Distance_Sphere\(/, sql) ++ assert_includes sql, "`places`.`lonlat`" ++ assert_match(/ST_GeomFromText\('POINT\(-72\.099 42\.099\)'.*4326/, sql) ++ ++ predicate_sql = sql_for(node.lt(500)) ++ assert_match(/\AST_Distance_Sphere\(/, predicate_sql) ++ assert_match(/<\s*'?500'?/, predicate_sql) ++ end ++ ++ def test_table_attribute_receiver_with_rgeo_rhs_and_meter_units ++ ++ ++ receiver = lonlat ++ geom = geographic_factory.point(-71.0, 41.0) ++ node = receiver.st_distance_sphere(geom, :meter) ++ ++ ++ assert_distance_sphere_node(node, expression_count: 3, spatial_arguments: [true, true, false]) ++ assert_equal receiver, node.expressions[0] ++ assert_equal geom, node.expressions[1] ++ assert_equal "meter", node.expressions[2] ++ end ++ ++ def test_spatial_constant_receiver_with_ewkt_rhs ++ ++ ++ geom = geographic_factory.point(-71.0, 41.0) ++ receiver = Arel.spatial(geom) ++ node = receiver.st_distance_sphere(EWKT_POINT) ++ ++ ++ assert_distance_sphere_node(node, expression_count: 2, spatial_arguments: [true, true]) ++ assert_same receiver, node.expressions[0] ++ assert_equal geom, node.expressions[0].delegate ++ assert_equal EWKT_POINT, node.expressions[1] ++ ++ sql = sql_for(node) ++ assert_match(/\AST_Distance_Sphere\(/, sql) ++ assert_operator sql.scan(/ST_GeomFromText/).length, :>=, 2 ++ end ++ ++ def test_spatial_function_receiver_with_ewkt_rhs_and_units ++ ++ ++ receiver = lonlat.st_length ++ node = receiver.st_distance_sphere(EWKT_POINT, "yard") ++ ++ ++ assert_distance_sphere_node(node, expression_count: 3, spatial_arguments: [true, true, false]) ++ assert_equal receiver, node.expressions[0] ++ assert_equal EWKT_POINT, node.expressions[1] ++ assert_equal "yard", node.expressions[2] ++ ++ sql = sql_for(node) ++ assert_match(/\AST_Distance_Sphere\(/, sql) ++ assert_includes sql, "ST_Length" ++ end ++ ++ def test_missing_rhs_raises_argument_error ++ ++ assert_raises(ArgumentError) { lonlat.st_distance_sphere } ++ end ++ ++ def test_referential_transparency_for_same_arguments ++ geom = geographic_factory.point(-71.0, 41.0) ++ ++ assert_equal lonlat.st_distance_sphere(geom, :meter), lonlat.st_distance_sphere(geom, :meter) ++ end ++ ++ def test_does_not_mutate_receiver_rhs_string_or_geometry ++ rhs = EWKT_POINT.dup ++ geom = geographic_factory.point(-71.0, 41.0) ++ receiver_before = { ++ table: lonlat.relation.name, ++ name: lonlat.name, ++ sql: sql_for(lonlat) ++ } ++ rhs_before = rhs.dup ++ geom_before = { text: geom.as_text, srid: geom.srid } ++ ++ lonlat.st_distance_sphere(rhs) ++ lonlat.st_distance_sphere(geom, :meter) ++ ++ assert_equal receiver_before, { table: lonlat.relation.name, name: lonlat.name, sql: sql_for(lonlat) } ++ assert_equal rhs_before, rhs ++ assert_equal geom_before, { text: geom.as_text, srid: geom.srid } ++ end ++ ++ def test_no_global_state_across_fresh_ruby_process ++ in_process = JSON.generate(attribute_string_summary(lonlat.st_distance_sphere(EWKT_POINT))) ++ script = <<~RUBY ++ require "json" ++ $LOAD_PATH.unshift "/workspace/repo/lib" ++ require "activerecord-mysql2rgeo-adapter" ++ ++ class Place < ActiveRecord::Base ++ self.table_name = "places" ++ end ++ ++ class FakeMysqlConnection ++ def quote(value) ++ "'\#{value.to_s.gsub("'", "''")}'" ++ end ++ ++ def quote_table_name(name) ++ "`\#{name}`" ++ end ++ ++ def quote_column_name(name) ++ "`\#{name}`" ++ end ++ end ++ ++ visitor = Arel::Visitors::Mysql2Rgeo.new(FakeMysqlConnection.new) ++ node = Place.arel_table[:lonlat].st_distance_sphere("SRID=4326;POINT(-72.099 42.099)") ++ sql = visitor.accept(node, Arel::Collectors::SQLString.new).value ++ predicate_sql = visitor.accept(node.lt(500), Arel::Collectors::SQLString.new).value ++ summary = { ++ class_name: node.class.name, ++ name: node.name, ++ expression_count: node.expressions.length, ++ receiver_table: node.expressions[0].relation.name, ++ receiver_name: node.expressions[0].name, ++ rhs: node.expressions[1], ++ spatial_result: node.spatial_result?, ++ spatial_arguments: (0...node.expressions.length).map { |index| node.spatial_argument?(index) }, ++ sql: sql, ++ predicate_sql: predicate_sql ++ } ++ STDOUT.write(JSON.generate(summary)) ++ RUBY ++ ++ fresh_process, stderr, status = Open3.capture3(RbConfig.ruby, "-I", "/workspace/repo/lib", "-e", script) ++ ++ assert status.success?, stderr ++ assert_equal in_process, fresh_process ++ end ++ ++ def test_no_filesystem_network_database_or_active_record_config_side_effects ++ before_connection_handler = ActiveRecord::Base.connection_handler.object_id ++ before_configurations = ActiveRecord::Base.configurations ++ ++ Dir.mktmpdir do |dir| ++ Dir.chdir(dir) do ++ before_entries = Dir.children(".") ++ socket_error = Class.new(RuntimeError) ++ socket_blocker = proc { raise socket_error, "network access is undeclared" } ++ ++ Socket.stub(:tcp, socket_blocker) do ++ TCPSocket.stub(:open, socket_blocker) do ++ lonlat.st_distance_sphere(EWKT_POINT) ++ lonlat.st_distance_sphere(geographic_factory.point(-71.0, 41.0), :meter) ++ end ++ end ++ ++ assert_equal before_entries, Dir.children(".") ++ end ++ end ++ ++ assert_equal before_connection_handler, ActiveRecord::Base.connection_handler.object_id ++ assert_same before_configurations, ActiveRecord::Base.configurations ++ end ++ ++ private ++ ++ def lonlat ++ Place.arel_table[:lonlat] ++ end ++ ++ def geographic_factory ++ RGeo::Geographic.spherical_factory(srid: 4326) ++ end ++ ++ def visitor ++ @visitor ||= Arel::Visitors::Mysql2Rgeo.new(FakeMysqlConnection.new) ++ end ++ ++ def sql_for(node) ++ visitor.accept(node, Arel::Collectors::SQLString.new).value ++ end ++ ++ def assert_distance_sphere_node(node, expression_count:, spatial_arguments:) ++ assert_instance_of RGeo::ActiveRecord::SpatialNamedFunction, node ++ assert_equal "ST_Distance_Sphere", node.name ++ assert_equal expression_count, node.expressions.length ++ assert_equal false, node.spatial_result? ++ assert_equal spatial_arguments, spatial_arguments(node) ++ end ++ ++ def attribute_string_summary(node) ++ { ++ class_name: node.class.name, ++ name: node.name, ++ expression_count: node.expressions.length, ++ receiver_table: node.expressions[0].relation.name, ++ receiver_name: node.expressions[0].name, ++ rhs: node.expressions[1], ++ spatial_result: node.spatial_result?, ++ spatial_arguments: spatial_arguments(node), ++ sql: sql_for(node), ++ predicate_sql: sql_for(node.lt(500)) ++ } ++ end ++ ++ def attribute_geometry_units_summary(node) ++ { ++ class_name: node.class.name, ++ name: node.name, ++ expression_count: node.expressions.length, ++ receiver_table: node.expressions[0].relation.name, ++ receiver_name: node.expressions[0].name, ++ rhs_class: node.expressions[1].class.name, ++ rhs_text: node.expressions[1].as_text, ++ rhs_srid: node.expressions[1].srid, ++ units: node.expressions[2], ++ spatial_result: node.spatial_result?, ++ spatial_arguments: spatial_arguments(node) ++ } ++ end ++ ++ def constant_receiver_summary(node) ++ { ++ class_name: node.class.name, ++ name: node.name, ++ expression_count: node.expressions.length, ++ receiver_class: node.expressions[0].class.name, ++ receiver_text: node.expressions[0].delegate.as_text, ++ receiver_srid: node.expressions[0].delegate.srid, ++ rhs: node.expressions[1], ++ spatial_result: node.spatial_result?, ++ spatial_arguments: spatial_arguments(node), ++ sql: sql_for(node) ++ } ++ end ++ ++ def function_receiver_summary(node) ++ { ++ class_name: node.class.name, ++ name: node.name, ++ expression_count: node.expressions.length, ++ receiver_class: node.expressions[0].class.name, ++ receiver_name: node.expressions[0].name, ++ receiver_expression_names: node.expressions[0].expressions.map(&:name), ++ rhs: node.expressions[1], ++ units: node.expressions[2], ++ spatial_result: node.spatial_result?, ++ spatial_arguments: spatial_arguments(node), ++ sql: sql_for(node) ++ } ++ end ++ ++ def spatial_arguments(node) ++ (0...node.expressions.length).map { |index| node.spatial_argument?(index) } ++ 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,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++exec ruby -I /workspace/repo/lib /workspace/repo/usercase-test-coderl/st_distance_sphere_test.rb diff --git a/tasks/format-code-task-002735/tests/test.sh b/tasks/format-code-task-002735/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..83299a45a58d233b93140e414eb3738a3ed362c6 --- /dev/null +++ b/tasks/format-code-task-002735/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/st_distance_sphere_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-002735/tests/test_command.sh b/tasks/format-code-task-002735/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002735/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-002751/environment/Dockerfile b/tasks/format-code-task-002751/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2aa4395bae055c15d822947120f3f0e6c820b254 --- /dev/null +++ b/tasks/format-code-task-002751/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9a1a6dd1c8cfa0252cdccf1eca24d5b15ce9650eb63a899598276defa77795e5 diff --git a/tasks/format-code-task-002751/environment/setup/files/blocklist b/tasks/format-code-task-002751/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002751/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002751/environment/setup/setup.sh b/tasks/format-code-task-002751/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002751/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002751/tests/test.patch b/tasks/format-code-task-002751/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1330d7bf9c58b1635faf73ff165e1a65f769bb3d --- /dev/null +++ b/tasks/format-code-task-002751/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/tests/lib/rules/no-redundant-story-name.test.ts b/tests/lib/rules/no-redundant-story-name.test.ts +index 40ddfa1..4e9d308 100644 +--- a/tests/lib/rules/no-redundant-story-name.test.ts ++++ b/tests/lib/rules/no-redundant-story-name.test.ts +@@ -8,6 +8,7 @@ + //------------------------------------------------------------------------------ + + import { AST_NODE_TYPES } from '@typescript-eslint/types' ++import dedent from 'ts-dedent' + + import rule from '../../../lib/rules/no-redundant-story-name' + import ruleTester from '../../utils/rule-tester' +@@ -24,6 +25,16 @@ ruleTester.run('no-redundant-story-name', rule, { + const Default = {} + export const PrimaryButton = { ...Default, name: 'The Primary Button' } + `, ++ ` ++ export const PrimaryButton = Template.bind({}) ++ PrimaryButton.storyName = 'The Primary Button' ++ `, ++ ` ++ export function PrimaryButton () { ++ return
Hello
++ } ++ PrimaryButton.storyName = 'The Primary Button' ++ `, + ], + + invalid: [ +@@ -57,5 +68,26 @@ ruleTester.run('no-redundant-story-name', rule, { + }, + ], + }, ++ { ++ code: dedent` ++ export const PrimaryButton = Template.bind({}) ++ PrimaryButton.storyName = 'Primary Button' ++ `, ++ errors: [ ++ { ++ messageId: 'storyNameIsRedundant', ++ type: AST_NODE_TYPES.AssignmentExpression, ++ suggestions: [ ++ { ++ messageId: 'removeRedundantName', ++ output: dedent` ++ export const PrimaryButton = Template.bind({}) ++ ++ `, ++ }, ++ ], ++ }, ++ ], ++ }, + ], + }) +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+3R0WrDIBTG8Vz3KXyBGHVxfZySVGEdiQ41ZXv72VysZbD1pmWM/n8356AHPPLJ ++cTlMbufDsWvuRVVba9dafa9rr63Rxjxp0+tGaW23phH2bhtdWHIZkhBNirH8Nnft/p+S5/yLz2W3 ++j/M8BCfzy+3euJa/VvYrf92bmn//rGr+6nYr/OzB8987sQY/ercJb+/itfbidJC76TB2aZl87kJs ++k3dLcEMobS4xfbRhmL08zcmSN3/9CQAAAAAAAAAAAAAAAOBBfQKC/7svACgAAA== +diff --git 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-002751/tests/test.sh b/tasks/format-code-task-002751/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..67edb7e7f5f6f5a1a50b76ae6e9b096ea48f0de1 --- /dev/null +++ b/tasks/format-code-task-002751/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/lib/rules/no-redundant-story-name.test.ts +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-002751/tests/test_command.sh b/tasks/format-code-task-002751/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002751/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002756/environment/Dockerfile b/tasks/format-code-task-002756/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..59a9a590a666158bb90624ab884d98287fa14660 --- /dev/null +++ b/tasks/format-code-task-002756/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:03db128f97cd1dbec5a22666745716f2808a3d151e4fda9a79054831b3616bfa diff --git a/tasks/format-code-task-002756/environment/setup/files/blocklist b/tasks/format-code-task-002756/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002756/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002756/environment/setup/setup.sh b/tasks/format-code-task-002756/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002756/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002756/tests/test.patch b/tasks/format-code-task-002756/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b709152fade2842e47dacfda7a52b8440571e58 --- /dev/null +++ b/tasks/format-code-task-002756/tests/test.patch @@ -0,0 +1,52 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..01dcd33b +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/test_cache.py -v"] ++} +diff --git a/tests/test_cache.py b/tests/test_cache.py +index 712d2c4f..14ac4441 100644 +--- a/tests/test_cache.py ++++ b/tests/test_cache.py +@@ -106,3 +106,25 @@ class TestCache(unittest.TestCase): + self.assertDictEqual( + {"test1": 1}, + self.cache.get_all()) ++ ++ @patch('streamlink.cache.mktime', side_effect=OverflowError) ++ def test_set_expires_at_overflow_does_not_raise(self, mock_mktime): ++ try: ++ self.cache.set("value", 10, expires_at=datetime.datetime(1970, 1, 1)) ++ except OverflowError: ++ self.fail("Cache.set() raised OverflowError on mktime overflow") ++ ++ @patch('streamlink.cache.mktime', side_effect=OverflowError) ++ def test_set_expires_at_overflow_value_expired(self, mock_mktime): ++ ++ ++ self.cache.set("value", 10, expires_at=datetime.datetime(1970, 1, 1)) ++ self.assertIsNone(self.cache.get("value")) ++ ++ @patch('streamlink.cache.mktime', side_effect=OverflowError) ++ def test_set_expires_at_overflow_does_not_keep_default_expiry(self, mock_mktime): ++ ++ ++ self.cache.set("value", 10, expires=60 * 60 * 24 * 7, ++ expires_at=datetime.datetime(1970, 1, 1)) ++ self.assertIsNone(self.cache.get("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,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest -v -rA tests/test_cache.py::TestCache::test_set_expires_at_overflow_does_not_raise tests/test_cache.py::TestCache::test_set_expires_at_overflow_value_expired tests/test_cache.py::TestCache::test_set_expires_at_overflow_does_not_keep_default_expiry ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002756/tests/test.sh b/tasks/format-code-task-002756/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5bd826db8a8866c0e5f7bbd26bafba28dfa8c58f --- /dev/null +++ b/tasks/format-code-task-002756/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_cache.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-002756/tests/test_command.sh b/tasks/format-code-task-002756/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002756/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002758/environment/Dockerfile b/tasks/format-code-task-002758/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c489d4c3d80b898b4d6436ca78ca83f73da587fb --- /dev/null +++ b/tasks/format-code-task-002758/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:156cdbebc7df326efe3bc07aca4db3b28c41c3742eb47756da8e8476d2b5bb7e diff --git a/tasks/format-code-task-002758/environment/setup/files/blocklist b/tasks/format-code-task-002758/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002758/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002758/environment/setup/setup.sh b/tasks/format-code-task-002758/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002758/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002758/tests/test.patch b/tasks/format-code-task-002758/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..aeb8a6c9e74a62d35644a70ceb3b663abca5daf7 --- /dev/null +++ b/tasks/format-code-task-002758/tests/test.patch @@ -0,0 +1,128 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..95176c99 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/plugins/test_nos.py -v"] ++} +diff --git a/tests/plugins/test_nos.py b/tests/plugins/test_nos.py +index 5b1ceb44..39473a3e 100644 +--- a/tests/plugins/test_nos.py ++++ b/tests/plugins/test_nos.py +@@ -1,3 +1,9 @@ ++from textwrap import dedent ++ ++import pytest ++ ++from streamlink import Streamlink ++from streamlink.exceptions import PluginError + from streamlink.plugins.nos import NOS + from tests.plugins import PluginCanHandleUrl + +@@ -7,6 +13,8 @@ class TestPluginCanHandleUrlNOS(PluginCanHandleUrl): + + should_match = [ + "https://nos.nl/live", ++ "https://nos.nl/l/2490404", ++ "https://nos.nl/collectie/13950-natuurramp-libie", + "https://nos.nl/collectie/13781/livestream/2385081-ek-voetbal-engeland-schotland", + "https://nos.nl/collectie/13951/video/2491092-dit-was-prinsjesdag", + "https://nos.nl/video/2490788-meteoor-gespot-boven-noord-nederland", +@@ -19,4 +27,82 @@ class TestPluginCanHandleUrlNOS(PluginCanHandleUrl): + "https://nos.nl/programmas", + "https://nos.nl/uitzendingen", + "https://nos.nl/uitzendingen/livestream/2385462", ++ "https://nos.nl/lifestyle", ++ "https://nos.nl/lijst-iets", + ] ++ ++ ++_HLS_URL = "https://example.com/master.m3u8" ++ ++_HTML_TEMPLATE = """ ++ ++ ++ ++ ++""" ++ ++ ++def _make_html(type_value): ++ import json as _json ++ ++ payload = { ++ "@type": type_value, ++ "encodingFormat": "application/vnd.apple.mpegurl", ++ "contentUrl": _HLS_URL, ++ "identifier": "12345", ++ "name": "Some title", ++ } ++ return dedent(_HTML_TEMPLATE).format(json=_json.dumps(payload)) ++ ++ ++_PLAYLIST = "#EXTM3U\n#EXT-X-VERSION:3\n#EXT-X-STREAM-INF:BANDWIDTH=800000\nvariant.m3u8\n" ++ ++ ++class TestNOSSchema: ++ """Exercise _get_streams to verify the @type validation accepts both ++ a plain string and a list containing 'VideoObject'.""" ++ ++ URL = "https://nos.nl/live" ++ ++ @pytest.fixture() ++ def plugin(self, requests_mock, session: Streamlink): ++ ++ requests_mock.get(_HLS_URL, text=_PLAYLIST) ++ return NOS(session, self.URL) ++ ++ def test_type_string_video_object_validates(self, plugin, requests_mock): ++ ++ ++ requests_mock.get(self.URL, text=_make_html("VideoObject")) ++ streams = plugin._get_streams() ++ ++ ++ assert plugin.id == "12345" ++ assert plugin.title == "Some title" ++ ++ assert streams is not None ++ ++ def test_type_list_with_video_object_validates(self, plugin, requests_mock): ++ ++ ++ ++ requests_mock.get(self.URL, text=_make_html(["VideoObject", "WebPage"])) ++ streams = plugin._get_streams() ++ assert plugin.id == "12345" ++ assert plugin.title == "Some title" ++ assert streams is not None ++ ++ def test_type_string_non_video_no_streams(self, plugin, requests_mock): ++ ++ ++ ++ ++ ++ requests_mock.get(self.URL, text=_make_html("WebPage")) ++ try: ++ result = plugin._get_streams() ++ except PluginError: ++ return ++ assert result is None or not result, ( ++ "Non-VideoObject @type must not yield streams" ++ ) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest -v -rA tests/plugins/test_nos.py::TestNOSSchema::test_type_string_video_object_validates tests/plugins/test_nos.py::TestNOSSchema::test_type_list_with_video_object_validates tests/plugins/test_nos.py::TestNOSSchema::test_type_string_non_video_no_streams ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002758/tests/test.sh b/tasks/format-code-task-002758/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dbe1829b49eadd00571a5c1ad9d9942e013d8def --- /dev/null +++ b/tasks/format-code-task-002758/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/plugins/test_nos.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-002758/tests/test_command.sh b/tasks/format-code-task-002758/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002758/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002760/environment/Dockerfile b/tasks/format-code-task-002760/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2a0a8a1be51df896c1331a7b18c8585a989c5323 --- /dev/null +++ b/tasks/format-code-task-002760/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7dc3da78b6cf253009f00978161f82c5e6edac8277bceeeb98b8afc8f1768c71 diff --git a/tasks/format-code-task-002760/environment/setup/files/blocklist b/tasks/format-code-task-002760/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002760/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002760/environment/setup/setup.sh b/tasks/format-code-task-002760/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002760/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002760/tests/test.patch b/tasks/format-code-task-002760/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d71924432aab2bc5d8c6dd4c198f91cce1696ad9 --- /dev/null +++ b/tasks/format-code-task-002760/tests/test.patch @@ -0,0 +1,151 @@ +diff --git a/test/Webhook.spec.ts b/test/Webhook.spec.ts +index 182b3d9b..7956fb61 100644 +--- a/test/Webhook.spec.ts ++++ b/test/Webhook.spec.ts +@@ -149,6 +149,53 @@ describe('Webhooks', () => { + + expect(event.id).to.equal(EVENT_PAYLOAD.id); + }); ++ ++ it('should accept a receivedAt timestamp (ms) where event is within tolerance relative to receivedAt', async () => { ++ const eventTimestampSec = Math.floor(Date.now() / 1000) - 600; ++ const receivedAtMs = (eventTimestampSec + 5) * 1000; ++ ++ const header = stripe.webhooks.generateTestHeaderString({ ++ timestamp: eventTimestampSec, ++ payload: EVENT_PAYLOAD_STRING, ++ secret: SECRET, ++ }); ++ ++ const event = await constructEventFn( ++ EVENT_PAYLOAD_STRING, ++ header, ++ SECRET, ++ 10, ++ undefined, ++ receivedAtMs ++ ); ++ ++ expect(event.id).to.equal(EVENT_PAYLOAD.id); ++ }); ++ ++ it('should reject when receivedAt indicates the event is outside tolerance', async () => { ++ const eventTimestampSec = Math.floor(Date.now() / 1000); ++ const receivedAtMs = (eventTimestampSec + 60) * 1000; ++ ++ const header = stripe.webhooks.generateTestHeaderString({ ++ timestamp: eventTimestampSec, ++ payload: EVENT_PAYLOAD_STRING, ++ secret: SECRET, ++ }); ++ ++ await expect( ++ constructEventFn( ++ EVENT_PAYLOAD_STRING, ++ header, ++ SECRET, ++ 10, ++ undefined, ++ receivedAtMs ++ ) ++ ).to.be.rejectedWith( ++ StripeSignatureVerificationError, ++ /Timestamp outside the tolerance zone/ ++ ); ++ }); + }; + }; + +@@ -242,6 +289,70 @@ describe('Webhooks', () => { + ); + }); + ++ it('should accept receivedAt timestamp in ms where event is within tolerance of receivedAt', async () => { ++ ++ const eventTimestampSec = Math.floor(Date.now() / 1000) - 600; ++ ++ const receivedAtMs = (eventTimestampSec + 5) * 1000; ++ ++ const header = stripe.webhooks.generateTestHeaderString({ ++ timestamp: eventTimestampSec, ++ payload: EVENT_PAYLOAD_STRING, ++ secret: SECRET, ++ }); ++ ++ ++ expect( ++ await verifyHeaderFn( ++ EVENT_PAYLOAD_STRING, ++ header, ++ SECRET, ++ 10, ++ undefined, ++ receivedAtMs ++ ) ++ ).to.equal(true); ++ }); ++ ++ it('should reject when receivedAt timestamp shows the event is outside tolerance', async () => { ++ const eventTimestampSec = Math.floor(Date.now() / 1000); ++ ++ const receivedAtMs = (eventTimestampSec + 60) * 1000; ++ ++ const header = stripe.webhooks.generateTestHeaderString({ ++ timestamp: eventTimestampSec, ++ payload: EVENT_PAYLOAD_STRING, ++ secret: SECRET, ++ }); ++ ++ await expect( ++ verifyHeaderFn( ++ EVENT_PAYLOAD_STRING, ++ header, ++ SECRET, ++ 10, ++ undefined, ++ receivedAtMs ++ ) ++ ).to.be.rejectedWith( ++ StripeSignatureVerificationError, ++ /Timestamp outside the tolerance zone/ ++ ); ++ }); ++ ++ it('should fall back to Date.now() when receivedAt is not provided', async () => { ++ ++ const header = stripe.webhooks.generateTestHeaderString({ ++ timestamp: Date.now() / 1000, ++ payload: EVENT_PAYLOAD_STRING, ++ secret: SECRET, ++ }); ++ ++ expect( ++ await verifyHeaderFn(EVENT_PAYLOAD_STRING, header, SECRET, 10) ++ ).to.equal(true); ++ }); ++ + it( + 'should return true when the header contains a valid signature and ' + + 'the timestamp is within the tolerance', +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..1970b2c0 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["yarn mocha-only test/Webhook.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 ++yarn mocha-only test/Webhook.spec.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002760/tests/test.sh b/tasks/format-code-task-002760/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..29336ee7de8ee7b1ed9f3d14f5e7db3ef9c367b3 --- /dev/null +++ b/tasks/format-code-task-002760/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/Webhook.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-002760/tests/test_command.sh b/tasks/format-code-task-002760/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002760/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002767/environment/Dockerfile b/tasks/format-code-task-002767/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d2dc65f691401118db71838aff1d9e9ae942bfb2 --- /dev/null +++ b/tasks/format-code-task-002767/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7f44a4eda2d1ee5d51b780cc338187adc350e49bc2c7ed757ab176f8bf8fd78f diff --git a/tasks/format-code-task-002767/environment/setup/files/blocklist b/tasks/format-code-task-002767/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002767/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002767/environment/setup/setup.sh b/tasks/format-code-task-002767/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002767/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002767/tests/test.patch b/tasks/format-code-task-002767/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d50829fe6899d263d820c5ab33d786b0f554fb1d --- /dev/null +++ b/tasks/format-code-task-002767/tests/test.patch @@ -0,0 +1,287 @@ +diff --git a/lib/__tests__/needlessDisables-unusedRule.test.js b/lib/__tests__/needlessDisables-unusedRule.test.js +new file mode 100644 +index 000000000..d6860467b +--- /dev/null ++++ b/lib/__tests__/needlessDisables-unusedRule.test.js +@@ -0,0 +1,96 @@ ++"use strict"; ++ ++const needlessDisables = require("../needlessDisables"); ++const standalone = require("../standalone"); ++const stripIndent = require("common-tags").stripIndent; ++ ++ ++ ++ ++ ++function getUnusedRule(range) { ++ if (range.unusedRule !== undefined) return range.unusedRule; ++ ++ return range.rule; ++} ++ ++it("needlessDisables annotates each unused range with its unused rule (rule-specific disable)", () => { ++ const config = { rules: { "color-named": "never" } }; ++ ++ const css = stripIndent` ++ /* stylelint-disable color-named */ ++ a {} ++ /* stylelint-enable */ ++ `; ++ ++ return standalone({ config, code: css, ignoreDisables: true }).then( ++ linted => { ++ const report = needlessDisables(linted.results); ++ ++ expect(report).toHaveLength(1); ++ expect(report[0].ranges).toHaveLength(1); ++ expect(getUnusedRule(report[0].ranges[0])).toBe("color-named"); ++ expect(report[0].ranges[0].start).toBe(1); ++ expect(report[0].ranges[0].end).toBe(3); ++ } ++ ); ++}); ++ ++it("needlessDisables annotates a bare /* stylelint-disable */ range with unused rule 'all'", () => { ++ const config = { rules: { "block-no-empty": true } }; ++ ++ const css = stripIndent` ++ /* stylelint-disable */ ++ a { color: pink; } ++ /* stylelint-enable */ ++ `; ++ ++ return standalone({ config, code: css, ignoreDisables: true }).then( ++ linted => { ++ const report = needlessDisables(linted.results); ++ ++ expect(report).toHaveLength(1); ++ expect(report[0].ranges).toHaveLength(1); ++ expect(getUnusedRule(report[0].ranges[0])).toBe("all"); ++ } ++ ); ++}); ++ ++it("needlessDisables annotates multiple ranges each with the correct unused rule (differential)", () => { ++ const config = { ++ rules: { ++ "block-no-empty": true, ++ "color-named": "never" ++ } ++ }; ++ ++ ++ ++ ++ const css = stripIndent` ++ /* stylelint-disable color-named */ ++ a { width: 10px; } ++ /* stylelint-enable */ ++ /* stylelint-disable block-no-empty */ ++ a { width: 10px; } ++ /* stylelint-enable */ ++ `; ++ ++ return standalone({ config, code: css, ignoreDisables: true }).then( ++ linted => { ++ const report = needlessDisables(linted.results); ++ ++ expect(report).toHaveLength(1); ++ const ranges = report[0].ranges; ++ ++ ++ const colorNamedRange = ranges.find(r => r.start === 1); ++ const blockNoEmptyRange = ranges.find(r => r.start === 4); ++ ++ expect(colorNamedRange).toBeDefined(); ++ expect(blockNoEmptyRange).toBeDefined(); ++ expect(getUnusedRule(colorNamedRange)).toBe("color-named"); ++ expect(getUnusedRule(blockNoEmptyRange)).toBe("block-no-empty"); ++ } ++ ); ++}); +diff --git a/lib/formatters/__tests__/needlessDisablesStringFormatter-newFormat.test.js b/lib/formatters/__tests__/needlessDisablesStringFormatter-newFormat.test.js +new file mode 100644 +index 000000000..5396a3c91 +--- /dev/null ++++ b/lib/formatters/__tests__/needlessDisablesStringFormatter-newFormat.test.js +@@ -0,0 +1,157 @@ ++"use strict"; ++ ++const needlessDisables = require("../../needlessDisables"); ++const needlessDisablesStringFormatter = require("../needlessDisablesStringFormatter"); ++const standalone = require("../../standalone"); ++const stripAnsi = require("strip-ansi"); ++const stripIndent = require("common-tags").stripIndent; ++ ++ ++ ++ ++function syntheticRange(rule, start, end) { ++ const r = { unusedRule: rule, rule: rule, start: start }; ++ ++ if (end !== undefined) r.end = end; ++ ++ return r; ++} ++ ++describe("needlessDisablesStringFormatter (issue: better error output)", () => { ++ it("formats a range with a rule, start, and end as 'unused rule: X, start line: N, end line: M'", () => { ++ const actual = stripAnsi( ++ needlessDisablesStringFormatter([ ++ { ++ source: "foo.css", ++ ranges: [syntheticRange("color-named", 2, 4)] ++ } ++ ]) ++ ); ++ ++ let expected = stripIndent` ++ foo.css ++ unused rule: color-named, start line: 2, end line: 4`; ++ ++ expected = `\n${expected}\n`; ++ ++ expect(actual).toBe(expected); ++ }); ++ ++ it("formats a range with a rule and only start (no end) as 'unused rule: X, start line: N'", () => { ++ const actual = stripAnsi( ++ needlessDisablesStringFormatter([ ++ { ++ source: "foo.css", ++ ranges: [syntheticRange("block-no-empty", 7)] ++ } ++ ]) ++ ); ++ ++ let expected = stripIndent` ++ foo.css ++ unused rule: block-no-empty, start line: 7`; ++ ++ expected = `\n${expected}\n`; ++ ++ expect(actual).toBe(expected); ++ }); ++ ++ it("formats multiple ranges and multiple sources with the new format", () => { ++ const actual = stripAnsi( ++ needlessDisablesStringFormatter([ ++ { ++ source: "foo.css", ++ ranges: [ ++ syntheticRange("color-named", 1, 3), ++ syntheticRange("all", 7) ++ ] ++ }, ++ { ++ source: "bar.css", ++ ranges: [ ++ syntheticRange("block-no-empty", 19, 33), ++ syntheticRange("color-named", 99, 102) ++ ] ++ } ++ ]) ++ ); ++ ++ let expected = stripIndent` ++ foo.css ++ unused rule: color-named, start line: 1, end line: 3 ++ unused rule: all, start line: 7 ++ ++ bar.css ++ unused rule: block-no-empty, start line: 19, end line: 33 ++ unused rule: color-named, start line: 99, end line: 102`; ++ ++ expected = `\n${expected}\n`; ++ ++ expect(actual).toBe(expected); ++ }); ++ ++ it("does not emit the old 'start: N, end: M' format (negative assertion)", () => { ++ const actual = stripAnsi( ++ needlessDisablesStringFormatter([ ++ { ++ source: "foo.css", ++ ranges: [syntheticRange("color-named", 2, 4)] ++ } ++ ]) ++ ); ++ ++ ++ ++ expect(actual).not.toMatch(/(^|[^a-z])start: 2(?![0-9])/); ++ expect(actual).not.toMatch(/(^|[^a-z])end: 4(?![0-9])/); ++ ++ expect(actual).toContain("unused rule: color-named"); ++ expect(actual).toContain("start line: 2"); ++ expect(actual).toContain("end line: 4"); ++ }); ++ ++ ++ ++ ++ it("end-to-end: produces 'unused rule: X, start line: N, end line: M' from a real disable", () => { ++ const config = { rules: { "color-named": "never" } }; ++ const css = stripIndent` ++ /* stylelint-disable color-named */ ++ a {} ++ /* stylelint-enable */ ++ `; ++ ++ return standalone({ config, code: css, ignoreDisables: true }).then( ++ linted => { ++ const report = needlessDisables(linted.results); ++ const actual = stripAnsi(needlessDisablesStringFormatter(report)); ++ ++ expect(actual).toContain("unused rule: color-named"); ++ expect(actual).toContain("start line: 1"); ++ expect(actual).toContain("end line: 3"); ++ ++ expect(actual).not.toMatch(/(^|[^a-z])start: 1(?![0-9])/); ++ expect(actual).not.toMatch(/(^|[^a-z])end: 3(?![0-9])/); ++ } ++ ); ++ }); ++ ++ it("end-to-end: a bare /* stylelint-disable */ produces 'unused rule: all'", () => { ++ const config = { rules: { "block-no-empty": true } }; ++ const css = stripIndent` ++ /* stylelint-disable */ ++ a { color: pink; } ++ /* stylelint-enable */ ++ `; ++ ++ return standalone({ config, code: css, ignoreDisables: true }).then( ++ linted => { ++ const report = needlessDisables(linted.results); ++ const actual = stripAnsi(needlessDisablesStringFormatter(report)); ++ ++ expect(actual).toContain("unused rule: all"); ++ expect(actual).toContain("start line: 1"); ++ } ++ ); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..3cc485f6f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest lib/__tests__/needlessDisables-unusedRule.test.js lib/formatters/__tests__/needlessDisablesStringFormatter-newFormat.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 ++npx jest lib/__tests__/needlessDisables-unusedRule.test.js lib/formatters/__tests__/needlessDisablesStringFormatter-newFormat.test.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002767/tests/test.sh b/tasks/format-code-task-002767/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86ba256117bd15c9e2972318657a082d18135925 --- /dev/null +++ b/tasks/format-code-task-002767/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' +lib/__tests__/needlessDisables-unusedRule.test.js +lib/formatters/__tests__/needlessDisablesStringFormatter-newFormat.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-002767/tests/test_command.sh b/tasks/format-code-task-002767/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002767/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002769/environment/Dockerfile b/tasks/format-code-task-002769/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5bb01875ab8d6a9332145d47c4ff5b0c0ec12ee4 --- /dev/null +++ b/tasks/format-code-task-002769/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7a94855ef57855737ff3360a265576e6d84538d2799c7219a543b20c53d7a174 diff --git a/tasks/format-code-task-002769/environment/setup/files/blocklist b/tasks/format-code-task-002769/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002769/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002769/environment/setup/setup.sh b/tasks/format-code-task-002769/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002769/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002769/tests/test.patch b/tasks/format-code-task-002769/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ebeb398d8a32053f8cb15d943ef695b891184d3a --- /dev/null +++ b/tasks/format-code-task-002769/tests/test.patch @@ -0,0 +1,111 @@ +diff --git a/lib/rules/value-list-comma-newline-after/__tests__/index.js b/lib/rules/value-list-comma-newline-after/__tests__/index.js +index fa87c21bc..e0ca04bb3 100644 +--- a/lib/rules/value-list-comma-newline-after/__tests__/index.js ++++ b/lib/rules/value-list-comma-newline-after/__tests__/index.js +@@ -38,6 +38,14 @@ testRule(rule, { + code: '$grid-breakpoints: (\n(xs),\n(sm, 768px)\n) !default;', + description: 'ignores scss maps', + }, ++ { ++ code: 'a { background-size: 0, /* foo */\n 0; }', ++ description: 'inline block comment with newline after', ++ }, ++ { ++ code: 'a { background-size: 0,/* foo */\n 0; }', ++ description: 'inline block comment (no space) with newline after', ++ }, + ], + + reject: [ +@@ -93,6 +101,18 @@ testRule(rule, { + code: 'a { background-size: 0, 0;\r\n}', + description: 'ignores single-line list, multi-line block with CRLF', + }, ++ { ++ code: 'a { background-size: 0, /* foo */\n 0; }', ++ description: 'inline block comment then newline (multi-line)', ++ }, ++ { ++ code: 'a { background-size: 0,/* foo */\n 0; }', ++ description: 'inline block comment (no space) then newline (multi-line)', ++ }, ++ { ++ code: 'a { background-size: 0,\n/*foo*/0,\n0; }', ++ description: 'newline after comma, block comment on next line (preserved)', ++ }, + ], + + reject: [ +@@ -187,3 +207,50 @@ testRule(rule, { + }, + ], + }); ++ ++testRule(rule, { ++ ruleName, ++ config: ['always-multi-line'], ++ skipBasicChecks: true, ++ ++ reject: [ ++ { ++ code: 'a { background-size: 0, /* foo */ 0,\n 0; }', ++ description: 'block comment then space-value (no newline) still warns', ++ message: messages.expectedAfterMultiLine(), ++ line: 1, ++ }, ++ ], ++}); ++ ++testRule(rule, { ++ ruleName, ++ config: ['always-multi-line'], ++ skipBasicChecks: true, ++ syntax: 'scss', ++ ++ accept: [ ++ { ++ code: 'a { background-size: 0, // foo\n 0; }', ++ description: 'inline scss line comment after comma+space', ++ }, ++ { ++ code: 'a { background-size: 0,// foo\n 0; }', ++ description: 'inline scss line comment immediately after comma', ++ }, ++ ], ++}); ++ ++testRule(rule, { ++ ruleName, ++ config: ['always'], ++ skipBasicChecks: true, ++ syntax: 'scss', ++ ++ accept: [ ++ { ++ code: 'a { background-size: 0, // foo\n 0; }', ++ description: 'inline scss line comment after comma+space (always)', ++ }, ++ ], ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..d143b3e2c +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/jest lib/rules/value-list-comma-newline-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,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++./node_modules/.bin/jest lib/rules/value-list-comma-newline-after ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002769/tests/test.sh b/tasks/format-code-task-002769/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..51eb48da96da6bc19ed6ca59b5aba576efaa4fe4 --- /dev/null +++ b/tasks/format-code-task-002769/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +lib/rules/value-list-comma-newline-after/__tests__/index.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002769/tests/test_command.sh b/tasks/format-code-task-002769/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002769/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002793/environment/Dockerfile b/tasks/format-code-task-002793/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c45b0a7a89c8fcd7e2b904d55f87999770e13f6e --- /dev/null +++ b/tasks/format-code-task-002793/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6bc0ece2d19570818d4e91ae8a03e3c68a4b6117dd5496927902b15c2dd54769 diff --git a/tasks/format-code-task-002793/environment/setup/files/blocklist b/tasks/format-code-task-002793/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002793/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002793/environment/setup/setup.sh b/tasks/format-code-task-002793/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002793/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002793/tests/test.patch b/tasks/format-code-task-002793/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..483ade742fe04c2ccc3fd11a6df80e31e8176a09 --- /dev/null +++ b/tasks/format-code-task-002793/tests/test.patch @@ -0,0 +1,84 @@ +diff --git a/tests/graphql/test-nested-input.graphql b/tests/graphql/test-nested-input.graphql +new file mode 100644 +index 0000000000..080cfeb5e5 +--- /dev/null ++++ b/tests/graphql/test-nested-input.graphql +@@ -0,0 +1,57 @@ ++#> server-sdl ++schema @server @upstream { ++ query: Query ++} ++ ++input A { ++ b: B ++} ++ ++input B { ++ c: C ++} ++ ++input C { ++ d: D ++} ++ ++input D { ++ e: Int ++} ++ ++type Query { ++ a(a: A!): X @const(data: {a: "hello"}) ++} ++ ++type X { ++ a: String ++} ++ ++#> client-sdl ++input A { ++ b: B ++} ++ ++input B { ++ c: C ++} ++ ++input C { ++ d: D ++} ++ ++input D { ++ e: Int ++} ++ ++type Query { ++ a(a: A!): X ++} ++ ++type X { ++ a: String ++} ++ ++schema { ++ query: Query ++} +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+3STW7DIBAFYK99ill5Fxcs/6ibXgURIA4SwQ7gSL19qRspUaU2m0Rt1fdtBjHY ++RvNcbxfrtDD+9FQ8CsuGrltr9rmua941rOl71g75HOc9ZwV1D7vRlSUmGYiKME3pu3O3+n9Ufck/ ++mZiEmg4H6XUd9/f7xq38m7a55J/XjLc9bwti97vC1/55/krTGvzW6DLkWSwzWZ9H4hzxeniuGTUv ++FaeqonNXm51cXLrulkqGcaL319Bms5YxyHl/dCLORuU9Ov9bfmdHYbXxyabXj81owskEkSahnM0N ++EbXLT/hJyTktwZQ/PSEAAAAAAAAAAAAAAAAAAAAAgN/rDX6y+l4AKAAA +diff --git 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-002793/tests/test.sh b/tasks/format-code-task-002793/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..49c6407fe9cdca32761e9421ca7e59950134a503 --- /dev/null +++ b/tasks/format-code-task-002793/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/graphql/test-nested-input.graphql +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-002793/tests/test_command.sh b/tasks/format-code-task-002793/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002793/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002794/environment/Dockerfile b/tasks/format-code-task-002794/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7658da22f3255d25b2f64af0ddc6796d075edfbb --- /dev/null +++ b/tasks/format-code-task-002794/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4d6c16d5200aaf8971a02c31f59cd2d43120ade174e76983c316ea7021d67fd3 diff --git a/tasks/format-code-task-002794/environment/setup/files/blocklist b/tasks/format-code-task-002794/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002794/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002794/environment/setup/setup.sh b/tasks/format-code-task-002794/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002794/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002794/tests/test.patch b/tasks/format-code-task-002794/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e19a54d3a525a3339e7ca948011772cc95ed9323 --- /dev/null +++ b/tasks/format-code-task-002794/tests/test.patch @@ -0,0 +1,80 @@ +diff --git a/net/netutil/netutil_test.go b/net/netutil/netutil_test.go +new file mode 100644 +index 0000000000000..5deb0d94d2b94 +--- /dev/null ++++ b/net/netutil/netutil_test.go +@@ -0,0 +1,54 @@ ++ ++ ++ ++ ++package netutil ++ ++import ( ++ "io" ++ "net" ++ "testing" ++) ++ ++type conn struct { ++ net.Conn ++} ++ ++func TestOneConnListener(t *testing.T) { ++ c1 := new(conn) ++ a1 := dummyAddr("a1") ++ ++ ++ ln := NewOneConnListener(c1, a1) ++ if got := ln.Addr(); got != a1 { ++ t.Errorf("Addr = %#v; want %#v", got, a1) ++ } ++ c, err := ln.Accept() ++ if err != nil { ++ t.Fatal(err) ++ } ++ if c != c1 { ++ t.Fatalf("didn't get c1; got %p", c) ++ } ++ c, err = ln.Accept() ++ if err != io.EOF { ++ t.Errorf("got %v; want EOF", err) ++ } ++ if c != nil { ++ t.Errorf("unexpected non-nil Conn") ++ } ++ ++ ++ ln = NewOneConnListener(c1, a1) ++ ln.Close() ++ _, err = ln.Accept() ++ if err != io.EOF { ++ t.Fatalf("got %v; want EOF", err) ++ } ++ ++ ++ ln = NewOneConnListener(c1, nil) ++ if ln.Addr() == nil { ++ t.Errorf("nil Addr") ++ } ++} +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+3STQrCMBCG4a57iohrmyY27cqzSP/QgiZgU89v2oWKoG4sIr4PhBmSQAa+JNXQ ++HZpta88ymksaFMZMNXisU6+MVjor1oUO+0rlaRYJM9tEd4belychopNz/tW9d+c/Krnl79veb2t3 ++PJa2Sfr95954m3+xvuafGx3yz3Id8k8/N8Jzf57/ciGrzsqq7Pdx3YjpE1RtE++cGFuxOotV7Qbr ++N0ok0rZ+XIPvDjL+9ugAAAAAAAAAAAAAAADA37sAOQueZAAoAAA= +diff --git 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-002794/tests/test.sh b/tasks/format-code-task-002794/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..97fed262c88dd1fbdf4603bb4803db14332f8557 --- /dev/null +++ b/tasks/format-code-task-002794/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' +net/netutil/netutil_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-002794/tests/test_command.sh b/tasks/format-code-task-002794/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002794/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002903/environment/Dockerfile b/tasks/format-code-task-002903/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be63fb775cb48ae81c4972c55ef182e3ebd32886 --- /dev/null +++ b/tasks/format-code-task-002903/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:65c985b3f421ecda21c3e7be8c8789bbaa74b1dcb87388176342005c1e7d821c diff --git a/tasks/format-code-task-002903/environment/setup/files/blocklist b/tasks/format-code-task-002903/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002903/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002903/environment/setup/setup.sh b/tasks/format-code-task-002903/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002903/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002903/tests/test.patch b/tasks/format-code-task-002903/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3925fda9dde62e670481b10e3c9c9e659b9b217f --- /dev/null +++ b/tasks/format-code-task-002903/tests/test.patch @@ -0,0 +1,370 @@ +diff --git a/common/ratereporter_test.go b/common/ratereporter_test.go +new file mode 100644 +index 0000000..718e708 +--- /dev/null ++++ b/common/ratereporter_test.go +@@ -0,0 +1,338 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package common ++ ++import ( ++ "fmt" ++ "math" ++ "sync" ++ "testing" ++ ++ "github.com/stretchr/testify/require" ++ "github.com/stretchr/testify/suite" ++) ++ ++const ( ++ t0 = int64(1000000000) ++ t1 = int64(3000000000) ++ t2 = int64(7000000000) ++) ++ ++type RateReporterSuite struct { ++ *require.Assertions ++ suite.Suite ++} ++ ++func TestRateReporterSuite(t *testing.T) { ++ suite.Run(t, new(RateReporterSuite)) ++} ++ ++func (s *RateReporterSuite) SetupTest() { ++ s.Assertions = require.New(s.T()) ++} ++ ++ ++func (s *RateReporterSuite) TestEmptyCollect() { ++ r := NewRateReporter() ++ s.Empty(r.Collect()) ++} ++ ++ ++func (s *RateReporterSuite) TestFirstReport() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Update("a", 10, t0) ++ ++ out := r.Collect() ++ s.Len(out, 1) ++ rep, ok := out["a"] ++ s.True(ok) ++ s.EqualValues(10, rep.Value) ++ s.EqualValues(t0, rep.Time) ++ s.Equal(0.0, rep.Rate) ++ s.False(rep.Final) ++} ++ ++ ++func (s *RateReporterSuite) TestRateBetweenReports() { ++ r := NewRateReporter() ++ r.Open("a") ++ ++ r.Update("a", 10, t0) ++ first := r.Collect() ++ s.Equal(0.0, first["a"].Rate) ++ ++ ++ r.Update("a", 30, t1) ++ second := r.Collect() ++ s.Len(second, 1) ++ s.EqualValues(30, second["a"].Value) ++ s.InEpsilon(10.0, second["a"].Rate, 1e-9) ++ s.False(second["a"].Final) ++ ++ ++ r.Update("a", 70, t2) ++ third := r.Collect() ++ s.InEpsilon(10.0, third["a"].Rate, 1e-9) ++ s.EqualValues(70, third["a"].Value) ++} ++ ++ ++func (s *RateReporterSuite) TestLastWriteWins() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Update("a", 5, t0) ++ r.Update("a", 11, t0) ++ r.Update("a", 99, t1) ++ ++ out := r.Collect() ++ s.Len(out, 1) ++ s.EqualValues(99, out["a"].Value) ++ s.EqualValues(t1, out["a"].Time) ++} ++ ++ ++func (s *RateReporterSuite) TestDedupNoChange() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Update("a", 10, t0) ++ ++ s.Len(r.Collect(), 1) ++ s.Empty(r.Collect()) ++ s.Empty(r.Collect()) ++ ++ ++ r.Update("a", 20, t1) ++ s.Len(r.Collect(), 1) ++} ++ ++ ++func (s *RateReporterSuite) TestFinalReportOnClose() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Update("a", 42, t0) ++ r.Collect() ++ ++ r.Close("a") ++ out := r.Collect() ++ s.Len(out, 1) ++ s.True(out["a"].Final) ++ s.EqualValues(42, out["a"].Value) ++ ++ ++ s.Empty(r.Collect()) ++} ++ ++ ++func (s *RateReporterSuite) TestShortLivedReportedOnce() { ++ r := NewRateReporter() ++ ++ r.Open("a") ++ r.Update("a", 7, t0) ++ r.Close("a") ++ ++ out := r.Collect() ++ s.Len(out, 1) ++ s.True(out["a"].Final) ++ s.EqualValues(7, out["a"].Value) ++ s.Equal(0.0, out["a"].Rate) ++ ++ s.Empty(r.Collect()) ++} ++ ++ ++func (s *RateReporterSuite) TestNestedOpens() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Open("a") ++ r.Update("a", 10, t0) ++ ++ r.Close("a") ++ out := r.Collect() ++ s.Len(out, 1) ++ s.False(out["a"].Final) ++ ++ r.Close("a") ++ out = r.Collect() ++ s.Len(out, 1) ++ s.True(out["a"].Final) ++ ++ s.Empty(r.Collect()) ++} ++ ++ ++func (s *RateReporterSuite) TestCloseWithoutSample() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Close("a") ++ s.Empty(r.Collect()) ++} ++ ++ ++func (s *RateReporterSuite) TestCloseUnknownKey() { ++ r := NewRateReporter() ++ r.Close("nope") ++ s.Empty(r.Collect()) ++} ++ ++ ++func (s *RateReporterSuite) TestReuseAfterFinal() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Update("a", 100, t0) ++ r.Collect() ++ r.Close("a") ++ r.Collect() ++ ++ r.Open("a") ++ r.Update("a", 5, t1) ++ out := r.Collect() ++ s.Len(out, 1) ++ s.Equal(0.0, out["a"].Rate) ++ s.EqualValues(5, out["a"].Value) ++ s.False(out["a"].Final) ++} ++ ++ ++func (s *RateReporterSuite) TestNoInfiniteOrNaNRate() { ++ ++ r := NewRateReporter() ++ r.Open("a") ++ r.Update("a", 10, t0) ++ r.Collect() ++ r.Update("a", 50, t0) ++ rep := r.Collect()["a"] ++ s.False(math.IsInf(rep.Rate, 0)) ++ s.False(math.IsNaN(rep.Rate)) ++ s.Equal(0.0, rep.Rate) ++ ++ ++ r2 := NewRateReporter() ++ r2.Open("b") ++ r2.Update("b", 10, t1) ++ r2.Collect() ++ r2.Update("b", 20, t0) ++ rep2 := r2.Collect()["b"] ++ s.False(math.IsInf(rep2.Rate, 0)) ++ s.False(math.IsNaN(rep2.Rate)) ++ s.Equal(0.0, rep2.Rate) ++ ++ ++ r3 := NewRateReporter() ++ r3.Open("c") ++ r3.Update("c", 10, t0) ++ r3.Collect() ++ r3.Update("c", 20, 0) ++ rep3 := r3.Collect()["c"] ++ s.Equal(0.0, rep3.Rate) ++} ++ ++ ++func (s *RateReporterSuite) TestNegativeRate() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Update("a", 100, t0) ++ r.Collect() ++ r.Update("a", 80, t1) ++ out := r.Collect() ++ s.InEpsilon(-10.0, out["a"].Rate, 1e-9) ++} ++ ++ ++func (s *RateReporterSuite) TestMultipleKeys() { ++ r := NewRateReporter() ++ r.Open("a") ++ r.Open("b") ++ r.Update("a", 10, t0) ++ r.Update("b", 100, t0) ++ ++ out := r.Collect() ++ s.Len(out, 2) ++ s.EqualValues(10, out["a"].Value) ++ s.EqualValues(100, out["b"].Value) ++ ++ ++ r.Update("a", 30, t1) ++ out = r.Collect() ++ s.Len(out, 1) ++ s.Contains(out, "a") ++ s.NotContains(out, "b") ++} ++ ++ ++func (s *RateReporterSuite) TestConcurrentDistinctKeys() { ++ r := NewRateReporter() ++ ++ const n = 200 ++ var wg sync.WaitGroup ++ wg.Add(n) ++ for i := 0; i < n; i++ { ++ go func(i int) { ++ defer wg.Done() ++ key := fmt.Sprintf("k-%d", i) ++ r.Open(key) ++ r.Update(key, int64(i), t0) ++ r.Close(key) ++ }(i) ++ } ++ wg.Wait() ++ ++ ++ ++ out := r.Collect() ++ s.Len(out, n) ++ for i := 0; i < n; i++ { ++ rep, ok := out[fmt.Sprintf("k-%d", i)] ++ s.True(ok) ++ s.True(rep.Final) ++ s.EqualValues(int64(i), rep.Value) ++ } ++ ++ ++ s.Empty(r.Collect()) ++} ++ ++ ++ ++func (s *RateReporterSuite) TestConcurrentSameKey() { ++ r := NewRateReporter() ++ ++ const n = 200 ++ var wg sync.WaitGroup ++ wg.Add(n) ++ for i := 0; i < n; i++ { ++ go func(i int) { ++ defer wg.Done() ++ r.Open("hot") ++ r.Update("hot", int64(i), t0+int64(i)) ++ r.Close("hot") ++ }(i) ++ } ++ wg.Wait() ++ ++ ++ ++ out := r.Collect() ++ s.Len(out, 1) ++ s.True(out["hot"].Final) ++ ++ s.Empty(r.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,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++export GO111MODULE=off ++REPO_PKG="github.com/uber/cherami-server" ++ ++ ++go test -run 'TestUtilSuite|TestLoadReporterSuite|TestCounterBankSuite' "$REPO_PKG/common" ++ ++ ++go test -race -run 'TestRateReporterSuite' "$REPO_PKG/common" diff --git a/tasks/format-code-task-002903/tests/test.sh b/tasks/format-code-task-002903/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed470c7e0b003cae6159f598369058baf45200f7 --- /dev/null +++ b/tasks/format-code-task-002903/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' +common/ratereporter_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-002903/tests/test_command.sh b/tasks/format-code-task-002903/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002903/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002904/environment/Dockerfile b/tasks/format-code-task-002904/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9f4daacc868d6768afdb4c80af55914860d002fa --- /dev/null +++ b/tasks/format-code-task-002904/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e04d0bd82eeefb60517244f6c04c90830d48be25dd8301120fc56b2602743661 diff --git a/tasks/format-code-task-002904/environment/setup/files/blocklist b/tasks/format-code-task-002904/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002904/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002904/environment/setup/setup.sh b/tasks/format-code-task-002904/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002904/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002904/tests/test.patch b/tasks/format-code-task-002904/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..986d8883f4af7a293115e8a9b5319fbd0f5a48e4 --- /dev/null +++ b/tasks/format-code-task-002904/tests/test.patch @@ -0,0 +1,406 @@ +diff --git a/fxevent/error_contract_test.go b/fxevent/error_contract_test.go +new file mode 100644 +index 0000000..070e0c0 +--- /dev/null ++++ b/fxevent/error_contract_test.go +@@ -0,0 +1,390 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package fxevent_test ++ ++import ( ++ "bytes" ++ "errors" ++ "testing" ++ "time" ++ ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ "go.uber.org/fx/fxevent" ++ "go.uber.org/zap" ++ "go.uber.org/zap/zapcore" ++ "go.uber.org/zap/zaptest/observer" ++) ++ ++func verifierObserveZap(event fxevent.Event) []observer.LoggedEntry { ++ core, logs := observer.New(zap.DebugLevel) ++ (&fxevent.ZapLogger{Logger: zap.New(core)}).LogEvent(event) ++ return logs.TakeAll() ++} ++ ++func verifierObserveConsole(event fxevent.Event) string { ++ var out bytes.Buffer ++ (&fxevent.ConsoleLogger{W: &out}).LogEvent(event) ++ return out.String() ++} ++ ++func TestVerifierZapHookFailuresAreErrorsWithRuntime(t *testing.T) { ++ boom := errors.New("verifier hook failure") ++ tests := []struct { ++ name string ++ event fxevent.Event ++ message string ++ callee string ++ runtime string ++ }{ ++ { ++ name: "OnStart", ++ event: &fxevent.OnStartExecuted{ ++ FunctionName: "verifier.start", ++ CallerName: "verifier.module", ++ Runtime: 17 * time.Millisecond, ++ Err: boom, ++ }, ++ message: "OnStart hook failed", ++ callee: "verifier.start", ++ runtime: "17ms", ++ }, ++ { ++ name: "OnStop", ++ event: &fxevent.OnStopExecuted{ ++ FunctionName: "verifier.stop", ++ CallerName: "verifier.module", ++ Runtime: 23 * time.Millisecond, ++ Err: boom, ++ }, ++ message: "OnStop hook failed", ++ callee: "verifier.stop", ++ runtime: "23ms", ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ entries := verifierObserveZap(tt.event) ++ require.Len(t, entries, 1) ++ assert.Equal(t, zapcore.ErrorLevel, entries[0].Level) ++ assert.Equal(t, tt.message, entries[0].Message) ++ fields := entries[0].ContextMap() ++ assert.Equal(t, "verifier.module", fields["caller"]) ++ assert.Equal(t, "verifier hook failure", fields["error"]) ++ assert.Equal(t, tt.callee, fields["callee"]) ++ assert.Equal(t, tt.runtime, fields["runtime"]) ++ }) ++ } ++ ++ assert.Equal(t, ++ "[Fx] HOOK OnStart\t\tverifier.start called by verifier.module failed in 17ms: verifier hook failure\n", ++ verifierObserveConsole(tests[0].event), ++ ) ++ assert.Equal(t, ++ "[Fx] HOOK OnStop\t\tverifier.stop called by verifier.module failed in 23ms: verifier hook failure\n", ++ verifierObserveConsole(tests[1].event), ++ ) ++} ++ ++func TestVerifierZapOptionFailuresAreAtomicAndComplete(t *testing.T) { ++ boom := errors.New("verifier option failure") ++ tests := []struct { ++ name string ++ event fxevent.Event ++ message string ++ fields map[string]interface{} ++ }{ ++ { ++ name: "Supplied", ++ event: &fxevent.Supplied{TypeName: "verifier.Type", ModuleName: "verifier", Err: boom}, ++ message: "supply failed", ++ fields: map[string]interface{}{ ++ "type": "verifier.Type", ++ "module": "verifier", ++ "error": "verifier option failure", ++ }, ++ }, ++ { ++ name: "ProvidedMultipleOutputs", ++ event: &fxevent.Provided{ ++ ConstructorName: "verifier.New", ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ Err: boom, ++ }, ++ message: "provide failed", ++ fields: map[string]interface{}{ ++ "constructor": "verifier.New", ++ "module": "verifier", ++ "types": []interface{}{"verifier.A", "verifier.B"}, ++ "error": "verifier option failure", ++ }, ++ }, ++ { ++ name: "ProvidedNoOutputs", ++ event: &fxevent.Provided{ ++ ConstructorName: "verifier.Empty", ++ ModuleName: "verifier", ++ Err: boom, ++ }, ++ message: "provide failed", ++ fields: map[string]interface{}{ ++ "constructor": "verifier.Empty", ++ "module": "verifier", ++ "types": []interface{}{}, ++ "error": "verifier option failure", ++ }, ++ }, ++ { ++ name: "Replaced", ++ event: &fxevent.Replaced{ ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ Err: boom, ++ }, ++ message: "replace failed", ++ fields: map[string]interface{}{ ++ "module": "verifier", ++ "types": []interface{}{"verifier.A", "verifier.B"}, ++ "error": "verifier option failure", ++ }, ++ }, ++ { ++ name: "Decorated", ++ event: &fxevent.Decorated{ ++ DecoratorName: "verifier.Decorate", ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ Err: boom, ++ }, ++ message: "decorate failed", ++ fields: map[string]interface{}{ ++ "decorator": "verifier.Decorate", ++ "module": "verifier", ++ "types": []interface{}{"verifier.A", "verifier.B"}, ++ "error": "verifier option failure", ++ }, ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ entries := verifierObserveZap(tt.event) ++ require.Len(t, entries, 1, "a failed event must not emit success records") ++ assert.Equal(t, zapcore.ErrorLevel, entries[0].Level) ++ assert.Equal(t, tt.message, entries[0].Message) ++ assert.Equal(t, tt.fields, entries[0].ContextMap()) ++ }) ++ } ++} ++ ++func TestVerifierConsoleOptionFailuresAreAtomicAndComplete(t *testing.T) { ++ boom := errors.New("verifier option failure") ++ tests := []struct { ++ name string ++ event fxevent.Event ++ want string ++ }{ ++ { ++ name: "Supplied", ++ event: &fxevent.Supplied{TypeName: "verifier.Type", ModuleName: "verifier", Err: boom}, ++ want: "[Fx] ERROR\tFailed to supply verifier.Type from module \"verifier\": verifier option failure\n", ++ }, ++ { ++ name: "ProvidedMultipleOutputs", ++ event: &fxevent.Provided{ ++ ConstructorName: "verifier.New", ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ Err: boom, ++ }, ++ want: "[Fx] ERROR\tFailed to provide [verifier.A, verifier.B] from verifier.New from module \"verifier\": verifier option failure\n", ++ }, ++ { ++ name: "ProvidedNoOutputs", ++ event: &fxevent.Provided{ ++ ConstructorName: "verifier.Empty", ++ Err: boom, ++ }, ++ want: "[Fx] ERROR\tFailed to provide [] from verifier.Empty: verifier option failure\n", ++ }, ++ { ++ name: "Replaced", ++ event: &fxevent.Replaced{ ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ Err: boom, ++ }, ++ want: "[Fx] ERROR\tFailed to replace [verifier.A, verifier.B] from module \"verifier\": verifier option failure\n", ++ }, ++ { ++ name: "Decorated", ++ event: &fxevent.Decorated{ ++ DecoratorName: "verifier.Decorate", ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ Err: boom, ++ }, ++ want: "[Fx] ERROR\tFailed to decorate [verifier.A, verifier.B] with verifier.Decorate from module \"verifier\": verifier option failure\n", ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ assert.Equal(t, tt.want, verifierObserveConsole(tt.event)) ++ }) ++ } ++} ++ ++func TestVerifierFailedEventsOmitEmptyModuleContext(t *testing.T) { ++ boom := errors.New("verifier option failure") ++ tests := []struct { ++ name string ++ event fxevent.Event ++ want string ++ }{ ++ { ++ name: "Supplied", ++ event: &fxevent.Supplied{TypeName: "verifier.Type", Err: boom}, ++ want: "[Fx] ERROR\tFailed to supply verifier.Type: verifier option failure\n", ++ }, ++ { ++ name: "Provided", ++ event: &fxevent.Provided{ ++ ConstructorName: "verifier.New", ++ OutputTypeNames: []string{"verifier.A"}, ++ Err: boom, ++ }, ++ want: "[Fx] ERROR\tFailed to provide [verifier.A] from verifier.New: verifier option failure\n", ++ }, ++ { ++ name: "Replaced", ++ event: &fxevent.Replaced{ ++ OutputTypeNames: []string{"verifier.A"}, ++ Err: boom, ++ }, ++ want: "[Fx] ERROR\tFailed to replace [verifier.A]: verifier option failure\n", ++ }, ++ { ++ name: "Decorated", ++ event: &fxevent.Decorated{ ++ DecoratorName: "verifier.Decorate", ++ OutputTypeNames: []string{"verifier.A"}, ++ Err: boom, ++ }, ++ want: "[Fx] ERROR\tFailed to decorate [verifier.A] with verifier.Decorate: verifier option failure\n", ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ entries := verifierObserveZap(tt.event) ++ require.Len(t, entries, 1) ++ assert.NotContains(t, entries[0].ContextMap(), "module") ++ assert.Equal(t, tt.want, verifierObserveConsole(tt.event)) ++ }) ++ } ++} ++ ++func TestVerifierSuccessfulOptionEventsKeepExistingBehavior(t *testing.T) { ++ t.Run("Supplied", func(t *testing.T) { ++ event := &fxevent.Supplied{TypeName: "verifier.Type", ModuleName: "verifier"} ++ entries := verifierObserveZap(event) ++ require.Len(t, entries, 1) ++ assert.Equal(t, zapcore.InfoLevel, entries[0].Level) ++ assert.Equal(t, "supplied", entries[0].Message) ++ assert.Equal(t, map[string]interface{}{ ++ "module": "verifier", ++ "type": "verifier.Type", ++ }, entries[0].ContextMap()) ++ assert.Equal(t, ++ "[Fx] SUPPLY\tverifier.Type from module \"verifier\"\n", ++ verifierObserveConsole(event), ++ ) ++ }) ++ ++ tests := []struct { ++ name string ++ event fxevent.Event ++ message string ++ identityKey string ++ identityValue string ++ console string ++ }{ ++ { ++ name: "Provided", ++ event: &fxevent.Provided{ ++ ConstructorName: "verifier.New", ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ }, ++ message: "provided", ++ identityKey: "constructor", ++ identityValue: "verifier.New", ++ console: "[Fx] PROVIDE\tverifier.A <= verifier.New from module \"verifier\"\n" + ++ "[Fx] PROVIDE\tverifier.B <= verifier.New from module \"verifier\"\n", ++ }, ++ { ++ name: "Replaced", ++ event: &fxevent.Replaced{ ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ }, ++ message: "replaced", ++ console: "[Fx] REPLACE\tverifier.A from module \"verifier\"\n" + ++ "[Fx] REPLACE\tverifier.B from module \"verifier\"\n", ++ }, ++ { ++ name: "Decorated", ++ event: &fxevent.Decorated{ ++ DecoratorName: "verifier.Decorate", ++ ModuleName: "verifier", ++ OutputTypeNames: []string{"verifier.A", "verifier.B"}, ++ }, ++ message: "decorated", ++ identityKey: "decorator", ++ identityValue: "verifier.Decorate", ++ console: "[Fx] DECORATE\tverifier.A <= verifier.Decorate from module \"verifier\"\n" + ++ "[Fx] DECORATE\tverifier.B <= verifier.Decorate from module \"verifier\"\n", ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ entries := verifierObserveZap(tt.event) ++ require.Len(t, entries, 2) ++ for i, typ := range []string{"verifier.A", "verifier.B"} { ++ assert.Equal(t, zapcore.InfoLevel, entries[i].Level) ++ assert.Equal(t, tt.message, entries[i].Message) ++ wantFields := map[string]interface{}{ ++ "module": "verifier", ++ "type": typ, ++ } ++ if tt.identityKey != "" { ++ wantFields[tt.identityKey] = tt.identityValue ++ } ++ assert.Equal(t, wantFields, entries[i].ContextMap()) ++ } ++ assert.Equal(t, tt.console, verifierObserveConsole(tt.event)) ++ }) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++GOPROXY=off go test ./fxevent -count=1 diff --git a/tasks/format-code-task-002904/tests/test.sh b/tasks/format-code-task-002904/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f34e952d0615f5250c49fb04adc67c903bad8ad5 --- /dev/null +++ b/tasks/format-code-task-002904/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' +fxevent/error_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-002904/tests/test_command.sh b/tasks/format-code-task-002904/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002904/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002932/environment/Dockerfile b/tasks/format-code-task-002932/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..50e4e62308b0bd22d8544a981cae1df8fb60c10a --- /dev/null +++ b/tasks/format-code-task-002932/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:46682d061a020d5d23755e21cb044842a7938df926d708b82fc7f7d01e577159 diff --git a/tasks/format-code-task-002932/environment/setup/files/blocklist b/tasks/format-code-task-002932/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002932/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002932/environment/setup/setup.sh b/tasks/format-code-task-002932/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002932/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002932/tests/test.patch b/tasks/format-code-task-002932/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..46e663ae1bab23f94f174bc137da76700271c791 --- /dev/null +++ b/tasks/format-code-task-002932/tests/test.patch @@ -0,0 +1,74 @@ +diff --git a/packages/varlet-ui/src/bottom-navigation/__tests__/__snapshots__/index.spec.js.snap b/packages/varlet-ui/src/bottom-navigation/__tests__/__snapshots__/index.spec.js.snap +index 22850022866..af9d2ca46b0 100644 +--- a/packages/varlet-ui/src/bottom-navigation/__tests__/__snapshots__/index.spec.js.snap ++++ b/packages/varlet-ui/src/bottom-navigation/__tests__/__snapshots__/index.spec.js.snap +@@ -15,7 +15,8 @@ exports[`test bottom-navigation component props > test variant mode 1`] = ` +
tag 4 + + +-" ++ ++" + `; + + exports[`test bottom-navigation component props > test variant mode 2`] = ` +@@ -33,5 +34,6 @@ exports[`test bottom-navigation component props > test variant mode 2`] = ` +
tag 4 + + +-" ++ ++" + `; +diff --git a/packages/varlet-ui/src/bottom-navigation/__tests__/index.spec.js b/packages/varlet-ui/src/bottom-navigation/__tests__/index.spec.js +index a0ca3977023..5e2f97f60be 100644 +--- a/packages/varlet-ui/src/bottom-navigation/__tests__/index.spec.js ++++ b/packages/varlet-ui/src/bottom-navigation/__tests__/index.spec.js +@@ -262,6 +262,23 @@ describe('test bottom-navigation component props', () => { + wrapper.unmount() + }) + ++ test('test bottom-navigation placeholder', async () => { ++ const wrapper = mount(VarBottomNavigation, { ++ props: { ++ placeholder: true, ++ fixed: true, ++ }, ++ }) ++ ++ expect(wrapper.find('.var-bottom-navigation__placeholder').exists()).toBe(true) ++ await wrapper.setProps({ placeholder: false, fixed: false }) ++ expect(wrapper.find('.var-bottom-navigation__placeholder').exists()).toBe(false) ++ await wrapper.setProps({ placeholder: true, fixed: false }) ++ expect(wrapper.find('.var-bottom-navigation__placeholder').exists()).toBe(false) ++ ++ wrapper.unmount() ++ }) ++ + test('test bottom-navigation fab-props', async () => { + const wrapper = mount(Wrapper, { + props: { +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+3STW+cMBAGYM78imkSRe0BDOzSlSr10OaSSjlEUe7IwJR1y9ouNmj77wtsvpSq ++pJUSVVXf52IwM/agmbjsVVsXrAcRvJRktMnzeR09XufnNM/SLEtXWfo2SNI036wDyl+sogd652VH ++FHTG+KW4p77/o+L7/nt2vqjMbid1Hbvt893xRP/TZLW663+aZGP/1/lmE1DyfCX82n/e/+NXolRa ++lNJtw6qmeQhKrsOQ99Z0ni4/XJ+/PxLGeqFNzVG2nuLfnUz7R2F4TB+n+SG3lR3XVLNlXbOuFDt6 ++3fG3Xk3b5Xc6u/j05uEFwsrqq2zYiUF2Lfvo5oTTU7La7mgey8WE3vEfRA/Kc2TbvlHaPUq7+wm/ ++5alOcoamcOepMvqzakg5koNUrSxbXrylatXPh1/1ej56nLOGPU25bvnPVKjt/raGbkyPoptKlm4W ++rSrnJolDsDgcEB/e4i+OXFeJ0nhvdpGWg2qkV0aLophLKgqhxt7tY2e5GqPDvz2aAAAAAAAAAAAA ++AAAAAAAAAPAbfgCdIw8zACgAAA== +diff --git 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-002932/tests/test.sh b/tasks/format-code-task-002932/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9fb2081b2ef7361ab8a864ef16d899f07ccda19e --- /dev/null +++ b/tasks/format-code-task-002932/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/varlet-ui/src/bottom-navigation/__tests__/__snapshots__/index.spec.js.snap +packages/varlet-ui/src/bottom-navigation/__tests__/index.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-002932/tests/test_command.sh b/tasks/format-code-task-002932/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002932/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002935/environment/Dockerfile b/tasks/format-code-task-002935/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ad20cfadf4abbb43fc1899cece9fa282a7488618 --- /dev/null +++ b/tasks/format-code-task-002935/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b4248da3f879154ea54227bcfd187f5a272265fa550f748b603caadc99582ca1 diff --git a/tasks/format-code-task-002935/environment/setup/files/blocklist b/tasks/format-code-task-002935/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002935/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002935/environment/setup/setup.sh b/tasks/format-code-task-002935/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002935/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002935/tests/test.patch b/tasks/format-code-task-002935/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f8d3c12ff6348f49d301f3a4730ac892a3a0ffc --- /dev/null +++ b/tasks/format-code-task-002935/tests/test.patch @@ -0,0 +1,295 @@ +diff --git a/usercase-test-coderl/test_to_values.py b/usercase-test-coderl/test_to_values.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_to_values.py +@@ -0,0 +1,259 @@ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import builtins ++import copy ++import json ++import socket ++import subprocess ++import sys ++from datetime import date ++ ++import narwhals.stable.v1 as nw ++import pandas as pd ++import polars as pl ++import pytest ++ ++import altair as alt ++ ++ ++class GeoFeatureCollection: ++ def __init__(self) -> None: ++ self.interface = { ++ "type": "FeatureCollection", ++ "features": [ ++ { ++ "type": "Feature", ++ "geometry": {"type": "Point", "coordinates": (1.5, 2.5)}, ++ "properties": {"name": "A", "missing": None}, ++ }, ++ { ++ "type": "Feature", ++ "geometry": { ++ "type": "LineString", ++ "coordinates": [(0, 0), (1, 1)], ++ }, ++ "properties": {"name": "B"}, ++ }, ++ ], ++ } ++ ++ @property ++ def __geo_interface__(self): ++ return self.interface ++ ++ ++def test_pandas_dataframe_returns_inline_rows() -> None: ++ ++ ++ ++ ++ data = pd.DataFrame({"x": [1, 2], "y": ["a", "b"]}) ++ ++ actual = alt.to_values(data) ++ ++ assert actual == {"values": [{"x": 1, "y": "a"}, {"x": 2, "y": "b"}]} ++ ++ ++def test_pandas_dataframe_applies_altair_sanitization() -> None: ++ ++ ++ ++ ++ data = pd.DataFrame( ++ { ++ "when": pd.to_datetime(["2020-01-01 01:02:03", None]), ++ "score": [1.25, float("inf")], ++ "flag": [True, False], ++ } ++ ) ++ ++ actual = alt.to_values(data) ++ ++ assert actual == { ++ "values": [ ++ {"when": "2020-01-01T01:02:03", "score": 1.25, "flag": True}, ++ {"when": "", "score": None, "flag": False}, ++ ] ++ } ++ ++ ++def test_values_dictionary_is_returned_unchanged_as_data_dictionary() -> None: ++ ++ ++ ++ ++ data = {"values": [{"x": 1}], "name": "kept"} ++ ++ actual = alt.to_values(data) ++ ++ assert actual == {"values": [{"x": 1}], "name": "kept"} ++ ++ ++def test_geo_interface_feature_collection_returns_sanitized_values() -> None: ++ ++ ++ ++ ++ data = GeoFeatureCollection() ++ ++ actual = alt.to_values(data) ++ ++ assert actual == { ++ "values": [ ++ { ++ "name": "A", ++ "missing": None, ++ "type": "Feature", ++ "geometry": {"type": "Point", "coordinates": [1.5, 2.5]}, ++ }, ++ { ++ "name": "B", ++ "type": "Feature", ++ "geometry": { ++ "type": "LineString", ++ "coordinates": [[0, 0], [1, 1]], ++ }, ++ }, ++ ] ++ } ++ ++ ++def test_narwhals_dataframe_returns_sanitized_named_rows() -> None: ++ ++ ++ ++ ++ native = pl.DataFrame( ++ { ++ "x": [1, 2], ++ "when": [date(2021, 5, 17), date(2021, 5, 18)], ++ "label": ["left", None], ++ } ++ ) ++ data = nw.from_native(native, eager_only=True) ++ ++ actual = alt.to_values(data) ++ ++ assert actual == { ++ "values": [ ++ {"x": 1, "when": "2021-05-17T00:00:00", "label": "left"}, ++ {"x": 2, "when": "2021-05-18T00:00:00", "label": None}, ++ ] ++ } ++ ++ ++def test_dictionary_without_values_key_raises_key_error() -> None: ++ ++ ++ ++ ++ with pytest.raises(KeyError) as excinfo: ++ alt.to_values({"x": [1]}) ++ ++ ++ assert isinstance(excinfo.value, KeyError) ++ ++ ++def test_unsupported_object_raises_type_error() -> None: ++ ++ ++ ++ ++ with pytest.raises(TypeError) as excinfo: ++ alt.to_values(0) ++ ++ ++ assert isinstance(excinfo.value, TypeError) ++ ++ ++def test_referential_transparency_for_same_input() -> None: ++ data = pd.DataFrame({"x": [3, 4], "y": ["c", "d"]}) ++ ++ assert alt.to_values(data) == alt.to_values(data) ++ ++ ++def test_does_not_mutate_caller_inputs() -> None: ++ dict_data = {"values": [{"x": 1, "tags": ["a", "b"]}]} ++ dict_before = copy.deepcopy(dict_data) ++ frame_data = pd.DataFrame( ++ {"when": pd.to_datetime(["2022-02-03 04:05:06"]), "score": [float("inf")]} ++ ) ++ frame_before = frame_data.copy(deep=True) ++ native_narwhals_data = pl.DataFrame( ++ {"x": [1], "when": [date(2023, 1, 2)], "label": ["stable"]} ++ ) ++ narwhals_data = nw.from_native(native_narwhals_data, eager_only=True) ++ narwhals_before = narwhals_data.rows(named=True) ++ geo_data = GeoFeatureCollection() ++ geo_before = copy.deepcopy(geo_data.interface) ++ ++ alt.to_values(dict_data) ++ alt.to_values(frame_data) ++ alt.to_values(narwhals_data) ++ alt.to_values(geo_data) ++ ++ assert dict_data == dict_before ++ pd.testing.assert_frame_equal(frame_data, frame_before) ++ assert narwhals_data.rows(named=True) == narwhals_before ++ assert geo_data.interface == geo_before ++ ++ ++def test_no_global_state_across_fresh_python_process() -> None: ++ data = pd.DataFrame({"x": [9, 10], "y": ["i", "j"]}) ++ in_process = alt.to_values(data) ++ script = """ ++import json ++import sys ++sys.path.insert(0, "/workspace/repo") ++import pandas as pd ++import altair as alt ++out = alt.to_values(pd.DataFrame({"x": [9, 10], "y": ["i", "j"]})) ++sys.stdout.write(json.dumps(out, 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 == {"values": [{"x": 9, "y": "i"}, {"x": 10, "y": "j"}]} ++ assert fresh_process == in_process ++ ++ ++def test_does_not_write_files_use_network_or_change_transformer_state( ++ monkeypatch: pytest.MonkeyPatch, tmp_path ++) -> None: ++ before_active = alt.data_transformers.active ++ before_options = alt.data_transformers.options.copy() ++ before_consolidate = alt.data_transformers.consolidate_datasets ++ ++ def fail_socket(*args, **kwargs): ++ raise AssertionError("alt.to_values must not open network sockets") ++ ++ real_open = builtins.open ++ ++ def guarded_open(file, mode="r", *args, **kwargs): ++ if any(flag in mode for flag in ("w", "a", "x", "+")): ++ raise AssertionError(f"alt.to_values must not write files: {file!r}") ++ return real_open(file, mode, *args, **kwargs) ++ ++ monkeypatch.setattr(socket, "socket", fail_socket) ++ monkeypatch.setattr(builtins, "open", guarded_open) ++ monkeypatch.chdir(tmp_path) ++ before_entries = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ ++ actual = alt.to_values({"values": [{"x": 42}]}) ++ ++ after_entries = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ assert actual == {"values": [{"x": 42}]} ++ assert after_entries == before_entries ++ assert alt.data_transformers.active == before_active ++ assert alt.data_transformers.options == before_options ++ assert alt.data_transformers.consolidate_datasets is before_consolidate +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,26 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTHONNOUSERSITE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export UV_OFFLINE=1 ++ ++VENV_PYTHON="/workspace/repo/.venv/bin/python" ++if [[ ! -x "${VENV_PYTHON}" ]]; then ++ echo "Expected offline test virtualenv at ${VENV_PYTHON}" >&2 ++ exit 127 ++fi ++ ++exec "${VENV_PYTHON}" -m pytest -o addopts="" /workspace/repo/usercase-test-coderl/test_to_values.py -v diff --git a/tasks/format-code-task-002935/tests/test.sh b/tasks/format-code-task-002935/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c2bfdae9760192fe5f8ae75949136644ce4d17eb --- /dev/null +++ b/tasks/format-code-task-002935/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_to_values.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-002935/tests/test_command.sh b/tasks/format-code-task-002935/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002935/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-002950/environment/Dockerfile b/tasks/format-code-task-002950/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..41688429e9c456539428eae3b260808caaa60ce5 --- /dev/null +++ b/tasks/format-code-task-002950/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:924dd53dcf7b787bd0022c6da623c582c5dbd1a91cc3361bd16a61829383dd45 diff --git a/tasks/format-code-task-002950/environment/setup/files/blocklist b/tasks/format-code-task-002950/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002950/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002950/environment/setup/setup.sh b/tasks/format-code-task-002950/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002950/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002950/tests/test.patch b/tasks/format-code-task-002950/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6d43d7c9e6db9921cd4fd7504e1b7af6559a4d9a --- /dev/null +++ b/tasks/format-code-task-002950/tests/test.patch @@ -0,0 +1,125 @@ +diff --git a/cmd/apprepository-controller/server/controller_test.go b/cmd/apprepository-controller/server/controller_test.go +index a605d3b9478..8f26ce69bf7 100644 +--- a/cmd/apprepository-controller/server/controller_test.go ++++ b/cmd/apprepository-controller/server/controller_test.go +@@ -22,6 +22,7 @@ import ( + "github.com/google/go-cmp/cmp" + apprepov1alpha1 "github.com/kubeapps/kubeapps/cmd/apprepository-controller/pkg/apis/apprepository/v1alpha1" + batchv1 "k8s.io/api/batch/v1" ++ batchv1beta1 "k8s.io/api/batch/v1beta1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +@@ -37,7 +38,7 @@ func Test_newCronJob(t *testing.T) { + crontab string + userAgentComment string + apprepo *apprepov1alpha1.AppRepository +- expected batchv1.CronJob ++ expected batchv1beta1.CronJob + }{ + { + "my-charts", +@@ -61,7 +62,7 @@ func Test_newCronJob(t *testing.T) { + URL: "https://charts.acme.com/my-charts", + }, + }, +- batchv1.CronJob{ ++ batchv1beta1.CronJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: "apprepo-kubeapps-sync-my-charts", + OwnerReferences: []metav1.OwnerReference{ +@@ -79,10 +80,10 @@ func Test_newCronJob(t *testing.T) { + }, + Annotations: map[string]string{}, + }, +- Spec: batchv1.CronJobSpec{ ++ Spec: batchv1beta1.CronJobSpec{ + Schedule: "*/10 * * * *", + ConcurrencyPolicy: "Replace", +- JobTemplate: batchv1.JobTemplateSpec{ ++ JobTemplate: batchv1beta1.JobTemplateSpec{ + Spec: batchv1.JobSpec{ + TTLSecondsAfterFinished: &defaultTTL, + Template: corev1.PodTemplateSpec{ +@@ -155,7 +156,7 @@ func Test_newCronJob(t *testing.T) { + }, + }, + }, +- batchv1.CronJob{ ++ batchv1beta1.CronJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: "apprepo-kubeapps-sync-my-charts", + OwnerReferences: []metav1.OwnerReference{ +@@ -173,10 +174,10 @@ func Test_newCronJob(t *testing.T) { + }, + Annotations: map[string]string{}, + }, +- Spec: batchv1.CronJobSpec{ ++ Spec: batchv1beta1.CronJobSpec{ + Schedule: "*/20 * * * *", + ConcurrencyPolicy: "Replace", +- JobTemplate: batchv1.JobTemplateSpec{ ++ JobTemplate: batchv1beta1.JobTemplateSpec{ + Spec: batchv1.JobSpec{ + TTLSecondsAfterFinished: &defaultTTL, + Template: corev1.PodTemplateSpec{ +@@ -255,7 +256,7 @@ func Test_newCronJob(t *testing.T) { + }, + }, + }, +- batchv1.CronJob{ ++ batchv1beta1.CronJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: "apprepo-otherns-sync-my-charts-in-otherns", + Labels: map[string]string{ +@@ -264,10 +265,10 @@ func Test_newCronJob(t *testing.T) { + }, + Annotations: map[string]string{}, + }, +- Spec: batchv1.CronJobSpec{ ++ Spec: batchv1beta1.CronJobSpec{ + Schedule: "*/20 * * * *", + ConcurrencyPolicy: "Replace", +- JobTemplate: batchv1.JobTemplateSpec{ ++ JobTemplate: batchv1beta1.JobTemplateSpec{ + Spec: batchv1.JobSpec{ + TTLSecondsAfterFinished: &defaultTTL, + Template: corev1.PodTemplateSpec{ +@@ -1416,7 +1417,7 @@ func TestObjectBelongsTo(t *testing.T) { + }{ + { + name: "it recognises a cronjob belonging to an app repository in another namespace", +- object: &batchv1.CronJob{ ++ object: &batchv1beta1.CronJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: "apprepo-kubeapps-sync-my-charts", + Namespace: "kubeapps", +@@ -1436,7 +1437,7 @@ func TestObjectBelongsTo(t *testing.T) { + }, + { + name: "it returns false if the namespace does not match", +- object: &batchv1.CronJob{ ++ object: &batchv1beta1.CronJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: "apprepo-kubeapps-sync-my-charts", + Namespace: "kubeapps", +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+3RUYrCMBSF4Ty7imzANilNuhypTXCEtilJLLj76fRFEZy+KMPg/72cC7mQC6c4 ++Xs69O/hxLsW7qEVjzJqLx1xnbSpV2UY1tRVKa6srIc3bLrpzSbmNUooYQv5tb+v9nypu/Wef8qEL ++w9COrkhfr/tjs//G3vrXy56ubWWEVK874bkP779zci3+6N3uFOTPKPezLMpucGU7TdFPIZ1ziNd9 ++F8YcQ9/7WCYf5yV2f309AAAAAAAAAAAAAAAA8Nm+AZpXfEYAKAAA +diff --git 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-002950/tests/test.sh b/tasks/format-code-task-002950/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..550dfde5b24727c002a17ba513e190c84cae5c70 --- /dev/null +++ b/tasks/format-code-task-002950/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' +cmd/apprepository-controller/server/controller_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002950/tests/test_command.sh b/tasks/format-code-task-002950/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002950/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002951/environment/Dockerfile b/tasks/format-code-task-002951/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..21d93a6ff2fe86fc3ad372395ef0fc4571cc9603 --- /dev/null +++ b/tasks/format-code-task-002951/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ff71b5e3adef78e3887b91b3b672c8d30b682191e0b654703af92bc6f8de7ded diff --git a/tasks/format-code-task-002951/environment/setup/files/blocklist b/tasks/format-code-task-002951/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002951/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002951/environment/setup/setup.sh b/tasks/format-code-task-002951/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002951/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002951/tests/test.patch b/tasks/format-code-task-002951/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..181a3dc9afba9dc6e14e18b3e008beb9bdc57258 --- /dev/null +++ b/tasks/format-code-task-002951/tests/test.patch @@ -0,0 +1,464 @@ +diff --git a/usercase-test-coderl/fixtures/env_config.json b/usercase-test-coderl/fixtures/env_config.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/env_config.json +@@ -0,0 +1,1 @@ ++{"Description":"env-picked","UUID":"env-uuid","Server":{"bindport":7070},"PluginSearchPath":[],"Plugins":[]} +diff --git a/usercase-test-coderl/fixtures/good.json b/usercase-test-coderl/fixtures/good.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/good.json +@@ -0,0 +1,1 @@ ++{"Description":"smoke","UUID":"fixed","Server":{"bindport":8080},"PluginSearchPath":[],"Plugins":[]} +diff --git a/usercase-test-coderl/fixtures/invalid_config.json b/usercase-test-coderl/fixtures/invalid_config.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/invalid_config.json +@@ -0,0 +1,1 @@ ++{"Description":"invalid","UUID":"invalid-uuid","PluginSearchPath":[],"Plugins":[],"Limits":{"PodLogs":{"SinceSeconds":7,"SinceTime":"2020-01-02T03:04:05Z"}}} +diff --git a/usercase-test-coderl/fixtures/malformed.json b/usercase-test-coderl/fixtures/malformed.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/malformed.json +@@ -0,0 +1,1 @@ ++{"Description": +diff --git a/usercase-test-coderl/fixtures/missing_plugin.json b/usercase-test-coderl/fixtures/missing_plugin.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/missing_plugin.json +@@ -0,0 +1,1 @@ ++{"Description":"missing-plugin","UUID":"missing-plugin-uuid","PluginSearchPath":["/workspace/repo/usercase-test-coderl/fixtures/plugins.d"],"Plugins":[{"name":"missing"}]} +diff --git a/usercase-test-coderl/fixtures/plugins.d/alpha.yaml b/usercase-test-coderl/fixtures/plugins.d/alpha.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/plugins.d/alpha.yaml +@@ -0,0 +1,7 @@ ++sonobuoy-config: ++ driver: Job ++ plugin-name: alpha ++ result-type: alpha ++spec: ++ image: busybox:1.36 ++ name: alpha +diff --git a/usercase-test-coderl/fixtures/plugins.d/beta.yaml b/usercase-test-coderl/fixtures/plugins.d/beta.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/plugins.d/beta.yaml +@@ -0,0 +1,7 @@ ++sonobuoy-config: ++ driver: DaemonSet ++ plugin-name: beta ++ result-type: beta ++spec: ++ image: busybox:1.36 ++ name: beta +diff --git a/usercase-test-coderl/fixtures/plugins.json b/usercase-test-coderl/fixtures/plugins.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/plugins.json +@@ -0,0 +1,1 @@ ++{"Description":"plugins","UUID":"plugins-uuid","Server":{"bindport":8081},"PluginSearchPath":["/workspace/repo/usercase-test-coderl/fixtures/plugins.d"],"Plugins":[{"name":"alpha"},{"name":"beta"}],"Namespace":"acceptance-ns","WorkerImage":"sonobuoy/worker:test","ImagePullPolicy":"Never"} +diff --git a/usercase-test-coderl/fixtures/resolve_empty_uuid.json b/usercase-test-coderl/fixtures/resolve_empty_uuid.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/resolve_empty_uuid.json +@@ -0,0 +1,1 @@ ++{"Description":"resolve","UUID":"","ResultsDir":"from-file","Server":{"bindport":9090},"PluginSearchPath":[],"Plugins":[]} +diff --git a/usercase-test-coderl/load_config_test.go b/usercase-test-coderl/load_config_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/load_config_test.go +@@ -0,0 +1,370 @@ ++package usercase_test_coderl ++ ++import ( ++ "os" ++ "path/filepath" ++ "reflect" ++ "sort" ++ "strings" ++ "testing" ++ ++ "github.com/vmware-tanzu/sonobuoy/pkg/config" ++) ++ ++const fixtures = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++type configSummary struct { ++ Description string ++ UUID string ++ LoadedPlugins []string ++} ++ ++func summarizeConfig(cfg *config.Config) configSummary { ++ ++ pluginNames := make([]string, 0, len(cfg.LoadedPlugins)) ++ for _, p := range cfg.LoadedPlugins { ++ pluginNames = append(pluginNames, p.GetName()) ++ } ++ sort.Strings(pluginNames) ++ ++ return configSummary{ ++ Description: cfg.Description, ++ UUID: cfg.UUID, ++ LoadedPlugins: pluginNames, ++ } ++} ++ ++func assertSummary(t *testing.T, got, want configSummary) { ++ t.Helper() ++ if !reflect.DeepEqual(got, want) { ++ t.Fatalf("unexpected config summary:\n got: %#v\nwant: %#v", got, want) ++ } ++} ++ ++func assertErrorContains(t *testing.T, err error, substrings ...string) { ++ t.Helper() ++ if err == nil { ++ t.Fatalf("expected error containing %q, got nil", substrings) ++ } ++ errMessage := strings.ToLower(err.Error()) ++ for _, substring := range substrings { ++ ++ if !strings.Contains(errMessage, strings.ToLower(substring)) { ++ t.Fatalf("expected error %q to contain %q", err.Error(), substring) ++ } ++ } ++} ++ ++func assertErrorPrefix(t *testing.T, err error, prefix string) { ++ t.Helper() ++ if err == nil { ++ t.Fatalf("expected error with prefix %q, got nil", prefix) ++ } ++ ++ if !strings.HasPrefix(err.Error(), prefix) { ++ t.Fatalf("expected error %q to have prefix %q", err.Error(), prefix) ++ } ++} ++ ++func isolateLoadConfigEnv(t *testing.T) { ++ t.Helper() ++ for _, key := range []string{"SONOBUOY_CONFIG", "RESULTS_DIR", "SONOBUOY_ADVERTISE_IP"} { ++ key := key ++ old, ok := os.LookupEnv(key) ++ if err := os.Unsetenv(key); err != nil { ++ t.Fatalf("unset %s: %v", key, err) ++ } ++ t.Cleanup(func() { ++ if ok { ++ _ = os.Setenv(key, old) ++ } else { ++ _ = os.Unsetenv(key) ++ } ++ }) ++ } ++} ++ ++func setEnv(t *testing.T, key, value string) { ++ t.Helper() ++ if err := os.Setenv(key, value); err != nil { ++ t.Fatalf("set %s: %v", key, err) ++ } ++} ++ ++func chdir(t *testing.T, dir string) { ++ t.Helper() ++ old, err := os.Getwd() ++ if err != nil { ++ t.Fatal(err) ++ } ++ if err := os.Chdir(dir); err != nil { ++ t.Fatal(err) ++ } ++ t.Cleanup(func() { ++ _ = os.Chdir(old) ++ }) ++} ++ ++func writeFile(t *testing.T, path, body string) { ++ t.Helper() ++ if err := os.WriteFile(path, []byte(body), 0644); err != nil { ++ t.Fatalf("write %s: %v", path, err) ++ } ++} ++ ++func loadSummary(t *testing.T, paths ...string) configSummary { ++ t.Helper() ++ cfg, err := config.LoadConfig(paths...) ++ if err != nil { ++ t.Fatal(err) ++ } ++ return summarizeConfig(cfg) ++} ++ ++func TestLoadConfigSkipsMissingExplicitPathAndLoadsNext(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.7") ++ ++ got := loadSummary(t, fixtures+"/missing.json", fixtures+"/good.json") ++ assertSummary(t, got, configSummary{ ++ Description: "smoke", ++ UUID: "fixed", ++ LoadedPlugins: []string{}, ++ }) ++} ++ ++func TestLoadConfigWithNoPathsUsesSonobuoyConfigEnv(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ setEnv(t, "SONOBUOY_CONFIG", fixtures+"/env_config.json") ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "192.0.2.10") ++ ++ got := loadSummary(t) ++ assertSummary(t, got, configSummary{ ++ Description: "env-picked", ++ UUID: "env-uuid", ++ LoadedPlugins: []string{}, ++ }) ++} ++ ++func TestLoadConfigWithNoPathsUsesDefaultConfigJSON(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.11") ++ tmp := t.TempDir() ++ writeFile(t, filepath.Join(tmp, "config.json"), `{"Description":"default-file","UUID":"default-uuid","Server":{"bindport":6060},"PluginSearchPath":[],"Plugins":[]}`) ++ chdir(t, tmp) ++ ++ got := loadSummary(t) ++ assertSummary(t, got, configSummary{ ++ Description: "default-file", ++ UUID: "default-uuid", ++ LoadedPlugins: []string{}, ++ }) ++} ++ ++func TestLoadConfigWithNoPathsFallsBackToEtcPath(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ tmp := t.TempDir() ++ chdir(t, tmp) ++ ++ cfg, err := config.LoadConfig() ++ if cfg != nil { ++ t.Fatalf("expected nil config, got %#v", summarizeConfig(cfg)) ++ } ++ assertErrorContains(t, err, "open config", "/etc/sonobuoy/config.json") ++} ++ ++func TestLoadConfigBadPathErrorIncludesOpenConfig(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ ++ cfg, err := config.LoadConfig("bad\x00path.json") ++ if cfg != nil { ++ t.Fatalf("expected nil config, got %#v", summarizeConfig(cfg)) ++ } ++ assertErrorContains(t, err, "open config") ++} ++ ++func TestLoadConfigMalformedJSONReportsUnmarshalForFile(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ ++ cfg, err := config.LoadConfig(fixtures + "/malformed.json") ++ if cfg != nil { ++ t.Fatalf("expected nil config, got %#v", summarizeConfig(cfg)) ++ } ++ assertErrorContains(t, err, "unmarshal", "malformed.json") ++} ++ ++func TestLoadConfigResolveAppliesEnvironmentOverridesAndFillsUUID(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ setEnv(t, "RESULTS_DIR", "/override/results") ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "203.0.113.8") ++ ++ cfg, err := config.LoadConfig(fixtures + "/resolve_empty_uuid.json") ++ if err != nil { ++ t.Fatal(err) ++ } ++ got := summarizeConfig(cfg) ++ generatedUUID := got.UUID ++ got.UUID = "" ++ assertSummary(t, got, configSummary{ ++ Description: "resolve", ++ UUID: "", ++ LoadedPlugins: []string{}, ++ }) ++ ++ if cfg.ResultsDir != "/override/results" { ++ t.Fatalf("expected RESULTS_DIR override, got %q", cfg.ResultsDir) ++ } ++ if generatedUUID == "" { ++ t.Fatal("expected LoadConfig to replace empty UUID with a generated value; got empty string") ++ } ++} ++ ++func TestLoadConfigInitializesSelectedPlugins(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.12") ++ ++ got := loadSummary(t, fixtures+"/plugins.json") ++ assertSummary(t, got, configSummary{ ++ Description: "plugins", ++ UUID: "plugins-uuid", ++ LoadedPlugins: []string{"alpha", "beta"}, ++ }) ++} ++ ++func TestLoadConfigMissingSelectedPluginReturnsConfiguredPluginError(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ ++ cfg, err := config.LoadConfig(fixtures + "/missing_plugin.json") ++ if cfg != nil { ++ t.Fatalf("expected nil config, got %#v", summarizeConfig(cfg)) ++ } ++ assertErrorContains(t, err, "Configured plugin", "missing", "does not exist") ++} ++ ++func TestLoadConfigValidationErrorsArePrefixed(t *testing.T) { ++ ++ ++ ++ ++ isolateLoadConfigEnv(t) ++ ++ cfg, err := config.LoadConfig(fixtures + "/invalid_config.json") ++ if cfg != nil { ++ t.Fatalf("expected nil config, got %#v", summarizeConfig(cfg)) ++ } ++ assertErrorPrefix(t, err, "invalid configuration:") ++} ++ ++func TestLoadConfigReferentialTransparencyForStableInputs(t *testing.T) { ++ isolateLoadConfigEnv(t) ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.7") ++ want := configSummary{ ++ Description: "smoke", ++ UUID: "fixed", ++ LoadedPlugins: []string{}, ++ } ++ ++ first := loadSummary(t, fixtures+"/good.json") ++ second := loadSummary(t, fixtures+"/good.json") ++ assertSummary(t, first, want) ++ assertSummary(t, second, want) ++ assertSummary(t, second, first) ++} ++ ++func TestLoadConfigAcceptsCallerPathSlice(t *testing.T) { ++ isolateLoadConfigEnv(t) ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.7") ++ paths := append([]string(nil), fixtures+"/missing.json", fixtures+"/good.json") ++ ++ got := loadSummary(t, paths...) ++ ++ assertSummary(t, got, configSummary{ ++ Description: "smoke", ++ UUID: "fixed", ++ LoadedPlugins: []string{}, ++ }) ++} ++ ++func TestLoadConfigNoGlobalStateWithInProcessNoise(t *testing.T) { ++ isolateLoadConfigEnv(t) ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.7") ++ wantStable := configSummary{ ++ Description: "smoke", ++ UUID: "fixed", ++ LoadedPlugins: []string{}, ++ } ++ ++ first := loadSummary(t, fixtures+"/good.json") ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "192.0.2.10") ++ noise := loadSummary(t, fixtures+"/env_config.json") ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.12") ++ pluginNoise := loadSummary(t, fixtures+"/plugins.json") ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.7") ++ again := loadSummary(t, fixtures+"/good.json") ++ ++ assertSummary(t, first, wantStable) ++ assertSummary(t, noise, configSummary{ ++ Description: "env-picked", ++ UUID: "env-uuid", ++ LoadedPlugins: []string{}, ++ }) ++ assertSummary(t, pluginNoise, configSummary{ ++ Description: "plugins", ++ UUID: "plugins-uuid", ++ LoadedPlugins: []string{"alpha", "beta"}, ++ }) ++ assertSummary(t, again, wantStable) ++} ++ ++func TestLoadConfigLoadsDefaultConfigJSONFromWorkingDirectory(t *testing.T) { ++ isolateLoadConfigEnv(t) ++ setEnv(t, "SONOBUOY_ADVERTISE_IP", "198.51.100.13") ++ tmp := t.TempDir() ++ writeFile(t, filepath.Join(tmp, "config.json"), `{"Description":"side-effects","UUID":"side-effects-uuid","Server":{"bindport":5050},"PluginSearchPath":[],"Plugins":[]}`) ++ chdir(t, tmp) ++ ++ got := loadSummary(t) ++ ++ ++ assertSummary(t, got, configSummary{ ++ Description: "side-effects", ++ UUID: "side-effects-uuid", ++ LoadedPlugins: []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,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002951/tests/test.sh b/tasks/format-code-task-002951/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bedaf810b3b3b89131c5bfd544641b9839ff653a --- /dev/null +++ b/tasks/format-code-task-002951/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/env_config.json +usercase-test-coderl/fixtures/good.json +usercase-test-coderl/fixtures/invalid_config.json +usercase-test-coderl/fixtures/malformed.json +usercase-test-coderl/fixtures/missing_plugin.json +usercase-test-coderl/fixtures/plugins.d/alpha.yaml +usercase-test-coderl/fixtures/plugins.d/beta.yaml +usercase-test-coderl/fixtures/plugins.json +usercase-test-coderl/fixtures/resolve_empty_uuid.json +usercase-test-coderl/load_config_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002951/tests/test_command.sh b/tasks/format-code-task-002951/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002951/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-002956/environment/Dockerfile b/tasks/format-code-task-002956/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e6f2ba0e89f3a37478d22185a2597dbe0c3301e3 --- /dev/null +++ b/tasks/format-code-task-002956/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0dcd2a918377a2b5efeaa7a98e69760c34782ba87c879d31a1c70ece704760b9 diff --git a/tasks/format-code-task-002956/environment/setup/files/blocklist b/tasks/format-code-task-002956/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002956/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002956/environment/setup/setup.sh b/tasks/format-code-task-002956/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002956/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002956/tests/test.patch b/tasks/format-code-task-002956/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..08cc95145511ced4ecc1aae31d3220149618261c --- /dev/null +++ b/tasks/format-code-task-002956/tests/test.patch @@ -0,0 +1,193 @@ +diff --git a/cns/client_test.go b/cns/client_test.go +index af86661f8..141fb0b15 100644 +--- a/cns/client_test.go ++++ b/cns/client_test.go +@@ -19,15 +19,15 @@ package cns + import ( + "context" + "os" ++ "testing" + + "github.com/kr/pretty" +- "github.com/vmware/govmomi/object" + + "github.com/vmware/govmomi/find" ++ "github.com/vmware/govmomi/object" ++ "github.com/vmware/govmomi/vim25/debug" + "github.com/vmware/govmomi/vim25/soap" + +- "testing" +- + "github.com/vmware/govmomi" + cnstypes "github.com/vmware/govmomi/cns/types" + vim25types "github.com/vmware/govmomi/vim25/types" +@@ -35,9 +35,26 @@ import ( + ) + + func TestClient(t *testing.T) { ++ ++ ++ ++ enableDebug := os.Getenv("CNS_DEBUG") ++ soapTraceDirectory := ".soap" ++ + url := os.Getenv("CNS_VC_URL") // example: export CNS_VC_URL='https://username:password@vc-ip/sdk' + datacenter := os.Getenv("CNS_DATACENTER") + datastore := os.Getenv("CNS_DATASTORE") ++ ++ ++ ++ ++ run_fileshare_tests := os.Getenv("CNS_RUN_FILESHARE_TESTS") ++ ++ ++ ++ ++ backingDiskURLPath := os.Getenv("BACKING_DISK_URL_PATH") ++ + if url == "" || datacenter == "" || datastore == "" { + t.Skip("CNS_VC_URL or CNS_DATACENTER or CNS_DATASTORE is not set") + } +@@ -46,6 +63,17 @@ func TestClient(t *testing.T) { + if err != nil { + t.Fatal(err) + } ++ ++ if enableDebug == "true" { ++ if _, err := os.Stat(soapTraceDirectory); os.IsNotExist(err) { ++ os.Mkdir(soapTraceDirectory, 0755) ++ } ++ p := debug.FileProvider{ ++ Path: soapTraceDirectory, ++ } ++ debug.SetProvider(&p) ++ } ++ + ctx := context.Background() + c, err := govmomi.NewClient(ctx, u, true) + if err != nil { +@@ -187,6 +215,36 @@ func TestClient(t *testing.T) { + } + t.Logf("Sucessfully Queried Volumes. queryResult: %+v", pretty.Sprint(queryResult)) + ++ ++ ++ ++ if cnsClient.serviceClient.Version != ReleaseVSAN67u3 && cnsClient.serviceClient.Version != ReleaseVSAN70 { ++ t.Logf("Calling QueryVolumeInfo using: %+v", pretty.Sprint(volumeIDList)) ++ queryVolumeInfoTask, err := cnsClient.QueryVolumeInfo(ctx, volumeIDList) ++ if err != nil { ++ t.Errorf("Failed to query volumes with QueryVolumeInfo. Error: %+v \n", err) ++ t.Fatal(err) ++ } ++ queryVolumeInfoTaskInfo, err := GetTaskInfo(ctx, queryVolumeInfoTask) ++ if err != nil { ++ t.Errorf("Failed to query volumes with QueryVolumeInfo. Error: %+v \n", err) ++ t.Fatal(err) ++ } ++ queryVolumeInfoTaskResult, err := GetTaskResult(ctx, queryVolumeInfoTaskInfo) ++ if err != nil { ++ t.Errorf("Failed to query volumes with QueryVolumeInfo. Error: %+v \n", err) ++ t.Fatal(err) ++ } ++ if queryVolumeInfoTaskResult == nil { ++ t.Fatalf("Empty queryVolumeInfoTaskResult") ++ t.FailNow() ++ } ++ queryVolumeInfoOperationRes := queryVolumeInfoTaskResult.GetCnsVolumeOperationResult() ++ if queryVolumeInfoOperationRes.Fault != nil { ++ t.Fatalf("Failed to query volumes with QueryVolumeInfo. fault=%+v", queryVolumeInfoOperationRes.Fault) ++ } ++ t.Logf("Sucessfully Queried Volumes. queryVolumeInfoTaskResult: %+v", pretty.Sprint(queryVolumeInfoTaskResult)) ++ } + // Test ExtendVolume API + var newCapacityInMb int64 = 10240 + var cnsVolumeExtendSpecList []cnstypes.CnsVolumeExtendSpec +@@ -452,7 +510,7 @@ func TestClient(t *testing.T) { + if attachVolumeOperationRes.Fault != nil { + t.Fatalf("Failed to attach volume: fault=%+v", attachVolumeOperationRes.Fault) + } +- diskUUID := attachVolumeOperationRes.VolumeId.Id ++ diskUUID := interface{}(attachTaskResult).(*cnstypes.CnsVolumeAttachResult).DiskUUID + t.Logf("Volume attached sucessfully. Disk UUID: %s", diskUUID) + + // Re-Attach same volume to the same node and expect ResourceInUse fault +@@ -549,7 +607,7 @@ func TestClient(t *testing.T) { + } + t.Logf("Volume: %q deleted sucessfully", volumeId) + +- if cnsClient.serviceClient.Version != ReleaseVSAN67u3 { ++ if run_fileshare_tests == "true" && cnsClient.serviceClient.Version != ReleaseVSAN67u3 { + // Test creating vSAN file-share Volume + var cnsFileVolumeCreateSpecList []cnstypes.CnsVolumeCreateSpec + vSANFileCreateSpec := &cnstypes.CnsVSANFileCreateSpec{ +@@ -650,8 +708,7 @@ func TestClient(t *testing.T) { + } + t.Logf("fileshare volume:%q deleted sucessfully", filevolumeId) + } +- if cnsClient.serviceClient.Version != ReleaseVSAN67u3 && cnsClient.serviceClient.Version != ReleaseVSAN70 { +- backingDiskURLPath := os.Getenv("BACKING_DISK_URL_PATH") ++ if backingDiskURLPath != "" && cnsClient.serviceClient.Version != ReleaseVSAN67u3 && cnsClient.serviceClient.Version != ReleaseVSAN70 { + // Test CreateVolume API with existing VMDK + var cnsVolumeCreateSpecList []cnstypes.CnsVolumeCreateSpec + cnsVolumeCreateSpec := cnstypes.CnsVolumeCreateSpec{ +diff --git a/cns/simulator/simulator_test.go b/cns/simulator/simulator_test.go +index 6f96ddda8..da32b647f 100644 +--- a/cns/simulator/simulator_test.go ++++ b/cns/simulator/simulator_test.go +@@ -21,6 +21,7 @@ import ( + "testing" + + "github.com/google/uuid" ++ + "github.com/vmware/govmomi" + "github.com/vmware/govmomi/cns" + cnstypes "github.com/vmware/govmomi/cns/types" +@@ -211,6 +212,27 @@ func TestSimulator(t *testing.T) { + t.Fatal("Number of volumes mismatches after creating a single volume") + } + ++ ++ queryVolumeInfoTask, err := cnsClient.QueryVolumeInfo(ctx, []cnstypes.CnsVolumeId{{Id: createVolumeOperationRes.VolumeId.Id}}) ++ if err != nil { ++ t.Fatal(err) ++ } ++ queryVolumeInfoTaskInfo, err := cns.GetTaskInfo(ctx, queryVolumeInfoTask) ++ if err != nil { ++ t.Fatal(err) ++ } ++ queryVolumeInfoTaskResult, err := cns.GetTaskResult(ctx, queryVolumeInfoTaskInfo) ++ if err != nil { ++ t.Fatal(err) ++ } ++ if queryVolumeInfoTaskResult == nil { ++ t.Fatalf("Empty query VolumeInfo Task Result") ++ } ++ queryVolumeInfoOperationRes := queryVolumeInfoTaskResult.GetCnsVolumeOperationResult() ++ if queryVolumeInfoOperationRes.Fault != nil { ++ t.Fatalf("Failed to query volume detail using QueryVolumeInfo: fault=%+v", queryVolumeInfoOperationRes.Fault) ++ } ++ + // QueryAll + queryFilter = cnstypes.CnsQueryFilter{} + querySelection := cnstypes.CnsQuerySelection{} +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+3STQrCMBCG4ax7iohrk6Yx7XGkbYoKtoUmen5rQfwBdaOI+D6bGZhABr5R1X67 ++86umO2jxKemocG6qo/s69cZlxuTWWmNFaowrCiHdxza6sg+xHKQUQ9/HZ+9ezX+UuuQfmxBXdd+2 ++ZedV2Lzvj5f5j7Nz/pnLx/yXeWaETN+3wmN/nv98pqttp6sybJLay+kIqsYn616eWrk4SKXrLmil ++VPLtZQEAAAAAAAAAAAAAAADcOAIimeCnACgAAA== +diff --git 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-002956/tests/test.sh b/tasks/format-code-task-002956/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..453be696515f497ad5578d0a030dd100442f5fb4 --- /dev/null +++ b/tasks/format-code-task-002956/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' +cns/client_test.go +cns/simulator/simulator_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-002956/tests/test_command.sh b/tasks/format-code-task-002956/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002956/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002957/environment/Dockerfile b/tasks/format-code-task-002957/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d3a76c83cc453c80b17b7e646c8f334fd3cee118 --- /dev/null +++ b/tasks/format-code-task-002957/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:42cf524c415b6eb959bceacdd89d75e16533fdd5cf6a9ad42cdb8e7566442aa8 diff --git a/tasks/format-code-task-002957/environment/setup/files/blocklist b/tasks/format-code-task-002957/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002957/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002957/environment/setup/setup.sh b/tasks/format-code-task-002957/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002957/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002957/tests/test.patch b/tasks/format-code-task-002957/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..44de0181cd2df66864110353f44d2b9d29d7f7ce --- /dev/null +++ b/tasks/format-code-task-002957/tests/test.patch @@ -0,0 +1,289 @@ +diff --git a/config-reloader/config/config_namespace_selector_test.go b/config-reloader/config/config_namespace_selector_test.go +new file mode 100644 +index 0000000..ef93105 +--- /dev/null ++++ b/config-reloader/config/config_namespace_selector_test.go +@@ -0,0 +1,36 @@ ++ ++ ++ ++package config ++ ++import ( ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++) ++ ++ ++ ++func TestNamespaceSelectorFlagParsedToConfigField(t *testing.T) { ++ cfg := &Config{} ++ err := cfg.ParseFlags([]string{ ++ "--datasource=default", ++ "--id=test", ++ "--namespace-selector=team=infra,tier=prod", ++ }) ++ assert.Nil(t, err) ++ assert.Equal(t, "team=infra,tier=prod", cfg.NamespaceSelector) ++ ++ assert.Nil(t, cfg.Validate()) ++} ++ ++ ++func TestNamespaceSelectorFlagDefaultsToEmpty(t *testing.T) { ++ cfg := &Config{} ++ err := cfg.ParseFlags([]string{ ++ "--datasource=default", ++ "--id=test", ++ }) ++ assert.Nil(t, err) ++ assert.Equal(t, "", cfg.NamespaceSelector) ++} +diff --git a/config-reloader/datasource/kube_informer_namespace_selector_test.go b/config-reloader/datasource/kube_informer_namespace_selector_test.go +new file mode 100644 +index 0000000..2a6a06a +--- /dev/null ++++ b/config-reloader/datasource/kube_informer_namespace_selector_test.go +@@ -0,0 +1,217 @@ ++package datasource ++ ++import ( ++ "context" ++ "sort" ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ "github.com/vmware/kube-fluentd-operator/config-reloader/config" ++ corev1 "k8s.io/api/core/v1" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++ "k8s.io/client-go/informers" ++ testclient "k8s.io/client-go/kubernetes/fake" ++) ++ ++ ++ ++func addLabeledNamespace(factory informers.SharedInformerFactory, name string, labels map[string]string) { ++ factory.Core().V1().Namespaces().Informer().GetIndexer().Add( ++ &corev1.Namespace{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: name, ++ Labels: labels, ++ }, ++ }, ++ ) ++} ++ ++ ++ ++ ++func buildCfg(t *testing.T, args []string) *config.Config { ++ t.Helper() ++ cfg := &config.Config{} ++ if err := cfg.ParseFlags(args); err != nil { ++ t.Fatalf("ParseFlags(%v) failed: %v", args, err) ++ } ++ if err := cfg.Validate(); err != nil { ++ t.Fatalf("Validate() failed for args %v: %v", args, err) ++ } ++ return cfg ++} ++ ++ ++ ++func TestDiscoverNamespacesByLabelSelectorSingleKey(t *testing.T) { ++ assert := assert.New(t) ++ ++ cfg := buildCfg(t, []string{ ++ "--datasource=default", ++ "--id=test", ++ "--namespace-selector=team=infra", ++ }) ++ ++ clientset := testclient.NewSimpleClientset() ++ factory := informers.NewSharedInformerFactory(clientset, 0) ++ ++ addLabeledNamespace(factory, "ns-infra", map[string]string{"team": "infra"}) ++ addLabeledNamespace(factory, "ns-other", map[string]string{"team": "other"}) ++ addLabeledNamespace(factory, "ns-unlabeled", nil) ++ ++ ds := &kubeInformerConnection{ ++ client: clientset, ++ cfg: cfg, ++ nslist: factory.Core().V1().Namespaces().Lister(), ++ cmlist: factory.Core().V1().ConfigMaps().Lister(), ++ podlist: factory.Core().V1().Pods().Lister(), ++ } ++ ++ namespaces, err := ds.discoverNamespaces(context.Background()) ++ assert.NoError(err) ++ sort.Strings(namespaces) ++ assert.Equal([]string{"ns-infra"}, namespaces, ++ "only the namespace whose labels match team=infra should be returned") ++} ++ ++ ++ ++func TestDiscoverNamespacesByLabelSelectorMultipleKeys(t *testing.T) { ++ assert := assert.New(t) ++ ++ cfg := buildCfg(t, []string{ ++ "--datasource=default", ++ "--id=test", ++ "--namespace-selector=team=infra,tier=prod", ++ }) ++ ++ clientset := testclient.NewSimpleClientset() ++ factory := informers.NewSharedInformerFactory(clientset, 0) ++ ++ addLabeledNamespace(factory, "ns-match", map[string]string{"team": "infra", "tier": "prod"}) ++ addLabeledNamespace(factory, "ns-partial-1", map[string]string{"team": "infra"}) ++ addLabeledNamespace(factory, "ns-partial-2", map[string]string{"team": "infra", "tier": "dev"}) ++ addLabeledNamespace(factory, "ns-other", map[string]string{"team": "other", "tier": "prod"}) ++ ++ ds := &kubeInformerConnection{ ++ client: clientset, ++ cfg: cfg, ++ nslist: factory.Core().V1().Namespaces().Lister(), ++ cmlist: factory.Core().V1().ConfigMaps().Lister(), ++ podlist: factory.Core().V1().Pods().Lister(), ++ } ++ ++ namespaces, err := ds.discoverNamespaces(context.Background()) ++ assert.NoError(err) ++ sort.Strings(namespaces) ++ assert.Equal([]string{"ns-match"}, namespaces, ++ "only namespaces matching ALL of team=infra,tier=prod should be returned") ++} ++ ++ ++ ++ ++ ++func TestDiscoverNamespacesSelectorBypassesConfigmapDiscovery(t *testing.T) { ++ assert := assert.New(t) ++ ++ cfg := buildCfg(t, []string{ ++ "--datasource=default", ++ "--id=test", ++ "--default-configmap=fluentd-config", ++ "--namespace-selector=team=infra", ++ }) ++ ++ clientset := testclient.NewSimpleClientset() ++ factory := informers.NewSharedInformerFactory(clientset, 0) ++ ++ ++ addLabeledNamespace(factory, "ns-infra", map[string]string{"team": "infra"}) ++ addLabeledNamespace(factory, "ns-other", map[string]string{"team": "other"}) ++ ++ ds := &kubeInformerConnection{ ++ client: clientset, ++ cfg: cfg, ++ nslist: factory.Core().V1().Namespaces().Lister(), ++ cmlist: factory.Core().V1().ConfigMaps().Lister(), ++ podlist: factory.Core().V1().Pods().Lister(), ++ } ++ ++ namespaces, err := ds.discoverNamespaces(context.Background()) ++ assert.NoError(err) ++ sort.Strings(namespaces) ++ assert.Equal([]string{"ns-infra"}, namespaces, ++ "namespace-selector path must select labeled namespaces even when they have no configmap") ++} ++ ++ ++ ++ ++func TestDiscoverNamespacesExplicitListTakesPrecedenceOverSelector(t *testing.T) { ++ assert := assert.New(t) ++ ++ cfg := buildCfg(t, []string{ ++ "--datasource=default", ++ "--id=test", ++ "--namespaces=ns-a", ++ "--namespaces=ns-b", ++ "--namespace-selector=team=infra", ++ }) ++ ++ clientset := testclient.NewSimpleClientset() ++ factory := informers.NewSharedInformerFactory(clientset, 0) ++ ++ ++ ++ addLabeledNamespace(factory, "ns-a", map[string]string{"team": "other"}) ++ addLabeledNamespace(factory, "ns-b", nil) ++ ++ ds := &kubeInformerConnection{ ++ client: clientset, ++ cfg: cfg, ++ nslist: factory.Core().V1().Namespaces().Lister(), ++ cmlist: factory.Core().V1().ConfigMaps().Lister(), ++ podlist: factory.Core().V1().Pods().Lister(), ++ } ++ ++ namespaces, err := ds.discoverNamespaces(context.Background()) ++ assert.NoError(err) ++ sort.Strings(namespaces) ++ assert.Equal([]string{"ns-a", "ns-b"}, namespaces, ++ "--namespaces explicit list must be returned as-is regardless of --namespace-selector") ++} ++ ++ ++ ++ ++ ++func TestDiscoverNamespacesSelectorExcludesNonMatching(t *testing.T) { ++ assert := assert.New(t) ++ ++ cfg := buildCfg(t, []string{ ++ "--datasource=default", ++ "--id=test", ++ "--namespace-selector=team=infra", ++ }) ++ ++ clientset := testclient.NewSimpleClientset() ++ factory := informers.NewSharedInformerFactory(clientset, 0) ++ ++ ++ addLabeledNamespace(factory, "ns1", map[string]string{"team": "other"}) ++ addLabeledNamespace(factory, "ns2", map[string]string{"app": "web"}) ++ addLabeledNamespace(factory, "ns3", nil) ++ ++ ds := &kubeInformerConnection{ ++ client: clientset, ++ cfg: cfg, ++ nslist: factory.Core().V1().Namespaces().Lister(), ++ cmlist: factory.Core().V1().ConfigMaps().Lister(), ++ podlist: factory.Core().V1().Pods().Lister(), ++ } ++ ++ namespaces, err := ds.discoverNamespaces(context.Background()) ++ assert.NoError(err) ++ assert.Equal([]string{}, namespaces, ++ "no namespace matches the selector, so the result must be empty") ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..379821f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,5 @@ ++{ ++ "test_commands": [ ++ "cd config-reloader && go test -run 'NamespaceSelector|DiscoverNamespaces' ./datasource/... ./config/..." ++ ] ++} +diff --git 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 config-reloader && go test -run 'NamespaceSelector|DiscoverNamespaces' ./datasource/... ./config/... ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002957/tests/test.sh b/tasks/format-code-task-002957/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..15ac6135d0f17026d730428e8bc12a636fdc43ed --- /dev/null +++ b/tasks/format-code-task-002957/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' +config-reloader/config/config_namespace_selector_test.go +config-reloader/datasource/kube_informer_namespace_selector_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-002957/tests/test_command.sh b/tasks/format-code-task-002957/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002957/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002960/environment/Dockerfile b/tasks/format-code-task-002960/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d11cb0852d0506163db52f0818b400e11daa103b --- /dev/null +++ b/tasks/format-code-task-002960/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a081071cb3f4f97e204b8f1bc8875ea8cab4de89360b1b873603bbf4025b424f diff --git a/tasks/format-code-task-002960/environment/setup/files/blocklist b/tasks/format-code-task-002960/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002960/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002960/environment/setup/setup.sh b/tasks/format-code-task-002960/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002960/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002960/tests/test.patch b/tasks/format-code-task-002960/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..de726ecb04dab1ff629b82405161d41b73af4b65 --- /dev/null +++ b/tasks/format-code-task-002960/tests/test.patch @@ -0,0 +1,325 @@ +diff --git a/tests/unittests/geojson_contract_tests.py b/tests/unittests/geojson_contract_tests.py +new file mode 100644 +index 0000000000..f53e115534 +--- /dev/null ++++ b/tests/unittests/geojson_contract_tests.py +@@ -0,0 +1,308 @@ ++import json ++import os ++ ++import pytest ++ ++import fiftyone.core.labels as fol ++import fiftyone.core.sample as fos ++from fiftyone.utils.geojson import GeoJSONImageDatasetExporter ++from fiftyone.utils.geojson import GeoJSONImageDatasetImporter ++ ++ ++def _write_json(path, value): ++ with open(path, "w") as f: ++ json.dump(value, f) ++ ++ ++def _feature(filename, geometry, **properties): ++ return { ++ "type": "Feature", ++ "geometry": geometry, ++ "properties": {"filename": filename, **properties}, ++ } ++ ++ ++def _point(x, y): ++ return {"type": "Point", "coordinates": [x, y]} ++ ++ ++def test_importer_handles_null_geometry(tmp_path): ++ data_dir = tmp_path / "data" ++ data_dir.mkdir() ++ (data_dir / "empty.jpg").write_bytes(b"image") ++ labels = { ++ "type": "FeatureCollection", ++ "features": [_feature("empty.jpg", None, raw="keep")], ++ } ++ _write_json(tmp_path / "labels.json", labels) ++ ++ importer = GeoJSONImageDatasetImporter(str(tmp_path)) ++ importer.setup() ++ samples = list(importer) ++ assert len(samples) == 1 ++ assert samples[0].raw == "keep" ++ assert samples[0].location is None ++ ++ ++def test_importer_applies_only_configured_property_parsers(tmp_path): ++ data_dir = tmp_path / "data" ++ data_dir.mkdir() ++ (data_dir / "labeled.jpg").write_bytes(b"image") ++ labels = { ++ "type": "FeatureCollection", ++ "features": [ ++ _feature("labeled.jpg", _point(1, 2), score="7", raw="keep") ++ ], ++ } ++ _write_json(tmp_path / "labels.json", labels) ++ ++ importer = GeoJSONImageDatasetImporter( ++ str(tmp_path), property_parsers={"score": int} ++ ) ++ importer.setup() ++ samples = list(importer) ++ assert samples[0].score == 7 ++ assert samples[0].raw == "keep" ++ assert samples[0].location.point == [1, 2] ++ ++ ++def _write_duplicate_features(tmp_path, second_source="shared"): ++ data_dir = tmp_path / "data" ++ data_dir.mkdir() ++ (data_dir / "same.jpg").write_bytes(b"image") ++ labels = { ++ "type": "FeatureCollection", ++ "features": [ ++ _feature( ++ "same.jpg", _point(1, 2), source="shared", first="one" ++ ), ++ _feature( ++ "same.jpg", _point(3, 4), source=second_source, second="two" ++ ), ++ ], ++ } ++ _write_json(tmp_path / "labels.json", labels) ++ ++ ++def test_importer_aggregates_duplicate_features_in_multi_mode(tmp_path): ++ _write_duplicate_features(tmp_path) ++ importer = GeoJSONImageDatasetImporter(str(tmp_path), multi_location=True) ++ importer.setup() ++ samples = list(importer) ++ assert len(samples) == 1 ++ assert samples[0].location.points == [[1, 2], [3, 4]] ++ assert samples[0].source == "shared" ++ assert samples[0].first == "one" ++ assert samples[0].second == "two" ++ ++ ++def test_importer_rejects_duplicate_features_in_single_mode(tmp_path): ++ _write_duplicate_features(tmp_path) ++ importer = GeoJSONImageDatasetImporter(str(tmp_path), multi_location=False) ++ with pytest.raises(ValueError, match="multiple features"): ++ importer.setup() ++ list(importer) ++ ++ ++def test_importer_rejects_conflicting_duplicate_properties(tmp_path): ++ _write_duplicate_features(tmp_path, second_source="conflict") ++ importer = GeoJSONImageDatasetImporter(str(tmp_path), multi_location=True) ++ with pytest.raises(ValueError, match="source"): ++ importer.setup() ++ list(importer) ++ ++ ++def test_importer_order_is_deterministic(tmp_path): ++ data_dir = tmp_path / "data" ++ data_dir.mkdir() ++ for name in ("z.jpg", "a.jpg", "unlisted.jpg"): ++ (data_dir / name).write_bytes(b"image") ++ labels = { ++ "type": "FeatureCollection", ++ "features": [ ++ _feature("z.jpg", _point(0, 0)), ++ _feature("a.jpg", _point(1, 1)), ++ ], ++ } ++ _write_json(tmp_path / "labels.json", labels) ++ ++ importer = GeoJSONImageDatasetImporter(str(tmp_path)) ++ importer.setup() ++ assert [os.path.basename(s.filepath) for s in importer] == [ ++ "z.jpg", ++ "a.jpg", ++ "unlisted.jpg", ++ ] ++ ++ ++def test_skip_unlabeled_ignores_null_geometry_and_media_only_files(tmp_path): ++ data_dir = tmp_path / "data" ++ data_dir.mkdir() ++ for name in ("z.jpg", "null.jpg", "unlisted.jpg"): ++ (data_dir / name).write_bytes(b"image") ++ labels = { ++ "type": "FeatureCollection", ++ "features": [ ++ _feature("z.jpg", _point(0, 0)), ++ _feature("null.jpg", None), ++ ], ++ } ++ _write_json(tmp_path / "labels.json", labels) ++ ++ importer = GeoJSONImageDatasetImporter(str(tmp_path), skip_unlabeled=True) ++ importer.setup() ++ assert [os.path.basename(s.filepath) for s in importer] == ["z.jpg"] ++ ++ ++def test_importer_resolves_relative_and_absolute_filepath_properties(tmp_path): ++ data_dir = tmp_path / "data" ++ data_dir.mkdir() ++ (data_dir / "named.jpg").write_bytes(b"image") ++ external_dir = tmp_path / "external" ++ external_dir.mkdir() ++ relative = external_dir / "relative.jpg" ++ absolute = external_dir / "absolute.jpg" ++ relative.write_bytes(b"image") ++ absolute.write_bytes(b"image") ++ labels = { ++ "type": "FeatureCollection", ++ "features": [ ++ _feature("named.jpg", _point(0, 0)), ++ { ++ "type": "Feature", ++ "geometry": _point(1, 1), ++ "properties": {"filepath": "external/relative.jpg"}, ++ }, ++ { ++ "type": "Feature", ++ "geometry": _point(2, 2), ++ "properties": {"filepath": str(absolute)}, ++ }, ++ ], ++ } ++ _write_json(tmp_path / "labels.json", labels) ++ ++ importer = GeoJSONImageDatasetImporter(str(tmp_path), skip_unlabeled=True) ++ importer.setup() ++ assert [s.filepath for s in importer] == [ ++ str(data_dir / "named.jpg"), ++ str(relative), ++ str(absolute), ++ ] ++ ++ ++def test_exporter_default_mode_and_media_modes_remain_compatible(tmp_path): ++ image1 = tmp_path / "one.jpg" ++ image2 = tmp_path / "two.jpg" ++ image1.write_bytes(b"one") ++ image2.write_bytes(b"two") ++ samples = [ ++ fos.Sample( ++ filepath=str(image1), ++ location=fol.GeoLocations(points=[[1, 2], [3, 4]]), ++ keep="yes", ++ omit=None, ++ ), ++ fos.Sample(filepath=str(image2), location=None, keep="no", omit=None), ++ ] ++ ++ copied_dir = tmp_path / "copied" ++ exporter = GeoJSONImageDatasetExporter( ++ str(copied_dir), ++ location_field="location", ++ property_makers={ ++ "keep": lambda value: value, ++ "omit": lambda value: value, ++ }, ++ copy_media=True, ++ ) ++ exporter.setup() ++ for sample in samples: ++ exporter.export_sample(sample) ++ exporter.close() ++ exported = json.load(open(copied_dir / "labels.json")) ++ assert len(exported["features"]) == 2 ++ assert [f["properties"]["filename"] for f in exported["features"]] == [ ++ "one.jpg", ++ "two.jpg", ++ ] ++ assert exported["features"][0]["geometry"]["type"] == "GeometryCollection" ++ assert exported["features"][0]["properties"]["keep"] == "yes" ++ assert "omit" not in exported["features"][0]["properties"] ++ assert exported["features"][1]["geometry"] is None ++ assert (copied_dir / "data" / "one.jpg").read_bytes() == b"one" ++ ++ referenced_dir = tmp_path / "referenced" ++ exporter = GeoJSONImageDatasetExporter( ++ str(referenced_dir), location_field="location", copy_media=False ++ ) ++ exporter.setup() ++ exporter.export_sample(samples[0]) ++ exporter.close() ++ exported = json.load(open(referenced_dir / "labels.json")) ++ assert exported["features"][0]["properties"]["filepath"] == str(image1) ++ assert "filename" not in exported["features"][0]["properties"] ++ ++ ++def test_flattened_export_round_trips_multi_locations(tmp_path): ++ image = tmp_path / "source.jpg" ++ empty_image = tmp_path / "empty.jpg" ++ image.write_bytes(b"image") ++ empty_image.write_bytes(b"empty") ++ sample = fos.Sample( ++ filepath=str(image), ++ location=fol.GeoLocations( ++ points=[[1, 2], [3, 4]], ++ lines=[[[5, 6], [7, 8]]], ++ polygons=[[[[0, 0], [1, 0], [1, 1], [0, 0]]]], ++ ), ++ source="survey", ++ ) ++ export_dir = tmp_path / "flat" ++ exporter = GeoJSONImageDatasetExporter( ++ str(export_dir), ++ location_field="location", ++ property_makers={"source": lambda value: value}, ++ flatten_locations=True, ++ ) ++ exporter.setup() ++ exporter.export_sample(sample) ++ exporter.export_sample( ++ fos.Sample(filepath=str(empty_image), location=None, source="empty") ++ ) ++ exporter.close() ++ ++ exported = json.load(open(export_dir / "labels.json")) ++ assert [ ++ f["geometry"]["type"] if f["geometry"] is not None else None ++ for f in exported["features"] ++ ] == [ ++ "Point", ++ "Point", ++ "LineString", ++ "Polygon", ++ None, ++ ] ++ assert [ ++ f["properties"]["filename"] for f in exported["features"][:4] ++ ] == ["source.jpg"] * 4 ++ assert [ ++ f["properties"]["source"] for f in exported["features"][:4] ++ ] == ["survey"] * 4 ++ assert exported["features"][4]["properties"] == { ++ "source": "empty", ++ "filename": "empty.jpg", ++ } ++ ++ importer = GeoJSONImageDatasetImporter( ++ str(export_dir), multi_location=True, skip_unlabeled=True ++ ) ++ importer.setup() ++ samples = list(importer) ++ assert len(samples) == 1 ++ assert samples[0].source == "survey" ++ assert samples[0].location.points == [[1, 2], [3, 4]] ++ assert samples[0].location.lines == [[[5, 6], [7, 8]]] ++ assert samples[0].location.polygons == [ ++ [[[0, 0], [1, 0], [1, 1], [0, 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,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++export FIFTYONE_DISABLE_SERVICES=1 ++python -m pytest -q tests/unittests/geojson_contract_tests.py diff --git a/tasks/format-code-task-002960/tests/test.sh b/tasks/format-code-task-002960/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..15c357c8bf25a473fe782ff7c836616df6473ece --- /dev/null +++ b/tasks/format-code-task-002960/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/unittests/geojson_contract_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-002960/tests/test_command.sh b/tasks/format-code-task-002960/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002960/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002968/environment/Dockerfile b/tasks/format-code-task-002968/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2bf43704c4b460cbf7b67540589a3a1a04906d93 --- /dev/null +++ b/tasks/format-code-task-002968/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:11658b9fabde17c0f8c2324a92959db4a20be486109debfa2ef8036cf3cec247 diff --git a/tasks/format-code-task-002968/environment/setup/files/blocklist b/tasks/format-code-task-002968/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002968/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002968/environment/setup/setup.sh b/tasks/format-code-task-002968/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002968/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002968/tests/test.patch b/tasks/format-code-task-002968/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a0b9c7d712082d73feba94cf4f21b36f67dcd6ab --- /dev/null +++ b/tasks/format-code-task-002968/tests/test.patch @@ -0,0 +1,135 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..618cfbc4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/mocha tests/lib/rules/no-ref-as-operand.js --reporter dot"] ++} +diff --git a/tests/lib/rules/no-ref-as-operand.js b/tests/lib/rules/no-ref-as-operand.js +index fb564ce1..fb450ba9 100644 +--- a/tests/lib/rules/no-ref-as-operand.js ++++ b/tests/lib/rules/no-ref-as-operand.js +@@ -672,3 +672,108 @@ tester.run('no-ref-as-operand', rule, { + } + ] + }) ++ ++ ++ ++const tsTester = new RuleTester({ ++ parser: require.resolve('vue-eslint-parser'), ++ parserOptions: { ++ ecmaVersion: 2020, ++ sourceType: 'module', ++ parser: require.resolve('@typescript-eslint/parser') ++ } ++}) ++ ++tsTester.run('no-ref-as-operand (ts/no-init)', rule, { ++ valid: [ ++ ++ ++ { ++ filename: 'test.ts', ++ code: ` ++ import { ref, Ref } from 'vue' ++ let foo: Ref | undefined; ++ if (!foo) { ++ foo = ref(5); ++ } ++ ` ++ }, ++ ++ ++ { ++ filename: 'test.js', ++ code: ` ++ import { ref } from 'vue' ++ let foo; ++ if (!foo) { ++ foo = ref(5); ++ } ++ ` ++ } ++ ], ++ invalid: [ ++ ++ ++ ++ { ++ filename: 'test.js', ++ code: ` ++ import { ref } from 'vue' ++ let count = ref(0) ++ count++ ++ `, ++ output: ` ++ import { ref } from 'vue' ++ let count = ref(0) ++ count.value++ ++ `, ++ errors: [ ++ { ++ messageId: 'requireDotValue', ++ line: 4 ++ } ++ ] ++ }, ++ ++ { ++ filename: 'test.js', ++ code: ` ++ import { ref } from 'vue' ++ const foo = ref(0) ++ if (foo) {} ++ `, ++ output: ` ++ import { ref } from 'vue' ++ const foo = ref(0) ++ if (foo.value) {} ++ `, ++ errors: [ ++ { ++ messageId: 'requireDotValue', ++ line: 4 ++ } ++ ] ++ }, ++ ++ ++ { ++ filename: 'test.ts', ++ code: ` ++ import { ref, Ref } from 'vue' ++ let foo: Ref = ref(0) ++ foo++ ++ `, ++ output: ` ++ import { ref, Ref } from 'vue' ++ let foo: Ref = ref(0) ++ foo.value++ ++ `, ++ errors: [ ++ { ++ messageId: 'requireDotValue', ++ line: 4 ++ } ++ ] ++ } ++ ] ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++./node_modules/.bin/mocha tests/lib/rules/no-ref-as-operand.js --reporter dot ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002968/tests/test.sh b/tasks/format-code-task-002968/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0387ae6ad0803d1f7b293700974393c764b8623a --- /dev/null +++ b/tasks/format-code-task-002968/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/lib/rules/no-ref-as-operand.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-002968/tests/test_command.sh b/tasks/format-code-task-002968/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002968/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002994/environment/Dockerfile b/tasks/format-code-task-002994/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6b71e459b971451453a3ea3be85767e9a4e37cae --- /dev/null +++ b/tasks/format-code-task-002994/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e22189a18330d01a136d9370c62833239a5650f1c40639532dc85c80821a57ea diff --git a/tasks/format-code-task-002994/environment/setup/files/blocklist b/tasks/format-code-task-002994/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002994/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002994/environment/setup/setup.sh b/tasks/format-code-task-002994/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002994/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002994/tests/test.patch b/tasks/format-code-task-002994/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d1a2a2d350f8250215cd2232036217091927d51 --- /dev/null +++ b/tasks/format-code-task-002994/tests/test.patch @@ -0,0 +1,77 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..763320fd +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=. /root/.cache/pypoetry/virtualenvs/wemake-python-styleguide-QnKYwBMZ-py3.9/bin/pytest tests/test_visitors/test_ast/test_naming/test_variable_self_reassignment.py --no-cov"] ++} +diff --git a/tests/test_visitors/test_ast/test_naming/test_variable_self_reassignment.py b/tests/test_visitors/test_ast/test_naming/test_variable_self_reassignment.py +index 131e5f29..8bf9cb9f 100644 +--- a/tests/test_visitors/test_ast/test_naming/test_variable_self_reassignment.py ++++ b/tests/test_visitors/test_ast/test_naming/test_variable_self_reassignment.py +@@ -86,6 +86,37 @@ right_swap4 = 'dx, dy = +dy, -dx' + right_swap5 = 'dx, dy = dy, dx' + right_swap6 = 'dy, dx = dx, dy' + ++ ++right_unary_not_issue_repro = """ ++in_code_block = False ++in_code_block = not in_code_block ++""" ++ ++right_unary_not_simple = """ ++x = True ++x = not x ++""" ++ ++right_unary_not_typed = """ ++x: bool = True ++x: bool = not x ++""" ++ ++right_unary_negative = """ ++x = 1 ++x = -x ++""" ++ ++right_unary_invert = """ ++x = 1 ++x = ~x ++""" ++ ++right_unary_plus = """ ++x = 1 ++x = +x ++""" ++ + + # Wrong: + +@@ -267,6 +298,12 @@ def test_self_variable_reassignment_triple( + right_swap4, + right_swap5, + right_swap6, ++ right_unary_not_issue_repro, ++ right_unary_not_simple, ++ right_unary_not_typed, ++ right_unary_negative, ++ right_unary_invert, ++ right_unary_plus, + ]) + def test_correct_variable_reassignment( + assert_errors, +diff --git 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=. /root/.cache/pypoetry/virtualenvs/wemake-python-styleguide-QnKYwBMZ-py3.9/bin/pytest tests/test_visitors/test_ast/test_naming/test_variable_self_reassignment.py --no-cov ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002994/tests/test.sh b/tasks/format-code-task-002994/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c347f16b0a82fa7813dbcc3161c9aab1d4c17290 --- /dev/null +++ b/tasks/format-code-task-002994/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_visitors/test_ast/test_naming/test_variable_self_reassignment.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-002994/tests/test_command.sh b/tasks/format-code-task-002994/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002994/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003010/environment/Dockerfile b/tasks/format-code-task-003010/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..176b9b8cef85672c6850351d9c6c4263375517d4 --- /dev/null +++ b/tasks/format-code-task-003010/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:191ae70f3af42d586d9b13684a01392162b4c23801c66d396ac42f4dafe66695 diff --git a/tasks/format-code-task-003010/environment/setup/files/blocklist b/tasks/format-code-task-003010/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003010/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003010/environment/setup/setup.sh b/tasks/format-code-task-003010/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003010/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003010/tests/test.patch b/tasks/format-code-task-003010/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cb976c01be48cbe0c294737dcc0034dd67bdf1d5 --- /dev/null +++ b/tasks/format-code-task-003010/tests/test.patch @@ -0,0 +1,79 @@ +diff --git a/src/core/utils/__tests__/manifest.test.ts b/src/core/utils/__tests__/manifest.test.ts +index 7bdaad947..3e04f4575 100644 +--- a/src/core/utils/__tests__/manifest.test.ts ++++ b/src/core/utils/__tests__/manifest.test.ts +@@ -1447,6 +1447,53 @@ describe('Manifest Utils', () => { + }, + ); + }); ++ ++ describe('host_permissions', () => { ++ it('should keep host_permissions as-is for MV3', async () => { ++ const expectedHostPermissions = ['https://google.com/*']; ++ const expectedPermissions = ['scripting']; ++ setFakeWxt({ ++ config: { ++ manifest: { ++ host_permissions: expectedHostPermissions, ++ permissions: expectedPermissions, ++ }, ++ manifestVersion: 3, ++ command: 'build', ++ }, ++ }); ++ const output = fakeBuildOutput(); ++ ++ const { manifest: actual } = await generateManifest([], output); ++ ++ expect(actual.permissions).toEqual(expectedPermissions); ++ expect(actual.host_permissions).toEqual(expectedHostPermissions); ++ }); ++ ++ it('should move host_permissions to permissions for MV2, ignoring duplicates', async () => { ++ const expectedPermissions = [ ++ 'scripting', ++ '*://*.youtube.com/*', ++ 'https://google.com/*', ++ ]; ++ setFakeWxt({ ++ config: { ++ manifest: { ++ host_permissions: ['https://google.com/*', '*://*.youtube.com/*'], ++ permissions: ['scripting', '*://*.youtube.com/*'], ++ }, ++ manifestVersion: 2, ++ command: 'build', ++ }, ++ }); ++ const output = fakeBuildOutput(); ++ ++ const { manifest: actual } = await generateManifest([], output); ++ ++ expect(actual.permissions).toEqual(expectedPermissions); ++ expect(actual.host_permissions).toBeUndefined(); ++ }); ++ }); + }); + + describe('stripPathFromMatchPattern', () => { +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/DIBgG8J77KXB6XV/oSk1MPHjz6ME7aQtmJBs0QJd9fGkPakx0ly1GfX4H ++IPwJkOet+snutDLuQMWl8OxWyqXPPvfLWMha1ILzhm8KLoRsZcHkxV70wRRTFxgrgvfpu32n1n+p ++6j3/ZGJSg9/vO6eruD3fHafyF237lv9G5nnRtDznz8/3hK/98/yvr6i3jvoubstBs6UIeqNLcxx9 ++SOzp4fnxfkV+TOS8Nuu6mbff3czzq9KNR3aw8xEWJsdiGGjwwdCU7C6SUvNKVIpyRdmXPK7S0sTy ++p38NAAAAAAAAAAAAAAAAAAAAAPA3vAI7H4ccACgAAA== +diff --git 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-003010/tests/test.sh b/tasks/format-code-task-003010/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed8301a75e0bd7c32725a4b47eeac0e9bbe9cdab --- /dev/null +++ b/tasks/format-code-task-003010/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/core/utils/__tests__/manifest.test.ts +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-003010/tests/test_command.sh b/tasks/format-code-task-003010/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003010/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003017/environment/Dockerfile b/tasks/format-code-task-003017/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..37a3bcc4b6fcd82ab9d7685ca95f249aa4c30335 --- /dev/null +++ b/tasks/format-code-task-003017/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ddd33443fed230042761f4af2536378f8a4a678df9acdadbf84b16cf2179a491 diff --git a/tasks/format-code-task-003017/environment/setup/files/blocklist b/tasks/format-code-task-003017/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003017/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003017/environment/setup/setup.sh b/tasks/format-code-task-003017/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003017/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-003017/tests/test.patch b/tasks/format-code-task-003017/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..810aee61d8248bb8b29582a56b4f8df860fd6bf5 --- /dev/null +++ b/tasks/format-code-task-003017/tests/test.patch @@ -0,0 +1,169 @@ +diff --git a/usercase-test-coderl/test_space_timesteps.py b/usercase-test-coderl/test_space_timesteps.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_space_timesteps.py +@@ -0,0 +1,144 @@ ++ ++ ++ ++ ++ ++ ++import builtins ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++ ++import pytest ++ ++from sdg.respace import space_timesteps ++ ++ ++def test_single_sequence_section_rounds_evenly_across_whole_timeline(): ++ ++ ++ ++ assert space_timesteps(10, [5]) == {0, 2, 4, 7, 9} ++ ++ ++def test_two_sequence_sections_split_evenly_and_reset_offsets(): ++ ++ ++ ++ assert space_timesteps(12, [3, 3]) == {0, 2, 5, 6, 8, 11} ++ ++ ++def test_sequence_sections_distribute_remainder_to_earliest_sections(): ++ ++ ++ ++ assert space_timesteps(11, [2, 3, 1]) == {0, 3, 4, 6, 7, 8} ++ ++ ++def test_sequence_sections_handle_one_requested_step_boundary(): ++ ++ ++ ++ assert space_timesteps(9, [1, 2, 3]) == {0, 3, 5, 6, 7, 8} ++ ++ ++def test_comma_string_single_count_matches_integer_list(): ++ ++ ++ ++ assert space_timesteps(10, "5") == {0, 2, 4, 7, 9} ++ ++ ++def test_comma_string_multiple_counts_matches_integer_list(): ++ ++ ++ ++ assert space_timesteps(12, "3,3") == {0, 2, 5, 6, 8, 11} ++ ++ ++def test_ddim_string_uses_integer_stride_for_requested_count(): ++ ++ ++ ++ assert space_timesteps(10, "ddim5") == {0, 2, 4, 6, 8} ++ ++ ++def test_ddim_string_can_use_nontrivial_stride_boundary(): ++ ++ ++ ++ assert space_timesteps(12, "ddim3") == {0, 4, 8} ++ ++ ++def test_sequence_request_larger_than_section_raises_value_error(): ++ ++ ++ ++ ++ with pytest.raises(ValueError): ++ space_timesteps(4, [5]) ++ ++ ++def test_ddim_request_without_integer_stride_raises_value_error(): ++ ++ ++ ++ ++ with pytest.raises(ValueError): ++ space_timesteps(10, "ddim7") ++ ++ ++def test_referential_transparency_for_repeated_same_input(): ++ first = space_timesteps(11, [2, 3, 1]) ++ second = space_timesteps(11, [2, 3, 1]) ++ assert first == {0, 3, 4, 6, 7, 8} ++ assert second == {0, 3, 4, 6, 7, 8} ++ assert first == second ++ ++ ++def test_does_not_mutate_section_counts_list(): ++ section_counts = [2, 3, 1] ++ original = copy.deepcopy(section_counts) ++ assert space_timesteps(11, section_counts) == {0, 3, 4, 6, 7, 8} ++ assert section_counts == original ++ ++ ++def test_no_global_state_across_fresh_python_process(): ++ in_process = sorted(space_timesteps(12, [3, 3])) ++ script = ( ++ "import json, sys; " ++ "sys.path.insert(0, '/workspace/repo'); " ++ "from sdg.respace import space_timesteps; " ++ "sys.stdout.write(json.dumps(sorted(space_timesteps(12, [3, 3]))))" ++ ) ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ assert in_process == [0, 2, 5, 6, 8, 11] ++ assert fresh_process == [0, 2, 5, 6, 8, 11] ++ assert fresh_process == in_process ++ ++ ++def test_no_filesystem_network_or_open_side_effects(tmp_path, monkeypatch): ++ def fail_socket(*args, **kwargs): ++ raise AssertionError("space_timesteps must not open network sockets") ++ ++ def fail_open(*args, **kwargs): ++ raise AssertionError("space_timesteps must not access files") ++ ++ monkeypatch.chdir(tmp_path) ++ monkeypatch.setattr(socket, "socket", fail_socket) ++ monkeypatch.setattr(builtins, "open", fail_open) ++ ++ before = sorted(os.listdir(tmp_path)) ++ assert space_timesteps(10, "ddim5") == {0, 2, 4, 6, 8} ++ after = sorted(os.listdir(tmp_path)) ++ assert after == before == [] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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 -euo pipefail ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTHONDONTWRITEBYTECODE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec python -m pytest -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_space_timesteps.py -v diff --git a/tasks/format-code-task-003017/tests/test.sh b/tasks/format-code-task-003017/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4c4c09123aa68668eab85af5217f86b7eea8ffbd --- /dev/null +++ b/tasks/format-code-task-003017/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_space_timesteps.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-003017/tests/test_command.sh b/tasks/format-code-task-003017/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003017/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-003019/environment/Dockerfile b/tasks/format-code-task-003019/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..31f8862b4a05ffa54d9016b32ebed3e2c2e26c86 --- /dev/null +++ b/tasks/format-code-task-003019/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dd419ec998e0f8ac02fa747e9597bd7c1a2aea23631ca8fd95c7d9a333e3ca3e diff --git a/tasks/format-code-task-003019/environment/setup/files/blocklist b/tasks/format-code-task-003019/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003019/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003019/environment/setup/setup.sh b/tasks/format-code-task-003019/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003019/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003019/tests/test.patch b/tasks/format-code-task-003019/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e9b93adfb56c5fa02f841d03e3255512135e79a2 --- /dev/null +++ b/tasks/format-code-task-003019/tests/test.patch @@ -0,0 +1,215 @@ +diff --git a/tests/django_example/example/__init__.py b/tests/django_example/example/__init__.py +new file mode 100644 +index 0000000..e69de29 +diff --git a/tests/django_example/example/settings.py b/tests/django_example/example/settings.py +new file mode 100644 +index 0000000..1f69f09 +--- /dev/null ++++ b/tests/django_example/example/settings.py +@@ -0,0 +1,31 @@ ++ ++import os ++ ++ ++BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ++SECRET_KEY = 'not-a-secret' ++DEBUG = True ++ALLOWED_HOSTS = [] ++INSTALLED_APPS = ['app', 'app2'] ++MIDDLEWARE_CLASSES = [] ++ROOT_URLCONF = 'example.urls' ++TEMPLATES = [] ++DATABASES = { ++ 'default': { ++ 'ENGINE': 'django.db.backends.sqlite3', ++ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), ++ } ++} ++LANGUAGE_CODE = 'en-us' ++TIME_ZONE = 'UTC' ++USE_I18N = True ++USE_L10N = True ++USE_TZ = True ++STATIC_URL = '/static/' ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/django_example/example/urls.py b/tests/django_example/example/urls.py +new file mode 100644 +index 0000000..0c8ed42 +--- /dev/null ++++ b/tests/django_example/example/urls.py +@@ -0,0 +1,8 @@ ++ ++from django.conf.urls import url ++from django.contrib import admin ++ ++ ++urlpatterns = [ ++ url(r'^admin/', admin.site.urls), ++] +diff --git a/tests/django_example/example/wsgi.py b/tests/django_example/example/wsgi.py +new file mode 100644 +index 0000000..314e9ca +--- /dev/null ++++ b/tests/django_example/example/wsgi.py +@@ -0,0 +1,7 @@ ++ ++import os ++from django.core.wsgi import get_wsgi_application ++ ++ ++os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") ++application = get_wsgi_application() +diff --git a/tests/django_example/manage.py b/tests/django_example/manage.py +new file mode 100755 +index 0000000..e0e65d2 +--- /dev/null ++++ b/tests/django_example/manage.py +@@ -0,0 +1,9 @@ ++#!/usr/bin/env python ++import os ++import sys ++ ++ ++if __name__ == "__main__": ++ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") ++ from django.core.management import execute_from_command_line ++ execute_from_command_line(sys.argv) +diff --git a/tests/django_test.py b/tests/django_test.py +index f113991..b4d4f23 100644 +--- a/tests/django_test.py ++++ b/tests/django_test.py +@@ -1,7 +1,11 @@ + from xmlrunner.unittest import unittest + + import sys +-from os import path, chdir, getcwd ++import os ++from os import path ++import glob ++import tempfile ++import shutil + + try: + import django +@@ -9,6 +13,9 @@ + django = None + else: + from django.test.utils import get_runner ++ from django.conf import settings, UserSettingsHolder ++ from django.apps import apps ++ + + TESTS_DIR = path.dirname(__file__) + +@@ -17,15 +24,30 @@ + class DjangoTest(unittest.TestCase): + + def setUp(self): +- self._old_cwd = getcwd() ++ self._old_cwd = os.getcwd() + self.project_dir = path.abspath(path.join(TESTS_DIR, 'django_example')) +- chdir(self.project_dir) ++ self.tmpdir = tempfile.mkdtemp() ++ os.chdir(self.project_dir) + sys.path.append(self.project_dir) +- import django.conf +- django.conf.settings = django.conf.LazySettings() ++ ++ self.old_settings = settings._wrapped ++ os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings' ++ settings.INSTALLED_APPS ++ settings.DATABASES['default']['NAME'] = path.join( ++ self.tmpdir, 'db.sqlilte3') ++ ++ self.override = UserSettingsHolder(settings._wrapped) ++ settings._wrapped = self.override + + def tearDown(self): +- chdir(self._old_cwd) ++ os.chdir(self._old_cwd) ++ shutil.rmtree(self.tmpdir) ++ settings._wrapped = self.old_settings ++ ++ def _override_settings(self, **kwargs): ++ ++ for key, new_value in kwargs.items(): ++ setattr(self.override, key, new_value) + + def _check_runner(self, runner): + suite = runner.build_suite(test_labels=['app2', 'app']) +@@ -42,17 +64,42 @@ def _check_runner(self, runner): + ])) + + def test_django_runner(self): +- from django.conf import settings +- settings.configure(INSTALLED_APPS=['app', 'app2']) + runner_class = get_runner(settings) + runner = runner_class() + self._check_runner(runner) + + def test_django_xmlrunner(self): +- from django.conf import settings +- settings.configure( +- INSTALLED_APPS=['app', 'app2'], ++ self._override_settings( + TEST_RUNNER='xmlrunner.extra.djangotestrunner.XMLTestRunner') + runner_class = get_runner(settings) + runner = runner_class() + self._check_runner(runner) ++ ++ def test_django_single_report(self): ++ self._override_settings( ++ TEST_OUTPUT_DIR=self.tmpdir, ++ TEST_OUTPUT_FILE_NAME='results.xml', ++ TEST_OUTPUT_VERBOSE=0, ++ TEST_RUNNER='xmlrunner.extra.djangotestrunner.XMLTestRunner') ++ apps.populate(settings.INSTALLED_APPS) ++ runner_class = get_runner(settings) ++ runner = runner_class() ++ suite = runner.build_suite() ++ runner.run_suite(suite) ++ expected_file = path.join(self.tmpdir, 'results.xml') ++ self.assertTrue(path.exists(expected_file), ++ 'did not generate xml report where expected.') ++ ++ def test_django_multiple_reports(self): ++ self._override_settings( ++ TEST_OUTPUT_DIR=self.tmpdir, ++ TEST_OUTPUT_VERBOSE=0, ++ TEST_RUNNER='xmlrunner.extra.djangotestrunner.XMLTestRunner') ++ apps.populate(settings.INSTALLED_APPS) ++ runner_class = get_runner(settings) ++ runner = runner_class() ++ suite = runner.build_suite(test_labels=None) ++ runner.run_suite(suite) ++ test_files = glob.glob(path.join(self.tmpdir, 'TEST*.xml')) ++ self.assertTrue(test_files, ++ 'did not generate xml reports where 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+3SQU+DMBQHcM58ijq9DgpSSEx2WLJl0yhbMjx4IjCagRmF0LLMby82mzMmussW ++Nf5/l9e077VNX620LdZZzMXGNs6FdgLGdOx8jnrsMNdxKQuYGxjUcXwaGISd7UYftFIlDSFGU1Xq ++u7xj63+Udei/4lLFy6osE5FZMj/dGcf67zL/vf+e1807nu9Sg9DTXeFr/7z/lxd2Wgg7TWRuLjOi ++P0HKM5Nv66pRZHQ3DCezeDGOottwsogfZqPH+/GAb5OyXnNLcqUKsZL79PlTNJ2F82E0HfT2W+ko ++7ew5Easq3lXeXB1Se2b9ovJKXJN+SVpRqLcCoqusXZWe6W/Mn34tAAAAAAAAAAAAAAAAAAAAAIDf ++5RVbAV5+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-003019/tests/test.sh b/tasks/format-code-task-003019/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..da00495f75968fa0e3ef58bc5e04aca14de9e19d --- /dev/null +++ b/tasks/format-code-task-003019/tests/test.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 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/django_example/example/__init__.py +tests/django_example/example/settings.py +tests/django_example/example/urls.py +tests/django_example/example/wsgi.py +tests/django_example/manage.py +tests/django_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-003019/tests/test_command.sh b/tasks/format-code-task-003019/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003019/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003021/environment/Dockerfile b/tasks/format-code-task-003021/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..93e6b439075b1e5f011c753ef0bde716a03492e0 --- /dev/null +++ b/tasks/format-code-task-003021/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2ea60a396133ca493f098801a2a45e38ac43fde0fd330456972c1820999acda3 diff --git a/tasks/format-code-task-003021/environment/setup/files/blocklist b/tasks/format-code-task-003021/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003021/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003021/environment/setup/setup.sh b/tasks/format-code-task-003021/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003021/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003021/tests/test.patch b/tasks/format-code-task-003021/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..676b3386eb58e8d3216a13cd7a10b8a5d567bf03 --- /dev/null +++ b/tasks/format-code-task-003021/tests/test.patch @@ -0,0 +1,145 @@ +diff --git a/tvm/cell/hash_test.go b/tvm/cell/hash_test.go +new file mode 100644 +index 0000000..4359701 +--- /dev/null ++++ b/tvm/cell/hash_test.go +@@ -0,0 +1,118 @@ ++package cell ++ ++import ( ++ "bytes" ++ "crypto/sha256" ++ "encoding/hex" ++ "testing" ++) ++ ++func mustHex(t *testing.T, s string) []byte { ++ t.Helper() ++ b, err := hex.DecodeString(s) ++ if err != nil { ++ t.Fatalf("bad hex %q: %v", s, err) ++ } ++ return b ++} ++ ++func TestCellHash_Length(t *testing.T) { ++ c := BeginCell().MustStoreUInt(0xABCD, 16).EndCell() ++ h := c.Hash() ++ if len(h) != 32 { ++ t.Fatalf("expected 32 byte hash, got %d", len(h)) ++ } ++} ++ ++func TestCellHash_KnownVectors(t *testing.T) { ++ cases := []struct { ++ name string ++ cell *Cell ++ want string ++ }{ ++ { ++ name: "leaf 16 bit", ++ cell: BeginCell().MustStoreUInt(0xABCD, 16).EndCell(), ++ want: "c580b831e55fcba6f9635f9818ae4d6227b21d370913e36c6f31789d89ac3bde", ++ }, ++ { ++ name: "non byte aligned 3 bit", ++ cell: BeginCell().MustStoreUInt(0b101, 3).EndCell(), ++ want: "c8235418b5cd55bc46073ea5cf9f3aac5a594ed782bee88dcd0acfd8ede4c756", ++ }, ++ { ++ name: "nested chain with refs", ++ cell: func() *Cell { ++ cc1 := BeginCell().MustStoreUInt(111, 63).EndCell() ++ cc2 := BeginCell().MustStoreUInt(772227, 63).MustStoreRef(cc1).EndCell() ++ cc3 := BeginCell().MustStoreUInt(333, 63).MustStoreRef(cc2).EndCell() ++ return BeginCell().MustStoreUInt(777, 63).MustStoreRef(cc3).EndCell() ++ }(), ++ want: "bb2509fe3cff8f1faae19213774d218c018f9616cd397850c8ad9038db84eaa9", ++ }, ++ } ++ ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ got := tc.cell.Hash() ++ if !bytes.Equal(got, mustHex(t, tc.want)) { ++ t.Fatalf("hash mismatch\n got: %s\nwant: %s", hex.EncodeToString(got), tc.want) ++ } ++ }) ++ } ++} ++ ++func TestCellHash_EmptyCell(t *testing.T) { ++ ++ want := sha256.Sum256([]byte{0x00, 0x00}) ++ ++ got := BeginCell().EndCell().Hash() ++ if !bytes.Equal(got, want[:]) { ++ t.Fatalf("empty cell hash mismatch\n got: %s\nwant: %s", ++ hex.EncodeToString(got), hex.EncodeToString(want[:])) ++ } ++} ++ ++func TestCellHash_Deterministic(t *testing.T) { ++ build := func() *Cell { ++ ref := BeginCell().MustStoreUInt(42, 32).EndCell() ++ return BeginCell().MustStoreUInt(7, 8).MustStoreRef(ref).EndCell() ++ } ++ ++ c := build() ++ h1 := c.Hash() ++ h2 := c.Hash() ++ if !bytes.Equal(h1, h2) { ++ t.Fatal("hashing the same cell twice produced different results") ++ } ++ ++ ++ if !bytes.Equal(build().Hash(), h1) { ++ t.Fatal("two identical cells produced different hashes") ++ } ++} ++ ++func TestCellHash_DataSensitive(t *testing.T) { ++ a := BeginCell().MustStoreUInt(1, 16).EndCell() ++ b := BeginCell().MustStoreUInt(2, 16).EndCell() ++ if bytes.Equal(a.Hash(), b.Hash()) { ++ t.Fatal("cells with different data hashed to the same value") ++ } ++} ++ ++func TestCellHash_RefSensitive(t *testing.T) { ++ refA := BeginCell().MustStoreUInt(1, 8).EndCell() ++ refB := BeginCell().MustStoreUInt(2, 8).EndCell() ++ ++ noRef := BeginCell().MustStoreUInt(0xFF, 8).EndCell() ++ withRef := BeginCell().MustStoreUInt(0xFF, 8).MustStoreRef(refA).EndCell() ++ if bytes.Equal(noRef.Hash(), withRef.Hash()) { ++ t.Fatal("cell with a reference hashed same as one without") ++ } ++ ++ ab := BeginCell().MustStoreUInt(0xFF, 8).MustStoreRef(refA).MustStoreRef(refB).EndCell() ++ ba := BeginCell().MustStoreUInt(0xFF, 8).MustStoreRef(refB).MustStoreRef(refA).EndCell() ++ if bytes.Equal(ab.Hash(), ba.Hash()) { ++ t.Fatal("reference order did not affect the hash") ++ } ++} +diff --git 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 ++ ++ ++ ++ ++go test ./tvm/cell/ -run '^(TestCell|TestCell24|TestCell25|TestCellReadSmall|TestCellReadEmpty)$' ++ ++ ++go test ./tvm/cell/ -run 'TestCellHash' -v diff --git a/tasks/format-code-task-003021/tests/test.sh b/tasks/format-code-task-003021/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4cba2ba62c9c1e6434884d2fcfb9c4d5fc894f96 --- /dev/null +++ b/tasks/format-code-task-003021/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' +tvm/cell/hash_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-003021/tests/test_command.sh b/tasks/format-code-task-003021/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003021/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003028/environment/Dockerfile b/tasks/format-code-task-003028/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3856d4d6b2d5d329a1db4f406b9d83eee6190a5b --- /dev/null +++ b/tasks/format-code-task-003028/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:446c952ffb05ca5d4f3569a5d424bba58b5a36a53106b2521850ee0911be88f3 diff --git a/tasks/format-code-task-003028/environment/setup/files/blocklist b/tasks/format-code-task-003028/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003028/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003028/environment/setup/setup.sh b/tasks/format-code-task-003028/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003028/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003028/tests/test.patch b/tasks/format-code-task-003028/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bef0e90e7023acd836952329974ecb10fe951dc8 --- /dev/null +++ b/tasks/format-code-task-003028/tests/test.patch @@ -0,0 +1,149 @@ +diff --git a/test/usage.js b/test/usage.js +index cc84d5b..d1d5205 100644 +--- a/test/usage.js ++++ b/test/usage.js +@@ -3673,4 +3673,122 @@ describe('usage tests', () => { + ' --small Packet size' + ]) + }) ++ ++ describe('single-character aliases ordering (#1403)', () => { ++ it('lists single-char alias before long form for options declared with option()', () => { ++ const r = checkUsage(() => yargs('--help') ++ .option('verbose', { alias: 'v', describe: 'Explain', type: 'boolean' }) ++ .wrap(null) ++ .parse() ++ ) ++ const lines = r.logs[0].split('\n') ++ const verboseLine = lines.find(l => l.indexOf('--verbose') >= 0) ++ verboseLine.should.equal(' -v, --verbose Explain [boolean]') ++ ++ verboseLine.indexOf('--verbose, -v').should.equal(-1) ++ }) ++ ++ it('lists single-char alias before long form when alias is added via .alias()', () => { ++ const r = checkUsage(() => yargs('--help') ++ .alias('help', 'h') ++ .wrap(null) ++ .parse() ++ ) ++ const lines = r.logs[0].split('\n') ++ const helpLine = lines.find(l => l.indexOf('--help') >= 0) ++ ++ helpLine.indexOf('-h').should.be.lessThan(helpLine.indexOf('--help')) ++ helpLine.indexOf('--help, -h').should.equal(-1) ++ }) ++ ++ it('indents long-only options to align with options that have a short alias', () => { ++ const r = checkUsage(() => yargs('--help') ++ .option('verbose', { alias: 'v', describe: 'Explain', type: 'boolean' }) ++ .option('xx', { describe: 'just xx' }) ++ .wrap(null) ++ .parse() ++ ) ++ const lines = r.logs[0].split('\n') ++ ++ const verboseLine = lines.find(l => l.indexOf('--verbose') >= 0) ++ verboseLine.should.equal(' -v, --verbose Explain [boolean]') ++ ++ ++ const xxLine = lines.find(l => l.indexOf('--xx') >= 0) ++ xxLine.should.equal(' --xx just xx') ++ ++ xxLine.should.match(/^ --xx/) ++ }) ++ ++ it('does NOT add extra indent when no option in the group has a short alias', () => { ++ const r = checkUsage(() => yargs('--help') ++ .option('foo', { describe: 'Foo', type: 'boolean' }) ++ .option('bar', { describe: 'Bar', type: 'string' }) ++ .wrap(null) ++ .parse() ++ ) ++ const lines = r.logs[0].split('\n') ++ const fooLine = lines.find(l => l.indexOf('--foo') >= 0) ++ const barLine = lines.find(l => l.indexOf('--bar') >= 0) ++ ++ fooLine.should.match(/^ --foo /) ++ barLine.should.match(/^ --bar /) ++ fooLine.should.equal(' --foo Foo [boolean]') ++ barLine.should.equal(' --bar Bar [string]') ++ }) ++ ++ it('does not add the `--` prefix or extra indent to positional arguments', () => { ++ const r = checkUsage(() => yargs('cmd --help') ++ .command('cmd ', 'do cmd', (yargs) => { ++ yargs.positional('foo', { describe: 'Foo positional', type: 'string' }) ++ .option('verbose', { alias: 'v', describe: 'Explain' }) ++ }) ++ .wrap(null) ++ .parse() ++ ) ++ const lines = r.logs[0].split('\n') ++ const positionalsIdx = lines.findIndex(l => l.indexOf('Positionals:') === 0) ++ positionalsIdx.should.be.greaterThan(-1) ++ const fooLine = lines[positionalsIdx + 1] ++ ++ fooLine.should.match(/^ foo /) ++ fooLine.indexOf('--foo').should.equal(-1) ++ fooLine.indexOf('-foo').should.equal(-1) ++ }) ++ ++ it('indents long-only options across groups when any group has a short alias', () => { ++ const r = checkUsage(() => yargs('--help') ++ .option('verbose', { alias: 'v', describe: 'Explain', type: 'boolean' }) ++ .option('output', { alias: 'O', describe: 'Out', type: 'string' }) ++ .group(['help'], 'Other:') ++ .group(['verbose', 'output'], 'Main:') ++ .wrap(null) ++ .parse() ++ ) ++ const lines = r.logs[0].split('\n') ++ ++ ++ const helpLine = lines.find(l => l.indexOf('--help') >= 0) ++ helpLine.should.match(/^ --help/) ++ ++ const versionLine = lines.find(l => l.indexOf('--version') >= 0) ++ versionLine.should.match(/^ --version/) ++ ++ const verboseLine = lines.find(l => l.indexOf('--verbose') >= 0) ++ verboseLine.should.match(/^ -v, --verbose/) ++ }) ++ ++ it('places multiple short aliases before the long form in the switches column', () => { ++ const r = checkUsage(() => yargs('--help') ++ .option('verbose', { alias: ['v', 'V'], describe: 'Explain', type: 'boolean' }) ++ .wrap(null) ++ .parse() ++ ) ++ const lines = r.logs[0].split('\n') ++ const verboseLine = lines.find(l => l.indexOf('--verbose') >= 0) ++ ++ verboseLine.indexOf('-v').should.be.lessThan(verboseLine.indexOf('--verbose')) ++ verboseLine.indexOf('-V').should.be.lessThan(verboseLine.indexOf('--verbose')) ++ }) ++ }) + }) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..4281a12 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npm run compile -- -p tsconfig.test.json && npx mocha --require ./test/before.js --timeout=12000 --check-leaks --grep \"single-character aliases ordering\" test/usage.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 ++npm run compile -- -p tsconfig.test.json && npx mocha --require ./test/before.js --timeout=12000 --check-leaks --grep "single-character aliases ordering" test/usage.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-003028/tests/test.sh b/tasks/format-code-task-003028/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ec4db44ef9a90cdbd9f62e0b7b973136f3613442 --- /dev/null +++ b/tasks/format-code-task-003028/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/usage.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-003028/tests/test_command.sh b/tasks/format-code-task-003028/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003028/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file