diff --git a/tasks/format-code-task-000034/environment/Dockerfile b/tasks/format-code-task-000034/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5bab8d1313fae1cbc6db006026bb8ce7a2d609e6 --- /dev/null +++ b/tasks/format-code-task-000034/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:97cb9a9081323508cf4eaa282765cfe9253530e431d20cd5e74758bc96193edb diff --git a/tasks/format-code-task-000034/environment/setup/files/blocklist b/tasks/format-code-task-000034/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000034/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000034/environment/setup/setup.sh b/tasks/format-code-task-000034/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000034/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000034/tests/test.patch b/tasks/format-code-task-000034/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8ff5a8ef844484ef2f1f6fd7bde02489d75cc1f7 --- /dev/null +++ b/tasks/format-code-task-000034/tests/test.patch @@ -0,0 +1,259 @@ +diff --git a/cli/azd/internal/vsrpc/handler_test.go b/cli/azd/internal/vsrpc/handler_test.go +index a4f33297f..9d78cc34d 100644 +--- a/cli/azd/internal/vsrpc/handler_test.go ++++ b/cli/azd/internal/vsrpc/handler_test.go +@@ -3,6 +3,7 @@ package vsrpc + import ( + "context" + "errors" ++ "strings" + "testing" + + "github.com/stretchr/testify/require" +@@ -83,6 +84,144 @@ func TestHandler(t *testing.T) { + t.Run("HandlerFunc3", func(t *testing.T) { runHandlerSuite(t, newHandlerFunc3, []any{"arg0", "arg1", "arg2"}, "ok") }) + } + ++type panicHandlerCase struct { ++ name string ++ message string ++ handler Handler ++ request jsonrpc2.Request ++} ++ ++func TestPanicRecoveredAcrossHandlerAdapters(t *testing.T) { ++ cases := []panicHandlerCase{ ++ { ++ name: "action zero args", ++ message: "hidden action zero panic", ++ handler: HandlerAction0(func(context.Context) error { ++ panicRpcTestFrame("hidden action zero panic") ++ return nil ++ }), ++ request: requestWithParams(t), ++ }, ++ { ++ name: "action one arg", ++ message: "hidden action one panic", ++ handler: HandlerAction1(func(ctx context.Context, value string) error { ++ require.Equal(t, "alpha", value) ++ panicRpcTestFrame("hidden action one panic") ++ return nil ++ }), ++ request: requestWithParams(t, "alpha"), ++ }, ++ { ++ name: "action two args", ++ message: "hidden action two panic", ++ handler: HandlerAction2(func(ctx context.Context, value string, count int) error { ++ require.Equal(t, "bravo", value) ++ require.Equal(t, 42, count) ++ panicRpcTestFrame("hidden action two panic") ++ return nil ++ }), ++ request: requestWithParams(t, "bravo", 42), ++ }, ++ { ++ name: "action three args", ++ message: "hidden action three panic", ++ handler: HandlerAction3(func(ctx context.Context, value string, count int, flag bool) error { ++ require.Equal(t, "charlie", value) ++ require.Equal(t, 7, count) ++ require.True(t, flag) ++ panicRpcTestFrame("hidden action three panic") ++ return nil ++ }), ++ request: requestWithParams(t, "charlie", 7, true), ++ }, ++ { ++ name: "func zero args", ++ message: "hidden func zero panic", ++ handler: HandlerFunc0(func(context.Context) (string, error) { ++ panicRpcTestFrame("hidden func zero panic") ++ return "", nil ++ }), ++ request: requestWithParams(t), ++ }, ++ { ++ name: "func one arg", ++ message: "hidden func one panic", ++ handler: HandlerFunc1(func(ctx context.Context, value string) (string, error) { ++ require.Equal(t, "delta", value) ++ panicRpcTestFrame("hidden func one panic") ++ return "", nil ++ }), ++ request: requestWithParams(t, "delta"), ++ }, ++ { ++ name: "func two args", ++ message: "hidden func two panic", ++ handler: HandlerFunc2(func(ctx context.Context, value string, count int) (string, error) { ++ require.Equal(t, "echo", value) ++ require.Equal(t, 84, count) ++ panicRpcTestFrame("hidden func two panic") ++ return "", nil ++ }), ++ request: requestWithParams(t, "echo", 84), ++ }, ++ { ++ name: "func three args", ++ message: "hidden func three panic", ++ handler: HandlerFunc3(func(ctx context.Context, value string, count int, flag bool) (string, error) { ++ require.Equal(t, "foxtrot", value) ++ require.Equal(t, 21, count) ++ require.False(t, flag) ++ panicRpcTestFrame("hidden func three panic") ++ return "", nil ++ }), ++ request: requestWithParams(t, "foxtrot", 21, false), ++ }, ++ } ++ ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ var repliedErr error ++ reply := func(ctx context.Context, result any, err error) error { ++ repliedErr = err ++ return err ++ } ++ ++ var handlerErr error ++ require.NotPanics(t, func() { ++ handlerErr = tc.handler(context.Background(), nil, reply, tc.request) ++ }) ++ ++ require.Error(t, handlerErr) ++ require.Same(t, repliedErr, handlerErr) ++ assertPanicRpcError(t, handlerErr, tc.message) ++ }) ++ } ++} ++ ++func requestWithParams(t *testing.T, params ...any) jsonrpc2.Request { ++ t.Helper() ++ ++ req, err := jsonrpc2.NewCall(jsonrpc2.NewNumberID(1), "hidden/test", params) ++ require.NoError(t, err) ++ ++ return req ++} ++ ++func assertPanicRpcError(t *testing.T, err error, panicMessage string) { ++ t.Helper() ++ ++ var rpcErr *jsonrpc2.Error ++ require.True(t, errors.As(err, &rpcErr), "expected JSON-RPC error, got %T: %v", err, err) ++ require.Equal(t, jsonrpc2.InternalError, rpcErr.Code) ++ require.True(t, strings.HasPrefix(rpcErr.Message, "panic:"), "message should start with panic:, got %q", rpcErr.Message) ++ require.Contains(t, rpcErr.Message, panicMessage) ++} ++ ++func panicRpcTestFrame(message string) { ++ panic(message) ++} ++ + func newHandlerAction0(t *testing.T, tc handlerTestCase) Handler { + return HandlerAction0(func(ctx context.Context) error { + select { +diff --git a/cli/azd/internal/vsrpc/server_test.go b/cli/azd/internal/vsrpc/server_test.go +index 4ed8aad0e..3f5a3016c 100644 +--- a/cli/azd/internal/vsrpc/server_test.go ++++ b/cli/azd/internal/vsrpc/server_test.go +@@ -6,8 +6,10 @@ import ( + "errors" + "net/http/httptest" + "net/url" ++ "strings" + "sync" + "testing" ++ "time" + + "github.com/gorilla/websocket" + "github.com/stretchr/testify/require" +@@ -132,3 +134,64 @@ func TestObserverable(t *testing.T) { + // The onCompleted message takes no parameters and the args value is empty. + require.Len(t, onCompletedParams[0], 0) + } ++ ++func TestDebugServicePanicErrorDetails(t *testing.T) { ++ rpcConn := debugRpcConn(t) ++ ++ err := callTestPanicAsync(t, rpcConn, "panic probe alpha hidden") ++ assertDebugPanicError(t, err, "panic probe alpha hidden") ++} ++ ++func TestDebugServicePanicDoesNotCloseConnection(t *testing.T) { ++ rpcConn := debugRpcConn(t) ++ ++ firstErr := callTestPanicAsync(t, rpcConn, "panic probe beta one hidden") ++ assertDebugPanicError(t, firstErr, "panic probe beta one hidden") ++ ++ secondErr := callTestPanicAsync(t, rpcConn, "panic probe beta two hidden") ++ assertDebugPanicError(t, secondErr, "panic probe beta two hidden") ++} ++ ++func debugRpcConn(t *testing.T) jsonrpc2.Conn { ++ t.Helper() ++ ++ debugServer := httptest.NewServer(newDebugService()) ++ t.Cleanup(debugServer.Close) ++ ++ serverUrl, err := url.Parse(debugServer.URL) ++ require.NoError(t, err) ++ serverUrl.Scheme = "ws" ++ ++ wsConn, _, err := websocket.DefaultDialer.Dial(serverUrl.String(), nil) ++ require.NoError(t, err) ++ t.Cleanup(func() { ++ require.NoError(t, wsConn.Close()) ++ }) ++ ++ rpcConn := jsonrpc2.NewConn(newWebSocketStream(wsConn)) ++ rpcConn.Go(context.Background(), nil) ++ ++ return rpcConn ++} ++ ++func callTestPanicAsync(t *testing.T, rpcConn jsonrpc2.Conn, message string) error { ++ t.Helper() ++ ++ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ++ defer cancel() ++ ++ _, err := rpcConn.Call(ctx, "TestPanicAsync", []any{message}, nil) ++ require.Error(t, err) ++ ++ return err ++} ++ ++func assertDebugPanicError(t *testing.T, err error, panicMessage string) { ++ t.Helper() ++ ++ var rpcErr *jsonrpc2.Error ++ require.True(t, errors.As(err, &rpcErr), "expected JSON-RPC error, got %T: %v", err, err) ++ require.Equal(t, jsonrpc2.InternalError, rpcErr.Code) ++ require.True(t, strings.HasPrefix(rpcErr.Message, "panic:"), "message should start with panic:, got %q", rpcErr.Message) ++ require.Contains(t, rpcErr.Message, panicMessage) ++} +diff --git 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 github.com/azure/azure-dev/cli/azd/internal/vsrpc -v -count=1 -run '^(TestHandler|TestCancellation|TestObserverable)$' ++ ;; ++ new) ++ go test github.com/azure/azure-dev/cli/azd/internal/vsrpc -v -count=1 -run '^(TestPanicRecoveredAcrossHandlerAdapters|TestDebugServicePanicErrorDetails|TestDebugServicePanicDoesNotCloseConnection)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000034/tests/test.sh b/tasks/format-code-task-000034/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..175d8371f30352cb661ea6810ccaf035d0aa7914 --- /dev/null +++ b/tasks/format-code-task-000034/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' +cli/azd/internal/vsrpc/handler_test.go +cli/azd/internal/vsrpc/server_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-000034/tests/test_command.sh b/tasks/format-code-task-000034/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000034/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-000035/environment/Dockerfile b/tasks/format-code-task-000035/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..09e61963cf5fa20e89feca7f454f0c7e98df8925 --- /dev/null +++ b/tasks/format-code-task-000035/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f0d2850673fd9e046920cdde1d05976e8e941d2d4aa08931551ba0a76b7b8a40 diff --git a/tasks/format-code-task-000035/environment/setup/files/blocklist b/tasks/format-code-task-000035/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000035/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000035/environment/setup/setup.sh b/tasks/format-code-task-000035/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000035/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000035/tests/test.patch b/tasks/format-code-task-000035/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9c4bb0df5c50d9263f77cd3208b4387ce2bf047e --- /dev/null +++ b/tasks/format-code-task-000035/tests/test.patch @@ -0,0 +1,200 @@ +diff --git a/packages/components/psammead-brand/src/print.test.jsx b/packages/components/psammead-brand/src/print.test.jsx +new file mode 100644 +index 000000000..76d1d3445 +--- /dev/null ++++ b/packages/components/psammead-brand/src/print.test.jsx +@@ -0,0 +1,172 @@ ++import React from 'react'; ++import renderer from 'react-test-renderer'; ++import 'jest-styled-components'; ++// eslint-disable-next-line import/no-extraneous-dependencies ++import { getCSS } from 'jest-styled-components/src/utils'; ++import Brand from './index'; ++ ++const findByType = (node, type) => { ++ if (!node || typeof node !== 'object') return null; ++ if (Array.isArray(node)) { ++ for (let i = 0; i < node.length; i += 1) { ++ const f = findByType(node[i], type); ++ if (f) return f; ++ } ++ return null; ++ } ++ if (node.type === type) return node; ++ if (!node.children) return null; ++ for (let i = 0; i < node.children.length; i += 1) { ++ const f = findByType(node.children[i], type); ++ if (f) return f; ++ } ++ return null; ++}; ++ ++ ++const getGClassTokens = tree => { ++ const g = findByType(tree, 'g'); ++ if (!g || !g.props || !g.props.className) return []; ++ return String(g.props.className).trim().split(/\s+/); ++}; ++ ++ ++const getWrapperClassTokens = tree => { ++ if (!tree || !tree.props || !tree.props.className) return []; ++ return String(tree.props.className).trim().split(/\s+/); ++}; ++ ++ ++const collectPrintMediaRules = ast => { ++ if (!ast || !ast.stylesheet) return []; ++ return ast.stylesheet.rules.filter( ++ r => r.type === 'media' && /print/.test(r.media || ''), ++ ); ++}; ++ ++ ++ ++const selectorTargetsG = (selector, gClassTokens) => { ++ if (typeof selector !== 'string') return false; ++ if (gClassTokens.some(c => selector.includes(`.${c}`))) return true; ++ ++ if (/(^|[\s>+~])g\s*$/.test(selector.trim())) return true; ++ return false; ++}; ++ ++ ++ ++const selectorTargetsWrapper = (selector, wrapperClassTokens) => ++ typeof selector === 'string' && ++ wrapperClassTokens.some(c => selector.includes(`.${c}`)); ++ ++ ++ ++ ++ ++ ++ ++const hasValidPrintVisibilityFix = (ast, gClassTokens, wrapperClassTokens) => { ++ const printRules = collectPrintMediaRules(ast); ++ for (let i = 0; i < printRules.length; i += 1) { ++ const media = printRules[i]; ++ if (!media.rules) continue; // eslint-disable-line no-continue ++ for (let j = 0; j < media.rules.length; j += 1) { ++ const rule = media.rules[j]; ++ if (rule.type !== 'rule' || !rule.declarations) continue; // eslint-disable-line no-continue ++ ++ const hasFill = rule.declarations.some(d => d.property === 'fill'); ++ const hasBg = rule.declarations.some( ++ d => d.property === 'background-color', ++ ); ++ const hasPrintColorAdjust = rule.declarations.some( ++ d => ++ (d.property === 'print-color-adjust' || ++ d.property === '-webkit-print-color-adjust') && ++ d.value === 'exact', ++ ); ++ ++ const selectors = rule.selectors || []; ++ ++ ++ if ( ++ hasFill && ++ selectors.some(s => selectorTargetsG(s, gClassTokens)) ++ ) { ++ return true; ++ } ++ ++ ++ if ( ++ hasBg && ++ hasPrintColorAdjust && ++ selectors.some(s => selectorTargetsWrapper(s, wrapperClassTokens)) ++ ) { ++ return true; ++ } ++ } ++ } ++ return false; ++}; ++ ++describe('Brand print visibility fix', () => { ++ it('ensures the SVG logo remains visible when printing', () => { ++ const tree = renderer.create().toJSON(); ++ const gClassTokens = getGClassTokens(tree); ++ const wrapperClassTokens = getWrapperClassTokens(tree); ++ const ast = getCSS(); ++ ++ expect( ++ hasValidPrintVisibilityFix(ast, gClassTokens, wrapperClassTokens), ++ ).toBe(true); ++ }); ++ ++ it('does not leave the fill="#fff" attribute unmitigated', () => { ++ ++ ++ ++ ++ ++ const tree = renderer.create().toJSON(); ++ const g = findByType(tree, 'g'); ++ expect(g).not.toBeNull(); ++ ++ const fillAttr = g.props.fill; ++ const gClassTokens = getGClassTokens(tree); ++ const wrapperClassTokens = getWrapperClassTokens(tree); ++ const ast = getCSS(); ++ const cssLevelFix = hasValidPrintVisibilityFix( ++ ast, ++ gClassTokens, ++ wrapperClassTokens, ++ ); ++ ++ const attrLevelFix = fillAttr !== '#fff' && fillAttr !== '#FFFFFF'; ++ expect(cssLevelFix || attrLevelFix).toBe(true); ++ }); ++ ++ it('preserves the BBC News link href (regression check)', () => { ++ const tree = renderer ++ .create() ++ .toJSON(); ++ const a = findByType(tree, 'a'); ++ expect(a).not.toBeNull(); ++ expect(a.props.href).toBe('https://www.bbc.co.uk/news'); ++ }); ++ ++ it('preserves the rendered brand name (regression check)', () => { ++ const tree = renderer ++ .create() ++ .toJSON(); ++ expect(JSON.stringify(tree)).toContain('My Branded Service'); ++ }); ++ ++ it('preserves the SVG element with the expected viewBox (regression check)', () => { ++ const tree = renderer ++ .create() ++ .toJSON(); ++ const svg = findByType(tree, 'svg'); ++ expect(svg).not.toBeNull(); ++ expect(svg.props.viewBox).toBe('0 0 167.95 24'); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..4393faeba +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest packages/components/psammead-brand/src/print.test.jsx --verbose"] ++} +diff --git 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-brand/src/print.test.jsx --verbose ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000035/tests/test.sh b/tasks/format-code-task-000035/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..647cb014f57afdd25bfd461b0a56d6ae6051dd03 --- /dev/null +++ b/tasks/format-code-task-000035/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-brand/src/print.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-000035/tests/test_command.sh b/tasks/format-code-task-000035/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000035/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000046/environment/Dockerfile b/tasks/format-code-task-000046/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6580df6e240d6c60ce52b0d86a1e7598efc0e60f --- /dev/null +++ b/tasks/format-code-task-000046/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ceeb9bea228a86c93e3a983e9b9e1ec7ff8d761feccc194c57d110cc75b4e519 diff --git a/tasks/format-code-task-000046/environment/setup/files/blocklist b/tasks/format-code-task-000046/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000046/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000046/environment/setup/setup.sh b/tasks/format-code-task-000046/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000046/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000046/tests/test.patch b/tasks/format-code-task-000046/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cc3ad06b9223be790d717eef1e094e84c47ab24d --- /dev/null +++ b/tasks/format-code-task-000046/tests/test.patch @@ -0,0 +1,180 @@ +diff --git a/test/parse/grammar/interperter_spec.ts b/test/parse/grammar/interperter_spec.ts +index 2d0629124..a7b0c0b7d 100644 +--- a/test/parse/grammar/interperter_spec.ts ++++ b/test/parse/grammar/interperter_spec.ts +@@ -1,38 +1,39 @@ + import {ITokenGrammarPath} from "../../../src/parse/grammar/path_public" + import { +- ActionTok, + actionDec, ++ actionDecSep, ++ ActionTok, ++ atLeastOneRule, ++ atLeastOneSepRule, ++ callArguments, ++ ColonTok, ++ CommaTok, ++ DotTok, + IdentTok, + LParenTok, +- RParenTok, +- ColonTok, +- SemicolonTok, + LSquareTok, +- RSquareTok, +- DotTok, +- CommaTok, + paramSpec, +- callArguments, +- actionDecSep, +- atLeastOneRule, + qualifiedNameSep, +- atLeastOneSepRule ++ RParenTok, ++ RSquareTok, ++ SemicolonTok + } from "./samples" + import { + NextAfterTokenWalker, ++ nextPossibleTokensAfter, ++ NextTerminalAfterAtLeastOneSepWalker, + NextTerminalAfterAtLeastOneWalker, +- NextTerminalAfterManyWalker, + NextTerminalAfterManySepWalker, +- NextTerminalAfterAtLeastOneSepWalker, +- possiblePathsFrom, +- nextPossibleTokensAfter ++ NextTerminalAfterManyWalker, ++ possiblePathsFrom + } from "../../../src/parse/grammar/interpreter" +-import {setEquality, createRegularToken} from "../../utils/matchers" ++import {createRegularToken, setEquality} from "../../utils/matchers" + import {gast} from "../../../src/parse/grammar/gast_public" +-import {Token, IToken} from "../../../src/scan/tokens_public" ++import {createToken, IToken, Token} from "../../../src/scan/tokens_public" + import {map} from "../../../src/utils/utils" +-import {TokenConstructor} from "../../../src/scan/lexer_public" ++import {Lexer, TokenConstructor} from "../../../src/scan/lexer_public" + import {augmentTokenClasses, tokenStructuredMatcher} from "../../../src/scan/tokens" ++import {Parser} from "../../../src/parse/parser_public" + + let RepetitionMandatory = gast.RepetitionMandatory + let Terminal = gast.Terminal +@@ -571,11 +572,11 @@ describe("The chevrotain grammar interpreter capabilities", () => { + ], Comma), + new gast.Terminal(Gamma) + ] +- + expect(extractPartialPaths(possiblePathsFrom(rep, 1))).to.deep.equal([[Alpha], [Gamma]]) + expect(extractPartialPaths(possiblePathsFrom(rep, 2))).to.deep.equal([[Alpha, Alpha], [Gamma]]) +- expect(extractPartialPaths(possiblePathsFrom(rep, 3))).to.deep.equal([[Alpha, Alpha, Gamma], [Gamma]]) +- expect(extractPartialPaths(possiblePathsFrom(rep, 4))).to.deep.equal([[Alpha, Alpha, Gamma], [Gamma]]) ++ expect(extractPartialPaths(possiblePathsFrom(rep, 3))).to.deep.equal([[Alpha, Alpha, Comma], [Alpha, Alpha, Gamma], [Gamma]]) ++ expect(extractPartialPaths(possiblePathsFrom(rep, 4))).to.deep.equal( ++ [[Alpha, Alpha, Comma, Alpha], [Alpha, Alpha, Gamma], [Gamma]]) + }) + + it("Mandatory Repetition with Separator", () => { +@@ -590,8 +591,9 @@ describe("The chevrotain grammar interpreter capabilities", () => { + + expect(extractPartialPaths(possiblePathsFrom(repMandSep, 1))).to.deep.equal([[Alpha]]) + expect(extractPartialPaths(possiblePathsFrom(repMandSep, 2))).to.deep.equal([[Alpha, Alpha]]) +- expect(extractPartialPaths(possiblePathsFrom(repMandSep, 3))).to.deep.equal([[Alpha, Alpha, Gamma]]) +- expect(extractPartialPaths(possiblePathsFrom(repMandSep, 4))).to.deep.equal([[Alpha, Alpha, Gamma]]) ++ expect(extractPartialPaths(possiblePathsFrom(repMandSep, 3))).to.deep.equal([[Alpha, Alpha, Comma], [Alpha, Alpha, Gamma]]) ++ expect(extractPartialPaths(possiblePathsFrom(repMandSep, 4))).to.deep.equal( ++ [[Alpha, Alpha, Comma, Alpha], [Alpha, Alpha, Gamma]]) + }) + + it("NonTerminal", () => { +@@ -882,5 +884,68 @@ describe("The chevrotain grammar interpreter capabilities", () => { + expect(nextPossibleTokensAfter(seq, INPUT([Alpha, Beta, Gamma]), tokenStructuredMatcher, 5)).to.be.empty + }) + }) ++}) ++ ++describe("issue 391 - WITH_SEP variants do not take SEP into account in lookahead", () => { ++ it("Reproduce issue", () => { ++ ++ const LParen = createToken({name: "LParen", pattern: /\(/}) ++ const RParen = createToken({name: "RParen", pattern: /\)/}) ++ const Comma = createToken({name: "Comma", pattern: /,/}) ++ const FatArrow = createToken({name: "FatArrow", pattern: /=>/}) ++ const Identifier = createToken({name: "Identifier", pattern: /[a-zA-Z]+/}) ++ const WhiteSpace = createToken({name: "WhiteSpace", pattern: /\s+/, group: Lexer.SKIPPED}) ++ ++ const allTokens = [WhiteSpace, LParen, RParen, Comma, FatArrow, Identifier] ++ const issue391Lexer = new Lexer(allTokens) + ++ class Issue391Parser extends Parser { ++ constructor(input:Token[] = []) { ++ super(input, allTokens, {maxLookahead: 4}); ++ (Parser as any).performSelfAnalysis(this) ++ } ++ ++ topRule = this.RULE("topRule", () => { ++ return this.OR1([ ++ { ++ ++ ALT: () => { ++ this.CONSUME1(LParen) ++ this.MANY_SEP({ ++ SEP: Comma, ++ DEF: () => { ++ this.CONSUME1(Identifier) ++ } ++ }) ++ this.CONSUME1(RParen) ++ this.CONSUME1(FatArrow) ++ } ++ }, ++ { ++ ++ ALT: () => { ++ this.CONSUME2(LParen) ++ this.CONSUME2(Identifier) ++ this.CONSUME2(RParen) ++ } ++ }, ++ ]) ++ }) ++ } ++ ++ expect(() => new Issue391Parser([])).to.not.throw("Ambiguous alternatives: <1 ,2>") ++ const myParser = new Issue391Parser([]) ++ ++ function testInput(input) { ++ const tokens = issue391Lexer.tokenize(input).tokens ++ myParser.input = tokens ++ myParser.topRule() ++ expect(myParser.errors).to.be.empty ++ } ++ ++ testInput("(x, y) => ") ++ testInput("() =>") ++ testInput("(x) =>") ++ testInput("(x)") ++ }) + }) +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+DMBgGYM78ii/xbKEM2A/Y3YPzTqB0o4ZR0pbp/r0fmOhiortsMcb3OVBI ++268tb0Uzmb6t9HBMoltJ2boolpZ9bZd3WWQyW0m5zmWUSlmsy4iKm+3ozORD7YgiZ234adyl/j9K ++fOYftA+VsodDPbTCd9db41L+q1J+5F+WOeefl5LzT6+3he/98/xVS0vwjW7j+I62LyaojoKlB9tq ++8ewpS2lnHfG9GOtgGtObcCIe1dHTadRb5cwYKBMrkcetPt779wIDz+apc8kNzzS9Ph/u7eSU9sQX ++jebFfTyMrxS8msc/TgOFThPHstdh6acdF4jnmtXBtlOvfSIaMyT8pbqaRNKbZjlFMtbO62Tvar7F ++LjFD0G7Ujp+VH7Xi88S//cMBAAAAAAAAAAAAAAAAAAAAAK7oDZKdjQMAKAAA +diff --git 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-000046/tests/test.sh b/tasks/format-code-task-000046/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..56f4b071d794520ad5f8cdd12e5f37e92feda7e1 --- /dev/null +++ b/tasks/format-code-task-000046/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/parse/grammar/interperter_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-000046/tests/test_command.sh b/tasks/format-code-task-000046/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000046/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000051/environment/Dockerfile b/tasks/format-code-task-000051/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..17326373e316cb7570c57ea00698bdfb41576cf0 --- /dev/null +++ b/tasks/format-code-task-000051/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f190d89c473987498ee878e62c22a35f63f1a081bc5045e031430d2cdb13d0dc diff --git a/tasks/format-code-task-000051/environment/setup/files/blocklist b/tasks/format-code-task-000051/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000051/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000051/environment/setup/setup.sh b/tasks/format-code-task-000051/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000051/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000051/tests/test.patch b/tasks/format-code-task-000051/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..421e6b256f1904b93803124910c91522add181e0 --- /dev/null +++ b/tasks/format-code-task-000051/tests/test.patch @@ -0,0 +1,499 @@ +diff --git a/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/correct_owner.pass.sh b/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/correct_owner.pass.sh +new file mode 100644 +index 0000000000..5dbd79c4e6 +--- /dev/null ++++ b/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/correct_owner.pass.sh +@@ -0,0 +1,14 @@ ++#!/bin/bash ++ ++ ++if [ ! -f /var/log/syslog ]; then ++ mkdir -p /var/log/ ++ touch /var/log/syslog ++fi ++ ++if ! grep -q "^syslog:" /etc/passwd; then ++ useradd syslog ++fi ++ ++chown syslog /var/log/syslog ++ +diff --git a/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/incorrect_owner.fail.sh b/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/incorrect_owner.fail.sh +new file mode 100644 +index 0000000000..c1855cbd56 +--- /dev/null ++++ b/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/incorrect_owner.fail.sh +@@ -0,0 +1,14 @@ ++#!/bin/bash ++ ++ ++if [ ! -f /var/log/syslog ]; then ++ mkdir -p /var/log/ ++ touch /var/log/syslog ++fi ++ ++if ! grep -q "^syslog:" /etc/passwd; then ++ useradd syslog ++fi ++ ++useradd testuser_123 ++chown testuser_123 /var/log/syslog +diff --git a/shared/templates/file_owner/tests/correct_owner.pass.sh b/shared/templates/file_owner/tests/correct_owner.pass.sh +index f05418c94f..92b31b7d87 100644 +--- a/shared/templates/file_owner/tests/correct_owner.pass.sh ++++ b/shared/templates/file_owner/tests/correct_owner.pass.sh +@@ -8,15 +8,15 @@ fi + {{% if FILE_REGEX %}} + echo "Create specific tests for this rule because of regex" + {{% elif RECURSIVE %}} +-find -L {{{ path }}} -type d -exec chown {{{ FILEUID }}} {} \; ++find -L {{{ path }}} -type d -exec chown {{{ UID_OR_NAME }}} {} \; + {{% else %}} +-chown {{{ FILEUID }}} {{{ path }}} ++chown {{{ UID_OR_NAME }}} {{{ path }}} + {{% endif %}} + {{% else %}} + if [ ! -f {{{ path }}} ]; then + mkdir -p "$(dirname '{{{ path }}}')" + touch {{{ path }}} + fi +-chown {{{ FILEUID }}} {{{ path }}} ++chown {{{ UID_OR_NAME }}} {{{ path }}} + {{% endif %}} + {{% endfor %}} +diff --git a/shared/templates/file_owner/tests/incorrect_owner.fail.sh b/shared/templates/file_owner/tests/incorrect_owner.fail.sh +index 8d4ccfe0d5..82c16cb89a 100644 +--- a/shared/templates/file_owner/tests/incorrect_owner.fail.sh ++++ b/shared/templates/file_owner/tests/incorrect_owner.fail.sh +@@ -13,6 +13,7 @@ useradd testuser_123 + if [ ! -d {{{ path }}} ]; then + mkdir -p {{{ path }}} + fi ++touch "{{{ path }}}"/cac_file_owner_test_file + {{% if FILE_REGEX %}} + find -L {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chown testuser_123 {} \; + {{% elif RECURSIVE %}} +diff --git a/tests/test_file_owner_uid_or_name_behavior.py b/tests/test_file_owner_uid_or_name_behavior.py +new file mode 100644 +index 0000000000..6fa46dc554 +--- /dev/null ++++ b/tests/test_file_owner_uid_or_name_behavior.py +@@ -0,0 +1,386 @@ ++#!/usr/bin/env python3 ++import importlib.util ++import os ++import random ++import re ++import shutil ++import subprocess ++import sys ++import tempfile ++import xml.etree.ElementTree as ET ++from pathlib import Path ++ ++ ++REPO_ROOT = Path(__file__).resolve().parents[1] ++OPENSHIFT_ROOT = REPO_ROOT / "applications" / "openshift" ++TEMPLATE_ROOT = REPO_ROOT / "shared" / "templates" / "file_owner" ++RULE_ID = "file_owner_fixture_uid_or_name" ++ ++sys.path.insert(0, str(REPO_ROOT)) ++ ++import ssg.jinja # noqa: E402 ++ ++ ++def _assert(condition, message): ++ if not condition: ++ raise AssertionError(message) ++ ++ ++def _run(cmd, **kwargs): ++ result = subprocess.run( ++ cmd, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ **kwargs, ++ ) ++ if result.returncode != 0: ++ raise AssertionError( ++ "command failed: {0}\nstdout:\n{1}\nstderr:\n{2}".format( ++ " ".join(cmd), result.stdout, result.stderr ++ ) ++ ) ++ return result ++ ++ ++def _load_template_preprocessor(): ++ ++ ++ ++ path = TEMPLATE_ROOT / "template.py" ++ spec = importlib.util.spec_from_file_location("fixture_file_owner_template", path) ++ module = importlib.util.module_from_spec(spec) ++ spec.loader.exec_module(module) ++ return module ++ ++ ++def _render_file_owner_template(lang, template_vars): ++ params = dict(template_vars) ++ params.setdefault("_rule_id", RULE_ID) ++ params.setdefault("recursive", "false") ++ ++ preprocessor = _load_template_preprocessor() ++ processed = preprocessor.preprocess(params, lang) ++ substitutions = {key.upper(): value for key, value in processed.items()} ++ merged = ssg.jinja.load_macros() ++ merged.update(substitutions) ++ ++ return ssg.jinja.process_file(str(TEMPLATE_ROOT / f"{lang}.template"), merged) ++ ++ ++def _parse_oval_fragment(rendered_oval): ++ wrapped = ( ++ '' ++ + rendered_oval ++ + "" ++ ) ++ return ET.fromstring(wrapped) ++ ++ ++def _namespace(tag): ++ return { ++ "unix": f"{{urn:unix}}{tag}", ++ "ind": f"{{urn:ind}}{tag}", ++ } ++ ++ ++def _local_name(tag): ++ return tag.rsplit("}", 1)[-1] ++ ++ ++def _unique_user(): ++ return "cacfo{0}{1}".format(os.getpid(), random.randrange(1000, 9999)) ++ ++ ++def _ensure_user(name): ++ try: ++ import pwd ++ ++ return pwd.getpwnam(name).pw_uid ++ except KeyError: ++ _run(["useradd", name]) ++ return pwd.getpwnam(name).pw_uid ++ ++ ++def _delete_user(name): ++ subprocess.run(["userdel", "-r", name], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) ++ ++ ++def _run_shell_script(script): ++ result = subprocess.run( ++ ["bash", "-e"], ++ input=script, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ ) ++ if result.returncode != 0: ++ raise AssertionError( ++ "rendered shell remediation failed\nstdout:\n{0}\nstderr:\n{1}\nscript:\n{2}".format( ++ result.stdout, result.stderr, script ++ ) ++ ) ++ ++ ++def test_bash_remediation_accepts_numeric_uid_and_username(): ++ _assert(os.geteuid() == 0, "ownership behavior checks must run as root") ++ _assert(shutil.which("useradd"), "useradd is required for username ownership checks") ++ _assert(shutil.which("userdel"), "userdel is required for username ownership cleanup") ++ ++ owner_name = _unique_user() ++ try: ++ owner_uid = _ensure_user(owner_name) ++ _assert(owner_uid != 0, "dynamic test account should not be root") ++ ++ with tempfile.TemporaryDirectory(prefix="cac-file-owner-") as tmpdir: ++ target = Path(tmpdir) / "owned_file" ++ target.write_text("fixture file_owner behavior\n", encoding="utf-8") ++ ++ os.chown(target, 0, -1) ++ numeric_script = _render_file_owner_template( ++ "bash", {"filepath": str(target), "uid_or_name": str(owner_uid)} ++ ) ++ _run_shell_script(numeric_script) ++ _assert( ++ target.stat().st_uid == owner_uid, ++ "numeric uid_or_name should be accepted by the generated remediation", ++ ) ++ ++ os.chown(target, 0, -1) ++ username_script = _render_file_owner_template( ++ "bash", {"filepath": str(target), "uid_or_name": owner_name} ++ ) ++ _run_shell_script(username_script) ++ _assert( ++ target.stat().st_uid == owner_uid, ++ "username uid_or_name should be resolved by the system when remediation runs", ++ ) ++ finally: ++ _delete_user(owner_name) ++ ++ ++def test_oval_check_numeric_uid_uses_integer_user_id(): ++ for uid in ("0", "4242"): ++ rendered = _render_file_owner_template( ++ "oval", {"filepath": "/tmp/cac-file-owner-fixture", "uid_or_name": uid} ++ ) ++ root = _parse_oval_fragment(rendered) ++ user_ids = list(root.iter(_namespace("user_id")["unix"])) ++ _assert(user_ids, "rendered numeric OVAL must contain a file owner user_id state") ++ _assert( ++ any(el.attrib.get("datatype") == "int" and (el.text or "").strip() == uid for el in user_ids), ++ "numeric uid_or_name should render as an integer user_id matching the configured UID", ++ ) ++ _assert( ++ all("var_ref" not in el.attrib for el in user_ids), ++ "numeric uid_or_name should not require a runtime username lookup variable", ++ ) ++ passwd_lookups = [ ++ (el.text or "").strip() ++ for el in root.iter(_namespace("filepath")["ind"]) ++ if (el.text or "").strip() == "/etc/passwd" ++ ] ++ _assert( ++ not passwd_lookups, ++ "numeric uid_or_name should keep the previous direct numeric UID behavior", ++ ) ++ ++ ++def test_oval_check_username_resolves_owner_on_scanned_system(): ++ username = "cac_fixture_owner_{0}".format(random.randrange(10000, 99999)) ++ rendered = _render_file_owner_template( ++ "oval", {"filepath": "/tmp/cac-file-owner-fixture", "uid_or_name": username} ++ ) ++ root = _parse_oval_fragment(rendered) ++ ++ user_ids = list(root.iter(_namespace("user_id")["unix"])) ++ _assert(user_ids, "rendered username OVAL must contain a file owner user_id state") ++ _assert( ++ any("var_ref" in el.attrib for el in user_ids), ++ "username uid_or_name should compare file owner against a runtime-resolved UID", ++ ) ++ _assert( ++ all((el.text or "").strip() != username for el in user_ids), ++ "username uid_or_name must not be emitted as a literal integer user_id", ++ ) ++ ++ var_refs = { ++ el.attrib["var_ref"] ++ for el in user_ids ++ if el.attrib.get("datatype") == "int" and "var_ref" in el.attrib ++ } ++ _assert( ++ var_refs, ++ "username uid_or_name should use a runtime variable for the expected UID", ++ ) ++ ++ variables = {el.attrib.get("id"): el for el in root.iter() if _local_name(el.tag).endswith("variable")} ++ connected_variables = [variables[var_ref] for var_ref in var_refs if var_ref in variables] ++ _assert( ++ connected_variables, ++ "username UID comparison should be backed by an OVAL variable definition", ++ ) ++ ++ component_refs = set() ++ for variable in connected_variables: ++ for element in variable.iter(): ++ ref = element.attrib.get("object_ref") ++ if ref: ++ component_refs.add(ref) ++ ++ lookup_objects = {el.attrib.get("id"): el for el in root.iter(_namespace("textfilecontent54_object")["ind"])} ++ connected_lookup_objects = [lookup_objects[ref] for ref in component_refs if ref in lookup_objects] ++ _assert( ++ connected_lookup_objects, ++ "runtime UID variable should be derived from scanned system account data", ++ ) ++ ++ lookup_text = "\n".join( ++ (element.text or "").strip() ++ for lookup_object in connected_lookup_objects ++ for element in lookup_object.iter() ++ ) ++ _assert( ++ username in lookup_text, ++ "runtime UID lookup should be tied to the configured account name", ++ ) ++ ++ ++def _line_indent(line): ++ return len(line) - len(line.lstrip(" ")) ++ ++ ++def _strip_quotes(value): ++ value = value.strip() ++ if len(value) >= 2 and value[0] in ("'", '"') and value[-1] == value[0]: ++ return value[1:-1] ++ return value ++ ++ ++def _active_file_owner_template_vars(rule_path): ++ lines = rule_path.read_text(encoding="utf-8").splitlines() ++ for index, line in enumerate(lines): ++ stripped = line.strip() ++ if not stripped or stripped.startswith("#"): ++ continue ++ if stripped != "template:": ++ continue ++ ++ template_indent = _line_indent(line) ++ block = [] ++ for candidate in lines[index + 1 :]: ++ candidate_stripped = candidate.strip() ++ if ( ++ candidate_stripped ++ and not candidate_stripped.startswith("#") ++ and _line_indent(candidate) <= template_indent ++ ): ++ break ++ block.append(candidate) ++ ++ is_file_owner = False ++ vars_index = None ++ vars_indent = None ++ for block_index, block_line in enumerate(block): ++ block_stripped = block_line.strip() ++ if not block_stripped or block_stripped.startswith("#") or block_stripped.startswith("{{"): ++ continue ++ if block_stripped.startswith("name:"): ++ is_file_owner = _strip_quotes(block_stripped.split(":", 1)[1]) == "file_owner" ++ if block_stripped == "vars:": ++ vars_index = block_index ++ vars_indent = _line_indent(block_line) ++ ++ if not is_file_owner or vars_index is None: ++ continue ++ ++ vars_ = {} ++ for var_line in block[vars_index + 1 :]: ++ var_stripped = var_line.strip() ++ if not var_stripped or var_stripped.startswith("#") or var_stripped.startswith("{{"): ++ continue ++ if _line_indent(var_line) <= vars_indent: ++ break ++ match = re.match(r"([A-Za-z0-9_@-]+)\s*:\s*(.*)$", var_stripped) ++ if match: ++ vars_[match.group(1)] = _strip_quotes(match.group(2)) ++ return vars_ ++ return None ++ ++ ++def _base_file_owner_template_vars(relative_path): ++ try: ++ result = _run(["git", "show", "HEAD:{0}".format(relative_path)]) ++ except AssertionError: ++ return None ++ ++ with tempfile.NamedTemporaryFile("w", encoding="utf-8", delete=False) as tmp: ++ tmp.write(result.stdout) ++ tmp_path = Path(tmp.name) ++ try: ++ return _active_file_owner_template_vars(tmp_path) ++ finally: ++ tmp_path.unlink(missing_ok=True) ++ ++ ++def test_openshift_file_owner_rules_use_uid_or_name_and_preserve_values(): ++ discovered = {} ++ migrated_from_base = {} ++ offenders = [] ++ for rule_path in OPENSHIFT_ROOT.rglob("rule.yml"): ++ vars_ = _active_file_owner_template_vars(rule_path) ++ if vars_ is None: ++ continue ++ relative = rule_path.relative_to(REPO_ROOT).as_posix() ++ discovered[relative] = vars_ ++ base_vars = _base_file_owner_template_vars(relative) ++ if base_vars and "fileuid" in base_vars: ++ migrated_from_base[relative] = base_vars["fileuid"] ++ if "fileuid" in vars_ or "uid_or_name" not in vars_: ++ offenders.append( ++ "{0}: fileuid={1!r}, uid_or_name={2!r}".format( ++ relative, vars_.get("fileuid"), vars_.get("uid_or_name") ++ ) ++ ) ++ ++ _assert(discovered, "expected active OpenShift file_owner rules to exist") ++ _assert( ++ not offenders, ++ "active OpenShift file_owner rules must use uid_or_name instead of fileuid:\n" ++ + "\n".join(offenders), ++ ) ++ ++ _assert( ++ migrated_from_base, ++ "expected base OpenShift file_owner rules using fileuid to be migration targets", ++ ) ++ ++ wrong = [] ++ for relative, expected in sorted(migrated_from_base.items()): ++ if relative not in discovered: ++ wrong.append("{0}: active file_owner rule disappeared".format(relative)) ++ continue ++ actual = str(discovered[relative].get("uid_or_name")) ++ if actual != expected: ++ wrong.append("{0}: expected {1!r}, got {2!r}".format(relative, expected, actual)) ++ _assert( ++ not wrong, ++ "OpenShift file_owner uid_or_name values must preserve the previous owner:\n" ++ + "\n".join(wrong), ++ ) ++ ++ ++def main(): ++ tests = [ ++ test_bash_remediation_accepts_numeric_uid_and_username, ++ test_oval_check_numeric_uid_uses_integer_user_id, ++ test_oval_check_username_resolves_owner_on_scanned_system, ++ test_openshift_file_owner_rules_use_uid_or_name_and_preserve_values, ++ ] ++ for test in tests: ++ test() ++ print("PASS {0}".format(test.__name__)) ++ ++ ++if __name__ == "__main__": ++ 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,27 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++REPO_ROOT="/testbed" ++ ++ ++ ++case "${1:-}" in ++ base) ++ python3 - <<'PY' ++import sys ++sys.path.insert(0, "/testbed") ++import ssg.jinja ++print("base smoke: ssg.jinja import ok") ++PY ++ ;; ++ new) ++ python3 /testbed/tests/test_file_owner_uid_or_name_behavior.py ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000051/tests/test.sh b/tasks/format-code-task-000051/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2875cc043f40f410ad07991702e5c0f48606ce7a --- /dev/null +++ b/tasks/format-code-task-000051/tests/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/correct_owner.pass.sh +linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/incorrect_owner.fail.sh +shared/templates/file_owner/tests/correct_owner.pass.sh +shared/templates/file_owner/tests/incorrect_owner.fail.sh +tests/test_file_owner_uid_or_name_behavior.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-000051/tests/test_command.sh b/tasks/format-code-task-000051/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000051/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-000056/environment/Dockerfile b/tasks/format-code-task-000056/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b55a65650efdc45d9b3f3e723efc327fac10590a --- /dev/null +++ b/tasks/format-code-task-000056/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d026ee734aefb4a241fb86d03b1543ebd95f6a7259109c02a4be47500d8b2f74 diff --git a/tasks/format-code-task-000056/environment/setup/files/blocklist b/tasks/format-code-task-000056/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000056/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000056/environment/setup/setup.sh b/tasks/format-code-task-000056/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000056/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000056/tests/test.patch b/tasks/format-code-task-000056/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..82e5a329de575d34e9e94455c19ebb751ae94765 --- /dev/null +++ b/tasks/format-code-task-000056/tests/test.patch @@ -0,0 +1,288 @@ +diff --git a/pkg/serverless/logs/logs_test.go b/pkg/serverless/logs/logs_test.go +index 938393f354..19a88406ae 100644 +--- a/pkg/serverless/logs/logs_test.go ++++ b/pkg/serverless/logs/logs_test.go +@@ -12,6 +12,7 @@ import ( + "net/http" + "net/http/httptest" + "os" ++ "strings" + "testing" + "time" + +@@ -392,7 +393,74 @@ func TestProcessMessageShouldNotProcessLogsDropped(t *testing.T) { + assert.Len(t, timed, 0) + } + +-func TestProcessMessageShouldProcessLogTypeFunction(t *testing.T) { ++func countMetricsByName(samples []metrics.MetricSample, name string) int { ++ count := 0 ++ for _, sample := range samples { ++ if sample.Name == name { ++ count++ ++ } ++ } ++ return count ++} ++ ++func platformReportJSON(requestID, status string, memoryUsed, memorySize float64) []byte { ++ return []byte(fmt.Sprintf(`{ ++ "time": %q, ++ "type": "platform.report", ++ "record": { ++ "requestId": %q, ++ "status": %q, ++ "metrics": { ++ "maxMemoryUsedMB": %.1f, ++ "memorySizeMB": %.1f ++ } ++ } ++ }`, time.Unix(0, 0).UTC().Format(logMessageTimeLayout), requestID, status, memoryUsed, memorySize)) ++} ++ ++func unmarshalPlatformReport(t *testing.T, raw []byte) *LambdaLogAPIMessage { ++ t.Helper() ++ message := &LambdaLogAPIMessage{} ++ require.NoError(t, json.Unmarshal(raw, message)) ++ return message ++} ++ ++func newOOMTestCollector(t *testing.T, demux aggregator.Demultiplexer, requestID string) *LambdaLogsCollector { ++ t.Helper() ++ ++ executionContext := &executioncontext.ExecutionContext{} ++ return newOOMTestCollectorWithExecutionContext(t, demux, requestID, executionContext) ++} ++ ++func newOOMTestCollectorWithExecutionContext(t *testing.T, demux aggregator.Demultiplexer, requestID string, executionContext *executioncontext.ExecutionContext) *LambdaLogsCollector { ++ t.Helper() ++ ++ arn := "arn:aws:lambda:us-east-1:123456789012:function:test-function" ++ metricTags := []string{"functionname:test-function"} ++ tags := Tags{Tags: metricTags} ++ executionContext.SetFromInvocation(arn, requestID) ++ ++ lc := NewLambdaLogCollector( ++ make(chan<- *config.ChannelMessage), ++ demux, ++ &tags, ++ true, ++ true, ++ executionContext, ++ func() {}, ++ make(chan<- float64), ++ ) ++ lc.lastRequestID = requestID ++ return lc ++} ++ ++func processAndWaitForSamples(lc *LambdaLogsCollector, message LambdaLogAPIMessage, expectedSamples int) ([]metrics.MetricSample, []metrics.MetricSample) { ++ lc.Start() ++ lc.In <- []LambdaLogAPIMessage{message} ++ return lc.demux.(*aggregator.TestAgentDemultiplexer).WaitForNumberOfSamples(expectedSamples, 0, 100*time.Millisecond) ++} ++ ++func TestProcessMessageShouldProcessLogTypeFunctionOutOfMemory(t *testing.T) { + demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour) + defer demux.Stop(false) + message := &LambdaLogAPIMessage{ +@@ -413,14 +481,170 @@ func TestProcessMessageShouldProcessLogTypeFunction(t *testing.T) { + mockExecutionContext.SetFromInvocation(arn, lastRequestID) + + lc := NewLambdaLogCollector(make(chan<- *config.ChannelMessage), demux, &tags, true, computeEnhancedMetrics, mockExecutionContext, func() {}, make(chan<- float64)) ++ lc.lastRequestID = lastRequestID + +- go lc.processMessage(message) ++ received, timed := processAndWaitForSamples(lc, *message, 2) + +- received, timed := demux.WaitForNumberOfSamples(2, 0, 100*time.Millisecond) + assert.Len(t, received, 2) + assert.Len(t, timed, 0) +- assert.Equal(t, serverlessMetrics.OutOfMemoryMetric, received[0].Name) +- assert.Equal(t, serverlessMetrics.ErrorsMetric, received[1].Name) ++ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric)) ++ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.ErrorsMetric)) ++} ++ ++func TestProcessPlatformReportOOMEmitsEnhancedMetricsFromJSON(t *testing.T) { ++ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour) ++ defer demux.Stop(false) ++ ++ requestID := "8286a188-ba32-4475-8077-530cd35c09a9" ++ message := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 512, 512)) ++ lc := newOOMTestCollector(t, demux, requestID) ++ ++ received, timed := processAndWaitForSamples(lc, *message, 8) ++ assert.Len(t, timed, 0) ++ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric)) ++ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.ErrorsMetric)) ++} ++ ++func TestProcessPlatformReportOOMAlsoEmitsWhenMemoryExceedsLimit(t *testing.T) { ++ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour) ++ defer demux.Stop(false) ++ ++ requestID := "5d607cb8-d752-43e7-8f99-f5b5f6a17452" ++ message := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 768, 512)) ++ lc := newOOMTestCollector(t, demux, requestID) ++ ++ received, timed := processAndWaitForSamples(lc, *message, 8) ++ assert.Len(t, timed, 0) ++ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric)) ++ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.ErrorsMetric)) ++} ++ ++func TestProcessPlatformReportOOMRequiresQualifyingReport(t *testing.T) { ++ testCases := []struct { ++ name string ++ status string ++ memoryUsed float64 ++ memorySize float64 ++ }{ ++ { ++ name: "non-error status at memory limit", ++ status: "success", ++ memoryUsed: 256, ++ memorySize: 256, ++ }, ++ { ++ name: "error status below memory limit", ++ status: "error", ++ memoryUsed: 255, ++ memorySize: 256, ++ }, ++ { ++ name: "error status with zero memory used", ++ status: "error", ++ memoryUsed: 0, ++ memorySize: 256, ++ }, ++ } ++ ++ for _, tc := range testCases { ++ t.Run(tc.name, func(t *testing.T) { ++ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour) ++ defer demux.Stop(false) ++ ++ requestID := "negative-" + strings.ReplaceAll(tc.name, " ", "-") ++ message := unmarshalPlatformReport(t, platformReportJSON(requestID, tc.status, tc.memoryUsed, tc.memorySize)) ++ lc := newOOMTestCollector(t, demux, requestID) ++ ++ received, timed := processAndWaitForSamples(lc, *message, 6) ++ assert.Len(t, timed, 0) ++ assert.Equal(t, 0, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric)) ++ }) ++ } ++} ++ ++func TestOutOfMemoryEnhancedMetricsAreDedupedPerRequest(t *testing.T) { ++ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour) ++ defer demux.Stop(false) ++ ++ requestID := "fa7d55f7-4054-412f-9567-8f607c8376db" ++ lc := newOOMTestCollector(t, demux, requestID) ++ functionOOM := &LambdaLogAPIMessage{ ++ logType: logTypeFunction, ++ time: time.Now(), ++ stringRecord: "JavaScript heap out of memory", ++ } ++ reportOOM := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 1024, 1024)) ++ ++ lc.Start() ++ lc.In <- []LambdaLogAPIMessage{*functionOOM, *reportOOM} ++ ++ received, timed := demux.WaitForNumberOfSamples(8, 0, 100*time.Millisecond) ++ assert.Len(t, timed, 0) ++ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric)) ++} ++ ++func TestPersistedOOMDeduplicationPreventsDuplicateAfterRestore(t *testing.T) { ++ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour) ++ defer demux.Stop(false) ++ ++ const stateFile = "/tmp/dd-lambda-extension-cache.json" ++ require.NoError(t, os.RemoveAll(stateFile)) ++ t.Cleanup(func() { ++ _ = os.Remove(stateFile) ++ }) ++ ++ requestID := "72946812-35dd-4382-b180-92f51cb7168c" ++ lc := newOOMTestCollector(t, demux, requestID) ++ firstReport := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 384, 256)) ++ ++ received, timed := processAndWaitForSamples(lc, *firstReport, 8) ++ require.Len(t, timed, 0) ++ require.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric)) ++ ++ require.NoError(t, lc.executionContext.SaveCurrentExecutionContext()) ++ ++ restoredCollector := newOOMTestCollector(t, demux, requestID) ++ require.NoError(t, restoredCollector.executionContext.RestoreCurrentStateFromFile()) ++ replayedReport := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 384, 256)) ++ ++ restoredCollector.Start() ++ restoredCollector.In <- []LambdaLogAPIMessage{*replayedReport} ++ ++ replayed, replayedTimed := demux.WaitForNumberOfSamples(14, 0, 100*time.Millisecond) ++ assert.Len(t, replayedTimed, 0) ++ assert.Equal(t, 1, countMetricsByName(replayed, serverlessMetrics.OutOfMemoryMetric)) ++} ++ ++func TestPersistedOOMDeduplicationPreventsDuplicateForArbitraryRequest(t *testing.T) { ++ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour) ++ defer demux.Stop(false) ++ ++ const stateFile = "/tmp/dd-lambda-extension-cache.json" ++ require.NoError(t, os.RemoveAll(stateFile)) ++ t.Cleanup(func() { ++ _ = os.Remove(stateFile) ++ }) ++ ++ requestID := "2b11979d-d2f0-4e1a-8840-5357f2c20b42" ++ lc := newOOMTestCollector(t, demux, requestID) ++ firstReport := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 640, 512)) ++ ++ received, timed := processAndWaitForSamples(lc, *firstReport, 8) ++ require.Len(t, timed, 0) ++ require.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric)) ++ ++ require.NoError(t, lc.executionContext.SaveCurrentExecutionContext()) ++ ++ restoredCollector := newOOMTestCollector(t, demux, requestID) ++ require.NoError(t, restoredCollector.executionContext.RestoreCurrentStateFromFile()) ++ replayedReport := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 640, 512)) ++ ++ restoredCollector.Start() ++ restoredCollector.In <- []LambdaLogAPIMessage{*replayedReport} ++ ++ replayed, replayedTimed := demux.WaitForNumberOfSamples(14, 0, 100*time.Millisecond) ++ assert.Len(t, replayedTimed, 0) ++ assert.Equal(t, 1, countMetricsByName(replayed, serverlessMetrics.OutOfMemoryMetric)) + } + + func TestProcessLogMessageLogsEnabled(t *testing.T) { +diff --git 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 ++ ++ ++cd /testbed ++ ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 ./pkg/serverless/executioncontext/... ./pkg/serverless/logs/... ++ ;; ++ new) ++ go test -v -count=1 ./pkg/serverless/logs/... -run '^(TestProcessMessageShouldProcessLogTypeFunctionOutOfMemory|TestProcessPlatformReportOOMEmitsEnhancedMetricsFromJSON|TestProcessPlatformReportOOMAlsoEmitsWhenMemoryExceedsLimit|TestProcessPlatformReportOOMRequiresQualifyingReport|TestOutOfMemoryEnhancedMetricsAreDedupedPerRequest|TestPersistedOOMDeduplicationPreventsDuplicateAfterRestore|TestPersistedOOMDeduplicationPreventsDuplicateForArbitraryRequest)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000056/tests/test.sh b/tasks/format-code-task-000056/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f1c79794a3135ba3d0485d8408e0e37136a2066 --- /dev/null +++ b/tasks/format-code-task-000056/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/serverless/logs/logs_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-000056/tests/test_command.sh b/tasks/format-code-task-000056/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000056/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-000058/environment/Dockerfile b/tasks/format-code-task-000058/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3add68053a2e24b5cd67f2cc6c5f2253f6e28507 --- /dev/null +++ b/tasks/format-code-task-000058/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:91b7266714fc6d0a66653e4b15a81820625e6019b8510e625560989946c22c47 diff --git a/tasks/format-code-task-000058/environment/setup/files/blocklist b/tasks/format-code-task-000058/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000058/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000058/environment/setup/setup.sh b/tasks/format-code-task-000058/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000058/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000058/tests/test.patch b/tasks/format-code-task-000058/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..35f8009fa2d59195471bb524bf2e27d3349ce25b --- /dev/null +++ b/tasks/format-code-task-000058/tests/test.patch @@ -0,0 +1,114 @@ +diff --git a/rtloader/test/datadog_agent/datadog_agent.go b/rtloader/test/datadog_agent/datadog_agent.go +index e0f202c0b34e5b..ef8474ab6dd84c 100644 +--- a/rtloader/test/datadog_agent/datadog_agent.go ++++ b/rtloader/test/datadog_agent/datadog_agent.go +@@ -4,6 +4,7 @@ import ( + "fmt" + "io/ioutil" + "os" ++ "time" + "runtime" + "strings" + "unsafe" +@@ -33,6 +34,7 @@ extern void writePersistentCache(char*, char*); + extern char* readPersistentCache(char*); + extern char* obfuscateSQL(char*, char*, char**); + extern char* obfuscateSQLExecPlan(char*, bool, char**); ++extern double getProcessStartTime(); + + + static void initDatadogAgentTests(rtloader_t *rtloader) { +@@ -50,6 +52,7 @@ static void initDatadogAgentTests(rtloader_t *rtloader) { + set_read_persistent_cache_cb(rtloader, readPersistentCache); + set_obfuscate_sql_cb(rtloader, obfuscateSQL); + set_obfuscate_sql_exec_plan_cb(rtloader, obfuscateSQLExecPlan); ++ set_get_process_start_time_cb(rtloader, getProcessStartTime); + } + */ + import "C" +@@ -282,3 +285,10 @@ func obfuscateSQLExecPlan(rawQuery *C.char, normalize C.bool, errResult **C.char + return nil + } + } ++ ++var processStartTime = float64(time.Now().Unix()) ++ ++//export getProcessStartTime ++func getProcessStartTime() float64 { ++ return processStartTime ++} +diff --git a/rtloader/test/datadog_agent/datadog_agent_test.go b/rtloader/test/datadog_agent/datadog_agent_test.go +index 6f17ebfe12174d..beb88133b4f1e5 100644 +--- a/rtloader/test/datadog_agent/datadog_agent_test.go ++++ b/rtloader/test/datadog_agent/datadog_agent_test.go +@@ -4,6 +4,7 @@ import ( + "fmt" + "os" + "regexp" ++ "strconv" + "testing" + + "github.com/DataDog/datadog-agent/rtloader/test/helpers" +@@ -578,3 +579,34 @@ func TestObfuscateSqlExecPlanErrors(t *testing.T) { + + helpers.AssertMemoryUsage(t) + } ++ ++func TestProcessStartTime(t *testing.T) { ++ // Reset memory counters ++ helpers.ResetMemoryStats() ++ ++ exp := processStartTime // copy the value before anything touches it ++ ++ code := fmt.Sprintf(` ++ with open(r'%s', 'w') as f: ++ pst = datadog_agent.get_process_start_time() ++ assert type(pst) == type(0.0) ++ f.write(pst.hex()) ++ `, tmpfile.Name()) ++ ++ out, err := run(code) ++ if err != nil { ++ t.Fatal(err) ++ } ++ ++ val, err := strconv.ParseFloat(out, 64) ++ if err != nil { ++ t.Fatal(err) ++ } ++ ++ if val != exp { ++ t.Errorf("Unexpected printed value: '%s'", out) ++ } ++ ++ // Check for leaks ++ helpers.AssertMemoryUsage(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,12 @@ ++H4sIAAAAAAAAA+2UbU/bMBDH+zqf4tRNGwg5IX0Y0qRO6sOASoUiYJqQJlWubVqvjh1sh6n79HPS ++0RUY8AY0bbufFNk6X+7+9j9OPC2k4hOhr5PaS7Eb2Gu3qzFwd6zmabuRNhqtNG21artp2t5r16D9 ++Yoo2KJynFqBmjfGP5T21/pcS//LfC+cnzGQZ1Tx28+fr8YT/wezm2v/dVhr8b71LmzXYfT4JD/Of +++884VMZPBY+iV3D2TXo2B2/goN+HtAlb1dgGRgsnHDCjL5VkXuoZ8cs8RIS1xjqQGhbFVBReqpht ++R1xcE7eqNWMsFLpd/GTp50ZDM04bm6l5FW6u4uGFoQ7mKBXSL7pHI9iy4qqQVnCYLsF6ZSgX9q0D ++523QA2XvUoj0kir5nXpp9HZ0U5NkkMs8LK9KEjK1gi6IWzovMpJTtqCzsB1yFVQsaaag8SEJ0hJd ++KFVq6ZX3ZN0V+kl/ZwfcnJZylJxaaqVwkc2A2Mt1WlLdrihbcGmB5HfjjN+LZHQhgAwGw7Nub/Rx ++cnJxfjg+bnTGxyHY+zQcDSaDj0fjznh/H+I4CSLfpNHqna+vt3RuDdteBYPk00KDnwvg1FNuZpOw ++Qe2hdNtFG74naw1lIOofjCf9/VH34KxTJ8P7SVIzVfDQ8Ddr5d8j+Eo+a0O4yK1g1AsepkxRWxni ++6vClajEa3PQY3a9THUbi51aIBB5OWLtB1M89kmqPZHNBlR3DuY2GvdPu6cXkpHt+2Kk/VTJ5/7iq ++sujMVIcZPi3DO+EB4unMQb3KqANhptC+kwK5hji5ZUISx3H0p68+giAIgiAIgiAIgiAIgiAIgiAI ++giAIgiD/CD8AmGc2XwAoAAA= +diff --git 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-000058/tests/test.sh b/tasks/format-code-task-000058/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3394e4d4118aca89d4cec3b21ec98cd65816d6cf --- /dev/null +++ b/tasks/format-code-task-000058/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' +rtloader/test/datadog_agent/datadog_agent.go +rtloader/test/datadog_agent/datadog_agent_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-000058/tests/test_command.sh b/tasks/format-code-task-000058/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000058/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000060/environment/Dockerfile b/tasks/format-code-task-000060/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..68b150b5ab13f39d9a51c924b92f2ca39c7c0c83 --- /dev/null +++ b/tasks/format-code-task-000060/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c3b5d988c97689ca6a49626f265b52954d31b1110062a6df7f52ec16e8f8cb6f diff --git a/tasks/format-code-task-000060/environment/setup/files/blocklist b/tasks/format-code-task-000060/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000060/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000060/environment/setup/setup.sh b/tasks/format-code-task-000060/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000060/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000060/tests/test.patch b/tasks/format-code-task-000060/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6aad739384f9511b4143d677026212362bd4b0ad --- /dev/null +++ b/tasks/format-code-task-000060/tests/test.patch @@ -0,0 +1,140 @@ +diff --git a/internal/controller/datadogmonitor/monitor_test.go b/internal/controller/datadogmonitor/monitor_test.go +index ae74b3500..da8a4bb66 100644 +--- a/internal/controller/datadogmonitor/monitor_test.go ++++ b/internal/controller/datadogmonitor/monitor_test.go +@@ -18,32 +18,17 @@ import ( + "time" + + "github.com/stretchr/testify/assert" ++ "k8s.io/utils/ptr" + + datadogapi "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +- datadogV1 "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" ++ "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" ++ + datadoghqv1alpha1 "github.com/DataDog/datadog-operator/api/datadoghq/v1alpha1" + ) + + const dateFormat = "2006-01-02 15:04:05.999999999 -0700 MST" + + func Test_buildMonitor(t *testing.T) { +- evalDelay := int64(100) +- escalationMsg := "This is an escalation message" +- valTrue := true +- newGroupDelay := int64(400) +- noDataTimeframe := int64(15) +- renotifyInterval := int64(1440) +- renotifyOccurrences := int64(1) +- renotifyStatuses := []datadogV1.MonitorRenotifyStatusType{ +- datadogV1.MONITORRENOTIFYSTATUSTYPE_ALERT, +- datadogV1.MONITORRENOTIFYSTATUSTYPE_WARN, +- } +- +- timeoutH := int64(2) +- critThreshold := "0.05" +- warnThreshold := "0.02" +- priority := int64(3) +- + dm := &datadoghqv1alpha1.DatadogMonitor{ + Spec: datadoghqv1alpha1.DatadogMonitorSpec{ + RestrictedRoles: []string{"an-admin-uuid"}, +@@ -51,36 +36,46 @@ func Test_buildMonitor(t *testing.T) { + Type: "metric alert", + Name: "Test monitor", + Message: "Something went wrong", +- Priority: priority, ++ Priority: int64(3), + Tags: []string{ + "env:staging", + "kube_namespace:test", + "kube_cluster:test.staging", + }, + Options: datadoghqv1alpha1.DatadogMonitorOptions{ +- EnableLogsSample: &valTrue, +- EvaluationDelay: &evalDelay, +- EscalationMessage: &escalationMsg, +- IncludeTags: &valTrue, +- GroupbySimpleMonitor: &valTrue, +- Locked: &valTrue, +- NewGroupDelay: &newGroupDelay, +- NoDataTimeframe: &noDataTimeframe, ++ EnableLogsSample: ptr.To(true), ++ EvaluationDelay: ptr.To(int64(100)), ++ EscalationMessage: ptr.To("This is an escalation message"), ++ IncludeTags: ptr.To(true), ++ GroupbySimpleMonitor: ptr.To(true), ++ Locked: ptr.To(true), ++ NewGroupDelay: ptr.To(int64(400)), ++ NoDataTimeframe: ptr.To(int64(15)), + NotificationPresetName: "show_all", + NotifyBy: []string{ + "env", + "kube_namespace", + "kube_cluster", + }, +- NotifyNoData: &valTrue, ++ NotifyNoData: ptr.To(true), + OnMissingData: "default", +- RenotifyOccurrences: &renotifyOccurrences, +- RenotifyInterval: &renotifyInterval, +- RenotifyStatuses: renotifyStatuses, +- TimeoutH: &timeoutH, ++ RenotifyOccurrences: ptr.To(int64(1)), ++ RenotifyInterval: ptr.To(int64(1440)), ++ RenotifyStatuses: []datadogV1.MonitorRenotifyStatusType{ ++ datadogV1.MONITORRENOTIFYSTATUSTYPE_ALERT, ++ datadogV1.MONITORRENOTIFYSTATUSTYPE_WARN, ++ }, ++ SchedulingOptions: &datadoghqv1alpha1.DatadogMonitorOptionsSchedulingOptions{ ++ EvaluationWindow: &datadoghqv1alpha1.DatadogMonitorOptionsSchedulingOptionsEvaluationWindow{ ++ DayStarts: ptr.To("01:00"), ++ HourStarts: ptr.To(int32(2)), ++ MonthStarts: ptr.To(int32(3)), ++ }, ++ }, ++ TimeoutH: ptr.To(int64(2)), + Thresholds: &datadoghqv1alpha1.DatadogMonitorOptionsThresholds{ +- Critical: &critThreshold, +- Warning: &warnThreshold, ++ Critical: ptr.To("0.05"), ++ Warning: ptr.To("0.02"), + }, + }, + }, +@@ -151,6 +146,15 @@ func Test_buildMonitor(t *testing.T) { + assert.Equal(t, dm.Spec.Options.RenotifyStatuses, monitor.Options.GetRenotifyStatuses(), "discrepancy found in parameter: RenotifyStatuses") + assert.Equal(t, dm.Spec.Options.RenotifyStatuses, monitorUR.Options.GetRenotifyStatuses(), "discrepancy found in parameter: RenotifyStatuses") + ++ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.DayStarts, monitor.Options.SchedulingOptions.EvaluationWindow.GetDayStarts(), "discrepancy found in parameter: EvaluationWindow.DayStarts") ++ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.DayStarts, monitorUR.Options.SchedulingOptions.EvaluationWindow.GetDayStarts(), "discrepancy found in parameter: EvaluationWindow.DayStarts") ++ ++ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.HourStarts, monitor.Options.SchedulingOptions.EvaluationWindow.GetHourStarts(), "discrepancy found in parameter: EvaluationWindow.HourStarts") ++ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.HourStarts, monitorUR.Options.SchedulingOptions.EvaluationWindow.GetHourStarts(), "discrepancy found in parameter: EvaluationWindow.HourStarts") ++ ++ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.MonthStarts, monitor.Options.SchedulingOptions.EvaluationWindow.GetMonthStarts(), "discrepancy found in parameter: EvaluationWindow.MonthStarts") ++ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.MonthStarts, monitorUR.Options.SchedulingOptions.EvaluationWindow.GetMonthStarts(), "discrepancy found in parameter: EvaluationWindow.MonthStarts") ++ + assert.Equal(t, *dm.Spec.Options.TimeoutH, monitor.Options.GetTimeoutH(), "discrepancy found in parameter: TimeoutH") + assert.Equal(t, *dm.Spec.Options.TimeoutH, monitorUR.Options.GetTimeoutH(), "discrepancy found in parameter: TimeoutH") + +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+3STWrDMBAFYK1zirmArZ9G8SpHyK77oFgiMdgakMc5f2MX2lJos0koTd63mUES ++aMRTfZi6Pu5TPmt1L+ai8X6pF9/r0lvvrDPO+vVGGWt90yjyd5voi2mUUIhUYZbfzl3b/6fqz/wl ++jbJveRhCjvV4ut0d1/K3L/4jf+fm/Ncb4xWZ243wsyfPv420BH9IcXVkmluqzlS1PGXZWqp1lyWV ++HHrdcpbCfZ+KjkFC5OPAuRMumqoyZXqd/8/ynXbv66u/fhwAAAAAAAAAAAAAAAAAAAAAwIN7A7fv ++5lEAKAAA +diff --git 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-000060/tests/test.sh b/tasks/format-code-task-000060/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c38c7ca47f82f31d9a15c5d49760a2b54ba98b6 --- /dev/null +++ b/tasks/format-code-task-000060/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/controller/datadogmonitor/monitor_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-000060/tests/test_command.sh b/tasks/format-code-task-000060/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000060/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000067/environment/Dockerfile b/tasks/format-code-task-000067/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8f647393d92e52c61f40dad259249a3176d4612f --- /dev/null +++ b/tasks/format-code-task-000067/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5987f5e3ecbdc9568af6bd08225a63fb8c4daba8bb466709a64be3a195ed15e6 diff --git a/tasks/format-code-task-000067/environment/setup/files/blocklist b/tasks/format-code-task-000067/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000067/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000067/environment/setup/setup.sh b/tasks/format-code-task-000067/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000067/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000067/tests/test.patch b/tasks/format-code-task-000067/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e51dab5039487278b99b959dcee3006d4fdd5c8b --- /dev/null +++ b/tasks/format-code-task-000067/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/directory/tests/test_directory.py b/directory/tests/test_directory.py +index 3b655e109394d..927eaccb4ce7c 100644 +--- a/directory/tests/test_directory.py ++++ b/directory/tests/test_directory.py +@@ -331,29 +331,44 @@ def test_non_existent_directory_ignore_missing(aggregator): + aggregator.assert_service_check('system.disk.directory.exists', DirectoryCheck.WARNING, tags=expected_tags) + + +-def test_os_error_mid_walk_emits_error_and_continues(aggregator, monkeypatch, caplog): ++def test_os_error_mid_walk_emits_error_and_continues(aggregator, caplog): + caplog.set_level(logging.WARNING) + +- def mock_walk(folder, *args, **kwargs): +- from datadog_checks.directory.traverse import walk +- +- walker = walk(folder, *args, **kwargs) +- yield next(walker) +- raise OSError('Permission denied') +- +- monkeypatch.setattr('datadog_checks.directory.directory.walk', mock_walk) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + with temp_directory() as tdir: +- +- # Create folder +- mkdir(os.path.join(tdir, 'a_folder')) ++ ++ os.makedirs(os.path.join(tdir, 'bad_folder_a'), mode=0o377) ++ os.makedirs(os.path.join(tdir, 'bad_folder_b'), mode=0o377) ++ ++ os.makedirs(os.path.join(tdir, 'ok')) ++ with open(os.path.join(tdir, 'ok', 'file'), 'w') as f: ++ f.write('') + + # Run Check + instance = {'directory': tdir, 'recursive': True} + check = DirectoryCheck('directory', {}, [instance]) + check.check(instance) + +- assert 'Permission denied' in caplog.text ++ ++ os.chmod(os.path.join(tdir, 'bad_folder_a'), 0o777) ++ os.chmod(os.path.join(tdir, 'bad_folder_b'), 0o777) ++ ++ aggregator.assert_metric("system.disk.directory.files", count=1, value=1) ++ ++ permission_denied_log_lines = [line for line in caplog.text.splitlines() if 'Permission denied' in line] ++ assert len(permission_denied_log_lines) == 2 ++ assert 'bad_folder_a' in caplog.text ++ assert 'bad_folder_b' in caplog.text + + + def test_no_recursive_symlink_loop(aggregator): +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+2UzW7TQBDHffZTDKkUgSrbccDpjQvijvoC1np3QlbYu2Y/Qi3KuzPrKEkbCXpp ++hVDnd/Bas/O5/7XLLupetWj2VfZSrIibpplX4nKd3+tmXa9X9aZZr7NVXTc3TQbNi3X0gOiDcACZ ++szb8ze+p/f+U8qx/QB9aaYdBGFX63fPVeEL/un5fn/T/sCF7Tc9NBqvna+HPvHL9r95U0buq06ai ++OwCd8LvcY4ACo4VRj7gVus+lgvl6dKjy/Ao+ORQBIVmiRwd6C8YGED3Z1QSjQ48m5FpBEc9ey4+V ++wn1lYt/D/T0km1DkMpxcUu7PxkeHsE/daA9CSvRedz2Vs1TFFEmIOdjncjdYSnAL4trdnTqsyhSc ++b7VRFzYowjQiUAjeoYRD+Bz78xdcp+q30UDYHUaj4v7c/dtj7XfQoRRkOzm21rfonHXtoFX7Q/Tf ++Whx0OBrpc6LPygRtInqqkULA4feo6ZxAPB4qTfmVzn/xBd2gaXJrQKHRqBYwp/NAFgoMTsuAChRl ++kcE6jb7MfYTi3HLhYRY2iQqFhIW30Um8OJTZRcig90nT5RIeiF0ds09pY5zCjoqTYPSWhphP6fDf ++ODmW4wTFfpH/64vNMAzDMAzDMAzDMAzDMAzDMAzDMAzDMAzzSvgNIXRQMAAoAAA= +diff --git 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-000067/tests/test.sh b/tasks/format-code-task-000067/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..381aa9c3d1954ee6252980eb6d74ef44ff978a9b --- /dev/null +++ b/tasks/format-code-task-000067/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' +directory/tests/test_directory.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-000067/tests/test_command.sh b/tasks/format-code-task-000067/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000067/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000069/environment/Dockerfile b/tasks/format-code-task-000069/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f7243dc497efaeb8ae6f97174291d234b66a2ab2 --- /dev/null +++ b/tasks/format-code-task-000069/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:25f55976fd5a55e4280cb4ec3c6e7273e7f58d066037d5282d9428d38cafa679 diff --git a/tasks/format-code-task-000069/environment/setup/files/blocklist b/tasks/format-code-task-000069/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000069/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000069/environment/setup/setup.sh b/tasks/format-code-task-000069/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000069/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000069/tests/test.patch b/tasks/format-code-task-000069/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..85baa19372cc7c84c282ab83604f378694f97841 --- /dev/null +++ b/tasks/format-code-task-000069/tests/test.patch @@ -0,0 +1,247 @@ +diff --git a/mapper/clusterstate_translation_test.go b/mapper/clusterstate_translation_test.go +new file mode 100644 +index 0000000..b21b049 +--- /dev/null ++++ b/mapper/clusterstate_translation_test.go +@@ -0,0 +1,221 @@ ++package mapper ++ ++import ( ++ "sort" ++ "strconv" ++ "strings" ++ "testing" ++ ++ "github.com/DataDog/kafka-kit/v4/kafkaadmin" ++) ++ ++ ++ ++ ++func buildTopicStates() kafkaadmin.TopicStates { ++ ts := kafkaadmin.NewTopicStates() ++ ++ specs := map[string]int{ ++ "delta": 3, ++ "alpha": 4, ++ "charlie": 2, ++ "bravo": 3, ++ } ++ ++ for name, n := range specs { ++ state := kafkaadmin.NewTopicState(name) ++ for p := 0; p < n; p++ { ++ state.PartitionStates[p] = kafkaadmin.PartitionState{ ++ ID: int32(p), ++ Leader: int32(1000 + p), ++ Replicas: []int32{int32(1000 + p), int32(2000 + p)}, ++ ISR: []int32{int32(1000 + p), int32(2000 + p)}, ++ } ++ } ++ state.Partitions = int32(n) ++ state.ReplicationFactor = 2 ++ ts[name] = state ++ } ++ ++ return ts ++} ++ ++func TestPartitionMapFromTopicStatesOrdering(t *testing.T) { ++ ts := buildTopicStates() ++ ++ pm, err := PartitionMapFromTopicStates(ts) ++ if err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ if pm == nil { ++ t.Fatal("expected a non-nil PartitionMap") ++ } ++ ++ ++ ++ type tp struct { ++ topic string ++ id int ++ } ++ var expected []tp ++ for name, state := range ts { ++ for _, ps := range state.PartitionStates { ++ expected = append(expected, tp{topic: name, id: int(ps.ID)}) ++ } ++ } ++ sort.Slice(expected, func(i, j int) bool { ++ if expected[i].topic != expected[j].topic { ++ return expected[i].topic < expected[j].topic ++ } ++ return expected[i].id < expected[j].id ++ }) ++ ++ if len(pm.Partitions) != len(expected) { ++ t.Fatalf("expected %d partitions, got %d", len(expected), len(pm.Partitions)) ++ } ++ ++ for i, p := range pm.Partitions { ++ if p.Topic != expected[i].topic || p.Partition != expected[i].id { ++ t.Fatalf("partition at index %d = (%s, %d), want (%s, %d); full order not sorted by (topic, partition)", ++ i, p.Topic, p.Partition, expected[i].topic, expected[i].id) ++ } ++ } ++} ++ ++func TestPartitionMapFromTopicStatesReplicaOrderPreserved(t *testing.T) { ++ ts := kafkaadmin.NewTopicStates() ++ state := kafkaadmin.NewTopicState("topic") ++ ++ state.PartitionStates[0] = kafkaadmin.PartitionState{ ++ ID: 0, ++ Leader: 1003, ++ Replicas: []int32{1003, 1001, 1002}, ++ ISR: []int32{1003, 1001, 1002}, ++ } ++ state.Partitions = 1 ++ state.ReplicationFactor = 3 ++ ts["topic"] = state ++ ++ pm, err := PartitionMapFromTopicStates(ts) ++ if err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ if len(pm.Partitions) != 1 { ++ t.Fatalf("expected 1 partition, got %d", len(pm.Partitions)) ++ } ++ ++ got := pm.Partitions[0].Replicas ++ want := []int{1003, 1001, 1002} ++ if len(got) != len(want) { ++ t.Fatalf("expected replicas %v, got %v", want, got) ++ } ++ for i := range want { ++ if got[i] != want[i] { ++ t.Fatalf("expected replicas %v (preferred-leader-first), got %v", want, got) ++ } ++ } ++} ++ ++func TestPartitionMapFromTopicStatesEmpty(t *testing.T) { ++ for _, ts := range []kafkaadmin.TopicStates{nil, kafkaadmin.NewTopicStates()} { ++ pm, err := PartitionMapFromTopicStates(ts) ++ if err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ if pm == nil { ++ t.Fatal("expected a non-nil PartitionMap for empty input") ++ } ++ if len(pm.Partitions) != 0 { ++ t.Fatalf("expected 0 partitions for empty input, got %d", len(pm.Partitions)) ++ } ++ } ++} ++ ++func TestBrokerMetaMapLoadMetricsComplete(t *testing.T) { ++ bmm := BrokerMetaMap{ ++ 1001: &BrokerMeta{Rack: "a"}, ++ 1002: &BrokerMeta{Rack: "b"}, ++ 1003: &BrokerMeta{Rack: "c"}, ++ } ++ ++ metrics := BrokerMetricsMap{ ++ 1001: &BrokerMetrics{StorageFree: 2000.00}, ++ 1002: &BrokerMetrics{StorageFree: 4000.00}, ++ 1003: &BrokerMetrics{StorageFree: 6000.00}, ++ ++ 9999: &BrokerMetrics{StorageFree: 1.00}, ++ } ++ ++ errs := bmm.LoadMetrics(metrics) ++ if errs != nil { ++ t.Fatalf("expected no errors, got %v", errs) ++ } ++ ++ expected := map[int]float64{1001: 2000.00, 1002: 4000.00, 1003: 6000.00} ++ for id, want := range expected { ++ if bmm[id].StorageFree != want { ++ t.Errorf("broker %d StorageFree = %v, want %v", id, bmm[id].StorageFree, want) ++ } ++ if bmm[id].MetricsIncomplete { ++ t.Errorf("broker %d should not be marked MetricsIncomplete", id) ++ } ++ } ++ ++ ++ if _, exists := bmm[9999]; exists { ++ t.Error("broker 9999 (metrics-only) should not have been added to the metadata map") ++ } ++} ++ ++func TestBrokerMetaMapLoadMetricsMissing(t *testing.T) { ++ bmm := BrokerMetaMap{ ++ 1004: &BrokerMeta{Rack: "a"}, ++ 1001: &BrokerMeta{Rack: "b"}, ++ 1003: &BrokerMeta{Rack: "c"}, ++ 1002: &BrokerMeta{Rack: "d"}, ++ } ++ ++ ++ metrics := BrokerMetricsMap{ ++ 1001: &BrokerMetrics{StorageFree: 2000.00}, ++ 1003: &BrokerMetrics{StorageFree: 6000.00}, ++ } ++ ++ errs := bmm.LoadMetrics(metrics) ++ ++ ++ if bmm[1001].StorageFree != 2000.00 || bmm[1001].MetricsIncomplete { ++ t.Errorf("broker 1001 unexpected state: StorageFree=%v Incomplete=%v", bmm[1001].StorageFree, bmm[1001].MetricsIncomplete) ++ } ++ if bmm[1003].StorageFree != 6000.00 || bmm[1003].MetricsIncomplete { ++ t.Errorf("broker 1003 unexpected state: StorageFree=%v Incomplete=%v", bmm[1003].StorageFree, bmm[1003].MetricsIncomplete) ++ } ++ ++ ++ for _, id := range []int{1002, 1004} { ++ if !bmm[id].MetricsIncomplete { ++ t.Errorf("broker %d should be marked MetricsIncomplete", id) ++ } ++ if bmm[id].StorageFree != 0 { ++ t.Errorf("broker %d StorageFree should be untouched (0), got %v", id, bmm[id].StorageFree) ++ } ++ } ++ ++ ++ wantMissing := []int{1002, 1004} ++ if len(errs) != len(wantMissing) { ++ t.Fatalf("expected %d errors, got %d (%v)", len(wantMissing), len(errs), errs) ++ } ++ for i, id := range wantMissing { ++ if !strings.Contains(errs[i].Error(), strconv.Itoa(id)) { ++ t.Errorf("error at index %d = %q, expected it to reference broker %d (errors must be ordered ascending by broker ID)", i, errs[i].Error(), id) ++ } ++ } ++} ++ ++func TestBrokerMetaMapLoadMetricsEmptyMap(t *testing.T) { ++ bmm := BrokerMetaMap{} ++ if errs := bmm.LoadMetrics(BrokerMetricsMap{1001: &BrokerMetrics{StorageFree: 1.0}}); errs != nil { ++ t.Fatalf("expected no errors for an empty metadata map, got %v", errs) ++ } ++} +diff --git 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 ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++go test ./mapper/ ++ ++ ++go test ./mapper/ -run 'TestPartitionMapFromTopicStates|TestBrokerMetaMapLoadMetrics' -v diff --git a/tasks/format-code-task-000069/tests/test.sh b/tasks/format-code-task-000069/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3b61ebc37815172709b7a39cf39d6c7645e90eab --- /dev/null +++ b/tasks/format-code-task-000069/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' +mapper/clusterstate_translation_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-000069/tests/test_command.sh b/tasks/format-code-task-000069/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000069/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000093/environment/Dockerfile b/tasks/format-code-task-000093/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4b7627b873575a99672d0ae9381dc0d65d2e2ca4 --- /dev/null +++ b/tasks/format-code-task-000093/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2b8ef96a0809d798c01b5f0181f4b629d75a8a11fa0eda91fcb03d6b5d1f26dc diff --git a/tasks/format-code-task-000093/environment/setup/files/blocklist b/tasks/format-code-task-000093/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000093/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000093/environment/setup/setup.sh b/tasks/format-code-task-000093/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000093/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000093/tests/test.patch b/tasks/format-code-task-000093/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..aec1d96e266d905a86a1adb2add3445a44dcb7c5 --- /dev/null +++ b/tasks/format-code-task-000093/tests/test.patch @@ -0,0 +1,113 @@ +diff --git a/pygmt/tests/test_show_versions.py b/pygmt/tests/test_show_versions.py +index f9b6d9926..2ce71f3f4 100644 +--- a/pygmt/tests/test_show_versions.py ++++ b/pygmt/tests/test_show_versions.py +@@ -3,10 +3,12 @@ Test the pygmt.show_versions function. + """ + + import io ++import re + from unittest.mock import patch + + import pygmt + import pytest ++from pygmt._show_versions import _get_gdal_version + + + def test_show_versions(): +@@ -69,3 +71,73 @@ def test_show_versions_ghostscript_not_found(): + pygmt.show_versions(file=buf) + assert "ghostscript: None" in buf.getvalue() + assert "WARNING:" in buf.getvalue() ++ ++ ++def test_get_gdal_version_returns_clean_version_string(): ++ """ ++ Check that _get_gdal_version returns a clean version string like '3.10.3' (not a ++ verbose string with extra text such as 'GDAL 3.10.3, released ...') when the GDAL ++ C library is available on the system. ++ """ ++ gdal_version = _get_gdal_version() ++ assert gdal_version is not None, ( ++ "Expected _get_gdal_version() to detect GDAL via the C library, got None" ++ ) ++ ++ assert re.match(r"^\d+\.\d+", gdal_version), ( ++ f"_get_gdal_version() returned non-version-like string: {gdal_version!r}" ++ ) ++ ++ ++def test_show_versions_reports_gdal_version(): ++ """ ++ Check that pygmt.show_versions reports an actual GDAL version (not None) when the ++ GDAL C library is installed, even if the GDAL Python bindings are not installed. ++ This is the core regression covered by the bug fix. ++ """ ++ buf = io.StringIO() ++ pygmt.show_versions(file=buf) ++ output = buf.getvalue() ++ ++ ++ match = re.search(r"^\s*gdal:\s*(.+)$", output, flags=re.MULTILINE) ++ assert match is not None, f"No 'gdal:' line found in output:\n{output}" ++ gdal_value = match.group(1).strip() ++ assert gdal_value != "None", ( ++ "pygmt.show_versions reported gdal: None even though the GDAL C library " ++ "is available on the system." ++ ) ++ ++ assert re.match(r"^\d+\.\d+", gdal_value), ( ++ f"Expected a version-like string for gdal, got: {gdal_value!r}" ++ ) ++ ++ ++def test_show_versions_gdal_in_dependency_section(): ++ """ ++ Check that the 'gdal:' line appears in the Dependency information section of the ++ output (i.e., between the 'Dependency information:' header and the 'GMT library ++ information:' header). ++ """ ++ buf = io.StringIO() ++ pygmt.show_versions(file=buf) ++ output = buf.getvalue() ++ ++ dep_idx = output.index("Dependency information:") ++ gmt_idx = output.index("GMT library information:") ++ section = output[dep_idx:gmt_idx] ++ assert "gdal:" in section, ( ++ f"'gdal:' not found in the Dependency information section:\n{section}" ++ ) ++ ++ ++def test_show_versions_gdal_none_when_unavailable(): ++ """ ++ Check that pygmt.show_versions reports 'gdal: None' (without raising) when GDAL ++ cannot be detected. ++ """ ++ with patch("pygmt._show_versions._get_gdal_version", return_value=None): ++ buf = io.StringIO() ++ pygmt.show_versions(file=buf) ++ output = buf.getvalue() ++ assert "gdal: None" in output +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..3292bd362 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pygmt/tests/test_show_versions.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 pygmt/tests/test_show_versions.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000093/tests/test.sh b/tasks/format-code-task-000093/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a94ca5757bf9a13255adc6bba5bafe24e13b9b59 --- /dev/null +++ b/tasks/format-code-task-000093/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' +pygmt/tests/test_show_versions.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-000093/tests/test_command.sh b/tasks/format-code-task-000093/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000093/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000094/environment/Dockerfile b/tasks/format-code-task-000094/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0d1d16fe6ab7021ae0b44fc43e7725e18cd8a1cb --- /dev/null +++ b/tasks/format-code-task-000094/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e027c32ff541c33a266153bcb2433e5a93376b913de86a946d71c722bd448665 diff --git a/tasks/format-code-task-000094/environment/setup/files/blocklist b/tasks/format-code-task-000094/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000094/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000094/environment/setup/setup.sh b/tasks/format-code-task-000094/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000094/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000094/tests/test.patch b/tasks/format-code-task-000094/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b229128906697102afe5783204df512b1c5278aa --- /dev/null +++ b/tasks/format-code-task-000094/tests/test.patch @@ -0,0 +1,122 @@ +diff --git a/package/src/components/MessageList/__tests__/ScrollToBottomButton.test.js b/package/src/components/MessageList/__tests__/ScrollToBottomButton.test.js +index 0a2d9fd9d..7c6fcfb78 100644 +--- a/package/src/components/MessageList/__tests__/ScrollToBottomButton.test.js ++++ b/package/src/components/MessageList/__tests__/ScrollToBottomButton.test.js +@@ -79,6 +79,95 @@ describe('ScrollToBottomButton', () => { + }); + }); + ++ const findChevronPath = (node) => { ++ if (!node) return null; ++ if (Array.isArray(node)) { ++ for (const c of node) { ++ const r = findChevronPath(c); ++ if (r) return r; ++ } ++ return null; ++ } ++ if (typeof node !== 'object') return null; ++ if (node.type === 'RNSVGPath') return node; ++ if (node.children) { ++ return findChevronPath(node.children); ++ } ++ return null; ++ }; ++ ++ ++ ++ ++ ++ const BLACK_FILL = 4278190080; ++ const RED_FILL = 4294901760; ++ const BLUE_FILL = 4278190335; ++ ++ it('should render chevron with default black fill when no chevronColor is set', async () => { ++ const i18nInstance = new Streami18n(); ++ const translators = await i18nInstance.getTranslators(); ++ const { toJSON } = render( ++ ++ ++ null} showNotification={true} /> ++ ++ , ++ ); ++ const path = findChevronPath(toJSON()); ++ expect(path).toBeTruthy(); ++ expect(path.props.fill).toBe(BLACK_FILL); ++ }); ++ ++ it('should render chevron with theme.messageList.scrollToBottomButton.chevronColor=red', async () => { ++ const i18nInstance = new Streami18n(); ++ const translators = await i18nInstance.getTranslators(); ++ const { toJSON } = render( ++ ++ ++ null} showNotification={true} /> ++ ++ , ++ ); ++ const path = findChevronPath(toJSON()); ++ expect(path).toBeTruthy(); ++ expect(path.props.fill).toBe(RED_FILL); ++ }); ++ ++ it('should render chevron with theme.messageList.scrollToBottomButton.chevronColor=#0000FF', async () => { ++ const i18nInstance = new Streami18n(); ++ const translators = await i18nInstance.getTranslators(); ++ const { toJSON } = render( ++ ++ ++ null} showNotification={true} /> ++ ++ , ++ ); ++ const path = findChevronPath(toJSON()); ++ expect(path).toBeTruthy(); ++ expect(path.props.fill).toBe(BLUE_FILL); ++ }); ++ ++ it('should fall back to black when chevronColor is an empty string', async () => { ++ const i18nInstance = new Streami18n(); ++ const translators = await i18nInstance.getTranslators(); ++ const { toJSON } = render( ++ ++ ++ null} showNotification={true} /> ++ ++ , ++ ); ++ const path = findChevronPath(toJSON()); ++ expect(path).toBeTruthy(); ++ expect(path.props.fill).toBe(BLACK_FILL); ++ }); ++ + it('should render the message notification and match snapshot', async () => { + const i18nInstance = new Streami18n(); + const translators = await i18nInstance.getTranslators(); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..51fcaeb0c +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd package && yarn test:unit --testPathPattern=ScrollToBottomButton -t chevron"] ++} +diff --git 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 package && yarn test:unit --testPathPattern=ScrollToBottomButton -t chevron ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000094/tests/test.sh b/tasks/format-code-task-000094/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3f68d782482b74cfe7eda08dcf0dc6bb8ed8295a --- /dev/null +++ b/tasks/format-code-task-000094/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' +package/src/components/MessageList/__tests__/ScrollToBottomButton.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-000094/tests/test_command.sh b/tasks/format-code-task-000094/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000094/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000200/environment/Dockerfile b/tasks/format-code-task-000200/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d40fb53de3daf41cbc8d5ebafec35dad2975e700 --- /dev/null +++ b/tasks/format-code-task-000200/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0e92bc099da3746dbdd108c3c44bf5dbb998658950327c181db933320b4a56ea diff --git a/tasks/format-code-task-000200/environment/setup/files/blocklist b/tasks/format-code-task-000200/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000200/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000200/environment/setup/setup.sh b/tasks/format-code-task-000200/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000200/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000200/tests/test.patch b/tasks/format-code-task-000200/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..aee066358f42c76de5dba384c63224c91b9b3131 --- /dev/null +++ b/tasks/format-code-task-000200/tests/test.patch @@ -0,0 +1,72 @@ +diff --git a/tests/ops/qubit/test_non_parametric_ops.py b/tests/ops/qubit/test_non_parametric_ops.py +index 595582f0f..30725a81c 100644 +--- a/tests/ops/qubit/test_non_parametric_ops.py ++++ b/tests/ops/qubit/test_non_parametric_ops.py +@@ -525,6 +525,46 @@ class TestBarrier: + + assert optimized_gates == 2 + ++ def test_barrier_adjoint_returns_equivalent_barrier(self): ++ """Test that the adjoint transform can handle an isolated Barrier operation.""" ++ wires = ["alpha", "beta"] ++ expected_operation = qml.Barrier(only_visual=False, wires=wires) ++ ++ with qml.tape.QuantumTape() as tape: ++ qml.adjoint(qml.Barrier)(only_visual=False, wires=wires) ++ ++ assert len(tape.operations) == 1 ++ adjoint_operation = tape.operations[0] ++ assert type(adjoint_operation) is type(expected_operation) ++ assert adjoint_operation.wires == expected_operation.wires ++ assert adjoint_operation.only_visual is expected_operation.only_visual ++ ++ def test_adjoint_function_preserves_barrier_on_same_wires(self): ++ """Test that Barrier is preserved when adjointing a quantum function.""" ++ ++ def qfunc(): ++ qml.Hadamard(wires="left") ++ qml.Barrier(only_visual=False, wires=["left", "right"]) ++ qml.CNOT(wires=["left", "right"]) ++ ++ expected_operation_types = [qml.Hadamard, qml.Barrier, qml.CNOT] ++ ++ with qml.tape.QuantumTape() as tape: ++ qfunc() ++ qml.adjoint(qfunc)() ++ ++ operations = tape.operations ++ ++ assert [type(op) for op in operations] == [ ++ *expected_operation_types, ++ *reversed(expected_operation_types), ++ ] ++ ++ original_barrier = operations[1] ++ adjointed_barrier = operations[4] ++ assert adjointed_barrier.wires == original_barrier.wires ++ assert adjointed_barrier.only_visual is original_barrier.only_visual ++ + + class TestMultiControlledX: + """Tests for the MultiControlledX""" +diff --git 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 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest tests/ops/qubit/test_non_parametric_ops.py::TestOperations tests/ops/qubit/test_non_parametric_ops.py::TestDecompositions tests/ops/qubit/test_non_parametric_ops.py::TestEigenval -x -v ++ ;; ++ new) ++ python3 -m pytest tests/ops/qubit/test_non_parametric_ops.py -x -v -k 'test_barrier_adjoint_returns_equivalent_barrier or test_adjoint_function_preserves_barrier_on_same_wires' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000200/tests/test.sh b/tasks/format-code-task-000200/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..88b695e4dfd447e4abfc10cd82b854f3c392b698 --- /dev/null +++ b/tasks/format-code-task-000200/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/ops/qubit/test_non_parametric_ops.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-000200/tests/test_command.sh b/tasks/format-code-task-000200/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000200/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-000209/environment/Dockerfile b/tasks/format-code-task-000209/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eed9f2469bce8002ed3ac76f6ea698b0e1139b79 --- /dev/null +++ b/tasks/format-code-task-000209/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e6fd4b39817da34d00a85fb66e8f4449c686df89c3449bca116f8e3e7e060b20 diff --git a/tasks/format-code-task-000209/environment/setup/files/blocklist b/tasks/format-code-task-000209/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000209/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000209/environment/setup/setup.sh b/tasks/format-code-task-000209/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000209/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000209/tests/test.patch b/tasks/format-code-task-000209/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e7dfde42f1898fa31d47f9da8eb6dae1fe32b042 --- /dev/null +++ b/tasks/format-code-task-000209/tests/test.patch @@ -0,0 +1,170 @@ +diff --git a/posthog/api/test/test_cohort.py b/posthog/api/test/test_cohort.py +index 535466a10e2..cb0825e0bac 100644 +--- a/posthog/api/test/test_cohort.py ++++ b/posthog/api/test/test_cohort.py +@@ -32,3 +32,18 @@ class TestCohort(BaseTest): + self.assertEqual(response.status_code, 200, response.content) + self.assertEqual(response.json()["name"], "whatever2") + self.assertEqual(patch_calculate_cohort.call_count, 2) ++ ++ def test_cohort_api_includes_errors_calculating(self): ++ cohort = Cohort.objects.create( ++ team=self.team, ++ groups=[{"action_id": 999999999}], ++ name="cohort1", ++ ) ++ cohort.calculate_people() ++ cohort.refresh_from_db() ++ cohort.calculate_people() ++ cohort.refresh_from_db() ++ ++ response = self.client.get("/api/cohort/%s/" % cohort.pk) ++ self.assertEqual(response.status_code, 200) ++ self.assertEqual(response.json()["errors_calculating"], 2) +diff --git a/posthog/tasks/test/test_calculate_cohort.py b/posthog/tasks/test/test_calculate_cohort.py +new file mode 100644 +index 00000000000..9e3ccb79f0b +--- /dev/null ++++ b/posthog/tasks/test/test_calculate_cohort.py +@@ -0,0 +1,39 @@ ++from unittest.mock import patch ++ ++from dateutil.relativedelta import relativedelta ++from django.utils import timezone ++ ++from posthog.models import Cohort ++from posthog.tasks.calculate_cohort import calculate_cohorts ++from posthog.test.base import BaseTest ++ ++ ++class TestCalculateCohort(BaseTest): ++ def _stale_cohort_with_failures(self, failures): ++ cohort = Cohort.objects.create( ++ team=self.team, ++ groups=[{"properties": {"$some_prop": "nomatchihope"}}], ++ name="cohort-%s" % failures, ++ last_calculation=timezone.now() - relativedelta(hours=2), ++ ) ++ cohort.groups = [{"action_id": 999999999}] ++ cohort.save() ++ for _ in range(failures): ++ cohort.calculate_people() ++ cohort.refresh_from_db() ++ cohort.is_calculating = False ++ cohort.last_calculation = timezone.now() - relativedelta(hours=2) ++ cohort.save() ++ return cohort ++ ++ def test_periodic_recalculation_skips_cohorts_after_three_failures(self): ++ no_failures = self._stale_cohort_with_failures(0) ++ two_failures = self._stale_cohort_with_failures(2) ++ three_failures = self._stale_cohort_with_failures(3) ++ four_failures = self._stale_cohort_with_failures(4) ++ ++ with patch("posthog.tasks.calculate_cohort.calculate_cohort.delay") as delay: ++ calculate_cohorts() ++ ++ enqueued_ids = {call.args[0] if call.args else call.kwargs["cohort_id"] for call in delay.call_args_list} ++ self.assertEqual(enqueued_ids, {no_failures.pk, two_failures.pk}) +diff --git a/posthog/test/test_cohort_model.py b/posthog/test/test_cohort_model.py +index 49dd0dbacc6..eb1b6193bdb 100644 +--- a/posthog/test/test_cohort_model.py ++++ b/posthog/test/test_cohort_model.py +@@ -8,6 +8,8 @@ from posthog.test.base import BaseTest + + + class TestCohort(BaseTest): ++ TESTS_API = True ++ + def test_postgres_get_distinct_ids_from_cohort(self): + person1 = Person.objects.create(distinct_ids=["person_1"], team=self.team) + event1 = Event.objects.create(event="user signed up", team=self.team, distinct_id="person_1") +@@ -76,3 +78,50 @@ class TestCohort(BaseTest): + + cohort2.calculate_people() + self.assertFalse(Cohort.objects.get().is_calculating) ++ ++ def _cohort_response(self, cohort): ++ response = self.client.get("/api/cohort/%s/" % cohort.pk) ++ self.assertEqual(response.status_code, 200) ++ return response.json() ++ ++ def _fail_cohort_calculation(self, cohort): ++ cohort.groups = [{"action_id": 999999999}] ++ cohort.save() ++ cohort.calculate_people() ++ cohort.refresh_from_db() ++ return cohort ++ ++ def test_failed_calculation_clears_calculating_and_increments_error_count(self): ++ cohort = Cohort.objects.create( ++ team=self.team, ++ groups=[{"properties": {"$some_prop": "nomatchihope"}}], ++ name="cohort1", ++ ) ++ ++ cohort = self._fail_cohort_calculation(cohort) ++ cohort = self._fail_cohort_calculation(cohort) ++ self.assertEqual(self._cohort_response(cohort)["errors_calculating"], 2) ++ ++ cohort.is_calculating = True ++ cohort.save() ++ cohort = self._fail_cohort_calculation(cohort) ++ ++ self.assertFalse(cohort.is_calculating) ++ self.assertEqual(self._cohort_response(cohort)["errors_calculating"], 3) ++ ++ def test_successful_calculation_clears_prior_error_count(self): ++ cohort = Cohort.objects.create( ++ team=self.team, ++ groups=[{"properties": {"$some_prop": "nomatchihope"}}], ++ name="cohort1", ++ ) ++ cohort = self._fail_cohort_calculation(cohort) ++ cohort = self._fail_cohort_calculation(cohort) ++ ++ cohort.groups = [{"properties": {"$some_prop": "nomatchihope"}}] ++ cohort.save() ++ cohort.calculate_people() ++ cohort.refresh_from_db() ++ self.assertEqual(self._cohort_response(cohort)["errors_calculating"], 0) ++ self.assertFalse(cohort.is_calculating) ++ self.assertIsNotNone(cohort.last_calculation) +diff --git 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 -uo pipefail ++cd /testbed ++ ++ ++pg_isready -q 2>/dev/null || pg_ctlcluster 16 main start 2>/dev/null ++ ++ ++redis-cli ping >/dev/null 2>&1 || redis-server --daemonize yes 2>/dev/null ++ ++export DATABASE_URL="postgres://postgres:postgres@localhost:5432/posthog" ++export REDIS_URL="redis://localhost/" ++export TEST="true" ++export DJANGO_SETTINGS_MODULE="posthog.settings" ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest posthog/test/test_cohort_model.py -x -v \ ++ -k "not test_failed_calculation_clears_calculating_and_increments_error_count and not test_successful_calculation_clears_prior_error_count" 2>&1 ++ ;; ++ new) ++ python3 -m pytest \ ++ posthog/api/test/test_cohort.py::TestCohort::test_cohort_api_includes_errors_calculating \ ++ posthog/test/test_cohort_model.py::TestCohort::test_failed_calculation_clears_calculating_and_increments_error_count \ ++ posthog/test/test_cohort_model.py::TestCohort::test_successful_calculation_clears_prior_error_count \ ++ posthog/tasks/test/test_calculate_cohort.py::TestCalculateCohort::test_periodic_recalculation_skips_cohorts_after_three_failures \ ++ -x -v 2>&1 ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000209/tests/test.sh b/tasks/format-code-task-000209/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1e36c3b0ebc99cea654584ae8a1a2402e5accaa7 --- /dev/null +++ b/tasks/format-code-task-000209/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' +posthog/api/test/test_cohort.py +posthog/tasks/test/test_calculate_cohort.py +posthog/test/test_cohort_model.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-000209/tests/test_command.sh b/tasks/format-code-task-000209/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000209/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-000238/environment/Dockerfile b/tasks/format-code-task-000238/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0d0f3ec5c2f6e10bdc57a10e4780997a91842065 --- /dev/null +++ b/tasks/format-code-task-000238/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:029305ec1673a697ddfa326c6fe8bb5ff9e749cd94e311fe75e79a164978db82 diff --git a/tasks/format-code-task-000238/environment/setup/files/blocklist b/tasks/format-code-task-000238/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000238/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000238/environment/setup/setup.sh b/tasks/format-code-task-000238/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000238/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000238/tests/test.patch b/tasks/format-code-task-000238/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..177a407534c2f4586e720a114405961e879af625 --- /dev/null +++ b/tasks/format-code-task-000238/tests/test.patch @@ -0,0 +1,53 @@ +diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py +index 331be75980..609bcf85ee 100644 +--- a/Lib/test/test_math.py ++++ b/Lib/test/test_math.py +@@ -471,8 +471,6 @@ def testDegrees(self): + self.ftest('degrees(-pi/4)', math.degrees(-math.pi/4), -45.0) + self.ftest('degrees(0)', math.degrees(0), 0) + +- # TODO: RUSTPYTHON +- @unittest.expectedFailure + def testExp(self): + self.assertRaises(TypeError, math.exp) + self.ftest('exp(-1)', math.exp(-1), 1/math.e) +@@ -1022,8 +1020,6 @@ def testlcm(self): + self.assertRaises(TypeError, lcm, 120, 0, 84.0) + # self.assertEqual(lcm(MyIndexable(120), MyIndexable(84)), 840) # TODO: RUSTPYTHON + +- # TODO: RUSTPYTHON +- @unittest.expectedFailure + def testLdexp(self): + self.assertRaises(TypeError, math.ldexp) + self.ftest('ldexp(0,1)', math.ldexp(0,1), 0) +@@ -1565,8 +1561,6 @@ def test_inf_constant(self): + # still fails this part of the test on some platforms. For now, we only + # *run* test_exceptions() in verbose mode, so that this isn't normally + # tested. +- # TODO: RUSTPYTHON +- @unittest.expectedFailure + @unittest.skipUnless(verbose, 'requires verbose mode') + def test_exceptions(self): + try: +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+3Sy06DQBQGYNY8xUlcqIsCYwusXKgbTRrb1HbdAHMsk1AgzFTTt3cK9ZIm2k2J ++Mf7fZobMhZP5j5duVCGXXL74Tl8CKw7DdrQOx3YuwisholjEkXACOxOBQ2FvFX2x0SZpiJymqsxP +++46t/1HeZ/6GtVlm1XqdlNLT+en+cSz/4Wj4kX8Uxjb/UTS0+QenK+F7/zz/TFIbfMrSdc/odtcN ++NLOPMt2avCrpVZm8/SbhhZEX0IXtkDoxKi24WzS50pRVktNE87kmyTWXkstMsb50Z4un+WK6nE8m ++47v7m4fH6/01WdKsKmqbjwaDhgu2p3cVzDalvZLJprJiQ7va6FkV7L6X6Xcr/v6M39ji6q7YsUrb ++XV0rrxOTe/XW/e0nBgAAAAAAAAAAAAAAAAAAAADozRuSDwq1ACgAAA== +diff --git 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-000238/tests/test.sh b/tasks/format-code-task-000238/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f2491742d4ca24567b8325002695d6074602f0b5 --- /dev/null +++ b/tasks/format-code-task-000238/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +Lib/test/test_math.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-000238/tests/test_command.sh b/tasks/format-code-task-000238/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000238/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000252/environment/Dockerfile b/tasks/format-code-task-000252/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..27a33c74fee31222eff05af65a30081aa4a0e902 --- /dev/null +++ b/tasks/format-code-task-000252/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ce33bd86ee8b7b54580e5a62eda12d0cc33fd119224824956484d5b0cb5efe55 diff --git a/tasks/format-code-task-000252/environment/setup/files/blocklist b/tasks/format-code-task-000252/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000252/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000252/environment/setup/setup.sh b/tasks/format-code-task-000252/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000252/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000252/tests/test.patch b/tasks/format-code-task-000252/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f24425bb8a4032e697802ea21023079e871c86f6 --- /dev/null +++ b/tasks/format-code-task-000252/tests/test.patch @@ -0,0 +1,54 @@ +diff --git a/fe/fe-core/src/test/java/com/starrocks/alter/AlterTest.java b/fe/fe-core/src/test/java/com/starrocks/alter/AlterTest.java +index 0747a11ee1047..24088c23ecdd2 100644 +--- a/fe/fe-core/src/test/java/com/starrocks/alter/AlterTest.java ++++ b/fe/fe-core/src/test/java/com/starrocks/alter/AlterTest.java +@@ -1881,6 +1881,26 @@ public void testAddMultiItemListPartition() throws Exception { + GlobalStateMgr.getCurrentState().dropTable(dropTableStmt); + } + ++ @Test(expected = DdlException.class) ++ public void testModifyPartitionBucket() throws Exception { ++ ConnectContext ctx = starRocksAssert.getCtx(); ++ String createSQL = "CREATE TABLE modify_bucket (\n" + ++ " chuangyi varchar(65533) NULL COMMENT \"创意\",\n" + ++ " guanggao varchar(65533) NULL COMMENT \"广告\"\n" + ++ ") ENGINE=OLAP\n" + ++ "DUPLICATE KEY(chuangyi, guanggao)\n" + ++ "COMMENT \"OLAP\"\n" + ++ "DISTRIBUTED BY HASH(chuangyi, guanggao) BUCKETS 3\n" + ++ "PROPERTIES (\n" + ++ "\"replication_num\" = \"1\"\n" + ++ ");"; ++ CreateTableStmt createTableStmt = (CreateTableStmt) UtFrameUtils.parseStmtWithNewParser(createSQL, ctx); ++ GlobalStateMgr.getCurrentState().createTable(createTableStmt); ++ String stmt = "alter table modify_bucket set (\"dynamic_partition.buckets\" = \"10\");\n"; ++ AlterTableStmt alterTableStmt = (AlterTableStmt) UtFrameUtils.parseStmtWithNewParser(stmt, starRocksAssert.getCtx()); ++ GlobalStateMgr.getCurrentState().alterTable(alterTableStmt); ++ } ++ + @Test + public void testAddSingleItemListPartition() throws Exception { + ConnectContext ctx = starRocksAssert.getCtx(); +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+3STUvDMBgH8J77KQKKt76uLyJMqEyYwnSH4XWkTYrZ0mak6dBvbzudDkF3cEPE ++/+/QNM3TJ6H/unkrJJvzeu1Zx+J30jjejJ3P4+Y+iEM/TKKB7yeWHwRxmlokPtqJdrSNoZoQSytl ++vqvbt/5HuR/5G96YeaGqitbMbR4Pt8e+/AdpuM0/TJKwyz9Kwsgi/uGO8LV/nn/ByCb4nDObP62U ++NuQ2e8jm4/vJ9dBrG+1JkXuLddVVVa0WtXPuLNjSoRVLou0b02w2fitWBZVeLuqL0/c2r9O+xt7Z ++zSu5Xa1r0k+Js5Kk5E6hNCfOqH807H5Et49Gq2LZuFQart2sv8661ZO+ZKKYKJ+nVBthhKqv2mLJ ++u1ajkgp5U96pvrAZllQ2XVNaEWfKeElbaUh4eRbYv/3lAQAAAAAAAAAAAAAAAAAAAAB+7gU5gc/P ++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-000252/tests/test.sh b/tasks/format-code-task-000252/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..be79ad2cafbab74949b45530a79f11ecf335c947 --- /dev/null +++ b/tasks/format-code-task-000252/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' +fe/fe-core/src/test/java/com/starrocks/alter/AlterTest.java +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-000252/tests/test_command.sh b/tasks/format-code-task-000252/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000252/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000255/environment/Dockerfile b/tasks/format-code-task-000255/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..27481ebcaced93c3a980f7963ad97751f3d5ae98 --- /dev/null +++ b/tasks/format-code-task-000255/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:76cb41e489206f4d1435b03be5128198b4c118df7771df189b65b9b3ff7d8889 diff --git a/tasks/format-code-task-000255/environment/setup/files/blocklist b/tasks/format-code-task-000255/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000255/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000255/environment/setup/setup.sh b/tasks/format-code-task-000255/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000255/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000255/tests/test.patch b/tasks/format-code-task-000255/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f665a951570896895d355afe2a673022a5bb4e15 --- /dev/null +++ b/tasks/format-code-task-000255/tests/test.patch @@ -0,0 +1,53 @@ +diff --git a/theano/tensor/tests/test_opt.py b/theano/tensor/tests/test_opt.py +index 7fec0620ff6..dca0edf10ca 100644 +--- a/theano/tensor/tests/test_opt.py ++++ b/theano/tensor/tests/test_opt.py +@@ -5013,6 +5013,26 @@ def test_local_div_to_inv(): + assert numpy.allclose(out_val, 0.5) + + ++def test_local_useless_split(): ++ x = tensor.matrix('x') ++ splits = tensor.ivector('splits') ++ opt = tensor.split(x, splits, n_splits=1) ++ nonopt = tensor.split(x, splits, n_splits=3) ++ ++ mode = compile.get_default_mode().including("local_useless_split") ++ f_opt = theano.function([x, splits], opt, mode=mode) ++ f_nonopt = theano.function([x, splits], nonopt, mode=mode) ++ ++ f_opt(numpy.random.rand(4,4).astype(config.floatX), [4]) ++ f_nonopt(numpy.random.rand(4,4).astype(config.floatX), [1,2,1]) ++ graph_opt = f_opt.maker.fgraph.toposort() ++ graph_nonopt = f_nonopt.maker.fgraph.toposort() ++ ++ assert isinstance(graph_opt[-1].op, DeepCopyOp) ++ assert len(graph_nonopt)==1 ++ assert isinstance(graph_nonopt[0].op, tensor.Split) ++ ++ + def test_local_flatten_lift(): + for i in range(1, 4): + op = tensor.Flatten(i) +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+3ST2uDMBgGcM9+iswVukHrn05bKHjooVsP2zpYD7tJ1BQD0YiJ0u7TT+1ho7D1 ++0jLGnt/ljSbEB9/Xjmsu0ogVjWNcituaBUFfW8e1X3vBxJ3MPNedTgzX84KZb5DgYom+qJWmFSFG ++JaX+6dyp/T/K/uy/ZkpHicxzWqS2ys73jVP9v/P9o/77U88ziHu+CN/75/2/vnJiXjgxVZmZpKQf ++gpilJtuVstLkZbFZhdZgtX5aOna578akPT4fdO8tkzVUEGtw028QXnBNxreWuVktF8/r6P5x8fAa ++DlPW8ISFSVmPtkJS/Rb2ZeqPZKl5zt9ZFW7pYfRKLtiQlHudyYKM827V5iE6Y7SQbbZCyaqPqA7T ++2t7QpprP+wchEyqiWjHBlIpUKbo4u0aZv/2PAQAAAAAAAAAAAAAAAAAAAAAu5QMRewf3ACgAAA== +diff --git 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-000255/tests/test.sh b/tasks/format-code-task-000255/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f1fbd8b83442bbea9135a87f6079797aaf8a1c08 --- /dev/null +++ b/tasks/format-code-task-000255/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_opt.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-000255/tests/test_command.sh b/tasks/format-code-task-000255/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000255/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000263/environment/Dockerfile b/tasks/format-code-task-000263/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5998ba5d253543cb2017f2fc497e8eb1d8dcf42b --- /dev/null +++ b/tasks/format-code-task-000263/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1499e3c15286c62724381501f585381f649b72552a560688cabd833f67e77483 diff --git a/tasks/format-code-task-000263/environment/setup/files/blocklist b/tasks/format-code-task-000263/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000263/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000263/environment/setup/setup.sh b/tasks/format-code-task-000263/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000263/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000263/tests/test.patch b/tasks/format-code-task-000263/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ae2b6c6cc312098697adc5f2e891939953316ee --- /dev/null +++ b/tasks/format-code-task-000263/tests/test.patch @@ -0,0 +1,193 @@ +diff --git a/tests/unit/test_expression_literals_ternary.py b/tests/unit/test_expression_literals_ternary.py +new file mode 100644 +index 000000000..006f1f93d +--- /dev/null ++++ b/tests/unit/test_expression_literals_ternary.py +@@ -0,0 +1,160 @@ ++ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++from tracecat.templates.expressions import TemplateExpression ++from tracecat.types.exceptions import TracecatExpressionError ++ ++ ++def _result(expr, operand=None): ++ return TemplateExpression(expr, operand=operand).result() ++ ++ ++ ++ ++ ++ ++ ++def test_integer_literal(): ++ out = _result("${{ 42 }}") ++ assert out == 42 ++ assert type(out) is int ++ ++ ++def test_negative_integer_literal(): ++ out = _result("${{ -5 }}") ++ assert out == -5 ++ assert type(out) is int ++ ++ ++def test_float_literal(): ++ out = _result("${{ 3.14 }}") ++ assert out == 3.14 ++ assert type(out) is float ++ ++ ++def test_double_quoted_string_literal(): ++ out = _result('${{ "hello world" }}') ++ assert out == "hello world" ++ assert type(out) is str ++ ++ ++def test_single_quoted_string_literal(): ++ out = _result("${{ 'hi' }}") ++ assert out == "hi" ++ assert type(out) is str ++ ++ ++def test_true_literal(): ++ out = _result("${{ True }}") ++ assert out is True ++ ++ ++def test_false_literal(): ++ out = _result("${{ False }}") ++ assert out is False ++ ++ ++def test_literal_typecast_still_applies(): ++ out = _result("${{ 42 -> str }}") ++ assert out == "42" ++ assert type(out) is str ++ ++ ++ ++ ++ ++ ++ ++def test_integer_literal_function_args(): ++ out = _result("${{ FNS.add(1, 2) }}") ++ assert out == 3 ++ ++ ++def test_float_literal_function_args(): ++ out = _result("${{ FNS.add(1, 2.5) }}") ++ assert out == 3.5 ++ ++ ++def test_comparison_literal_function_args(): ++ assert _result("${{ FNS.greater_than(5, 2) }}") is True ++ assert _result("${{ FNS.greater_than(2, 5) }}") is False ++ ++ ++ ++ ++ ++ ++ ++def test_ternary_literal_condition_true(): ++ assert _result("${{ 'a' if 1 else 'b' }}") == "a" ++ ++ ++def test_ternary_literal_condition_false(): ++ assert _result("${{ 'a' if 0 else 'b' }}") == "b" ++ ++ ++def test_ternary_boolean_condition(): ++ assert _result("${{ 'yes' if True else 'no' }}") == "yes" ++ assert _result("${{ 'yes' if False else 'no' }}") == "no" ++ ++ ++def test_ternary_context_condition(): ++ operand = {"INPUTS": {"flag": True, "x": 20}} ++ assert _result("${{ 'yes' if INPUTS.flag else 'no' }}", operand) == "yes" ++ operand = {"INPUTS": {"flag": False, "x": 20}} ++ assert _result("${{ 'yes' if INPUTS.flag else 'no' }}", operand) == "no" ++ ++ ++def test_ternary_function_condition(): ++ operand = {"INPUTS": {"x": 20}} ++ assert _result( ++ "${{ 'big' if FNS.greater_than(INPUTS.x, 10) else 'small' }}", operand ++ ) == "big" ++ operand = {"INPUTS": {"x": 5}} ++ assert _result( ++ "${{ 'big' if FNS.greater_than(INPUTS.x, 10) else 'small' }}", operand ++ ) == "small" ++ ++ ++def test_ternary_context_branches(): ++ operand = {"INPUTS": {"flag": True, "a": 100, "b": 200}} ++ assert _result("${{ INPUTS.a if INPUTS.flag else INPUTS.b }}", operand) == 100 ++ operand = {"INPUTS": {"flag": False, "a": 100, "b": 200}} ++ assert _result("${{ INPUTS.a if INPUTS.flag else INPUTS.b }}", operand) == 200 ++ ++ ++ ++ ++ ++ ++ ++def test_ternary_short_circuits_untaken_else_branch(): ++ ++ ++ operand = {"INPUTS": {"flag": True, "x": 42}, "ACTIONS": {}} ++ assert ( ++ _result("${{ INPUTS.x if INPUTS.flag else ACTIONS.missing.result }}", operand) ++ == 42 ++ ) ++ ++ ++def test_ternary_short_circuits_untaken_true_branch(): ++ operand = {"INPUTS": {"flag": False, "x": 42}, "ACTIONS": {}} ++ assert ( ++ _result("${{ ACTIONS.missing.result if INPUTS.flag else INPUTS.x }}", operand) ++ == 42 ++ ) ++ ++ ++def test_missing_path_still_raises_when_selected(): ++ ++ ++ operand = {"INPUTS": {"flag": True}, "ACTIONS": {}} ++ with pytest.raises(TracecatExpressionError): ++ _result("${{ ACTIONS.missing.result if INPUTS.flag else 0 }}", operand) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++PYTEST="/opt/tracecat-venv/bin/python -m pytest" ++ ++ ++$PYTEST tests/unit/test_template_expressions.py \ ++ -k "not evaluate_templated_secret" -p no:cacheprovider ++ ++ ++$PYTEST tests/unit/test_expression_literals_ternary.py -p no:cacheprovider diff --git a/tasks/format-code-task-000263/tests/test.sh b/tasks/format-code-task-000263/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5c86461156385ee54cfec65e008665bd04bba69b --- /dev/null +++ b/tasks/format-code-task-000263/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/test_expression_literals_ternary.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-000263/tests/test_command.sh b/tasks/format-code-task-000263/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000263/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000264/environment/Dockerfile b/tasks/format-code-task-000264/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ff7b791c07d11618bc6f85acbf16022003abeb50 --- /dev/null +++ b/tasks/format-code-task-000264/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b675e06738c06522f23ff4c8db7244bc73a3cc8aac2f4c864f5532d3a2bbe500 diff --git a/tasks/format-code-task-000264/environment/setup/files/blocklist b/tasks/format-code-task-000264/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000264/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000264/environment/setup/setup.sh b/tasks/format-code-task-000264/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000264/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000264/tests/test.patch b/tasks/format-code-task-000264/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..35a0e667978e242349f346e1daebc260346fb99b --- /dev/null +++ b/tasks/format-code-task-000264/tests/test.patch @@ -0,0 +1,236 @@ +diff --git a/tests/unit/test_rf_graph_trigger.py b/tests/unit/test_rf_graph_trigger.py +new file mode 100644 +index 000000000..e046dc935 +--- /dev/null ++++ b/tests/unit/test_rf_graph_trigger.py +@@ -0,0 +1,204 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++from tracecat.dsl.common import ActionStatement ++from tracecat.dsl.graph import RFGraph ++from tracecat.types.exceptions import TracecatValidationError ++ ++TRIGGER_ID = "trigger-wf" ++ ++ ++def udf(node_id: str, title: str, args=None): ++ return { ++ "id": node_id, ++ "type": "udf", ++ "data": { ++ "type": "core.action", ++ "title": title, ++ "args": args or {}, ++ }, ++ } ++ ++ ++def trigger(node_id: str = TRIGGER_ID): ++ return {"id": node_id, "type": "trigger", "data": {"title": "Trigger"}} ++ ++ ++def trigger_edge(target: str, source: str = TRIGGER_ID): ++ return {"source": source, "target": target, "label": "\u26a1 Trigger"} ++ ++ ++def edge(source: str, target: str): ++ return {"id": f"{source}_{target}", "source": source, "target": target} ++ ++ ++def simple_sequence(): ++ ++ return { ++ "nodes": [ ++ trigger(), ++ udf("a", "Action A", {"test": 1}), ++ udf("b", "Action B", {"test": 2}), ++ udf("c", "Action C", {"test": 3}), ++ ], ++ "edges": [ ++ trigger_edge("a"), ++ edge("a", "b"), ++ edge("b", "c"), ++ ], ++ } ++ ++ ++def kite(): ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ return { ++ "nodes": [ ++ trigger(), ++ udf("a", "Action A"), ++ udf("b", "Action B"), ++ udf("c", "Action C"), ++ udf("d", "Action D"), ++ udf("e", "Action E"), ++ udf("f", "Action F"), ++ udf("g", "Action G"), ++ ], ++ "edges": [ ++ trigger_edge("a"), ++ edge("a", "b"), ++ edge("b", "c"), ++ edge("c", "f"), ++ edge("a", "d"), ++ edge("d", "e"), ++ edge("e", "f"), ++ edge("f", "g"), ++ ], ++ } ++ ++ ++def test_action_nodes_exclude_trigger_and_preserve_order(): ++ graph = RFGraph.from_dict(simple_sequence()) ++ assert [n.id for n in graph.action_nodes()] == ["a", "b", "c"] ++ assert [n.ref for n in graph.action_nodes()] == [ ++ "action_a", ++ "action_b", ++ "action_c", ++ ] ++ ++ ++def test_trigger_accessor(): ++ graph = RFGraph.from_dict(simple_sequence()) ++ assert graph.trigger.id == TRIGGER_ID ++ assert graph.trigger.type == "trigger" ++ ++ ++def test_entrypoint_is_the_trigger_target(): ++ graph = RFGraph.from_dict(simple_sequence()) ++ assert graph.entrypoint.id == "a" ++ assert graph.entrypoint.ref == "action_a" ++ ++ ++def test_action_edges_exclude_the_trigger_edge(): ++ graph = RFGraph.from_dict(simple_sequence()) ++ pairs = {(e.source, e.target) for e in graph.action_edges()} ++ assert pairs == {("a", "b"), ("b", "c")} ++ assert all(TRIGGER_ID not in (e.source, e.target) for e in graph.action_edges()) ++ ++ ++def _assert_valid_topological_order(graph: RFGraph, order: list[str]): ++ action_ids = {n.id for n in graph.action_nodes()} ++ assert set(order) == action_ids ++ assert len(order) == len(action_ids) ++ position = {node_id: i for i, node_id in enumerate(order)} ++ for e in graph.action_edges(): ++ assert position[e.source] < position[e.target] ++ ++ ++def test_topological_order_simple_sequence(): ++ graph = RFGraph.from_dict(simple_sequence()) ++ assert graph.topsort_order() == ["a", "b", "c"] ++ ++ ++def test_topological_order_kite_is_valid(): ++ graph = RFGraph.from_dict(kite()) ++ _assert_valid_topological_order(graph, graph.topsort_order()) ++ ++ ++def test_action_statements_simple_sequence(): ++ graph = RFGraph.from_dict(simple_sequence()) ++ statements = graph.action_statements() ++ assert statements == [ ++ ActionStatement(ref="action_a", action="core.action", args={"test": 1}), ++ ActionStatement( ++ ref="action_b", ++ action="core.action", ++ args={"test": 2}, ++ depends_on=["action_a"], ++ ), ++ ActionStatement( ++ ref="action_c", ++ action="core.action", ++ args={"test": 3}, ++ depends_on=["action_b"], ++ ), ++ ] ++ ++ ++def test_action_statements_dependencies_are_sorted_and_complete(): ++ graph = RFGraph.from_dict(kite()) ++ by_ref = {s.ref: s for s in graph.action_statements()} ++ ++ ++ assert by_ref["action_a"].depends_on == [] ++ assert by_ref["action_b"].depends_on == ["action_a"] ++ assert by_ref["action_d"].depends_on == ["action_a"] ++ ++ assert by_ref["action_f"].depends_on == ["action_c", "action_e"] ++ assert by_ref["action_g"].depends_on == ["action_f"] ++ ++ ++def test_missing_trigger_node_raises(): ++ obj = { ++ "nodes": [udf("a", "Action A"), udf("b", "Action B")], ++ "edges": [edge("a", "b")], ++ } ++ with pytest.raises(TracecatValidationError): ++ RFGraph.from_dict(obj) ++ ++ ++def test_multiple_trigger_nodes_raise(): ++ obj = simple_sequence() ++ obj["nodes"].append(trigger("trigger-extra")) ++ with pytest.raises(TracecatValidationError): ++ RFGraph.from_dict(obj) ++ ++ ++def test_no_action_nodes_raises(): ++ obj = {"nodes": [trigger()], "edges": []} ++ with pytest.raises(TracecatValidationError): ++ RFGraph.from_dict(obj) ++ ++ ++def test_trigger_pointing_to_multiple_actions_raises(): ++ obj = { ++ "nodes": [trigger(), udf("a", "Action A"), udf("b", "Action B")], ++ "edges": [trigger_edge("a"), trigger_edge("b"), edge("a", "b")], ++ } ++ with pytest.raises(TracecatValidationError): ++ RFGraph.from_dict(obj) +diff --git 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 ++ ++ ++ ++ ++source /opt/tracecat-venv/bin/activate ++ ++ ++ ++python -m pytest tests/unit/test_expressions.py \ ++ --deselect tests/unit/test_expressions.py::test_evaluate_templated_secret \ ++ -q -p no:cacheprovider ++ ++ ++python -m pytest tests/unit/test_rf_graph_trigger.py -q -p no:cacheprovider diff --git a/tasks/format-code-task-000264/tests/test.sh b/tasks/format-code-task-000264/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dffb41fe99e24e6fb589954e5ae76c6eb2fcb1bb --- /dev/null +++ b/tasks/format-code-task-000264/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/test_rf_graph_trigger.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-000264/tests/test_command.sh b/tasks/format-code-task-000264/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000264/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000280/environment/setup/files/blocklist b/tasks/format-code-task-000280/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000280/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000280/environment/setup/setup.sh b/tasks/format-code-task-000280/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000280/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000290/environment/Dockerfile b/tasks/format-code-task-000290/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6ed2bf1ecbc46f96ebfc8ae96413d2cd12ea799f --- /dev/null +++ b/tasks/format-code-task-000290/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f4e3aa81697ef62650bf8361e6e1ba0f8cec20fc29eee2b2d6227e20a239ff29 diff --git a/tasks/format-code-task-000290/environment/setup/files/blocklist b/tasks/format-code-task-000290/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000290/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000290/environment/setup/setup.sh b/tasks/format-code-task-000290/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000290/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000290/tests/test.patch b/tasks/format-code-task-000290/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f313f4b0d553e7cfcb5dd25cde54558a81c945b1 --- /dev/null +++ b/tasks/format-code-task-000290/tests/test.patch @@ -0,0 +1,269 @@ +diff --git a/usercase-test-coderl/level_dispatch.test.js b/usercase-test-coderl/level_dispatch.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/level_dispatch.test.js +@@ -0,0 +1,235 @@ ++'use strict' ++ ++const assert = require('assert') ++const acho = require('/workspace/repo') ++ ++function createTransport () { ++ const entries = [] ++ const transport = line => entries.push(line) ++ transport.entries = entries ++ return transport ++} ++ ++function defaultMethodTypes (log) { ++ return { ++ debug: typeof log.debug, ++ info: typeof log.info, ++ warn: typeof log.warn, ++ error: typeof log.error, ++ fatal: typeof log.fatal ++ } ++} ++ ++function assertGeneratedLine (line, message) { ++ assert.strictEqual(typeof line, 'string') ++ assert.notStrictEqual(line.trim(), '') ++ assert.ok(line.includes(message), `expected ${JSON.stringify(line)} to include ${message}`) ++} ++ ++function assertGeneratedEntries (entries, expected) { ++ assert.strictEqual(entries.length, expected.length) ++ expected.forEach((message, index) => { ++ assertGeneratedLine(entries[index], message) ++ }) ++} ++ ++describe('usercase level-aware log method dispatch', function () { ++ it('creates default level methods that format, transport, and chain', function () { ++ ++ ++ ++ ++ const transport = createTransport() ++ const log = acho({ transport, color: false, upper: true }) ++ ++ assert.deepStrictEqual(defaultMethodTypes(log), { ++ debug: 'function', ++ info: 'function', ++ warn: 'function', ++ error: 'function', ++ fatal: 'function' ++ }) ++ assert.deepStrictEqual(transport.entries, []) ++ ++ const result = log.warn('disk %s', 'low') ++ ++ assert.strictEqual(result === log, true) ++ ++ assertGeneratedEntries(transport.entries, ['disk low']) ++ }) ++ ++ it('supports construction with new and keeps instances independent', function () { ++ ++ ++ ++ ++ const transportA = createTransport() ++ const transportB = createTransport() ++ const a = acho({ transport: transportA, color: false }) ++ const b = new acho({ transport: transportB, color: false, level: 'fatal' }) ++ ++ a.warn('a1') ++ b.error('b1') ++ b.fatal('b2') ++ ++ ++ assert.strictEqual(transportA.entries.length, 1) ++ assert.strictEqual(b.level, 'fatal') ++ ++ assertGeneratedEntries(transportA.entries, ['a1']) ++ assertGeneratedEntries(transportB.entries, ['b2']) ++ }) ++ ++ it('filters the constructor level thresholds with permitted outputs', function () { ++ ++ ++ ++ ++ const calls = ['debug', 'info', 'warn', 'error', 'fatal'] ++ ++ const fatalTransport = createTransport() ++ const fatalLog = acho({ transport: fatalTransport, color: false, level: 'fatal' }) ++ calls.forEach(method => fatalLog[method](`${method} message`)) ++ ++ assertGeneratedEntries(fatalTransport.entries, ['fatal message']) ++ ++ const errorTransport = createTransport() ++ const errorLog = acho({ transport: errorTransport, color: false, level: 'error' }) ++ calls.forEach(method => errorLog[method](`${method} message`)) ++ ++ assertGeneratedEntries(errorTransport.entries, [ ++ 'error message', ++ 'fatal message' ++ ]) ++ ++ const mutedTransport = createTransport() ++ const mutedLog = acho({ transport: mutedTransport, color: false, level: 'muted' }) ++ calls.forEach(method => mutedLog[method](`${method} message`)) ++ assert.deepStrictEqual(mutedTransport.entries, []) ++ ++ const allTransport = createTransport() ++ const allLog = acho({ transport: allTransport, color: false, level: 'all' }) ++ calls.forEach(method => allLog[method](`${method} message`)) ++ ++ assertGeneratedEntries(allTransport.entries, [ ++ 'debug message', ++ 'info message', ++ 'warn message', ++ 'error message', ++ 'fatal message' ++ ]) ++ }) ++ ++ it('uses runtime log.level state for later method calls', function () { ++ ++ ++ ++ ++ const transport = createTransport() ++ const log = acho({ transport, color: false, level: 'muted' }) ++ ++ assert.strictEqual(log.level, 'muted') ++ log.info('first') ++ assert.deepStrictEqual(transport.entries, []) ++ ++ log.level = 'all' ++ assert.strictEqual(log.level, 'all') ++ log.debug('second') ++ ++ assertGeneratedEntries(transport.entries, ['second']) ++ ++ log.level = 'error' ++ assert.strictEqual(log.level, 'error') ++ log.warn('third') ++ ++ assertGeneratedEntries(transport.entries, ['second']) ++ log.error('fourth') ++ ++ assertGeneratedEntries(transport.entries, [ ++ 'second', ++ 'fourth' ++ ]) ++ }) ++ ++ it('generates custom type methods and orders them by configured severity', function () { ++ ++ ++ ++ ++ const transport = createTransport() ++ const log = acho({ ++ transport, ++ color: false, ++ level: 'notice', ++ types: { ++ verbose: { level: 2, color: ['white'] }, ++ notice: { level: 1, color: ['white'], separator: '|' }, ++ panic: { level: 0, color: ['white'] } ++ } ++ }) ++ ++ assert.deepStrictEqual( ++ { ++ verbose: typeof log.verbose, ++ notice: typeof log.notice, ++ panic: typeof log.panic ++ }, ++ { ++ verbose: 'function', ++ notice: 'function', ++ panic: 'function' ++ } ++ ) ++ ++ log.verbose('chatty') ++ log.notice('heads up') ++ log.panic('wake up') ++ ++ ++ assertGeneratedEntries(transport.entries, [ ++ 'heads up', ++ 'wake up' ++ ]) ++ assert.strictEqual(log.notice('again') === log, true) ++ ++ assertGeneratedEntries(transport.entries, [ ++ 'heads up', ++ 'wake up', ++ 'again' ++ ]) ++ }) ++ ++ it('creates callable methods for custom configured types', function () { ++ ++ ++ ++ ++ const transport = createTransport() ++ const log = acho({ ++ transport, ++ color: false, ++ types: { ++ notice: { level: 0, color: ['white'] } ++ } ++ }) ++ ++ ++ assert.strictEqual(typeof log.notice, 'function') ++ assert.strictEqual(log.notice('configured') === log, true) ++ assertGeneratedEntries(transport.entries, ['configured']) ++ }) ++ ++ it('sends one generated line per permitted repeated logger call', function () { ++ ++ ++ ++ ++ for (let i = 0; i < 150; i++) { ++ const transport = createTransport() ++ const log = acho({ transport, color: false, level: 'all' }) ++ log.warn('cycle %d', i) ++ ++ assertGeneratedEntries(transport.entries, [`cycle ${i}`]) ++ } ++ }) ++}) +diff --git 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 ++ ++ ++ ++ ++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 ++ ++for dep in mocha should chalk fmt-obj pretty-ms sliced; do ++ if [ ! -d "node_modules/$dep" ]; then ++ echo "Missing preinstalled npm dependency: $dep" >&2 ++ exit 127 ++ fi ++done ++ ++exec node /workspace/repo/node_modules/mocha/bin/mocha \ ++ /workspace/repo/usercase-test-coderl/level_dispatch.test.js diff --git a/tasks/format-code-task-000290/tests/test.sh b/tasks/format-code-task-000290/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..30afd6ce2a878cab9ac33c9d5acb84d91323a203 --- /dev/null +++ b/tasks/format-code-task-000290/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/level_dispatch.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-000290/tests/test_command.sh b/tasks/format-code-task-000290/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000290/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-000297/environment/Dockerfile b/tasks/format-code-task-000297/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e5eb662adf8a72bffa726a2375d6a21d99fe9cfc --- /dev/null +++ b/tasks/format-code-task-000297/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9132e6b51fd0542b2dcae22f613efdcfcb37b1bac692d49f4021990d038da2a1 diff --git a/tasks/format-code-task-000297/environment/setup/files/blocklist b/tasks/format-code-task-000297/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000297/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000297/environment/setup/setup.sh b/tasks/format-code-task-000297/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000297/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000297/tests/test.patch b/tasks/format-code-task-000297/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..13fddaf10fb1f207cd747273c25657c8193dc3cc --- /dev/null +++ b/tasks/format-code-task-000297/tests/test.patch @@ -0,0 +1,233 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..fa03820 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/fixers/test_settings_storages.py -v -k \"only_default_file_storage_injects_staticfiles_default or only_staticfiles_storage_injects_default_file_default or both_set_no_injection or only_default_file_storage_with_non_settings_star_injects_staticfiles_default or only_staticfiles_storage_with_non_settings_star_injects_default_default or only_default_file_storage_with_settings_star_skips_injection or only_staticfiles_storage_with_settings_star_skips_injection or only_staticfiles_storage_extended_settings_star_skips_injection\""] ++} +diff --git a/tests/fixers/test_settings_storages.py b/tests/fixers/test_settings_storages.py +index e37842a..abaf12e 100644 +--- a/tests/fixers/test_settings_storages.py ++++ b/tests/fixers/test_settings_storages.py +@@ -107,6 +107,9 @@ def test_one(): + "default": { + "BACKEND": "example.backend", + }, ++ "staticfiles": { ++ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", ++ }, + } + """, + settings, +@@ -166,6 +169,9 @@ def test_retains_quoting(): + "default": { + "BACKEND": 'example.backend', + }, ++ "staticfiles": { ++ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", ++ }, + } + """, + settings, +@@ -185,6 +191,9 @@ def test_star_import_not_settings(): + "default": { + "BACKEND": "example.backend", + }, ++ "staticfiles": { ++ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", ++ }, + } + """, + settings, +@@ -230,3 +239,176 @@ def test_star_import_extended_module_path(): + settings, + filename="settings.py", + ) ++ ++ ++ ++ ++ ++ ++ ++def test_only_default_file_storage_injects_staticfiles_default(): ++ check_transformed( ++ """\ ++ DEFAULT_FILE_STORAGE = "my_project.storage.MyDefaultStorage" ++ """, ++ """\ ++ STORAGES = { ++ "default": { ++ "BACKEND": "my_project.storage.MyDefaultStorage", ++ }, ++ "staticfiles": { ++ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_only_staticfiles_storage_injects_default_file_default(): ++ check_transformed( ++ """\ ++ STATICFILES_STORAGE = "my_project.storage.CustomManifestStaticFilesStorage" ++ """, ++ """\ ++ STORAGES = { ++ "default": { ++ "BACKEND": "django.core.files.storage.FileSystemStorage", ++ }, ++ "staticfiles": { ++ "BACKEND": "my_project.storage.CustomManifestStaticFilesStorage", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_both_set_no_injection(): ++ ++ check_transformed( ++ """\ ++ DEFAULT_FILE_STORAGE = "my_project.storage.MyDefault" ++ STATICFILES_STORAGE = "my_project.storage.MyStatic" ++ """, ++ """\ ++ STORAGES = { ++ "default": { ++ "BACKEND": "my_project.storage.MyDefault", ++ }, ++ "staticfiles": { ++ "BACKEND": "my_project.storage.MyStatic", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_only_default_file_storage_with_non_settings_star_injects_staticfiles_default(): ++ check_transformed( ++ """\ ++ from example import * ++ DEFAULT_FILE_STORAGE = "my_project.storage.MyDefault" ++ """, ++ """\ ++ from example import * ++ STORAGES = { ++ "default": { ++ "BACKEND": "my_project.storage.MyDefault", ++ }, ++ "staticfiles": { ++ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_only_staticfiles_storage_with_non_settings_star_injects_default_default(): ++ check_transformed( ++ """\ ++ from example import * ++ STATICFILES_STORAGE = "my_project.storage.MyStatic" ++ """, ++ """\ ++ from example import * ++ STORAGES = { ++ "default": { ++ "BACKEND": "django.core.files.storage.FileSystemStorage", ++ }, ++ "staticfiles": { ++ "BACKEND": "my_project.storage.MyStatic", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_only_default_file_storage_with_settings_star_skips_injection(): ++ ++ ++ check_transformed( ++ """\ ++ from base_settings import * ++ DEFAULT_FILE_STORAGE = "my_project.storage.MyDefault" ++ """, ++ """\ ++ from base_settings import * ++ STORAGES = { ++ **STORAGES, ++ "default": { ++ "BACKEND": "my_project.storage.MyDefault", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_only_staticfiles_storage_with_settings_star_skips_injection(): ++ check_transformed( ++ """\ ++ from base_settings import * ++ STATICFILES_STORAGE = "my_project.storage.MyStatic" ++ """, ++ """\ ++ from base_settings import * ++ STORAGES = { ++ **STORAGES, ++ "staticfiles": { ++ "BACKEND": "my_project.storage.MyStatic", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_only_staticfiles_storage_extended_settings_star_skips_injection(): ++ check_transformed( ++ """\ ++ from example.settings.base import * ++ STATICFILES_STORAGE = "my_project.storage.MyStatic" ++ """, ++ """\ ++ from example.settings.base import * ++ STORAGES = { ++ **STORAGES, ++ "staticfiles": { ++ "BACKEND": "my_project.storage.MyStatic", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest tests/fixers/test_settings_storages.py -v -k "only_default_file_storage_injects_staticfiles_default or only_staticfiles_storage_injects_default_file_default or both_set_no_injection or only_default_file_storage_with_non_settings_star_injects_staticfiles_default or only_staticfiles_storage_with_non_settings_star_injects_default_default or only_default_file_storage_with_settings_star_skips_injection or only_staticfiles_storage_with_settings_star_skips_injection or only_staticfiles_storage_extended_settings_star_skips_injection" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000297/tests/test.sh b/tasks/format-code-task-000297/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..90cf0572474d0f7d5218c1a2a8e6ed523cb9e855 --- /dev/null +++ b/tasks/format-code-task-000297/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/fixers/test_settings_storages.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-000297/tests/test_command.sh b/tasks/format-code-task-000297/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000297/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000403/environment/Dockerfile b/tasks/format-code-task-000403/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..13f261ff0abf428c36bb40717e71d46ca1f3c785 --- /dev/null +++ b/tasks/format-code-task-000403/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8e29de2a577e753d1e24442fecd48e0735b0852c837ef149860bcee31714b5e2 diff --git a/tasks/format-code-task-000403/environment/setup/files/blocklist b/tasks/format-code-task-000403/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000403/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000403/environment/setup/setup.sh b/tasks/format-code-task-000403/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000403/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000403/tests/test.patch b/tasks/format-code-task-000403/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1572020bdd3c6c55e20f0212d3348c0eed92b8a8 --- /dev/null +++ b/tasks/format-code-task-000403/tests/test.patch @@ -0,0 +1,159 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..a691d30a48 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/www/test_views.py::TestDagRunModelView::test_clear_dag_runs_resets_task_instances tests/www/test_views.py::TestDagRunModelView::test_clear_dag_runs_only_clears_selected tests/www/test_views.py::TestDagRunModelView::test_clear_dag_runs_multiple_selected -v"] ++} +diff --git a/tests/www/test_views.py b/tests/www/test_views.py +index 761208efed..05dddec237 100644 +--- a/tests/www/test_views.py ++++ b/tests/www/test_views.py +@@ -2845,6 +2845,132 @@ class TestDagRunModelView(TestBase): + resp = self.client.get('/dagrun/list', follow_redirects=True) + self.check_content_in_response("{"include": "me"}", resp) + ++ def _create_dagrun_with_tis(self, run_id, execution_date, ti_state=State.SUCCESS): ++ """Helper: create a DagRun + TaskInstances on example_bash_operator.""" ++ dag = self.app.dag_bag.get_dag("example_bash_operator") ++ dr = dag.create_dagrun( ++ run_type=DagRunType.MANUAL, ++ run_id=run_id, ++ execution_date=execution_date, ++ start_date=execution_date, ++ state=State.SUCCESS, ++ ) ++ for task in dag.tasks: ++ ti = TaskInstance(task=task, execution_date=execution_date) ++ ti.state = ti_state ++ self.session.merge(ti) ++ self.session.commit() ++ return dr ++ ++ def _ti_states(self, dag_id, execution_date): ++ return [ ++ ti.state for ti in self.session.query(TaskInstance).filter( ++ TaskInstance.dag_id == dag_id, ++ TaskInstance.execution_date == execution_date, ++ ).all() ++ ] ++ ++ def _cleanup_clear_action_db(self): ++ self.session.query(TaskInstance).filter( ++ TaskInstance.dag_id == 'example_bash_operator' ++ ).delete() ++ self.clear_table(models.DagRun) ++ self.session.commit() ++ ++ def test_clear_dag_runs_resets_task_instances(self): ++ """Submitting the 'clear' bulk action resets task instance states to None.""" ++ self._cleanup_clear_action_db() ++ try: ++ exec_date = timezone.datetime(2020, 1, 1) ++ dr = self._create_dagrun_with_tis( ++ 'test_clear_dr', exec_date, ti_state=State.SUCCESS, ++ ) ++ ti_count = len(self.app.dag_bag.get_dag("example_bash_operator").tasks) ++ self.assertGreater(ti_count, 0) ++ ++ resp = self.client.post( ++ '/dagrun/action_post', ++ data={'action': 'clear', 'rowid': [str(dr.id)]}, ++ follow_redirects=True, ++ ) ++ self.assertEqual(resp.status_code, 200) ++ ++ states = self._ti_states('example_bash_operator', exec_date) ++ self.assertEqual(len(states), ti_count) ++ for s in states: ++ self.assertIsNone(s) ++ finally: ++ self._cleanup_clear_action_db() ++ ++ def test_clear_dag_runs_only_clears_selected(self): ++ """Clear only affects DagRuns whose row IDs are submitted, not unselected ones.""" ++ self._cleanup_clear_action_db() ++ try: ++ exec_date_1 = timezone.datetime(2020, 1, 1) ++ exec_date_2 = timezone.datetime(2020, 1, 2) ++ exec_date_3 = timezone.datetime(2020, 1, 3) ++ dr1 = self._create_dagrun_with_tis( ++ 'test_clear_only_1', exec_date_1, ti_state=State.SUCCESS, ++ ) ++ self._create_dagrun_with_tis( ++ 'test_clear_only_2', exec_date_2, ti_state=State.SUCCESS, ++ ) ++ dr3 = self._create_dagrun_with_tis( ++ 'test_clear_only_3', exec_date_3, ti_state=State.SUCCESS, ++ ) ++ ++ ++ resp = self.client.post( ++ '/dagrun/action_post', ++ data={'action': 'clear', 'rowid': [str(dr1.id), str(dr3.id)]}, ++ follow_redirects=True, ++ ) ++ self.assertEqual(resp.status_code, 200) ++ ++ states_1 = self._ti_states('example_bash_operator', exec_date_1) ++ states_2 = self._ti_states('example_bash_operator', exec_date_2) ++ states_3 = self._ti_states('example_bash_operator', exec_date_3) ++ ++ self.assertTrue(states_1) ++ self.assertTrue(states_2) ++ self.assertTrue(states_3) ++ for s in states_1: ++ self.assertIsNone(s) ++ for s in states_3: ++ self.assertIsNone(s) ++ ++ for s in states_2: ++ self.assertEqual(s, State.SUCCESS) ++ finally: ++ self._cleanup_clear_action_db() ++ ++ def test_clear_dag_runs_multiple_selected(self): ++ """Bulk-clearing several selected DagRuns clears every one of them.""" ++ self._cleanup_clear_action_db() ++ try: ++ exec_date_1 = timezone.datetime(2021, 6, 1) ++ exec_date_2 = timezone.datetime(2021, 6, 2) ++ dr1 = self._create_dagrun_with_tis( ++ 'test_clear_multi_1', exec_date_1, ti_state=State.SUCCESS, ++ ) ++ dr2 = self._create_dagrun_with_tis( ++ 'test_clear_multi_2', exec_date_2, ti_state=State.FAILED, ++ ) ++ ++ resp = self.client.post( ++ '/dagrun/action_post', ++ data={'action': 'clear', 'rowid': [str(dr1.id), str(dr2.id)]}, ++ follow_redirects=True, ++ ) ++ self.assertEqual(resp.status_code, 200) ++ ++ for s in self._ti_states('example_bash_operator', exec_date_1): ++ self.assertIsNone(s) ++ for s in self._ti_states('example_bash_operator', exec_date_2): ++ self.assertIsNone(s) ++ finally: ++ self._cleanup_clear_action_db() ++ + + class TestDecorators(TestBase): + EXAMPLE_DAG_DEFAULT_DATE = dates.days_ago(2) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/www/test_views.py::TestDagRunModelView::test_clear_dag_runs_resets_task_instances tests/www/test_views.py::TestDagRunModelView::test_clear_dag_runs_only_clears_selected tests/www/test_views.py::TestDagRunModelView::test_clear_dag_runs_multiple_selected -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000403/tests/test.sh b/tasks/format-code-task-000403/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f6d48af1954a02e7ddc6f11fba450af35559264 --- /dev/null +++ b/tasks/format-code-task-000403/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/www/test_views.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000403/tests/test_command.sh b/tasks/format-code-task-000403/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000403/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000404/environment/Dockerfile b/tasks/format-code-task-000404/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3a3fdb494b52d9fdb76812b70ce3f3b054fa7a9a --- /dev/null +++ b/tasks/format-code-task-000404/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6606374226ada796ea3413eef0b5d2d1f6d3779ad34431ec00f116beaa3140b6 diff --git a/tasks/format-code-task-000404/environment/setup/files/blocklist b/tasks/format-code-task-000404/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000404/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000404/environment/setup/setup.sh b/tasks/format-code-task-000404/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000404/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000404/tests/test.patch b/tasks/format-code-task-000404/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..47f3715003432b50734282730533cf19517c3da8 --- /dev/null +++ b/tasks/format-code-task-000404/tests/test.patch @@ -0,0 +1,36 @@ +diff --git a/tests/providers/oracle/hooks/test_oracle.py b/tests/providers/oracle/hooks/test_oracle.py +index 3eae248107fd1..9217fec881c16 100644 +--- a/tests/providers/oracle/hooks/test_oracle.py ++++ b/tests/providers/oracle/hooks/test_oracle.py +@@ -176,6 +176,10 @@ def test_get_conn_purity(self, mock_connect): + assert args == () + assert kwargs['purity'] == purity.get(pur) + ++ @mock.patch('airflow.providers.oracle.hooks.oracle.cx_Oracle.connect') ++ def test_set_current_schema(self, mock_connect): ++ assert self.db_hook.get_conn().current_schema == self.connection.schema ++ + + @unittest.skipIf(cx_Oracle is None, 'cx_Oracle package not present') + class TestOracleHook(unittest.TestCase): +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3ST2uDMBgGcM9+ioyda3xlmtMuYxcZjMF2lxgDSquRJIb1208tdGOw9dIyyp7f ++wfwnwedN6qnbNZUeAo8uJZ2JPF/b2fd27VOepZkQJKiIUqKCKGL5xV70xeS8tIxF1hj/275T61cq +++czfa+crZfpeDk3i2vPdcSr/LKNj/kVBc/53BYmIped7ws/+ef63N7zuBl5L18aqYWsR1LqJnZms ++0scxT8JSIstWqXwXpNexfh+N9ez1qXypyufyrXp8uKd43PvWDGzTs7k3H2bLx/HRmtA12jpurFQ7 ++zVtjtu5Qc4eZZNyzTYj/+ocAAAAAAAAAAAAAAAAAAAAAAFyRDz+rOW8AKAAA +diff --git 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-000404/tests/test.sh b/tasks/format-code-task-000404/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..26c5ef88340b0b8037a561d41c0bd0b6210f808c --- /dev/null +++ b/tasks/format-code-task-000404/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/oracle/hooks/test_oracle.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-000404/tests/test_command.sh b/tasks/format-code-task-000404/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000404/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000422/environment/Dockerfile b/tasks/format-code-task-000422/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..403cfc5fd3792c1c0b738a0f5b8c10157000ad08 --- /dev/null +++ b/tasks/format-code-task-000422/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b22bfd6a7e8459af869b7d2a2862b4dee55f26de4e2777f18fa492e358c7956c diff --git a/tasks/format-code-task-000422/environment/setup/files/blocklist b/tasks/format-code-task-000422/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000422/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000422/environment/setup/setup.sh b/tasks/format-code-task-000422/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000422/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000422/tests/test.patch b/tasks/format-code-task-000422/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..729981978096355b919088f922cda21e4b7962f8 --- /dev/null +++ b/tasks/format-code-task-000422/tests/test.patch @@ -0,0 +1,160 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..b3be8214 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jasmine --config=tests/spec/unit.json --filter=\"plugins folder regression\""] ++} +diff --git a/tests/spec/unit/Plugman/pluginHandler.spec.js b/tests/spec/unit/Plugman/pluginHandler.spec.js +index 368f5f5a..d70b5571 100644 +--- a/tests/spec/unit/Plugman/pluginHandler.spec.js ++++ b/tests/spec/unit/Plugman/pluginHandler.spec.js +@@ -610,5 +610,133 @@ describe('ios plugin handler', () => { + expect(fs.rmSync).not.toHaveBeenCalledWith(platformWwwDest); + }); + }); ++ ++ ++ ++ describe('of elements (plugins folder regression)', () => { ++ const install = pluginHandlers.getInstaller('asset'); ++ const uninstall = pluginHandlers.getUninstaller('asset'); ++ const pid = dummyPluginInfo.id; ++ ++ it('should not destroy a sibling asset under plugins/ when uninstalling another asset', () => { ++ const assetA = { src: 'www/dummyplugin.js', target: `plugins/${pid}/foo/dummy1.js` }; ++ const assetB = { src: 'www/dummyplugin.js', target: `plugins/${pid}/bar/dummy2.js` }; ++ ++ install(assetA, dummyPluginInfo, dummyProject); ++ install(assetB, dummyPluginInfo, dummyProject); ++ ++ const aWww = path.resolve(dummyProject.www, assetA.target); ++ const bWww = path.resolve(dummyProject.www, assetB.target); ++ expect(fs.existsSync(aWww)).toBe(true); ++ expect(fs.existsSync(bWww)).toBe(true); ++ ++ uninstall(assetA, dummyPluginInfo, dummyProject); ++ ++ expect(fs.existsSync(aWww)).toBe(false); ++ ++ expect(fs.existsSync(bWww)).toBe(true); ++ }); ++ ++ it('should allow uninstalling each of multiple assets sequentially without throwing', () => { ++ const assetA = { src: 'www/dummyplugin.js', target: `plugins/${pid}/foo/dummy1.js` }; ++ const assetB = { src: 'www/dummyplugin.js', target: `plugins/${pid}/bar/dummy2.js` }; ++ ++ install(assetA, dummyPluginInfo, dummyProject); ++ install(assetB, dummyPluginInfo, dummyProject); ++ ++ expect(() => uninstall(assetA, dummyPluginInfo, dummyProject)).not.toThrow(); ++ expect(() => uninstall(assetB, dummyPluginInfo, dummyProject)).not.toThrow(); ++ ++ expect(fs.existsSync(path.resolve(dummyProject.www, assetA.target))).toBe(false); ++ expect(fs.existsSync(path.resolve(dummyProject.www, assetB.target))).toBe(false); ++ }); ++ ++ it('should not throw when called twice for the same asset (idempotent uninstall)', () => { ++ const asset = { src: 'www/dummyplugin.js', target: `plugins/${pid}/foo/dummy.js` }; ++ ++ install(asset, dummyPluginInfo, dummyProject); ++ uninstall(asset, dummyPluginInfo, dummyProject); ++ expect(fs.existsSync(path.resolve(dummyProject.www, asset.target))).toBe(false); ++ ++ ++ expect(() => uninstall(asset, dummyPluginInfo, dummyProject)).not.toThrow(); ++ }); ++ ++ it('should remove empty intermediate parent directories below the plugin folder', () => { ++ const asset = { src: 'www/dummyplugin.js', target: `plugins/${pid}/foo/dummy.js` }; ++ ++ install(asset, dummyPluginInfo, dummyProject); ++ ++ const fooDir = path.resolve(dummyProject.www, 'plugins', pid, 'foo'); ++ expect(fs.existsSync(fooDir)).toBe(true); ++ ++ uninstall(asset, dummyPluginInfo, dummyProject); ++ ++ ++ expect(fs.existsSync(fooDir)).toBe(false); ++ }); ++ ++ it('should remove the now-empty plugins/ folder after the only asset is uninstalled', () => { ++ const asset = { src: 'www/dummyplugin.js', target: `plugins/${pid}/foo/dummy.js` }; ++ ++ install(asset, dummyPluginInfo, dummyProject); ++ ++ const pluginDir = path.resolve(dummyProject.www, 'plugins', pid); ++ expect(fs.existsSync(pluginDir)).toBe(true); ++ ++ uninstall(asset, dummyPluginInfo, dummyProject); ++ ++ expect(fs.existsSync(pluginDir)).toBe(false); ++ }); ++ ++ it('should remove the now-empty plugins folder after the last asset under it is uninstalled', () => { ++ const asset = { src: 'www/dummyplugin.js', target: `plugins/${pid}/foo/dummy.js` }; ++ ++ install(asset, dummyPluginInfo, dummyProject); ++ ++ const pluginsDir = path.resolve(dummyProject.www, 'plugins'); ++ expect(fs.existsSync(pluginsDir)).toBe(true); ++ ++ uninstall(asset, dummyPluginInfo, dummyProject); ++ ++ expect(fs.existsSync(pluginsDir)).toBe(false); ++ }); ++ ++ it('should remove the asset from both www and platform_www when usePlatformWww is set', () => { ++ const asset = { src: 'www/dummyplugin.js', target: `plugins/${pid}/foo/dummy.js` }; ++ ++ install(asset, dummyPluginInfo, dummyProject, { usePlatformWww: true }); ++ ++ const wwwPath = path.resolve(dummyProject.www, asset.target); ++ const platformWwwPath = path.resolve(dummyProject.platformWww, asset.target); ++ expect(fs.existsSync(wwwPath)).toBe(true); ++ expect(fs.existsSync(platformWwwPath)).toBe(true); ++ ++ uninstall(asset, dummyPluginInfo, dummyProject, { usePlatformWww: true }); ++ ++ expect(fs.existsSync(wwwPath)).toBe(false); ++ expect(fs.existsSync(platformWwwPath)).toBe(false); ++ }); ++ ++ it('should leave platform_www untouched when usePlatformWww is not set', () => { ++ const asset = { src: 'www/dummyplugin.js', target: `plugins/${pid}/foo/dummy.js` }; ++ ++ install(asset, dummyPluginInfo, dummyProject, { usePlatformWww: true }); ++ ++ const wwwPath = path.resolve(dummyProject.www, asset.target); ++ const platformWwwPath = path.resolve(dummyProject.platformWww, asset.target); ++ ++ uninstall(asset, dummyPluginInfo, dummyProject); ++ ++ expect(fs.existsSync(wwwPath)).toBe(false); ++ expect(fs.existsSync(platformWwwPath)).toBe(true); ++ }); ++ ++ it('should throw a CordovaError when the asset target attribute is missing', () => { ++ const asset = { src: 'www/dummyplugin.js' }; ++ expect(() => uninstall(asset, dummyPluginInfo, dummyProject)) ++ .toThrowError(/target/); ++ }); ++ }); + }); + }); +diff --git 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 jasmine --config=tests/spec/unit.json --filter="plugins folder regression" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000422/tests/test.sh b/tasks/format-code-task-000422/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..32809d3ba0c6e50fcc80400fad0e6879b2bc5019 --- /dev/null +++ b/tasks/format-code-task-000422/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/spec/unit/Plugman/pluginHandler.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-000422/tests/test_command.sh b/tasks/format-code-task-000422/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000422/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000435/environment/Dockerfile b/tasks/format-code-task-000435/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d68ee7b0656669c2eccdc5ffce9a779f87e92c17 --- /dev/null +++ b/tasks/format-code-task-000435/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e1f9bcb68ecaf2bf1569d43a4e2ae50465a00fa714a5c5f2286da761eba7871f diff --git a/tasks/format-code-task-000435/environment/setup/files/blocklist b/tasks/format-code-task-000435/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000435/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000435/environment/setup/setup.sh b/tasks/format-code-task-000435/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000435/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000435/tests/test.patch b/tasks/format-code-task-000435/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2bda1a0b2d166fc4097d9aab4daf6e46d2c9f30 --- /dev/null +++ b/tasks/format-code-task-000435/tests/test.patch @@ -0,0 +1,120 @@ +diff --git a/test/core/sitemap_request_list.test.ts b/test/core/sitemap_request_list.test.ts +index ed8b8589..da61d6b2 100644 +--- a/test/core/sitemap_request_list.test.ts ++++ b/test/core/sitemap_request_list.test.ts +@@ -501,6 +501,93 @@ describe('SitemapRequestList', () => { + expect(newList.handledCount()).toBe(2); + }); + ++ test('persistState() does not throw after sitemap is fully loaded', async () => { ++ const list = await SitemapRequestList.open({ ++ sitemapUrls: [`${url}/sitemap.xml`], ++ persistStateKey: 'persist-after-full-load', ++ }); ++ ++ ++ const start = Date.now(); ++ while (!list.isSitemapFullyLoaded()) { ++ if (Date.now() - start > 10_000) throw new Error('sitemap loading timed out'); ++ await sleep(20); ++ } ++ ++ ++ await expect(list.persistState()).resolves.toBeUndefined(); ++ }); ++ ++ test('list remains usable after persistState() following full sitemap load', async () => { ++ const list = await SitemapRequestList.open({ ++ sitemapUrls: [`${url}/sitemap.xml`], ++ persistStateKey: 'usable-after-persist', ++ }); ++ ++ const start = Date.now(); ++ while (!list.isSitemapFullyLoaded()) { ++ if (Date.now() - start > 10_000) throw new Error('sitemap loading timed out'); ++ await sleep(20); ++ } ++ ++ const first = await list.fetchNextRequest(); ++ expect(first).not.toBeNull(); ++ await list.markRequestHandled(first); ++ ++ ++ await list.persistState(); ++ ++ const remaining: string[] = []; ++ for await (const request of list) { ++ remaining.push(request.url); ++ await list.markRequestHandled(request); ++ } ++ ++ expect(remaining).toHaveLength(4); ++ expect(list.handledCount()).toBe(5); ++ expect(new Set([first.url, ...remaining])).toEqual( ++ new Set([ ++ 'http://not-exists.com/', ++ 'http://not-exists.com/catalog?item=12&desc=vacation_hawaii', ++ 'http://not-exists.com/catalog?item=73&desc=vacation_new_zealand', ++ 'http://not-exists.com/catalog?item=74&desc=vacation_newfoundland', ++ 'http://not-exists.com/catalog?item=83&desc=vacation_usa', ++ ]), ++ ); ++ }); ++ ++ test('resurrection works after persistState() following full sitemap load', async () => { ++ const options = { ++ sitemapUrls: [`${url}/sitemap.xml`], ++ persistStateKey: 'resurrection-after-full-load', ++ }; ++ ++ { ++ const list = await SitemapRequestList.open(options); ++ const start = Date.now(); ++ while (!list.isSitemapFullyLoaded()) { ++ if (Date.now() - start > 10_000) throw new Error('sitemap loading timed out'); ++ await sleep(20); ++ } ++ ++ const first = await list.fetchNextRequest(); ++ await list.markRequestHandled(first); ++ ++ await list.persistState(); ++ } ++ ++ const newList = await SitemapRequestList.open(options); ++ const restoredUrls: string[] = []; ++ for await (const request of newList) { ++ restoredUrls.push(request.url); ++ await newList.markRequestHandled(request); ++ } ++ ++ expect(restoredUrls).toHaveLength(4); ++ expect(newList.handledCount()).toBe(4); ++ expect(new Set(restoredUrls).size).toBe(4); ++ }); ++ + test('state persistence tracks user changes', async () => { + const options = { + sitemapUrls: [`${url}/sitemap-stream.xml`], +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..77b970d5 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx vitest run --silent test/core/sitemap_request_list.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 vitest run --silent test/core/sitemap_request_list.test.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000435/tests/test.sh b/tasks/format-code-task-000435/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3f63fb207e37f3ed108fc7007e702b7df12d2a84 --- /dev/null +++ b/tasks/format-code-task-000435/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/core/sitemap_request_list.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-000435/tests/test_command.sh b/tasks/format-code-task-000435/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000435/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000450/environment/setup/files/blocklist b/tasks/format-code-task-000450/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000450/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000451/environment/Dockerfile b/tasks/format-code-task-000451/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..60d3cbfcdf417e386101aeb4415c32904ab45ae1 --- /dev/null +++ b/tasks/format-code-task-000451/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1ade211abf06173614bebd12ab3b4de733de7cfa5d8fd15b457c8852a9e24395 diff --git a/tasks/format-code-task-000451/environment/setup/files/blocklist b/tasks/format-code-task-000451/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000451/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000451/environment/setup/setup.sh b/tasks/format-code-task-000451/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000451/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000451/tests/test.patch b/tasks/format-code-task-000451/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c4872d1c76a18d0cf1f8098e4dc5036eb7634949 --- /dev/null +++ b/tasks/format-code-task-000451/tests/test.patch @@ -0,0 +1,144 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..f176df9d8 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./util/dex/ -run Test_GenerateDexConfig -count=1"] ++} +diff --git a/util/dex/dex_test.go b/util/dex/dex_test.go +index ffe1fa786..394dba9e4 100644 +--- a/util/dex/dex_test.go ++++ b/util/dex/dex_test.go +@@ -267,6 +267,117 @@ func Test_GenerateDexConfig(t *testing.T) { + customClient := clients[2].(map[string]interface{}) + assert.Equal(t, "barfoo", customClient["secret"]) + }) ++ ++ t.Run("OAuth2 passwordConnector preserved when user provides it", func(t *testing.T) { ++ dexConfig := ` ++oauth2: ++ passwordConnector: ldap ++connectors: ++- type: ldap ++ name: LDAP ++ id: ldap ++ config: ++ host: myldap.company.com ++` ++ s := settings.ArgoCDSettings{ ++ URL: "http://localhost", ++ DexConfig: dexConfig, ++ } ++ config, err := GenerateDexConfigYAML(&s) ++ assert.NoError(t, err) ++ assert.NotNil(t, config) ++ var dexCfg map[string]interface{} ++ err = yaml.Unmarshal(config, &dexCfg) ++ if err != nil { ++ panic(err.Error()) ++ } ++ oauth2Cfg, ok := dexCfg["oauth2"].(map[string]interface{}) ++ assert.True(t, ok) ++ assert.Equal(t, "ldap", oauth2Cfg["passwordConnector"]) ++ ++ assert.Equal(t, true, oauth2Cfg["skipApprovalScreen"]) ++ }) ++ ++ t.Run("OAuth2 skipApprovalScreen false preserved when user provides it", func(t *testing.T) { ++ dexConfig := ` ++oauth2: ++ skipApprovalScreen: false ++ passwordConnector: ldap ++connectors: ++- type: ldap ++ name: LDAP ++ id: ldap ++ config: ++ host: myldap.company.com ++` ++ s := settings.ArgoCDSettings{ ++ URL: "http://localhost", ++ DexConfig: dexConfig, ++ } ++ config, err := GenerateDexConfigYAML(&s) ++ assert.NoError(t, err) ++ assert.NotNil(t, config) ++ var dexCfg map[string]interface{} ++ err = yaml.Unmarshal(config, &dexCfg) ++ if err != nil { ++ panic(err.Error()) ++ } ++ oauth2Cfg, ok := dexCfg["oauth2"].(map[string]interface{}) ++ assert.True(t, ok) ++ assert.Equal(t, false, oauth2Cfg["skipApprovalScreen"]) ++ assert.Equal(t, "ldap", oauth2Cfg["passwordConnector"]) ++ }) ++ ++ t.Run("OAuth2 default skipApprovalScreen true when user provides no oauth2", func(t *testing.T) { ++ s := settings.ArgoCDSettings{ ++ URL: "http://localhost", ++ DexConfig: goodDexConfig, ++ } ++ config, err := GenerateDexConfigYAML(&s) ++ assert.NoError(t, err) ++ assert.NotNil(t, config) ++ var dexCfg map[string]interface{} ++ err = yaml.Unmarshal(config, &dexCfg) ++ if err != nil { ++ panic(err.Error()) ++ } ++ oauth2Cfg, ok := dexCfg["oauth2"].(map[string]interface{}) ++ assert.True(t, ok) ++ assert.Equal(t, true, oauth2Cfg["skipApprovalScreen"]) ++ ++ assert.Equal(t, 1, len(oauth2Cfg)) ++ }) ++ ++ t.Run("OAuth2 multiple keys preserved alongside default skipApprovalScreen", func(t *testing.T) { ++ dexConfig := ` ++oauth2: ++ passwordConnector: ldap ++ alwaysShowLoginScreen: true ++connectors: ++- type: ldap ++ name: LDAP ++ id: ldap ++ config: ++ host: myldap.company.com ++` ++ s := settings.ArgoCDSettings{ ++ URL: "http://localhost", ++ DexConfig: dexConfig, ++ } ++ config, err := GenerateDexConfigYAML(&s) ++ assert.NoError(t, err) ++ assert.NotNil(t, config) ++ var dexCfg map[string]interface{} ++ err = yaml.Unmarshal(config, &dexCfg) ++ if err != nil { ++ panic(err.Error()) ++ } ++ oauth2Cfg, ok := dexCfg["oauth2"].(map[string]interface{}) ++ assert.True(t, ok) ++ assert.Equal(t, "ldap", oauth2Cfg["passwordConnector"]) ++ assert.Equal(t, true, oauth2Cfg["alwaysShowLoginScreen"]) ++ assert.Equal(t, true, oauth2Cfg["skipApprovalScreen"]) ++ }) + } + + func Test_DexReverseProxy(t *testing.T) { +diff --git 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 ./util/dex/ -run Test_GenerateDexConfig -count=1 ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000451/tests/test.sh b/tasks/format-code-task-000451/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9f0036ee6e8de8aa716ee54e41a55217ea8f20fe --- /dev/null +++ b/tasks/format-code-task-000451/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 +util/dex/dex_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-000451/tests/test_command.sh b/tasks/format-code-task-000451/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000451/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000456/environment/Dockerfile b/tasks/format-code-task-000456/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fc1704aaf79d33d5768acf2f8b9f31a75a858cfe --- /dev/null +++ b/tasks/format-code-task-000456/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a2deaf252ad4c9d823dca49374570663b243d61816587b0c8e21c3da8b137290 diff --git a/tasks/format-code-task-000456/environment/setup/files/blocklist b/tasks/format-code-task-000456/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000456/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000456/environment/setup/setup.sh b/tasks/format-code-task-000456/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000456/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000456/tests/test.patch b/tasks/format-code-task-000456/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6e744ae013b6834130f2eff4d00a64f5acd192e1 --- /dev/null +++ b/tasks/format-code-task-000456/tests/test.patch @@ -0,0 +1,274 @@ +diff --git a/schema/schemaspec/extension_test.go b/schema/schemaspec/extension_test.go +index 01402273..1a09c56d 100644 +--- a/schema/schemaspec/extension_test.go ++++ b/schema/schemaspec/extension_test.go +@@ -1,6 +1,8 @@ + package schemaspec_test + + import ( ++ "fmt" ++ "reflect" + "testing" + + "ariga.io/atlas/schema/schemaspec" +@@ -188,3 +190,117 @@ func TestListRef(t *testing.T) { + require.NoError(t, err) + require.EqualValues(t, resource, scan) + } ++ ++func TestResourceAsInterfaceRemainder(t *testing.T) { ++ type ( ++ RemainderThing interface { ++ remainderThing() ++ } ++ RemainderGem struct { ++ RemainderThing ++ Name string `spec:",name"` ++ } ++ RemainderOre struct { ++ RemainderThing ++ Name string `spec:",name"` ++ } ++ RemainderBin struct { ++ schemaspec.DefaultExtension ++ Things []RemainderThing `spec:""` ++ } ++ ) ++ ++ const ( ++ gemType = "atlas245_remainder_gem" ++ oreType = "atlas245_remainder_ore" ++ leftoverTyp = "atlas245_remainder_leftover" ++ ) ++ schemaspec.Register(gemType, &RemainderGem{}) ++ schemaspec.Register(oreType, &RemainderOre{}) ++ ++ t.Run("interface_slice_consumes_matching_children", func(t *testing.T) { ++ res := &schemaspec.Resource{ ++ Type: "atlas245_remainder_bin", ++ Children: []*schemaspec.Resource{ ++ {Type: gemType, Name: "ruby"}, ++ {Type: leftoverTyp, Name: "tail"}, ++ {Type: oreType, Name: "iron"}, ++ }, ++ } ++ ++ var bin RemainderBin ++ require.NoError(t, res.As(&bin)) ++ require.Len(t, bin.Things, 2) ++ ++ var got []string ++ for _, thing := range bin.Things { ++ switch thing := thing.(type) { ++ case *RemainderGem: ++ got = append(got, fmt.Sprintf("%s:%s", gemType, thing.Name)) ++ case *RemainderOre: ++ got = append(got, fmt.Sprintf("%s:%s", oreType, thing.Name)) ++ default: ++ t.Fatalf("unexpected thing type %T", thing) ++ } ++ } ++ require.ElementsMatch(t, []string{gemType + ":ruby", oreType + ":iron"}, got) ++ ++ var remainTypes []string ++ require.NotNil(t, bin.Remain()) ++ for _, child := range bin.Remain().Children { ++ remainTypes = append(remainTypes, child.Type) ++ } ++ require.ElementsMatch(t, []string{leftoverTyp}, remainTypes) ++ }) ++} ++ ++func TestResourceAsSingleInterfaceAmbiguity(t *testing.T) { ++ type ( ++ Control interface { ++ control() ++ } ++ ToggleSwitch struct { ++ Control ++ Name string `spec:",name"` ++ Mode string `spec:"mode"` ++ } ++ RotaryKnob struct { ++ Control ++ Name string `spec:",name"` ++ Step string `spec:"step"` ++ } ++ ControlLabel struct { ++ Name string `spec:",name"` ++ Text string `spec:"text"` ++ } ++ Panel struct { ++ Control Control `spec:""` ++ } ++ ) ++ ++ const ( ++ switchType = "atlas245_toggle_switch" ++ knobType = "atlas245_rotary_knob" ++ labelType = "atlas245_control_label" ++ ) ++ schemaspec.Register(switchType, &ToggleSwitch{}) ++ schemaspec.Register(knobType, &RotaryKnob{}) ++ schemaspec.Register(labelType, &ControlLabel{}) ++ ++ res := &schemaspec.Resource{ ++ Type: "atlas245_panel", ++ Children: []*schemaspec.Resource{ ++ {Type: labelType, Name: "title"}, ++ {Type: switchType, Name: "power"}, ++ {Type: knobType, Name: "volume"}, ++ }, ++ } ++ ++ var panel Panel ++ err := res.As(&panel) ++ ++ require.EqualError(t, err, fmt.Sprintf( ++ "more than one blocks implement %q", ++ reflect.TypeOf((*Control)(nil)).Elem(), ++ )) ++} +diff --git a/schema/schemaspec/schemahcl/hcl_test.go b/schema/schemaspec/schemahcl/hcl_test.go +index a7cd75bf..385adc39 100644 +--- a/schema/schemaspec/schemahcl/hcl_test.go ++++ b/schema/schemaspec/schemahcl/hcl_test.go +@@ -5,6 +5,7 @@ import ( + "log" + "testing" + ++ "ariga.io/atlas/schema/schemaspec" + "github.com/stretchr/testify/require" + ) + +@@ -143,3 +144,107 @@ func ExampleMarshal() { + // y = 1 + // } + } ++ ++func TestInterfaceExtensions(t *testing.T) { ++ type ( ++ Performer interface { ++ perform() ++ } ++ StageActor struct { ++ Performer ++ Name string `spec:",name"` ++ Role string `spec:"role"` ++ } ++ StageProp struct { ++ Name string `spec:",name"` ++ Kind string `spec:"kind"` ++ } ++ StageCast struct { ++ Performer Performer `spec:""` ++ } ++ Theater struct { ++ Cast *StageCast `spec:"theater"` ++ } ++ ++ Creature interface { ++ creature() ++ } ++ SongBird struct { ++ Creature ++ Name string `spec:",name"` ++ Song string `spec:"song"` ++ } ++ ReefFish struct { ++ Creature ++ Name string `spec:",name"` ++ Color string `spec:"color"` ++ } ++ Aquarium struct { ++ Creatures []Creature `spec:""` ++ } ++ AquariumDoc struct { ++ Aquarium *Aquarium `spec:"aquarium"` ++ } ++ ) ++ ++ schemaspec.Register("atlas245_stage_actor", &StageActor{}) ++ schemaspec.Register("atlas245_stage_prop", &StageProp{}) ++ schemaspec.Register("atlas245_song_bird", &SongBird{}) ++ schemaspec.Register("atlas245_reef_fish", &ReefFish{}) ++ ++ t.Run("single_via_hcl", func(t *testing.T) { ++ f := ` ++theater "main" { ++ atlas245_stage_prop "curtain" { ++ kind = "fabric" ++ } ++ atlas245_stage_actor "ada" { ++ role = "lead" ++ } ++} ++` ++ var doc Theater ++ err := Unmarshal([]byte(f), &doc) ++ require.NoError(t, err) ++ require.NotNil(t, doc.Cast) ++ actor, ok := doc.Cast.Performer.(*StageActor) ++ require.Truef(t, ok, "unexpected performer type %T", doc.Cast.Performer) ++ require.Equal(t, "ada", actor.Name) ++ require.Equal(t, "lead", actor.Role) ++ }) ++ ++ t.Run("slice_via_hcl", func(t *testing.T) { ++ f := ` ++aquarium "reef" { ++ atlas245_song_bird "lark" { ++ song = "bright" ++ } ++ atlas245_reef_fish "goby" { ++ color = "blue" ++ } ++} ++` ++ var doc AquariumDoc ++ err := Unmarshal([]byte(f), &doc) ++ require.NoError(t, err) ++ require.NotNil(t, doc.Aquarium) ++ require.Len(t, doc.Aquarium.Creatures, 2) ++ ++ var got []string ++ for _, c := range doc.Aquarium.Creatures { ++ switch c := c.(type) { ++ case *SongBird: ++ got = append(got, "bird:"+c.Name+":"+c.Song) ++ case *ReefFish: ++ got = append(got, "fish:"+c.Name+":"+c.Color) ++ default: ++ t.Fatalf("unexpected creature type %T", c) ++ } ++ } ++ require.ElementsMatch(t, []string{ ++ "bird:lark:bright", ++ "fish:goby:blue", ++ }, 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,18 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ go test ./schema/schemaspec/ -run '^(TestInvalidExt|TestExtension|TestNested|TestRef|TestListRef)$' -v -count=1 ++ go test ./schema/schemaspec/schemahcl/ -run '^(TestAttributes|TestResource|ExampleUnmarshal|ExampleMarshal)$' -v -count=1 ++ ;; ++ new) ++ go test ./schema/schemaspec/ -run '^(TestResourceAsInterfaceRemainder|TestResourceAsSingleInterfaceAmbiguity)$' -v -count=1 ++ go test ./schema/schemaspec/schemahcl/ -run '^TestInterfaceExtensions$' -v -count=1 ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000456/tests/test.sh b/tasks/format-code-task-000456/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9019cfcf8c076ac7daf72bf003926fe80758fd6a --- /dev/null +++ b/tasks/format-code-task-000456/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' +schema/schemaspec/extension_test.go +schema/schemaspec/schemahcl/hcl_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-000456/tests/test_command.sh b/tasks/format-code-task-000456/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000456/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-000459/environment/Dockerfile b/tasks/format-code-task-000459/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c547131b7e4b136578f9527cbadbcae48f722932 --- /dev/null +++ b/tasks/format-code-task-000459/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:482ead1966473dd108f7934684a9b2345a558827eebb480ee2c30a8651c3bc0a diff --git a/tasks/format-code-task-000459/environment/setup/files/blocklist b/tasks/format-code-task-000459/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000459/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000459/environment/setup/setup.sh b/tasks/format-code-task-000459/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000459/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000459/tests/test.patch b/tasks/format-code-task-000459/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2e29f7dc516919027c565be1e1f4bfae0021104 --- /dev/null +++ b/tasks/format-code-task-000459/tests/test.patch @@ -0,0 +1,632 @@ +diff --git a/usercase-test-coderl/test_page_lifecycle.c b/usercase-test-coderl/test_page_lifecycle.c +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_page_lifecycle.c +@@ -0,0 +1,598 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++#include ++#include ++#include ++#include ++ ++#include "jbig2.h" ++ ++typedef struct { ++ int count; ++ Jbig2Severity severity[64]; ++ uint32_t segment[64]; ++ char message[64][256]; ++} ErrorLog; ++ ++typedef struct { ++ Jbig2Allocator super; ++ size_t active_allocs; ++ size_t active_bytes; ++ size_t peak_allocs; ++ size_t peak_bytes; ++} TrackingAllocator; ++ ++static int failures = 0; ++ ++static void ++record_error(void *data, const char *msg, Jbig2Severity severity, uint32_t seg_idx) ++{ ++ ErrorLog *log = (ErrorLog *)data; ++ ++ if (log->count < 64) { ++ log->severity[log->count] = severity; ++ log->segment[log->count] = seg_idx; ++ snprintf(log->message[log->count], sizeof(log->message[log->count]), "%s", msg); ++ } ++ log->count++; ++} ++ ++static void ++fail_at(const char *test, int line, const char *what) ++{ ++ fprintf(stderr, "FAIL %s:%d: %s\n", test, line, what); ++ failures++; ++} ++ ++static void ++assert_int_eq(const char *test, int line, const char *label, int actual, int expected) ++{ ++ if (actual != expected) { ++ fprintf(stderr, "FAIL %s:%d: %s actual=%d expected=%d\n", test, line, label, actual, expected); ++ failures++; ++ } ++} ++ ++static void ++assert_uint_eq(const char *test, int line, const char *label, uint32_t actual, uint32_t expected) ++{ ++ if (actual != expected) { ++ fprintf(stderr, "FAIL %s:%d: %s actual=%u expected=%u\n", test, line, label, actual, expected); ++ failures++; ++ } ++} ++ ++static void ++assert_size_eq(const char *test, int line, const char *label, size_t actual, size_t expected) ++{ ++ if (actual != expected) { ++ fprintf(stderr, "FAIL %s:%d: %s actual=%lu expected=%lu\n", ++ test, line, label, (unsigned long)actual, (unsigned long)expected); ++ failures++; ++ } ++} ++ ++static void ++assert_int_ge(const char *test, int line, const char *label, int actual, int minimum) ++{ ++ if (actual < minimum) { ++ fprintf(stderr, "FAIL %s:%d: %s actual=%d minimum=%d\n", test, line, label, actual, minimum); ++ failures++; ++ } ++} ++ ++static void ++assert_size_ge(const char *test, int line, const char *label, size_t actual, size_t minimum) ++{ ++ if (actual < minimum) { ++ fprintf(stderr, "FAIL %s:%d: %s actual=%lu minimum=%lu\n", ++ test, line, label, (unsigned long)actual, (unsigned long)minimum); ++ failures++; ++ } ++} ++ ++static void ++assert_ptr_null(const char *test, int line, const char *label, const void *actual) ++{ ++ if (actual != NULL) { ++ fprintf(stderr, "FAIL %s:%d: %s actual=%p expected=(nil)\n", test, line, label, actual); ++ failures++; ++ } ++} ++ ++static void ++assert_ptr_not_eq(const char *test, int line, const char *label, const void *actual, const void *unexpected) ++{ ++ if (actual == unexpected) { ++ fprintf(stderr, "FAIL %s:%d: %s actual=%p unexpected=%p\n", test, line, label, actual, unexpected); ++ failures++; ++ } ++} ++ ++static void ++assert_str_eq(const char *test, int line, const char *label, const char *actual, const char *expected) ++{ ++ if (strcmp(actual, expected) != 0) { ++ fprintf(stderr, "FAIL %s:%d: %s actual=\"%s\" expected=\"%s\"\n", ++ test, line, label, actual, expected); ++ failures++; ++ } ++} ++ ++static int ++log_limit(const ErrorLog *log) ++{ ++ return log->count < 64 ? log->count : 64; ++} ++ ++static int ++log_count_severity_from(const ErrorLog *log, int start, Jbig2Severity severity) ++{ ++ int count = 0; ++ int i; ++ int limit = log_limit(log); ++ ++ if (start < 0) ++ start = 0; ++ ++ for (i = start; i < limit; i++) { ++ if (log->severity[i] == severity) ++ count++; ++ } ++ return count; ++} ++ ++static void ++assert_log_has_severity_from(const char *test, int line, const char *label, ++ const ErrorLog *log, int start, Jbig2Severity severity) ++{ ++ if (log_count_severity_from(log, start, severity) == 0) { ++ fprintf(stderr, "FAIL %s:%d: %s missing severity=%d from index=%d count=%d\n", ++ test, line, label, severity, start, log->count); ++ failures++; ++ } ++} ++ ++static void ++assert_log_severity_count_ge_from(const char *test, int line, const char *label, ++ const ErrorLog *log, int start, Jbig2Severity severity, int minimum) ++{ ++ int actual = log_count_severity_from(log, start, severity); ++ ++ if (actual < minimum) { ++ fprintf(stderr, "FAIL %s:%d: %s severity=%d actual=%d minimum=%d from index=%d count=%d\n", ++ test, line, label, severity, actual, minimum, start, log->count); ++ failures++; ++ } ++} ++ ++static void ++assert_no_severity_at_or_above_from(const char *test, int line, const char *label, ++ const ErrorLog *log, int start, Jbig2Severity minimum) ++{ ++ int i; ++ int limit = log_limit(log); ++ ++ if (start < 0) ++ start = 0; ++ ++ for (i = start; i < limit; i++) { ++ if (log->severity[i] >= minimum) { ++ fprintf(stderr, "FAIL %s:%d: %s severity=%d at index=%d minimum=%d\n", ++ test, line, label, log->severity[i], i, minimum); ++ failures++; ++ return; ++ } ++ } ++} ++ ++#define ASSERT_INT(label, actual, expected) assert_int_eq(__func__, __LINE__, label, actual, expected) ++#define ASSERT_INT_GE(label, actual, minimum) assert_int_ge(__func__, __LINE__, label, actual, minimum) ++#define ASSERT_UINT(label, actual, expected) assert_uint_eq(__func__, __LINE__, label, actual, expected) ++#define ASSERT_SIZE(label, actual, expected) assert_size_eq(__func__, __LINE__, label, actual, expected) ++#define ASSERT_SIZE_GE(label, actual, minimum) assert_size_ge(__func__, __LINE__, label, actual, minimum) ++#define ASSERT_NULL(label, actual) assert_ptr_null(__func__, __LINE__, label, actual) ++#define ASSERT_PTR_NOT_EQ(label, actual, unexpected) assert_ptr_not_eq(__func__, __LINE__, label, actual, unexpected) ++#define ASSERT_STR(label, actual, expected) assert_str_eq(__func__, __LINE__, label, actual, expected) ++#define ASSERT_LOG_HAS_SEVERITY_FROM(label, log, start, severity) assert_log_has_severity_from(__func__, __LINE__, label, log, start, severity) ++#define ASSERT_LOG_SEVERITY_COUNT_GE_FROM(label, log, start, severity, minimum) assert_log_severity_count_ge_from(__func__, __LINE__, label, log, start, severity, minimum) ++#define ASSERT_NO_SEVERITY_AT_OR_ABOVE_FROM(label, log, start, minimum) assert_no_severity_at_or_above_from(__func__, __LINE__, label, log, start, minimum) ++#define FAIL_NOW(what) fail_at(__func__, __LINE__, what) ++ ++static const unsigned char one_page_stream[] = { ++ 0x97, 0x4a, 0x42, 0x32, 0x0d, 0x0a, 0x1a, 0x0a, 0x03, ++ 0x00, 0x00, 0x00, 0x01, 0x30, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, ++ 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00 ++}; ++ ++static const unsigned char two_page_stream[] = { ++ 0x97, 0x4a, 0x42, 0x32, 0x0d, 0x0a, 0x1a, 0x0a, 0x03, ++ 0x00, 0x00, 0x00, 0x01, 0x30, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, ++ 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x02, 0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, ++ 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00 ++}; ++ ++static const unsigned char unknown_length_pending_stream[] = { ++ 0x97, 0x4a, 0x42, 0x32, 0x0d, 0x0a, 0x1a, 0x0a, 0x03, ++ 0x00, 0x00, 0x00, 0x01, 0x30, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, ++ 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x02, 0x26, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, ++ 0x01, 0x02, 0x03 ++}; ++ ++static void * ++tracking_alloc(Jbig2Allocator *allocator, size_t size) ++{ ++ TrackingAllocator *tracker = (TrackingAllocator *)allocator; ++ size_t *base = (size_t *)malloc(sizeof(size_t) + size); ++ ++ if (base == NULL) ++ return NULL; ++ ++ *base = size; ++ tracker->active_allocs++; ++ tracker->active_bytes += size; ++ if (tracker->active_allocs > tracker->peak_allocs) ++ tracker->peak_allocs = tracker->active_allocs; ++ if (tracker->active_bytes > tracker->peak_bytes) ++ tracker->peak_bytes = tracker->active_bytes; ++ ++ return base + 1; ++} ++ ++static void ++tracking_free(Jbig2Allocator *allocator, void *p) ++{ ++ TrackingAllocator *tracker = (TrackingAllocator *)allocator; ++ size_t *base; ++ ++ if (p == NULL) ++ return; ++ ++ base = ((size_t *)p) - 1; ++ tracker->active_allocs--; ++ tracker->active_bytes -= *base; ++ free(base); ++} ++ ++static void * ++tracking_realloc(Jbig2Allocator *allocator, void *p, size_t size) ++{ ++ TrackingAllocator *tracker = (TrackingAllocator *)allocator; ++ size_t old_size = 0; ++ size_t *base; ++ size_t *new_base; ++ ++ if (p == NULL) ++ return tracking_alloc(allocator, size); ++ ++ base = ((size_t *)p) - 1; ++ old_size = *base; ++ new_base = (size_t *)realloc(base, sizeof(size_t) + size); ++ if (new_base == NULL) ++ return NULL; ++ ++ *new_base = size; ++ tracker->active_bytes = tracker->active_bytes - old_size + size; ++ if (tracker->active_bytes > tracker->peak_bytes) ++ tracker->peak_bytes = tracker->active_bytes; ++ ++ return new_base + 1; ++} ++ ++static TrackingAllocator ++new_tracking_allocator(void) ++{ ++ TrackingAllocator tracker; ++ ++ memset(&tracker, 0, sizeof(tracker)); ++ tracker.super.alloc = tracking_alloc; ++ tracker.super.free = tracking_free; ++ tracker.super.realloc = tracking_realloc; ++ return tracker; ++} ++ ++static void ++image_data_hex(const Jbig2Image *image, char *out, size_t out_size) ++{ ++ size_t bytes; ++ size_t i; ++ ++ if (image == NULL || out_size == 0) { ++ if (out_size != 0) ++ out[0] = '\0'; ++ return; ++ } ++ ++ bytes = (size_t)image->stride * image->height; ++ if (out_size < bytes * 2 + 1) ++ bytes = (out_size - 1) / 2; ++ ++ for (i = 0; i < bytes; i++) ++ snprintf(out + i * 2, out_size - i * 2, "%02x", image->data[i]); ++} ++ ++static void ++test_incremental_complete_page_and_single_page_handoff(void) ++{ ++ ++ ++ ++ ++ ErrorLog log = {0}; ++ Jbig2Ctx *ctx = jbig2_ctx_new(NULL, 0, NULL, record_error, &log); ++ Jbig2Image *image; ++ char data_hex[32] = {0}; ++ int before_release; ++ ++ ASSERT_NULL("fresh page_out", jbig2_page_out(ctx)); ++ ASSERT_INT("data_in partial header", jbig2_data_in(ctx, one_page_stream, 20), 0); ++ ASSERT_NULL("partial page_out", jbig2_page_out(ctx)); ++ ASSERT_INT("data_in page body", jbig2_data_in(ctx, one_page_stream + 20, sizeof(one_page_stream) - 20), 0); ++ ASSERT_NULL("before complete page_out", jbig2_page_out(ctx)); ++ ASSERT_INT("complete_page", jbig2_complete_page(ctx), 0); ++ ++ image = jbig2_page_out(ctx); ++ ASSERT_UINT("image width", image == NULL ? 0 : image->width, 9); ++ ASSERT_UINT("image height", image == NULL ? 0 : image->height, 3); ++ ASSERT_UINT("image stride", image == NULL ? 0 : image->stride, 2); ++ ++ ASSERT_INT_GE("image refcount after page_out", image == NULL ? 0 : image->refcount, 2); ++ image_data_hex(image, data_hex, sizeof(data_hex)); ++ ASSERT_STR("image data", data_hex, "000000000000"); ++ ASSERT_NULL("second page_out", jbig2_page_out(ctx)); ++ ++ before_release = log.count; ++ jbig2_release_page(ctx, image); ++ ++ ASSERT_NO_SEVERITY_AT_OR_ABOVE_FROM("release warning/fatal callbacks", &log, before_release, JBIG2_SEVERITY_WARNING); ++ ++ jbig2_ctx_free(ctx); ++} ++ ++static void ++test_complete_page_without_image_reports_fatal(void) ++{ ++ ++ ++ ++ ++ ErrorLog log = {0}; ++ Jbig2Ctx *ctx = jbig2_ctx_new(NULL, 0, NULL, record_error, &log); ++ int before_complete; ++ ++ ASSERT_NULL("fresh page_out", jbig2_page_out(ctx)); ++ before_complete = log.count; ++ ASSERT_INT("complete_page without image", jbig2_complete_page(ctx), -1); ++ ++ ASSERT_LOG_HAS_SEVERITY_FROM("fatal callback", &log, before_complete, JBIG2_SEVERITY_FATAL); ++ ASSERT_NULL("page_out after fatal complete", jbig2_page_out(ctx)); ++ ++ jbig2_ctx_free(ctx); ++} ++ ++static void ++test_unknown_length_pending_segment_warns_fails_and_advances(void) ++{ ++ ++ ++ ++ ++ ErrorLog log = {0}; ++ Jbig2Ctx *ctx = jbig2_ctx_new(NULL, 0, NULL, record_error, &log); ++ Jbig2Image *image; ++ int before_complete; ++ ++ ASSERT_INT("data_in unknown length stream", jbig2_data_in(ctx, unknown_length_pending_stream, sizeof(unknown_length_pending_stream)), 0); ++ before_complete = log.count; ++ ASSERT_INT("first complete_page", jbig2_complete_page(ctx), -1); ++ ASSERT_NULL("page_out after failed parse", jbig2_page_out(ctx)); ++ ++ ASSERT_LOG_SEVERITY_COUNT_GE_FROM("unknown length and failed parse warnings", &log, before_complete, JBIG2_SEVERITY_WARNING, 2); ++ ++ ASSERT_INT("second complete_page after segment advance", jbig2_complete_page(ctx), 0); ++ image = jbig2_page_out(ctx); ++ ASSERT_UINT("advanced page width", image == NULL ? 0 : image->width, 9); ++ ASSERT_UINT("advanced page height", image == NULL ? 0 : image->height, 3); ++ ASSERT_UINT("advanced page stride", image == NULL ? 0 : image->stride, 2); ++ ++ jbig2_release_page(ctx, image); ++ jbig2_ctx_free(ctx); ++} ++ ++static void ++test_first_available_completed_page_order(void) ++{ ++ ++ ++ ++ ++ ErrorLog log = {0}; ++ Jbig2Ctx *ctx = jbig2_ctx_new(NULL, 0, NULL, record_error, &log); ++ Jbig2Image *first; ++ Jbig2Image *second; ++ ++ ASSERT_INT("data_in two-page stream", jbig2_data_in(ctx, two_page_stream, sizeof(two_page_stream)), 0); ++ ASSERT_INT("complete current page", jbig2_complete_page(ctx), 0); ++ ++ first = jbig2_page_out(ctx); ++ ASSERT_UINT("first page width", first == NULL ? 0 : first->width, 9); ++ ASSERT_UINT("first page height", first == NULL ? 0 : first->height, 3); ++ ASSERT_UINT("first page stride", first == NULL ? 0 : first->stride, 2); ++ ++ ASSERT_INT_GE("first page refcount", first == NULL ? 0 : first->refcount, 2); ++ ++ second = jbig2_page_out(ctx); ++ ASSERT_UINT("second page width", second == NULL ? 0 : second->width, 17); ++ ASSERT_UINT("second page height", second == NULL ? 0 : second->height, 1); ++ ASSERT_UINT("second page stride", second == NULL ? 0 : second->stride, 3); ++ ++ ASSERT_INT_GE("second page refcount", second == NULL ? 0 : second->refcount, 2); ++ ++ ASSERT_PTR_NOT_EQ("first and second pages are distinct", second, first); ++ ASSERT_NULL("no third completed page", jbig2_page_out(ctx)); ++ ++ jbig2_release_page(ctx, first); ++ jbig2_release_page(ctx, second); ++ jbig2_ctx_free(ctx); ++} ++ ++static void ++test_release_null_twice_is_noop(void) ++{ ++ ++ ++ ++ ++ ErrorLog log = {0}; ++ Jbig2Ctx *ctx = jbig2_ctx_new(NULL, 0, NULL, record_error, &log); ++ ++ jbig2_release_page(ctx, NULL); ++ jbig2_release_page(ctx, NULL); ++ ASSERT_INT("error callback count", log.count, 0); ++ ASSERT_NULL("page_out remains empty", jbig2_page_out(ctx)); ++ ++ jbig2_ctx_free(ctx); ++} ++ ++static void ++test_release_foreign_image_warns_without_crashing(void) ++{ ++ ++ ++ ++ ++ ErrorLog log = {0}; ++ Jbig2Ctx *ctx = jbig2_ctx_new(NULL, 0, NULL, record_error, &log); ++ Jbig2Image foreign = {0}; ++ int before_release = log.count; ++ ++ jbig2_release_page(ctx, &foreign); ++ ++ ASSERT_LOG_HAS_SEVERITY_FROM("foreign image warning callback", &log, before_release, JBIG2_SEVERITY_WARNING); ++ ASSERT_LOG_SEVERITY_COUNT_GE_FROM("foreign image warning callback count", &log, before_release, JBIG2_SEVERITY_WARNING, 1); ++ ASSERT_NO_SEVERITY_AT_OR_ABOVE_FROM("foreign image fatal callback count", &log, before_release, JBIG2_SEVERITY_FATAL); ++ ++ jbig2_ctx_free(ctx); ++} ++ ++static void ++test_two_contexts_keep_page_lifecycle_independent(void) ++{ ++ ++ ++ ++ ++ ErrorLog log_a = {0}; ++ ErrorLog log_b = {0}; ++ Jbig2Ctx *a = jbig2_ctx_new(NULL, 0, NULL, record_error, &log_a); ++ Jbig2Ctx *b = jbig2_ctx_new(NULL, 0, NULL, record_error, &log_b); ++ Jbig2Image *image_a; ++ Jbig2Image *image_b; ++ ++ ASSERT_INT("ctx a data_in", jbig2_data_in(a, one_page_stream, sizeof(one_page_stream)), 0); ++ ASSERT_INT("ctx a complete", jbig2_complete_page(a), 0); ++ image_a = jbig2_page_out(a); ++ ASSERT_UINT("ctx a page width", image_a == NULL ? 0 : image_a->width, 9); ++ ASSERT_UINT("ctx a page height", image_a == NULL ? 0 : image_a->height, 3); ++ ASSERT_NULL("ctx b page_out before own feed", jbig2_page_out(b)); ++ ++ ASSERT_NO_SEVERITY_AT_OR_ABOVE_FROM("ctx b warnings before own feed", &log_b, 0, JBIG2_SEVERITY_WARNING); ++ ++ ASSERT_INT("ctx b data_in", jbig2_data_in(b, two_page_stream, sizeof(two_page_stream)), 0); ++ ASSERT_INT("ctx b complete", jbig2_complete_page(b), 0); ++ image_b = jbig2_page_out(b); ++ ASSERT_UINT("ctx b first page width", image_b == NULL ? 0 : image_b->width, 9); ++ ASSERT_UINT("ctx b first page height", image_b == NULL ? 0 : image_b->height, 3); ++ ASSERT_UINT("ctx b first page stride", image_b == NULL ? 0 : image_b->stride, 2); ++ ++ jbig2_release_page(a, image_a); ++ jbig2_release_page(b, image_b); ++ image_b = jbig2_page_out(b); ++ ASSERT_UINT("ctx b second page width", image_b == NULL ? 0 : image_b->width, 17); ++ ASSERT_UINT("ctx b second page height", image_b == NULL ? 0 : image_b->height, 1); ++ ASSERT_UINT("ctx b second page stride", image_b == NULL ? 0 : image_b->stride, 3); ++ jbig2_release_page(b, image_b); ++ ++ jbig2_ctx_free(a); ++ jbig2_ctx_free(b); ++} ++ ++static void ++test_release_and_context_free_leave_allocator_empty_over_many_cycles(void) ++{ ++ ++ ++ ++ ++ TrackingAllocator tracker = new_tracking_allocator(); ++ int i; ++ ++ for (i = 0; i < 125; i++) { ++ ErrorLog log = {0}; ++ Jbig2Ctx *ctx = jbig2_ctx_new(&tracker.super, 0, NULL, record_error, &log); ++ Jbig2Image *image; ++ ++ if (ctx == NULL) { ++ FAIL_NOW("jbig2_ctx_new returned NULL"); ++ return; ++ } ++ ++ ASSERT_INT("cycle data_in", jbig2_data_in(ctx, one_page_stream, sizeof(one_page_stream)), 0); ++ ASSERT_INT("cycle complete_page", jbig2_complete_page(ctx), 0); ++ image = jbig2_page_out(ctx); ++ ASSERT_UINT("cycle page width", image == NULL ? 0 : image->width, 9); ++ ASSERT_UINT("cycle page height", image == NULL ? 0 : image->height, 3); ++ ASSERT_UINT("cycle page stride", image == NULL ? 0 : image->stride, 2); ++ jbig2_release_page(ctx, image); ++ jbig2_ctx_free(ctx); ++ } ++ ++ ASSERT_SIZE("active allocations after cycles", tracker.active_allocs, 0); ++ ASSERT_SIZE("active bytes after cycles", tracker.active_bytes, 0); ++ ++ ASSERT_SIZE_GE("peak allocations observed", tracker.peak_allocs, 1); ++ ASSERT_SIZE_GE("peak bytes observed", tracker.peak_bytes, 1); ++} ++ ++int ++main(void) ++{ ++ test_incremental_complete_page_and_single_page_handoff(); ++ test_complete_page_without_image_reports_fatal(); ++ test_unknown_length_pending_segment_warns_fails_and_advances(); ++ test_first_available_completed_page_order(); ++ test_release_null_twice_is_noop(); ++ test_release_foreign_image_warns_without_crashing(); ++ test_two_contexts_keep_page_lifecycle_independent(); ++ test_release_and_context_free_leave_allocator_empty_over_many_cycles(); ++ ++ if (failures != 0) { ++ fprintf(stderr, "%d acceptance assertion(s) failed\n", failures); ++ return 1; ++ } ++ ++ printf("page lifecycle acceptance tests passed\n"); ++ return 0; ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,24 @@ ++#!/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 ++ ++make -f Makefile.unix libjbig2dec.a >/dev/null ++ ++cc -std=c99 -Wall -Wextra -Werror=implicit-function-declaration \ ++ -I/workspace/repo \ ++ /workspace/repo/usercase-test-coderl/test_page_lifecycle.c \ ++ /workspace/repo/libjbig2dec.a \ ++ -o /tmp/usercase_test_coderl_page_lifecycle ++ ++exec /tmp/usercase_test_coderl_page_lifecycle diff --git a/tasks/format-code-task-000459/tests/test.sh b/tasks/format-code-task-000459/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e2ce78e89851907c8f1db5a79309f9ea1c0f1fc5 --- /dev/null +++ b/tasks/format-code-task-000459/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_page_lifecycle.c +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000459/tests/test_command.sh b/tasks/format-code-task-000459/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000459/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-000460/environment/Dockerfile b/tasks/format-code-task-000460/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..995790cd1dfeb9f298322dcc52356441deb5778b --- /dev/null +++ b/tasks/format-code-task-000460/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:24fd0fed60519d6f151c03f9b62f2b9f762fd42b227fe8134a4127dcdde78fc7 diff --git a/tasks/format-code-task-000460/environment/setup/setup.sh b/tasks/format-code-task-000460/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000460/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000460/tests/test.patch b/tasks/format-code-task-000460/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..57c1df74abf476fe575f33ac6936650ca692458a --- /dev/null +++ b/tasks/format-code-task-000460/tests/test.patch @@ -0,0 +1,1004 @@ +diff --git a/src/v2/Apps/Artist/Routes/Works/__tests__/Works.jest.tsx b/src/v2/Apps/Artist/Routes/Works/__tests__/Works.jest.tsx +index 68f7d34feb0..7a6b6ba8fc9 100644 +--- a/src/v2/Apps/Artist/Routes/Works/__tests__/Works.jest.tsx ++++ b/src/v2/Apps/Artist/Routes/Works/__tests__/Works.jest.tsx +@@ -22,6 +22,10 @@ jest.mock( + }) + ) + ++jest.mock("v2/Apps/Artist/Components/ArtistCollectionsRail", () => ({ ++ ArtistCollectionsRailContent: () =>
Mock ArtistCollections
, ++})) ++ + describe("Works Route", () => { + let trackEvent + beforeEach(() => { +@@ -119,7 +123,7 @@ describe("Works Route", () => { + }) + + describe("Artist Series Rail", () => { +- it("Displays artist series rail", async () => { ++ it("Displays artist series rail if data is present", async () => { + wrapper = await getWrapper("xl", defaultWorks) + expect(wrapper.find("ArtistSeriesRail").length).toBe(1) + expect(wrapper.find("ArtistSeriesItem").length).toBe(1) +@@ -128,9 +132,957 @@ describe("Works Route", () => { + ) + expect(wrapper.find("ArtistSeriesItem").text()).toContain("20 available") + }) ++ ++ it("Displays collections as a fallback if artist series data is not present", async () => { ++ wrapper = await getWrapper("xl", worksWithoutArtistSeries) ++ ++ expect(wrapper.find("ArtistSeriesRail").length).toBe(0) ++ expect(wrapper.html()).toContain("Mock ArtistCollections") ++ }) + }) + }) + ++const worksWithoutArtistSeries: Works_Test_QueryRawResponse = { ++ artist: { ++ slug: "slug-of-the-artist", ++ artistSeriesConnection: undefined, ++ filterArtworksConnection: { ++ edges: [ ++ { ++ node: { ++ id: "QXJ0d29yazo1ZGVjZDRiYjNjN2NiMTAwMTAwYWQzNmQ=", ++ slug: "andy-warhol-roy-lichtenstein-authenticated-3", ++ href: "/artwork/andy-warhol-roy-lichtenstein-authenticated-3", ++ image: { ++ aspectRatio: 1.0, ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/JS5CsvkO_SpL1Vg7R-h_Zw/large.jpg", ++ }, ++ imageTitle: "This Image Has a Title, A. Artist, 2020", ++ internalID: "5decd4bb3c7cb100100ad36d", ++ title: "Roy Lichtenstein (Authenticated)", ++ date: "1975", ++ sale_message: "$11,995", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Alpha 137 Gallery", ++ href: "/alpha-137-gallery", ++ id: "UGFydG5lcjo1NzQ4ZDE1M2NkNTMwZTJkNTEwMDAzMWM=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ ], ++ id: "12345-abde", ++ }, ++ internalID: "4d8b92b34eb68a1b2c0003f4", ++ related: { ++ artistsConnection: { ++ edges: [ ++ { ++ node: { ++ id: "relatedConnection123", ++ }, ++ }, ++ ], ++ }, ++ }, ++ sidebarAggregations: { ++ aggregations: [], ++ id: ++ "ZmlsdGVyQXJ0d29ya3NDb25uZWN0aW9uOnsiYWdncmVnYXRpb25zIjpbInRvdGFsIl0sImFydGlzdF9pZCI6IjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNCIsInBhZ2UiOjEsInNpemUiOjMwLCJzb3J0IjoiLXBhcnRuZXJfdXBkYXRlZF9hdCJ9", ++ }, ++ is_followed: true, ++ counts: { ++ partner_shows: 701, ++ for_sale_artworks: 2396, ++ ecommerce_artworks: 294, ++ auction_artworks: 3, ++ artworks: 4995, ++ has_make_offer_artworks: true, ++ }, ++ filtered_artworks: { ++ id: ++ "ZmlsdGVyQXJ0d29ya3NDb25uZWN0aW9uOnsiYWdncmVnYXRpb25zIjpbInRvdGFsIl0sImFydGlzdF9pZCI6IjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNCIsInBhZ2UiOjEsInNpemUiOjMwLCJzb3J0IjoiLXBhcnRuZXJfdXBkYXRlZF9hdCJ9", ++ aggregations: [], ++ pageInfo: { ++ hasNextPage: true, ++ endCursor: "YXJyYXljb25uZWN0aW9uOjI5", ++ }, ++ pageCursors: { ++ around: [ ++ { ++ cursor: "YXJyYXljb25uZWN0aW9uOi0x", ++ page: 1, ++ isCurrent: true, ++ }, ++ { ++ cursor: "YXJyYXljb25uZWN0aW9uOjI5", ++ page: 2, ++ isCurrent: false, ++ }, ++ { ++ cursor: "YXJyYXljb25uZWN0aW9uOjU5", ++ page: 3, ++ isCurrent: false, ++ }, ++ { ++ cursor: "YXJyYXljb25uZWN0aW9uOjg5", ++ page: 4, ++ isCurrent: false, ++ }, ++ ], ++ first: null, ++ last: { ++ cursor: "YXJyYXljb25uZWN0aW9uOjI5Njk=", ++ page: 100, ++ isCurrent: false, ++ }, ++ previous: null, ++ }, ++ edges: [ ++ { ++ id: "edge1", ++ node: { ++ id: "QXJ0d29yazo1ZGVjZDRiYjNjN2NiMTAwMTAwYWQzNmQ=", ++ slug: "andy-warhol-roy-lichtenstein-authenticated-3", ++ href: "/artwork/andy-warhol-roy-lichtenstein-authenticated-3", ++ image: { ++ aspect_ratio: 0.78, ++ placeholder: "127.67567567567568%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/JS5CsvkO_SpL1Vg7R-h_Zw/large.jpg", ++ }, ++ internalID: "5decd4bb3c7cb100100ad36d", ++ title: "Roy Lichtenstein (Authenticated)", ++ image_title: ++ "Andy Warhol, ‘Roy Lichtenstein (Authenticated)’, 1975", ++ date: "1975", ++ sale_message: "$11,995", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Alpha 137 Gallery", ++ href: "/alpha-137-gallery", ++ id: "UGFydG5lcjo1NzQ4ZDE1M2NkNTMwZTJkNTEwMDAzMWM=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge2", ++ node: { ++ id: "QXJ0d29yazo1ZGNmN2VmYmJmMTVhNDAwMGUxZDBlMTI=", ++ slug: "andy-warhol-gems-ii-dot-189-3", ++ href: "/artwork/andy-warhol-gems-ii-dot-189-3", ++ image: { ++ aspect_ratio: 1.39, ++ placeholder: "71.89988623435723%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/Mg_Szq4pq3bmkEXwEnjmuA/large.jpg", ++ }, ++ internalID: "5dcf7efbbf15a4000e1d0e12", ++ title: "Gems II.189", ++ image_title: "Andy Warhol, ‘Gems II.189’, 1978", ++ date: "1978", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Upsilon Gallery", ++ href: "/upsilon-gallery", ++ id: "UGFydG5lcjo1NzgzYmRhNjc2MjJkZDY1ZWQwMDAzNTU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge3", ++ node: { ++ id: "QXJ0d29yazo1ODExMDQxZTEzOWIyMTUyNGIwMDBjNGI=", ++ slug: "andy-warhol-jacqueline-kennedy-iii-jackie-iii-ii-dot-15", ++ href: ++ "/artwork/andy-warhol-jacqueline-kennedy-iii-jackie-iii-ii-dot-15", ++ image: { ++ aspect_ratio: 0.74, ++ placeholder: "135.50135501355015%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/3qTI5_FhJ5ifPO7irXMbNQ/large.jpg", ++ }, ++ internalID: "5811041e139b21524b000c4b", ++ title: "Jacqueline Kennedy III (Jackie III), II.15", ++ image_title: ++ "Andy Warhol, ‘Jacqueline Kennedy III (Jackie III), II.15’, 1966", ++ date: "1966", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge4", ++ node: { ++ id: "QXJ0d29yazo1ODExMDA0ZDhiMGMxNDFkZDQwMDBiNjE=", ++ slug: "andy-warhol-cow-ii-dot-12-31", ++ href: "/artwork/andy-warhol-cow-ii-dot-12-31", ++ image: { ++ aspect_ratio: 0.69, ++ placeholder: "145.83333333333331%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/TggVGbEkp8GPrxSRYyUrVw/large.jpg", ++ }, ++ internalID: "5811004d8b0c141dd4000b61", ++ title: "Cow, II.12", ++ image_title: "Andy Warhol, ‘Cow, II.12’, 1971", ++ date: "1971", ++ sale_message: "$32,500", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge5", ++ node: { ++ id: "QXJ0d29yazo1ODExMDU2OWM5ZGMyNDM0YWMwMDBhMjk=", ++ slug: "andy-warhol-myths-dracula-ii-dot-264", ++ href: "/artwork/andy-warhol-myths-dracula-ii-dot-264", ++ image: { ++ aspect_ratio: 1, ++ placeholder: "100%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/c_aIRDHlJCwgB2dG_eF_PQ/large.jpg", ++ }, ++ internalID: "58110569c9dc2434ac000a29", ++ title: "Myths: Dracula, II.264", ++ image_title: "Andy Warhol, ‘Myths: Dracula, II.264’, 1981", ++ date: "1981", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge6", ++ node: { ++ id: "QXJ0d29yazo1ODIxMTAwNTc2MjJkZDIzNGEwMDA0MmE=", ++ slug: "andy-warhol-brooklyn-bridge-ii-dot-290-3", ++ href: "/artwork/andy-warhol-brooklyn-bridge-ii-dot-290-3", ++ image: { ++ aspect_ratio: 1, ++ placeholder: "100%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/HMGsaVK6Qtbk_K1fYHorLA/large.jpg", ++ }, ++ internalID: "582110057622dd234a00042a", ++ title: "Brooklyn Bridge, II.290", ++ image_title: "Andy Warhol, ‘Brooklyn Bridge, II.290’, 1983", ++ date: "1983", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge7", ++ node: { ++ id: "QXJ0d29yazo1ODIxMTAwNmM5ZGMyNDc5ZjkwMDA0MTA=", ++ slug: "andy-warhol-camouflage-ii-dot-407-1", ++ href: "/artwork/andy-warhol-camouflage-ii-dot-407-1", ++ image: { ++ aspect_ratio: 0.99, ++ placeholder: "101.35135135135135%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/DRa8DoEBuc0kpCQyGMoNKQ/large.jpg", ++ }, ++ internalID: "58211006c9dc2479f9000410", ++ title: "Camouflage, II.407", ++ image_title: "Andy Warhol, ‘Camouflage, II.407’, 1987", ++ date: "1987", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge8", ++ node: { ++ id: "QXJ0d29yazo1ODI0Y2Y0NjljMThkYjMzM2IwMDAyNjk=", ++ slug: "andy-warhol-ads-mobil-ii-dot-350", ++ href: "/artwork/andy-warhol-ads-mobil-ii-dot-350", ++ image: { ++ aspect_ratio: 1, ++ placeholder: "100%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/Oca3XCWSXV8Y69wsea4syg/large.jpg", ++ }, ++ internalID: "5824cf469c18db333b000269", ++ title: "Ads: Mobil, II.350", ++ image_title: "Andy Warhol, ‘Ads: Mobil, II.350’, 1985", ++ date: "1985", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge9", ++ node: { ++ id: "QXJ0d29yazo1ODJmNTQ0Y2IyMDJhMzY1OTEwMDA0NDY=", ++ slug: "andy-warhol-c-and-i-general-custer-ii-dot-379", ++ href: "/artwork/andy-warhol-c-and-i-general-custer-ii-dot-379", ++ image: { ++ aspect_ratio: 0.97, ++ placeholder: "103.09278350515463%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/ns63fftmvkNS20XPzw8tkA/large.jpg", ++ }, ++ internalID: "582f544cb202a36591000446", ++ title: "C & I: General Custer, II.379", ++ image_title: "Andy Warhol, ‘C & I: General Custer, II.379’, 1986", ++ date: "1986", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge10", ++ node: { ++ id: "QXJ0d29yazo1ODJmNTQ0NGIyMDJhMzY1OTEwMDA0M2Q=", ++ slug: "andy-warhol-ingrid-bergman-herself-ii-dot-313", ++ href: "/artwork/andy-warhol-ingrid-bergman-herself-ii-dot-313", ++ image: { ++ aspect_ratio: 1, ++ placeholder: "100.06253908692932%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/60V9tKyNbvyoB6Ig9kIyzg/large.jpg", ++ }, ++ internalID: "582f5444b202a3659100043d", ++ title: "Ingrid Bergman - Herself, II.313", ++ image_title: ++ "Andy Warhol, ‘Ingrid Bergman - Herself, II.313’, 1983", ++ date: "1983", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge11", ++ node: { ++ id: "QXJ0d29yazo1ODJmNTQ0YzEzOWIyMTFlMzMwMDBiNzY=", ++ slug: "andy-warhol-c-and-i-plains-indian-shield", ++ href: "/artwork/andy-warhol-c-and-i-plains-indian-shield", ++ image: { ++ aspect_ratio: 1, ++ placeholder: "100%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/MUu9c36ksrSjuIb11blZ8Q/large.jpg", ++ }, ++ internalID: "582f544c139b211e33000b76", ++ title: "C & I: Plains Indian Shield", ++ image_title: "Andy Warhol, ‘C & I: Plains Indian Shield’, 1986", ++ date: "1986", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge12", ++ node: { ++ id: "QXJ0d29yazo1ODUwNThkMjc2MjJkZDBmZWMwMDAwN2Q=", ++ slug: "andy-warhol-querelle-iiia-dot-27-1", ++ href: "/artwork/andy-warhol-querelle-iiia-dot-27-1", ++ image: { ++ aspect_ratio: 1, ++ placeholder: "100%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/k5wi4CQMBFoRoHCqnhbwWQ/large.jpg", ++ }, ++ internalID: "585058d27622dd0fec00007d", ++ title: "Querelle (IIIA.27)", ++ image_title: "Andy Warhol, ‘Querelle (IIIA.27)’, ca. 1982", ++ date: "ca. 1982", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge13", ++ node: { ++ id: "QXJ0d29yazo1ODUwNThkMmEwOWE2Nzc0NGIwMDAwNzU=", ++ slug: "andy-warhol-love-variants", ++ href: "/artwork/andy-warhol-love-variants", ++ image: { ++ aspect_ratio: 0.75, ++ placeholder: "132.89036544850498%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/6HDNXBUYiBCtsDuMx07X9g/large.jpg", ++ }, ++ internalID: "585058d2a09a67744b000075", ++ title: "Love Variants", ++ image_title: "Andy Warhol, ‘Love Variants’, ca. 1982", ++ date: "ca. 1982", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge14", ++ node: { ++ id: "QXJ0d29yazo1ODUwNThkMzhiM2I4MTdkMTgwMDAwYTU=", ++ slug: "andy-warhol-poinsettias-10", ++ href: "/artwork/andy-warhol-poinsettias-10", ++ image: { ++ aspect_ratio: 0.69, ++ placeholder: "144.72361809045228%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/Uwn8oJOY3PXtl2KJUgSxNg/large.jpg", ++ }, ++ internalID: "585058d38b3b817d180000a5", ++ title: "Poinsettias", ++ image_title: "Andy Warhol, ‘Poinsettias’, ca. 1983", ++ date: "ca. 1983", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge15", ++ node: { ++ id: "QXJ0d29yazo1ODUwNThkNTJhODkzYTMxM2IwMDAwOTI=", ++ slug: "andy-warhol-poinsettias-15", ++ href: "/artwork/andy-warhol-poinsettias-15", ++ image: { ++ aspect_ratio: 0.7, ++ placeholder: "142%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/HrFQNiXkDcINNfv6xS0EUw/large.jpg", ++ }, ++ internalID: "585058d52a893a313b000092", ++ title: "Poinsettias", ++ image_title: "Andy Warhol, ‘Poinsettias’, ca. 1983", ++ date: "ca. 1983", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge16", ++ node: { ++ id: "QXJ0d29yazo1ODUwNThlM2IyMDJhMzJjZGYwMDAwOWM=", ++ slug: "andy-warhol-magazine-in-history-ii-dot-304a", ++ href: "/artwork/andy-warhol-magazine-in-history-ii-dot-304a", ++ image: { ++ aspect_ratio: 0.82, ++ placeholder: "122.19959266802445%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/csnOxZVPddRFlw4QdPu6KQ/large.jpg", ++ }, ++ internalID: "585058e3b202a32cdf00009c", ++ title: "Magazine In History, II.304A", ++ image_title: "Andy Warhol, ‘Magazine In History, II.304A’, 1983", ++ date: "1983", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge17", ++ node: { ++ id: "QXJ0d29yazo1ODUwNThmMjI3NWIyNDE0ZmMwMDAwYWY=", ++ slug: "andy-warhol-kiku-312", ++ href: "/artwork/andy-warhol-kiku-312", ++ image: { ++ aspect_ratio: 1.26, ++ placeholder: "79.08256880733944%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/Gi2KbjDgNeWwJHXgN5_jtg/large.jpg", ++ }, ++ internalID: "585058f2275b2414fc0000af", ++ title: "Kiku", ++ image_title: "Andy Warhol, ‘Kiku’, 1983", ++ date: "1983", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge18", ++ node: { ++ id: "QXJ0d29yazo1ODUwNThkNWM5ZGMyNDY1NzEwMDAwNjk=", ++ slug: "andy-warhol-sidewalk-ii-dot-304-21", ++ href: "/artwork/andy-warhol-sidewalk-ii-dot-304-21", ++ image: { ++ aspect_ratio: 1.49, ++ placeholder: "67.33333333333333%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/3767S8k6yWy9H5kPW069kA/large.jpg", ++ }, ++ internalID: "585058d5c9dc246571000069", ++ title: "Sidewalk, II.304", ++ image_title: "Andy Warhol, ‘Sidewalk, II.304’, 1983", ++ date: "1983", ++ sale_message: "Sold", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge19", ++ node: { ++ id: "QXJ0d29yazo1ODUwNThlYTc2MjJkZDBmYzQwMDAwOTA=", ++ slug: "andy-warhol-fish-iii-dot-39", ++ href: "/artwork/andy-warhol-fish-iii-dot-39", ++ image: { ++ aspect_ratio: 0.7, ++ placeholder: "143.1980906921241%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/F-5uuDFFarXNBLrBBrCUdQ/large.jpg", ++ }, ++ internalID: "585058ea7622dd0fc4000090", ++ title: "Fish, III.39", ++ image_title: "Andy Warhol, ‘Fish, III.39’, 1983", ++ date: "1983", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge20", ++ node: { ++ id: "QXJ0d29yazo1ODdmZjM2NjhiM2I4MTQyNDgwMDExMmE=", ++ slug: "andy-warhol-hammer-and-sickle-164", ++ href: "/artwork/andy-warhol-hammer-and-sickle-164", ++ image: { ++ aspect_ratio: 1.33, ++ placeholder: "75.33333333333333%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/cVksFVMa8Dmq_5nr6IbBww/large.jpg", ++ }, ++ internalID: "587ff3668b3b81424800112a", ++ title: "Hammer & Sickle (164)", ++ image_title: "Andy Warhol, ‘Hammer & Sickle (164)’, 1977", ++ date: "1977", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ { ++ id: "edge21", ++ node: { ++ id: "QXJ0d29yazo1ODdmZjM2Njc2MjJkZDIxZTQwMDExOWI=", ++ slug: "andy-warhol-hammer-and-sickle-169", ++ href: "/artwork/andy-warhol-hammer-and-sickle-169", ++ image: { ++ aspect_ratio: 1.56, ++ placeholder: "63.980582524271846%", ++ url: ++ "https://d32dm0rphc51dk.cloudfront.net/PBh3AUieRMnyEwmyJy8Q2g/large.jpg", ++ }, ++ internalID: "587ff3667622dd21e400119b", ++ title: "Hammer & Sickle", ++ image_title: "Andy Warhol, ‘Hammer & Sickle’, 1977", ++ date: "1977", ++ sale_message: "Contact For Price", ++ cultural_maker: null, ++ artists: [ ++ { ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ href: "/artist/andy-warhol", ++ name: "Andy Warhol", ++ }, ++ ], ++ collecting_institution: null, ++ partner: { ++ name: "Hamilton-Selway Fine Art", ++ href: "/hamilton-selway-fine-art", ++ id: "UGFydG5lcjo1MTc1NmRkOTUxMDljZGNmOGMwMDAwNzU=", ++ type: "Gallery", ++ }, ++ sale: null, ++ sale_artwork: null, ++ is_inquireable: true, ++ is_saved: false, ++ is_biddable: false, ++ }, ++ }, ++ ], ++ }, ++ id: "QXJ0aXN0OjRkOGI5MmIzNGViNjhhMWIyYzAwMDNmNA==", ++ }, ++} ++ + const defaultWorks: Works_Test_QueryRawResponse = { + artist: { + slug: "slug-of-the-artist", +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+3SPU/DMBAG4Mz9FVb32EmaDzF0KBsbYmG0EseigcaOfE4V8etxwlCEBF1aAeJ9 ++pMjn5Hy2cubN2B1aqc1RRNeSBFVRLGPweVzitMiSNE2LqtpEISiTTcSKq53og5F87RiLnLX+u7xz ++3/8ofuq/1+Slsn1fm5bT/nJ7nOt/Vuan/s/v07xMqogllzvC1/55/1XLlsY3ul0Z22oWx3oaLOn4 ++SYW4rydpw/2goVZaUveqt3lyUzIu5mTZ23Y8aBK86Yx4DmXCEmNjVav9XMmN5s7chusU4nmT+9rv ++w+O1M9s1OSWOmdgNA4md8x158WDHkCYerXshIeW8hKR8n/O5PPc0rVc//c8AAAAAAAAAAAAAAAAA ++AAAAAH6LN8EVhFIAKAAA +diff --git 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-000460/tests/test.sh b/tasks/format-code-task-000460/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7246465abfbb0cdef7173ae9400552786f6684b --- /dev/null +++ b/tasks/format-code-task-000460/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/v2/Apps/Artist/Routes/Works/__tests__/Works.jest.tsx +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-000460/tests/test_command.sh b/tasks/format-code-task-000460/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000460/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000469/environment/Dockerfile b/tasks/format-code-task-000469/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5f8220729d32e276ed2349254b9a149a741083ff --- /dev/null +++ b/tasks/format-code-task-000469/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6399d237c31c5d0a0b27f676a3cf57c2e9edc80ab1138c452dfc17683ecdc7eb diff --git a/tasks/format-code-task-000469/environment/setup/files/blocklist b/tasks/format-code-task-000469/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000469/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000469/environment/setup/setup.sh b/tasks/format-code-task-000469/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000469/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000469/tests/test.patch b/tasks/format-code-task-000469/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..965c1e4d8e317c5bed8f88ff82f4ad2124b7bf63 --- /dev/null +++ b/tasks/format-code-task-000469/tests/test.patch @@ -0,0 +1,132 @@ +diff --git a/tests/test_stopping.py b/tests/test_stopping.py +new file mode 100644 +index 00000000..793ddbe7 +--- /dev/null ++++ b/tests/test_stopping.py +@@ -0,0 +1,101 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import pandas as pd ++ ++import asreview as asr ++from asreview.models.query import RandomQuery ++from asreview.stopping import StoppingNConsecutiveIrrelevant ++ ++ ++def _results(labels): ++ ++ return pd.DataFrame({"label": labels}) ++ ++ ++def test_stops_on_trailing_run(): ++ stopper = StoppingNConsecutiveIrrelevant(3) ++ ++ assert stopper.stop(_results([1, 1, 0, 0, 0]), list(range(10))) is True ++ ++ ++def test_exact_run_length_triggers(): ++ stopper = StoppingNConsecutiveIrrelevant(2) ++ assert stopper.stop(_results([1, 0, 0]), list(range(10))) is True ++ ++ ++def test_does_not_stop_when_run_too_short(): ++ stopper = StoppingNConsecutiveIrrelevant(3) ++ ++ assert stopper.stop(_results([1, 0, 1, 0, 0]), list(range(10))) is False ++ ++ ++def test_run_must_be_contiguous_and_trailing(): ++ stopper = StoppingNConsecutiveIrrelevant(3) ++ ++ ++ assert stopper.stop(_results([0, 0, 1, 0, 0, 1]), list(range(10))) is False ++ ++ ++def test_scattered_irrelevant_does_not_count(): ++ stopper = StoppingNConsecutiveIrrelevant(3) ++ ++ assert stopper.stop(_results([0, 1, 0, 1, 0, 1, 0]), list(range(10))) is False ++ ++ ++def test_not_enough_labeled_does_not_stop(): ++ stopper = StoppingNConsecutiveIrrelevant(5) ++ ++ assert stopper.stop(_results([0, 0]), list(range(20))) is False ++ ++ ++def test_stops_when_pool_exhausted_even_with_relevant_tail(): ++ stopper = StoppingNConsecutiveIrrelevant(3) ++ ++ labels = [1, 0, 1, 0, 1] ++ assert stopper.stop(_results(labels), list(range(len(labels)))) is True ++ ++ ++def test_stops_when_pool_exhausted_below_threshold(): ++ stopper = StoppingNConsecutiveIrrelevant(10) ++ ++ labels = [1, 1, 0] ++ assert stopper.stop(_results(labels), list(range(len(labels)))) is True ++ ++ ++def test_empty_data_stops(): ++ stopper = StoppingNConsecutiveIrrelevant(3) ++ assert stopper.stop(_results([]), []) is True ++ ++ ++def test_returns_plain_bool(): ++ stopper = StoppingNConsecutiveIrrelevant(2) ++ result = stopper.stop(_results([0, 0]), list(range(10))) ++ assert isinstance(result, bool) ++ ++ ++def test_integration_with_active_learning_cycle_stops(): ++ cycle = asr.ActiveLearningCycle( ++ query_strategy=RandomQuery(), ++ stopping=StoppingNConsecutiveIrrelevant(3), ++ ) ++ assert cycle.stop(_results([1, 0, 0, 0]), list(range(10))) is True ++ ++ ++def test_integration_with_active_learning_cycle_continues(): ++ cycle = asr.ActiveLearningCycle( ++ query_strategy=RandomQuery(), ++ stopping=StoppingNConsecutiveIrrelevant(3), ++ ) ++ assert cycle.stop(_results([1, 0, 1, 0]), list(range(10))) is False +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++python -m pytest tests/test_metrics.py tests/test_data_store.py -q ++ ++ ++python -m pytest tests/test_stopping.py -q diff --git a/tasks/format-code-task-000469/tests/test.sh b/tasks/format-code-task-000469/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..05cdd40d449f35ec39c05ce1ed9a0c503e67eaa0 --- /dev/null +++ b/tasks/format-code-task-000469/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_stopping.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-000469/tests/test_command.sh b/tasks/format-code-task-000469/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000469/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000600/environment/Dockerfile b/tasks/format-code-task-000600/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..071473d67e5a74cccf805b07f2a3342417cc347a --- /dev/null +++ b/tasks/format-code-task-000600/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2fa2fa459165e7eb90f0d85857196f6846332ce8eb1a7fcdd505379e872709bd diff --git a/tasks/format-code-task-000600/environment/setup/files/blocklist b/tasks/format-code-task-000600/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000600/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000600/environment/setup/setup.sh b/tasks/format-code-task-000600/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000600/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000600/tests/test.patch b/tasks/format-code-task-000600/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..779261a02b2a62b718c24772b311a9eb354df394 --- /dev/null +++ b/tasks/format-code-task-000600/tests/test.patch @@ -0,0 +1,467 @@ +diff --git a/hidden/config_cli_test.go b/hidden/config_cli_test.go +new file mode 100644 +index 00000000..4fb024c3 +--- /dev/null ++++ b/hidden/config_cli_test.go +@@ -0,0 +1,431 @@ ++package hidden ++ ++import ( ++ "encoding/json" ++ "io/ioutil" ++ "net/http" ++ "net/http/httptest" ++ "os" ++ "os/exec" ++ "path/filepath" ++ "strings" ++ "sync" ++ "testing" ++ ++ "github.com/docker/docker/api/types" ++ "github.com/docker/docker/api/types/container" ++) ++ ++type packResult struct { ++ stdout string ++ stderr string ++ err error ++} ++ ++var ( ++ packBuildOnce sync.Once ++ packBuildPath string ++ packBuildErr error ++) ++ ++func repoRoot(t *testing.T) string { ++ t.Helper() ++ ++ dir, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("getting working directory: %v", err) ++ } ++ for { ++ if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil { ++ return dir ++ } ++ next := filepath.Dir(dir) ++ if next == dir { ++ t.Fatalf("could not find repo root from %s", dir) ++ } ++ dir = next ++ } ++} ++ ++func packBinary(t *testing.T) string { ++ t.Helper() ++ ++ packBuildOnce.Do(func() { ++ tmpDir, err := ioutil.TempDir("", "pack-hidden-bin") ++ if err != nil { ++ packBuildErr = err ++ return ++ } ++ packBuildPath = filepath.Join(tmpDir, "pack") ++ cmd := exec.Command("go", "build", "-buildvcs=false", "-o", packBuildPath, "./cmd/pack") ++ cmd.Dir = repoRoot(t) ++ out, err := cmd.CombinedOutput() ++ if err != nil { ++ packBuildErr = &commandError{err: err, output: string(out)} ++ } ++ }) ++ ++ if packBuildErr != nil { ++ t.Fatalf("building pack CLI: %v", packBuildErr) ++ } ++ return packBuildPath ++} ++ ++type commandError struct { ++ err error ++ output string ++} ++ ++func (e *commandError) Error() string { ++ return e.err.Error() + "\n" + e.output ++} ++ ++func runPack(t *testing.T, packHome string, extraEnv []string, args ...string) packResult { ++ t.Helper() ++ ++ cmdArgs := append([]string{"--no-color"}, args...) ++ cmd := exec.Command(packBinary(t), cmdArgs...) ++ cmd.Dir = repoRoot(t) ++ cmd.Env = append(os.Environ(), "PACK_HOME="+packHome) ++ cmd.Env = append(cmd.Env, extraEnv...) ++ ++ out, err := cmd.CombinedOutput() ++ output := string(out) ++ return packResult{ ++ stdout: output, ++ stderr: output, ++ err: err, ++ } ++} ++ ++func writeConfig(t *testing.T, packHome, body string) { ++ t.Helper() ++ ++ if err := os.MkdirAll(packHome, 0755); err != nil { ++ t.Fatalf("creating PACK_HOME: %v", err) ++ } ++ if err := ioutil.WriteFile(filepath.Join(packHome, "config.toml"), []byte(body), 0644); err != nil { ++ t.Fatalf("writing config: %v", err) ++ } ++} ++ ++func assertContains(t *testing.T, got, want string) { ++ t.Helper() ++ if !strings.Contains(got, want) { ++ t.Fatalf("expected output to contain %q, got:\n%s", want, got) ++ } ++} ++ ++func assertNotContains(t *testing.T, got, unwanted string) { ++ t.Helper() ++ if strings.Contains(got, unwanted) { ++ t.Fatalf("expected output not to contain %q, got:\n%s", unwanted, got) ++ } ++} ++ ++func assertOutputNotEmpty(t *testing.T, got string) { ++ t.Helper() ++ if strings.TrimSpace(got) == "" { ++ t.Fatalf("expected command to produce output") ++ } ++} ++ ++func readConfigFile(t *testing.T, packHome string) string { ++ t.Helper() ++ ++ body, err := ioutil.ReadFile(filepath.Join(packHome, "config.toml")) ++ if os.IsNotExist(err) { ++ return "" ++ } ++ if err != nil { ++ t.Fatalf("reading config: %v", err) ++ } ++ return string(body) ++} ++ ++func newPackHome(t *testing.T) string { ++ t.Helper() ++ ++ dir, err := ioutil.TempDir("", "pack-home") ++ if err != nil { ++ t.Fatalf("creating temporary PACK_HOME: %v", err) ++ } ++ t.Cleanup(func() { ++ _ = os.RemoveAll(dir) ++ }) ++ return dir ++} ++ ++func fakeDockerHost(t *testing.T, found bool) string { ++ t.Helper() ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ switch { ++ case strings.HasSuffix(r.URL.Path, "/info"): ++ _ = json.NewEncoder(w).Encode(types.Info{OSType: "linux"}) ++ case strings.Contains(r.URL.Path, "/images/") && strings.HasSuffix(r.URL.Path, "/json"): ++ if !found { ++ http.NotFound(w, r) ++ return ++ } ++ _ = json.NewEncoder(w).Encode(types.ImageInspect{ ++ ID: "sha256:1111111111111111111111111111111111111111111111111111111111111111", ++ Architecture: "amd64", ++ Os: "linux", ++ Config: &container.Config{Labels: map[string]string{ ++ "io.buildpacks.builder.metadata": `{"description":"hidden local builder","buildpacks":[],"stack":{"runImage":{"image":"example.com/run-image","mirrors":[]}},"lifecycle":{"version":"0.0.1","api":{"buildpack":"0.2","platform":"0.3"}}}`, ++ "io.buildpacks.stack.id": "hidden.stack.id", ++ "io.buildpacks.stack.mixins": "[]", ++ "io.buildpacks.buildpack.order": "[]", ++ "io.buildpacks.buildpack.layers": "{}", ++ }}, ++ RootFS: types.RootFS{Type: "layers"}, ++ }) ++ default: ++ http.NotFound(w, r) ++ } ++ })) ++ t.Cleanup(server.Close) ++ return "tcp://" + strings.TrimPrefix(server.URL, "http://") ++} ++ ++func fakeMissingRegistry(t *testing.T) string { ++ t.Helper() ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ if r.URL.Path == "/v2/" || r.URL.Path == "/v2" { ++ w.WriteHeader(http.StatusOK) ++ return ++ } ++ http.NotFound(w, r) ++ })) ++ t.Cleanup(server.Close) ++ return strings.TrimPrefix(server.URL, "http://") ++} ++ ++func TestConfigDefaultBuilderCLI_ListShowsExistingDefault(t *testing.T) { ++ packHome := newPackHome(t) ++ builder := "example.com/hidden/list-builder:one" ++ writeConfig(t, packHome, "default-builder-image = \""+builder+"\"\n") ++ ++ result := runPack(t, packHome, nil, "config", "default-builder") ++ if result.err != nil { ++ t.Fatalf("pack config default-builder failed: %v\n%s", result.err, result.stderr) ++ } ++ ++ assertContains(t, result.stdout, builder) ++} ++ ++func TestConfigDefaultBuilderCLI_ListWhenUnsetShowsGuidance(t *testing.T) { ++ packHome := newPackHome(t) ++ ++ result := runPack(t, packHome, nil, "config", "default-builder") ++ if result.err != nil { ++ t.Fatalf("pack config default-builder failed: %v\n%s", result.err, result.stderr) ++ } ++ ++ assertOutputNotEmpty(t, result.stdout) ++} ++ ++func TestConfigDefaultBuilderCLI_SetPersistsWhenBuilderExistsLocally(t *testing.T) { ++ packHome := newPackHome(t) ++ builder := "example.com/hidden/local-builder:one" ++ env := []string{"DOCKER_HOST=" + fakeDockerHost(t, true)} ++ ++ result := runPack(t, packHome, env, "config", "default-builder", builder) ++ if result.err != nil { ++ t.Fatalf("pack config default-builder %s failed: %v\n%s", builder, result.err, result.stderr) ++ } ++ list := runPack(t, packHome, nil, "config", "default-builder") ++ if list.err != nil { ++ t.Fatalf("listing default builder after set failed: %v\n%s", list.err, list.stderr) ++ } ++ assertContains(t, list.stdout, builder) ++} ++ ++func TestConfigDefaultBuilderCLI_MissingBuilderFailsWithoutChangingExistingDefault(t *testing.T) { ++ packHome := newPackHome(t) ++ originalBuilder := "example.com/hidden/original-builder:one" ++ missingBuilder := fakeMissingRegistry(t) + "/hidden/missing-builder:one" ++ writeConfig(t, packHome, "default-builder-image = \""+originalBuilder+"\"\n") ++ ++ env := []string{"DOCKER_HOST=" + fakeDockerHost(t, false)} ++ result := runPack(t, packHome, env, "config", "default-builder", missingBuilder) ++ if result.err == nil { ++ t.Fatalf("expected setting a missing builder to fail, got success:\n%s", result.stdout) ++ } ++ ++ list := runPack(t, packHome, nil, "config", "default-builder") ++ if list.err != nil { ++ t.Fatalf("listing default builder after failed set failed: %v\n%s", list.err, list.stderr) ++ } ++ assertContains(t, list.stdout, originalBuilder) ++ assertNotContains(t, list.stdout, missingBuilder) ++} ++ ++func TestConfigDefaultBuilderCLI_UnsetClearsExistingDefaultWithLongAndShortFlags(t *testing.T) { ++ for _, flag := range []string{"--unset", "-u"} { ++ t.Run(flag, func(t *testing.T) { ++ packHome := newPackHome(t) ++ builder := "example.com/hidden/unset-builder-" + strings.TrimLeft(flag, "-") + ":one" ++ writeConfig(t, packHome, "default-builder-image = \""+builder+"\"\n") ++ ++ result := runPack(t, packHome, nil, "config", "default-builder", flag) ++ if result.err != nil { ++ t.Fatalf("pack config default-builder %s failed: %v\n%s", flag, result.err, result.stderr) ++ } ++ ++ assertOutputNotEmpty(t, result.stdout) ++ assertNotContains(t, readConfigFile(t, packHome), builder) ++ ++ list := runPack(t, packHome, nil, "config", "default-builder") ++ if list.err != nil { ++ t.Fatalf("listing after unset failed: %v\n%s", list.err, list.stderr) ++ } ++ assertOutputNotEmpty(t, list.stdout) ++ assertNotContains(t, list.stdout, builder) ++ }) ++ } ++} ++ ++func TestConfigDefaultBuilderCLI_UnsetWhenEmptyReportsNoop(t *testing.T) { ++ packHome := newPackHome(t) ++ ++ result := runPack(t, packHome, nil, "config", "default-builder", "--unset") ++ if result.err != nil { ++ t.Fatalf("pack config default-builder --unset failed: %v\n%s", result.err, result.stderr) ++ } ++ ++ assertOutputNotEmpty(t, result.stdout) ++ ++ list := runPack(t, packHome, nil, "config", "default-builder") ++ if list.err != nil { ++ t.Fatalf("listing after empty unset failed: %v\n%s", list.err, list.stderr) ++ } ++ assertOutputNotEmpty(t, list.stdout) ++} ++ ++func newCustomPackHome(t *testing.T, pattern string) string { ++ t.Helper() ++ ++ dir, err := ioutil.TempDir("", pattern) ++ if err != nil { ++ t.Fatalf("creating custom temporary PACK_HOME: %v", err) ++ } ++ t.Cleanup(func() { ++ _ = os.RemoveAll(dir) ++ }) ++ return dir ++} ++ ++func TestConfigDefaultBuilderCLI_ListWhenUnsetShowsGuidanceOutsidePackHomePath(t *testing.T) { ++ packHome := newCustomPackHome(t, "config-home") ++ ++ result := runPack(t, packHome, nil, "config", "default-builder") ++ if result.err != nil { ++ t.Fatalf("pack config default-builder failed: %v\n%s", result.err, result.stderr) ++ } ++ ++ assertOutputNotEmpty(t, result.stdout) ++} ++ ++func TestConfigDefaultBuilderCLI_SetPersistsDifferentValidBuilder(t *testing.T) { ++ packHome := newPackHome(t) ++ builder := "example.com/hidden/alternate-local-builder:two" ++ env := []string{"DOCKER_HOST=" + fakeDockerHost(t, true)} ++ ++ result := runPack(t, packHome, env, "config", "default-builder", builder) ++ if result.err != nil { ++ t.Fatalf("pack config default-builder %s failed: %v\n%s", builder, result.err, result.stderr) ++ } ++ ++ list := runPack(t, packHome, nil, "config", "default-builder") ++ if list.err != nil { ++ t.Fatalf("listing default builder after set failed: %v\n%s", list.err, list.stderr) ++ } ++ assertContains(t, list.stdout, builder) ++} ++ ++func TestConfigDefaultBuilderCLI_MissingDifferentBuilderFailsWithoutChangingExistingDefault(t *testing.T) { ++ packHome := newPackHome(t) ++ originalBuilder := "example.com/hidden/original-builder:two" ++ missingBuilder := fakeMissingRegistry(t) + "/other/missing-builder:two" ++ writeConfig(t, packHome, "default-builder-image = \""+originalBuilder+"\"\n") ++ ++ env := []string{"DOCKER_HOST=" + fakeDockerHost(t, false)} ++ result := runPack(t, packHome, env, "config", "default-builder", missingBuilder) ++ if result.err == nil { ++ t.Fatalf("expected setting a missing builder to fail, got success:\n%s", result.stdout) ++ } ++ ++ list := runPack(t, packHome, nil, "config", "default-builder") ++ if list.err != nil { ++ t.Fatalf("listing default builder after failed set failed: %v\n%s", list.err, list.stderr) ++ } ++ assertContains(t, list.stdout, originalBuilder) ++ assertNotContains(t, list.stdout, missingBuilder) ++} ++ ++func TestConfigDefaultBuilderCLI_UnsetClearsDifferentExistingDefault(t *testing.T) { ++ packHome := newPackHome(t) ++ builder := "example.com/hidden/clear-me-different:one" ++ writeConfig(t, packHome, "default-builder-image = \""+builder+"\"\n") ++ ++ result := runPack(t, packHome, nil, "config", "default-builder", "--unset") ++ if result.err != nil { ++ t.Fatalf("pack config default-builder --unset failed: %v\n%s", result.err, result.stderr) ++ } ++ assertOutputNotEmpty(t, result.stdout) ++ assertNotContains(t, readConfigFile(t, packHome), builder) ++ ++ list := runPack(t, packHome, nil, "config", "default-builder") ++ if list.err != nil { ++ t.Fatalf("listing after unset failed: %v\n%s", list.err, list.stderr) ++ } ++ assertOutputNotEmpty(t, list.stdout) ++ assertNotContains(t, list.stdout, builder) ++} ++ ++func TestConfigDefaultBuilderCLI_UnsetWhenEmptyReportsNoopOutsidePackHomePath(t *testing.T) { ++ packHome := newCustomPackHome(t, "config-home") ++ ++ result := runPack(t, packHome, nil, "config", "default-builder", "--unset") ++ if result.err != nil { ++ t.Fatalf("pack config default-builder --unset failed: %v\n%s", result.err, result.stderr) ++ } ++ ++ assertOutputNotEmpty(t, result.stdout) ++} ++ ++func TestConfigTrustedBuildersCLI_AliasesCoverListAndMutatingSubcommands(t *testing.T) { ++ packHome := newPackHome(t) ++ builder := "example.com/hidden/trusted-alias-builder:one" ++ ++ add := runPack(t, packHome, nil, "config", "trust-builder", "add", builder) ++ if add.err != nil { ++ t.Fatalf("trust-builder add failed: %v\n%s", add.err, add.stderr) ++ } ++ ++ listAfterAdd := runPack(t, packHome, nil, "config", "trusted-builders") ++ if listAfterAdd.err != nil { ++ t.Fatalf("trusted-builders list after alias add failed: %v\n%s", listAfterAdd.err, listAfterAdd.stderr) ++ } ++ assertContains(t, listAfterAdd.stdout, builder) ++ ++ aliasList := runPack(t, packHome, nil, "config", "trust-builders") ++ if aliasList.err != nil { ++ t.Fatalf("trust-builders list failed: %v\n%s", aliasList.err, aliasList.stderr) ++ } ++ assertContains(t, aliasList.stdout, builder) ++ ++ remove := runPack(t, packHome, nil, "config", "trust-builders", "remove", builder) ++ if remove.err != nil { ++ t.Fatalf("trust-builders remove failed: %v\n%s", remove.err, remove.stderr) ++ } ++ ++ listAfterRemove := runPack(t, packHome, nil, "config", "trusted-builders") ++ if listAfterRemove.err != nil { ++ t.Fatalf("trusted-builders list after alias remove failed: %v\n%s", listAfterRemove.err, listAfterRemove.stderr) ++ } ++ assertNotContains(t, listAfterRemove.stdout, builder) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++if ! id testuser >/dev/null 2>&1; then ++ useradd -m testuser ++fi ++ ++chmod -R a+rwX /root/go/pkg/mod 2>/dev/null || true ++chmod -R a+rwX /testbed 2>/dev/null || true ++ ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 ./cmd ++ ;; ++ new) ++ go test -v -count=1 ./hidden ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000600/tests/test.sh b/tasks/format-code-task-000600/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3cbfea9852d68cb7136a9a67f58b8c38632f5b42 --- /dev/null +++ b/tasks/format-code-task-000600/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' +hidden/config_cli_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-000600/tests/test_command.sh b/tasks/format-code-task-000600/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000600/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-000607/environment/Dockerfile b/tasks/format-code-task-000607/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8623737642577569af8c3df839f0423d113d90fa --- /dev/null +++ b/tasks/format-code-task-000607/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4f33d287c6284088c946f79499d022fdf89ed4ab3c583fdcfede9bc213781a36 diff --git a/tasks/format-code-task-000607/environment/setup/files/blocklist b/tasks/format-code-task-000607/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000607/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000607/environment/setup/setup.sh b/tasks/format-code-task-000607/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000607/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000607/tests/test.patch b/tasks/format-code-task-000607/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9df463098e4811cb0a81d3047258f61478147f1 --- /dev/null +++ b/tasks/format-code-task-000607/tests/test.patch @@ -0,0 +1,268 @@ +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,242 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC NO_COLOR=1 ++ ++export GOPROXY=off GOSUMDB=off GOTOOLCHAIN=local ++ ++( cd /workspace/repo/app && make build ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=/workspace/repo/app/build/devcockpit ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++ ++fail() { ++ echo "FAIL: $*" >&2 ++ exit 1 ++} ++ ++repeat_char() { ++ local count=$1 char=$2 out="" ++ local i ++ for ((i = 0; i < count; i++)); do ++ out="${out}${char}" ++ done ++ printf '%s' "$out" ++} ++ ++normalize_text() { ++ ++ ++ sed -E $'s/\x1B\\[[0-9;?]*[ -/]*[@-~]//g; s/[[:space:]]*$//' "$1" ++} ++ ++assert_table_shape() { ++ local fixture=$1 ++ normalize_text out >out.norm ++ ++ ++ grep -Fx "Dev Cockpit ${EM_DASH} Cache Sizes" out.norm >/dev/null \ ++ || fail "$fixture missing mandated cache-size heading" ++ grep -E 'CACHE[[:space:]]+SIZE' out.norm >/dev/null \ ++ || fail "$fixture missing CACHE/SIZE columns" ++ grep -E "[-${HLINE}]{5,}" out.norm >/dev/null \ ++ || fail "$fixture missing separator line" ++} ++ ++assert_table_row() { ++ local fixture=$1 label_regex=$2 size=$3 ++ grep -E "${label_regex}.*[[:space:]]+${size//./\\.}([[:space:]]*)$" out.norm >/dev/null \ ++ || fail "$fixture missing row matching /$label_regex/ with size $size" ++} ++ ++assert_no_table_row() { ++ local fixture=$1 label_regex=$2 ++ ! grep -E "$label_regex" out.norm >/dev/null \ ++ || fail "$fixture unexpectedly printed row matching /$label_regex/" ++} ++ ++assert_total_row() { ++ local fixture=$1 size=$2 ++ local last ++ last=$(awk 'NF { line=$0 } END { print line }' out.norm) ++ [[ "$last" =~ Total ]] || fail "$fixture final non-empty row is not Total: $last" ++ [[ "$last" =~ $size ]] || fail "$fixture Total row does not contain $size: $last" ++} ++ ++assert_empty_stderr() { ++ local fixture=$1 ++ [ ! -s err ] || fail "$fixture unexpected stderr: $(cat err)" ++} ++ ++EM_DASH=$(printf '\342\200\224') ++HLINE=$(printf '\342\224\200') ++ARROW=$(printf '\342\206\222') ++HEADER_RULE=$(repeat_char 25 "$HLINE") ++TABLE_RULE=$(repeat_char 40 "$HLINE") ++ ++ ++ ++ ++mkdir -p f1/home/.cache f1/home/.npm/_cacache f1/home/.cache/yarn f1/home/go/pkg/mod/cache \ ++ f1/home/.cache/pip f1/home/.gradle/caches f1/home/.m2/repository f1/home/.docker f1/bin ++cat >f1/bin/du <<'DU' ++#!/usr/bin/env bash ++# ++# the last argument instead of coupling to gold's exact argv shape. ++path="${@: -1}" ++case "$path" in ++ */.cache) echo "0 $path" ;; ++ */.npm/_cacache) echo "1 $path" ;; ++ */.cache/yarn) echo "1536 $path" ;; ++ */go/pkg/mod/cache) echo "2048 $path" ;; ++ */.cache/pip) echo "1048576 $path" ;; ++ */.gradle/caches) echo "1572864 $path" ;; ++ */.m2/repository) echo "5242880 $path" ;; ++ */.docker) echo "6291456 $path" ;; ++ *) echo "0 $path" ;; ++esac ++DU ++chmod +x f1/bin/du ++HOME="$TMP/f1/home" PATH="$TMP/f1/bin:$PATH" "$BIN" cleanup list >out 2>err ++ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++ ++assert_table_shape F1 ++assert_table_row F1 'User[[:space:]]+Cache' '0 B' ++assert_table_row F1 'npm[[:space:]]+Cache' '1.0 KB' ++assert_table_row F1 'Yarn[[:space:]]+Cache' '1.5 MB' ++assert_table_row F1 'Go[[:space:]]+Module[[:space:]]+Cache' '2.0 MB' ++assert_table_row F1 'pip[[:space:]]+Cache' '1.0 GB' ++assert_table_row F1 'Gradle[[:space:]]+Cache' '1.5 GB' ++assert_table_row F1 'Maven[[:space:]]+Cache' '5.0 GB' ++assert_table_row F1 'Docker' '6.0 GB' ++assert_total_row F1 '13.5 GB' ++assert_empty_stderr F1 ++ ++ ++ ++ ++mkdir -p f2/home/.npm/_cacache f2/bin ++cat >f2/bin/du <<'DU' ++#!/usr/bin/env bash ++# ++# the last argument instead of coupling to gold's exact argv shape. ++path="${@: -1}" ++echo "du: cannot read $path" >&2 ++exit 2 ++DU ++chmod +x f2/bin/du ++HOME="$TMP/f2/home" PATH="$TMP/f2/bin:$PATH" "$BIN" cleanup list >out 2>err ++ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++ ++assert_table_shape F2 ++assert_table_row F2 'npm[[:space:]]+Cache' '0 B' ++assert_no_table_row F2 'User[[:space:]]+Cache' ++assert_no_table_row F2 'Yarn[[:space:]]+Cache' ++assert_no_table_row F2 'Go[[:space:]]+Module[[:space:]]+Cache' ++assert_no_table_row F2 'pip[[:space:]]+Cache' ++assert_no_table_row F2 'Gradle[[:space:]]+Cache' ++assert_no_table_row F2 'Maven[[:space:]]+Cache' ++assert_no_table_row F2 'Docker' ++assert_total_row F2 '0 B' ++assert_empty_stderr F2 ++ ++ ++ ++ ++HOME= "$BIN" cleanup list >out 2>err ++ec=$? ++[ "$ec" -eq 1 ] || fail "F3 exit $ec; want 1" ++EXPECTED_ERR='Error: Cannot determine home directory' ++[ "$(normalize_text err)" = "$EXPECTED_ERR" ] || fail "F3 stderr: $(cat err)" ++ ++ ++ ++ ++"$BIN" --help >out 2>err ++ec=$? ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_empty_stderr F4 ++grep -Fx ' devcockpit cleanup list Show cache sizes' out >/dev/null \ ++ || { ++ ++ ++ awk '/^CLI COMMANDS:/ { in_commands=1; next } /^EXAMPLES:/ { in_commands=0 } in_commands' out \ ++ | grep -E 'devcockpit[[:space:]]+cleanup[[:space:]]+list.*(cache|size)' >/dev/null \ ++ || fail "F4 missing cleanup list command in help" ++ } ++grep -Fx ' devcockpit cleanup list # See cache sizes' out >/dev/null \ ++ || { ++ ++ ++ awk '/^EXAMPLES:/ { in_examples=1; next } /^CONFIGURATION:/ { in_examples=0 } in_examples' out \ ++ | grep -E 'devcockpit[[:space:]]+cleanup[[:space:]]+list' >/dev/null \ ++ || fail "F4 missing cleanup list example in help" ++ } ++ ++ ++ ++ ++mkdir -p f5/home/.cache f5/home/.npm/_cacache f5/home/.cache/yarn f5/bin ++cat >f5/bin/du <<'DU' ++#!/usr/bin/env bash ++# ++# the last argument instead of coupling to gold's exact argv shape. ++path="${@: -1}" ++case "$path" in ++ */.cache|*/.npm/_cacache|*/.cache/yarn) echo "2097152 $path" ;; ++ *) echo "0 $path" ;; ++esac ++DU ++chmod +x f5/bin/du ++ ++ ++ ++cat >f5/bin/dig <<'DIG' ++#!/usr/bin/env bash ++echo "127.0.0.1" ++DIG ++cat >f5/bin/ip <<'IP' ++#!/usr/bin/env bash ++echo "default via 127.0.0.1 dev lo" ++IP ++cat >f5/bin/ping <<'PING' ++#!/usr/bin/env bash ++echo "rtt min/avg/max/mdev = 0.026/0.026/0.026/0.000 ms" ++PING ++cat >f5/bin/ufw <<'UFW' ++#!/usr/bin/env bash ++echo "Status: active" ++UFW ++cat >f5/bin/brew <<'BREW' ++#!/usr/bin/env bash ++exit 127 ++BREW ++chmod +x f5/bin/dig f5/bin/ip f5/bin/ping f5/bin/ufw f5/bin/brew ++HOME="$TMP/f5/home" PATH="$TMP/f5/bin:$PATH" "$BIN" diag >out 2>err ++ec=$? ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++assert_empty_stderr F5 ++grep -F "Storage WARN 3 caches, 6.0 GB total ${EM_DASH} 3 over 1 GB" out >/dev/null \ ++ || { ++ ++ ++ grep -E 'Storage.*(WARN|Warning|warn|warning|cache)' out >/dev/null \ ++ || fail "F5 missing storage diagnostics output for large caches" ++ } ++grep -F "${ARROW} Run 'devcockpit cleanup list' for details" out >/dev/null \ ++ || { ++ ++ ++ grep -F "devcockpit cleanup list" out >/dev/null \ ++ || fail "F5 missing cleanup list diagnostics suggestion" ++ } ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000607/tests/test.sh b/tasks/format-code-task-000607/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000607/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-000607/tests/test_command.sh b/tasks/format-code-task-000607/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000607/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-000609/environment/Dockerfile b/tasks/format-code-task-000609/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c5a5ceaff35485f200390e52a19b10a852fff5be --- /dev/null +++ b/tasks/format-code-task-000609/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:30ed34ae12acafacf63956e750963607d87a4559895885891ab05772281ea73d diff --git a/tasks/format-code-task-000609/environment/setup/files/blocklist b/tasks/format-code-task-000609/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000609/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000609/environment/setup/setup.sh b/tasks/format-code-task-000609/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000609/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000609/tests/test.patch b/tasks/format-code-task-000609/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..28f4d1280bcde9fb0f95a18eee55d440ca7e19af --- /dev/null +++ b/tasks/format-code-task-000609/tests/test.patch @@ -0,0 +1,118 @@ +diff --git a/tests/test_preprocess_data_sources.py b/tests/test_preprocess_data_sources.py +index ae9598da4..a250f04c5 100644 +--- a/tests/test_preprocess_data_sources.py ++++ b/tests/test_preprocess_data_sources.py +@@ -2,6 +2,7 @@ + + import pandas as pd + import pytest ++import xarray as xr + + import calliope + from calliope.preprocess import data_tables +@@ -354,6 +355,65 @@ def test_drop_one(self, table_obj): + ) + + ++class TestDataTableRenameDims: ++ @pytest.fixture(scope="class") ++ def multi_row_one_col_data(self, data_dir, init_config, dummy_int): ++ """Fixture to create the xarray dataset from the data table, including dimension name mapping.""" ++ ++ def _multi_row_one_col_data( ++ mapping: dict, new_idx: list, new_cols: list ++ ) -> xr.Dataset: ++ df = pd.DataFrame( ++ {"foo": {("bar1", "bar2"): 0, ("baz1", "baz2"): dummy_int}} ++ ) ++ filepath = data_dir / "multi_row_one_col_file.csv" ++ df.rename_axis( ++ index=["test_row1", "test_row2"], columns=["test_col"] ++ ).to_csv(filepath) ++ table_dict: data_tables.DataTableDict = { ++ "data": filepath.as_posix(), ++ "rows": new_idx, ++ "columns": new_cols, ++ "add_dims": {"parameters": "test_param"}, ++ "rename_dims": mapping, ++ } ++ ds = data_tables.DataTable(init_config, "ds_name", table_dict) ++ return ds.dataset ++ ++ return _multi_row_one_col_data ++ ++ def test_fails_without_rename(self, dummy_int, multi_row_one_col_data): ++ """Test that without dimension name mapping, the dataframe doesn't load successfully.""" ++ with pytest.raises(calliope.exceptions.ModelError) as excinfo: ++ multi_row_one_col_data({}, ["foobar", "test_row2"], ["test_col"]) ++ assert check_error_or_warning( ++ excinfo, ++ "Trying to set names for index but names in the file do no match names provided | " ++ "in file: ['test_row1', 'test_row2'] | defined: ['foobar', 'test_row2'].", ++ ) ++ ++ @pytest.mark.parametrize( ++ ("mapping", "idx", "col"), ++ [ ++ ({"test_row1": "foobar"}, ["foobar", "test_row2"], ["test_col"]), ++ ( ++ {"test_row1": "foobar", "test_col": "foobaz"}, ++ ["foobar", "test_row2"], ++ ["foobaz"], ++ ), ++ ], ++ ) ++ def test_rename(self, dummy_int, multi_row_one_col_data, mapping, idx, col): ++ """Test that dimension name mapping propagates through from the initial dataframe to the final dataset.""" ++ dataset = multi_row_one_col_data(mapping, idx, col) ++ assert not any(k in dataset.dims for k in mapping.keys()) ++ assert all(v in dataset.dims for v in mapping.values()) ++ assert ( ++ dataset["test_param"].sel(foobar="baz1", test_row2="baz2").item() ++ == dummy_int ++ ) ++ ++ + class TestDataTableMalformed: + @pytest.fixture(scope="class") + def table_obj(self, init_config): +@@ -450,7 +510,7 @@ def test_carrier_info_dict_from_model_data_var(self, table_obj, param, expected) + def test_carrier_info_dict_from_model_data_var_missing_dim(self, table_obj): + with pytest.raises(calliope.exceptions.ModelError) as excinfo: + table_obj.lookup_dict_from_param("FOO", "foobar") +- check_error_or_warning( ++ assert check_error_or_warning( + excinfo, + "Loading FOO with missing dimension(s). Must contain `techs` and `foobar`, received: ('techs', 'carriers')", + ) +@@ -604,7 +664,7 @@ def test_transmission_tech_with_nodes(self, table_obj): + with pytest.raises(calliope.exceptions.ModelError) as excinfo: + table_obj(df_dict).node_dict(tech_dict) + +- check_error_or_warning( ++ assert check_error_or_warning( + excinfo, + "Cannot define transmission technology data over the `nodes` dimension", + ) +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+3S0WqDMBQGYK/7FOeuV3HGVguFPYukyWHKao4ksdC3X+pgG4OtNy3b2P9dmONJ ++JME/5WEejq5jf3oo7qXKdk2zjNnncal1U+tabzZVVReV1k3bFtTc7UQfzDGZQFQEkfTdumvzf1T5 ++nn/imDor42i8K2N/uz2u5V+3b/nXO73L+W9bvS2out0RvvbP87eOluAP7FbTOfXiN6RGymVu0uUR ++Xy/GFHgKYjnGzplkuihzyG/ldCYVzImU8qJ6No4DqYm87K2x/eWb07D0lBtiejyKcdHKxKS8mZPk ++fkxhsEmNJjxziJfd114SeWYXu6c5yGHojoNlH3m9+un/BQAAAAAAAAAAAAAAAAAAAADwm7wAMJwD ++uwAoAAA= +diff --git 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-000609/tests/test.sh b/tasks/format-code-task-000609/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc2202137aaf3e15bc5c0fbcb6c58f4d091adfd1 --- /dev/null +++ b/tasks/format-code-task-000609/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_preprocess_data_sources.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-000609/tests/test_command.sh b/tasks/format-code-task-000609/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000609/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000610/environment/Dockerfile b/tasks/format-code-task-000610/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eaaa6e3226ceb1150453c07fec5ad4d496afa51c --- /dev/null +++ b/tasks/format-code-task-000610/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:315e0dd06f9f96994807519db0306097d0d3bcb2c1e91e67e17aedcc8e9eabf5 diff --git a/tasks/format-code-task-000610/environment/setup/files/blocklist b/tasks/format-code-task-000610/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000610/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000610/environment/setup/setup.sh b/tasks/format-code-task-000610/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000610/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000610/tests/test.patch b/tasks/format-code-task-000610/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ba8f81cff97a098254ed2f08a391f17fd3fd48c5 --- /dev/null +++ b/tasks/format-code-task-000610/tests/test.patch @@ -0,0 +1,116 @@ +diff --git a/src/components/__tests__/TextInput.test.js b/src/components/__tests__/TextInput.test.js +index a1b04c6b70..338e854ce8 100644 +--- a/src/components/__tests__/TextInput.test.js ++++ b/src/components/__tests__/TextInput.test.js +@@ -14,6 +14,9 @@ const style = StyleSheet.create({ + height: { + height: 100, + }, ++ inputFontVariant: { ++ fontVariant: ['small-caps'], ++ }, + }); + + const affixTextValue = '/100'; +@@ -175,6 +178,28 @@ it('correctly applies a component as the text label', () => { + expect(toJSON()).toMatchSnapshot(); + }); + ++it('renders flat input with custom font variant', () => { ++ const { getByTestId } = render(); ++ ++ expect(getByTestId('text-input-flat').props.style).toEqual( ++ expect.arrayContaining([ ++ expect.objectContaining({ fontVariant: ['small-caps'] }), ++ ]) ++ ); ++}); ++ ++it('renders outlined input with custom font variant', () => { ++ const { getByTestId } = render( ++ ++ ); ++ ++ expect(getByTestId('text-input-outlined').props.style).toEqual( ++ expect.arrayContaining([ ++ expect.objectContaining({ fontVariant: ['small-caps'] }), ++ ]) ++ ); ++}); ++ + describe('maxFontSizeMultiplier', () => { + const createInput = (type, maxFontSizeMultiplier) => { + return ( +diff --git a/src/components/__tests__/__snapshots__/TextInput.test.js.snap b/src/components/__tests__/__snapshots__/TextInput.test.js.snap +index d932270dd7..fc75258684 100644 +--- a/src/components/__tests__/__snapshots__/TextInput.test.js.snap ++++ b/src/components/__tests__/__snapshots__/TextInput.test.js.snap +@@ -180,6 +180,7 @@ exports[`correctly applies a component as the text label 1`] = ` + "color": "#000000", + "fontFamily": "System", + "fontSize": 16, ++ "fontVariant": undefined, + "fontWeight": undefined, + "textAlign": "left", + "textAlignVertical": "center", +@@ -362,6 +363,7 @@ exports[`correctly applies default textAlign based on default RTL 1`] = ` + "color": "#000000", + "fontFamily": "System", + "fontSize": 16, ++ "fontVariant": undefined, + "fontWeight": undefined, + "textAlign": "left", + "textAlignVertical": "center", +@@ -593,6 +595,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = ` + "color": "#000000", + "fontFamily": "System", + "fontSize": 16, ++ "fontVariant": undefined, + "fontWeight": undefined, + "textAlign": "left", + "textAlignVertical": "top", +@@ -776,6 +779,7 @@ exports[`correctly applies textAlign center 1`] = ` + "color": "#000000", + "fontFamily": "System", + "fontSize": 16, ++ "fontVariant": undefined, + "fontWeight": undefined, + "textAlign": "center", + "textAlignVertical": "center", +@@ -958,6 +962,7 @@ exports[`correctly renders left-side icon adornment, and right-side affix adornm + "color": "#000000", + "fontFamily": "System", + "fontSize": 16, ++ "fontVariant": undefined, + "fontWeight": undefined, + "textAlign": "left", + "textAlignVertical": "center", +@@ -1266,6 +1271,7 @@ exports[`correctly renders left-side icon adornment, and right-side affix adornm + "color": "#000000", + "fontFamily": "System", + "fontSize": 16, ++ "fontVariant": undefined, + "fontWeight": undefined, + "textAlign": "left", + "textAlignVertical": "center", +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+3STWvDIBwG8JzzKSwd9BSjWc1Ova2HXdodyk6FYBJZWloNako+/kwO3RhsvbSM ++bc8PxJe/oPJIy253qAulT2l0Kyx4EGLsg8/9OOYiY1nO5iIP65znjEdE3OxGH3TOS0tIZI3x3+27 ++VP+l6Hv+XjlfVOZ4lLqmrrneGZfy56F2zv8+C/nPcy4iwq53ha/98/ynk7Tc6bSUromrmoyfoFR1 ++rPrWWE9W68dlsVy9LIb1WLc92YcBSZJh/ix9E5pXVi9mG9X7J912fkuH2pbu3d0sbNQmqcxJWfmq ++4p9+LAAAAAAAAAAAAAAAAAAAAADAH/MGnYr1oAAoAAA= +diff --git 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-000610/tests/test.sh b/tasks/format-code-task-000610/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..69d514faa7c5b4c46bf46dc811c39c4e99917e83 --- /dev/null +++ b/tasks/format-code-task-000610/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/components/__tests__/TextInput.test.js +src/components/__tests__/__snapshots__/TextInput.test.js.snap +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-000610/tests/test_command.sh b/tasks/format-code-task-000610/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000610/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000631/environment/Dockerfile b/tasks/format-code-task-000631/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..96aa58bf59c35155b87ad58323f5a7369fcae482 --- /dev/null +++ b/tasks/format-code-task-000631/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3de6b06390f6027afd8ef0a4e332adbc39b477fb4e4813ba175057a266bd20ff diff --git a/tasks/format-code-task-000631/environment/setup/files/blocklist b/tasks/format-code-task-000631/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000631/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000631/environment/setup/setup.sh b/tasks/format-code-task-000631/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000631/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000631/tests/test.patch b/tasks/format-code-task-000631/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..398197be4ff143c4da6e7734d457e22b4599937b --- /dev/null +++ b/tasks/format-code-task-000631/tests/test.patch @@ -0,0 +1,63 @@ +diff --git a/descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/HBondAcceptorCountDescriptorTest.java b/descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/HBondAcceptorCountDescriptorTest.java +index aeea43b4308..8f92dd1cb46 100644 +--- a/descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/HBondAcceptorCountDescriptorTest.java ++++ b/descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/HBondAcceptorCountDescriptorTest.java +@@ -20,11 +20,13 @@ + + import javax.vecmath.Point3d; + ++import org.hamcrest.CoreMatchers; + import org.junit.Assert; + import org.junit.Before; + import org.junit.Test; + import org.openscience.cdk.DefaultChemObjectBuilder; + import org.openscience.cdk.exception.CDKException; ++import org.openscience.cdk.exception.InvalidSmilesException; + import org.openscience.cdk.interfaces.IAtom; + import org.openscience.cdk.interfaces.IAtomContainer; + import org.openscience.cdk.interfaces.IBond; +@@ -119,4 +121,17 @@ public void testCID9257() throws CDKException { + descriptor.setParameters(params); + Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue()); + } ++ ++ ++ ++ ++ @Test ++ public void exocyclicOxygenInAromaticRing() throws InvalidSmilesException { ++ SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); ++ IAtomContainer m = sp.parseSmiles("Cn1c2nc([nH]c2c(=O)n(c1=O)C)C1CCCC1"); ++ ++ HBondAcceptorCountDescriptor hbond_acceptor_desc = new HBondAcceptorCountDescriptor(); ++ int actual = ((IntegerResult)hbond_acceptor_desc.calculate(m).getValue()).intValue(); ++ Assert.assertThat(actual, CoreMatchers.is(3)); ++ } + } +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+2U3U/bMBDA+9y/4hDS3mK3gbQSU5HY+gDSxCbgbZuQ4zitV8cOdhKp//3O4aOF ++CfoAaJp2P1Vxcz7fh+8uLG+1Ka6V7fjgvRgh0yzrV+Tp2v8fZ+konWST0RTl4/FkdDiA7N0i2qIN ++jfAAA+9c85Lerv1/FLapf6NCcy1dVQlbsLB8Ox876p+OsoP7+mfTKeqNDycHBwMYvV0Iz/Of139/ ++j+fa8lyE5VAW0DdBrorhcB+u/BoaB14FZzoFuRIVFKpWtlBWahVAl2BdA8J4JYo1iE5oI3Kjhrjx ++HfYgKYHHa+OsSrlXtQu6cX7N2xUXkqtc82izfyTSecXHLE0uz0++XZ5+vdqIk20x+4XV+vkRmqWy ++Q4gh3HUsJB3I1hs45oXquG2NgfT4w/hBFaBaFdpDUmOWVd3b78X9qSR8gcRtdh67770um6YOR7zP ++hFWiU5aJWsilYs4veC9IX8ztT5u7/Jetla/3H61s/G/bvL2WzkJyA9riJBhzdLcmpTYKkvnCu7Y+ ++K2btignJ0DDrGyGZC9/oUsgG9x7yQnGnfNDOzraLhmIMdCUW2i5mMZVkHq3PXrjtt4wsZvy6yJ7c ++WamH+MMRuWgtOGvWscfg9JOzxYmUqsYu/+xa28xVkF7H1yscK8yj17sJwlfOKNkadFi5osWRianG ++2cP2NDhl9+f4Y+Uf6DyZR70Z1pw5HMaAo2ilYrJYsajMNocDezjJdgZ3a7rEET4rz10UhVkpTFC3 ++Ozgrf/tTRRAEQRAEQRAEQRAEQRAEQRAEQRAEQRDEM/wGyuMcrwAoAAA= +diff --git 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-000631/tests/test.sh b/tasks/format-code-task-000631/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..db65eb216f8cafcd9d89eb29b522973561ecbd13 --- /dev/null +++ b/tasks/format-code-task-000631/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' +descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/HBondAcceptorCountDescriptorTest.java +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-000631/tests/test_command.sh b/tasks/format-code-task-000631/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000631/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000636/environment/Dockerfile b/tasks/format-code-task-000636/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7ddef27b9d26cf947f26662d89b165c23056cab1 --- /dev/null +++ b/tasks/format-code-task-000636/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:57480741f65491f78b93acc71cbe8bf8b62a6e9e133ce87dc51384329933b3a8 diff --git a/tasks/format-code-task-000636/environment/setup/files/blocklist b/tasks/format-code-task-000636/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000636/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000636/environment/setup/setup.sh b/tasks/format-code-task-000636/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000636/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000636/tests/test.patch b/tasks/format-code-task-000636/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..060d3a5e1e0651d35d5498691e22f13048799a85 --- /dev/null +++ b/tasks/format-code-task-000636/tests/test.patch @@ -0,0 +1,101 @@ +diff --git a/t/unit/test_transport.py b/t/unit/test_transport.py +index d94a520..a6a1a4e 100644 +--- a/t/unit/test_transport.py ++++ b/t/unit/test_transport.py +@@ -700,6 +700,74 @@ class test_SSLTransport: + with pytest.raises(socket.timeout): + self.t._read(64) + ++ def test_wrap_socket_sni_accepts_ca_certs_kwarg(self): ++ ++ sock = Mock() ++ with patch('ssl.SSLContext'): ++ self.t._wrap_socket_sni(sock, ca_certs='/path/to/ca.pem') ++ ++ def test_wrap_socket_sni_loads_ca_certs(self): ++ import ssl as _ssl ++ sock = Mock() ++ with patch('ssl.SSLContext') as mock_ctx_cls: ++ mock_ctx = mock_ctx_cls.return_value ++ self.t._wrap_socket_sni(sock, ca_certs='/path/to/ca.pem') ++ assert mock_ctx.load_verify_locations.called ++ args, _ = mock_ctx.load_verify_locations.call_args ++ assert args[0] == '/path/to/ca.pem' ++ ++ mock_ctx.set_ciphers.assert_not_called() ++ del _ssl ++ ++ def test_wrap_socket_sni_no_ca_certs_no_load(self): ++ sock = Mock() ++ with patch('ssl.SSLContext') as mock_ctx_cls: ++ mock_ctx = mock_ctx_cls.return_value ++ self.t._wrap_socket_sni(sock) ++ mock_ctx.load_verify_locations.assert_not_called() ++ ++ def test_wrap_socket_sni_accepts_ciphers_kwarg(self): ++ sock = Mock() ++ with patch('ssl.SSLContext'): ++ self.t._wrap_socket_sni(sock, ciphers='HIGH:!aNULL') ++ ++ def test_wrap_socket_sni_sets_ciphers(self): ++ sock = Mock() ++ with patch('ssl.SSLContext') as mock_ctx_cls: ++ mock_ctx = mock_ctx_cls.return_value ++ self.t._wrap_socket_sni(sock, ciphers='HIGH:!aNULL') ++ mock_ctx.set_ciphers.assert_called_with('HIGH:!aNULL') ++ mock_ctx.load_verify_locations.assert_not_called() ++ ++ def test_wrap_socket_sni_no_ciphers_no_call(self): ++ sock = Mock() ++ with patch('ssl.SSLContext') as mock_ctx_cls: ++ mock_ctx = mock_ctx_cls.return_value ++ self.t._wrap_socket_sni(sock) ++ mock_ctx.set_ciphers.assert_not_called() ++ ++ def test_wrap_socket_full_sslopts_dict_reproduces_issue(self): ++ ++ ++ import ssl as _ssl ++ sock = Mock() ++ sslopts = { ++ 'ca_certs': '/path/to/ca.pem', ++ 'cert_reqs': _ssl.CERT_REQUIRED, ++ 'certfile': '/path/to/cert.pem', ++ 'keyfile': '/path/to/key.pem', ++ } ++ with patch('ssl.SSLContext') as mock_ctx_cls: ++ mock_ctx = mock_ctx_cls.return_value ++ ++ ++ self.t._wrap_socket(sock, **sslopts) ++ assert mock_ctx.load_verify_locations.called ++ args, _ = mock_ctx.load_verify_locations.call_args ++ assert args[0] == '/path/to/ca.pem' ++ mock_ctx.load_cert_chain.assert_called_with( ++ '/path/to/cert.pem', '/path/to/key.pem') ++ + + class test_TCPTransport: + class Transport(transport.TCPTransport): +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..e1b29b4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest t/unit/test_transport.py -k \"wrap_socket_sni or wrap_socket_full\" -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 t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_accepts_ca_certs_kwarg t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_loads_ca_certs t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_no_ca_certs_no_load t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_accepts_ciphers_kwarg t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_sets_ciphers t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_no_ciphers_no_call t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_full_sslopts_dict_reproduces_issue ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000636/tests/test.sh b/tasks/format-code-task-000636/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..16cadfa11dde75e607ee57e1ef9ef84597ebcb3c --- /dev/null +++ b/tasks/format-code-task-000636/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' +t/unit/test_transport.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-000636/tests/test_command.sh b/tasks/format-code-task-000636/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000636/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000638/environment/Dockerfile b/tasks/format-code-task-000638/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d3c08e54430a4f968e8343e8d5926c8ad855b39a --- /dev/null +++ b/tasks/format-code-task-000638/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b52b55443b48a16b5c03e15aaf4ce77632875da1d022903264573a7304a5bf18 diff --git a/tasks/format-code-task-000638/environment/setup/files/blocklist b/tasks/format-code-task-000638/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000638/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000638/environment/setup/setup.sh b/tasks/format-code-task-000638/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000638/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000638/tests/test.patch b/tasks/format-code-task-000638/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..dd96b9fe4944b94585677a6d6e2b769ac715fb60 --- /dev/null +++ b/tasks/format-code-task-000638/tests/test.patch @@ -0,0 +1,180 @@ +diff --git a/packages/protocol/test-sol/utils/UtilsHelpers.t.sol b/packages/protocol/test-sol/utils/UtilsHelpers.t.sol +new file mode 100644 +index 00000000000..1c1b0b0b0b0 +--- /dev/null ++++ b/packages/protocol/test-sol/utils/UtilsHelpers.t.sol +@@ -0,0 +1,116 @@ ++ ++pragma solidity ^0.5.13; ++ ++import { Constants } from "../constants.sol"; ++import { Utils } from "../utils.sol"; ++ ++contract ConstantsHarness is Constants {} ++ ++contract UtilsHelpersTest is Utils { ++ ConstantsHarness private constants; ++ ++ function setUp() public { ++ constants = new ConstantsHarness(); ++ } ++ ++ function testConstantsExposeDurationsExternally() public { ++ assertEq(constants.DAY(), 24 * 60 * 60); ++ assertEq(constants.WEEK(), 7 * constants.DAY()); ++ assertEq(constants.YEAR(), 365 * constants.DAY()); ++ } ++ ++ function testAssertAlmostEqualPassesWithinMargin() public { ++ assertAlmostEqual(100, 105, 5); ++ assertAlmostEqual(105, 100, 5); ++ assertAlmostEqual(100, 100, 0); ++ } ++ ++ function testAssertAlmostEqualFailsOutsideMarginWithDifferenceMessage() public { ++ assertAlmostEqual(100, 106, 5); ++ } ++ ++ function testAssertAlmostEqualHandlesReverseDifference() public { ++ assertAlmostEqual(106, 100, 5); ++ } ++ ++ function testArraysEqualReturnsTrueForSameSetDifferentOrder() public { ++ address[] memory arr1 = new address[](3); ++ address[] memory arr2 = new address[](3); ++ arr1[0] = address(uint160(0x1111)); ++ arr1[1] = address(uint160(0xBEEF)); ++ arr1[2] = address(uint160(0xCAFE)); ++ arr2[0] = address(uint160(0xCAFE)); ++ arr2[1] = address(uint160(0x1111)); ++ arr2[2] = address(uint160(0xBEEF)); ++ assertTrue(arraysEqual(arr1, arr2)); ++ } ++ ++ function testArraysEqualReturnsFalseForDifferentLengths() public { ++ address[] memory arr1 = new address[](2); ++ address[] memory arr2 = new address[](3); ++ arr1[0] = address(uint160(0x1234)); ++ arr1[1] = address(uint160(0x5678)); ++ arr2[0] = address(uint160(0x1234)); ++ arr2[1] = address(uint160(0x5678)); ++ arr2[2] = address(uint160(0x9ABC)); ++ assertTrue(!arraysEqual(arr1, arr2)); ++ } ++ ++ function testArraysEqualReturnsFalseForSameLengthDifferentSet() public { ++ address[] memory arr1 = new address[](3); ++ address[] memory arr2 = new address[](3); ++ arr1[0] = address(uint160(0x1234)); ++ arr1[1] = address(uint160(0x5678)); ++ arr1[2] = address(uint160(0x9ABC)); ++ arr2[0] = address(uint160(0x1234)); ++ arr2[1] = address(uint160(0x5678)); ++ arr2[2] = address(uint160(0xDEF0)); ++ assertTrue(!arraysEqual(arr1, arr2)); ++ } ++ ++ function testArraysEqualDoesNotLeakStateAcrossCalls() public { ++ address[] memory firstA = new address[](2); ++ address[] memory firstB = new address[](2); ++ address[] memory secondA = new address[](2); ++ address[] memory secondB = new address[](2); ++ firstA[0] = address(uint160(0xAAAA)); ++ firstA[1] = address(uint160(0xCCCC)); ++ firstB[0] = address(uint160(0xCCCC)); ++ firstB[1] = address(uint160(0xAAAA)); ++ secondA[0] = address(uint160(0xAAAA)); ++ secondA[1] = address(uint160(0xBBBB)); ++ secondB[0] = address(uint160(0xAAAA)); ++ secondB[1] = address(uint160(0xCCCC)); ++ assertTrue(arraysEqual(firstA, firstB)); ++ assertTrue(!arraysEqual(secondA, secondB)); ++ } ++ ++ function testGeneratePRNReturnsWithinInclusiveRangeForDifferentRanges() public { ++ uint256 small = generatePRN(1, 10, 123); ++ assertTrue(small >= 1 && small <= 10); ++ uint256 medium = generatePRN(50, 75, 456); ++ assertTrue(medium >= 50 && medium <= 75); ++ uint256 wide = generatePRN(1000, 1000000, 789); ++ assertTrue(wide >= 1000 && wide <= 1000000); ++ } ++ ++ function testGeneratePRNAllowsDegenerateRange() public { ++ assertEq(generatePRN(42, 42, 999), 42); ++ } ++ ++ function testGeneratePRNVariesAcrossSaltsForNonDegenerateRange() public { ++ uint256 min = 1000; ++ uint256 max = 1000000; ++ uint256 first = generatePRN(min, max, 1); ++ assertTrue(first >= min && first <= max); ++ bool sawDifferent = false; ++ for (uint256 salt = 2; salt <= 12; salt++) { ++ uint256 next = generatePRN(min, max, salt); ++ assertTrue(next >= min && next <= max); ++ if (next != first) { ++ sawDifferent = true; ++ } ++ } ++ assertTrue(sawDifferent); ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,53 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++git submodule update --init --recursive || exit $? ++ ++ ++cd packages/protocol ++ ++case "${1:-}" in ++ base) ++ forge test --match-path test-sol/voting/Election.t.sol --optimize --optimizer-runs 200 -vv || exit $? ++ ;; ++ new) ++ forge test \ ++ --match-path test-sol/utils/UtilsHelpers.t.sol \ ++ --no-match-test 'testAssertAlmostEqual(FailsOutsideMarginWithDifferenceMessage|HandlesReverseDifference)' \ ++ --optimize \ ++ --optimizer-runs 200 \ ++ -vv || exit $? ++ ++ for test_name in \ ++ testAssertAlmostEqualFailsOutsideMarginWithDifferenceMessage \ ++ testAssertAlmostEqualHandlesReverseDifference ++ do ++ out_file="$(mktemp)" ++ forge test \ ++ --match-path test-sol/utils/UtilsHelpers.t.sol \ ++ --match-test "${test_name}" \ ++ --optimize \ ++ --optimizer-runs 200 \ ++ -vv >"${out_file}" 2>&1 ++ status=$? ++ cat "${out_file}" ++ if [ "${status}" -eq 0 ]; then ++ echo "expected ${test_name} to fail outside the allowed margin" ++ rm -f "${out_file}" ++ exit 1 ++ fi ++ if ! grep -Eq 'Difference is[[:space:]]+6' "${out_file}"; then ++ echo "expected ${test_name} output to report the absolute difference" ++ rm -f "${out_file}" ++ exit 1 ++ fi ++ rm -f "${out_file}" ++ done ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000638/tests/test.sh b/tasks/format-code-task-000638/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b57996c9a8cda19098b88de187a34c705f861689 --- /dev/null +++ b/tasks/format-code-task-000638/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/protocol/test-sol/utils/UtilsHelpers.t.sol +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000638/tests/test_command.sh b/tasks/format-code-task-000638/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000638/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-000663/environment/Dockerfile b/tasks/format-code-task-000663/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c13b7e50b40faf3297a7c0868dbf8de2309a41cb --- /dev/null +++ b/tasks/format-code-task-000663/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:61d5b329d4f1d172a8e14762abdb2379728b74d12860206575b8aa555432ef11 diff --git a/tasks/format-code-task-000663/environment/setup/files/blocklist b/tasks/format-code-task-000663/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000663/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000663/environment/setup/setup.sh b/tasks/format-code-task-000663/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000663/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000663/tests/test.patch b/tasks/format-code-task-000663/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7d82c83f6cac71e73e5272f42b21a273c3285e32 --- /dev/null +++ b/tasks/format-code-task-000663/tests/test.patch @@ -0,0 +1,117 @@ +diff --git a/karma.conf.js b/karma.conf.js +index 614df15a..01dd109c 100644 +--- a/karma.conf.js ++++ b/karma.conf.js +@@ -30,7 +30,8 @@ module.exports = function(karma) { + + client: { + jasmine: { +- failFast: !!karma.autoWatch ++ failFast: false, ++ random: false + } + }, + +@@ -39,9 +40,11 @@ module.exports = function(karma) { + // https://github.com/chartjs/Chart.js/pull/5629 + customLaunchers: { + chrome: { +- base: 'Chrome', ++ base: 'ChromeHeadless', + flags: [ +- '--disable-accelerated-2d-canvas' ++ '--no-sandbox', ++ '--disable-accelerated-2d-canvas', ++ '--disable-gpu' + ] + }, + firefox: { +diff --git a/test/specs/core.controller.tests.js b/test/specs/core.controller.tests.js +index 12045a78..4efda349 100644 +--- a/test/specs/core.controller.tests.js ++++ b/test/specs/core.controller.tests.js +@@ -1440,4 +1440,62 @@ describe('Chart', function() { + expect(chart.getDataVisibility(1)).toBe(false); + }); + }); ++ ++ describe('Chart.getChart', function() { ++ it('should expose a static getChart function', function() { ++ expect(typeof Chart.getChart).toBe('function'); ++ }); ++ ++ it('should return the chart instance when passed the canvas element', function() { ++ var chart = acquireChart({type: 'line'}); ++ expect(Chart.getChart(chart.canvas)).toBe(chart); ++ }); ++ ++ it('should return the chart instance when passed the rendering context', function() { ++ var chart = acquireChart({type: 'line'}); ++ expect(Chart.getChart(chart.ctx)).toBe(chart); ++ }); ++ ++ it('should return the chart instance when passed the canvas id string', function() { ++ var chart = acquireChart({type: 'line'}); ++ chart.canvas.id = 'chart-getchart-by-id'; ++ expect(Chart.getChart('chart-getchart-by-id')).toBe(chart); ++ }); ++ ++ it('should return undefined when no chart exists for the canvas', function() { ++ var lonelyCanvas = document.createElement('canvas'); ++ expect(Chart.getChart(lonelyCanvas)).toBeUndefined(); ++ }); ++ ++ it('should return a falsy "not found" value when passed an unknown id string', function() { ++ ++ ++ var result = Chart.getChart('non-existent-canvas-id-xyz'); ++ expect(result == null).toBe(true); ++ }); ++ ++ it('should return undefined after the chart has been destroyed', function() { ++ var canvas = document.createElement('canvas'); ++ document.body.appendChild(canvas); ++ var chart = new Chart(canvas, {type: 'line', options: {responsive: false, animation: false}}); ++ expect(Chart.getChart(canvas)).toBe(chart); ++ chart.destroy(); ++ expect(Chart.getChart(canvas)).toBeUndefined(); ++ document.body.removeChild(canvas); ++ }); ++ ++ it('should allow constructing a chart on the same canvas after destroy', function() { ++ var canvas = document.createElement('canvas'); ++ document.body.appendChild(canvas); ++ var chart1 = new Chart(canvas, {type: 'line', options: {responsive: false, animation: false}}); ++ chart1.destroy(); ++ var chart2; ++ expect(function() { ++ chart2 = new Chart(canvas, {type: 'bar', options: {responsive: false, animation: false}}); ++ }).not.toThrow(); ++ expect(Chart.getChart(canvas)).toBe(chart2); ++ chart2.destroy(); ++ document.body.removeChild(canvas); ++ }); ++ }); + }); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..d77c8e0c +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["NODE_ENV=test ./node_modules/.bin/karma start --single-run --browsers chrome --grep core.controller"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++NODE_ENV=test ./node_modules/.bin/karma start --single-run --browsers chrome --grep core.controller ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000663/tests/test.sh b/tasks/format-code-task-000663/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..80de60b6fbe5b8698d046c7e593d2dc9dcd15cb1 --- /dev/null +++ b/tasks/format-code-task-000663/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' +karma.conf.js +test/specs/core.controller.tests.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-000663/tests/test_command.sh b/tasks/format-code-task-000663/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000663/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000664/environment/Dockerfile b/tasks/format-code-task-000664/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ac364338e1e89a619d29efe27cf12f8d54057e51 --- /dev/null +++ b/tasks/format-code-task-000664/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5f62ad2db89f1117100a68d486ac7404535b01303e6405726633be3df7e04abe diff --git a/tasks/format-code-task-000664/environment/setup/files/blocklist b/tasks/format-code-task-000664/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000664/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000664/environment/setup/setup.sh b/tasks/format-code-task-000664/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000664/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000664/tests/test.patch b/tasks/format-code-task-000664/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e07cb787898a965568af7809fd6d5b2d43d3da70 --- /dev/null +++ b/tasks/format-code-task-000664/tests/test.patch @@ -0,0 +1,33 @@ +diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java +index 89c6d0aa7e6..602eec7e988 100644 +--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java ++++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java +@@ -97,6 +97,7 @@ public class XdocsJavaDocsTest extends AbstractModuleTestSupport { + "ParameterName", + "StaticVariableName", + "SuppressWarnings", ++ "SuppressWarningsHolder", + "TypeName", + }; + +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+3SsW7DIBQFUM/+Cn7A1MSx0yVLlalzh24RAVI7xWABJsrfF7tDq0htlkRV1HuW ++hwA9EBe6Gzstt8rEh+xWymRV13NNzus8ZvWCsXpVsWqZlYw1ZZWR+mY3+mb0gTtCMmdt+G3fpfU7 ++Rb/yD8qHrbB9z42kvr3eGZfyX7DmLP9lk6ZIeb0r/Oyf5y8kmYPfKZlLFQt/7IJoyYFHTh7zPhoy ++rZJiM5V1+h10GIfhJBw/ahqs1Z6KVol3H05a0c4E5QzX9FVa4Z9Tk02qL58deh6VoVMfuuedHl3a ++/2asU+s9116R4in/69cAAAAAAAAAAAAAAAAAAAAAALgvH12R3GQAKAAA +diff --git 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-000664/tests/test.sh b/tasks/format-code-task-000664/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d7d1680594651da0fd1f23f5c6a850a3b2f7f7f6 --- /dev/null +++ b/tasks/format-code-task-000664/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java +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-000664/tests/test_command.sh b/tasks/format-code-task-000664/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000664/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000696/environment/Dockerfile b/tasks/format-code-task-000696/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3d26f42f27742a2167a80604c25c2038573a251d --- /dev/null +++ b/tasks/format-code-task-000696/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ccda66981b5e8a499675cd82b61ba898b84ee818e01193bb768b18c561e4f760 diff --git a/tasks/format-code-task-000696/environment/setup/files/blocklist b/tasks/format-code-task-000696/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000696/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000696/environment/setup/setup.sh b/tasks/format-code-task-000696/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000696/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000696/tests/test.patch b/tasks/format-code-task-000696/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e3a26f96ffe624914a0a9b9cfb8c847326e3c71f --- /dev/null +++ b/tasks/format-code-task-000696/tests/test.patch @@ -0,0 +1,260 @@ +diff --git a/cli/projectlist_test.go b/cli/projectlist_test.go +new file mode 100644 +index 0000000000..35686e9d28 +--- /dev/null ++++ b/cli/projectlist_test.go +@@ -0,0 +1,119 @@ ++package cli_test ++ ++import ( ++ "bytes" ++ "strconv" ++ "strings" ++ "testing" ++ ++ "github.com/stretchr/testify/require" ++ ++ "github.com/coder/coder/cli/clitest" ++ "github.com/coder/coder/coderd" ++ "github.com/coder/coder/coderd/coderdtest" ++ "github.com/coder/coder/codersdk" ++) ++ ++func TestProjectList(t *testing.T) { ++ t.Parallel() ++ ++ t.Run("EmptyShowsCreateHint", func(t *testing.T) { ++ t.Parallel() ++ client := coderdtest.New(t) ++ coderdtest.CreateInitialUser(t, client) ++ ++ output := runProjectListCommand(t, client, "projects", "list") ++ ++ require.Contains(t, output, "coder projects create ") ++ require.NotContains(t, output, "Last Updated") ++ require.NotContains(t, output, "Used By") ++ }) ++ ++ t.Run("ListShowsProjectTable", func(t *testing.T) { ++ t.Parallel() ++ client := coderdtest.New(t) ++ user := coderdtest.CreateInitialUser(t, client) ++ project := createReadyProject(t, client, user.Organization) ++ ++ output := runProjectListCommand(t, client, "projects", "list") ++ ++ require.Contains(t, output, project.Name) ++ require.Contains(t, output, "Project") ++ require.Contains(t, output, "Source") ++ require.Contains(t, output, "Last Updated") ++ require.Contains(t, output, "Used By") ++ }) ++ ++ t.Run("AliasShowsProjectTable", func(t *testing.T) { ++ t.Parallel() ++ client := coderdtest.New(t) ++ user := coderdtest.CreateInitialUser(t, client) ++ project := createReadyProject(t, client, user.Organization) ++ ++ output := runProjectListCommand(t, client, "projects", "ls") ++ ++ require.Contains(t, output, project.Name) ++ require.Contains(t, output, "Project") ++ require.Contains(t, output, "Source") ++ require.Contains(t, output, "Last Updated") ++ require.Contains(t, output, "Used By") ++ }) ++ ++ t.Run("UsedByPluralization", func(t *testing.T) { ++ t.Parallel() ++ client := coderdtest.New(t) ++ user := coderdtest.CreateInitialUser(t, client) ++ zeroOwnerProject := createReadyProject(t, client, user.Organization) ++ oneOwnerProject := createReadyProject(t, client, user.Organization) ++ _ = coderdtest.CreateWorkspace(t, client, "", oneOwnerProject.ID) ++ ++ output := runProjectListCommand(t, client, "projects", "list") ++ ++ require.Contains(t, output, zeroOwnerProject.Name) ++ require.Contains(t, output, oneOwnerProject.Name) ++ zeroUsedBy := usedByFields(t, output, zeroOwnerProject.Name) ++ oneUsedBy := usedByFields(t, output, oneOwnerProject.Name) ++ require.Equal(t, strconv.Itoa(0), zeroUsedBy[0]) ++ require.Equal(t, strconv.Itoa(1), oneUsedBy[0]) ++ require.NotEqual(t, zeroUsedBy[1], oneUsedBy[1]) ++ }) ++} ++ ++func runProjectListCommand(t *testing.T, client *codersdk.Client, args ...string) string { ++ t.Helper() ++ ++ cmd, root := clitest.New(t, args...) ++ clitest.SetupConfig(t, client, root) ++ ++ var stdout bytes.Buffer ++ cmd.SetOut(&stdout) ++ err := cmd.Execute() ++ require.NoError(t, err) ++ return stdout.String() ++} ++ ++func usedByFields(t *testing.T, output string, projectName string) []string { ++ t.Helper() ++ ++ for _, line := range strings.Split(output, "\n") { ++ if !strings.Contains(line, projectName) { ++ continue ++ } ++ fields := strings.Fields(line) ++ require.GreaterOrEqual(t, len(fields), 2) ++ return fields[len(fields)-2:] ++ } ++ require.FailNowf(t, "project row not found", "project %q was not present in output:\n%s", projectName, output) ++ return nil ++} ++ ++func createReadyProject(t *testing.T, client *codersdk.Client, organization string) coderd.Project { ++ t.Helper() ++ ++ daemon := coderdtest.NewProvisionerDaemon(t, client) ++ defer daemon.Close() ++ ++ job := coderdtest.CreateProjectImportJob(t, client, organization, nil) ++ coderdtest.AwaitProjectImportJob(t, client, organization, job.ID) ++ return coderdtest.CreateProject(t, client, organization, job.ID) ++} +diff --git a/coderd/projects_test.go b/coderd/projects_test.go +index 9ea0cbf87f..6fa5a65490 100644 +--- a/coderd/projects_test.go ++++ b/coderd/projects_test.go +@@ -2,6 +2,7 @@ package coderd_test + + import ( + "context" ++ "encoding/json" + "net/http" + "testing" + +@@ -11,6 +12,7 @@ import ( + "github.com/coder/coder/coderd/coderdtest" + "github.com/coder/coder/codersdk" + "github.com/coder/coder/database" ++ "github.com/coder/coder/httpmw" + ) + + func TestProjects(t *testing.T) { +@@ -36,6 +38,22 @@ func TestProjects(t *testing.T) { + require.NoError(t, err) + require.Len(t, projects, 1) + }) ++ ++ t.Run("ListWorkspaceOwnerCountDistinctOwners", func(t *testing.T) { ++ t.Parallel() ++ client := coderdtest.New(t) ++ user := coderdtest.CreateInitialUser(t, client) ++ ++ noWorkspaceProject := createProjectForUsageCount(t, client, user.Organization) ++ oneOwnerProject := createProjectForUsageCount(t, client, user.Organization) ++ _ = coderdtest.CreateWorkspace(t, client, "", oneOwnerProject.ID) ++ _ = coderdtest.CreateWorkspace(t, client, "", oneOwnerProject.ID) ++ ++ counts := projectUsageCountsByName(t, client, "") ++ ++ require.Equal(t, float64(0), counts[noWorkspaceProject.Name]) ++ require.Equal(t, float64(1), counts[oneOwnerProject.Name]) ++ }) + } + + func TestProjectsByOrganization(t *testing.T) { +@@ -60,6 +78,22 @@ func TestProjectsByOrganization(t *testing.T) { + require.NoError(t, err) + require.Len(t, projects, 1) + }) ++ ++ t.Run("ListWorkspaceOwnerCountDistinctOwners", func(t *testing.T) { ++ t.Parallel() ++ client := coderdtest.New(t) ++ user := coderdtest.CreateInitialUser(t, client) ++ ++ noWorkspaceProject := createProjectForUsageCount(t, client, user.Organization) ++ oneOwnerProject := createProjectForUsageCount(t, client, user.Organization) ++ _ = coderdtest.CreateWorkspace(t, client, "", oneOwnerProject.ID) ++ _ = coderdtest.CreateWorkspace(t, client, "", oneOwnerProject.ID) ++ ++ counts := projectUsageCountsByName(t, client, user.Organization) ++ ++ require.Equal(t, float64(0), counts[noWorkspaceProject.Name]) ++ require.Equal(t, float64(1), counts[oneOwnerProject.Name]) ++ }) + } + + func TestPostProjectsByOrganization(t *testing.T) { +@@ -151,3 +185,47 @@ func TestParametersByProject(t *testing.T) { + require.Len(t, params, 1) + }) + } ++ ++func createProjectForUsageCount(t *testing.T, client *codersdk.Client, organization string) coderd.Project { ++ t.Helper() ++ ++ daemon := coderdtest.NewProvisionerDaemon(t, client) ++ defer daemon.Close() ++ ++ job := coderdtest.CreateProjectImportJob(t, client, organization, nil) ++ coderdtest.AwaitProjectImportJob(t, client, organization, job.ID) ++ return coderdtest.CreateProject(t, client, organization, job.ID) ++} ++ ++func projectUsageCountsByName(t *testing.T, client *codersdk.Client, organization string) map[string]float64 { ++ t.Helper() ++ ++ route := "/api/v2/projects" ++ if organization != "" { ++ route += "/" + organization ++ } ++ serverURL, err := client.URL.Parse(route) ++ require.NoError(t, err) ++ req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, serverURL.String(), nil) ++ require.NoError(t, err) ++ req.AddCookie(&http.Cookie{ ++ Name: httpmw.AuthCookie, ++ Value: client.SessionToken, ++ }) ++ res, err := http.DefaultClient.Do(req) ++ require.NoError(t, err) ++ defer res.Body.Close() ++ require.Equal(t, http.StatusOK, res.StatusCode) ++ ++ var projects []map[string]interface{} ++ require.NoError(t, json.NewDecoder(res.Body).Decode(&projects)) ++ counts := make(map[string]float64, len(projects)) ++ for _, project := range projects { ++ name, ok := project["name"].(string) ++ require.True(t, ok) ++ count, ok := project["workspace_owner_count"].(float64) ++ require.True(t, ok) ++ counts[name] = count ++ } ++ return counts ++} +diff --git 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 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 -run 'TestProject(Create|Plan|Update)' ./cli/ ++ ;; ++ new) ++ go test -v -count=1 -run 'TestProjectList|TestProjects/ListWorkspaceOwnerCountDistinctOwners|TestProjectsByOrganization/ListWorkspaceOwnerCountDistinctOwners' ./cli/ ./coderd/ ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000696/tests/test.sh b/tasks/format-code-task-000696/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..da697c7fd9e7d77524922121447b11b0cfeb1d14 --- /dev/null +++ b/tasks/format-code-task-000696/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' +cli/projectlist_test.go +coderd/projects_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-000696/tests/test_command.sh b/tasks/format-code-task-000696/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000696/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-000697/environment/Dockerfile b/tasks/format-code-task-000697/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8e0a06f50acda3aca7a66cdd4170e993aadbcdad --- /dev/null +++ b/tasks/format-code-task-000697/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:32fd726a7176272f278fe7ed7ecd535e083165de1f49ede2f4ace3169a9fe99c diff --git a/tasks/format-code-task-000697/environment/setup/files/blocklist b/tasks/format-code-task-000697/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000697/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000697/environment/setup/setup.sh b/tasks/format-code-task-000697/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000697/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000697/tests/test.patch b/tasks/format-code-task-000697/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..30070eac424ca5a37fddf8bde034d1fcaa59f137 --- /dev/null +++ b/tasks/format-code-task-000697/tests/test.patch @@ -0,0 +1,53 @@ +diff --git a/texteditor/editor_test.go b/texteditor/editor_test.go +index 68d606e0cc..5ccd8a92af 100644 +--- a/texteditor/editor_test.go ++++ b/texteditor/editor_test.go +@@ -85,7 +85,7 @@ func TestEditorChange(t *testing.T) { + mods.SetFlag(true, key.Control) + ed.HandleEvent(events.NewKey(events.KeyChord, 0, key.CodeReturnEnter, mods)) + assert.Equal(t, 1, n) +- assert.Equal(t, "Go\n", text) ++ assert.Equal(t, "Go\n\n", text) + }) + } + +@@ -101,12 +101,12 @@ func TestEditorInput(t *testing.T) { + b.AssertRender(t, "input", func() { + ed.HandleEvent(events.NewKey(events.KeyChord, 'G', 0, 0)) + assert.Equal(t, 1, n) +- assert.Equal(t, "G", text) ++ assert.Equal(t, "G\n", text) + ed.HandleEvent(events.NewKey(events.KeyChord, 'o', 0, 0)) + assert.Equal(t, 2, n) +- assert.Equal(t, "Go", text) ++ assert.Equal(t, "Go\n", text) + ed.HandleEvent(events.NewKey(events.KeyChord, 0, key.CodeReturnEnter, 0)) + assert.Equal(t, 3, n) +- assert.Equal(t, "Go\n", text) ++ assert.Equal(t, "Go\n\n", text) + }) + } +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+3TX2udMBQAcJ/9FGctjJahMd5q97IyGKUM9rTtoW8l6rkqxOSSRHsH98PvaLs6 ++CltfWrax83swf82JOTGtxl43N2gmEb2UjJwXxVKSx+VSl0UuZbnZyPI8yqiWlREUL7ajn4w+KAcQ ++OWvD7+Y9Nf6PStf8B/ThprbDoEyT+u75YjyV/7Is1vxvSsr/WZkXEWTPt4Vf+8/zf/xKVL0RlfJd ++7DFAgnHdwHIXKmzi+BgujR8dwrWU4uoTNDihtrsBTYAOVYPOg6Lh3tA5ao0NnBjEhsqtddDapNWi ++1dvb01jtQtJShPuZkHwD3Vd7KRNac6nWo/PWPTQd3cO11Rt0alBr+0et1Q99++3bchqW5oWgpzAj ++BcovXks4HCC4EecP+nLbh7qDYOHKgkzzMzhprVamTa1rxV4Ea7V/P2VpnqcZ9J52TH/FToW+0gj0 ++cnf/YvHmNKYoib9bsL1bbQ7xeTQQOgS6WvMnz6fpYxqfK5DS6e4DNn2wTkDiaO7RVxq4XHo+dLQT ++PKwdH81uDEeQTJDUdjThnYz/9KVhjDHGGGOMMcYYY4wxxhhjjDHGGGN/je8espvcACgAAA== +diff --git 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-000697/tests/test.sh b/tasks/format-code-task-000697/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7829a304e9bbf823259be5efc3a7b6eea00c8ab1 --- /dev/null +++ b/tasks/format-code-task-000697/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' +texteditor/editor_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-000697/tests/test_command.sh b/tasks/format-code-task-000697/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000697/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000699/environment/Dockerfile b/tasks/format-code-task-000699/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7fd3b31ad92bcf7cfc06141ff508750f388cb65b --- /dev/null +++ b/tasks/format-code-task-000699/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d2d3a2ed53cbccf49dd9ab66ffc59f902a503820cd000bbf609214bd194f4f05 diff --git a/tasks/format-code-task-000699/environment/setup/files/blocklist b/tasks/format-code-task-000699/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000699/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000699/environment/setup/setup.sh b/tasks/format-code-task-000699/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000699/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000699/tests/test.patch b/tasks/format-code-task-000699/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fcdf2d8d4aa7d83459919111010a0cd7d0f4a127 --- /dev/null +++ b/tasks/format-code-task-000699/tests/test.patch @@ -0,0 +1,114 @@ +diff --git a/deno/lib/__tests__/string.test.ts b/deno/lib/__tests__/string.test.ts +index 78a4458ef..5391da7f2 100644 +--- a/deno/lib/__tests__/string.test.ts ++++ b/deno/lib/__tests__/string.test.ts +@@ -165,6 +165,41 @@ test("email validations", () => { + ).toBe(true); + }); + ++test("base64 validations", () => { ++ const validBase64Strings = [ ++ "SGVsbG8gV29ybGQ=", ++ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==", ++ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms=", ++ "UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", ++ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", ++ "MTIzNDU2Nzg5MA==", ++ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=", ++ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo=", ++ "ISIkJSMmJyonKCk=", ++ "", ++ ]; ++ ++ for (const str of validBase64Strings) { ++ expect(str + z.string().base64().safeParse(str).success).toBe(str + "true"); ++ } ++ ++ const invalidBase64Strings = [ ++ "12345", ++ "SGVsbG8gV29ybGQ", ++ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw", ++ "!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", ++ "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", ++ ".MTIzND2Nzg5MC4=", ++ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", ++ ]; ++ ++ for (const str of invalidBase64Strings) { ++ expect(str + z.string().base64().safeParse(str).success).toBe( ++ str + "false" ++ ); ++ } ++}); ++ + test("url validations", () => { + const url = z.string().url(); + url.parse("http://google.com"); +diff --git a/src/__tests__/string.test.ts b/src/__tests__/string.test.ts +index 2eae674b1..ea2f1376b 100644 +--- a/src/__tests__/string.test.ts ++++ b/src/__tests__/string.test.ts +@@ -164,6 +164,41 @@ test("email validations", () => { + ).toBe(true); + }); + ++test("base64 validations", () => { ++ const validBase64Strings = [ ++ "SGVsbG8gV29ybGQ=", ++ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==", ++ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms=", ++ "UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", ++ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", ++ "MTIzNDU2Nzg5MA==", ++ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=", ++ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo=", ++ "ISIkJSMmJyonKCk=", ++ "", ++ ]; ++ ++ for (const str of validBase64Strings) { ++ expect(str + z.string().base64().safeParse(str).success).toBe(str + "true"); ++ } ++ ++ const invalidBase64Strings = [ ++ "12345", ++ "SGVsbG8gV29ybGQ", ++ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw", ++ "!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", ++ "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", ++ ".MTIzND2Nzg5MC4=", ++ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", ++ ]; ++ ++ for (const str of invalidBase64Strings) { ++ expect(str + z.string().base64().safeParse(str).success).toBe( ++ str + "false" ++ ); ++ } ++}); ++ + test("url validations", () => { + const url = z.string().url(); + url.parse("http://google.com"); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SS07DMBAG4Kx9iqFd205KElZcgBXiAlEeLnFp7cp2EMfHbiVaKpVuWiHE/0mR ++HzOJJxqLbtLroVHmXWa3kkcPVbUbo9NxNy+qRVHU9aIqyiyPs7zMqLpZRUcmH1pHlDlrw095l+J/ ++lDj0Pygfmt5uNq0ZhB+vd8al/pdV+dX/sq5j/8v6vsgov14J5/3z/s/v5OSd7LSR8Q5Q1/qReRWI ++q8nSVm/VstVrxvqBdvejUwNjc3qZDIVRkXe9pKe4TylIS+vIB6fNq0hrETwz2w9apRjnvTVL/UpC ++7ideBs9TSOzXYuWtiWnpzec2jPEJypnHWTqkadK2bxr5/fuz42oGZezZQo7+QKZEdsjm3Fjej6p/ ++o7Xuzp7FfrtXAAAAAAAAAAAAAAAAAAAAAACnPgFV7dEGACgAAA== +diff --git 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-000699/tests/test.sh b/tasks/format-code-task-000699/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4bdf0c30aeb368639e5dc2b312e4d1dadd761893 --- /dev/null +++ b/tasks/format-code-task-000699/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' +deno/lib/__tests__/string.test.ts +src/__tests__/string.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-000699/tests/test_command.sh b/tasks/format-code-task-000699/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000699/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000807/environment/Dockerfile b/tasks/format-code-task-000807/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..debe364357cb66dcf05c571b6fbc7d054fc678bd --- /dev/null +++ b/tasks/format-code-task-000807/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2b8a959d192dbd5b2fcf6e5374b4d7ad54eec8923314fc1220fffa8b75782304 diff --git a/tasks/format-code-task-000807/environment/setup/files/blocklist b/tasks/format-code-task-000807/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000807/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000807/environment/setup/setup.sh b/tasks/format-code-task-000807/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000807/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000807/tests/test.patch b/tasks/format-code-task-000807/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..94cca7d7735287f02219a097d7fb7293ec5bc68a --- /dev/null +++ b/tasks/format-code-task-000807/tests/test.patch @@ -0,0 +1,717 @@ +diff --git a/usercase-test-coderl/githubAutomatedRepos.test.ts b/usercase-test-coderl/githubAutomatedRepos.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/githubAutomatedRepos.test.ts +@@ -0,0 +1,666 @@ ++// @vitest-environment jsdom ++ ++import React, { type ReactNode } from 'react'; ++import { execFileSync } from 'node:child_process'; ++import { mkdtempSync, rmSync } from 'node:fs'; ++import { tmpdir } from 'node:os'; ++import { join } from 'node:path'; ++import { afterEach, describe, expect, test, vi } from 'vitest'; ++import { cleanup, renderHook, waitFor } from '@testing-library/react'; ++import { QueryClient, QueryClientProvider, type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query'; ++ ++import { ++ useGitHubAutomatedRepos as useRootGitHubAutomatedRepos, ++ type IGitHubRepos as RootGitHubRepos, ++} from '../src/index'; ++import { ++ useGitHubAutomatedRepos as useReactQueryGitHubAutomatedRepos, ++ type IGitHubRepos as ReactQueryGitHubRepos, ++} from '../src/react-query'; ++ ++type RootHookState = { ++ data: RootGitHubRepos[] | undefined; ++ isLoading: boolean; ++ error: { name: string; message: string } | null; ++}; ++ ++type QueryHookState = { ++ data: ReactQueryGitHubRepos[] | undefined; ++ status: string; ++ fetchStatus: string; ++ isPending: boolean; ++ isLoading: boolean; ++ isFetching: boolean; ++ error: { name: string; message: string } | null; ++}; ++ ++type RootSignature = typeof useRootGitHubAutomatedRepos extends ( ++ gitHubUsername: string, ++ keyWord: string ++) => { data: RootGitHubRepos[] | undefined; isLoading: boolean; error: Error | null } ++ ? true ++ : never; ++ ++type ReactQuerySignature = typeof useReactQueryGitHubAutomatedRepos extends ( ++ gitHubUsername: string, ++ keyWord: string, ++ options?: Omit< ++ UseQueryOptions, ++ 'queryKey' | 'queryFn' ++ > ++) => UseQueryResult ++ ? true ++ : never; ++ ++const rootSignatureCheck: RootSignature = true; ++const reactQuerySignatureCheck: ReactQuerySignature = true; ++ ++const rootTypeFixture: RootGitHubRepos = { ++ name: 'portfolio-site', ++ topics: ['portfolio', 'react'], ++ html_url: 'https://github.com/octocat/portfolio-site', ++ description: 'Portfolio', ++ id: 1, ++ homepage: 'https://octocat.example', ++ banner: ['https://raw.example/banner.png'], ++}; ++ ++const reactQueryTypeFixture: ReactQueryGitHubRepos = { ++ name: 'attached-tool', ++ topics: ['attached', 'typescript'], ++ html_url: 'https://github.com/octocat/attached-tool', ++ description: 'Attached tool', ++ id: 2, ++ homepage: 'https://attached.example', ++ banner: ['https://raw.example/hero-banner.svg'], ++}; ++ ++void rootSignatureCheck; ++void reactQuerySignatureCheck; ++void rootTypeFixture; ++void reactQueryTypeFixture; ++ ++const GITHUB_REPOS_API = [ ++ { ++ id: 1, ++ name: 'portfolio-site', ++ topics: ['portfolio', 'react'], ++ html_url: 'https://github.com/octocat/portfolio-site', ++ description: 'Portfolio', ++ homepage: 'https://octocat.example', ++ }, ++ { ++ id: 2, ++ name: 'attached-tool', ++ topics: ['attached', 'typescript'], ++ html_url: 'https://github.com/octocat/attached-tool', ++ description: 'Attached tool', ++ homepage: 'https://attached.example', ++ }, ++]; ++ ++const PORTFOLIO_RESULT = [ ++ { ++ id: 1, ++ name: 'portfolio-site', ++ html_url: 'https://github.com/octocat/portfolio-site', ++ description: 'Portfolio', ++ topics: ['portfolio', 'react'], ++ homepage: 'https://octocat.example', ++ banner: ['https://raw.example/banner.png'], ++ }, ++]; ++ ++const ATTACHED_RESULT = [ ++ { ++ id: 2, ++ name: 'attached-tool', ++ html_url: 'https://github.com/octocat/attached-tool', ++ description: 'Attached tool', ++ topics: ['attached', 'typescript'], ++ homepage: 'https://attached.example', ++ banner: ['https://raw.example/hero-banner.svg'], ++ }, ++]; ++ ++const repositoryFeedResponse = () => { ++ const response = [...GITHUB_REPOS_API] as typeof GITHUB_REPOS_API & { ++ items: typeof GITHUB_REPOS_API; ++ total_count: number; ++ }; ++ response.items = GITHUB_REPOS_API; ++ response.total_count = GITHUB_REPOS_API.length; ++ return response; ++}; ++ ++const expectRepositoryFeedStarted = (calls: string[], gitHubUsername: string): void => { ++ ++ expect(calls.length).toBeGreaterThan(0); ++ expect(calls.some((url) => url.includes(gitHubUsername))).toBe(true); ++}; ++ ++const expectRepositoryFeedNotStarted = (calls: string[]): void => { ++ expect(calls).toEqual([]); ++}; ++ ++const requestUrl = (input: RequestInfo | URL): string => { ++ ++ return input instanceof Request ? input.url : String(input); ++}; ++ ++const jsonResponse = (value: unknown): Response => ++ ({ ++ ok: true, ++ json: async () => value, ++ }) as Response; ++ ++const installSuccessfulFetch = (): string[] => { ++ const calls: string[] = []; ++ ++ vi.stubGlobal( ++ 'fetch', ++ vi.fn(async (input: RequestInfo | URL): Promise => { ++ const url = requestUrl(input); ++ calls.push(url); ++ ++ ++ if (url.includes('portfolio-site')) { ++ return jsonResponse([{ name: 'banner.png', type: 'file', download_url: 'https://raw.example/banner.png' }]); ++ } ++ ++ if (url.includes('attached-tool')) { ++ return jsonResponse([{ name: 'hero-banner.svg', type: 'file', download_url: 'https://raw.example/hero-banner.svg' }]); ++ } ++ ++ if (url.includes('octocat')) { ++ return jsonResponse(repositoryFeedResponse()); ++ } ++ ++ throw new Error(`Unexpected fetch URL: ${url}`); ++ }) ++ ); ++ ++ return calls; ++}; ++ ++const installRejectingFetch = (reason: unknown): string[] => { ++ const calls: string[] = []; ++ ++ vi.stubGlobal( ++ 'fetch', ++ vi.fn(async (input: RequestInfo | URL): Promise => { ++ calls.push(requestUrl(input)); ++ throw reason; ++ }) ++ ); ++ ++ return calls; ++}; ++ ++const snapshotRoot = (value: { ++ data: RootGitHubRepos[] | undefined; ++ isLoading: boolean; ++ error: Error | null; ++}): RootHookState => ({ ++ data: value.data, ++ isLoading: value.isLoading, ++ error: value.error ? { name: value.error.name, message: value.error.message } : null, ++}); ++ ++const snapshotQuery = (value: UseQueryResult): QueryHookState => ({ ++ data: value.data, ++ status: value.status, ++ fetchStatus: value.fetchStatus, ++ isPending: value.isPending, ++ isLoading: value.isLoading, ++ isFetching: value.isFetching, ++ error: value.error ? { name: value.error.name, message: value.error.message } : null, ++}); ++ ++const renderRootUntilSettled = async (gitHubUsername: string, keyWord: string): Promise => { ++ const { result } = renderHook(() => useRootGitHubAutomatedRepos(gitHubUsername, keyWord)); ++ await waitFor(() => { ++ if (result.current.isLoading || !result.current.data) { ++ throw new Error('waiting for root hook data'); ++ } ++ }); ++ return snapshotRoot(result.current); ++}; ++ ++const createQueryClient = (): QueryClient => ++ new QueryClient({ ++ defaultOptions: { ++ queries: { ++ retry: false, ++ gcTime: 0, ++ }, ++ }, ++ }); ++ ++const withQueryClient = ++ (client: QueryClient) => ++ ({ children }: { children: ReactNode }) => ++ React.createElement(QueryClientProvider, { client }, children); ++ ++afterEach(() => { ++ cleanup(); ++ vi.unstubAllGlobals(); ++ vi.restoreAllMocks(); ++}); ++ ++describe('useGitHubAutomatedRepos public hook exports', () => { ++ test('root hook exposes initial, loading, and resolved repository states', async () => { ++ ++ ++ ++ ++ const calls = installSuccessfulFetch(); ++ const seen: RootHookState[] = []; ++ ++ const { result } = renderHook(() => { ++ const value = useRootGitHubAutomatedRepos('octocat', 'portfolio'); ++ seen.push(snapshotRoot(value)); ++ return value; ++ }); ++ ++ await waitFor(() => { ++ if (result.current.isLoading || !result.current.data) { ++ throw new Error('waiting for root hook data'); ++ } ++ }); ++ ++ ++ expect(seen[0]).toEqual({ data: undefined, isLoading: false, error: null }); ++ expect(seen).toContainEqual({ data: undefined, isLoading: true, error: null }); ++ expect(snapshotRoot(result.current)).toEqual({ ++ data: PORTFOLIO_RESULT, ++ isLoading: false, ++ error: null, ++ }); ++ expectRepositoryFeedStarted(calls, 'octocat'); ++ }); ++ ++ test('root hook with empty username keeps idle state and does not fetch', async () => { ++ ++ ++ ++ ++ const calls = installSuccessfulFetch(); ++ const seen: RootHookState[] = []; ++ ++ const { result } = renderHook(() => { ++ const value = useRootGitHubAutomatedRepos('', 'portfolio'); ++ seen.push(snapshotRoot(value)); ++ return value; ++ }); ++ ++ await Promise.resolve(); ++ ++ ++ expect(seen.every((state) => state.data === undefined && state.isLoading === false && state.error === null)).toBe(true); ++ expect(snapshotRoot(result.current)).toEqual({ data: undefined, isLoading: false, error: null }); ++ expectRepositoryFeedNotStarted(calls); ++ }); ++ ++ test('root hook with empty keyword keeps idle state and does not fetch', async () => { ++ ++ ++ ++ ++ const calls = installSuccessfulFetch(); ++ const seen: RootHookState[] = []; ++ ++ const { result } = renderHook(() => { ++ const value = useRootGitHubAutomatedRepos('octocat', ''); ++ seen.push(snapshotRoot(value)); ++ return value; ++ }); ++ ++ await Promise.resolve(); ++ ++ ++ expect(seen.every((state) => state.data === undefined && state.isLoading === false && state.error === null)).toBe(true); ++ expect(snapshotRoot(result.current)).toEqual({ data: undefined, isLoading: false, error: null }); ++ expectRepositoryFeedNotStarted(calls); ++ }); ++ ++ test('root hook exposes a rejected Error value unchanged', async () => { ++ ++ ++ ++ ++ const calls = installRejectingFetch(new Error('feed exploded')); ++ const seen: RootHookState[] = []; ++ ++ const { result } = renderHook(() => { ++ const value = useRootGitHubAutomatedRepos('octocat', 'portfolio'); ++ seen.push(snapshotRoot(value)); ++ return value; ++ }); ++ ++ await waitFor(() => { ++ if (result.current.isLoading || !result.current.error) { ++ throw new Error('waiting for root hook error'); ++ } ++ }); ++ ++ expect(result.current.error).toBeInstanceOf(Error); ++ ++ expect(seen[0]).toEqual({ data: undefined, isLoading: false, error: null }); ++ expect(seen).toContainEqual({ data: undefined, isLoading: true, error: null }); ++ expect(snapshotRoot(result.current)).toEqual({ ++ data: undefined, ++ isLoading: false, ++ error: { name: 'Error', message: 'feed exploded' }, ++ }); ++ expectRepositoryFeedStarted(calls, 'octocat'); ++ }); ++ ++ test('root hook converts a non-Error rejection to Unknown error occurred', async () => { ++ ++ ++ ++ ++ const calls = installRejectingFetch('plain rejection'); ++ ++ const { result } = renderHook(() => useRootGitHubAutomatedRepos('octocat', 'portfolio')); ++ ++ await waitFor(() => { ++ if (result.current.isLoading || !result.current.error) { ++ throw new Error('waiting for root hook non-Error conversion'); ++ } ++ }); ++ ++ expect(result.current.error).toBeInstanceOf(Error); ++ expect(snapshotRoot(result.current)).toEqual({ ++ data: undefined, ++ isLoading: false, ++ error: { name: 'Error', message: 'Unknown error occurred' }, ++ }); ++ expectRepositoryFeedStarted(calls, 'octocat'); ++ }); ++ ++ test('react-query hook uses the requested key, passes options, and returns portfolio data', async () => { ++ ++ ++ ++ ++ const calls = installSuccessfulFetch(); ++ const client = createQueryClient(); ++ ++ const { result, unmount } = renderHook( ++ () => ++ useReactQueryGitHubAutomatedRepos('octocat', 'portfolio', { ++ staleTime: 600000, ++ refetchInterval: false, ++ refetchOnWindowFocus: false, ++ }), ++ { wrapper: withQueryClient(client) } ++ ); ++ ++ await waitFor(() => { ++ if (!result.current.data) { ++ throw new Error('waiting for react-query hook data'); ++ } ++ }); ++ ++ expect(snapshotQuery(result.current)).toEqual({ ++ data: PORTFOLIO_RESULT, ++ status: 'success', ++ fetchStatus: 'idle', ++ isPending: false, ++ isLoading: false, ++ isFetching: false, ++ error: null, ++ }); ++ expect(client.getQueryData(['githubRepos', 'octocat', 'portfolio'])).toEqual(PORTFOLIO_RESULT); ++ const query = client.getQueryCache().find({ queryKey: ['githubRepos', 'octocat', 'portfolio'] }); ++ const queryOptions = query?.options as ++ | UseQueryOptions ++ | undefined; ++ expect(queryOptions?.staleTime).toBe(600000); ++ expect(queryOptions?.refetchInterval).toBe(false); ++ expect(queryOptions?.refetchOnWindowFocus).toBe(false); ++ expectRepositoryFeedStarted(calls, 'octocat'); ++ ++ unmount(); ++ client.clear(); ++ }); ++ ++ test('react-query hook caches portfolio and attached keywords separately', async () => { ++ ++ ++ ++ ++ const calls = installSuccessfulFetch(); ++ const client = createQueryClient(); ++ const wrapper = withQueryClient(client); ++ ++ const first = renderHook( ++ () => ++ useReactQueryGitHubAutomatedRepos('octocat', 'portfolio', { ++ staleTime: 600000, ++ refetchInterval: false, ++ refetchOnWindowFocus: false, ++ }), ++ { wrapper } ++ ); ++ ++ await waitFor(() => { ++ if (!first.result.current.data) { ++ throw new Error('waiting for portfolio data'); ++ } ++ }); ++ const second = renderHook( ++ () => ++ useReactQueryGitHubAutomatedRepos('octocat', 'attached', { ++ staleTime: 600000, ++ refetchInterval: false, ++ refetchOnWindowFocus: false, ++ }), ++ { wrapper } ++ ); ++ ++ await waitFor(() => { ++ if (!second.result.current.data) { ++ throw new Error('waiting for attached data'); ++ } ++ }); ++ ++ expect(client.getQueryData(['githubRepos', 'octocat', 'portfolio'])).toEqual(PORTFOLIO_RESULT); ++ expect(client.getQueryData(['githubRepos', 'octocat', 'attached'])).toEqual(ATTACHED_RESULT); ++ expect(snapshotQuery(second.result.current)).toEqual({ ++ data: ATTACHED_RESULT, ++ status: 'success', ++ fetchStatus: 'idle', ++ isPending: false, ++ isLoading: false, ++ isFetching: false, ++ error: null, ++ }); ++ expectRepositoryFeedStarted(calls, 'octocat'); ++ ++ first.unmount(); ++ second.unmount(); ++ client.clear(); ++ }); ++ ++ test('react-query enabled false leaves the request disabled', async () => { ++ ++ ++ ++ ++ const calls = installSuccessfulFetch(); ++ const client = createQueryClient(); ++ ++ const { result, unmount } = renderHook(() => useReactQueryGitHubAutomatedRepos('octocat', 'portfolio', { enabled: false }), { ++ wrapper: withQueryClient(client), ++ }); ++ ++ await Promise.resolve(); ++ ++ expect(snapshotQuery(result.current)).toEqual({ ++ data: undefined, ++ status: 'pending', ++ fetchStatus: 'idle', ++ isPending: true, ++ isLoading: false, ++ isFetching: false, ++ error: null, ++ }); ++ expect(client.getQueryData(['githubRepos', 'octocat', 'portfolio'])).toBeUndefined(); ++ expectRepositoryFeedNotStarted(calls); ++ ++ unmount(); ++ client.clear(); ++ }); ++}); ++ ++describe('Lib-Pure contract checks for the hook surfaces', () => { ++ test('referential transparency: repeated root calls with the same arguments settle to the same literal result', async () => { ++ installSuccessfulFetch(); ++ const first = await renderRootUntilSettled('octocat', 'portfolio'); ++ cleanup(); ++ ++ installSuccessfulFetch(); ++ const second = await renderRootUntilSettled('octocat', 'portfolio'); ++ ++ expect(first).toEqual({ ++ data: PORTFOLIO_RESULT, ++ isLoading: false, ++ error: null, ++ }); ++ expect(second).toEqual(first); ++ }); ++ ++ test('passes caller-provided React Query options through', async () => { ++ const calls = installSuccessfulFetch(); ++ const client = createQueryClient(); ++ const options = { ++ staleTime: 600000, ++ refetchInterval: false, ++ refetchOnWindowFocus: false, ++ meta: { source: 'acceptance-test' }, ++ } satisfies Omit< ++ UseQueryOptions, ++ 'queryKey' | 'queryFn' ++ >; ++ const before = structuredClone(options); ++ ++ const { result, unmount } = renderHook(() => useReactQueryGitHubAutomatedRepos('octocat', 'portfolio', options), { ++ wrapper: withQueryClient(client), ++ }); ++ ++ await waitFor(() => { ++ if (!result.current.data) { ++ throw new Error('waiting for react-query data'); ++ } ++ }); ++ ++ const query = client.getQueryCache().find({ queryKey: ['githubRepos', 'octocat', 'portfolio'] }); ++ const queryOptions = query?.options as ++ | UseQueryOptions ++ | undefined; ++ ++ expect(queryOptions?.staleTime).toBe(before.staleTime); ++ expect(queryOptions?.refetchInterval).toBe(before.refetchInterval); ++ expect(queryOptions?.refetchOnWindowFocus).toBe(before.refetchOnWindowFocus); ++ expect(queryOptions?.meta).toEqual(before.meta); ++ expect(snapshotQuery(result.current).data).toEqual(PORTFOLIO_RESULT); ++ expectRepositoryFeedStarted(calls, 'octocat'); ++ ++ unmount(); ++ client.clear(); ++ }); ++ ++ test('no global state: root hook matches a fresh Node process for the same arguments', async () => { ++ installSuccessfulFetch(); ++ const inProcess = await renderRootUntilSettled('octocat', 'portfolio'); ++ const childScript = ` ++ import { createRequire } from 'node:module'; ++ import { JSDOM } from 'jsdom'; ++ const require = createRequire(import.meta.url); ++ const dom = new JSDOM(''); ++ globalThis.window = dom.window; ++ globalThis.document = dom.window.document; ++ Object.defineProperty(globalThis, 'navigator', { value: dom.window.navigator, configurable: true }); ++ globalThis.HTMLElement = dom.window.HTMLElement; ++ globalThis.IS_REACT_ACT_ENVIRONMENT = true; ++ const { renderHook, waitFor, cleanup } = require('@testing-library/react'); ++ const { useGitHubAutomatedRepos } = await import('/workspace/repo/src/index.ts'); ++ const calls = []; ++ globalThis.fetch = async (input) => { ++ // ++ const url = input instanceof Request ? input.url : String(input); ++ calls.push(url); ++ // ++ if (url.includes('portfolio-site')) { ++ return { ok: true, json: async () => [{ name: 'banner.png', type: 'file', download_url: 'https://raw.example/banner.png' }] }; ++ } ++ if (url.includes('octocat')) { ++ const repos = ${JSON.stringify(GITHUB_REPOS_API)}; ++ repos.items = repos; ++ repos.total_count = repos.length; ++ return { ok: true, json: async () => repos }; ++ } ++ throw new Error('Unexpected fetch URL: ' + url); ++ }; ++ const { result } = renderHook(() => useGitHubAutomatedRepos('octocat', 'portfolio')); ++ await waitFor(() => { ++ if (result.current.isLoading || !result.current.data) { ++ throw new Error('waiting for data'); ++ } ++ }); ++ const out = { ++ data: result.current.data, ++ isLoading: result.current.isLoading, ++ error: result.current.error ? { name: result.current.error.name, message: result.current.error.message } : null, ++ calls, ++ }; ++ cleanup(); ++ process.stdout.write(JSON.stringify(out)); ++ `; ++ ++ const child = JSON.parse( ++ execFileSync(process.execPath, ['--import', 'tsx', '--input-type=module', '-e', childScript], { ++ cwd: '/workspace/repo', ++ encoding: 'utf8', ++ }) ++ ) as RootHookState & { calls: string[] }; ++ ++ expect(inProcess).toEqual({ ++ data: PORTFOLIO_RESULT, ++ isLoading: false, ++ error: null, ++ }); ++ expect(child).toEqual({ ++ data: PORTFOLIO_RESULT, ++ isLoading: false, ++ error: null, ++ calls: expect.any(Array), ++ }); ++ expectRepositoryFeedStarted(child.calls, 'octocat'); ++ }); ++ ++ test('root hook returns the same observable data from a different cwd', async () => { ++ const originalCwd = process.cwd(); ++ const temporaryCwd = mkdtempSync(join(tmpdir(), 'github-automated-repos-fixture-')); ++ ++ try { ++ process.chdir(temporaryCwd); ++ const calls = installSuccessfulFetch(); ++ const state = await renderRootUntilSettled('octocat', 'portfolio'); ++ ++ expect(state).toEqual({ ++ data: PORTFOLIO_RESULT, ++ isLoading: false, ++ error: null, ++ }); ++ ++ expectRepositoryFeedStarted(calls, 'octocat'); ++ } finally { ++ process.chdir(originalCwd); ++ rmSync(temporaryCwd, { recursive: true, force: true }); ++ } ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,41 @@ ++#!/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 PATH="/workspace/repo/node_modules/.bin:${PATH}" ++export npm_config_offline=true ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_update_notifier=false ++ ++for required_bin in ./node_modules/.bin/tsc ./node_modules/.bin/vitest ./node_modules/.bin/tsx; do ++ if [[ ! -x "${required_bin}" ]]; then ++ echo "Missing offline test dependency: ${required_bin}" >&2 ++ exit 127 ++ fi ++done ++ ++./node_modules/.bin/tsc --noEmit \ ++ --strict \ ++ --jsx react \ ++ --esModuleInterop \ ++ --module esnext \ ++ --moduleResolution node \ ++ --target es2017 \ ++ --lib es6,dom,es2017 \ ++ --types vitest,node \ ++ --skipLibCheck \ ++ /workspace/repo/usercase-test-coderl/githubAutomatedRepos.test.ts ++ ++exec ./node_modules/.bin/vitest run /workspace/repo/usercase-test-coderl/githubAutomatedRepos.test.ts diff --git a/tasks/format-code-task-000807/tests/test.sh b/tasks/format-code-task-000807/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ca27746e222365d8f5891b732cc270f18f87a43 --- /dev/null +++ b/tasks/format-code-task-000807/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/githubAutomatedRepos.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-000807/tests/test_command.sh b/tasks/format-code-task-000807/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000807/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-000809/environment/Dockerfile b/tasks/format-code-task-000809/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e9919e69a3b332cd40d5efa8ae35fc84723de39b --- /dev/null +++ b/tasks/format-code-task-000809/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4dda3413a1108473b66610714b657d2e22d5be9d0c5f2afa40f3bf9ebf6d6bf5 diff --git a/tasks/format-code-task-000809/environment/setup/files/blocklist b/tasks/format-code-task-000809/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000809/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000809/environment/setup/setup.sh b/tasks/format-code-task-000809/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000809/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000809/tests/test.patch b/tasks/format-code-task-000809/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ca1e157639556e862d41efeb740636e945715daf --- /dev/null +++ b/tasks/format-code-task-000809/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/django_prometheus/tests/end2end/testapp/settings.py b/django_prometheus/tests/end2end/testapp/settings.py +index dad2cb68..60254d8d 100644 +--- a/django_prometheus/tests/end2end/testapp/settings.py ++++ b/django_prometheus/tests/end2end/testapp/settings.py +@@ -1,6 +1,8 @@ + import os + import tempfile + ++from django import VERSION as DJANGO_VERSION ++ + from testapp.helpers import get_middleware + + # SECURITY WARNING: keep the secret key used in production secret! +@@ -131,6 +133,12 @@ + }, + } + ++if DJANGO_VERSION >= (4, 0): ++ CACHES["native_redis"] = { ++ "BACKEND": "django_prometheus.cache.backends.redis.NativeRedisCache", ++ "LOCATION": "redis://127.0.0.1:6379/0", ++ } ++ + + # Internationalization + LANGUAGE_CODE = "en-us" +diff --git a/django_prometheus/tests/end2end/testapp/test_caches.py b/django_prometheus/tests/end2end/testapp/test_caches.py +index 84ccbb6c..389dc5ae 100644 +--- a/django_prometheus/tests/end2end/testapp/test_caches.py ++++ b/django_prometheus/tests/end2end/testapp/test_caches.py +@@ -1,10 +1,13 @@ + import pytest + from django.core.cache import caches ++from django import VERSION as DJANGO_VERSION + from redis import RedisError + + from django_prometheus.testutils import assert_metric_equal, get_metric + + _SUPPORTED_CACHES = ["memcached.PyLibMCCache", "memcached.PyMemcacheCache", "filebased", "locmem", "redis"] ++if DJANGO_VERSION >= (4, 0): ++ _SUPPORTED_CACHES.append("native_redis") + + + class TestCachesMetrics: +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+3TQW+bMBQA4Jz5FU+ttBs4ZIWeWilSq7bTllRNetgJOfZrYAIb2YYpU378bJY1 ++VdWul1TTtPcJhLGfecYPklVX1bJA1bPRexl7p1k2XL3n16GdZpM0zfNxnvl+3xp/HEH2bit6orOO ++G4CR0dr9Ke6t8X9Usq+/Q+sKoZuGK5nY8nA53qr/aXbyWP8sT339T/JJPoLx4Zbwuv+8/kLCUPgV ++yig6hoXfDAd3KCsL1QMo7YDXBrncgOmUqtQ6MmEwFnUFrb+Fc2ASe6a6uobJ+YcUtlv4FWLR9Ggg ++jiXHRqvqB8IG7T5Lg43gokT5WiYUpYYjXx9nj2ALSkD8PYVaC16X2jpIU//NvLgA1lnDhkC2qhTb ++Z4r90e4mxh2EokaRrRF9Z1jZVLiq5w6h939EZHVnBAILYSwJXcPj+C4oTLjrFLgSwb/RGh2ErYSH ++qsboycYy+Y2rtS5aoxv0wZ0dRixDJSf+jG6/Lq/ns9vp8vrs9xy4+DSdXc2LxeVyeTO7WhRf5hf3 ++ny/PwjBv28Sic36PLLQbV2oFcRNaIfsuYvc7h9e2SbuBuI/+9rdGCCGEEEIIIYQQQgghhBBCCCGE ++EEIO7ycTgPGHACgAAA== +diff --git 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-000809/tests/test.sh b/tasks/format-code-task-000809/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bcabbb51fece2506ec0b4941c44016eeca9b96b9 --- /dev/null +++ b/tasks/format-code-task-000809/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' +django_prometheus/tests/end2end/testapp/settings.py +django_prometheus/tests/end2end/testapp/test_caches.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-000809/tests/test_command.sh b/tasks/format-code-task-000809/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000809/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000831/environment/Dockerfile b/tasks/format-code-task-000831/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9a9514db27a74fd324d2ff9d610b23a6e2459645 --- /dev/null +++ b/tasks/format-code-task-000831/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:125c4ea47f1c925fe548656f51537d43994586ce410f47c8714726485bc7140b diff --git a/tasks/format-code-task-000831/environment/setup/files/blocklist b/tasks/format-code-task-000831/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000831/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000831/environment/setup/setup.sh b/tasks/format-code-task-000831/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000831/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000831/tests/test.patch b/tasks/format-code-task-000831/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..695b5635b3f592b1bca6e5d43d25a9b29539fd54 --- /dev/null +++ b/tasks/format-code-task-000831/tests/test.patch @@ -0,0 +1,608 @@ +diff --git a/usercase-test-coderl/test_afc_rename.py b/usercase-test-coderl/test_afc_rename.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_afc_rename.py +@@ -0,0 +1,577 @@ ++from __future__ import annotations ++ ++import asyncio ++import datetime ++import pathlib ++import posixpath ++import struct ++from collections import deque ++ ++import pytest ++ ++from pymobiledevice3.exceptions import AfcException, AfcFileNotFoundError ++from pymobiledevice3.lockdown_service_provider import LockdownServiceProvider ++from pymobiledevice3.services.afc import AfcError, AfcService ++ ++ ++pytestmark = pytest.mark.asyncio ++ ++ ++ ++ ++ ++ ++ ++AFC_MAGIC = b"CFA6LPAA" ++HEADER_SIZE = 40 ++ ++OP_STATUS = 0x01 ++OP_DATA = 0x02 ++OP_READ_DIR = 0x03 ++OP_REMOVE_PATH = 0x08 ++OP_MAKE_DIR = 0x09 ++OP_GET_FILE_INFO = 0x0A ++OP_FILE_OPEN = 0x0D ++OP_FILE_OPEN_RES = 0x0E ++OP_READ = 0x0F ++OP_WRITE = 0x10 ++OP_FILE_CLOSE = 0x14 ++OP_RENAME_PATH = 0x18 ++ ++STATUS_SUCCESS = 0 ++STATUS_READ_ERROR = 4 ++STATUS_INVALID_ARG = 7 ++STATUS_OBJECT_NOT_FOUND = 8 ++STATUS_OBJECT_EXISTS = 16 ++ ++MODE_RDONLY = 1 ++MODE_WRONLY = 3 ++MODE_WR = 4 ++ ++ ++def _packet(packet_num: int, operation: int, payload: bytes) -> bytes: ++ return struct.pack( ++ "<8sQQQQ", ++ AFC_MAGIC, ++ HEADER_SIZE + len(payload), ++ HEADER_SIZE + len(payload), ++ packet_num, ++ operation, ++ ) + payload ++ ++ ++def _status_packet(packet_num: int, status: int) -> bytes: ++ return _packet(packet_num, OP_STATUS, struct.pack(" bytes: ++ return _packet(packet_num, OP_DATA, payload) ++ ++ ++def _cstring(value: str) -> bytes: ++ return value.encode("utf-8") + b"\x00" ++ ++ ++def _parse_strings(payload: bytes) -> list[str]: ++ return payload.decode("utf-8").split("\x00")[:-1] ++ ++ ++def _afc_listing(values: list[str]) -> bytes: ++ return b"".join(_cstring(value) for value in values) ++ ++ ++def _active_afc_reader_tasks() -> int: ++ return sum(1 for task in asyncio.all_tasks() if task.get_name() == "afc-reader" and not task.done()) ++ ++ ++class _InProcessAfcConnection: ++ def __init__(self) -> None: ++ self.files: dict[str, bytes] = {} ++ self.dirs: set[str] = {""} ++ self.handles: dict[int, dict[str, object]] = {} ++ self.next_handle = 100 ++ self.close_count = 0 ++ self._responses: asyncio.Queue[bytes] = asyncio.Queue() ++ self._buffer = bytearray() ++ ++ async def sendall(self, data: bytes) -> None: ++ magic, entire_length, _, packet_num, operation = struct.unpack("<8sQQQQ", data[:HEADER_SIZE]) ++ assert magic == AFC_MAGIC ++ payload = data[HEADER_SIZE:entire_length] ++ status, response = self._handle(operation, payload) ++ if status == STATUS_SUCCESS: ++ await self._responses.put(_data_packet(packet_num, response)) ++ else: ++ await self._responses.put(_status_packet(packet_num, status)) ++ ++ async def recvall(self, size: int) -> bytes: ++ while len(self._buffer) < size: ++ self._buffer.extend(await self._responses.get()) ++ result = bytes(self._buffer[:size]) ++ del self._buffer[:size] ++ return result ++ ++ async def close(self) -> None: ++ self.close_count += 1 ++ ++ def _handle(self, operation: int, payload: bytes) -> tuple[int, bytes]: ++ if operation == OP_MAKE_DIR: ++ return self._mkdir(_parse_strings(payload)[0]), b"" ++ if operation == OP_GET_FILE_INFO: ++ return self._stat(_parse_strings(payload)[0]) ++ if operation == OP_READ_DIR: ++ return self._listdir(_parse_strings(payload)[0]) ++ if operation == OP_REMOVE_PATH: ++ return self._remove(_parse_strings(payload)[0]), b"" ++ if operation == OP_FILE_OPEN: ++ mode = struct.unpack(" str: ++ normalized = posixpath.normpath("/" + path).lstrip("/") ++ return "" if normalized == "." else normalized ++ ++ def _parent(self, path: str) -> str: ++ parent = posixpath.dirname(path) ++ return "" if parent == "." else parent ++ ++ def _children(self, directory: str) -> list[str]: ++ prefix = f"{directory}/" if directory else "" ++ names = set() ++ for path in self.dirs | set(self.files): ++ if path == directory or not path.startswith(prefix): ++ continue ++ rest = path[len(prefix) :] ++ if rest: ++ names.add(rest.split("/", 1)[0]) ++ return sorted(names) ++ ++ def _path_kind(self, path: str) -> str | None: ++ if path in self.files: ++ return "file" ++ if path in self.dirs: ++ return "dir" ++ return None ++ ++ def _has_file_ancestor(self, path: str) -> bool: ++ parts = pathlib.PurePosixPath(path).parts ++ for index in range(1, len(parts)): ++ if "/".join(parts[:index]) in self.files: ++ return True ++ return False ++ ++ def _mkdir(self, path: str) -> int: ++ current = "" ++ for part in pathlib.PurePosixPath(self._normalize(path)).parts: ++ current = part if not current else f"{current}/{part}" ++ if current in self.files: ++ return STATUS_OBJECT_EXISTS ++ self.dirs.add(current) ++ return STATUS_SUCCESS ++ ++ def _stat(self, path: str) -> tuple[int, bytes]: ++ path = self._normalize(path) ++ if path in self.files: ++ size = len(self.files[path]) ++ ifmt = "S_IFREG" ++ blocks = 1 ++ elif path in self.dirs: ++ size = 64 ++ ifmt = "S_IFDIR" ++ blocks = 0 ++ else: ++ return STATUS_READ_ERROR, b"" ++ ++ timestamp_ns = 1_700_000_000_000_000_000 ++ return STATUS_SUCCESS, _afc_listing( ++ [ ++ "st_size", ++ str(size), ++ "st_blocks", ++ str(blocks), ++ "st_mtime", ++ str(timestamp_ns), ++ "st_birthtime", ++ str(timestamp_ns), ++ "st_nlink", ++ "1", ++ "st_ifmt", ++ ifmt, ++ ] ++ ) ++ ++ def _listdir(self, path: str) -> tuple[int, bytes]: ++ path = self._normalize(path) ++ if path not in self.dirs: ++ return STATUS_READ_ERROR, b"" ++ return STATUS_SUCCESS, _afc_listing([".", "..", *self._children(path)]) ++ ++ def _remove(self, path: str) -> int: ++ path = self._normalize(path) ++ if path in self.files: ++ del self.files[path] ++ return STATUS_SUCCESS ++ if path in self.dirs and path: ++ if self._children(path): ++ return STATUS_OBJECT_EXISTS ++ self.dirs.remove(path) ++ return STATUS_SUCCESS ++ return STATUS_OBJECT_NOT_FOUND ++ ++ def _open(self, path: str, mode: int) -> tuple[int, bytes]: ++ path = self._normalize(path) ++ parent = self._parent(path) ++ if mode == MODE_RDONLY and path not in self.files: ++ return STATUS_OBJECT_NOT_FOUND, b"" ++ if mode in (MODE_WRONLY, MODE_WR): ++ if parent not in self.dirs or self._has_file_ancestor(path): ++ return STATUS_OBJECT_NOT_FOUND, b"" ++ self.files[path] = b"" ++ handle = self.next_handle ++ self.next_handle += 1 ++ self.handles[handle] = {"path": path, "offset": 0} ++ return STATUS_SUCCESS, struct.pack(" int: ++ if handle not in self.handles: ++ return STATUS_INVALID_ARG ++ path = self.handles[handle]["path"] ++ self.files[path] = self.files.get(path, b"") + data ++ return STATUS_SUCCESS ++ ++ def _read(self, handle: int, size: int) -> tuple[int, bytes]: ++ if handle not in self.handles: ++ return STATUS_INVALID_ARG, b"" ++ entry = self.handles[handle] ++ path = entry["path"] ++ offset = entry["offset"] ++ data = self.files[path][offset : offset + size] ++ entry["offset"] = offset + len(data) ++ return STATUS_SUCCESS, data ++ ++ def _close_handle(self, handle: int) -> int: ++ if handle not in self.handles: ++ return STATUS_INVALID_ARG ++ del self.handles[handle] ++ return STATUS_SUCCESS ++ ++ def _rename(self, source: str, target: str) -> int: ++ source = self._normalize(source) ++ target = self._normalize(target) ++ source_kind = self._path_kind(source) ++ if source_kind is None: ++ return STATUS_OBJECT_NOT_FOUND ++ if source == target: ++ return STATUS_SUCCESS ++ if self._parent(target) not in self.dirs or self._has_file_ancestor(target): ++ return STATUS_INVALID_ARG ++ if self._path_kind(target) is not None: ++ return STATUS_OBJECT_EXISTS ++ if source_kind == "file": ++ self.files[target] = self.files.pop(source) ++ return STATUS_SUCCESS ++ ++ moved_dirs = {path for path in self.dirs if path == source or path.startswith(f"{source}/")} ++ moved_files = {path: data for path, data in self.files.items() if path.startswith(f"{source}/")} ++ for path in moved_dirs: ++ self.dirs.remove(path) ++ for path in moved_files: ++ del self.files[path] ++ for path in moved_dirs: ++ suffix = path[len(source) :] ++ self.dirs.add(f"{target}{suffix}") ++ for path, data in moved_files.items(): ++ suffix = path[len(source) :] ++ self.files[f"{target}{suffix}"] = data ++ return STATUS_SUCCESS ++ ++ ++class _InProcessLockdownProvider(LockdownServiceProvider): ++ def __init__(self) -> None: ++ super().__init__() ++ self.connections: deque[_InProcessAfcConnection] = deque() ++ ++ @property ++ def product_version(self) -> str: ++ return "17.0" ++ ++ @property ++ def product_build_version(self) -> str: ++ return "21A000" ++ ++ @property ++ def ecid(self) -> int: ++ return 1234 ++ ++ async def get_developer_mode_status(self) -> bool: ++ return True ++ ++ async def get_date(self) -> datetime.datetime: ++ return datetime.datetime.fromtimestamp(1_700_000_000) ++ ++ async def set_language(self, language: str) -> None: ++ return None ++ ++ async def get_language(self) -> str: ++ return "en" ++ ++ async def set_locale(self, locale: str) -> None: ++ return None ++ ++ async def get_locale(self) -> str: ++ return "en_US" ++ ++ async def set_assistive_touch(self, value: bool) -> None: ++ return None ++ ++ async def get_assistive_touch(self) -> bool: ++ return False ++ ++ async def set_voice_over(self, value: bool) -> None: ++ return None ++ ++ async def get_voice_over(self) -> bool: ++ return False ++ ++ async def set_invert_display(self, value: bool) -> None: ++ return None ++ ++ async def get_invert_display(self) -> bool: ++ return False ++ ++ async def set_enable_wifi_connections(self, value: bool) -> None: ++ return None ++ ++ async def get_enable_wifi_connections(self) -> bool: ++ return False ++ ++ async def set_timezone(self, timezone: str) -> None: ++ return None ++ ++ async def set_uses24h_clock(self, value: bool) -> None: ++ return None ++ ++ async def start_lockdown_service(self, name: str, include_escrow_bag: bool = False) -> _InProcessAfcConnection: ++ connection = _InProcessAfcConnection() ++ self.connections.append(connection) ++ return connection ++ ++ async def get_service_connection_attributes(self, name: str, include_escrow_bag: bool = False) -> dict: ++ return {"Port": 1234} ++ ++ async def create_service_connection(self, port: int) -> _InProcessAfcConnection: ++ connection = _InProcessAfcConnection() ++ self.connections.append(connection) ++ return connection ++ ++ async def get_value(self, domain: str | None = None, key: str | None = None): ++ if key == "TimeIntervalSince1970": ++ return 1_700_000_000 ++ return None ++ ++ async def set_value(self, value, domain: str | None = None, key: str | None = None) -> dict: ++ return {} ++ ++ async def remove_value(self, domain: str | None = None, key: str | None = None) -> dict: ++ return {} ++ ++ ++async def _new_afc() -> tuple[_InProcessLockdownProvider, AfcService]: ++ lockdown = _InProcessLockdownProvider() ++ afc = AfcService(lockdown) ++ return lockdown, afc ++ ++ ++async def test_rename_file_moves_bytes_and_removes_source() -> None: ++ ++ ++ ++ ++ _, afc = await _new_afc() ++ try: ++ await afc.set_file_contents("source.txt", b"data") ++ assert await afc.get_file_contents("source.txt") == b"data" ++ assert await afc.rename("source.txt", "dest.txt") is None ++ assert await afc.get_file_contents("dest.txt") == b"data" ++ with pytest.raises(AfcFileNotFoundError) as exc: ++ await afc.get_file_contents("source.txt") ++ ++ assert isinstance(exc.value, AfcFileNotFoundError) ++ finally: ++ await afc.aclose() ++ ++ ++async def test_rename_file_between_existing_folders() -> None: ++ ++ ++ ++ ++ _, afc = await _new_afc() ++ try: ++ await afc.makedirs("dir_a/dir_b") ++ await afc.set_file_contents("dir_a/dir_b/source.txt", b"nested-data") ++ assert await afc.rename("dir_a/dir_b/source.txt", "dir_a/dest.txt") is None ++ assert await afc.get_file_contents("dir_a/dest.txt") == b"nested-data" ++ with pytest.raises(AfcFileNotFoundError) as exc: ++ await afc.get_file_contents("dir_a/dir_b/source.txt") ++ ++ assert isinstance(exc.value, AfcFileNotFoundError) ++ finally: ++ await afc.aclose() ++ ++ ++async def test_rename_directory_moves_tree() -> None: ++ ++ ++ ++ ++ _, afc = await _new_afc() ++ try: ++ await afc.makedirs("folder_src/nested") ++ await afc.set_file_contents("folder_src/nested/file.txt", b"dir-data") ++ assert await afc.rename("folder_src", "folder_dest") is None ++ assert await afc.get_file_contents("folder_dest/nested/file.txt") == b"dir-data" ++ with pytest.raises(AfcFileNotFoundError) as exc: ++ await afc.get_file_contents("folder_src/nested/file.txt") ++ ++ assert isinstance(exc.value, AfcFileNotFoundError) ++ finally: ++ await afc.aclose() ++ ++ ++async def test_rename_to_self_is_successful_noop() -> None: ++ ++ ++ ++ ++ _, afc = await _new_afc() ++ try: ++ await afc.set_file_contents("same.txt", b"same-data") ++ assert await afc.rename("same.txt", "same.txt") is None ++ assert await afc.get_file_contents("same.txt") == b"same-data" ++ finally: ++ await afc.aclose() ++ ++ ++async def test_rename_missing_source_raises_specific_not_found() -> None: ++ ++ ++ ++ ++ _, afc = await _new_afc() ++ try: ++ with pytest.raises(AfcFileNotFoundError) as exc: ++ await afc.rename("missing.txt", "dest.txt") ++ ++ assert isinstance(exc.value, AfcFileNotFoundError) ++ finally: ++ await afc.aclose() ++ ++ ++async def test_rename_target_rejection_surfaces_original_afc_error() -> None: ++ ++ ++ ++ ++ _, afc = await _new_afc() ++ try: ++ await afc.set_file_contents("source.txt", b"data") ++ await afc.set_file_contents("not_a_dir", b"blocker") ++ with pytest.raises(AfcException) as exc: ++ await afc.rename("source.txt", "not_a_dir/dest.txt") ++ ++ assert isinstance(exc.value, AfcException) ++ assert not isinstance(exc.value, AfcFileNotFoundError) ++ ++ assert exc.value.status == AfcError.INVALID_ARG ++ assert await afc.get_file_contents("source.txt") == b"data" ++ finally: ++ await afc.aclose() ++ ++ ++async def test_rename_accepts_path_like_values() -> None: ++ ++ ++ ++ ++ _, afc = await _new_afc() ++ try: ++ await afc.makedirs(pathlib.Path("pathlike")) ++ await afc.set_file_contents(pathlib.Path("pathlike/source.txt"), b"pathlike-data") ++ assert ( ++ await afc.rename( ++ pathlib.Path("pathlike/source.txt"), ++ pathlib.Path("pathlike/dest.txt"), ++ ) ++ is None ++ ) ++ assert await afc.get_file_contents(pathlib.Path("pathlike/dest.txt")) == b"pathlike-data" ++ finally: ++ await afc.aclose() ++ ++ ++async def test_two_afc_instances_keep_independent_filesystems() -> None: ++ ++ ++ ++ ++ _, afc_a = await _new_afc() ++ _, afc_b = await _new_afc() ++ try: ++ await afc_a.set_file_contents("source.txt", b"left-data") ++ await afc_b.set_file_contents("source.txt", b"right-data") ++ assert await afc_a.rename("source.txt", "dest.txt") is None ++ assert await afc_a.get_file_contents("dest.txt") == b"left-data" ++ assert await afc_b.get_file_contents("source.txt") == b"right-data" ++ with pytest.raises(AfcFileNotFoundError) as exc: ++ await afc_b.get_file_contents("dest.txt") ++ ++ assert isinstance(exc.value, AfcFileNotFoundError) ++ finally: ++ await afc_a.aclose() ++ await afc_b.aclose() ++ ++ ++async def test_aclose_is_idempotent_and_closes_connection_once() -> None: ++ ++ ++ ++ ++ _, afc = await _new_afc() ++ await afc.set_file_contents("source.txt", b"data") ++ assert await afc.rename("source.txt", "dest.txt") is None ++ ++ assert await afc.get_file_contents("dest.txt") == b"data" ++ await afc.aclose() ++ await afc.aclose() ++ ++ ++async def test_repeated_sessions_do_not_leave_afc_reader_tasks() -> None: ++ ++ ++ ++ ++ ++ for index in range(100): ++ _, afc = await _new_afc() ++ async with afc: ++ source = f"source-{index}.txt" ++ dest = f"dest-{index}.txt" ++ await afc.set_file_contents(source, b"cycle-data") ++ assert await afc.rename(source, dest) is None ++ assert await afc.get_file_contents(dest) == b"cycle-data" ++ await asyncio.sleep(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,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 PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec /opt/coderl_venv/bin/python -m pytest -p pytest_asyncio.plugin /workspace/repo/usercase-test-coderl/test_afc_rename.py -v diff --git a/tasks/format-code-task-000831/tests/test.sh b/tasks/format-code-task-000831/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..abdb1515b1fe3a26b40ff042cd4887d9857c0cf8 --- /dev/null +++ b/tasks/format-code-task-000831/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_afc_rename.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-000831/tests/test_command.sh b/tasks/format-code-task-000831/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000831/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-000836/environment/Dockerfile b/tasks/format-code-task-000836/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..808ac53341e55ed592c37f00c470b7300175746a --- /dev/null +++ b/tasks/format-code-task-000836/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1e989eb4c315e87e98c84570d0d8007566ea36493d26096eeb14cacb41ce2c18 diff --git a/tasks/format-code-task-000836/environment/setup/files/blocklist b/tasks/format-code-task-000836/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000836/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000836/environment/setup/setup.sh b/tasks/format-code-task-000836/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000836/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000836/tests/test.patch b/tasks/format-code-task-000836/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3275b03d34b04a9a9ef1171bfa6dab737c9e34b3 --- /dev/null +++ b/tasks/format-code-task-000836/tests/test.patch @@ -0,0 +1,46 @@ +diff --git a/eval_test.go b/eval_test.go +index a63619a..3bef9e4 100644 +--- a/eval_test.go ++++ b/eval_test.go +@@ -135,6 +135,17 @@ func TestExpand(t *testing.T) { + input: "${var=${var01^^}}", + output: "ABCDEFGH28IJ", + }, ++ ++ { ++ params: map[string]string{"var01": "abcdEFGH28ij"}, ++ input: "$${var01}", ++ output: "${var01}", ++ }, ++ { ++ params: map[string]string{"var01": "abcdEFGH28ij"}, ++ input: "some text ${var01}$${var$${var01}$var01${var01}", ++ output: "some text abcdEFGH28ij${var${var01}$var01abcdEFGH28ij", ++ }, + } + + for _, expr := range expressions { +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+3TT2/TMBgG8J7zKV7EBQ6J4460EmhISFRwAA2NcUJoyh8nsZrake2Ubp+eN9G2 ++TohuO2xCiOd3ceParx0/TlIMuqvOldmK2VNJ2TLLppb93k6/ZTZP53MpFxn3S5ktj2aUPdmObhl8 ++yB3RzFkb7hp33///qGSff1A+nJd2s8lNlfj28da4J3+ZZkf7/NMF5/9qkS5nlD7eFg77z/MvK5qC ++L1QVRc/pqwo09PTh5Mu7s4/007q17/NSRWrXWxeu+o/FeBiisftuKeXnk/ffPq2ObV2PhVbGD05R ++aNV1MX+x6bRZk9ppHzy96K023F7XEt6VotGhHYqEL6GonDVK8L30Q+EDxW9v9vky2qwr7Sju754c ++dYZiX9/Me+BSt3bf2Hq4vKRK9cpUypQXpD3l21x3edGpSNf0nZ5RfLhyY23TKXFV58eb8TxMRIwH ++UdnxuhTHXD+0JKkNofevxcECyTjpQUtFtR5f43QwUwJ8wxsOdjwHjkyV/GLTA8Vbih0POuOH1a7n ++D58On8vfvqoAAAAAAAAAAAAAAAAAAAAA8Ae/AEyKRdAAKAAA +diff --git 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-000836/tests/test.sh b/tasks/format-code-task-000836/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..13c98c0590c14bb7e12fb9f69967bc4b29a05477 --- /dev/null +++ b/tasks/format-code-task-000836/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' +eval_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-000836/tests/test_command.sh b/tasks/format-code-task-000836/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000836/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000852/environment/Dockerfile b/tasks/format-code-task-000852/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d43e26cb93ce2913b5c5918677e4a6dc9eed9537 --- /dev/null +++ b/tasks/format-code-task-000852/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9f19e59b5c08bf170848f6079b6e3c74b9424f040487e3dfe82e87fae5f9c226 diff --git a/tasks/format-code-task-000852/environment/setup/files/blocklist b/tasks/format-code-task-000852/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000852/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000852/environment/setup/setup.sh b/tasks/format-code-task-000852/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000852/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000852/tests/test.patch b/tasks/format-code-task-000852/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0060246d3f11ac2fe47d6521711729efcb608743 --- /dev/null +++ b/tasks/format-code-task-000852/tests/test.patch @@ -0,0 +1,477 @@ +diff --git a/usercase-test-coderl/test_yfinance_acceptance.py b/usercase-test-coderl/test_yfinance_acceptance.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_yfinance_acceptance.py +@@ -0,0 +1,444 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++from unittest import mock ++ ++import pandas as pd ++import yfinance ++ ++from pybroker import YFinance, disable_data_source_cache ++from pybroker.data import DataSource ++ ++ ++START = "2023-01-01" ++END = "2023-01-05" ++ ++ ++def _single_symbol_daily(auto_adjust: bool) -> pd.DataFrame: ++ columns = { ++ "Open": [130.28, 126.89, 127.13], ++ "High": [130.90, 128.66, 127.77], ++ "Low": [124.17, 125.08, 124.76], ++ "Close": ( ++ [123.63, 124.90, 123.58] ++ if auto_adjust ++ else [125.07, 126.36, 125.02] ++ ), ++ "Volume": [112117500, 89113600, 80962700], ++ } ++ if not auto_adjust: ++ columns["Adj Close"] = [123.63, 124.90, 123.58] ++ return pd.DataFrame( ++ columns, ++ index=pd.Index( ++ pd.to_datetime(["2023-01-03", "2023-01-04", "2023-01-05"]), ++ name="Date", ++ ), ++ ) ++ ++ ++def _multi_symbol_daily() -> pd.DataFrame: ++ return pd.DataFrame( ++ [ ++ [ ++ 130.28, ++ 243.08, ++ 130.90, ++ 245.75, ++ 124.17, ++ 237.40, ++ 125.07, ++ 239.58, ++ 123.63, ++ 234.42, ++ 112117500, ++ 25740000, ++ ], ++ [ ++ 126.89, ++ 232.28, ++ 128.66, ++ 232.87, ++ 125.08, ++ 225.96, ++ 126.36, ++ 229.10, ++ 124.90, ++ 224.17, ++ 89113600, ++ 50623400, ++ ], ++ ], ++ index=pd.Index( ++ pd.to_datetime(["2023-01-03", "2023-01-04"]), ++ name="Date", ++ ), ++ columns=pd.MultiIndex.from_tuples( ++ [ ++ ("Open", "AAPL"), ++ ("Open", "MSFT"), ++ ("High", "AAPL"), ++ ("High", "MSFT"), ++ ("Low", "AAPL"), ++ ("Low", "MSFT"), ++ ("Close", "AAPL"), ++ ("Close", "MSFT"), ++ ("Adj Close", "AAPL"), ++ ("Adj Close", "MSFT"), ++ ("Volume", "AAPL"), ++ ("Volume", "MSFT"), ++ ] ++ ), ++ ) ++ ++ ++def _assert_frame(actual: pd.DataFrame, rows: list[dict], columns: list[str]): ++ expected = pd.DataFrame(rows, columns=columns) ++ if "date" in expected: ++ expected["date"] = pd.to_datetime(expected["date"]) ++ ++ assert set(actual.columns) == set(columns) ++ actual_cmp = actual.loc[:, columns] ++ sort_cols = [col for col in ["date", "symbol"] if col in columns] ++ if sort_cols: ++ actual_cmp = actual_cmp.sort_values(sort_cols).reset_index(drop=True) ++ expected = expected.sort_values(sort_cols).reset_index(drop=True) ++ pd.testing.assert_frame_equal( ++ actual_cmp.reset_index(drop=True), expected, check_dtype=False ++ ) ++ ++ ++def setup_function(): ++ disable_data_source_cache() ++ ++ ++def _download_arg(call_args, index: int, *names: str): ++ if len(call_args.args) > index: ++ return call_args.args[index] ++ for name in names: ++ if name in call_args.kwargs: ++ return call_args.kwargs[name] ++ raise AssertionError(f"missing yfinance.download argument {names[0]}") ++ ++ ++def _assert_download_symbols(call_args, expected: set[str]): ++ ++ actual = _download_arg(call_args, 0, "tickers", "symbols") ++ if isinstance(actual, str): ++ actual_symbols = set(actual.replace(",", " ").split()) ++ else: ++ actual_symbols = set(actual) ++ assert actual_symbols == expected ++ ++ ++def _assert_download_dates(call_args): ++ ++ assert pd.Timestamp(_download_arg(call_args, 1, "start")) == pd.Timestamp(START) ++ assert pd.Timestamp(_download_arg(call_args, 2, "end")) == pd.Timestamp(END) ++ ++ ++def _download_auto_adjust(call_args) -> bool: ++ ++ return _download_arg(call_args, 7, "auto_adjust") ++ ++ ++def _assert_values_by_date(actual: pd.DataFrame, column: str, values: list[float]): ++ ++ expected = pd.DataFrame( ++ { ++ "date": pd.to_datetime(["2023-01-03", "2023-01-04", "2023-01-05"]), ++ column: values, ++ } ++ ) ++ actual_cmp = actual.loc[:, ["date", column]].sort_values("date") ++ pd.testing.assert_frame_equal( ++ actual_cmp.reset_index(drop=True), expected, check_dtype=False ++ ) ++ ++ ++def test_single_symbol_auto_adjust_false_normalizes_yahoo_rows(): ++ ++ ++ ++ yf = YFinance(auto_adjust=False) ++ assert isinstance(yf, DataSource) is True ++ ++ with mock.patch.object( ++ yfinance, "download", return_value=_single_symbol_daily(False) ++ ) as download: ++ result = yf.query("AAPL", START, END) ++ ++ _assert_frame( ++ result, ++ [ ++ { ++ "date": "2023-01-03", ++ "symbol": "AAPL", ++ "open": 130.28, ++ "high": 130.90, ++ "low": 124.17, ++ "close": 125.07, ++ "volume": 112117500, ++ "adj_close": 123.63, ++ }, ++ { ++ "date": "2023-01-04", ++ "symbol": "AAPL", ++ "open": 126.89, ++ "high": 128.66, ++ "low": 125.08, ++ "close": 126.36, ++ "volume": 89113600, ++ "adj_close": 124.90, ++ }, ++ { ++ "date": "2023-01-05", ++ "symbol": "AAPL", ++ "open": 127.13, ++ "high": 127.77, ++ "low": 124.76, ++ "close": 125.02, ++ "volume": 80962700, ++ "adj_close": 123.58, ++ }, ++ ], ++ [ ++ "date", ++ "symbol", ++ "open", ++ "high", ++ "low", ++ "close", ++ "volume", ++ "adj_close", ++ ], ++ ) ++ _assert_download_symbols(download.call_args, {"AAPL"}) ++ _assert_download_dates(download.call_args) ++ assert _download_auto_adjust(download.call_args) is False ++ ++ ++def test_multiple_symbols_are_row_oriented_and_timeframe_ignored_by_provider(): ++ ++ ++ ++ yf = YFinance(auto_adjust=False) ++ ++ with mock.patch.object( ++ yfinance, "download", return_value=_multi_symbol_daily() ++ ) as download: ++ result = yf.query(["AAPL", "MSFT"], START, END, _timeframe="5m") ++ ++ _assert_frame( ++ result, ++ [ ++ { ++ "date": "2023-01-03", ++ "symbol": "AAPL", ++ "open": 130.28, ++ "high": 130.90, ++ "low": 124.17, ++ "close": 125.07, ++ "volume": 112117500, ++ "adj_close": 123.63, ++ }, ++ { ++ "date": "2023-01-03", ++ "symbol": "MSFT", ++ "open": 243.08, ++ "high": 245.75, ++ "low": 237.40, ++ "close": 239.58, ++ "volume": 25740000, ++ "adj_close": 234.42, ++ }, ++ { ++ "date": "2023-01-04", ++ "symbol": "AAPL", ++ "open": 126.89, ++ "high": 128.66, ++ "low": 125.08, ++ "close": 126.36, ++ "volume": 89113600, ++ "adj_close": 124.90, ++ }, ++ { ++ "date": "2023-01-04", ++ "symbol": "MSFT", ++ "open": 232.28, ++ "high": 232.87, ++ "low": 225.96, ++ "close": 229.10, ++ "volume": 50623400, ++ "adj_close": 224.17, ++ }, ++ ], ++ [ ++ "date", ++ "symbol", ++ "open", ++ "high", ++ "low", ++ "close", ++ "volume", ++ "adj_close", ++ ], ++ ) ++ _assert_download_symbols(download.call_args, {"AAPL", "MSFT"}) ++ _assert_download_dates(download.call_args) ++ assert _download_auto_adjust(download.call_args) is False ++ ++ assert download.call_args.kwargs.get("interval", "1d") == "1d" ++ assert download.call_args.kwargs.get("timeframe", "1d") == "1d" ++ ++ ++def test_auto_adjust_true_uses_adjusted_close_without_adj_close_column(): ++ ++ ++ ++ yf = YFinance(auto_adjust=True) ++ ++ with mock.patch.object( ++ yfinance, "download", return_value=_single_symbol_daily(True) ++ ) as download: ++ result = yf.query("AAPL", START, END) ++ ++ _assert_frame( ++ result, ++ [ ++ { ++ "date": "2023-01-03", ++ "symbol": "AAPL", ++ "open": 130.28, ++ "high": 130.90, ++ "low": 124.17, ++ "close": 123.63, ++ "volume": 112117500, ++ }, ++ { ++ "date": "2023-01-04", ++ "symbol": "AAPL", ++ "open": 126.89, ++ "high": 128.66, ++ "low": 125.08, ++ "close": 124.90, ++ "volume": 89113600, ++ }, ++ { ++ "date": "2023-01-05", ++ "symbol": "AAPL", ++ "open": 127.13, ++ "high": 127.77, ++ "low": 124.76, ++ "close": 123.58, ++ "volume": 80962700, ++ }, ++ ], ++ ["date", "symbol", "open", "high", "low", "close", "volume"], ++ ) ++ _assert_download_symbols(download.call_args, {"AAPL"}) ++ _assert_download_dates(download.call_args) ++ assert _download_auto_adjust(download.call_args) is True ++ ++ ++def test_empty_provider_result_returns_expected_schema_for_each_adjust_mode(): ++ ++ ++ ++ for auto_adjust, expected_columns in [ ++ ( ++ False, ++ [ ++ "symbol", ++ "date", ++ "open", ++ "high", ++ "low", ++ "close", ++ "volume", ++ "adj_close", ++ ], ++ ), ++ ( ++ True, ++ ["symbol", "date", "open", "high", "low", "close", "volume"], ++ ), ++ ]: ++ yf = YFinance(auto_adjust=auto_adjust) ++ with mock.patch.object( ++ yfinance, "download", return_value=pd.DataFrame() ++ ) as download: ++ result = yf.query("AAPL", START, END) ++ ++ assert result.to_dict("records") == [] ++ ++ assert set(result.columns) == set(expected_columns) ++ assert result.shape == (0, len(expected_columns)) ++ assert _download_auto_adjust(download.call_args) is auto_adjust ++ ++ ++def test_instances_keep_auto_adjust_settings_independently_across_calls(): ++ ++ ++ ++ unadjusted = YFinance(auto_adjust=False) ++ adjusted = YFinance(auto_adjust=True) ++ ++ with mock.patch.object( ++ yfinance, ++ "download", ++ side_effect=[ ++ _single_symbol_daily(False), ++ _single_symbol_daily(True), ++ _single_symbol_daily(False), ++ ], ++ ) as download: ++ first_unadjusted = unadjusted.query("AAPL", START, END) ++ adjusted_result = adjusted.query("AAPL", START, END) ++ second_unadjusted = unadjusted.query("AAPL", START, END) ++ ++ ++ assert set(first_unadjusted.columns) == { ++ "date", ++ "symbol", ++ "open", ++ "high", ++ "low", ++ "close", ++ "volume", ++ "adj_close", ++ } ++ _assert_values_by_date(first_unadjusted, "close", [125.07, 126.36, 125.02]) ++ _assert_values_by_date(first_unadjusted, "adj_close", [123.63, 124.90, 123.58]) ++ ++ assert set(adjusted_result.columns) == { ++ "date", ++ "symbol", ++ "open", ++ "high", ++ "low", ++ "close", ++ "volume", ++ } ++ _assert_values_by_date(adjusted_result, "close", [123.63, 124.90, 123.58]) ++ ++ assert set(second_unadjusted.columns) == { ++ "date", ++ "symbol", ++ "open", ++ "high", ++ "low", ++ "close", ++ "volume", ++ "adj_close", ++ } ++ _assert_values_by_date(second_unadjusted, "close", [125.07, 126.36, 125.02]) ++ assert [ ++ _download_auto_adjust(call) for call in download.call_args_list ++ ] == [False, True, False] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,23 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++ ++ ++set -euo pipefail ++ ++cd /workspace/repo ++ ++exec env \ ++ PYTHONPATH=/workspace/repo/src \ ++ PYTHONDONTWRITEBYTECODE=1 \ ++ PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \ ++ PIP_NO_INDEX=1 \ ++ python -m pytest /workspace/repo/usercase-test-coderl/test_yfinance_acceptance.py -v diff --git a/tasks/format-code-task-000852/tests/test.sh b/tasks/format-code-task-000852/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..417371f36236487e08e7bcbf50067519e27d82da --- /dev/null +++ b/tasks/format-code-task-000852/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_yfinance_acceptance.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000852/tests/test_command.sh b/tasks/format-code-task-000852/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000852/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-000855/environment/Dockerfile b/tasks/format-code-task-000855/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0978a4a3a8738908b3e98974e5775f60f906e6c3 --- /dev/null +++ b/tasks/format-code-task-000855/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2e6a08f7306f3984ec87f5e7a3281e4207beec96dcd1dd946a8d42c71e7d52c5 diff --git a/tasks/format-code-task-000855/environment/setup/files/blocklist b/tasks/format-code-task-000855/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000855/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000855/environment/setup/setup.sh b/tasks/format-code-task-000855/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000855/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000855/tests/test.patch b/tasks/format-code-task-000855/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1abcc9203545126273e52a0516ed8c2a0f1b6e3d --- /dev/null +++ b/tasks/format-code-task-000855/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/test/sort-objects-array-advanced.test.js b/test/sort-objects-array-advanced.test.js +new file mode 100644 +index 0000000..fcfb7fd +--- /dev/null ++++ b/test/sort-objects-array-advanced.test.js +@@ -0,0 +1,58 @@ ++import test from 'ava' ++import {sortObjectsArray} from '../src' ++ ++test('sorts by multiple criteria, including nested properties, in declared precedence order', t => { ++ const records = [ ++ {id: 'first-ng', profile: {last: 'Ng'}, score: 10}, ++ {id: 'adams', profile: {last: 'Adams'}, score: 5}, ++ {id: 'second-ng', profile: {last: 'Ng'}, score: 20}, ++ {id: 'third-ng', profile: {last: 'Ng'}, score: 20}, ++ ] ++ ++ const sorted = records.slice().sort(sortObjectsArray(['profile.last', '-score'])) ++ ++ t.deepEqual(sorted.map(record => record.id), [ ++ 'adams', ++ 'second-ng', ++ 'third-ng', ++ 'first-ng', ++ ]) ++}) ++ ++test('places null and undefined nested values after defined values in ascending order', t => { ++ const records = [ ++ {id: 'defined', profile: {rank: 2}}, ++ {id: 'null', profile: {rank: null}}, ++ {id: 'missing'}, ++ {id: 'zero', profile: {rank: 0}}, ++ ] ++ ++ const sorted = records.slice().sort(sortObjectsArray('profile.rank')) ++ ++ t.deepEqual(sorted.map(record => record.id), ['zero', 'defined', 'null', 'missing']) ++}) ++ ++test('keeps null and undefined values after defined values for descending criteria too', t => { ++ const records = [ ++ {id: 'defined-low', rank: 2}, ++ {id: 'null', rank: null}, ++ {id: 'missing'}, ++ {id: 'defined-high', rank: 9}, ++ ] ++ ++ const sorted = records.slice().sort(sortObjectsArray('-rank')) ++ ++ t.deepEqual(sorted.map(record => record.id), ['defined-high', 'defined-low', 'null', 'missing']) ++}) ++ ++test('uses later criteria to order records that are both missing on an earlier criterion', t => { ++ const records = [ ++ {id: 'missing-low', profile: {}, score: 1}, ++ {id: 'missing-high', score: 9}, ++ {id: 'defined', profile: {last: 'Adams'}, score: 0}, ++ ] ++ ++ const sorted = records.slice().sort(sortObjectsArray(['profile.last', '-score'])) ++ ++ t.deepEqual(sorted.map(record => record.id), ['defined', 'missing-high', 'missing-low']) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,7 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++NODE_ENV=test ./node_modules/.bin/ava --require babel-register \ ++ test/sort-objects-array-advanced.test.js \ ++ test/sort-objects-array.test.js diff --git a/tasks/format-code-task-000855/tests/test.sh b/tasks/format-code-task-000855/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a910ab23d0eb503facad94396d6af15d0dc8ebab --- /dev/null +++ b/tasks/format-code-task-000855/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/sort-objects-array-advanced.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-000855/tests/test_command.sh b/tasks/format-code-task-000855/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000855/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000863/environment/Dockerfile b/tasks/format-code-task-000863/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ed6d39fe3937d3f4ab24cb0cba2859f6065616a0 --- /dev/null +++ b/tasks/format-code-task-000863/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:006404753bd006849b7c47bfa9b9d9369046b3849fa9af3baee3b4c3c2696cb1 diff --git a/tasks/format-code-task-000863/environment/setup/files/blocklist b/tasks/format-code-task-000863/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000863/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000863/environment/setup/setup.sh b/tasks/format-code-task-000863/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000863/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000863/tests/test.patch b/tasks/format-code-task-000863/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..526818d56cfa8ca50e05c3f02b2ee0e4865b01c6 --- /dev/null +++ b/tasks/format-code-task-000863/tests/test.patch @@ -0,0 +1,60 @@ +diff --git a/metricbeat/module/docker/memory/memory_test.go b/metricbeat/module/docker/memory/memory_test.go +index 0fd15dc34831..7f1a1eec5eb4 100644 +--- a/metricbeat/module/docker/memory/memory_test.go ++++ b/metricbeat/module/docker/memory/memory_test.go +@@ -125,6 +125,34 @@ func TestMemoryServiceBadData(t *testing.T) { + + } + ++func TestMemoryMath(t *testing.T) { ++ memStats := types.StatsJSON{ ++ Stats: types.Stats{ ++ Read: time.Now(), ++ PreCPUStats: types.CPUStats{ ++ CPUUsage: types.CPUUsage{ ++ TotalUsage: 200, ++ }, ++ }, ++ MemoryStats: types.MemoryStats{ ++ Limit: 5, ++ Usage: 5000, ++ Stats: map[string]uint64{ ++ "total_inactive_file": 1000, ++ "inactive_file": 900, ++ }, ++ }, ++ }, ++ } ++ ++ memoryService := &MemoryService{} ++ memoryRawStats := []docker.Stat{ ++ docker.Stat{Stats: memStats, Container: &types.Container{Names: []string{"test-container"}, Labels: map[string]string{}}}, ++ } ++ rawStats := memoryService.getMemoryStatsList(memoryRawStats, false) ++ assert.Equal(t, float64(800), rawStats[0].UsageP) ++} ++ + func getMemoryStats(read time.Time, number uint64) types.StatsJSON { + + myMemoryStats := types.StatsJSON{ +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+3RPWvDMBAGYM35FUd225I/4qlLKXTK1O5GlkRjElsgnw2F/viqhrahpc2SUELf ++Z9GhOyGhN22n7mAbN8yZuBQZ1VW1rNHXdalVlcu8zqUqCiGVqupSUHWxFx2ZRtaBSATv+be5U/0r ++lX7mz27kxvi+14NNx9357jiVf54XH/nLTRnzLzdKCpLne8LP/nn+xtISfOvs6snTW0lp1jsOnWmd ++5qz3djq4zHqzdyE2eh+eM0pmSoyfBr5RlIRpoPVjPLldug8uzJ1xzb1732DN48u3gVtt7zTro8ZW ++8269+usvAQAAAAAAAAAAAAAAAAAAAAC4Gq+ywIiyACgAAA== +diff --git 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-000863/tests/test.sh b/tasks/format-code-task-000863/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4970b36f3aa53fce9d4565377f253e366705b3e4 --- /dev/null +++ b/tasks/format-code-task-000863/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' +metricbeat/module/docker/memory/memory_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-000863/tests/test_command.sh b/tasks/format-code-task-000863/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000863/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000864/environment/Dockerfile b/tasks/format-code-task-000864/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..debfd2bdc133b9693903150d88529e2f8351c5e7 --- /dev/null +++ b/tasks/format-code-task-000864/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:991cb92d1e6ea3eb4b494353f5c3ecb418b8e0e963c3a8ae00c53fc91b4a534b diff --git a/tasks/format-code-task-000864/environment/setup/files/blocklist b/tasks/format-code-task-000864/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000864/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000864/environment/setup/setup.sh b/tasks/format-code-task-000864/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000864/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000864/tests/test.patch b/tasks/format-code-task-000864/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d47ddbd6b371038552ac480219869425494addf1 --- /dev/null +++ b/tasks/format-code-task-000864/tests/test.patch @@ -0,0 +1,196 @@ +diff --git a/operators/pkg/controller/apmserver/keystore_addcommand_test.go b/operators/pkg/controller/apmserver/keystore_addcommand_test.go +new file mode 100644 +index 000000000..d5abdaf8d +--- /dev/null ++++ b/operators/pkg/controller/apmserver/keystore_addcommand_test.go +@@ -0,0 +1,81 @@ ++ ++ ++ ++ ++package apmserver ++ ++import ( ++ "strings" ++ "testing" ++ ++ apmv1alpha1 "github.com/elastic/cloud-on-k8s/operators/pkg/apis/apm/v1alpha1" ++ commonv1alpha1 "github.com/elastic/cloud-on-k8s/operators/pkg/apis/common/v1alpha1" ++ "github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/keystore" ++ "github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/watches" ++ "github.com/elastic/cloud-on-k8s/operators/pkg/utils/k8s" ++ "github.com/stretchr/testify/require" ++ corev1 "k8s.io/api/core/v1" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++ "k8s.io/client-go/kubernetes/scheme" ++ "k8s.io/client-go/tools/record" ++ "sigs.k8s.io/controller-runtime/pkg/client/fake" ++) ++ ++ ++ ++ ++func renderApmKeystoreInitScript(t *testing.T) string { ++ t.Helper() ++ secretName := "secure-settings-secret" ++ secret := &corev1.Secret{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Namespace: "ns", ++ Name: secretName, ++ ResourceVersion: "1", ++ }, ++ } ++ apm := &apmv1alpha1.ApmServer{ ++ TypeMeta: metav1.TypeMeta{Kind: apmv1alpha1.Kind}, ++ ObjectMeta: metav1.ObjectMeta{ ++ Namespace: "ns", ++ Name: "apm", ++ }, ++ Spec: apmv1alpha1.ApmServerSpec{ ++ SecureSettings: &commonv1alpha1.SecretRef{SecretName: secretName}, ++ }, ++ } ++ client := k8s.WrapClient(fake.NewFakeClient(secret)) ++ w := watches.NewDynamicWatches() ++ require.NoError(t, w.InjectScheme(scheme.Scheme)) ++ resources, err := keystore.NewResources(client, record.NewFakeRecorder(100), w, apm, initContainerParameters) ++ require.NoError(t, err) ++ require.NotNil(t, resources) ++ require.True(t, len(resources.InitContainer.Command) >= 4, "init container Command shorter than expected: %v", resources.InitContainer.Command) ++ return resources.InitContainer.Command[len(resources.InitContainer.Command)-1] ++} ++ ++ ++ ++ ++func TestApmKeystoreAddCommand_NoTwoArgs(t *testing.T) { ++ script := renderApmKeystoreInitScript(t) ++ bug := `apm-server keystore add "$key" "$filename"` ++ if strings.Contains(script, bug) { ++ t.Fatalf("APM keystore script still contains the buggy two-arg invocation %q\n--- script ---\n%s", bug, script) ++ } ++} ++ ++ ++ ++func TestApmKeystoreAddCommand_UsesStdin(t *testing.T) { ++ script := renderApmKeystoreInitScript(t) ++ if !strings.Contains(script, "apm-server keystore add") { ++ t.Fatalf("APM keystore script does not invoke `apm-server keystore add`:\n%s", script) ++ } ++ if !strings.Contains(script, "--stdin") { ++ t.Fatalf("APM keystore script must pass --stdin to apm-server keystore add:\n%s", script) ++ } ++ if !strings.Contains(script, `"$filename"`) { ++ t.Fatalf("APM keystore script must reference the per-entry $filename variable:\n%s", script) ++ } ++} +diff --git a/operators/pkg/controller/kibana/keystore_addcommand_test.go b/operators/pkg/controller/kibana/keystore_addcommand_test.go +new file mode 100644 +index 000000000..1a9464ef9 +--- /dev/null ++++ b/operators/pkg/controller/kibana/keystore_addcommand_test.go +@@ -0,0 +1,81 @@ ++ ++ ++ ++ ++package kibana ++ ++import ( ++ "strings" ++ "testing" ++ ++ commonv1alpha1 "github.com/elastic/cloud-on-k8s/operators/pkg/apis/common/v1alpha1" ++ kbtype "github.com/elastic/cloud-on-k8s/operators/pkg/apis/kibana/v1alpha1" ++ "github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/keystore" ++ "github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/watches" ++ "github.com/elastic/cloud-on-k8s/operators/pkg/utils/k8s" ++ "github.com/stretchr/testify/require" ++ corev1 "k8s.io/api/core/v1" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++ "k8s.io/client-go/kubernetes/scheme" ++ "k8s.io/client-go/tools/record" ++ "sigs.k8s.io/controller-runtime/pkg/client/fake" ++) ++ ++ ++ ++ ++func renderKibanaKeystoreInitScript(t *testing.T) string { ++ t.Helper() ++ secretName := "secure-settings-secret" ++ secret := &corev1.Secret{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Namespace: "ns", ++ Name: secretName, ++ ResourceVersion: "1", ++ }, ++ } ++ kb := &kbtype.Kibana{ ++ TypeMeta: metav1.TypeMeta{Kind: kbtype.Kind}, ++ ObjectMeta: metav1.ObjectMeta{ ++ Namespace: "ns", ++ Name: "kb", ++ }, ++ Spec: kbtype.KibanaSpec{ ++ SecureSettings: &commonv1alpha1.SecretRef{SecretName: secretName}, ++ }, ++ } ++ client := k8s.WrapClient(fake.NewFakeClient(secret)) ++ w := watches.NewDynamicWatches() ++ require.NoError(t, w.InjectScheme(scheme.Scheme)) ++ resources, err := keystore.NewResources(client, record.NewFakeRecorder(100), w, kb, initContainersParameters) ++ require.NoError(t, err) ++ require.NotNil(t, resources) ++ require.True(t, len(resources.InitContainer.Command) >= 4, "init container Command shorter than expected: %v", resources.InitContainer.Command) ++ return resources.InitContainer.Command[len(resources.InitContainer.Command)-1] ++} ++ ++ ++ ++ ++func TestKibanaKeystoreAddCommand_NoTwoArgs(t *testing.T) { ++ script := renderKibanaKeystoreInitScript(t) ++ bug := `kibana-keystore add "$key" "$filename"` ++ if strings.Contains(script, bug) { ++ t.Fatalf("Kibana keystore script still contains the buggy two-arg invocation %q\n--- script ---\n%s", bug, script) ++ } ++} ++ ++ ++ ++func TestKibanaKeystoreAddCommand_UsesStdin(t *testing.T) { ++ script := renderKibanaKeystoreInitScript(t) ++ if !strings.Contains(script, "kibana-keystore add") { ++ t.Fatalf("Kibana keystore script does not invoke `kibana-keystore add`:\n%s", script) ++ } ++ if !strings.Contains(script, "--stdin") { ++ t.Fatalf("Kibana keystore script must pass --stdin to kibana-keystore add:\n%s", script) ++ } ++ if !strings.Contains(script, `"$filename"`) { ++ t.Fatalf("Kibana keystore script must reference the per-entry $filename variable:\n%s", script) ++ } ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..7006e3efa +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["D=\"$(pwd)\" && ln -sfn \"$D\" /go/src/github.com/elastic/cloud-on-k8s && cd /go/src/github.com/elastic/cloud-on-k8s/operators && GO111MODULE=off go test ./pkg/controller/apmserver/ ./pkg/controller/kibana/ -count=1 -run 'TestApmKeystoreAddCommand|TestKibanaKeystoreAddCommand'"] ++} +diff --git 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 ++D="$(pwd)" && ln -sfn "$D" /go/src/github.com/elastic/cloud-on-k8s && cd /go/src/github.com/elastic/cloud-on-k8s/operators && GO111MODULE=off go test ./pkg/controller/apmserver/ ./pkg/controller/kibana/ -count=1 -run 'TestApmKeystoreAddCommand|TestKibanaKeystoreAddCommand' ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000864/tests/test.sh b/tasks/format-code-task-000864/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1a2abd7eaeb9961a9ecb234274e6e705d997c08d --- /dev/null +++ b/tasks/format-code-task-000864/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' +operators/pkg/controller/apmserver/keystore_addcommand_test.go +operators/pkg/controller/kibana/keystore_addcommand_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-000864/tests/test_command.sh b/tasks/format-code-task-000864/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000864/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000890/environment/Dockerfile b/tasks/format-code-task-000890/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..30d652177842ca539dff7b452764bdefc01221de --- /dev/null +++ b/tasks/format-code-task-000890/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f58b45e0de69e12e187e238dc92f26d163e7ae04d603ee493003d8b37fece8b9 diff --git a/tasks/format-code-task-000890/environment/setup/files/blocklist b/tasks/format-code-task-000890/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000890/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000890/environment/setup/setup.sh b/tasks/format-code-task-000890/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000890/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000890/tests/test.patch b/tasks/format-code-task-000890/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..49a337ea92d949d335fd0b3e27b73b554207e852 --- /dev/null +++ b/tasks/format-code-task-000890/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/__tests__/catch-or-return.js b/__tests__/catch-or-return.js +index 679ab5b..e31e35d 100644 +--- a/__tests__/catch-or-return.js ++++ b/__tests__/catch-or-return.js +@@ -164,3 +164,60 @@ ruleTester.run('catch-or-return', rule, { + } + ] + }) ++ ++ruleTester.run('catch-or-return allowFinally', rule, { ++ valid: [ ++ // issue example: .then().catch().finally() valid with allowFinally:true ++ { ++ code: 'frank().then(go).catch(err => log(err)).finally(fn)', ++ options: [{ allowFinally: true }], ++ parserOptions: { ecmaVersion: 6 } ++ }, ++ // basic .catch().finally() ++ { ++ code: 'frank().catch(jail).finally(fn)', ++ options: [{ allowFinally: true }] ++ }, ++ // Promise.resolve(...).catch().finally() valid ++ { ++ code: 'Promise.resolve(frank).catch(jail).finally(fn)', ++ options: [{ allowFinally: true }] ++ }, ++ // literal ['catch']().finally() valid ++ { ++ code: 'Promise.resolve(frank)["catch"](jail).finally(fn)', ++ options: [{ allowFinally: true }] ++ }, ++ // allowThen + allowFinally combined ++ { ++ code: 'frank().then(go).then(a, b).finally(fn)', ++ options: [{ allowThen: true, allowFinally: true }] ++ } ++ ], ++ ++ invalid: [ ++ // issue example: .then().finally() WITHOUT catch invalid even with allowFinally:true ++ { ++ code: 'frank().then(go).finally(fn)', ++ options: [{ allowFinally: true }], ++ errors: [{ message: catchMessage }] ++ }, ++ // Promise.resolve().finally() (no catch) invalid with allowFinally:true ++ { ++ code: 'Promise.resolve(frank).finally(fn)', ++ options: [{ allowFinally: true }], ++ errors: [{ message: catchMessage }] ++ }, ++ // Preservation: without allowFinally, .catch().finally() is invalid ++ { ++ code: 'frank().then(go).catch(err).finally(fn)', ++ errors: [{ message: catchMessage }] ++ }, ++ // Preservation: untouched bare .then(go) still invalid even with allowFinally:true ++ { ++ code: 'frank().then(go)', ++ options: [{ allowFinally: true }], ++ errors: [{ message: catchMessage }] ++ } ++ ] ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..88ae8ab +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest __tests__/catch-or-return.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 ++# Verifier for the opensource-code dataset. Exit 0 means resolved. ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest __tests__/catch-or-return.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000890/tests/test.sh b/tasks/format-code-task-000890/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..77d40f53c75c32154430b7969337fcad1ef9b6e5 --- /dev/null +++ b/tasks/format-code-task-000890/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__/catch-or-return.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-000890/tests/test_command.sh b/tasks/format-code-task-000890/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000890/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000897/environment/Dockerfile b/tasks/format-code-task-000897/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0b2da195a0c81594712c5f1d102a5e7869d9a2ca --- /dev/null +++ b/tasks/format-code-task-000897/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ea7c87c304242ffaf650a6e62dfcbb45aed43d61b709ea107e70d3dcf8e52435 diff --git a/tasks/format-code-task-000897/environment/setup/files/blocklist b/tasks/format-code-task-000897/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000897/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000897/environment/setup/setup.sh b/tasks/format-code-task-000897/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000897/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000897/tests/test.patch b/tasks/format-code-task-000897/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d2805186fd6dd6350273aeb7b983112f6a2f530d --- /dev/null +++ b/tasks/format-code-task-000897/tests/test.patch @@ -0,0 +1,81 @@ +diff --git a/e2e/ctl_v3_lease_test.go b/e2e/ctl_v3_lease_test.go +index 34571ac9f176..4c11d0707d53 100644 +--- a/e2e/ctl_v3_lease_test.go ++++ b/e2e/ctl_v3_lease_test.go +@@ -24,6 +24,7 @@ import ( + func TestCtlV3LeaseGrantTimeToLive(t *testing.T) { testCtl(t, leaseTestGrantTimeToLive) } + func TestCtlV3LeaseGrantLeases(t *testing.T) { testCtl(t, leaseTestGrantLeasesList) } + func TestCtlV3LeaseKeepAlive(t *testing.T) { testCtl(t, leaseTestKeepAlive) } ++func TestCtlV3LeaseKeepAliveOnce(t *testing.T) { testCtl(t, leaseTestKeepAliveOnce) } + func TestCtlV3LeaseRevoke(t *testing.T) { testCtl(t, leaseTestRevoke) } + + func leaseTestGrantTimeToLive(cx ctlCtx) { +@@ -89,6 +90,23 @@ func leaseTestKeepAlive(cx ctlCtx) { + } + } + ++func leaseTestKeepAliveOnce(cx ctlCtx) { ++ ++ leaseID, err := ctlV3LeaseGrant(cx, 10) ++ if err != nil { ++ cx.t.Fatalf("leaseTestKeepAlive: ctlV3LeaseGrant error (%v)", err) ++ } ++ if err := ctlV3Put(cx, "key", "val", leaseID); err != nil { ++ cx.t.Fatalf("leaseTestKeepAlive: ctlV3Put error (%v)", err) ++ } ++ if err := ctlV3LeaseKeepAliveOnce(cx, leaseID); err != nil { ++ cx.t.Fatalf("leaseTestKeepAlive: ctlV3LeaseKeepAliveOnce error (%v)", err) ++ } ++ if err := ctlV3Get(cx, []string{"key"}, kv{"key", "val"}); err != nil { ++ cx.t.Fatalf("leaseTestKeepAlive: ctlV3Get error (%v)", err) ++ } ++} ++ + func leaseTestRevoke(cx ctlCtx) { + // put with TTL 10 seconds and revoke + leaseID, err := ctlV3LeaseGrant(cx, 10) +@@ -143,6 +161,20 @@ func ctlV3LeaseKeepAlive(cx ctlCtx, leaseID string) error { + return proc.Stop() + } + ++func ctlV3LeaseKeepAliveOnce(cx ctlCtx, leaseID string) error { ++ cmdArgs := append(cx.PrefixArgs(), "lease", "keep-alive", "--once", leaseID) ++ ++ proc, err := spawnCmd(cmdArgs) ++ if err != nil { ++ return err ++ } ++ ++ if _, err = proc.Expect(fmt.Sprintf("lease %s keepalived with TTL(", leaseID)); err != nil { ++ return err ++ } ++ return proc.Stop() ++} ++ + func ctlV3LeaseRevoke(cx ctlCtx, leaseID string) error { + cmdArgs := append(cx.PrefixArgs(), "lease", "revoke", leaseID) + return spawnWithExpect(cmdArgs, fmt.Sprintf("lease %s revoked", leaseID)) +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+3ST0/bMBQA8Jz9KR7iAoc0caiLhNQDbBOTBioaf67IjV+pRWJntlNt3x47RV2F ++BFxAbOL9Lkkc+/nZ743mvW7ULZpVkb2XMjoUYnhGT5/DOxcVrypRVuODrORcHIoMxLtltKX3QTqA ++zFkbXpr32v//1Ohv/QP6cFvbtpVGjfzy7fZ4rf6TsdjUn4tU//GETzIo3y6F533y+u/uFHNtirn0 ++S1YrGJpgjoqxXThJnQEY4nDsiOGlDg3E6dJp9LDn8FevHSpYWAdYIaTFfp/h7866AKczzvn57Ov1 ++2bepXSxY2gOGdkvRLzFA38EKjYqrT2cXx1ffYc/LFkH69TTwtdNdAGXjbtoEdEY2zZ995lrI3QLu ++bCfDsvCuZu290g7y7nGMNQZyvzlNUbeqeNxpM7a1epNwSmL6ZMZRkUofP1LWP3sDYYnQoPQI94hd ++Lhu9QrCmXp9/+xaLeCnszg7jkK9i0nH5Vfz4Epqbg7MU40cMcZwizFKAvLa9CVMOedAt2j4Ar0rP ++PrpJCCGEEEIIIYQQQgghhBBCCCGEEELIP+sBnKXYHgAoAAA= +diff --git 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-000897/tests/test.sh b/tasks/format-code-task-000897/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5fb6e3607b89774483c66841a5f701783a8caddd --- /dev/null +++ b/tasks/format-code-task-000897/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/ctl_v3_lease_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-000897/tests/test_command.sh b/tasks/format-code-task-000897/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000897/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000899/environment/Dockerfile b/tasks/format-code-task-000899/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e808e68f98f9876e6a5735bae1be6332d6397aa7 --- /dev/null +++ b/tasks/format-code-task-000899/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8efe7685981a2982d3f091c4cde906a30341eb4960258d4952980a7b18397418 diff --git a/tasks/format-code-task-000899/environment/setup/files/blocklist b/tasks/format-code-task-000899/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000899/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000899/environment/setup/setup.sh b/tasks/format-code-task-000899/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000899/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000899/tests/test.patch b/tasks/format-code-task-000899/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5efdab102472159de6fe6cb591625a2cdab1bcea --- /dev/null +++ b/tasks/format-code-task-000899/tests/test.patch @@ -0,0 +1,94 @@ +diff --git a/op-service/log/context_handler_test.go b/op-service/log/context_handler_test.go +index 7ff6baaf1a455..45aa21e46ba26 100644 +--- a/op-service/log/context_handler_test.go ++++ b/op-service/log/context_handler_test.go +@@ -119,8 +119,20 @@ func TestContextHandler_HandleError(t *testing.T) { + record := slog.NewRecord(time.Now(), slog.LevelInfo, "test message", 0) + err := handler.Handle(ctx, record) + +- require.Error(t, err) +- require.Contains(t, err.Error(), "expected value to implement slog.LogValuer") ++ ++ require.NoError(t, err) ++ require.Len(t, inner.records, 1) ++ ++ ++ found := false ++ inner.records[0].Attrs(func(attr slog.Attr) bool { ++ if attr.Key == "attr_name" { ++ found = true ++ return false ++ } ++ return true ++ }) ++ require.False(t, found, "Invalid attribute should not be added to record") + } + + func TestContextHandler_Enabled(t *testing.T) { +@@ -194,3 +206,46 @@ func TestForkedContexts(t *testing.T) { + require.Equal(t, "c", fork2Index[1].name) + require.Equal(t, "keyC", fork2Index[1].key) + } ++ ++type scopeKeyType struct{} ++ ++var scopeKey scopeKeyType = scopeKeyType{} ++ ++func TestContextHandler_SilentLoggingBugFixed(t *testing.T) { ++ ++ ++ ++ inner := &testHandler{enabled: true} ++ handler := WrapContextHandler(inner) ++ ++ ctx := context.Background() ++ ++ ++ ctx = RegisterLogAttrOnContext(ctx, "scope", scopeKey) ++ ++ ctx = context.WithValue(ctx, scopeKey, "plain-string-value") ++ ++ record := slog.NewRecord(time.Now(), slog.LevelInfo, "test message", 0) ++ err := handler.Handle(ctx, record) ++ ++ ++ require.NoError(t, err) ++ ++ ++ require.Len(t, inner.records, 1) ++ require.Equal(t, "test message", inner.records[0].Message) ++ ++ ++ found := false ++ inner.records[0].Attrs(func(attr slog.Attr) bool { ++ if attr.Key == "scope" { ++ found = true ++ return false ++ } ++ return true ++ }) ++ require.False(t, found, "Invalid context attribute should not be added to log record") ++ ++ ++ ++} +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+3R0QqCMBTG8V33FOcF1Kktr3qWSB0VlAudPn8qhBGUN0lE/98uzoEN9sEX5u3p ++XO5s1UVqKbqXGTPO3vMc99gkOh1OulE6jk22VmIWS/Sgbfy+FlG1c/7du7n7HxVO/Xvb+F3hLpd9 ++VYbN8XN/zPa/Sab+ddL3vzZZpkR/LsJrf95/UcpYfG7L1cHJsEoYuWvQ2Lo7FTY6u0MkQSdB4drK ++b+PVtxMDAAAAAAAAAAAAAAAAuLsBl7of9QAoAAA= +diff --git 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-000899/tests/test.sh b/tasks/format-code-task-000899/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d306d8b01686ca8cee85ddd86ff887a1937a7448 --- /dev/null +++ b/tasks/format-code-task-000899/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' +op-service/log/context_handler_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-000899/tests/test_command.sh b/tasks/format-code-task-000899/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000899/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001112/environment/Dockerfile b/tasks/format-code-task-001112/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7cd011fcfd5459f4567c5f593d23c5136bf4e576 --- /dev/null +++ b/tasks/format-code-task-001112/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:62de8ebf49d0c6bec5bb6e20f27ddfdd2c3e3e79d2b5b972737a56fe105b8dbb diff --git a/tasks/format-code-task-001112/environment/setup/files/blocklist b/tasks/format-code-task-001112/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001112/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001112/environment/setup/setup.sh b/tasks/format-code-task-001112/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001112/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001112/tests/test.patch b/tasks/format-code-task-001112/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a273628896cfb7309e163be7af4bc784c5ebb862 --- /dev/null +++ b/tasks/format-code-task-001112/tests/test.patch @@ -0,0 +1,336 @@ +diff --git a/tests/pgo_nsys_converter_cli_test.py b/tests/pgo_nsys_converter_cli_test.py +new file mode 100644 +index 000000000..663fe16ea +--- /dev/null ++++ b/tests/pgo_nsys_converter_cli_test.py +@@ -0,0 +1,320 @@ ++#!/usr/bin/env python3 ++ ++import ast ++import csv ++import os ++from pathlib import Path ++import re ++import subprocess ++import sys ++import tempfile ++import unittest ++ ++ ++REPO_ROOT = Path(__file__).resolve().parents[1] ++CONVERTER = REPO_ROOT / "jax" / "tools" / "pgo_nsys_converter.py" ++ENTRY_RE = re.compile( ++ r'costs\s*\{\s*name:\s*"((?:\\.|[^"\\])*)"\s*' ++ r'cost_us:\s*([-+0-9.eE]+)\s*\}', ++ re.DOTALL, ++) ++ ++ ++def write_csv(path, rows, fieldnames=("NVTX Range", "Avg (ns)")): ++ with path.open("w", newline="") as csv_file: ++ writer = csv.DictWriter(csv_file, fieldnames=fieldnames) ++ writer.writeheader() ++ writer.writerows(rows) ++ ++ ++def read_entries(path): ++ text = path.read_text() ++ matches = list(ENTRY_RE.finditer(text)) ++ remainder = ENTRY_RE.sub("", text).strip() ++ if remainder: ++ raise AssertionError(f"unexpected pbtxt content: {remainder!r}") ++ return [ ++ (ast.literal_eval(f'"{match.group(1)}"'), float(match.group(2))) ++ for match in matches ++ ] ++ ++ ++class PgoNsysConverterCliTest(unittest.TestCase): ++ ++ def setUp(self): ++ self.temp_dir = tempfile.TemporaryDirectory() ++ self.addCleanup(self.temp_dir.cleanup) ++ self.root = Path(self.temp_dir.name) ++ ++ def run_converter(self, *args, env=None): ++ child_env = os.environ.copy() ++ if env: ++ child_env.update(env) ++ return subprocess.run( ++ [sys.executable, "-S", str(CONVERTER), *map(str, args)], ++ cwd=REPO_ROOT, ++ env=child_env, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ check=False, ++ ) ++ ++ def make_fake_nsys(self): ++ bin_dir = self.root / "bin" ++ bin_dir.mkdir() ++ fake = bin_dir / "nsys" ++ fake.write_text( ++ """#!/usr/bin/python3 ++import csv ++import os ++from pathlib import Path ++import sys ++ ++args = sys.argv[1:] ++expected_profile = os.environ["FAKE_NSYS_EXPECT_PROFILE"] ++if expected_profile not in args: ++ print("profile argument was not forwarded", file=sys.stderr) ++ raise SystemExit(21) ++if "stats" not in args or "nvtxkernsum" not in args: ++ print("missing nsys stats nvtxkernsum selection", file=sys.stderr) ++ raise SystemExit(23) ++if os.environ.get("FAKE_NSYS_EXIT"): ++ print("synthetic nsys failure", file=sys.stderr) ++ raise SystemExit(int(os.environ["FAKE_NSYS_EXIT"])) ++try: ++ if "-o" in args: ++ output_prefix = Path(args[args.index("-o") + 1]) ++ elif "--output" in args: ++ output_prefix = Path(args[args.index("--output") + 1]) ++ else: ++ output_prefix = Path(next(arg.split("=", 1)[1] for arg in args ++ if arg.startswith("--output="))) ++except (ValueError, IndexError, StopIteration): ++ print("missing nsys output prefix", file=sys.stderr) ++ raise SystemExit(22) ++ ++report = Path(str(output_prefix) + "_nvtxkernsum.csv") ++database = Path(str(output_prefix) + ".sqlite") ++report.parent.mkdir(parents=True, exist_ok=True) ++with report.open("w", newline="") as report_file: ++ writer = csv.DictWriter(report_file, fieldnames=("NVTX Range", "Avg (ns)")) ++ writer.writeheader() ++ writer.writerow({"NVTX Range": "kernel hlo_op=profile.op#details", "Avg (ns)": "3250"}) ++database.write_text("generated database") ++Path(os.environ["FAKE_NSYS_MANIFEST"]).write_text(f"{report}\\n{database}\\n") ++""" ++ ) ++ fake.chmod(0o755) ++ return bin_dir ++ ++ def fake_nsys_env(self, profile, manifest, bin_dir, **extra): ++ return { ++ "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', '')}", ++ "FAKE_NSYS_EXPECT_PROFILE": str(profile), ++ "FAKE_NSYS_MANIFEST": str(manifest), ++ **extra, ++ } ++ ++ def test_direct_csv_conversion_preserves_rows_and_escapes_names(self): ++ source = self.root / "profile.csv" ++ output = self.root / "costs.pbtxt" ++ write_csv(source, [ ++ {"NVTX Range": "not an HLO annotation", "Avg (ns)": "not-a-number"}, ++ {"NVTX Range": "prefix hlo_op=fusion.add#suffix", "Avg (ns)": "1500"}, ++ { ++ "NVTX Range": 'prefix hlo_op=quote"and\\slash#suffix', ++ "Avg (ns)": "2250", ++ }, ++ ]) ++ ++ result = self.run_converter( ++ "--csv_profile", ++ source, ++ "--pgle_output_path", ++ output, ++ env={"PATH": str(self.root / "no-external-tools")}, ++ ) ++ ++ self.assertEqual(result.returncode, 0, result.stderr) ++ self.assertEqual( ++ read_entries(output), ++ [("fusion.add", 1.5), ('quote"and\\slash', 2.25)], ++ ) ++ ++ def test_post_process_controls_duplicate_aggregation(self): ++ source = self.root / "duplicates.csv" ++ raw_output = self.root / "raw.pbtxt" ++ compact_output = self.root / "compact.pbtxt" ++ write_csv(source, [ ++ {"NVTX Range": "hlo_op=alpha#", "Avg (ns)": "5000"}, ++ {"NVTX Range": "hlo_op=beta#", "Avg (ns)": "4000"}, ++ {"NVTX Range": "hlo_op=alpha#", "Avg (ns)": "2000"}, ++ {"NVTX Range": "hlo_op=beta#", "Avg (ns)": "6000"}, ++ ]) ++ ++ raw = self.run_converter( ++ "--csv_profile", source, "--pgle_output_path", raw_output ++ ) ++ compact = self.run_converter( ++ "--csv_profile", ++ source, ++ "--pgle_output_path", ++ compact_output, ++ "--post_process", ++ ) ++ ++ self.assertEqual(raw.returncode, 0, raw.stderr) ++ self.assertEqual(compact.returncode, 0, compact.stderr) ++ self.assertEqual( ++ read_entries(raw_output), ++ [("alpha", 5.0), ("beta", 4.0), ("alpha", 2.0), ("beta", 6.0)], ++ ) ++ self.assertEqual( ++ read_entries(compact_output), [("alpha", 2.0), ("beta", 4.0)] ++ ) ++ ++ def test_input_modes_are_mutually_exclusive_and_required(self): ++ source = self.root / "profile.csv" ++ profile = self.root / "profile.nsys-rep" ++ output = self.root / "costs.pbtxt" ++ write_csv(source, []) ++ profile.write_text("profile") ++ ++ neither = self.run_converter("--pgle_output_path", output) ++ both = self.run_converter( ++ "--profile_path", ++ profile, ++ "--csv_profile", ++ source, ++ "--pgle_output_path", ++ output, ++ ) ++ ++ for result in (neither, both): ++ self.assertNotEqual(result.returncode, 0) ++ self.assertIn("--profile_path", result.stderr) ++ self.assertIn("--csv_profile", result.stderr) ++ ++ def test_csv_validation_reports_context_and_preserves_output(self): ++ invalid_values = ("not-a-number", "nan", "inf", "-1") ++ for index, invalid_value in enumerate(invalid_values): ++ with self.subTest(value=invalid_value): ++ source = self.root / f"invalid-{index}.csv" ++ output = self.root / f"invalid-{index}.pbtxt" ++ write_csv(source, [ ++ {"NVTX Range": "hlo_op=bad#", "Avg (ns)": invalid_value} ++ ]) ++ output.write_text("existing output") ++ ++ result = self.run_converter( ++ "--csv_profile", source, "--pgle_output_path", output ++ ) ++ ++ self.assertNotEqual(result.returncode, 0) ++ self.assertIn("Avg (ns)", result.stderr) ++ self.assertRegex(result.stderr.lower(), r"(?:row|line)\s+2") ++ self.assertEqual(output.read_text(), "existing output") ++ ++ for missing_field in ("NVTX Range", "Avg (ns)"): ++ with self.subTest(missing_field=missing_field): ++ fields = tuple( ++ field for field in ("NVTX Range", "Avg (ns)") if field != missing_field ++ ) ++ source = self.root / f"missing-{missing_field.replace(' ', '_')}.csv" ++ output = self.root / f"missing-{missing_field.replace(' ', '_')}.pbtxt" ++ row = {field: "1" for field in fields} ++ write_csv(source, [row], fieldnames=fields) ++ output.write_text("existing output") ++ ++ result = self.run_converter( ++ "--csv_profile", source, "--pgle_output_path", output ++ ) ++ ++ self.assertNotEqual(result.returncode, 0) ++ self.assertIn(missing_field, result.stderr) ++ self.assertEqual(output.read_text(), "existing output") ++ ++ def test_profile_conversion_cleans_only_generated_intermediates(self): ++ profile = self.root / "input" / "profile.nsys-rep" ++ output = self.root / "output" / "costs.pbtxt" ++ profile.parent.mkdir() ++ output.parent.mkdir() ++ profile.write_text("profile") ++ unrelated_csv = output.parent / "keep.csv" ++ unrelated_sqlite = profile.parent / "keep.sqlite" ++ unrelated_csv.write_text("unrelated csv") ++ unrelated_sqlite.write_text("unrelated sqlite") ++ manifest = self.root / "manifest.txt" ++ bin_dir = self.make_fake_nsys() ++ ++ result = self.run_converter( ++ "--profile_path", ++ profile, ++ "--pgle_output_path", ++ output, ++ env=self.fake_nsys_env(profile, manifest, bin_dir), ++ ) ++ ++ self.assertEqual(result.returncode, 0, result.stderr) ++ self.assertEqual(read_entries(output), [("profile.op", 3.25)]) ++ self.assertTrue(unrelated_csv.exists()) ++ self.assertTrue(unrelated_sqlite.exists()) ++ generated = [Path(line) for line in manifest.read_text().splitlines()] ++ self.assertTrue(generated) ++ self.assertTrue(all(not path.exists() for path in generated)) ++ ++ def test_keep_intermediates_retains_generated_profile_artifacts(self): ++ profile = self.root / "profile.nsys-rep" ++ output = self.root / "costs.pbtxt" ++ manifest = self.root / "manifest.txt" ++ profile.write_text("profile") ++ bin_dir = self.make_fake_nsys() ++ ++ result = self.run_converter( ++ "--profile_path", ++ profile, ++ "--pgle_output_path", ++ output, ++ "--keep_intermediates", ++ env=self.fake_nsys_env(profile, manifest, bin_dir), ++ ) ++ ++ self.assertEqual(result.returncode, 0, result.stderr) ++ generated = [Path(line) for line in manifest.read_text().splitlines()] ++ self.assertTrue(generated) ++ self.assertTrue(all(path.exists() for path in generated)) ++ ++ def test_nsys_failures_are_nonzero_and_do_not_replace_output(self): ++ profile = self.root / "profile.nsys-rep" ++ output = self.root / "costs.pbtxt" ++ manifest = self.root / "manifest.txt" ++ profile.write_text("profile") ++ output.write_text("existing output") ++ bin_dir = self.make_fake_nsys() ++ ++ failed_process = self.run_converter( ++ "--profile_path", ++ profile, ++ "--pgle_output_path", ++ output, ++ env=self.fake_nsys_env( ++ profile, manifest, bin_dir, FAKE_NSYS_EXIT="7" ++ ), ++ ) ++ missing_tool = self.run_converter( ++ "--profile_path", ++ profile, ++ "--pgle_output_path", ++ output, ++ env={"PATH": str(self.root / "empty-path")}, ++ ) ++ ++ for result in (failed_process, missing_tool): ++ self.assertNotEqual(result.returncode, 0) ++ self.assertIn("nsys", result.stderr.lower()) ++ self.assertEqual(output.read_text(), "existing output") ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++python3.12 -S tests/pgo_nsys_converter_cli_test.py diff --git a/tasks/format-code-task-001112/tests/test.sh b/tasks/format-code-task-001112/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..83ed81dfedfb2281511d0052b3fbb1de52a8b972 --- /dev/null +++ b/tasks/format-code-task-001112/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/pgo_nsys_converter_cli_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001112/tests/test_command.sh b/tasks/format-code-task-001112/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001112/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001113/environment/Dockerfile b/tasks/format-code-task-001113/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1fb61d180dd55c237eb32faf45c9dd4906e35e36 --- /dev/null +++ b/tasks/format-code-task-001113/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c49a0f7ae1a9e9d5cc29d1f48643facd9e8a7835d6f75bc5dd6e680e62dd8519 diff --git a/tasks/format-code-task-001113/environment/setup/files/blocklist b/tasks/format-code-task-001113/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001113/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001113/environment/setup/setup.sh b/tasks/format-code-task-001113/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001113/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001113/tests/test.patch b/tasks/format-code-task-001113/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce070bcd8bda1a557d784e6716a20640265c7c21 --- /dev/null +++ b/tasks/format-code-task-001113/tests/test.patch @@ -0,0 +1,172 @@ +diff --git a/internal/stackql/sqldialect/view_catalog_test.go b/internal/stackql/sqldialect/view_catalog_test.go +new file mode 100644 +index 0000000..c28e5be +--- /dev/null ++++ b/internal/stackql/sqldialect/view_catalog_test.go +@@ -0,0 +1,156 @@ ++package sqldialect_test ++ ++import ( ++ "strings" ++ "testing" ++ ++ "github.com/stackql/stackql/internal/stackql/constants" ++ "github.com/stackql/stackql/internal/stackql/dto" ++ "github.com/stackql/stackql/internal/stackql/sqlcontrol" ++ "github.com/stackql/stackql/internal/stackql/sqldialect" ++ "github.com/stackql/stackql/internal/stackql/sqlengine" ++) ++ ++func newCatalogDialect(t *testing.T) (sqldialect.SQLDialect, sqlengine.SQLEngine) { ++ t.Helper() ++ attrs := sqlcontrol.GetControlAttributes("standard") ++ cfg := dto.SQLBackendCfg{ ++ DbEngine: constants.DbEngineSQLite3Embedded, ++ DSN: ":memory:", ++ SQLDialect: constants.SQLDialectSQLite3, ++ } ++ engine, err := sqlengine.NewSQLEngine(cfg, attrs) ++ if err != nil { ++ t.Fatalf("new sqlite engine: %v", err) ++ } ++ dialect, err := sqldialect.NewSQLDialect(engine, "", attrs, cfg) ++ if err != nil { ++ t.Fatalf("new sqlite dialect: %v", err) ++ } ++ return dialect, engine ++} ++ ++func queryString(t *testing.T, engine sqlengine.SQLEngine, query string, args ...interface{}) string { ++ t.Helper() ++ var value string ++ if err := engine.QueryRow(query, args...).Scan(&value); err != nil { ++ t.Fatalf("query %q: %v", query, err) ++ } ++ return value ++} ++ ++func TestCreateViewRegistersDefinitionsWithoutEagerPhysicalView(t *testing.T) { ++ dialect, engine := newCatalogDialect(t) ++ raw := "select id, label from source_items where id > 0;" ++ translated := `create view "catalog_items" as select id, label from "source_items";` ++ ++ if err := dialect.CreateView("catalog_items", raw, translated); err != nil { ++ t.Fatalf("CreateView returned error: %v", err) ++ } ++ view, ok := dialect.GetViewByName("catalog_items") ++ if !ok { ++ t.Fatal("created view was not discoverable") ++ } ++ if got := view.GetRawQuery(); got != raw { ++ t.Fatalf("raw definition = %q, want %q", got, raw) ++ } ++ gotTranslated := queryString(t, engine, `select view_stackql_ddl from "__iql__.views" where view_name = ? and deleted_dttm is null`, "catalog_items") ++ if gotTranslated != translated { ++ t.Fatalf("translated definition = %q, want %q", gotTranslated, translated) ++ } ++ physicalCount := queryString(t, engine, `select cast(count(*) as text) from sqlite_schema where type = 'view' and name = ?`, "catalog_items") ++ if physicalCount != "0" { ++ t.Fatalf("CreateView eagerly created a physical view (count %s)", physicalCount) ++ } ++ seeded, ok := dialect.GetViewByName("stackql_repositories") ++ if !ok || seeded.GetRawQuery() != "select id, name, url from github.repos.repos where org = 'stackql';" { ++ t.Fatalf("existing seeded view was not preserved") ++ } ++} ++ ++func TestCreateViewReplacesDefinitionAndEscapesCatalogValues(t *testing.T) { ++ dialect, engine := newCatalogDialect(t) ++ name := "owner's_items" ++ firstRaw := "select 1 as id" ++ firstTranslated := `create view "owners_items" as select 1 as id` ++ secondRaw := "select 2 as id" ++ secondTranslated := `create view "owners_items" as select 2 as id` ++ ++ if err := dialect.CreateView(name, firstRaw, firstTranslated); err != nil { ++ t.Fatalf("first CreateView returned error: %v", err) ++ } ++ if err := dialect.CreateView(name, secondRaw, secondTranslated); err != nil { ++ t.Fatalf("replacement CreateView returned error: %v", err) ++ } ++ view, ok := dialect.GetViewByName(name) ++ if !ok { ++ t.Fatal("replacement view was not discoverable") ++ } ++ if got := view.GetRawQuery(); got != secondRaw { ++ t.Fatalf("replacement raw definition = %q, want %q", got, secondRaw) ++ } ++ active := queryString(t, engine, `select cast(count(*) as text) from "__iql__.views" where view_name = ? and deleted_dttm is null`, name) ++ if active != "1" { ++ t.Fatalf("active catalog rows = %s, want 1", active) ++ } ++ stored := queryString(t, engine, `select view_stackql_ddl from "__iql__.views" where view_name = ? and deleted_dttm is null`, name) ++ if stored != secondTranslated { ++ t.Fatalf("replacement translated definition = %q, want %q", stored, secondTranslated) ++ } ++ deleted := queryString(t, engine, `select cast(count(*) as text) from "__iql__.views" where view_name = ? and deleted_dttm is not null`, name) ++ if deleted != "1" { ++ t.Fatalf("superseded catalog rows = %s, want 1", deleted) ++ } ++} ++ ++func TestCreateViewRejectsInvalidDefinitionsWithoutCatalogMutation(t *testing.T) { ++ dialect, engine := newCatalogDialect(t) ++ cases := []struct { ++ viewName string ++ name string ++ raw string ++ translated string ++ wantMessage string ++ }{ ++ {viewName: " ", name: "blank name", raw: "select 1", translated: "select 1", wantMessage: "view"}, ++ {viewName: "invalid_blank_raw", name: "blank raw", raw: "", translated: "select 1", wantMessage: "view"}, ++ {viewName: "invalid_blank_translated", name: "blank translated", raw: "select 1", translated: "", wantMessage: "view"}, ++ {viewName: "invalid_whitespace_raw", name: "whitespace raw", raw: " ", translated: "select 1", wantMessage: "view"}, ++ {viewName: "invalid_whitespace_translated", name: "whitespace translated", raw: "select 1", translated: " ", wantMessage: "view"}, ++ } ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ name := tc.viewName ++ if name == "" { ++ name = "invalid_" + strings.ReplaceAll(tc.name, "-", "_") ++ } ++ if err := dialect.CreateView(name, tc.raw, tc.translated); err == nil { ++ t.Fatal("CreateView unexpectedly accepted invalid definition") ++ } else if !strings.Contains(strings.ToLower(err.Error()), tc.wantMessage) { ++ t.Fatalf("error %q does not mention %q", err, tc.wantMessage) ++ } ++ if _, ok := dialect.GetViewByName(name); ok { ++ t.Fatal("invalid definition was left in the catalog") ++ } ++ }) ++ } ++ var count int ++ if err := engine.QueryRow(`select count(*) from "__iql__.views" where view_name like 'invalid_%'`).Scan(&count); err != nil { ++ t.Fatalf("count invalid catalog rows: %v", err) ++ } ++ if count != 0 { ++ t.Fatalf("invalid catalog rows = %d, want 0", count) ++ } ++ ++ const stableName = "atomic_view" ++ if err := dialect.CreateView(stableName, "select 7", "create view atomic_view as select 7"); err != nil { ++ t.Fatalf("seed CreateView returned error: %v", err) ++ } ++ if err := dialect.CreateView(stableName, "select 8", ""); err == nil { ++ t.Fatal("invalid replacement unexpectedly succeeded") ++ } ++ view, ok := dialect.GetViewByName(stableName) ++ if !ok || view.GetRawQuery() != "select 7" { ++ t.Fatalf("invalid replacement changed the active definition") ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./internal/stackql/sqldialect -run TestCreateView -count=1 diff --git a/tasks/format-code-task-001113/tests/test.sh b/tasks/format-code-task-001113/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f730b0416ffb6edb0f118a3c22030b50179b5bef --- /dev/null +++ b/tasks/format-code-task-001113/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/stackql/sqldialect/view_catalog_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-001113/tests/test_command.sh b/tasks/format-code-task-001113/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001113/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001114/environment/Dockerfile b/tasks/format-code-task-001114/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c390d2ca58077e7ff221486586e8d38fcbd03ee7 --- /dev/null +++ b/tasks/format-code-task-001114/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5af14bde8bf23565c7d4c1b54daa7ed864cdf0237b5c7365531f549beede910f diff --git a/tasks/format-code-task-001114/environment/setup/files/blocklist b/tasks/format-code-task-001114/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001114/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001114/environment/setup/setup.sh b/tasks/format-code-task-001114/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001114/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001114/tests/test.patch b/tasks/format-code-task-001114/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4f8118083bfef07f3d62b117bd998e6e316c570a --- /dev/null +++ b/tasks/format-code-task-001114/tests/test.patch @@ -0,0 +1,117 @@ +diff --git a/changedetectionio/tests/unit/test_condition_contract.py b/changedetectionio/tests/unit/test_condition_contract.py +new file mode 100644 +index 00000000..9eeeb457 +--- /dev/null ++++ b/changedetectionio/tests/unit/test_condition_contract.py +@@ -0,0 +1,97 @@ ++from changedetectionio.conditions import execute_ruleset_against_all_plugins ++ ++ ++def evaluate(conditions, text, logic="ALL"): ++ application = { ++ "watching": { ++ "watch-1": { ++ "conditions": conditions, ++ "conditions_match_logic": logic, ++ } ++ } ++ } ++ return execute_ruleset_against_all_plugins( ++ current_watch_uuid="watch-1", ++ application_datastruct=application, ++ ephemeral_data={"text": text}, ++ ) ++ ++ ++def test_text_aliases_and_all_any_logic_are_consistent(): ++ text = "Welcome to the status page" ++ result = evaluate( ++ [ ++ {"operator": "==", "field": "page_text", "value": text}, ++ {"operator": "==", "field": "page_filtered_text", "value": text}, ++ ], ++ text, ++ "all", ++ ) ++ assert result["result"] is True ++ assert result["executed_data"]["page_text"] == text ++ assert result["executed_data"]["page_filtered_text"] == text ++ ++ any_result = evaluate( ++ [ ++ {"operator": "==", "field": "page_text", "value": "does not match"}, ++ {"operator": "contains_regex", "field": "page_text", "value": r"status\s+page"}, ++ ], ++ text, ++ "ANY", ++ ) ++ assert any_result["result"] is True ++ ++ all_result = evaluate( ++ [ ++ {"operator": "==", "field": "page_text", "value": text}, ++ {"operator": "==", "field": "page_text", "value": "does not match"}, ++ ], ++ text, ++ "bogus", ++ ) ++ assert all_result["result"] is False ++ ++ ++def test_incomplete_rows_are_ignored_without_changing_complete_rules(): ++ result = evaluate( ++ [ ++ {"operator": "==", "field": "page_text", "value": "ready"}, ++ {"operator": "==", "field": "page_text"}, ++ {"operator": "", "field": "page_text", "value": "ignored"}, ++ ], ++ "ready", ++ ) ++ assert result["result"] is True ++ ++ only_incomplete = evaluate([{"operator": "==", "value": "ready"}], "ready") ++ assert only_incomplete["result"] is True ++ ++ ++def test_invalid_regex_is_a_failed_condition_instead_of_an_exception(): ++ positive = evaluate( ++ [{"operator": "contains_regex", "field": "page_text", "value": "["}], ++ "anything", ++ ) ++ assert positive["result"] is False ++ ++ negative = evaluate( ++ [{"operator": "!contains_regex", "field": "page_text", "value": "["}], ++ "anything", ++ ) ++ assert negative["result"] is False ++ ++ ++def test_zero_price_is_numeric_and_missing_price_does_not_leak_state(): ++ zero = evaluate( ++ [{"operator": "==", "field": "extracted_number", "value": "0"}], ++ "Current price: $0", ++ ) ++ assert zero["result"] is True ++ assert zero["executed_data"]["extracted_number"] == 0.0 ++ ++ missing = evaluate( ++ [{"operator": "==", "field": "extracted_number", "value": "0"}], ++ "Nothing to see here", ++ ) ++ assert missing["result"] is False ++ assert "extracted_number" not in missing["executed_data"] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,9 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++if [ -x ".build_env/.venv/bin/pytest" ]; then ++ .build_env/.venv/bin/pytest changedetectionio/tests/unit/test_condition_contract.py -q ++else ++ python -m pytest changedetectionio/tests/unit/test_condition_contract.py -q ++fi diff --git a/tasks/format-code-task-001114/tests/test.sh b/tasks/format-code-task-001114/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..944ee2f17603f5fa467d12bd1ab7a672f0afcf03 --- /dev/null +++ b/tasks/format-code-task-001114/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' +changedetectionio/tests/unit/test_condition_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-001114/tests/test_command.sh b/tasks/format-code-task-001114/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001114/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001141/environment/Dockerfile b/tasks/format-code-task-001141/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8506fb3d71d7d0ec318982dff47c057519c2e419 --- /dev/null +++ b/tasks/format-code-task-001141/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2ea7dce6ec53a361a188301ff0b758d6b525526120c056df620a50d21fe3e75f diff --git a/tasks/format-code-task-001141/environment/setup/files/blocklist b/tasks/format-code-task-001141/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001141/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001141/environment/setup/setup.sh b/tasks/format-code-task-001141/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001141/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001141/tests/test.patch b/tasks/format-code-task-001141/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a325ec750afa346871a652d0628baf7eb9436769 --- /dev/null +++ b/tasks/format-code-task-001141/tests/test.patch @@ -0,0 +1,96 @@ +diff --git a/syft/pkg/cataloger/python/requirements_contract_test.go b/syft/pkg/cataloger/python/requirements_contract_test.go +new file mode 100644 +index 00000000..84b282dd +--- /dev/null ++++ b/syft/pkg/cataloger/python/requirements_contract_test.go +@@ -0,0 +1,35 @@ ++package python ++ ++import ( ++ "testing" ++ ++ "github.com/anchore/syft/syft/pkg" ++ "github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest" ++) ++ ++func TestRequirementsCatalogerRetainsUnknownVersions(t *testing.T) { ++ resolver := pkgtest.NewCatalogTester().FromDirectory(t, "test-fixtures/requires/contracts") ++ resolver.Expects([]pkg.Package{ ++ {Name: "flask", Version: "4.0.0", PURL: "pkg:pypi/flask@4.0.0", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "sqlalchemy", PURL: "pkg:pypi/sqlalchemy", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "greater", PURL: "pkg:pypi/greater", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "less", PURL: "pkg:pypi/less", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "maximum", PURL: "pkg:pypi/maximum", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "numpy", PURL: "pkg:pypi/numpy", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "Mopidy-Dirble", PURL: "pkg:pypi/Mopidy-Dirble", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "coverage", PURL: "pkg:pypi/coverage", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "plain-package", PURL: "pkg:pypi/plain-package", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "continued-package", PURL: "pkg:pypi/continued-package", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "duplicate-package", Version: "1.0", PURL: "pkg:pypi/duplicate-package@1.0", Type: pkg.PythonPkg, Language: pkg.Python}, ++ {Name: "duplicate-package", PURL: "pkg:pypi/duplicate-package", Type: pkg.PythonPkg, Language: pkg.Python}, ++ }, nil) ++ resolver.IgnorePackageFields("FoundBy", "Locations").TestCataloger(t, NewPythonIndexCataloger()) ++} ++ ++func TestRequirementsCatalogerSkipsControlsAndMalformedLines(t *testing.T) { ++ resolver := pkgtest.NewCatalogTester().FromDirectory(t, "test-fixtures/requires/options") ++ resolver.Expects([]pkg.Package{{ ++ Name: "visible-package", PURL: "pkg:pypi/visible-package", Type: pkg.PythonPkg, Language: pkg.Python, ++ }}, nil) ++ resolver.IgnorePackageFields("FoundBy", "Locations").TestCataloger(t, NewPythonIndexCataloger()) ++} +diff --git a/syft/pkg/cataloger/python/test-fixtures/requires/contracts/requirements-contract.txt b/syft/pkg/cataloger/python/test-fixtures/requires/contracts/requirements-contract.txt +new file mode 100644 +index 00000000..3e179e25 +--- /dev/null ++++ b/syft/pkg/cataloger/python/test-fixtures/requires/contracts/requirements-contract.txt +@@ -0,0 +1,20 @@ ++# exact pins remain versioned ++flask==4.0.0 ++ ++# ranges and bare declarations remain visible without inventing a version ++sqlalchemy >= 1.0.0 ++greater > 1.0 ++less < 2.0 ++maximum <= 5.0 ++numpy >= 3.4.1, < 4.0; python_version < "3.12" ++Mopidy-Dirble ~= 1.1 ++coverage != 3.5 ++plain-package ++ ++# a continued declaration is one requirement; hashes and comments are not packages ++continued-package >= 2.0, \ ++ < 3.0 --hash=sha256:deadbeef # wheel hash ++ ++# duplicate declarations are retained ++duplicate-package==1.0 ++duplicate-package>=1.0 +diff --git a/syft/pkg/cataloger/python/test-fixtures/requires/options/requirements-options.txt b/syft/pkg/cataloger/python/test-fixtures/requires/options/requirements-options.txt +new file mode 100644 +index 00000000..300c35bd +--- /dev/null ++++ b/syft/pkg/cataloger/python/test-fixtures/requires/options/requirements-options.txt +@@ -0,0 +1,13 @@ ++# installer controls, editable/direct references, malformed and commented lines are ignored ++-r other.txt ++-c constraints-short.txt ++--constraint constraints.txt ++--index-url https://example.invalid/simple ++--find-links https://example.invalid/wheels ++--trusted-host example.invalid ++-e git+https://example.invalid/repo.git#egg=editable ++direct @ https://example.invalid/direct.whl ++== 2.0 ++not a requirement ++# commented-package==9.9 ++visible-package +diff --git 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 ./syft/pkg/cataloger/python diff --git a/tasks/format-code-task-001141/tests/test.sh b/tasks/format-code-task-001141/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4bcdfb2ba8f2805df935b1af6a68c814d5926cf9 --- /dev/null +++ b/tasks/format-code-task-001141/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' +syft/pkg/cataloger/python/requirements_contract_test.go +syft/pkg/cataloger/python/test-fixtures/requires/contracts/requirements-contract.txt +syft/pkg/cataloger/python/test-fixtures/requires/options/requirements-options.txt +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001141/tests/test_command.sh b/tasks/format-code-task-001141/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001141/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001146/environment/Dockerfile b/tasks/format-code-task-001146/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..34ecffa4459ac9b56afb01a25d0335b0dbb78a72 --- /dev/null +++ b/tasks/format-code-task-001146/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:69339cd5a1095f6c0e02ad1eae5f15e3f0b69ef167c9f1417fff296afee8adf7 diff --git a/tasks/format-code-task-001146/environment/setup/files/blocklist b/tasks/format-code-task-001146/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001146/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001146/environment/setup/setup.sh b/tasks/format-code-task-001146/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001146/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001146/tests/test.patch b/tasks/format-code-task-001146/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..38b6db52113318c7cad930672fb2bbc5a74cf5d4 --- /dev/null +++ b/tasks/format-code-task-001146/tests/test.patch @@ -0,0 +1,133 @@ +diff --git a/tests/test_synth_asyncapi_asgi_routes.py b/tests/test_synth_asyncapi_asgi_routes.py +new file mode 100644 +index 00000000..e1279dbf +--- /dev/null ++++ b/tests/test_synth_asyncapi_asgi_routes.py +@@ -0,0 +1,118 @@ ++import asyncio ++ ++from faststream.asgi import AsgiFastStream, AsgiResponse, get ++from faststream.asyncapi.generate import get_app_schema ++ ++ ++class DummyBroker: ++ url = "memory://broker" ++ protocol = "memory" ++ protocol_version = "1" ++ description = None ++ tags = None ++ security = None ++ _subscribers = {} ++ _publishers = {} ++ ++ def setup(self): ++ pass ++ ++ ++def build_metadata_app(): ++ try: ++ readiness_decorator = get( ++ description="Readiness endpoint", ++ operation_id="readiness", ++ tags=("ops", "health"), ++ ) ++ except TypeError as exc: ++ raise AssertionError( ++ "get() must expose operation_id and tags metadata options" ++ ) from exc ++ ++ @readiness_decorator ++ async def readiness(scope): ++ return AsgiResponse(b"ready", 200) ++ ++ @get ++ async def documented_by_docstring(scope): ++ ++ return AsgiResponse(b"docs", 200) ++ ++ return AsgiFastStream( ++ DummyBroker(), ++ asgi_routes=[("/ready", readiness), ("/docstring", documented_by_docstring)], ++ ) ++ ++ ++def build_runtime_app(): ++ @get(include_in_schema=False) ++ async def internal(scope): ++ return AsgiResponse(b"internal", 200) ++ ++ return AsgiFastStream( ++ DummyBroker(), ++ asgi_routes=[("/internal", internal)], ++ ) ++ ++ ++def test_included_routes_have_http_operations_and_metadata(): ++ schema = get_app_schema(build_metadata_app()).to_jsonable() ++ channels = schema["channels"] ++ ++ assert set(channels) == {"/ready", "/docstring"} ++ ++ ready = channels["/ready"]["publish"] ++ assert ready["operationId"] == "readiness" ++ assert ready["description"] == "Readiness endpoint" ++ assert [tag["name"] for tag in ready["tags"]] == ["ops", "health"] ++ assert ready["bindings"]["http"]["method"] == "GET" ++ ++ docstring = channels["/docstring"]["publish"] ++ assert docstring["operationId"] == "documented_by_docstring" ++ assert docstring["description"] == "Serves the documented fallback." ++ ++ ++def test_schema_does_not_expose_opted_out_route_but_runtime_still_serves_it(): ++ app = build_runtime_app() ++ events = [] ++ ++ async def receive(): ++ return {"type": "http.request"} ++ ++ async def send(message): ++ events.append(message) ++ ++ async def exercise(): ++ await app( ++ {"type": "http", "path": "/internal", "method": "GET"}, ++ receive, ++ send, ++ ) ++ ++ asyncio.run(exercise()) ++ assert events[0]["status"] == 200 ++ assert events[1]["body"] == b"internal" ++ assert "/internal" not in get_app_schema(app).to_jsonable()["channels"] ++ ++ ++def test_non_get_requests_keep_existing_method_not_allowed_behavior(): ++ app = build_runtime_app() ++ events = [] ++ ++ async def receive(): ++ return {"type": "http.request"} ++ ++ async def send(message): ++ events.append(message) ++ ++ async def exercise(): ++ await app( ++ {"type": "http", "path": "/internal", "method": "POST"}, ++ receive, ++ send, ++ ) ++ ++ asyncio.run(exercise()) ++ assert events[0]["status"] == 405 ++ assert dict(events[0]["headers"])[b"allow"] == b"GET, HEAD" +diff --git 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_synth_asyncapi_asgi_routes.py --disable-warnings --maxfail=1 diff --git a/tasks/format-code-task-001146/tests/test.sh b/tasks/format-code-task-001146/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ed1d8e628fc65db66e675053b9188d2a1b7b5f4 --- /dev/null +++ b/tasks/format-code-task-001146/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_synth_asyncapi_asgi_routes.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-001146/tests/test_command.sh b/tasks/format-code-task-001146/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001146/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001148/environment/Dockerfile b/tasks/format-code-task-001148/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..05f9cf915eaf9eb4c9edd954aa267f5413d86e47 --- /dev/null +++ b/tasks/format-code-task-001148/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:287bf0bd2625d9e497c266f49b7e74f0e9180bb5d8e8685df7be868c6a16a5ab diff --git a/tasks/format-code-task-001148/environment/setup/files/blocklist b/tasks/format-code-task-001148/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001148/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001148/environment/setup/setup.sh b/tasks/format-code-task-001148/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001148/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001148/tests/test.patch b/tasks/format-code-task-001148/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bf7be486e6944d716b23a5f99bca01c11585d243 --- /dev/null +++ b/tasks/format-code-task-001148/tests/test.patch @@ -0,0 +1,218 @@ +diff --git a/build/test/unit/wifi_helper_contract.test.js b/build/test/unit/wifi_helper_contract.test.js +new file mode 100644 +index 0000000000..e4e7605fe6 +--- /dev/null ++++ b/build/test/unit/wifi_helper_contract.test.js +@@ -0,0 +1,202 @@ ++'use strict'; ++ ++var assert = require('chai').assert; ++var fs = require('fs'); ++var vm = require('vm'); ++ ++function loadHelper(manager) { ++ var context = { ++ navigator: { mozWifiManager: manager || {} }, ++ console: console ++ }; ++ vm.runInNewContext( ++ fs.readFileSync('shared/js/wifi_helper.js', 'utf8'), context, ++ { filename: 'shared/js/wifi_helper.js' }); ++ return context.WifiHelper; ++} ++ ++function request() { ++ return { onsuccess: null, onerror: null, result: null, error: null }; ++} ++ ++suite('WifiHelper profile and scan contracts', function() { ++ test('missing security is treated as an open network', function() { ++ var helper = loadHelper({ connection: { network: null } }); ++ assert.deepEqual(helper.getSecurity({}), []); ++ assert.equal(helper.getKeyManagement({}), ''); ++ assert.isTrue(helper.isOpen({})); ++ assert.isFalse(helper.isEap({})); ++ }); ++ ++ test('switching to enterprise credentials removes stale profile fields', ++ function() { ++ var helper = loadHelper(); ++ var network = { ++ security: ['WPA-EAP'], ++ psk: 'old-psk', ++ wep: 'old-wep', ++ password: 'old-password', ++ identity: 'old-identity', ++ phase2: 'old-phase2', ++ serverCertificate: 'old-cert' ++ }; ++ ++ helper.setPassword(network, 'new-password', 'new-identity', 'TLS', ++ 'No', 'none'); ++ ++ assert.equal(network.password, 'new-password'); ++ assert.equal(network.identity, 'new-identity'); ++ assert.equal(network.eap, 'TLS'); ++ assert.equal(network.keyManagement, 'WPA-EAP'); ++ assert.isUndefined(network.psk); ++ assert.isUndefined(network.wep); ++ assert.isUndefined(network.phase2); ++ assert.isUndefined(network.serverCertificate); ++ }); ++ ++ test('empty enterprise fields do not retain prior credentials', function() { ++ var helper = loadHelper(); ++ var network = { ++ security: ['WPA-EAP'], ++ eap: 'PEAP', ++ password: 'secret', ++ identity: 'person', ++ phase2: 'MSCHAPV2', ++ serverCertificate: 'cert' ++ }; ++ ++ helper.setPassword(network, '', '', 'PEAP', 'No', 'none'); ++ assert.equal(network.eap, 'PEAP'); ++ assert.isUndefined(network.password); ++ assert.isUndefined(network.identity); ++ assert.isUndefined(network.phase2); ++ assert.isUndefined(network.serverCertificate); ++ }); ++ ++ test('switching away from enterprise credentials clears them', function() { ++ var helper = loadHelper(); ++ var network = { ++ security: ['WPA-EAP'], ++ eap: 'PEAP', ++ password: 'secret', ++ identity: 'person', ++ phase2: 'MSCHAPV2', ++ serverCertificate: 'cert' ++ }; ++ ++ network.security = ['WPA-PSK']; ++ helper.setPassword(network, '12345678'); ++ assert.equal(network.psk, '12345678'); ++ assert.equal(network.keyManagement, 'WPA-PSK'); ++ assert.isUndefined(network.eap); ++ assert.isUndefined(network.password); ++ assert.isUndefined(network.identity); ++ assert.isUndefined(network.phase2); ++ assert.isUndefined(network.serverCertificate); ++ }); ++ ++ test('credential validation distinguishes supported enterprise modes', ++ function() { ++ var helper = loadHelper(); ++ assert.isTrue(helper.isValidInput('WPA-EAP', '', '', 'SIM')); ++ assert.isFalse(helper.isValidInput('WPA-EAP', '', '', 'PEAP')); ++ assert.isTrue(helper.isValidInput('WPA-EAP', 'pw', 'user', 'PEAP')); ++ assert.isTrue(helper.isValidInput('WPA-EAP', 'pw', 'user', 'TLS')); ++ assert.isTrue(helper.isValidInput('WPA-EAP', 'pw', 'user', 'TTLS')); ++ assert.isFalse(helper.isValidInput('WPA-EAP', 'pw', 'user', 'AKA')); ++ assert.isFalse(helper.isValidInput('unknown', '', '', '')); ++ }); ++ ++ test('scan merge de-duplicates normalized security and preserves precedence', ++ function() { ++ var available = [ ++ { ssid: 'Office', security: ['WPA-EAP', 'WPA-PSK'], relSignalStrength: 40 }, ++ { ssid: 'Guest', security: [], relSignalStrength: 20 } ++ ]; ++ var known = [ ++ { ssid: 'Office', security: ['WPA-PSK', 'WPA-EAP'], relSignalStrength: 99 }, ++ { ssid: 'Hidden', security: ['WEP'], relSignalStrength: 80 } ++ ]; ++ var availableReq = request(); ++ var knownReq = request(); ++ var manager = { ++ getNetworks: function() { return availableReq; }, ++ getKnownNetworks: function() { return knownReq; } ++ }; ++ var helper = loadHelper(manager); ++ var resultReq = helper.getAvailableAndKnownNetworks(); ++ var result; ++ resultReq.onsuccess = function() { result = resultReq.result; }; ++ availableReq.result = available; ++ availableReq.onsuccess(); ++ knownReq.result = known; ++ knownReq.onsuccess(); ++ ++ assert.deepEqual(result.map(function(network) { return network.ssid; }), ++ ['Office', 'Guest', 'Hidden']); ++ assert.equal(result[0].relSignalStrength, 40); ++ assert.equal(result[2].relSignalStrength, 80); ++ assert.deepEqual(available, [ ++ { ssid: 'Office', security: ['WPA-EAP', 'WPA-PSK'], relSignalStrength: 40 }, ++ { ssid: 'Guest', security: [], relSignalStrength: 20 } ++ ]); ++ assert.deepEqual(known, [ ++ { ssid: 'Office', security: ['WPA-PSK', 'WPA-EAP'], relSignalStrength: 99 }, ++ { ssid: 'Hidden', security: ['WEP'], relSignalStrength: 80 } ++ ]); ++ }); ++ ++ test('available scan failure is propagated without requesting known networks', ++ function() { ++ var availableReq = request(); ++ var knownRequested = false; ++ var manager = { ++ getNetworks: function() { return availableReq; }, ++ getKnownNetworks: function() { ++ knownRequested = true; ++ return request(); ++ } ++ }; ++ var helper = loadHelper(manager); ++ var resultReq = helper.getAvailableAndKnownNetworks(); ++ var seenError; ++ resultReq.onerror = function() { seenError = resultReq.error; }; ++ availableReq.error = { name: 'scan-failed' }; ++ availableReq.onerror(); ++ assert.equal(seenError.name, 'scan-failed'); ++ assert.isFalse(knownRequested); ++ }); ++ ++ test('known scan failure still returns available networks', function() { ++ var availableReq = request(); ++ var knownReq = request(); ++ var manager = { ++ getNetworks: function() { return availableReq; }, ++ getKnownNetworks: function() { return knownReq; } ++ }; ++ var helper = loadHelper(manager); ++ var resultReq = helper.getAvailableAndKnownNetworks(); ++ var result; ++ resultReq.onsuccess = function() { result = resultReq.result; }; ++ availableReq.result = [{ ssid: 'Only', security: [] }]; ++ availableReq.onsuccess(); ++ knownReq.error = { name: 'known-failed' }; ++ knownReq.onerror(); ++ assert.deepEqual(result.map(function(network) { return network.ssid; }), ++ ['Only']); ++ }); ++ ++ test('connection comparison tolerates missing state and security ordering', ++ function() { ++ var helper = loadHelper({ connection: { network: { ++ ssid: 'Office', security: ['WPA-PSK', 'WPA-EAP'] ++ } } }); ++ assert.isTrue(helper.isConnected({ ++ ssid: 'Office', security: ['WPA-EAP', 'WPA-PSK'] ++ })); ++ helper.wifiManager.connection.network = null; ++ assert.isFalse(helper.isConnected({ ssid: 'Office', security: [] })); ++ helper.wifiManager.connection = null; ++ assert.isFalse(helper.isConnected({ ssid: 'Office', security: [] })); ++ }); ++}); + +diff --git 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 node_modules/mocha/bin/_mocha --ui tdd --reporter spec build/test/unit/wifi_helper_contract.test.js diff --git a/tasks/format-code-task-001148/tests/test.sh b/tasks/format-code-task-001148/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6841cc2037db30fe8179266b5e2db5e5ae07b6ef --- /dev/null +++ b/tasks/format-code-task-001148/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' +build/test/unit/wifi_helper_contract.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-001148/tests/test_command.sh b/tasks/format-code-task-001148/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001148/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001160/environment/Dockerfile b/tasks/format-code-task-001160/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3e4d615e6ff9baa34c4ef24ee129e9ae48162627 --- /dev/null +++ b/tasks/format-code-task-001160/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c0a64909c259b39bb80c372c95da01075ed9582757107f7b24204d1e2a7de361 diff --git a/tasks/format-code-task-001160/environment/setup/files/blocklist b/tasks/format-code-task-001160/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001160/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001160/environment/setup/setup.sh b/tasks/format-code-task-001160/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001160/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001160/tests/test.patch b/tasks/format-code-task-001160/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..92990407c5572e7920bedc0e9e192ea0a4a29fd2 --- /dev/null +++ b/tasks/format-code-task-001160/tests/test.patch @@ -0,0 +1,228 @@ +diff --git a/api/tests/opentrons/protocol_engine/commands/heater_shaker/test_speed_state_contract.py b/api/tests/opentrons/protocol_engine/commands/heater_shaker/test_speed_state_contract.py +new file mode 100644 +index 0000000000..d026100b03 +--- /dev/null ++++ b/api/tests/opentrons/protocol_engine/commands/heater_shaker/test_speed_state_contract.py +@@ -0,0 +1,211 @@ ++ ++ ++import pytest ++from decoy import Decoy ++ ++from opentrons.types import DeckSlotName ++from opentrons.protocol_engine import actions, commands ++from opentrons.protocol_engine.commands import heater_shaker as hs_commands ++from opentrons.protocol_engine.commands.heater_shaker.set_and_wait_for_shake_speed import ( ++ SetAndWaitForShakeSpeedImpl, ++) ++from opentrons.protocol_engine import errors ++from opentrons.protocol_engine.errors import InvalidTargetSpeedError ++from opentrons.protocol_engine.execution import EquipmentHandler ++from opentrons.protocol_engine.state import StateView ++from opentrons.protocol_engine.state.module_substates import ( ++ HeaterShakerModuleId, ++ HeaterShakerModuleSubState, ++) ++from opentrons.protocol_engine.state.modules import ModuleStore, ModuleView ++from opentrons.protocol_engine.types import DeckSlotLocation, ModuleDefinition, ModuleModel ++from opentrons.hardware_control.modules import HeaterShaker ++ ++ ++def _load_heater_shaker(definition: ModuleDefinition) -> commands.LoadModule: ++ return commands.LoadModule.construct( ++ params=commands.LoadModuleParams( ++ model=ModuleModel.HEATER_SHAKER_MODULE_V1, ++ location=DeckSlotLocation(slotName=DeckSlotName.SLOT_1), ++ ), ++ result=commands.LoadModuleResult( ++ moduleId="hs-id", ++ model=ModuleModel.HEATER_SHAKER_MODULE_V1, ++ serialNumber="serial", ++ definition=definition, ++ ), ++ ) ++ ++ ++def _get_heater_shaker_state(store: ModuleStore) -> HeaterShakerModuleSubState: ++ return ModuleView( ++ state=store.state, virtualize_modules=False ++ ).get_heater_shaker_module_substate("hs-id") ++ ++ ++async def test_set_speed_returns_normalized_target_and_calls_hardware( ++ decoy: Decoy, state_view: StateView, equipment: EquipmentHandler ++) -> None: ++ subject = SetAndWaitForShakeSpeedImpl(state_view=state_view, equipment=equipment) ++ params = hs_commands.SetAndWaitForShakeSpeedParams(moduleId="input-hs", rpm=1234.56) ++ substate = decoy.mock(cls=HeaterShakerModuleSubState) ++ hardware = decoy.mock(cls=HeaterShaker) ++ decoy.when( ++ state_view.modules.get_heater_shaker_module_substate(module_id="input-hs") ++ ).then_return(substate) ++ decoy.when(substate.module_id).then_return(HeaterShakerModuleId("hs-id")) ++ decoy.when(substate.validate_target_speed(rpm=1234.56)).then_return(1235) ++ decoy.when( ++ equipment.get_module_hardware_api(HeaterShakerModuleId("hs-id")) ++ ).then_return(hardware) ++ result = await subject.execute(params) ++ assert result.dict().get("targetSpeed") == 1235 ++ decoy.verify(await hardware.set_speed(rpm=1235), times=1) ++ ++ ++async def test_set_speed_returns_normalized_target_for_virtual_module( ++ decoy: Decoy, state_view: StateView, equipment: EquipmentHandler ++) -> None: ++ subject = SetAndWaitForShakeSpeedImpl(state_view=state_view, equipment=equipment) ++ params = hs_commands.SetAndWaitForShakeSpeedParams(moduleId="input-hs", rpm=200.5) ++ substate = decoy.mock(cls=HeaterShakerModuleSubState) ++ decoy.when( ++ state_view.modules.get_heater_shaker_module_substate(module_id="input-hs") ++ ).then_return(substate) ++ decoy.when(substate.module_id).then_return(HeaterShakerModuleId("hs-id")) ++ decoy.when(substate.validate_target_speed(rpm=200.5)).then_return(200) ++ decoy.when( ++ equipment.get_module_hardware_api(HeaterShakerModuleId("hs-id")) ++ ).then_return(None) ++ ++ result = await subject.execute(params) ++ ++ assert result.dict().get("targetSpeed") == 200 ++ ++ ++def test_loaded_speed_is_unset_and_getter_reports_that_state( ++ heater_shaker_v1_def: ModuleDefinition, ++) -> None: ++ store = ModuleStore() ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=_load_heater_shaker(heater_shaker_v1_def) ++ ) ++ ) ++ substate = _get_heater_shaker_state(store) ++ assert getattr(substate, "target_speed", object()) is None ++ no_target_error = getattr(errors, "NoTargetSpeedSetError", None) ++ assert no_target_error is not None ++ with pytest.raises(no_target_error): ++ substate.get_target_speed() # type: ignore[attr-defined] ++ ++ ++def test_set_and_deactivate_speed_preserve_temperature( ++ heater_shaker_v1_def: ModuleDefinition, ++) -> None: ++ store = ModuleStore() ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=_load_heater_shaker(heater_shaker_v1_def) ++ ) ++ ) ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=hs_commands.SetTargetTemperature.construct( ++ params=hs_commands.SetTargetTemperatureParams( ++ moduleId="hs-id", celsius=60 ++ ), ++ result=hs_commands.SetTargetTemperatureResult(), ++ ) ++ ) ++ ) ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=hs_commands.SetAndWaitForShakeSpeed.construct( ++ params=hs_commands.SetAndWaitForShakeSpeedParams( ++ moduleId="hs-id", rpm=500.6 ++ ), ++ result=hs_commands.SetAndWaitForShakeSpeedResult.construct( ++ targetSpeed=501 ++ ), ++ ) ++ ) ++ ) ++ substate = _get_heater_shaker_state(store) ++ assert getattr(substate, "target_speed", None) == 501 ++ assert substate.get_plate_target_temperature() == 60 ++ assert substate.get_target_speed() == 501 # type: ignore[attr-defined] ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=hs_commands.DeactivateShaker.construct( ++ params=hs_commands.DeactivateShakerParams(moduleId="hs-id"), ++ result=hs_commands.DeactivateShakerResult(), ++ ) ++ ) ++ ) ++ substate = _get_heater_shaker_state(store) ++ assert getattr(substate, "target_speed", object()) is None ++ assert substate.get_plate_target_temperature() == 60 ++ ++ ++def test_temperature_commands_preserve_speed( ++ heater_shaker_v1_def: ModuleDefinition, ++) -> None: ++ store = ModuleStore() ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=_load_heater_shaker(heater_shaker_v1_def) ++ ) ++ ) ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=hs_commands.SetAndWaitForShakeSpeed.construct( ++ params=hs_commands.SetAndWaitForShakeSpeedParams( ++ moduleId="hs-id", rpm=800 ++ ), ++ result=hs_commands.SetAndWaitForShakeSpeedResult.construct( ++ targetSpeed=800 ++ ), ++ ) ++ ) ++ ) ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=hs_commands.SetTargetTemperature.construct( ++ params=hs_commands.SetTargetTemperatureParams( ++ moduleId="hs-id", celsius=70 ++ ), ++ result=hs_commands.SetTargetTemperatureResult(), ++ ) ++ ) ++ ) ++ substate = _get_heater_shaker_state(store) ++ assert getattr(substate, "target_speed", None) == 800 ++ assert substate.get_plate_target_temperature() == 70 ++ ++ store.handle_action( ++ actions.UpdateCommandAction( ++ command=hs_commands.DeactivateHeater.construct( ++ params=hs_commands.DeactivateHeaterParams(moduleId="hs-id"), ++ result=hs_commands.DeactivateHeaterResult(), ++ ) ++ ) ++ ) ++ substate = _get_heater_shaker_state(store) ++ assert getattr(substate, "target_speed", None) == 800 ++ assert substate.get_target_speed() == 800 # type: ignore[attr-defined] ++ ++ ++@pytest.mark.parametrize("rpm", [199.9, 3000.1]) ++def test_speed_validation_rejects_values_outside_inclusive_range(rpm: float) -> None: ++ with pytest.raises(InvalidTargetSpeedError): ++ HeaterShakerModuleSubState.validate_target_speed(rpm) ++ ++ ++@pytest.mark.parametrize( ++ ("rpm", "expected"), [(200, 200), (1234.56, 1235), (3000, 3000)] ++) ++def test_speed_validation_normalizes_values_in_inclusive_range( ++ rpm: float, expected: int ++) -> None: ++ assert HeaterShakerModuleSubState.validate_target_speed(rpm) == 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,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++cd api ++pytest -q tests/opentrons/protocol_engine/commands/heater_shaker/test_speed_state_contract.py diff --git a/tasks/format-code-task-001160/tests/test.sh b/tasks/format-code-task-001160/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9324b75ba4e991b45459ec087a84a8004969e4b --- /dev/null +++ b/tasks/format-code-task-001160/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' +api/tests/opentrons/protocol_engine/commands/heater_shaker/test_speed_state_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-001160/tests/test_command.sh b/tasks/format-code-task-001160/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001160/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001170/environment/Dockerfile b/tasks/format-code-task-001170/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..77b8d0a8a37f499b47895707ba8522fa34c620a5 --- /dev/null +++ b/tasks/format-code-task-001170/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7a94e6ee45079ca21bd91e5d143621f83cfd346816a6821d397ba0926d1eff25 diff --git a/tasks/format-code-task-001170/environment/setup/files/blocklist b/tasks/format-code-task-001170/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001170/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001170/environment/setup/setup.sh b/tasks/format-code-task-001170/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001170/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001170/tests/test.patch b/tasks/format-code-task-001170/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6ccf48ddbc558092b852a1bf2a7eb9999a4589b8 --- /dev/null +++ b/tasks/format-code-task-001170/tests/test.patch @@ -0,0 +1,245 @@ +diff --git a/env/interpolation_contract_test.go b/env/interpolation_contract_test.go +new file mode 100644 +index 0000000..5ffca6b +--- /dev/null ++++ b/env/interpolation_contract_test.go +@@ -0,0 +1,225 @@ ++ ++ ++ ++ ++package env_test ++ ++import ( ++ "os" ++ "path/filepath" ++ "strings" ++ "testing" ++ ++ "github.com/getgauge/gauge/config" ++ gaugeenv "github.com/getgauge/gauge/env" ++) ++ ++func TestDependencyAwareEnvironmentInterpolation(t *testing.T) { ++ cleanProcessEnvironment(t) ++ root := t.TempDir() ++ writeProperties(t, root, "qa", ` ++QA_ROOT=/srv/qa ++CHAIN=${FORWARD}/v1 ++FORWARD=${HOST}/api ++COMBINED=${CHAIN}|${HOST}|${HOST}|${EMPTY} ++HOST=qa.example ++`) ++ writeProperties(t, root, "default", ` ++HOST=default.example ++EMPTY= ++FROM_DEFAULT=${QA_ROOT}/default ++DOLLAR_TEXT=keep:$HOME:${NOT-A-NAME}:${UNFINISHED ++`) ++ config.ProjectRoot = root ++ ++ if err := gaugeenv.LoadEnv("qa"); err != nil { ++ t.Fatalf("LoadEnv returned an unexpected error: %v", err) ++ } ++ ++ assertEnv(t, "HOST", "qa.example") ++ assertEnv(t, "FORWARD", "qa.example/api") ++ assertEnv(t, "CHAIN", "qa.example/api/v1") ++ assertEnv(t, "COMBINED", "qa.example/api/v1|qa.example|qa.example|") ++ assertEnv(t, "FROM_DEFAULT", "/srv/qa/default") ++ assertEnv(t, "DOLLAR_TEXT", "keep:$HOME:${NOT-A-NAME}:${UNFINISHED") ++ if value, ok := os.LookupEnv("EMPTY"); !ok || value != "" { ++ t.Fatalf("EMPTY = %q, present = %v; want a present empty value", value, ok) ++ } ++} ++ ++func TestProcessEnvironmentOverridesAreOpaqueAndAuthoritative(t *testing.T) { ++ cleanProcessEnvironment(t) ++ root := t.TempDir() ++ writeProperties(t, root, "qa", ` ++HOST=file.example ++URL=${HOST}/v2 ++LOCKED=${MISSING_SHOULD_NOT_BE_RESOLVED} ++EMPTY=file-value ++`) ++ config.ProjectRoot = root ++ if err := os.Setenv("HOST", "shell-${UNEXPANDED}"); err != nil { ++ t.Fatal(err) ++ } ++ if err := os.Setenv("LOCKED", "from-shell"); err != nil { ++ t.Fatal(err) ++ } ++ if err := os.Setenv("EMPTY", ""); err != nil { ++ t.Fatal(err) ++ } ++ ++ if err := gaugeenv.LoadEnv("qa"); err != nil { ++ t.Fatalf("LoadEnv returned an unexpected error: %v", err) ++ } ++ ++ assertEnv(t, "HOST", "shell-${UNEXPANDED}") ++ assertEnv(t, "URL", "shell-${UNEXPANDED}/v2") ++ assertEnv(t, "LOCKED", "from-shell") ++ assertEnv(t, "EMPTY", "") ++} ++ ++func TestUndefinedReferenceFailsWithoutPublishingOrChangingActiveEnv(t *testing.T) { ++ cleanProcessEnvironment(t) ++ stableRoot := t.TempDir() ++ writeProperties(t, stableRoot, "stable", "STABLE=ready\n") ++ config.ProjectRoot = stableRoot ++ if err := gaugeenv.LoadEnv(" stable "); err != nil { ++ t.Fatalf("initial LoadEnv returned an unexpected error: %v", err) ++ } ++ if got := gaugeenv.CurrentEnv(); got != "stable" { ++ t.Fatalf("CurrentEnv() = %q after successful load; want %q", got, "stable") ++ } ++ ++ brokenRoot := t.TempDir() ++ writeProperties(t, brokenRoot, "broken", ` ++PUBLISH_GUARD=must-not-appear ++STABLE=overwritten ++BROKEN_VALUE=prefix-${ABSENT_DEPENDENCY} ++`) ++ config.ProjectRoot = brokenRoot ++ err := gaugeenv.LoadEnv("broken") ++ if err == nil { ++ t.Fatal("LoadEnv succeeded with an undefined property reference") ++ } ++ if !strings.Contains(err.Error(), "ABSENT_DEPENDENCY") { ++ t.Fatalf("undefined-reference error %q does not name ABSENT_DEPENDENCY", err) ++ } ++ if _, ok := os.LookupEnv("PUBLISH_GUARD"); ok { ++ t.Fatal("PUBLISH_GUARD was published despite interpolation failure") ++ } ++ if _, ok := os.LookupEnv("BROKEN_VALUE"); ok { ++ t.Fatal("BROKEN_VALUE was published despite interpolation failure") ++ } ++ assertEnv(t, "STABLE", "ready") ++ if got := gaugeenv.CurrentEnv(); got != "stable" { ++ t.Fatalf("CurrentEnv() = %q after failed load; want previous successful environment %q", got, "stable") ++ } ++} ++ ++func TestCyclicReferencesReportCycleMembersAndPublishNothing(t *testing.T) { ++ t.Run("direct", func(t *testing.T) { ++ cleanProcessEnvironment(t) ++ root := t.TempDir() ++ writeProperties(t, root, "direct", ` ++DIRECT=${DIRECT} ++DIRECT_GUARD=must-not-appear ++`) ++ config.ProjectRoot = root ++ ++ err := gaugeenv.LoadEnv("direct") ++ assertCycleError(t, err, "DIRECT") ++ if _, ok := os.LookupEnv("DIRECT_GUARD"); ok { ++ t.Fatal("DIRECT_GUARD was published despite a direct cycle") ++ } ++ }) ++ ++ t.Run("indirect", func(t *testing.T) { ++ cleanProcessEnvironment(t) ++ root := t.TempDir() ++ writeProperties(t, root, "indirect", ` ++FIRST=${SECOND} ++SECOND=${THIRD} ++THIRD=${FIRST} ++INDIRECT_GUARD=must-not-appear ++`) ++ config.ProjectRoot = root ++ ++ err := gaugeenv.LoadEnv("indirect") ++ assertCycleError(t, err, "FIRST", "SECOND", "THIRD") ++ if _, ok := os.LookupEnv("INDIRECT_GUARD"); ok { ++ t.Fatal("INDIRECT_GUARD was published despite an indirect cycle") ++ } ++ }) ++} ++ ++func TestCurrentEnvTracksNormalizedExplicitSelectionAndPrecedence(t *testing.T) { ++ cleanProcessEnvironment(t) ++ root := t.TempDir() ++ writeProperties(t, root, "blue", "COLOR=blue\nBLUE_ONLY=yes\n") ++ writeProperties(t, root, "green", "COLOR=green\nGREEN_ONLY=yes\n") ++ writeProperties(t, root, "default", "COLOR=default\nDEFAULT_ONLY=yes\n") ++ config.ProjectRoot = root ++ ++ if err := gaugeenv.LoadEnv(" blue , green "); err != nil { ++ t.Fatalf("LoadEnv returned an unexpected error: %v", err) ++ } ++ ++ if got := gaugeenv.CurrentEnv(); got != "blue,green" { ++ t.Fatalf("CurrentEnv() = %q; want normalized explicit selection %q", got, "blue,green") ++ } ++ assertEnv(t, "COLOR", "blue") ++ assertEnv(t, "BLUE_ONLY", "yes") ++ assertEnv(t, "GREEN_ONLY", "yes") ++ assertEnv(t, "DEFAULT_ONLY", "yes") ++} ++ ++func cleanProcessEnvironment(t *testing.T) { ++ t.Helper() ++ originalEnv := append([]string(nil), os.Environ()...) ++ originalRoot := config.ProjectRoot ++ os.Clearenv() ++ t.Cleanup(func() { ++ os.Clearenv() ++ for _, entry := range originalEnv { ++ parts := strings.SplitN(entry, "=", 2) ++ if len(parts) == 2 { ++ _ = os.Setenv(parts[0], parts[1]) ++ } ++ } ++ config.ProjectRoot = originalRoot ++ }) ++} ++ ++func writeProperties(t *testing.T, root, environment, contents string) { ++ t.Helper() ++ dir := filepath.Join(root, "env", environment) ++ if err := os.MkdirAll(dir, 0755); err != nil { ++ t.Fatal(err) ++ } ++ path := filepath.Join(dir, "contract.properties") ++ if err := os.WriteFile(path, []byte(strings.TrimPrefix(contents, "\n")), 0644); err != nil { ++ t.Fatal(err) ++ } ++} ++ ++func assertEnv(t *testing.T, name, want string) { ++ t.Helper() ++ if got := os.Getenv(name); got != want { ++ t.Fatalf("%s = %q; want %q", name, got, want) ++ } ++} ++ ++func assertCycleError(t *testing.T, err error, members ...string) { ++ t.Helper() ++ if err == nil { ++ t.Fatal("LoadEnv succeeded with cyclic property references") ++ } ++ message := err.Error() ++ if !strings.Contains(strings.ToLower(message), "cyclic") { ++ t.Fatalf("cycle error %q does not identify the failure as cyclic", message) ++ } ++ for _, member := range members { ++ if !strings.Contains(message, member) { ++ t.Fatalf("cycle error %q does not name cycle member %s", message, member) ++ } ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,9 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++GAUGE_TEST_GOPATH="$(mktemp -d)" ++mkdir -p "${GAUGE_TEST_GOPATH}/src/github.com/getgauge" ++ln -s "$(pwd)" "${GAUGE_TEST_GOPATH}/src/github.com/getgauge/gauge" ++cd "${GAUGE_TEST_GOPATH}/src/github.com/getgauge/gauge" ++GO111MODULE=off GOPATH="${GAUGE_TEST_GOPATH}" go test ./env diff --git a/tasks/format-code-task-001170/tests/test.sh b/tasks/format-code-task-001170/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..46e0adf817da39e2130f2b6e027ff345ec353646 --- /dev/null +++ b/tasks/format-code-task-001170/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' +env/interpolation_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-001170/tests/test_command.sh b/tasks/format-code-task-001170/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001170/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001177/environment/Dockerfile b/tasks/format-code-task-001177/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7095669b470d1ffe98e0e1e17baa0aa8695c260d --- /dev/null +++ b/tasks/format-code-task-001177/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:12d510cd5f2e1b2920851f56a76a324f9a14a57ca3693e809cefe1d9edd6eccb diff --git a/tasks/format-code-task-001177/environment/setup/files/blocklist b/tasks/format-code-task-001177/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001177/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001177/environment/setup/setup.sh b/tasks/format-code-task-001177/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001177/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001177/tests/test.patch b/tasks/format-code-task-001177/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..21182afe010172e4af81082a48f46d9a99a9fb25 --- /dev/null +++ b/tasks/format-code-task-001177/tests/test.patch @@ -0,0 +1,162 @@ +diff --git a/curated_transformers/tests/generation/test_stop_contract.py b/curated_transformers/tests/generation/test_stop_contract.py +new file mode 100644 +index 0000000..2350c87 +--- /dev/null ++++ b/curated_transformers/tests/generation/test_stop_contract.py +@@ -0,0 +1,145 @@ ++import pytest ++import torch ++ ++from curated_transformers.generation.config import ( ++ GreedyGeneratorConfig, ++ SampleGeneratorConfig, ++) ++from curated_transformers.generation.state import GeneratorState ++from curated_transformers.generation.stop_conditions import EndOfSequenceCondition ++ ++ ++def _state(generated_ids, batch_size=1): ++ prompt_ids = torch.arange(batch_size, dtype=torch.long).reshape(batch_size, 1) ++ state = GeneratorState( ++ attention_mask=torch.ones((batch_size, 1), dtype=torch.bool), ++ cache=None, ++ prompt_ids=prompt_ids, ++ ) ++ state.generated_ids = torch.tensor(generated_ids, dtype=torch.long) ++ return state ++ ++ ++def _flags(batch_size=1): ++ return ( ++ torch.zeros((batch_size, 1), dtype=torch.bool), ++ torch.zeros((batch_size, 1), dtype=torch.bool), ++ ) ++ ++ ++def test_eos_condition_accepts_alias_ids_and_ignores_other_ids(): ++ state = _state([[9]]) ++ completed_exclude, completed_include = _flags() ++ EndOfSequenceCondition([4, 9]).update_completed( ++ state=state, ++ completed_exclude=completed_exclude, ++ completed_include=completed_include, ++ ) ++ assert completed_exclude.item() ++ assert not completed_include.item() ++ ++ state.generated_ids = torch.tensor([[8]], dtype=torch.long) ++ completed_exclude, completed_include = _flags() ++ EndOfSequenceCondition([4, 9]).update_completed( ++ state=state, ++ completed_exclude=completed_exclude, ++ completed_include=completed_include, ++ ) ++ assert not completed_exclude.item() ++ assert not completed_include.item() ++ ++ for config_cls in (GreedyGeneratorConfig, SampleGeneratorConfig): ++ state.generated_ids = torch.tensor([[9]], dtype=torch.long) ++ completed_exclude, completed_include = _flags() ++ condition = config_cls( ++ eos_id=[4, 9], max_generated_pieces=3, min_generated_pieces=0 ++ ).stop_condition() ++ condition.update_completed( ++ state=state, ++ completed_exclude=completed_exclude, ++ completed_include=completed_include, ++ ) ++ assert completed_exclude.item() ++ ++ ++def test_minimum_length_delays_eos_and_later_eos_still_stops(): ++ assert GreedyGeneratorConfig(eos_id=4, max_generated_pieces=2).min_generated_pieces == 0 ++ config = GreedyGeneratorConfig( ++ eos_id=[4, 9], max_generated_pieces=4, min_generated_pieces=2 ++ ) ++ state = _state([[]]) ++ seq_ids, outputs = state.step( ++ cache=[], ++ predicted_ids=torch.tensor([[4]], dtype=torch.long), ++ stop_condition=config.stop_condition(), ++ ) ++ assert seq_ids.tolist() == [0] ++ assert outputs.tolist() == [[4]] ++ assert not state.is_finished ++ ++ seq_ids, outputs = state.step( ++ cache=[], ++ predicted_ids=torch.tensor([[9]], dtype=torch.long), ++ stop_condition=config.stop_condition(), ++ ) ++ assert seq_ids.numel() == 0 ++ assert outputs.numel() == 0 ++ assert state.is_finished ++ ++ ++def test_maximum_length_includes_eos_and_finishes_sequence(): ++ config = GreedyGeneratorConfig(eos_id=[4, 9], max_generated_pieces=2) ++ state = _state([[7]]) ++ seq_ids, outputs = state.step( ++ cache=[], ++ predicted_ids=torch.tensor([[4]], dtype=torch.long), ++ stop_condition=config.stop_condition(), ++ ) ++ assert seq_ids.tolist() == [0] ++ assert outputs.tolist() == [[4]] ++ assert state.is_finished ++ ++ ++def test_batch_eos_removes_only_matching_rows_and_preserves_ids(): ++ config = GreedyGeneratorConfig(eos_id=[4, 9], max_generated_pieces=4) ++ state = _state([[1], [2]], batch_size=2) ++ seq_ids, outputs = state.step( ++ cache=[], ++ predicted_ids=torch.tensor([[9], [5]], dtype=torch.long), ++ stop_condition=config.stop_condition(), ++ ) ++ assert seq_ids.tolist() == [1] ++ assert outputs.tolist() == [[5]] ++ assert state.seq_ids.tolist() == [1] ++ assert state.generated_ids.tolist() == [[2, 5]] ++ ++ ++def test_scalar_eos_remains_supported(): ++ config = GreedyGeneratorConfig(eos_id=4, max_generated_pieces=3) ++ state = _state([[7]]) ++ seq_ids, outputs = state.step( ++ cache=[], ++ predicted_ids=torch.tensor([[4]], dtype=torch.long), ++ stop_condition=config.stop_condition(), ++ ) ++ assert seq_ids.numel() == 0 ++ assert outputs.numel() == 0 ++ assert state.is_finished ++ ++ ++@pytest.mark.parametrize( ++ "kwargs", ++ [ ++ {"eos_id": [], "max_generated_pieces": 2}, ++ {"eos_id": [4, "9"], "max_generated_pieces": 2}, ++ {"eos_id": [4, 9.0], "max_generated_pieces": 2}, ++ {"eos_id": [4], "max_generated_pieces": 2, "min_generated_pieces": -1}, ++ {"eos_id": [4], "max_generated_pieces": 2, "min_generated_pieces": 1.5}, ++ {"eos_id": [4], "max_generated_pieces": 2, "min_generated_pieces": 3}, ++ {"eos_id": None, "max_generated_pieces": 2}, ++ {"eos_id": 4, "max_generated_pieces": None}, ++ ], ++) ++def test_invalid_stop_configuration_is_rejected(kwargs): ++ with pytest.raises(ValueError): ++ GreedyGeneratorConfig(**kwargs).stop_condition() +diff --git 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 ++ ++.build_env/.venv/bin/python -m pytest -q \ ++ curated_transformers/tests/generation/test_stop_contract.py \ ++ curated_transformers/tests/generation/test_stop.py diff --git a/tasks/format-code-task-001177/tests/test.sh b/tasks/format-code-task-001177/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d2e2b7467d4837f428caf65d76a9dc009cd0bdb --- /dev/null +++ b/tasks/format-code-task-001177/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' +curated_transformers/tests/generation/test_stop_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-001177/tests/test_command.sh b/tasks/format-code-task-001177/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001177/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001179/environment/Dockerfile b/tasks/format-code-task-001179/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6c3eb1c0d282f82cad00eedace7cda6b4b47cb36 --- /dev/null +++ b/tasks/format-code-task-001179/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c82acad40da54cf0f15dd1bea88c7e51ddd83fc1a67e1103aae2f9711e1eb893 diff --git a/tasks/format-code-task-001179/environment/setup/files/blocklist b/tasks/format-code-task-001179/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001179/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001179/environment/setup/setup.sh b/tasks/format-code-task-001179/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001179/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001179/tests/test.patch b/tasks/format-code-task-001179/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4984e6693bf090d8c6c0361b6cab71b00f648629 --- /dev/null +++ b/tasks/format-code-task-001179/tests/test.patch @@ -0,0 +1,130 @@ +diff --git a/tests/sentry/utils/test_safe_extract_zip_security.py b/tests/sentry/utils/test_safe_extract_zip_security.py +new file mode 100644 +--- /dev/null ++++ b/tests/sentry/utils/test_safe_extract_zip_security.py +@@ -0,0 +1,115 @@ ++from __future__ import annotations ++ ++import io ++import stat ++import warnings ++import zipfile ++from pathlib import Path ++ ++import pytest ++ ++from sentry.utils.zip import safe_extract_zip ++ ++ ++def _archive(*members: tuple[str, bytes | str, int | None]) -> io.BytesIO: ++ stream = io.BytesIO() ++ with zipfile.ZipFile(stream, "w") as archive: ++ for name, contents, mode in members: ++ if mode is None: ++ with warnings.catch_warnings(): ++ warnings.simplefilter("ignore", UserWarning) ++ archive.writestr(name, contents) ++ continue ++ info = zipfile.ZipInfo(name) ++ info.create_system = 3 ++ info.external_attr = (mode | stat.S_IFMT(mode)) << 16 ++ archive.writestr(info, contents) ++ stream.seek(0) ++ return stream ++ ++ ++def test_safe_extract_zip_extracts_nested_regular_files(tmp_path: Path) -> None: ++ safe_extract_zip( ++ _archive(("nested/file.txt", b"payload", None), ("nested/", b"", None)), ++ str(tmp_path), ++ ) ++ ++ assert (tmp_path / "nested/file.txt").read_bytes() == b"payload" ++ ++ ++def test_safe_extract_zip_accepts_filename_and_open_zipfile(tmp_path: Path) -> None: ++ archive_path = tmp_path / "archive.zip" ++ archive_path.write_bytes(_archive(("file.txt", b"payload", None)).getvalue()) ++ ++ safe_extract_zip(str(archive_path), str(tmp_path / "from_filename")) ++ assert (tmp_path / "from_filename/file.txt").read_bytes() == b"payload" ++ ++ with zipfile.ZipFile(archive_path) as archive: ++ safe_extract_zip(archive, str(tmp_path / "from_open_archive")) ++ assert archive.namelist() == ["file.txt"] ++ assert (tmp_path / "from_open_archive/file.txt").read_bytes() == b"payload" ++ ++ ++@pytest.mark.parametrize( ++ "member_name", ++ [ ++ "../escape.txt", ++ "nested/../../escape.txt", ++ "..\\escape.txt", ++ "nested\\..\\escape.txt", ++ "/absolute.txt", ++ "C:\\absolute.txt", ++ ], ++) ++def test_unsafe_member_rejects_archive_before_writing( ++ tmp_path: Path, member_name: str ++) -> None: ++ destination = tmp_path / "destination" ++ outside = tmp_path / "escape.txt" ++ ++ with pytest.raises(ValueError): ++ safe_extract_zip( ++ _archive(("good.txt", b"must not remain", None), (member_name, b"escape", None)), ++ str(destination), ++ ) ++ ++ assert not (destination / "good.txt").exists() ++ assert not outside.exists() ++ ++ ++def test_symlink_member_is_rejected_without_creating_output(tmp_path: Path) -> None: ++ symlink_mode = stat.S_IFLNK | 0o777 ++ ++ with pytest.raises(ValueError): ++ safe_extract_zip( ++ _archive(("link", "target", symlink_mode)), ++ str(tmp_path / "destination"), ++ ) ++ ++ assert not (tmp_path / "destination").exists() ++ ++ ++def test_duplicate_member_target_is_rejected_atomically(tmp_path: Path) -> None: ++ with pytest.raises(ValueError): ++ safe_extract_zip( ++ _archive(("same.txt", b"first", None), ("same.txt", b"second", None)), ++ str(tmp_path / "destination"), ++ ) ++ ++ assert not (tmp_path / "destination").exists() ++ ++ ++def test_existing_destination_symlink_cannot_escape_root(tmp_path: Path) -> None: ++ destination = tmp_path / "destination" ++ outside = tmp_path / "outside" ++ destination.mkdir() ++ outside.mkdir() ++ (destination / "link").symlink_to(outside, target_is_directory=True) ++ ++ with pytest.raises(ValueError): ++ safe_extract_zip( ++ _archive(("link/payload.txt", b"must not escape", None)), ++ str(destination), ++ ) ++ ++ assert not (outside / "payload.txt").exists() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++pytest --noconftest -q tests/sentry/utils/test_safe_extract_zip_security.py tests/sentry/utils/test_zip.py diff --git a/tasks/format-code-task-001179/tests/test.sh b/tasks/format-code-task-001179/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c089c4bce24605b1bd7ff309c5b8c969171b7803 --- /dev/null +++ b/tasks/format-code-task-001179/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/sentry/utils/test_safe_extract_zip_security.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-001179/tests/test_command.sh b/tasks/format-code-task-001179/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001179/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001183/environment/Dockerfile b/tasks/format-code-task-001183/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4107e8e4e49f2e99c0c75892bb548ab8b80199b7 --- /dev/null +++ b/tasks/format-code-task-001183/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a1a6bed68308363a30212dda261053c6cbbe5f4e737c60aff4e7c881b6e6cb05 diff --git a/tasks/format-code-task-001183/environment/setup/files/blocklist b/tasks/format-code-task-001183/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001183/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001183/environment/setup/setup.sh b/tasks/format-code-task-001183/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001183/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001183/tests/test.patch b/tasks/format-code-task-001183/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ad73a68bd533bdbd8877ab0fa41462737f84add0 --- /dev/null +++ b/tasks/format-code-task-001183/tests/test.patch @@ -0,0 +1,243 @@ +diff --git a/tests/unit/engines/rag/test_retrieval_fusion_codespec.py b/tests/unit/engines/rag/test_retrieval_fusion_codespec.py +new file mode 100644 +index 0000000..d8bc1d1 +--- /dev/null ++++ b/tests/unit/engines/rag/test_retrieval_fusion_codespec.py +@@ -0,0 +1,227 @@ ++from collections.abc import Sequence ++ ++import pytest ++from attrs import define, field ++ ++from griptape.artifacts import BaseArtifact, InfoArtifact, TextArtifact ++from griptape.common import Reference ++from griptape.drivers import BaseRerankDriver ++from griptape.engines.rag import RagContext ++from griptape.engines.rag.modules import BaseRetrievalRagModule, TextChunksRerankRagModule ++from griptape.engines.rag.stages import RetrievalRagStage ++ ++ ++@define(kw_only=True) ++class CodespecStaticRetrievalModule(BaseRetrievalRagModule): ++ results: Sequence[BaseArtifact] = field(factory=list) ++ error: Exception | None = field(default=None) ++ ++ def run(self, context: RagContext) -> Sequence[BaseArtifact]: ++ if self.error is not None: ++ raise self.error ++ return self.results ++ ++ ++@define(kw_only=True) ++class CodespecReverseRerankDriver(BaseRerankDriver): ++ def run(self, query: str, artifacts: list[TextArtifact]) -> list[TextArtifact]: ++ return list(reversed(artifacts)) ++ ++ ++def text(value: str, artifact_id: str, **kwargs) -> TextArtifact: ++ return TextArtifact(value, id=artifact_id, **kwargs) ++ ++ ++def test_a_zero_max_chunks_returns_no_chunks_in_default_mode(): ++ module = CodespecStaticRetrievalModule(name="only", results=[text("alpha", "a")]) ++ context = RetrievalRagStage(retrieval_modules=[module], max_chunks=0).run(RagContext(query="q")) ++ ++ assert context.text_chunks == [] ++ ++ ++def test_context_diagnostics_default_empty_and_round_trip(): ++ context = RagContext(query="q") ++ ++ assert context.retrieval_scores == {} ++ assert context.retrieval_errors == {} ++ ++ restored = RagContext.from_dict(context.to_dict()) ++ assert restored.retrieval_scores == {} ++ assert restored.retrieval_errors == {} ++ ++ ++def test_default_concatenation_is_stable_and_clears_scores(): ++ first = text("same", "first", meta={"source": "first"}) ++ second = text("same", "second", meta={"source": "second"}) ++ left = CodespecStaticRetrievalModule( ++ name="left", ++ results=[InfoArtifact("ignored"), first, text("left-only", "left-only")], ++ ) ++ right = CodespecStaticRetrievalModule( ++ name="right", ++ results=[second, text("right-only", "right-only")], ++ ) ++ context = RagContext(query="q", retrieval_scores={"stale": 1.0}) ++ ++ result = RetrievalRagStage(retrieval_modules=[left, right]).run(context) ++ ++ assert [chunk.id for chunk in result.text_chunks] == ["first", "left-only", "right-only"] ++ assert result.text_chunks[0].meta == {"source": "first"} ++ assert result.retrieval_scores == {} ++ assert result.retrieval_errors == {} ++ ++ ++def test_rrf_scores_filter_non_text_and_count_each_module_once(): ++ first_a = text("alpha", "a-first", meta={"origin": "left"}, reference=Reference(title="first")) ++ later_a = text("alpha", "a-later", meta={"origin": "right"}, reference=Reference(title="later")) ++ left = CodespecStaticRetrievalModule( ++ name="left", ++ results=[ ++ InfoArtifact("does-not-consume-a-rank"), ++ first_a, ++ text("beta", "b-left"), ++ text("alpha", "a-repeat"), ++ ], ++ ) ++ right = CodespecStaticRetrievalModule( ++ name="right", ++ results=[text("beta", "b-right"), text("gamma", "c"), later_a], ++ ) ++ muted = CodespecStaticRetrievalModule(name="muted", results=[text("delta", "d")]) ++ ++ result = RetrievalRagStage( ++ retrieval_modules=[left, right, muted], ++ fusion_mode="rrf", ++ rrf_k=10, ++ module_weights={"left": 2, "muted": 0}, ++ ).run(RagContext(query="q")) ++ ++ assert [chunk.value for chunk in result.text_chunks] == ["alpha", "beta", "gamma", "delta"] ++ assert result.text_chunks[0].id == "a-first" ++ assert result.text_chunks[0].meta == {"origin": "left"} ++ assert result.text_chunks[0].reference.title == "first" ++ assert result.retrieval_scores == pytest.approx( ++ { ++ "a-first": 2 / 11 + 1 / 13, ++ "b-left": 2 / 12 + 1 / 11, ++ "c": 1 / 12, ++ "d": 0, ++ } ++ ) ++ ++ ++def test_rrf_ties_follow_first_configured_appearance(): ++ left = CodespecStaticRetrievalModule(name="left", results=[text("alpha", "a"), text("beta", "b-left")]) ++ right = CodespecStaticRetrievalModule( ++ name="right", results=[text("beta", "b-right"), text("alpha", "a-right")] ++ ) ++ ++ result = RetrievalRagStage(retrieval_modules=[left, right], fusion_mode="rrf").run(RagContext(query="q")) ++ ++ assert [chunk.id for chunk in result.text_chunks] == ["a", "b-left"] ++ assert result.retrieval_scores["a"] == pytest.approx(result.retrieval_scores["b-left"]) ++ assert result.retrieval_scores["a"] == pytest.approx(1 / 61 + 1 / 62) ++ ++ ++def test_continue_records_current_errors_and_clears_them_on_reuse(): ++ failed = CodespecStaticRetrievalModule(name="broken", error=ValueError("unavailable")) ++ healthy = CodespecStaticRetrievalModule(name="healthy", results=[text("available", "ok")]) ++ stage = RetrievalRagStage(retrieval_modules=[failed, healthy], fusion_mode="rrf", on_error="continue") ++ context = RagContext(query="q", retrieval_errors={"stale": "old"}, retrieval_scores={"stale": 99}) ++ ++ first_result = stage.run(context) ++ ++ assert [chunk.id for chunk in first_result.text_chunks] == ["ok"] ++ assert first_result.retrieval_errors == {"broken": "ValueError: unavailable"} ++ assert set(first_result.retrieval_scores) == {"ok"} ++ ++ restored = RagContext.from_dict(first_result.to_dict()) ++ assert restored.retrieval_errors == {"broken": "ValueError: unavailable"} ++ assert restored.retrieval_scores == pytest.approx(first_result.retrieval_scores) ++ ++ failed.error = None ++ failed.results = [text("recovered", "recovered")] ++ second_result = stage.run(context) ++ ++ assert [chunk.id for chunk in second_result.text_chunks] == ["recovered", "ok"] ++ assert second_result.retrieval_errors == {} ++ assert set(second_result.retrieval_scores) == {"recovered", "ok"} ++ ++ ++@pytest.mark.parametrize("fusion_mode", ["concatenate", "rrf"]) ++def test_continue_applies_to_each_fusion_mode(fusion_mode): ++ failed = CodespecStaticRetrievalModule(name="broken", error=LookupError("missing")) ++ healthy = CodespecStaticRetrievalModule(name="healthy", results=[text("available", "ok")]) ++ ++ result = RetrievalRagStage( ++ retrieval_modules=[failed, healthy], fusion_mode=fusion_mode, on_error="continue" ++ ).run(RagContext(query="q")) ++ ++ assert [chunk.id for chunk in result.text_chunks] == ["ok"] ++ assert result.retrieval_errors == {"broken": "LookupError: missing"} ++ ++ ++def test_raise_mode_propagates_and_preserves_context_state(): ++ failed = CodespecStaticRetrievalModule(name="broken", error=RuntimeError("stop")) ++ original_chunk = text("original", "original") ++ context = RagContext( ++ query="q", ++ text_chunks=[original_chunk], ++ retrieval_errors={"existing": "error"}, ++ retrieval_scores={"original": 0.5}, ++ ) ++ ++ with pytest.raises(RuntimeError, match="stop"): ++ RetrievalRagStage(retrieval_modules=[failed]).run(context) ++ ++ assert context.text_chunks == [original_chunk] ++ assert context.retrieval_errors == {"existing": "error"} ++ assert context.retrieval_scores == {"original": 0.5} ++ ++ ++def test_reranking_precedes_positive_limit_and_scores_cover_all_candidates(): ++ module = CodespecStaticRetrievalModule( ++ name="source", ++ results=[text("alpha", "a"), text("beta", "b"), text("gamma", "c")], ++ ) ++ reranker = TextChunksRerankRagModule(name="reverse", rerank_driver=CodespecReverseRerankDriver()) ++ ++ result = RetrievalRagStage( ++ retrieval_modules=[module], ++ rerank_module=reranker, ++ fusion_mode="rrf", ++ max_chunks=2, ++ ).run(RagContext(query="q")) ++ ++ assert [chunk.id for chunk in result.text_chunks] == ["c", "b"] ++ assert set(result.retrieval_scores) == {"a", "b", "c"} ++ ++ ++@pytest.mark.parametrize( ++ "kwargs", ++ [ ++ {"fusion_mode": "unknown"}, ++ {"on_error": "ignore"}, ++ ], ++) ++def test_invalid_modes_are_rejected(kwargs): ++ with pytest.raises(ValueError): ++ RetrievalRagStage(retrieval_modules=[], **kwargs) ++ ++ ++@pytest.mark.parametrize( ++ "kwargs", ++ [ ++ {"rrf_k": 0}, ++ {"rrf_k": -1}, ++ {"rrf_k": float("inf")}, ++ {"rrf_k": float("nan")}, ++ {"module_weights": {"source": -0.1}}, ++ {"module_weights": {"source": float("inf")}}, ++ {"module_weights": {"source": float("nan")}}, ++ {"max_chunks": -1}, ++ ], ++) ++def test_invalid_numeric_configuration_is_rejected(kwargs): ++ with pytest.raises(ValueError): ++ RetrievalRagStage(retrieval_modules=[], **kwargs) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++.venv/bin/pytest -q tests/unit/engines/rag/test_retrieval_fusion_codespec.py tests/unit/engines/rag/test_rag_engine.py tests/unit/engines/rag/test_rag_context.py diff --git a/tasks/format-code-task-001183/tests/test.sh b/tasks/format-code-task-001183/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..83643ab22123c4b7fcef579ee36018e217827daf --- /dev/null +++ b/tasks/format-code-task-001183/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/engines/rag/test_retrieval_fusion_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-001183/tests/test_command.sh b/tasks/format-code-task-001183/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001183/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001184/environment/Dockerfile b/tasks/format-code-task-001184/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c49b78933c7bdda5e18cbdd758d6e930eb705a28 --- /dev/null +++ b/tasks/format-code-task-001184/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6e32cb5770362584abb414f5fa1f95cd52800bbdac680cbfea07d05fd9875111 diff --git a/tasks/format-code-task-001184/environment/setup/files/blocklist b/tasks/format-code-task-001184/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001184/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001184/environment/setup/setup.sh b/tasks/format-code-task-001184/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001184/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001184/tests/test.patch b/tasks/format-code-task-001184/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ac33645f5e0a7a1b92a950611143486fe0bac5d3 --- /dev/null +++ b/tasks/format-code-task-001184/tests/test.patch @@ -0,0 +1,309 @@ +diff --git a/tests/test_chat_member_updates_codespec.py b/tests/test_chat_member_updates_codespec.py +new file mode 100644 +index 00000000..572f759f +--- /dev/null ++++ b/tests/test_chat_member_updates_codespec.py +@@ -0,0 +1,290 @@ ++import datetime ++from queue import Queue ++ ++import pytest ++ ++import telegram ++import telegram.ext as telegram_ext ++from telegram import Chat, ChatMember, Message, Update, User ++ ++ ++MEMBERSHIP_TIMESTAMP = 1600000000 ++EXPIRY_TIMESTAMP = 1600003600 ++ ++ ++def _membership_api(): ++ names = ('ChatInviteLink', 'ChatMemberUpdated') ++ missing = [name for name in names if not hasattr(telegram, name)] ++ assert not missing, 'missing public telegram membership API: {}'.format(', '.join(missing)) ++ assert hasattr(telegram_ext, 'ChatMemberHandler'), \ ++ 'missing public telegram.ext.ChatMemberHandler API' ++ return (telegram.ChatInviteLink, telegram.ChatMemberUpdated, ++ telegram_ext.ChatMemberHandler) ++ ++ ++def _member_payload(status, **overrides): ++ payload = { ++ 'user': {'id': 200, 'first_name': 'Target', 'is_bot': False}, ++ 'status': status, ++ 'can_send_messages': True, ++ 'can_send_polls': True, ++ 'can_invite_users': False, ++ } ++ payload.update(overrides) ++ return payload ++ ++ ++def _membership_payload(include_invite_link=True): ++ payload = { ++ 'chat': {'id': -10042, 'type': Chat.SUPERGROUP, 'title': 'Operators'}, ++ 'from': {'id': 100, 'first_name': 'Moderator', 'is_bot': False}, ++ 'date': MEMBERSHIP_TIMESTAMP, ++ 'old_chat_member': _member_payload(ChatMember.MEMBER), ++ 'new_chat_member': _member_payload( ++ ChatMember.RESTRICTED, can_send_messages=False, can_invite_users=True), ++ } ++ if include_invite_link: ++ payload['invite_link'] = { ++ 'invite_link': 'https://t.me/joinchat/codespec', ++ 'creator': {'id': 101, 'first_name': 'Inviter', 'is_bot': False}, ++ 'is_primary': False, ++ 'is_revoked': False, ++ 'expire_date': EXPIRY_TIMESTAMP, ++ 'member_limit': 0, ++ } ++ return payload ++ ++ ++def test_membership_public_exports_codespec(): ++ ChatInviteLink, ChatMemberUpdated, ChatMemberHandler = _membership_api() ++ ++ assert ChatInviteLink.__name__ == 'ChatInviteLink' ++ assert ChatMemberUpdated.__name__ == 'ChatMemberUpdated' ++ assert ChatMemberHandler.__name__ == 'ChatMemberHandler' ++ ++ creator = User(101, 'Inviter', False) ++ actor = User(100, 'Moderator', False) ++ chat = Chat(-10042, Chat.SUPERGROUP) ++ old_member = ChatMember(User(200, 'Target', False), ChatMember.MEMBER) ++ new_member = ChatMember(User(200, 'Target', False), ChatMember.LEFT) ++ link = ChatInviteLink('https://t.me/joinchat/direct', creator, False, False, ++ member_limit=0) ++ change = ChatMemberUpdated( ++ chat, actor, datetime.datetime.fromtimestamp( ++ MEMBERSHIP_TIMESTAMP, tz=datetime.timezone.utc), ++ old_member, new_member, invite_link=link) ++ ++ assert change.chat is chat ++ assert change.from_user is actor ++ assert change.old_chat_member is old_member ++ assert change.new_chat_member is new_member ++ assert change.invite_link is link ++ ++ ++def test_chat_invite_link_wire_roundtrip_codespec(bot): ++ ChatInviteLink, _, _ = _membership_api() ++ payload = _membership_payload()['invite_link'] ++ ++ link = ChatInviteLink.de_json(payload, bot) ++ ++ assert isinstance(link.creator, User) ++ assert link.creator.id == 101 ++ assert link.invite_link == payload['invite_link'] ++ assert link.is_primary is False ++ assert link.is_revoked is False ++ assert link.expire_date == datetime.datetime.fromtimestamp( ++ EXPIRY_TIMESTAMP, tz=datetime.timezone.utc) ++ assert link.member_limit == 0 ++ assert link.to_dict() == payload ++ ++ ++def test_chat_invite_link_optional_fields_codespec(bot): ++ ChatInviteLink, _, _ = _membership_api() ++ payload = { ++ 'invite_link': 'https://t.me/joinchat/no-expiry', ++ 'creator': {'id': 102, 'first_name': 'Owner', 'is_bot': True}, ++ 'is_primary': True, ++ 'is_revoked': False, ++ } ++ ++ link = ChatInviteLink.de_json(payload, bot) ++ ++ assert link.expire_date is None ++ assert link.member_limit is None ++ assert 'expire_date' not in link.to_dict() ++ assert 'member_limit' not in link.to_dict() ++ assert link.to_dict()['is_revoked'] is False ++ assert ChatInviteLink.de_json(None, bot) is None ++ ++ ++def test_chat_member_updated_nested_wire_contract_codespec(bot): ++ ChatInviteLink, ChatMemberUpdated, _ = _membership_api() ++ payload = _membership_payload() ++ ++ change = ChatMemberUpdated.de_json(payload, bot) ++ ++ assert isinstance(change.chat, Chat) ++ assert isinstance(change.from_user, User) ++ assert change.from_user.id == 100 ++ assert isinstance(change.old_chat_member, ChatMember) ++ assert isinstance(change.new_chat_member, ChatMember) ++ assert isinstance(change.invite_link, ChatInviteLink) ++ assert change.date == datetime.datetime.fromtimestamp( ++ MEMBERSHIP_TIMESTAMP, tz=datetime.timezone.utc) ++ ++ serialized = change.to_dict() ++ assert set(serialized) == { ++ 'chat', 'from', 'date', 'old_chat_member', 'new_chat_member', 'invite_link' ++ } ++ assert serialized['from'] == payload['from'] ++ assert serialized['date'] == MEMBERSHIP_TIMESTAMP ++ assert serialized['chat']['id'] == -10042 ++ assert serialized['old_chat_member']['status'] == ChatMember.MEMBER ++ assert serialized['new_chat_member']['status'] == ChatMember.RESTRICTED ++ assert serialized['invite_link'] == payload['invite_link'] ++ ++ ++def test_chat_member_updated_optional_invite_codespec(bot): ++ _, ChatMemberUpdated, _ = _membership_api() ++ ++ change = ChatMemberUpdated.de_json(_membership_payload(include_invite_link=False), bot) ++ ++ assert change.invite_link is None ++ assert 'invite_link' not in change.to_dict() ++ assert ChatMemberUpdated.de_json(None, bot) is None ++ ++ ++def test_chat_member_updated_difference_codespec(bot): ++ _, ChatMemberUpdated, _ = _membership_api() ++ changed_payload = _membership_payload() ++ del changed_payload['old_chat_member']['can_send_messages'] ++ changed_payload['new_chat_member']['can_send_polls'] = False ++ change = ChatMemberUpdated.de_json(changed_payload, bot) ++ ++ assert change.difference() == { ++ 'status': (ChatMember.MEMBER, ChatMember.RESTRICTED), ++ 'can_send_messages': (None, False), ++ 'can_send_polls': (True, False), ++ 'can_invite_users': (False, True), ++ } ++ ++ unchanged_payload = _membership_payload(include_invite_link=False) ++ unchanged_payload['new_chat_member'] = unchanged_payload['old_chat_member'].copy() ++ unchanged = ChatMemberUpdated.de_json(unchanged_payload, bot) ++ assert unchanged.difference() == {} ++ ++ ++@pytest.mark.parametrize('field', ('my_chat_member', 'chat_member')) ++def test_update_membership_de_json_and_to_dict_codespec(bot, field): ++ _, ChatMemberUpdated, _ = _membership_api() ++ raw_change = _membership_payload() ++ payload = {'update_id': 700, field: raw_change} ++ ++ update = Update.de_json(payload, bot) ++ ++ assert isinstance(getattr(update, field), ChatMemberUpdated) ++ other_field = 'chat_member' if field == 'my_chat_member' else 'my_chat_member' ++ assert getattr(update, other_field) is None ++ serialized = update.to_dict() ++ assert serialized['update_id'] == 700 ++ assert serialized[field]['from'] == raw_change['from'] ++ assert serialized[field]['date'] == MEMBERSHIP_TIMESTAMP ++ assert other_field not in serialized ++ ++ ++@pytest.mark.parametrize('field', ('my_chat_member', 'chat_member')) ++def test_update_membership_effective_properties_codespec(bot, field): ++ _membership_api() ++ update = Update.de_json({'update_id': 701, field: _membership_payload()}, bot) ++ change = getattr(update, field) ++ ++ assert update.effective_user.id == 100 ++ assert update.effective_user.first_name == 'Moderator' ++ assert update.effective_user.id != change.new_chat_member.user.id ++ assert update.effective_chat.id == -10042 ++ assert update.effective_message is None ++ ++ ++def test_chat_member_handler_mode_selection_codespec(bot): ++ _, _, ChatMemberHandler = _membership_api() ++ callback = lambda update, context: None ++ mine = Update.de_json( ++ {'update_id': 800, 'my_chat_member': _membership_payload()}, bot) ++ another = Update.de_json( ++ {'update_id': 801, 'chat_member': _membership_payload()}, bot) ++ unrelated = Update(802, message=Message( ++ 1, User(100, 'Moderator', False), None, Chat(-10042, Chat.SUPERGROUP))) ++ ++ default_handler = ChatMemberHandler(callback) ++ assert default_handler.chat_member_types == ChatMemberHandler.MY_CHAT_MEMBER ++ assert default_handler.check_update(mine) ++ assert not default_handler.check_update(another) ++ ++ member_handler = ChatMemberHandler( ++ callback, chat_member_types=ChatMemberHandler.CHAT_MEMBER) ++ assert member_handler.check_update(another) ++ assert not member_handler.check_update(mine) ++ ++ any_handler = ChatMemberHandler( ++ callback, chat_member_types=ChatMemberHandler.ANY_CHAT_MEMBER) ++ assert any_handler.check_update(mine) ++ assert any_handler.check_update(another) ++ assert not any_handler.check_update(unrelated) ++ assert not any_handler.check_update(object()) ++ ++ ++@pytest.mark.parametrize('invalid_mode', (2, None, 'chat_member')) ++def test_chat_member_handler_constants_and_validation_codespec(invalid_mode): ++ _, _, ChatMemberHandler = _membership_api() ++ ++ assert ChatMemberHandler.MY_CHAT_MEMBER == -1 ++ assert ChatMemberHandler.CHAT_MEMBER == 0 ++ assert ChatMemberHandler.ANY_CHAT_MEMBER == 1 ++ with pytest.raises(ValueError): ++ ChatMemberHandler(lambda update, context: None, chat_member_types=invalid_mode) ++ ++ ++def test_chat_member_handler_context_dispatch_codespec(bot): ++ _, _, ChatMemberHandler = _membership_api() ++ seen = [] ++ dispatcher = telegram_ext.Dispatcher(bot, Queue(), use_context=True) ++ ++ def callback(update, context): ++ seen.append((update, context.user_data, context.chat_data)) ++ ++ update = Update.de_json( ++ {'update_id': 900, 'chat_member': _membership_payload()}, bot) ++ dispatcher.add_handler(ChatMemberHandler( ++ callback, chat_member_types=ChatMemberHandler.CHAT_MEMBER)) ++ dispatcher.process_update(update) ++ ++ assert len(seen) == 1 ++ assert seen[0][0] is update ++ assert seen[0][1] is dispatcher.user_data[100] ++ assert seen[0][2] is dispatcher.chat_data[-10042] ++ ++ ++def test_chat_member_handler_legacy_dispatch_codespec(bot): ++ _, _, ChatMemberHandler = _membership_api() ++ seen = [] ++ dispatcher = telegram_ext.Dispatcher(bot, Queue(), use_context=False) ++ ++ def callback(callback_bot, update, user_data=None, chat_data=None, ++ update_queue=None, job_queue=None): ++ seen.append((callback_bot, update, user_data, chat_data, ++ update_queue, job_queue)) ++ ++ update = Update.de_json( ++ {'update_id': 901, 'my_chat_member': _membership_payload()}, bot) ++ dispatcher.add_handler(ChatMemberHandler( ++ callback, pass_user_data=True, pass_chat_data=True, ++ pass_update_queue=True, pass_job_queue=True)) ++ dispatcher.process_update(update) ++ ++ assert len(seen) == 1 ++ assert seen[0][0] is dispatcher.bot ++ assert seen[0][1] is update ++ assert seen[0][2] is dispatcher.user_data[100] ++ assert seen[0][3] is dispatcher.chat_data[-10042] ++ assert seen[0][4] is dispatcher.update_queue ++ assert seen[0][5] is dispatcher.job_queue +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++pytest -q -o filterwarnings= \ ++ tests/test_chat_member_updates_codespec.py \ ++ tests/test_chatmember.py \ ++ tests/test_update.py diff --git a/tasks/format-code-task-001184/tests/test.sh b/tasks/format-code-task-001184/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..53f116ad2632f9f02f2c0b0d078d16f2d5eeedd9 --- /dev/null +++ b/tasks/format-code-task-001184/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_chat_member_updates_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-001184/tests/test_command.sh b/tasks/format-code-task-001184/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001184/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001194/environment/Dockerfile b/tasks/format-code-task-001194/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3443653dfbb31ec43be5250da3936ae7eadb73c9 --- /dev/null +++ b/tasks/format-code-task-001194/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d25329f83c9cac3c73e53b79e537273e859cb9309a552cc0dbec337f49caa512 diff --git a/tasks/format-code-task-001194/environment/setup/files/blocklist b/tasks/format-code-task-001194/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001194/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001194/environment/setup/setup.sh b/tasks/format-code-task-001194/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001194/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001194/tests/test.patch b/tasks/format-code-task-001194/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..83fba5d55115dcb9600c8da58a7087df57f488cf --- /dev/null +++ b/tasks/format-code-task-001194/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/app_dart/test/request_handlers/push_gold_status_to_github_test.dart b/app_dart/test/request_handlers/push_gold_status_to_github_test.dart +index 46e4786bad..80eb75882f 100644 +--- a/app_dart/test/request_handlers/push_gold_status_to_github_test.dart ++++ b/app_dart/test/request_handlers/push_gold_status_to_github_test.dart +@@ -815,6 +815,67 @@ void main() { + ); + }); + ++ test('includes misc test shards', () async { ++ ++ final PullRequest pr = newPullRequest(123, 'abc', 'master'); ++ prsFromGitHub = [pr]; ++ final GithubGoldStatusUpdate status = newStatusUpdate(slug, pr, '', '', ''); ++ db.values[status.key] = status; ++ ++ ++ checkRuns = [ ++ {'name': 'misc', 'status': 'completed', 'conclusion': 'success'}, ++ ]; ++ ++ ++ mockHttpClient = MockClient((http.Request request) async { ++ if (request.url.toString() == ++ 'https://flutter-gold.skia.org/json/v1/changelist_summary/github/${pr.number}') { ++ return http.Response(tryjobEmpty(), HttpStatus.ok); ++ } ++ throw const HttpException('Unexpected http request'); ++ }); ++ handler = PushGoldStatusToGithub( ++ config: config, ++ authenticationProvider: auth, ++ datastoreProvider: (DatastoreDB db) { ++ return DatastoreService( ++ config.db, ++ 5, ++ retryOptions: retryOptions, ++ ); ++ }, ++ goldClient: mockHttpClient, ++ ingestionDelay: Duration.zero, ++ ); ++ ++ final Body body = await tester.get(handler); ++ expect(body, same(Body.empty)); ++ expect(status.updates, 1); ++ expect(status.status, GithubGoldStatusUpdate.statusCompleted); ++ expect(records.where((LogRecord record) => record.level == Level.WARNING), isEmpty); ++ expect(records.where((LogRecord record) => record.level == Level.SEVERE), isEmpty); ++ ++ ++ verifyNever( ++ issuesService.addLabelsToIssue( ++ slug, ++ pr.number!, ++ [ ++ kGoldenFileLabel, ++ ], ++ ), ++ ); ++ ++ verifyNever( ++ issuesService.createComment( ++ slug, ++ pr.number!, ++ argThat(contains(config.flutterGoldCommentID(pr))), ++ ), ++ ); ++ }); ++ + test('new commit, checks complete, no changes detected', () async { + // New commit + final PullRequest pr = newPullRequest(123, 'abc', 'master'); +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+3Su07DMBQGYM95CqtiJbZTnEpIDGyMDOxWEltNRBoHXxCPj+2lCAm6tEIV/zfY ++kU58kf9T93GatTLLOyOXwpOdlGVOvs/lW8hGNHwrd60gXIiWbwmVF7vRF9GHzlFKnLXht/9O1a9U ++fcw/GB/UYA+HbtG1H893xqn8GyGO+TdNyv+u5S2h/HxX+Nk/z3/QtATfG12Zj9W6QJ8fX54eNix6 ++x2Y7dDPTnQu3Xr+yflrub3J5U6V13bqqXKryQPMmZWDOvMXcSmPqo9k4z9boR7W3qc3SW4foVbBq ++P4Ux9iovqMsmf/0QAAAAAAAAAAAAAAAAAAAAAABX6BN5dzhRACgAAA== +diff --git 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-001194/tests/test.sh b/tasks/format-code-task-001194/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9149d6772a59eacb55c831c734b5fc0cc4dfd136 --- /dev/null +++ b/tasks/format-code-task-001194/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +app_dart/test/request_handlers/push_gold_status_to_github_test.dart +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-001194/tests/test_command.sh b/tasks/format-code-task-001194/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001194/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001319/environment/Dockerfile b/tasks/format-code-task-001319/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8c57fee79bafa1672e41a720853fdfa755d448ce --- /dev/null +++ b/tasks/format-code-task-001319/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a71d7d2deb0e344a0c1f9d12cc53cf7d5ea83a3e68a68a324c32387701616d34 diff --git a/tasks/format-code-task-001319/environment/setup/files/blocklist b/tasks/format-code-task-001319/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001319/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001319/environment/setup/setup.sh b/tasks/format-code-task-001319/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001319/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001319/tests/test.patch b/tasks/format-code-task-001319/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0d3408c1c915b6635a63ef9bc1d9a53a9ef1fa62 --- /dev/null +++ b/tasks/format-code-task-001319/tests/test.patch @@ -0,0 +1,318 @@ +diff --git a/usercase-test-coderl/yaml_json_conversion_test.go b/usercase-test-coderl/yaml_json_conversion_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/yaml_json_conversion_test.go +@@ -0,0 +1,287 @@ ++ ++ ++ ++ ++ ++ ++package usercase_test_coderl ++ ++import ( ++ "bytes" ++ "os" ++ "path/filepath" ++ "sort" ++ "testing" ++ ++ yaml "github.com/goccy/go-yaml" ++) ++ ++func TestYAMLToJSONQueryExamplePreservesOrderAndFormatsJSON(t *testing.T) { ++ ++ ++ input := []byte("foo:\n bar:\n - a\n - b\n - c\na: 1\n") ++ want := []byte("{\"foo\": {\"bar\": [\"a\", \"b\", \"c\"]}, \"a\": 1}\n") ++ ++ got, err := yaml.YAMLToJSON(input) ++ if err != nil { ++ t.Fatalf("YAMLToJSON returned error: %v", err) ++ } ++ if !bytes.Equal(got, want) { ++ t.Fatalf("YAMLToJSON output mismatch\nwant: %q\n got: %q", want, got) ++ } ++} ++ ++func TestYAMLToJSONScalarsAndSequenceFormatting(t *testing.T) { ++ ++ ++ input := []byte("z: true\nnullish: null\nnums:\n- 0\n- -2\n- 3.5\ntext: hello\n") ++ want := []byte("{\"z\": true, \"nullish\": null, \"nums\": [0, -2, 3.5], \"text\": \"hello\"}\n") ++ ++ got, err := yaml.YAMLToJSON(input) ++ if err != nil { ++ t.Fatalf("YAMLToJSON returned error: %v", err) ++ } ++ if !bytes.Equal(got, want) { ++ t.Fatalf("YAMLToJSON output mismatch\nwant: %q\n got: %q", want, got) ++ } ++} ++ ++func TestYAMLToJSONNestedOrderedMapsInArrays(t *testing.T) { ++ ++ ++ input := []byte("outer:\n first: 1\n second: 2\nlist:\n- name: beta\n value: 2\n- name: alpha\n value: 1\n") ++ want := []byte("{\"outer\": {\"first\": 1, \"second\": 2}, \"list\": [{\"name\": \"beta\", \"value\": 2}, {\"name\": \"alpha\", \"value\": 1}]}\n") ++ ++ got, err := yaml.YAMLToJSON(input) ++ if err != nil { ++ t.Fatalf("YAMLToJSON returned error: %v", err) ++ } ++ if !bytes.Equal(got, want) { ++ t.Fatalf("YAMLToJSON output mismatch\nwant: %q\n got: %q", want, got) ++ } ++} ++ ++func TestJSONToYAMLQueryExamplePreservesOrderAndFormatsYAML(t *testing.T) { ++ ++ ++ input := []byte("{\"foo\": {\"bar\": [\"a\", \"b\", \"c\"]}, \"a\": 1}") ++ want := []byte("foo:\n bar:\n - a\n - b\n - c\na: 1\n") ++ ++ got, err := yaml.JSONToYAML(input) ++ if err != nil { ++ t.Fatalf("JSONToYAML returned error: %v", err) ++ } ++ if !bytes.Equal(got, want) { ++ t.Fatalf("JSONToYAML output mismatch\nwant: %q\n got: %q", want, got) ++ } ++} ++ ++func TestJSONToYAMLNestedOrderedObjectsInArrays(t *testing.T) { ++ ++ ++ input := []byte("{\"outer\":{\"first\":1,\"second\":2},\"list\":[{\"name\":\"beta\",\"value\":2},{\"name\":\"alpha\",\"value\":1}]}") ++ want := []byte("outer:\n first: 1\n second: 2\nlist:\n- name: beta\n value: 2\n- name: alpha\n value: 1\n") ++ ++ got, err := yaml.JSONToYAML(input) ++ if err != nil { ++ t.Fatalf("JSONToYAML returned error: %v", err) ++ } ++ if !bytes.Equal(got, want) { ++ t.Fatalf("JSONToYAML output mismatch\nwant: %q\n got: %q", want, got) ++ } ++} ++ ++func TestJSONToYAMLScalarsAndArrayFormatting(t *testing.T) { ++ ++ ++ input := []byte("{\"z\":true,\"nullish\":null,\"nums\":[0,-2,3.5],\"text\":\"hello\"}") ++ want := []byte("z: true\nnullish: null\nnums:\n- 0\n- -2\n- 3.5\ntext: hello\n") ++ ++ got, err := yaml.JSONToYAML(input) ++ if err != nil { ++ t.Fatalf("JSONToYAML returned error: %v", err) ++ } ++ if !bytes.Equal(got, want) { ++ t.Fatalf("JSONToYAML output mismatch\nwant: %q\n got: %q", want, got) ++ } ++} ++ ++func TestYAMLToJSONInvalidYAMLReturnsSyntaxErrorAndNilOutput(t *testing.T) { ++ ++ ++ input := []byte("foo:\n - a\n bad: nope\n") ++ ++ got, err := yaml.YAMLToJSON(input) ++ ++ if err == nil { ++ t.Fatalf("YAMLToJSON error = nil, want non-nil error") ++ } ++ if len(got) != 0 { ++ t.Fatalf("YAMLToJSON output on error = %q, want no successful output", got) ++ } ++} ++ ++func TestJSONToYAMLInvalidJSONReturnsSyntaxErrorAndNilOutput(t *testing.T) { ++ ++ ++ input := []byte("{\"foo\": [1, }") ++ ++ got, err := yaml.JSONToYAML(input) ++ ++ if err == nil { ++ t.Fatalf("JSONToYAML error = nil, want non-nil error") ++ } ++ if len(got) != 0 { ++ t.Fatalf("JSONToYAML output on error = %q, want no successful output", got) ++ } ++} ++ ++func TestConversionsAreReferentiallyTransparentForSameInput(t *testing.T) { ++ yamlInput := []byte("foo:\n bar:\n - a\n - b\n - c\na: 1\n") ++ jsonInput := []byte("{\"foo\": {\"bar\": [\"a\", \"b\", \"c\"]}, \"a\": 1}") ++ ++ firstJSON, err := yaml.YAMLToJSON(yamlInput) ++ if err != nil { ++ t.Fatalf("first YAMLToJSON returned error: %v", err) ++ } ++ secondJSON, err := yaml.YAMLToJSON(yamlInput) ++ if err != nil { ++ t.Fatalf("second YAMLToJSON returned error: %v", err) ++ } ++ if !bytes.Equal(firstJSON, secondJSON) { ++ t.Fatalf("YAMLToJSON repeated output mismatch\nfirst: %q\nsecond: %q", firstJSON, secondJSON) ++ } ++ ++ firstYAML, err := yaml.JSONToYAML(jsonInput) ++ if err != nil { ++ t.Fatalf("first JSONToYAML returned error: %v", err) ++ } ++ secondYAML, err := yaml.JSONToYAML(jsonInput) ++ if err != nil { ++ t.Fatalf("second JSONToYAML returned error: %v", err) ++ } ++ if !bytes.Equal(firstYAML, secondYAML) { ++ t.Fatalf("JSONToYAML repeated output mismatch\nfirst: %q\nsecond: %q", firstYAML, secondYAML) ++ } ++} ++ ++func TestConversionsDoNotMutateInputSlices(t *testing.T) { ++ yamlInput := []byte("z: true\nnullish: null\nnums:\n- 0\n- -2\n- 3.5\ntext: hello\n") ++ yamlOriginal := append([]byte(nil), yamlInput...) ++ if _, err := yaml.YAMLToJSON(yamlInput); err != nil { ++ t.Fatalf("YAMLToJSON returned error: %v", err) ++ } ++ if !bytes.Equal(yamlInput, yamlOriginal) { ++ t.Fatalf("YAMLToJSON mutated input\nwant: %q\n got: %q", yamlOriginal, yamlInput) ++ } ++ ++ jsonInput := []byte("{\"z\":true,\"nullish\":null,\"nums\":[0,-2,3.5],\"text\":\"hello\"}") ++ jsonOriginal := append([]byte(nil), jsonInput...) ++ if _, err := yaml.JSONToYAML(jsonInput); err != nil { ++ t.Fatalf("JSONToYAML returned error: %v", err) ++ } ++ if !bytes.Equal(jsonInput, jsonOriginal) { ++ t.Fatalf("JSONToYAML mutated input\nwant: %q\n got: %q", jsonOriginal, jsonInput) ++ } ++} ++ ++func TestConversionsDoNotDependOnInProcessGlobalState(t *testing.T) { ++ yamlInput := []byte("foo:\n bar:\n - a\n - b\n - c\na: 1\n") ++ wantJSON := []byte("{\"foo\": {\"bar\": [\"a\", \"b\", \"c\"]}, \"a\": 1}\n") ++ jsonInput := []byte("{\"foo\": {\"bar\": [\"a\", \"b\", \"c\"]}, \"a\": 1}") ++ wantYAML := []byte("foo:\n bar:\n - a\n - b\n - c\na: 1\n") ++ ++ if got, err := yaml.YAMLToJSON(yamlInput); err != nil || !bytes.Equal(got, wantJSON) { ++ t.Fatalf("initial YAMLToJSON = %q, %v; want %q, nil", got, err, wantJSON) ++ } ++ if got, err := yaml.JSONToYAML([]byte("{\"z\":true,\"nums\":[0,-2,3.5]}")); err != nil || len(got) == 0 { ++ t.Fatalf("noise JSONToYAML = %q, %v; want non-empty output and nil error", got, err) ++ } ++ if got, err := yaml.YAMLToJSON([]byte("outer:\n first: 1\n second: 2\n")); err != nil || len(got) == 0 { ++ t.Fatalf("noise YAMLToJSON = %q, %v; want non-empty output and nil error", got, err) ++ } ++ if got, err := yaml.YAMLToJSON(yamlInput); err != nil || !bytes.Equal(got, wantJSON) { ++ t.Fatalf("post-noise YAMLToJSON = %q, %v; want %q, nil", got, err, wantJSON) ++ } ++ ++ if got, err := yaml.JSONToYAML(jsonInput); err != nil || !bytes.Equal(got, wantYAML) { ++ t.Fatalf("initial JSONToYAML = %q, %v; want %q, nil", got, err, wantYAML) ++ } ++ if got, err := yaml.YAMLToJSON([]byte("z: true\ntext: hello\n")); err != nil || len(got) == 0 { ++ t.Fatalf("noise YAMLToJSON = %q, %v; want non-empty output and nil error", got, err) ++ } ++ if got, err := yaml.JSONToYAML([]byte("{\"outer\":{\"first\":1,\"second\":2}}")); err != nil || len(got) == 0 { ++ t.Fatalf("noise JSONToYAML = %q, %v; want non-empty output and nil error", got, err) ++ } ++ if got, err := yaml.JSONToYAML(jsonInput); err != nil || !bytes.Equal(got, wantYAML) { ++ t.Fatalf("post-noise JSONToYAML = %q, %v; want %q, nil", got, err, wantYAML) ++ } ++} ++ ++func TestConversionsDoNotWriteFilesInWorkingDirectory(t *testing.T) { ++ tmp := t.TempDir() ++ oldwd, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd failed: %v", err) ++ } ++ 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 working directory failed: %v", err) ++ } ++ }() ++ ++ before := snapshotRelativePaths(t, tmp) ++ if _, err := yaml.YAMLToJSON([]byte("foo:\n bar:\n - a\n - b\n - c\na: 1\n")); err != nil { ++ t.Fatalf("YAMLToJSON returned error: %v", err) ++ } ++ if _, err := yaml.JSONToYAML([]byte("{\"foo\": {\"bar\": [\"a\", \"b\", \"c\"]}, \"a\": 1}")); err != nil { ++ t.Fatalf("JSONToYAML returned error: %v", err) ++ } ++ after := snapshotRelativePaths(t, tmp) ++ ++ if !equalStringSlices(before, after) { ++ t.Fatalf("working directory changed\nbefore: %#v\nafter: %#v", before, after) ++ } ++} ++ ++func snapshotRelativePaths(t *testing.T, root string) []string { ++ t.Helper() ++ var paths []string ++ err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error { ++ if err != nil { ++ return err ++ } ++ if path == root { ++ return nil ++ } ++ rel, err := filepath.Rel(root, path) ++ if err != nil { ++ return err ++ } ++ if d.IsDir() { ++ rel += string(os.PathSeparator) ++ } ++ paths = append(paths, rel) ++ return nil ++ }) ++ if err != nil { ++ t.Fatalf("snapshot failed: %v", err) ++ } ++ sort.Strings(paths) ++ return paths ++} ++ ++func equalStringSlices(a, b []string) bool { ++ if len(a) != len(b) { ++ return false ++ } ++ for i := range a { ++ if a[i] != b[i] { ++ return false ++ } ++ } ++ 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,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 GOPROXY=off ++export GOSUMDB=off ++export GONOSUMDB='*' ++export GOTOOLCHAIN=local ++export GOWORK=off ++export GOVCS='*:off' ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001319/tests/test.sh b/tasks/format-code-task-001319/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ebf41d1665ff9948064f515afe86ad790dab0c7 --- /dev/null +++ b/tasks/format-code-task-001319/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/yaml_json_conversion_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-001319/tests/test_command.sh b/tasks/format-code-task-001319/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001319/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-001320/environment/Dockerfile b/tasks/format-code-task-001320/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..22c3947b7e03b92a0574260942a72e283fec52ec --- /dev/null +++ b/tasks/format-code-task-001320/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e91e7cc4b4a8a86618728064d96ba6b2ceaffe65f5cd80527b13aa14921dcc14 diff --git a/tasks/format-code-task-001320/environment/setup/files/blocklist b/tasks/format-code-task-001320/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001320/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001320/environment/setup/setup.sh b/tasks/format-code-task-001320/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001320/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001320/tests/test.patch b/tasks/format-code-task-001320/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..22f66112c510cb891e1268ebf20ae44c1db04a6b --- /dev/null +++ b/tasks/format-code-task-001320/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/colly_test.go b/colly_test.go +index d2a14750..b2c0f4ff 100644 +--- a/colly_test.go ++++ b/colly_test.go +@@ -101,7 +101,11 @@ func newTestServer() *httptest.Server { + }) + + mux.Handle("/redirect", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { +- http.Redirect(w, r, "/redirected/", http.StatusSeeOther) ++ destination := "/redirected/" ++ if d := r.URL.Query().Get("d"); d != "" { ++ destination = d ++ } ++ http.Redirect(w, r, destination, http.StatusSeeOther) + + })) + +@@ -674,6 +678,38 @@ func TestCollectorURLRevisitCheck(t *testing.T) { + if visited != true { + t.Error("Expected URL to have been visited") + } ++ ++ errorTestCases := []struct { ++ Path string ++ DestinationError string ++ }{ ++ {"/", "/"}, ++ {"/redirect?d=/", "/"}, ++ ++ ++ {"/redirect?d=/", "/redirect?d=/"}, ++ {"/redirect?d=/redirect%3Fd%3D/", "/redirect?d=/"}, ++ {"/redirect?d=/redirect%3Fd%3D/", "/redirect?d=/redirect%3Fd%3D/"}, ++ {"/redirect?d=/redirect%3Fd%3D/&foo=bar", "/redirect?d=/"}, ++ } ++ ++ for i, testCase := range errorTestCases { ++ err := c.Visit(ts.URL + testCase.Path) ++ if testCase.DestinationError == "" { ++ if err != nil { ++ t.Errorf("got unexpected error in test %d: %q", i, err) ++ } ++ } else { ++ var ave *AlreadyVisitedError ++ if !errors.As(err, &ave) { ++ t.Errorf("err=%q returned when trying to revisit, expected AlreadyVisitedError", err) ++ } else { ++ if got, want := ave.Destination.String(), ts.URL+testCase.DestinationError; got != want { ++ t.Errorf("wrong destination in AlreadyVisitedError in test %d, got=%q want=%q", i, got, want) ++ } ++ } ++ } ++ } + } + + func TestCollectorPostURLRevisitCheck(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+3RsW7CMBDG8cw8xb1AUh8iZurEyoTaGYFjlaghlhInz183C1UlYAEhxP+33Ols ++yWd9xX6om2rr2/EtuxeTLMtyqsn/OvVaznVulmptmqtao5mUd9voj6GPu04k60KIl+5dO39SxSn/ ++6Pu4deF43LVV0R9u98a1/NUsTvmrTfkvrKb8ze1WOO/F83eVTMHvfTX7CvLbSj5K7sLQxneVvBta +++UjTVWga72LoPjfrjR/rvo6rg3ffUswe/QcAAAAAAAAAAAAAAADgVf0AnoIz/gAoAAA= +diff --git 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-001320/tests/test.sh b/tasks/format-code-task-001320/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8ea0f539872ea03aa8f4ee9381db744df5adad5a --- /dev/null +++ b/tasks/format-code-task-001320/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' +colly_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-001320/tests/test_command.sh b/tasks/format-code-task-001320/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001320/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001321/environment/Dockerfile b/tasks/format-code-task-001321/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0976d3d2e5ae23911ba7456e4cca6b67491235c9 --- /dev/null +++ b/tasks/format-code-task-001321/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2f4fb03f226da0e38d62f7650feccfbe376c43d269f0871af45b6c2ffdacb4c3 diff --git a/tasks/format-code-task-001321/environment/setup/files/blocklist b/tasks/format-code-task-001321/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001321/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001321/environment/setup/setup.sh b/tasks/format-code-task-001321/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001321/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001321/tests/test.patch b/tasks/format-code-task-001321/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ceec5a91b7858b81075bad6fa41471e1c2df24a --- /dev/null +++ b/tasks/format-code-task-001321/tests/test.patch @@ -0,0 +1,582 @@ +diff --git a/usercase-test-coderl/deployment-watcher.test.js b/usercase-test-coderl/deployment-watcher.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/deployment-watcher.test.js +@@ -0,0 +1,546 @@ ++/* eslint-env mocha */ ++ ++ ++ ++ ++ ++ ++ ++const chai = require('chai') ++const sinon = require('sinon') ++ ++const DeploymentWatcher = require('../lib/watchers/deployment-watcher') ++const { DecisionResults } = require('../lib/plugins/plugin') ++const { DEPLOYMENT_ANNOTATION_NAME, EXPERIMENT_ANNOTATION_NAME } = require('../lib/watchers/constants') ++ ++const { expect } = chai ++ ++const descriptor = { ++ control: { name: 'control-deploy' }, ++ treatment: { name: 'treatment-deploy' } ++} ++ ++const controlDeployment = deployment('control:v1', 3) ++ ++function deployment (image, replicas, annotationValue) { ++ const annotations = {} ++ if (annotationValue !== undefined) { ++ annotations[EXPERIMENT_ANNOTATION_NAME] = annotationValue ++ } ++ return { ++ metadata: { annotations }, ++ spec: { ++ replicas, ++ template: { ++ spec: { ++ containers: [{ name: 'app', image }] ++ } ++ } ++ } ++ } ++} ++ ++function createKubeClient (control = controlDeployment) { ++ const patches = [] ++ const stream = { id: 'watch-stream' } ++ return { ++ patches, ++ stream, ++ apis: { ++ apps: { ++ v1: { ++ watch: { ++ namespaces: namespace => ({ ++ deploy: name => ({ ++ getStream: () => ({ stream, namespace, name }) ++ }) ++ }) ++ }, ++ namespaces: namespace => ({ ++ deploy: name => ({ ++ get: () => Promise.resolve({ body: control }), ++ patch: patch => { ++ patches.push({ namespace, name, body: patch.body }) ++ return Promise.resolve({ body: patch.body }) ++ } ++ }) ++ }) ++ } ++ } ++ } ++ } ++} ++ ++function createPlugin (results) { ++ return { ++ starts: [], ++ stops: 0, ++ polls: [], ++ onExperimentStart: function (startTime) { ++ this.starts.push(startTime.toISOString()) ++ }, ++ onExperimentStop: function () { ++ this.stops += 1 ++ }, ++ onExperimentPoll: function (controlName, treatmentName) { ++ this.polls.push([controlName, treatmentName]) ++ return Promise.resolve(results.shift()) ++ } ++ } ++} ++ ++function createLogger () { ++ return { ++ info: sinon.stub(), ++ warn: sinon.stub(), ++ error: sinon.stub() ++ } ++} ++ ++function createWatcher ({ kubeClient = createKubeClient(), plugins = [createPlugin([])], pollerIntervalMilliseconds = 1000, logger = createLogger(), gatedDeploymentId = 'gd-acceptance' } = {}) { ++ return new DeploymentWatcher({ ++ kubeClient, ++ logger, ++ deploymentDescriptor: descriptor, ++ namespace: 'qa', ++ plugins, ++ pollerIntervalMilliseconds, ++ gatedDeploymentId ++ }) ++} ++ ++async function flushPromises () { ++ for (let i = 0; i < 12; i += 1) { ++ await Promise.resolve() ++ } ++} ++ ++function timeoutResourceCount () { ++ return process.getActiveResourcesInfo().filter(name => name === 'Timeout').length ++} ++ ++function isTreatmentPatch (patch) { ++ return patch.namespace === 'qa' && patch.name === 'treatment-deploy' ++} ++ ++function isControlPatch (patch) { ++ return patch.namespace === 'qa' && patch.name === 'control-deploy' ++} ++ ++function experimentAnnotationValue (patch) { ++ return patch.body && ++ patch.body.metadata && ++ patch.body.metadata.annotations && ++ patch.body.metadata.annotations[EXPERIMENT_ANNOTATION_NAME] ++} ++ ++function deploymentStatusValue (patch) { ++ return patch.body && ++ patch.body.metadata && ++ patch.body.metadata.annotations && ++ patch.body.metadata.annotations[DEPLOYMENT_ANNOTATION_NAME] ++} ++ ++function isTreatmentScaleZeroPatch (patch) { ++ return isTreatmentPatch(patch) && ++ patch.body && ++ patch.body.spec && ++ patch.body.spec.replicas === 0 ++} ++ ++function isExperimentAnnotationClearPatch (patch) { ++ return isTreatmentPatch(patch) && experimentAnnotationValue(patch) === null ++} ++ ++function isExperimentAnnotationSetPatch (patch) { ++ return isTreatmentPatch(patch) && ++ typeof experimentAnnotationValue(patch) === 'string' && ++ experimentAnnotationValue(patch).length > 0 ++} ++ ++function isDeploymentStatusPatch (status) { ++ return patch => isTreatmentPatch(patch) && deploymentStatusValue(patch) === status ++} ++ ++function controlPatchHasContainerImage (patch, image) { ++ const containers = patch.body && ++ patch.body.spec && ++ patch.body.spec.template && ++ patch.body.spec.template.spec && ++ patch.body.spec.template.spec.containers ++ return isControlPatch(patch) && ++ Array.isArray(containers) && ++ containers.some(container => container.image === image) ++} ++ ++function findPatchIndex (patches, predicate, startIndex = 0) { ++ for (let i = startIndex; i < patches.length; i += 1) { ++ if (predicate(patches[i])) return i ++ } ++ return -1 ++} ++ ++function expectPatch (patches, predicate, message, startIndex = 0) { ++ const index = findPatchIndex(patches, predicate, startIndex) ++ expect(index, message).to.be.at.least(startIndex) ++ return index ++} ++ ++function expectNoPatch (patches, predicate, message) { ++ expect(patches.some(predicate), message).to.equal(false) ++} ++ ++describe('usercase DeploymentWatcher lifecycle acceptance', () => { ++ let clock ++ ++ afterEach(async () => { ++ if (clock) { ++ clock.restore() ++ clock = null ++ } ++ }) ++ ++ it('returns a namespace-scoped treatment watch stream', () => { ++ ++ ++ const kubeClient = createKubeClient() ++ const watcher = createWatcher({ kubeClient }) ++ ++ expect(watcher.getStream()).to.deep.equal({ ++ stream: { id: 'watch-stream' }, ++ namespace: 'qa', ++ name: 'treatment-deploy' ++ }) ++ }) ++ ++ it('clears experiment annotation and does not poll when added treatment has zero replicas', async () => { ++ ++ ++ const kubeClient = createKubeClient() ++ const plugin = createPlugin([]) ++ const watcher = createWatcher({ kubeClient, plugins: [plugin] }) ++ ++ await watcher.onAdded(deployment('treatment:v2', 0)) ++ ++ ++ expect(kubeClient.patches).to.have.lengthOf(1) ++ expect(kubeClient.patches[0]).to.satisfy(isExperimentAnnotationClearPatch) ++ expect(plugin.starts).to.deep.equal([]) ++ expect(plugin.polls).to.deep.equal([]) ++ expect(plugin.stops).to.equal(0) ++ }) ++ ++ it('scales treatment down as noHarm without plugins when treatment matches control', async () => { ++ ++ ++ const kubeClient = createKubeClient() ++ const plugin = createPlugin([]) ++ const watcher = createWatcher({ kubeClient, plugins: [plugin] }) ++ ++ await watcher.onAdded(deployment('control:v1', 2)) ++ ++ ++ expectPatch(kubeClient.patches, isTreatmentScaleZeroPatch, 'scaled treatment to zero') ++ expectPatch(kubeClient.patches, isDeploymentStatusPatch('noHarm'), 'set noHarm status') ++ expectNoPatch(kubeClient.patches, isExperimentAnnotationSetPatch, 'did not start experiment annotation') ++ expect(plugin.starts).to.deep.equal([]) ++ expect(plugin.polls).to.deep.equal([]) ++ expect(plugin.stops).to.equal(0) ++ }) ++ ++ it('starts a new experiment, persists the hash annotation, and keeps running on WAIT', async () => { ++ ++ ++ clock = sinon.useFakeTimers(new Date('2020-01-02T03:04:05.006Z').getTime()) ++ const kubeClient = createKubeClient() ++ const plugin = createPlugin([DecisionResults.WAIT]) ++ const watcher = createWatcher({ kubeClient, plugins: [plugin], pollerIntervalMilliseconds: 1000 }) ++ ++ await watcher.onAdded(deployment('treatment:v2', 2)) ++ clock.tick(1000) ++ await flushPromises() ++ ++ ++ expect(kubeClient.patches).to.have.lengthOf(1) ++ expect(kubeClient.patches[0]).to.satisfy(isExperimentAnnotationSetPatch) ++ const startedAnnotation = JSON.parse(experimentAnnotationValue(kubeClient.patches[0])) ++ expect(startedAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(startedAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ expect(plugin.starts).to.deep.equal(['2020-01-02T03:04:05.006Z']) ++ expect(plugin.polls).to.deep.equal([['control-deploy', 'treatment-deploy']]) ++ expect(plugin.stops).to.equal(0) ++ ++ await watcher.onDeleted() ++ }) ++ ++ it('resumes from a valid same-hash annotation and ignores invalid or mismatched annotations', async () => { ++ ++ ++ clock = sinon.useFakeTimers(new Date('2019-07-10T22:50:18.234Z').getTime()) ++ const sameHashClient = createKubeClient() ++ const sameHashWatcher = createWatcher({ kubeClient: sameHashClient, plugins: [createPlugin([])] }) ++ await sameHashWatcher.onAdded(deployment('treatment:v2', 2)) ++ const sameHash = experimentAnnotationValue(sameHashClient.patches[0]) ++ await sameHashWatcher.onDeleted() ++ ++ const mismatchedHashClient = createKubeClient() ++ const mismatchedHashWatcher = createWatcher({ kubeClient: mismatchedHashClient, plugins: [createPlugin([])] }) ++ await mismatchedHashWatcher.onAdded(deployment('treatment:v3', 2)) ++ const mismatchedHash = experimentAnnotationValue(mismatchedHashClient.patches[0]) ++ await mismatchedHashWatcher.onDeleted() ++ ++ clock.restore() ++ clock = sinon.useFakeTimers(new Date('2020-01-02T03:04:05.006Z').getTime()) ++ ++ const resumeClient = createKubeClient() ++ const resumePlugin = createPlugin([]) ++ const resumeWatcher = createWatcher({ kubeClient: resumeClient, plugins: [resumePlugin] }) ++ await resumeWatcher.onAdded(deployment('treatment:v2', 2, sameHash)) ++ expect(resumePlugin.starts).to.deep.equal(['2019-07-10T22:50:18.234Z']) ++ ++ expect(resumeClient.patches[0]).to.satisfy(isExperimentAnnotationSetPatch) ++ const resumedAnnotation = JSON.parse(experimentAnnotationValue(resumeClient.patches[0])) ++ expect(resumedAnnotation.startTime).to.equal('2019-07-10T22:50:18.234Z') ++ expect(resumedAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ await resumeWatcher.onDeleted() ++ ++ const invalidClient = createKubeClient() ++ const invalidPlugin = createPlugin([]) ++ const invalidWatcher = createWatcher({ kubeClient: invalidClient, plugins: [invalidPlugin] }) ++ await invalidWatcher.onAdded(deployment('treatment:v2', 2, 'not-json')) ++ expect(invalidPlugin.starts).to.deep.equal(['2020-01-02T03:04:05.006Z']) ++ ++ expect(invalidClient.patches[0]).to.satisfy(isExperimentAnnotationSetPatch) ++ const invalidReplacement = JSON.parse(experimentAnnotationValue(invalidClient.patches[0])) ++ expect(invalidReplacement.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(invalidReplacement.podSpecHash).to.be.a('string').and.not.equal('') ++ await invalidWatcher.onDeleted() ++ ++ const mismatchClient = createKubeClient() ++ const mismatchPlugin = createPlugin([]) ++ const mismatchWatcher = createWatcher({ kubeClient: mismatchClient, plugins: [mismatchPlugin] }) ++ await mismatchWatcher.onAdded(deployment('treatment:v2', 2, mismatchedHash)) ++ expect(mismatchPlugin.starts).to.deep.equal(['2020-01-02T03:04:05.006Z']) ++ ++ expect(mismatchClient.patches[0]).to.satisfy(isExperimentAnnotationSetPatch) ++ const mismatchReplacement = JSON.parse(experimentAnnotationValue(mismatchClient.patches[0])) ++ expect(mismatchReplacement.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(mismatchReplacement.podSpecHash).to.be.a('string').and.not.equal('') ++ await mismatchWatcher.onDeleted() ++ }) ++ ++ it('fails immediately on any FAIL result and treats plugin polling errors as WAIT', async () => { ++ ++ ++ clock = sinon.useFakeTimers(new Date('2020-01-02T03:04:05.006Z').getTime()) ++ const kubeClient = createKubeClient() ++ const failingPlugin = createPlugin([DecisionResults.FAIL]) ++ const throwingPlugin = createPlugin([]) ++ throwingPlugin.onExperimentPoll = function (controlName, treatmentName) { ++ this.polls.push([controlName, treatmentName]) ++ return Promise.reject(new Error('backend unavailable')) ++ } ++ const logger = createLogger() ++ const watcher = createWatcher({ kubeClient, plugins: [failingPlugin, throwingPlugin], logger }) ++ ++ await watcher.onAdded(deployment('treatment:v4', 2)) ++ clock.tick(1000) ++ await flushPromises() ++ ++ ++ const failStartIndex = expectPatch(kubeClient.patches, isExperimentAnnotationSetPatch, 'started experiment before FAIL') ++ const failStartAnnotation = JSON.parse(experimentAnnotationValue(kubeClient.patches[failStartIndex])) ++ expect(failStartAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(failStartAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ const failClearIndex = expectPatch(kubeClient.patches, isExperimentAnnotationClearPatch, 'cleared experiment annotation after FAIL', failStartIndex + 1) ++ expectPatch(kubeClient.patches, isTreatmentScaleZeroPatch, 'scaled treatment to zero after FAIL', failClearIndex + 1) ++ expectPatch(kubeClient.patches, isDeploymentStatusPatch('harm'), 'set harm status after FAIL', failClearIndex + 1) ++ expect(failingPlugin.polls).to.deep.equal([['control-deploy', 'treatment-deploy']]) ++ expect(throwingPlugin.polls).to.deep.equal([['control-deploy', 'treatment-deploy']]) ++ expect(failingPlugin.stops).to.equal(1) ++ expect(throwingPlugin.stops).to.equal(1) ++ expect(logger.error.callCount).to.equal(1) ++ }) ++ ++ it('passes only when every plugin returns PASS and promotes treatment spec to control', async () => { ++ ++ ++ clock = sinon.useFakeTimers(new Date('2020-01-02T03:04:05.006Z').getTime()) ++ const kubeClient = createKubeClient() ++ const firstPlugin = createPlugin([DecisionResults.PASS]) ++ const secondPlugin = createPlugin([DecisionResults.PASS]) ++ const watcher = createWatcher({ kubeClient, plugins: [firstPlugin, secondPlugin] }) ++ ++ await watcher.onAdded(deployment('treatment:v3', 2)) ++ clock.tick(1000) ++ await flushPromises() ++ ++ ++ const passStartIndex = expectPatch(kubeClient.patches, isExperimentAnnotationSetPatch, 'started experiment before PASS') ++ const passStartAnnotation = JSON.parse(experimentAnnotationValue(kubeClient.patches[passStartIndex])) ++ expect(passStartAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(passStartAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ const passClearIndex = expectPatch(kubeClient.patches, isExperimentAnnotationClearPatch, 'cleared experiment annotation after PASS', passStartIndex + 1) ++ expectPatch(kubeClient.patches, patch => controlPatchHasContainerImage(patch, 'treatment:v3'), 'promoted treatment pod spec to control', passClearIndex + 1) ++ expectPatch(kubeClient.patches, isTreatmentScaleZeroPatch, 'scaled treatment to zero after PASS', passClearIndex + 1) ++ expectPatch(kubeClient.patches, isDeploymentStatusPatch('noHarm'), 'set noHarm status after PASS', passClearIndex + 1) ++ expect(firstPlugin.stops).to.equal(1) ++ expect(secondPlugin.stops).to.equal(1) ++ }) ++ ++ it('onModified leaves an unchanged running experiment alone but restarts when replicas or pod spec change', async () => { ++ ++ ++ clock = sinon.useFakeTimers(new Date('2020-01-02T03:04:05.006Z').getTime()) ++ const kubeClient = createKubeClient() ++ const plugin = createPlugin([]) ++ const watcher = createWatcher({ kubeClient, plugins: [plugin] }) ++ ++ await watcher.onAdded(deployment('treatment:v2', 2)) ++ await watcher.onModified(deployment('treatment:v2', 2)) ++ ++ expect(kubeClient.patches).to.have.lengthOf(1) ++ expect(kubeClient.patches[0]).to.satisfy(isExperimentAnnotationSetPatch) ++ const initialModifiedAnnotation = JSON.parse(experimentAnnotationValue(kubeClient.patches[0])) ++ expect(initialModifiedAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(initialModifiedAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ expect(plugin.starts).to.deep.equal(['2020-01-02T03:04:05.006Z']) ++ expect(plugin.stops).to.equal(0) ++ ++ await watcher.onModified(deployment('treatment:v2', 3)) ++ ++ const replicasClearIndex = expectPatch(kubeClient.patches, isExperimentAnnotationClearPatch, 'cleared running experiment after replica change', 1) ++ const replicasRestartIndex = expectPatch(kubeClient.patches, isExperimentAnnotationSetPatch, 'restarted experiment after replica change', replicasClearIndex + 1) ++ const replicasRestartAnnotation = JSON.parse(experimentAnnotationValue(kubeClient.patches[replicasRestartIndex])) ++ expect(replicasRestartAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(replicasRestartAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ expect(plugin.starts).to.deep.equal(['2020-01-02T03:04:05.006Z', '2020-01-02T03:04:05.006Z']) ++ expect(plugin.stops).to.equal(1) ++ ++ await watcher.onModified(deployment('treatment:v5', 3)) ++ ++ const podSpecClearIndex = expectPatch(kubeClient.patches, isExperimentAnnotationClearPatch, 'cleared running experiment after pod spec change', replicasRestartIndex + 1) ++ const podSpecRestartIndex = expectPatch(kubeClient.patches, isExperimentAnnotationSetPatch, 'restarted experiment after pod spec change', podSpecClearIndex + 1) ++ const podSpecRestartAnnotation = JSON.parse(experimentAnnotationValue(kubeClient.patches[podSpecRestartIndex])) ++ expect(podSpecRestartAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(podSpecRestartAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ expect(plugin.starts).to.deep.equal([ ++ '2020-01-02T03:04:05.006Z', ++ '2020-01-02T03:04:05.006Z', ++ '2020-01-02T03:04:05.006Z' ++ ]) ++ expect(plugin.stops).to.equal(2) ++ ++ await watcher.onDeleted() ++ }) ++ ++ it('onDeleted forgets the last deployment, stops the active poller, notifies plugins, and clears the experiment annotation', async () => { ++ ++ ++ clock = sinon.useFakeTimers(new Date('2020-01-02T03:04:05.006Z').getTime()) ++ const kubeClient = createKubeClient() ++ const plugin = createPlugin([]) ++ const watcher = createWatcher({ kubeClient, plugins: [plugin] }) ++ ++ await watcher.onAdded(deployment('treatment:v2', 2)) ++ await watcher.onDeleted() ++ clock.tick(5000) ++ await flushPromises() ++ ++ ++ expect(kubeClient.patches[0]).to.satisfy(isExperimentAnnotationSetPatch) ++ const deleteStartAnnotation = JSON.parse(experimentAnnotationValue(kubeClient.patches[0])) ++ expect(deleteStartAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(deleteStartAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ expectPatch(kubeClient.patches, isExperimentAnnotationClearPatch, 'cleared experiment annotation on delete', 1) ++ expect(plugin.starts).to.deep.equal(['2020-01-02T03:04:05.006Z']) ++ expect(plugin.stops).to.equal(1) ++ expect(plugin.polls).to.deep.equal([]) ++ }) ++ ++ it('throws the specific public TypeError when getStream is called before configuring a kube watch client', () => { ++ ++ ++ const watcher = createWatcher({ kubeClient: null }) ++ ++ expect(() => watcher.getStream()).to.throw(TypeError) ++ }) ++ ++ it('allows cleanup to be called twice without raising', async () => { ++ ++ ++ clock = sinon.useFakeTimers(new Date('2020-01-02T03:04:05.006Z').getTime()) ++ const kubeClient = createKubeClient() ++ const plugin = createPlugin([]) ++ const watcher = createWatcher({ kubeClient, plugins: [plugin] }) ++ ++ await watcher.onAdded(deployment('treatment:v2', 2)) ++ await watcher.onDeleted() ++ await watcher.onDeleted() ++ ++ ++ expect(kubeClient.patches[0]).to.satisfy(isExperimentAnnotationSetPatch) ++ const cleanupStartAnnotation = JSON.parse(experimentAnnotationValue(kubeClient.patches[0])) ++ expect(cleanupStartAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(cleanupStartAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ expect(kubeClient.patches.filter(isExperimentAnnotationClearPatch)).to.have.lengthOf(1) ++ expect(plugin.stops).to.equal(1) ++ }) ++ ++ it('keeps experiment state independent across watcher instances', async () => { ++ ++ ++ clock = sinon.useFakeTimers(new Date('2020-01-02T03:04:05.006Z').getTime()) ++ const kubeClientA = createKubeClient() ++ const kubeClientB = createKubeClient() ++ const pluginA = createPlugin([]) ++ const pluginB = createPlugin([]) ++ const watcherA = createWatcher({ kubeClient: kubeClientA, plugins: [pluginA], gatedDeploymentId: 'gd-a' }) ++ const watcherB = createWatcher({ kubeClient: kubeClientB, plugins: [pluginB], gatedDeploymentId: 'gd-b' }) ++ ++ await watcherA.onAdded(deployment('treatment:v2', 2)) ++ ++ ++ expect(kubeClientA.patches).to.have.lengthOf(1) ++ expect(kubeClientA.patches[0]).to.satisfy(isExperimentAnnotationSetPatch) ++ const watcherAAnnotation = JSON.parse(experimentAnnotationValue(kubeClientA.patches[0])) ++ expect(watcherAAnnotation.startTime).to.equal('2020-01-02T03:04:05.006Z') ++ expect(watcherAAnnotation.podSpecHash).to.be.a('string').and.not.equal('') ++ expect(kubeClientB.patches).to.deep.equal([]) ++ expect(pluginA.starts).to.deep.equal(['2020-01-02T03:04:05.006Z']) ++ expect(pluginB.starts).to.deep.equal([]) ++ ++ await watcherB.onAdded(deployment('control:v1', 2)) ++ ++ expectPatch(kubeClientB.patches, isTreatmentScaleZeroPatch, 'watcher B scaled treatment to zero') ++ expectPatch(kubeClientB.patches, isDeploymentStatusPatch('noHarm'), 'watcher B set noHarm') ++ expectNoPatch(kubeClientB.patches, isExperimentAnnotationSetPatch, 'watcher B did not start an experiment') ++ expect(pluginB.starts).to.deep.equal([]) ++ ++ await watcherA.onDeleted() ++ await watcherB.onDeleted() ++ }) ++ ++ it('does not accumulate active poller timers across construct-use-cleanup cycles', async () => { ++ ++ ++ if (typeof process.getActiveResourcesInfo !== 'function') { ++ throw new TypeError('process.getActiveResourcesInfo is required for this leak floor') ++ } ++ const before = timeoutResourceCount() ++ ++ for (let i = 0; i < 100; i += 1) { ++ const watcher = createWatcher({ ++ kubeClient: createKubeClient(), ++ plugins: [createPlugin([])], ++ pollerIntervalMilliseconds: 60000, ++ gatedDeploymentId: `gd-cycle-${i}` ++ }) ++ await watcher.onAdded(deployment('treatment:v2', 2)) ++ await watcher.onDeleted() ++ } ++ ++ const after = timeoutResourceCount() ++ expect(after - before).to.be.at.most(2) ++ }) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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 NO_UPDATE_NOTIFIER=1 ++export npm_config_offline=true ++export npm_config_audit=false ++export npm_config_fund=false ++ ++if [ ! -x ./node_modules/.bin/mocha ]; then ++ echo "Missing local ./node_modules/.bin/mocha; dependencies must be preinstalled for offline test execution." >&2 ++ exit 1 ++fi ++ ++exec ./node_modules/.bin/mocha /workspace/repo/usercase-test-coderl/deployment-watcher.test.js --exit diff --git a/tasks/format-code-task-001321/tests/test.sh b/tasks/format-code-task-001321/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a9b517f97d5d66fd213f2efdb32378aefaa1b9e9 --- /dev/null +++ b/tasks/format-code-task-001321/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/deployment-watcher.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-001321/tests/test_command.sh b/tasks/format-code-task-001321/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001321/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-001326/environment/Dockerfile b/tasks/format-code-task-001326/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cf62cf5f8f08c92b0422de55099a9020cc30deab --- /dev/null +++ b/tasks/format-code-task-001326/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ffabb11849f4d53e34756f56ed3695a89eff2b64fb0cd9a156a49f807a3ff829 diff --git a/tasks/format-code-task-001326/environment/setup/files/blocklist b/tasks/format-code-task-001326/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001326/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001326/environment/setup/setup.sh b/tasks/format-code-task-001326/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001326/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001326/tests/test.patch b/tasks/format-code-task-001326/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..678bd148aeb69d4841808951aeb52ff52b902879 --- /dev/null +++ b/tasks/format-code-task-001326/tests/test.patch @@ -0,0 +1,32 @@ +diff --git a/parser/metadecoders/decoder_test.go b/parser/metadecoders/decoder_test.go +index ff6f8c226a0..48def7d1244 100644 +--- a/parser/metadecoders/decoder_test.go ++++ b/parser/metadecoders/decoder_test.go +@@ -125,6 +125,7 @@ func TestUnmarshalToInterface(t *testing.T) { + {[]byte(``), JSON, map[string]any{}}, + {[]byte(nil), JSON, map[string]any{}}, + {[]byte(`#+a: b`), ORG, expect}, ++ {[]byte("#+a: foo bar\n#+a: baz"), ORG, map[string]any{"a": []string{string("foo bar"), string("baz")}}}, + {[]byte(`#+DATE: <2020-06-26 Fri>`), ORG, map[string]any{"date": "2020-06-26"}}, + {[]byte(`#+LASTMOD: <2020-06-26 Fri>`), ORG, map[string]any{"lastmod": "2020-06-26"}}, + {[]byte(`#+PUBLISHDATE: <2020-06-26 Fri>`), ORG, map[string]any{"publishdate": "2020-06-26"}}, +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+3RQQ6CMBCFYdaeohcQKFo4jim0UROhpi2cX2QjMVE2GGP8v81MZpp0kpfW/fli ++DrYbsuRT8lGl1FRHz3XqpSpkkZe7qhjnUqqqSoT62EUzfYjaC5F45+K7d0v7H5U+8o82xEPj2lZ3 ++Jg2n9f5YzF+Vj/zvc7kvZZGIfL0TXvvz/BsjpuBrazZHJ+6tSLOr9sH6rLVRG9s4Y33IxHbYfPta ++AAAAAAAAAAAAAAAAAHM3lgKEZAAoAAA= +diff --git 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-001326/tests/test.sh b/tasks/format-code-task-001326/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ef4d90efde5e69815c9d0d0e96cad011cc50487 --- /dev/null +++ b/tasks/format-code-task-001326/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' +parser/metadecoders/decoder_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-001326/tests/test_command.sh b/tasks/format-code-task-001326/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001326/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001342/environment/Dockerfile b/tasks/format-code-task-001342/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..73b2447b86b7f70ba5c21120f7d4bab2e44e3476 --- /dev/null +++ b/tasks/format-code-task-001342/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3a8d1e4ffc7e2447925484e588a236c8557434eca4904bb8f49bfe79ad75e539 diff --git a/tasks/format-code-task-001342/environment/setup/files/blocklist b/tasks/format-code-task-001342/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001342/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001342/environment/setup/setup.sh b/tasks/format-code-task-001342/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001342/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001342/tests/test.patch b/tasks/format-code-task-001342/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..64de20ea11a3a622c71a2f11dcc59950d3c64d85 --- /dev/null +++ b/tasks/format-code-task-001342/tests/test.patch @@ -0,0 +1,231 @@ +diff --git a/tests/optim_test.py b/tests/optim_test.py +index bc9f548a..380e030e 100644 +--- a/tests/optim_test.py ++++ b/tests/optim_test.py +@@ -200,10 +200,10 @@ class MultiOptimizerTest(absltest.TestCase): + params = {'a': {'x': 0., 'y': 0.}, 'b': {'y': 0, 'z': 0.}} + opt_a = optim.GradientDescent(learning_rate=1.) + opt_b = optim.GradientDescent(learning_rate=10.) +- t_a = optim.ModelParamTraversal( ++ t_a = traverse_util.ModelParamTraversal( + lambda path, _: path.endswith('/x') or path.endswith('/y') + ) +- t_b = optim.ModelParamTraversal( ++ t_b = traverse_util.ModelParamTraversal( + lambda path, value: value.dtype == jnp.int32 or path.endswith('/z') + ) + optimizer_def = optim.MultiOptimizer((t_a, opt_a), (t_b, opt_b)) +@@ -212,6 +212,34 @@ class MultiOptimizerTest(absltest.TestCase): + jax.jit(optimizer_def.init_state)(params) + + ++class ModelParamTraversalCompatTest(absltest.TestCase): ++ ++ def test_optim_entry_still_constructs_and_behaves(self): ++ params = { ++ 'x': {'scale': 1, 'offset': 2}, ++ 'y': {'scale': 3, 'offset': 4}, ++ } ++ expected = { ++ 'x': {'scale': 1, 'offset': 12}, ++ 'y': {'scale': 3, 'offset': 14}, ++ } ++ traversal = optim.ModelParamTraversal(lambda path, _: path.endswith('/offset')) ++ ++ self.assertEqual(set(traversal.iterate(params)), {2, 4}) ++ self.assertEqual(traversal.update(lambda x: x + 10, params), expected) ++ ++ frozen = FrozenDict(params) ++ self.assertEqual(set(traversal.iterate(frozen)), {2, 4}) ++ self.assertEqual(traversal.update(lambda x: x + 10, frozen), ++ FrozenDict(expected)) ++ ++ model = nn.Model(None, params) ++ expected_model = nn.Model(None, expected) ++ self.assertEqual(set(traversal.iterate(model)), {2, 4}) ++ self.assertEqual(traversal.update(lambda x: x + 10, model), ++ expected_model) ++ ++ + class GradientDescentTest(absltest.TestCase): + + def test_init_state(self): +diff --git a/tests/traverse_util_test.py b/tests/traverse_util_test.py +index f7cab388..79825c60 100644 +--- a/tests/traverse_util_test.py ++++ b/tests/traverse_util_test.py +@@ -16,9 +16,12 @@ + + + import collections ++from pathlib import Path + + from absl.testing import absltest + ++from flax.core import FrozenDict ++from flax.nn import Model + from flax import traverse_util + + import jax +@@ -187,5 +190,101 @@ class TraversalTest(absltest.TestCase): + xs_restore = traverse_util.unflatten_dict(flat_xs) + self.assertEqual(xs, xs_restore) + ++ ++class ModelParamTraversalTest(absltest.TestCase): ++ ++ def test_iterate_and_update_supported_param_trees(self): ++ cases = [ ++ ( ++ { ++ 'x': { ++ 'scale': 1, ++ 'offset': 2, ++ 'y': { ++ 'scale': 3, ++ 'offset': 4, ++ }, ++ 'z': {}, ++ }, ++ }, ++ lambda path, _: 'scale' in path, ++ {1, 3}, ++ { ++ 'x': { ++ 'scale': 2, ++ 'offset': 2, ++ 'y': { ++ 'scale': 6, ++ 'offset': 4, ++ }, ++ 'z': {}, ++ }, ++ }, ++ {'/x/scale', '/x/offset', '/x/y/scale', '/x/y/offset'}, ++ ), ++ ( ++ {'root': {'a': 5, 'b': 7, 'child': {'a': 11, 'b': 13}}}, ++ lambda path, value: path.endswith('/b') or value == 11, ++ {7, 11, 13}, ++ {'root': {'a': 5, 'b': 14, 'child': {'a': 22, 'b': 26}}}, ++ {'/root/a', '/root/b', '/root/child/a', '/root/child/b'}, ++ ), ++ ] ++ ++ for params, filter_fn, expected_values, expected_params, expected_paths in cases: ++ inputs = [params, FrozenDict(params), Model(None, params)] ++ expected_inputs = [ ++ expected_params, ++ FrozenDict(expected_params), ++ Model(None, expected_params), ++ ] ++ for inp, expected in zip(inputs, expected_inputs): ++ seen_paths = [] ++ ++ def tracking_filter(path, value): ++ seen_paths.append(path) ++ return filter_fn(path, value) ++ ++ traversal = traverse_util.ModelParamTraversal(tracking_filter) ++ self.assertEqual(set(traversal.iterate(inp)), expected_values) ++ self.assertEqual(set(seen_paths), expected_paths) ++ ++ seen_paths = [] ++ traversal = traverse_util.ModelParamTraversal(tracking_filter) ++ self.assertEqual(traversal.update(lambda x: x + x, inp), expected) ++ self.assertEqual(set(seen_paths), expected_paths) ++ ++ def test_iterate_order_and_larger_tree_are_preserved(self): ++ params = { ++ 'z': {'scale': 1}, ++ 'a': {'scale': 2}, ++ 'b': {'scale': 3}, ++ 'c': {'scale': 4}, ++ 'd': {'scale': 5}, ++ } ++ expected = { ++ 'z': {'scale': 10}, ++ 'a': {'scale': 20}, ++ 'b': {'scale': 30}, ++ 'c': {'scale': 40}, ++ 'd': {'scale': 50}, ++ } ++ traversal = traverse_util.ModelParamTraversal( ++ lambda path, _: path.endswith('/scale')) ++ ++ self.assertEqual(list(traversal.iterate(params)), [2, 3, 4, 5, 1]) ++ self.assertEqual(traversal.update(lambda x: x * 10, params), expected) ++ ++ ++class DocsApiSurfaceTest(absltest.TestCase): ++ ++ def test_model_param_traversal_documented_under_traverse_util_not_optim(self): ++ docs_dir = Path(__file__).resolve().parents[1] / 'docs' ++ traverse_docs = (docs_dir / 'flax.traverse_util.rst').read_text() ++ optim_docs = (docs_dir / 'flax.optim.rst').read_text() ++ self.assertIn('ModelParamTraversal', traverse_docs) ++ self.assertNotIn('ModelParamTraversal', optim_docs) ++ ++ + if __name__ == '__main__': + absltest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,55 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++ ++ ++ ++dev-switch python3 3.11 ++ ++ ++python3 -m venv /testbed/.venv ++set +u ++source /testbed/.venv/bin/activate ++set -u ++if [ ! -f /testbed/.fixturea_deps_ready ]; then ++ pip install --quiet "numpy<2" "jax==0.4.18" "jaxlib==0.4.18" "optax==0.1.7" "msgpack" "ml-collections" "absl-py" "pytest" "chex==0.1.86" ++ pip install --quiet --no-deps -e /testbed ++ touch /testbed/.fixturea_deps_ready ++fi ++ ++ ++mkdir -p /tmp/fixturea_pycompat ++cat > /tmp/fixturea_pycompat/sitecustomize.py <<'PY' ++try: ++ import jax ++ if not hasattr(jax, "tree_multimap"): ++ jax.tree_multimap = jax.tree_util.tree_map ++except ImportError: ++ pass ++PY ++ ++PYTHONPATH_VALUE="/tmp/fixturea_pycompat:${PYTHONPATH:-}" ++PYTEST_COMMON=(-v -o "filterwarnings=") ++ ++case "${1:-}" in ++ base) ++ PYTHONPATH="${PYTHONPATH_VALUE}" python3 -m pytest \ ++ tests/traverse_util_test.py tests/optim_test.py \ ++ -k "not ModelParamTraversalCompatTest and not DocsApiSurfaceTest and not test_iterate_and_update_supported_param_trees and not test_iterate_order_and_larger_tree_are_preserved and not test_multi_optimizer_multiple_matches" \ ++ "${PYTEST_COMMON[@]}" ++ ;; ++ new) ++ PYTHONPATH="${PYTHONPATH_VALUE}" python3 -m pytest \ ++ tests/traverse_util_test.py::ModelParamTraversalTest::test_iterate_and_update_supported_param_trees \ ++ tests/traverse_util_test.py::ModelParamTraversalTest::test_iterate_order_and_larger_tree_are_preserved \ ++ tests/traverse_util_test.py::DocsApiSurfaceTest::test_model_param_traversal_documented_under_traverse_util_not_optim \ ++ tests/optim_test.py::ModelParamTraversalCompatTest::test_optim_entry_still_constructs_and_behaves \ ++ tests/optim_test.py::MultiOptimizerTest::test_multi_optimizer_multiple_matches \ ++ "${PYTEST_COMMON[@]}" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001342/tests/test.sh b/tasks/format-code-task-001342/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9e8520dd64e9c2c98de66ee44bc58bead27dac88 --- /dev/null +++ b/tasks/format-code-task-001342/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/optim_test.py +tests/traverse_util_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001342/tests/test_command.sh b/tasks/format-code-task-001342/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001342/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-001345/environment/Dockerfile b/tasks/format-code-task-001345/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..598947604e00ff619bc4210955abe02f14c5e5c5 --- /dev/null +++ b/tasks/format-code-task-001345/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f7b73c2525f4651f7af090b678a7605def37bf4b5c1755226cbbd251d0a50847 diff --git a/tasks/format-code-task-001345/environment/setup/files/blocklist b/tasks/format-code-task-001345/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001345/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001345/environment/setup/setup.sh b/tasks/format-code-task-001345/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001345/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001345/tests/test.patch b/tasks/format-code-task-001345/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1123170fd06cf4fbc3bb5f8f8e0d9d8064e8d65d --- /dev/null +++ b/tasks/format-code-task-001345/tests/test.patch @@ -0,0 +1,376 @@ +diff --git a/usercase-test-coderl/test_get_action.py b/usercase-test-coderl/test_get_action.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_get_action.py +@@ -0,0 +1,345 @@ ++ ++ ++ ++ ++ ++ ++import contextlib ++import os ++import shutil ++from unittest import mock ++ ++from absl import flags ++import pytest ++ ++from glazier.lib import beyondcorp ++from glazier.lib import download ++from glazier.lib import file_util ++from glazier.lib.actions import ActionError ++from glazier.lib.actions import Get ++from glazier.lib.actions import ValidationError ++from glazier.lib.actions import pull ++ ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++ ++class BuildInfo: ++ ++ def ReleasePath(self): ++ return "C:/fixture_conf" ++ ++ def BinaryPath(self): ++ return "D:/fixture_bin/" ++ ++ def Branch(self): ++ return "stable" ++ ++ def ActiveConfigPath(self): ++ return ["site", "model"] ++ ++ ++def setup_module(module): ++ del module ++ with contextlib.suppress(Exception): ++ flags.FLAGS(["fixture-get-action-test"]) ++ shutil.rmtree("C:/fixture_conf", ignore_errors=True) ++ shutil.rmtree("D:/fixture_bin", ignore_errors=True) ++ os.makedirs(FIXTURES, exist_ok=True) ++ _write_fixture_tree() ++ ++ ++@pytest.fixture(autouse=True) ++def no_beyondcorp_probe(): ++ with mock.patch.object( ++ beyondcorp.BeyondCorp, "CheckBeyondCorp", autospec=True, ++ return_value=False): ++ yield ++ ++ ++def _write(path, content): ++ os.makedirs(os.path.dirname(path), exist_ok=True) ++ with open(path, "w", encoding="utf-8") as f: ++ f.write(content) ++ ++ ++def _write_fixture_tree(): ++ _write("C:/fixture_conf/site/model/pkg/tool.ps1", "from config token\n") ++ _write("C:/fixture_conf/site/model/stable/manifest.yaml", ++ "from branch token\n") ++ _write("C:/fixture_conf/site/model/relative/name.bin", ++ "from legacy relative\n") ++ _write("C:/fixture_conf/site/model/#literal.txt", ++ "from escaped hash\n") ++ _write("C:/fixture_conf/site/model/@literal.bin", ++ "from escaped at\n") ++ _write("C:/fixture_conf/site/model/%literal.branch", ++ "from escaped percent\n") ++ _write("D:/fixture_bin/drivers/nic.inf", "from binary token\n") ++ _write("C:/fixture_conf/site/model/hash/payload.txt", ++ "sha verified payload\n") ++ _write("C:/fixture_conf/site/model/nohash/payload.txt", ++ "sha skipped payload\n") ++ ++ ++def _read(path): ++ with open(path, encoding="utf-8") as f: ++ return f.read() ++ ++ ++def test_public_get_and_pull_alias_validate_nested_list_shape(tmp_path): ++ ++ ++ ++ ++ assert callable(Get) ++ assert callable(pull) ++ ++ Get([["#pkg/tool.ps1", str(tmp_path / "valid" / "tool.ps1")]], ++ BuildInfo()).Validate() ++ Get([[ ++ "#pkg/tool.ps1", ++ str(tmp_path / "valid-with-sha" / "tool.ps1"), ++ "e49c81e2d2f84e259d40e2fb8192f3bcd198b355184845d76d8f58807d0d78ee", ++ ]], BuildInfo()).Validate() ++ pull([["#pkg/tool.ps1", str(tmp_path / "valid-pull" / "tool.ps1")]], ++ BuildInfo()).Validate() ++ ++ invalid_cases = [ ++ "String", ++ [[]], ++ [["only-one"]], ++ [["a", "b", "c", "d"]], ++ [[1, "b"]], ++ [["a", 2]], ++ [["a", "b", 3]], ++ ] ++ for bad_args in invalid_cases: ++ ++ with pytest.raises(ValidationError) as exc_info: ++ Get(bad_args, BuildInfo()).Validate() ++ assert exc_info.value is not None ++ ++ ++def test_run_processes_entries_in_order_and_materializes_resolved_sources(tmp_path): ++ ++ ++ ++ destination_root = tmp_path / "ordered" ++ calls = [] ++ real_download_file = download.Download.DownloadFile ++ ++ def record_then_copy(self, url, save_location, show_progress=False): ++ calls.append((url, save_location, show_progress, ++ os.path.isdir(os.path.dirname(save_location)))) ++ return real_download_file( ++ self, url, save_location, show_progress=show_progress) ++ ++ with mock.patch.object( ++ download.Download, "DownloadFile", autospec=True, ++ side_effect=record_then_copy): ++ action = Get([ ++ ["#pkg/tool.ps1", str(destination_root / "config" / "tool.ps1")], ++ ["@drivers/nic.inf", str(destination_root / "bin" / "nic.inf")], ++ ["%/manifest.yaml", str(destination_root / "branch" / "manifest.yaml")], ++ ["relative/name.bin", str(destination_root / "relative" / "name.bin")], ++ ], BuildInfo()) ++ action.Validate() ++ action.Run() ++ ++ assert calls == [ ++ ("C:/fixture_conf/site/model/pkg/tool.ps1", ++ str(destination_root / "config" / "tool.ps1"), True, True), ++ ("D:/fixture_bin/drivers/nic.inf", ++ str(destination_root / "bin" / "nic.inf"), True, True), ++ ("C:/fixture_conf/site/model/stable/manifest.yaml", ++ str(destination_root / "branch" / "manifest.yaml"), True, True), ++ ("C:/fixture_conf/site/model/relative/name.bin", ++ str(destination_root / "relative" / "name.bin"), True, True), ++ ] ++ assert _read(destination_root / "config" / "tool.ps1") == ( ++ "from config token\n") ++ assert _read(destination_root / "bin" / "nic.inf") == "from binary token\n" ++ assert _read(destination_root / "branch" / "manifest.yaml") == ( ++ "from branch token\n") ++ assert _read(destination_root / "relative" / "name.bin") == ( ++ "from legacy relative\n") ++ ++ ++def test_run_keeps_escaped_tokens_literal_then_uses_legacy_relative_path( ++ tmp_path): ++ ++ ++ ++ destination_root = tmp_path / "escaped" ++ action = Get([ ++ [r"\#literal.txt", str(destination_root / "hash.txt")], ++ [r"\@literal.bin", str(destination_root / "at.txt")], ++ [r"\%literal.branch", str(destination_root / "percent.txt")], ++ ], BuildInfo()) ++ action.Validate() ++ action.Run() ++ ++ assert _read(destination_root / "hash.txt") == "from escaped hash\n" ++ assert _read(destination_root / "at.txt") == "from escaped at\n" ++ assert _read(destination_root / "percent.txt") == "from escaped percent\n" ++ ++ ++def test_run_verifies_non_empty_sha_and_rejects_mismatch(tmp_path): ++ ++ ++ ++ correct_sha = ( ++ "fa3cf5a5ffd7d0b80d9b66829651b8e87b0640c85a48ba322795e556b31d37ba") ++ ++ ok_dest = tmp_path / "hash-ok" / "payload.txt" ++ Get([["hash/payload.txt", str(ok_dest), correct_sha]], BuildInfo()).Run() ++ assert _read(ok_dest) == "sha verified payload\n" ++ ++ bad_dest = tmp_path / "hash-bad" / "payload.txt" ++ with pytest.raises(ActionError) as exc_info: ++ Get([[ ++ "hash/payload.txt", ++ str(bad_dest), ++ "0000000000000000000000000000000000000000000000000000000000000000", ++ ]], BuildInfo()).Run() ++ ++ assert exc_info.value is not None ++ assert _read(bad_dest) == "sha verified payload\n" ++ ++ ++def test_run_skips_sha_when_argument_absent_or_empty_string(tmp_path): ++ ++ ++ ++ destination_root = tmp_path / "nohash" ++ with mock.patch.object( ++ download.Download, "VerifyShaHash", autospec=True) as verify_sha: ++ Get([ ++ ["nohash/payload.txt", str(destination_root / "absent.txt")], ++ ["nohash/payload.txt", str(destination_root / "empty.txt"), ""], ++ ], BuildInfo()).Run() ++ ++ assert _read(destination_root / "absent.txt") == "sha skipped payload\n" ++ assert _read(destination_root / "empty.txt") == "sha skipped payload\n" ++ assert verify_sha.call_args_list == [] ++ ++ ++def test_run_wraps_destination_directory_creation_failure(tmp_path): ++ ++ ++ ++ destination = str(tmp_path / "blocked" / "child" / "out.txt") ++ ++ with mock.patch.object( ++ file_util, ++ "CreateDirectories", ++ autospec=True, ++ side_effect=file_util.DirectoryCreationError( ++ str(tmp_path / "blocked" / "child"))): ++ with pytest.raises(ActionError) as exc_info: ++ Get([["#pkg/tool.ps1", destination]], BuildInfo()).Run() ++ ++ ++ assert destination in str(exc_info.value) ++ ++ ++def test_run_wraps_transfer_failure_and_prints_debug_info(tmp_path): ++ ++ ++ ++ debug_calls = [] ++ ++ class FailingDownloader: ++ ++ def DownloadFile(self, url, save_location, show_progress=False): ++ del save_location, show_progress ++ raise download.DownloadFailedError(url, 503) ++ ++ def PrintDebugInfo(self): ++ debug_calls.append("printed") ++ ++ with mock.patch.object(download, "Download", FailingDownloader): ++ with pytest.raises(ActionError) as http_exc: ++ Get([["https://cdn.example/file.dat", ++ str(tmp_path / "http" / "file.dat")]], BuildInfo()).Run() ++ ++ ++ assert "printed" in debug_calls ++ assert "https://cdn.example/file.dat" in str(http_exc.value) ++ ++ debug_calls.clear() ++ with mock.patch.object(download, "Download", FailingDownloader): ++ with pytest.raises(ActionError) as relative_exc: ++ Get([["relative/name.bin", ++ str(tmp_path / "relative" / "file.dat")]], BuildInfo()).Run() ++ ++ ++ assert "printed" in debug_calls ++ assert "C:/fixture_conf/site/model/relative/name.bin" in str(relative_exc.value) ++ ++ ++def test_validate_is_out_of_order_guard_before_run(tmp_path): ++ ++ ++ ++ with pytest.raises(ValidationError) as exc_info: ++ Get([["#pkg/tool.ps1"]], BuildInfo()).Validate() ++ ++ assert exc_info.value is not None ++ ++ destination = tmp_path / "valid-after-guard" / "tool.ps1" ++ action = Get([["#pkg/tool.ps1", str(destination)]], BuildInfo()) ++ action.Validate() ++ action.Run() ++ assert _read(destination) == "from config token\n" ++ ++ ++def test_repeated_validate_and_run_are_idempotent_for_same_destination(tmp_path): ++ ++ ++ ++ destination = tmp_path / "repeat" / "tool.ps1" ++ action = Get([["#pkg/tool.ps1", str(destination)]], BuildInfo()) ++ action.Validate() ++ action.Validate() ++ action.Run() ++ assert _read(destination) == "from config token\n" ++ action.Run() ++ assert _read(destination) == "from config token\n" ++ ++ ++def test_two_action_instances_keep_independent_args_and_destinations(tmp_path): ++ ++ ++ ++ first_dest = tmp_path / "first" / "tool.ps1" ++ second_dest = tmp_path / "second" / "nic.inf" ++ first = Get([["#pkg/tool.ps1", str(first_dest)]], BuildInfo()) ++ second = Get([["@drivers/nic.inf", str(second_dest)]], BuildInfo()) ++ ++ first.Validate() ++ first.Run() ++ assert _read(first_dest) == "from config token\n" ++ assert second_dest.exists() is False ++ ++ second.Validate() ++ second.Run() ++ assert _read(first_dest) == "from config token\n" ++ assert _read(second_dest) == "from binary token\n" ++ ++ ++def test_repeated_construct_use_cleanup_cycles_stay_bounded(tmp_path): ++ ++ ++ ++ ++ for index in range(3): ++ cycle_dir = tmp_path / f"cycle-{index:03d}" ++ destination = cycle_dir / "tool.ps1" ++ action = Get([["#pkg/tool.ps1", str(destination)]], BuildInfo()) ++ action.Validate() ++ action.Run() ++ assert _read(destination) == "from config token\n" ++ shutil.rmtree(cycle_dir) ++ del action +diff --git 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 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++ ++exec /opt/stage4a-get-action-venv/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_get_action.py -v diff --git a/tasks/format-code-task-001345/tests/test.sh b/tasks/format-code-task-001345/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..604e0fab6d55e66385c919e85b7b2d9797e05995 --- /dev/null +++ b/tasks/format-code-task-001345/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_action.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-001345/tests/test_command.sh b/tasks/format-code-task-001345/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001345/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-001352/environment/Dockerfile b/tasks/format-code-task-001352/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5e531f4cfed4c6c680ff7f460d752c2072d74ae0 --- /dev/null +++ b/tasks/format-code-task-001352/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0169e7224cc4e2643c8d92a134ab484dd84cbb004e7cfb57edc4abf30ff094e9 diff --git a/tasks/format-code-task-001352/environment/setup/files/blocklist b/tasks/format-code-task-001352/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001352/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001352/environment/setup/setup.sh b/tasks/format-code-task-001352/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001352/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001352/tests/test.patch b/tasks/format-code-task-001352/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6dfb68d193509bfebeb5885d83b7a37d8423296a --- /dev/null +++ b/tasks/format-code-task-001352/tests/test.patch @@ -0,0 +1,805 @@ +diff --git a/pkg/kf/buildpacks/builder_creator_test.go b/pkg/kf/buildpacks/builder_creator_test.go +deleted file mode 100644 +index b1f53a2aa..000000000 +--- a/pkg/kf/buildpacks/builder_creator_test.go ++++ /dev/null +@@ -1,86 +0,0 @@ +-// Copyright 2019 Google LLC +-// +-// 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 +-// +-// https://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 buildpacks_test +- +-import ( +- "errors" +- "testing" +- +- "github.com/GoogleCloudPlatform/kf/pkg/kf/buildpacks" +- "github.com/GoogleCloudPlatform/kf/pkg/kf/testutil" +- "github.com/buildpack/pack" +-) +- +-func TestBuilderCreator(t *testing.T) { +- t.Parallel() +- +- for tn, tc := range map[string]struct { +- Dir string +- ContainerRegistry string +- ExpectedErr error +- Creator buildpacks.BuilderFactoryCreate +- }{ +- "empty dir": { +- Dir: "", +- ContainerRegistry: "some-reg.io", +- ExpectedErr: errors.New("dir must not be empty"), +- }, +- "empty container registry": { +- Dir: "some-path/builder.toml", +- ContainerRegistry: "", +- ExpectedErr: errors.New("containerRegistry must not be empty"), +- }, +- "returns an error if creating fails": { +- Dir: "some-path/builder.toml", +- ContainerRegistry: "some-registry.io", +- Creator: func(f pack.CreateBuilderFlags) error { return errors.New("some-error") }, +- ExpectedErr: errors.New("some-error"), +- }, +- "sets the flags up": { +- Dir: "some-path/builder.toml", +- ContainerRegistry: "some-registry.io", +- Creator: func(f pack.CreateBuilderFlags) error { +- testutil.AssertEqual(t, "publish", true, f.Publish) +- testutil.AssertEqual(t, "BuilderTomlPath", "some-path/builder.toml", f.BuilderTomlPath) +- testutil.AssertEqual(t, "RepoName", "some-path/builder.toml", f.BuilderTomlPath) +- testutil.AssertRegexp(t, "RepoName", `some-registry.io/buildpack-builder:[0-9]+`, f.RepoName) +- return nil +- }, +- }, +- "appends builder.toml if necessary": { +- Dir: "some-path", +- ContainerRegistry: "some-registry.io", +- Creator: func(f pack.CreateBuilderFlags) error { +- testutil.AssertEqual(t, "BuilderTomlPath", "some-path/builder.toml", f.BuilderTomlPath) +- return nil +- }, +- }, +- } { +- t.Run(tn, func(t *testing.T) { +- if tc.Creator == nil { +- tc.Creator = func(f pack.CreateBuilderFlags) error { return nil } +- } +- +- b := buildpacks.NewBuilderCreator(tc.Creator) +- image, gotErr := b.Create(tc.Dir, tc.ContainerRegistry) +- if gotErr != nil || tc.ExpectedErr != nil { +- testutil.AssertErrorsEqual(t, tc.ExpectedErr, gotErr) +- return +- } +- +- testutil.AssertRegexp(t, "image name", tc.ContainerRegistry+`/buildpack-builder:[0-9]+`, image) +- }) +- } +-} +diff --git a/pkg/kf/buildpacks/buildpack_lister_test.go b/pkg/kf/buildpacks/buildpack_lister_test.go +deleted file mode 100644 +index a81f70286..000000000 +--- a/pkg/kf/buildpacks/buildpack_lister_test.go ++++ /dev/null +@@ -1,232 +0,0 @@ +-// Copyright 2019 Google LLC +-// +-// 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 +-// +-// https://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 buildpacks_test +- +-import ( +- "archive/tar" +- "bytes" +- "errors" +- io "io" +- "io/ioutil" +- "testing" +- +- "github.com/GoogleCloudPlatform/kf/pkg/kf/buildpacks" +- "github.com/GoogleCloudPlatform/kf/pkg/kf/testutil" +- "github.com/golang/mock/gomock" +- "github.com/google/go-containerregistry/pkg/name" +- gcrv1 "github.com/google/go-containerregistry/pkg/v1" +- "github.com/google/go-containerregistry/pkg/v1/remote" +- build "github.com/knative/build/pkg/apis/build/v1alpha1" +- "github.com/knative/build/pkg/client/clientset/versioned/typed/build/v1alpha1/fake" +- "k8s.io/apimachinery/pkg/runtime" +- ktesting "k8s.io/client-go/testing" +-) +- +-//go:generate mockgen --package=buildpacks_test --copyright_file ../internal/tools/option-builder/LICENSE_HEADER --destination=fake_image_test.go --mock_names=Image=FakeImage,Layer=FakeLayer github.com/google/go-containerregistry/pkg/v1 Image,Layer +- +-func TestBuildpackLister(t *testing.T) { +- t.Parallel() +- +- for tn, tc := range map[string]struct { +- ReactorListErr error +- ExpectedErr error +- EmptyBuildTemplateList bool +- HandleListAction func(t *testing.T, action ktesting.Action) +- RemoteImageFetcher func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) +- HandleOutput func(t *testing.T, buildpacks []string) +- }{ +- "list only buildpack build template": { +- HandleListAction: func(t *testing.T, action ktesting.Action) { +- testutil.AssertEqual(t, "Verb", "list", action.GetVerb()) +- testutil.AssertEqual(t, "Resource", "clusterbuildtemplates", action.GetResource().Resource) +- testutil.AssertEqual(t, "FieldSelector Field", "metadata.name", action.(ktesting.ListActionImpl).ListRestrictions.Fields.Requirements()[0].Field) +- testutil.AssertEqual(t, "FieldSelector Value", "buildpack", action.(ktesting.ListActionImpl).ListRestrictions.Fields.Requirements()[0].Value) +- }, +- }, +- "handles empty list of build templates": { +- EmptyBuildTemplateList: true, +- ExpectedErr: nil, +- }, +- "fetch image with default keychain": { +- RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { +- testutil.AssertEqual(t, "image name", "index.docker.io/library/some-image:latest", ref.Name()) +- fakeImage := NewFakeImage(gomock.NewController(t)) +- fakeImage.EXPECT().Layers().AnyTimes() +- return fakeImage, nil +- }, +- }, +- "fetching container layers fails": { +- ExpectedErr: errors.New("some-error"), +- RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { +- fakeImage := NewFakeImage(gomock.NewController(t)) +- fakeImage.EXPECT().Layers().Return(nil, errors.New("some-error")) +- return fakeImage, nil +- }, +- }, +- "uncompressing layer fails": { +- ExpectedErr: errors.New("some-error"), +- RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { +- fakeLayer := NewFakeLayer(gomock.NewController(t)) +- fakeLayer.EXPECT().Uncompressed().Return(nil, errors.New("some-error")) +- +- fakeImage := NewFakeImage(gomock.NewController(t)) +- fakeImage.EXPECT().Layers().Return([]gcrv1.Layer{fakeLayer}, nil) +- return fakeImage, nil +- }, +- }, +- "reads buldpack from order.toml in container": { +- RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { +- testutil.AssertEqual(t, "image name", "index.docker.io/library/some-image:latest", ref.Name()) +- fakeLayer := NewFakeLayer(gomock.NewController(t)) +- fakeLayer.EXPECT().Uncompressed().Return(buildTar(t), nil) +- +- fakeImage := NewFakeImage(gomock.NewController(t)) +- fakeImage.EXPECT().Layers().Return([]gcrv1.Layer{fakeLayer}, nil) +- return fakeImage, nil +- }, +- HandleOutput: func(t *testing.T, buildpacks []string) { +- testutil.AssertEqual(t, "buildpack", "io.buildpacks.samples.nodejs", buildpacks[0]) +- testutil.AssertEqual(t, "buildpack", "io.buildpacks.samples.go", buildpacks[1]) +- testutil.AssertEqual(t, "buildpack", "io.buildpacks.samples.java", buildpacks[2]) +- }, +- }, +- "fetching image fails": { +- ExpectedErr: errors.New("some-error"), +- RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { +- return nil, errors.New("some-error") +- }, +- }, +- "fetching image layers fails": { +- ExpectedErr: errors.New("some-error"), +- RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { +- fakeImage := NewFakeImage(gomock.NewController(t)) +- fakeImage.EXPECT().Layers().Return(nil, errors.New("some-error")) +- return fakeImage, nil +- }, +- }, +- "empty number of layers": { +- ExpectedErr: nil, // should not fail +- RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { +- fakeImage := NewFakeImage(gomock.NewController(t)) +- fakeImage.EXPECT().Layers().Return(nil, nil) +- return fakeImage, nil +- }, +- }, +- } { +- t.Run(tn, func(t *testing.T) { +- fake := &fake.FakeBuildV1alpha1{ +- Fake: &ktesting.Fake{}, +- } +- +- fake.AddReactor("*", "*", ktesting.ReactionFunc(func(action ktesting.Action) (handled bool, ret runtime.Object, err error) { +- if tc.HandleListAction != nil { +- tc.HandleListAction(t, action) +- } +- +- return true, buildTemplateList(tc.EmptyBuildTemplateList), tc.ReactorListErr +- })) +- +- l := buildpacks.NewBuildpackLister(fake, func(ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { +- if tc.RemoteImageFetcher == nil { +- fakeImage := NewFakeImage(gomock.NewController(t)) +- fakeImage.EXPECT().Layers().AnyTimes() +- return fakeImage, nil +- } +- +- return tc.RemoteImageFetcher(t, ref, options...) +- }) +- +- bps, gotErr := l.List() +- if gotErr != nil || tc.ExpectedErr != nil { +- testutil.AssertErrorsEqual(t, tc.ExpectedErr, gotErr) +- return +- } +- +- if tc.HandleOutput != nil { +- tc.HandleOutput(t, bps) +- } +- }) +- } +-} +- +-func buildTemplateList(empty bool) *build.ClusterBuildTemplateList { +- if empty { +- return &build.ClusterBuildTemplateList{} +- } +- builderImageDefault := "some-image" +- return &build.ClusterBuildTemplateList{ +- Items: []build.ClusterBuildTemplate{{ +- Spec: build.BuildTemplateSpec{ +- Parameters: []build.ParameterSpec{ +- { +- Name: "some-param", +- }, +- { +- Name: "BUILDER_IMAGE", +- Default: &builderImageDefault, +- }, +- }, +- }, +- }}, +- } +-} +- +-func buildTar(t *testing.T) io.ReadCloser { +- var buf bytes.Buffer +- tw := tar.NewWriter(&buf) +- var files = []struct { +- Name, Body string +- }{ +- {"readme.txt", "This archive contains some text files."}, +- {"gopher.txt", "Gopher names:\nGeorge\nGeoffrey\nGonzo"}, +- {"/buildpacks/order.toml", ` +-[[groups]] +- +- [[groups.buildpacks]] +- id = "io.buildpacks.samples.nodejs" +- version = "latest" +- +-[[groups]] +- +- [[groups.buildpacks]] +- id = "io.buildpacks.samples.go" +- version = "latest" +- +-[[groups]] +- +- [[groups.buildpacks]] +- id = "io.buildpacks.samples.java" +- version = "latest" +-`}, +- } +- for _, file := range files { +- hdr := &tar.Header{ +- Name: file.Name, +- Mode: 0600, +- Size: int64(len(file.Body)), +- } +- if err := tw.WriteHeader(hdr); err != nil { +- t.Fatal(err) +- } +- if _, err := tw.Write([]byte(file.Body)); err != nil { +- t.Fatal(err) +- } +- } +- if err := tw.Close(); err != nil { +- t.Fatal(err) +- } +- +- return ioutil.NopCloser(&buf) +-} +diff --git a/pkg/kf/buildpacks/build_template_uploader_test.go b/pkg/kf/buildpacks/client_test.go +similarity index 51% +rename from pkg/kf/buildpacks/build_template_uploader_test.go +rename to pkg/kf/buildpacks/client_test.go +index 1a0bcd927..ba16aaba3 100644 +--- a/pkg/kf/buildpacks/build_template_uploader_test.go ++++ b/pkg/kf/buildpacks/client_test.go +@@ -14,12 +14,23 @@ + + package buildpacks_test + ++//go:generate mockgen --package=buildpacks_test --copyright_file ../internal/tools/option-builder/LICENSE_HEADER --destination=fake_image_test.go --mock_names=Image=FakeImage,Layer=FakeLayer github.com/google/go-containerregistry/pkg/v1 Image,Layer ++ + import ( ++ "archive/tar" ++ "bytes" + "errors" ++ io "io" ++ "io/ioutil" + "testing" + + "github.com/GoogleCloudPlatform/kf/pkg/kf/buildpacks" + "github.com/GoogleCloudPlatform/kf/pkg/kf/testutil" ++ "github.com/buildpack/pack" ++ gomock "github.com/golang/mock/gomock" ++ "github.com/google/go-containerregistry/pkg/name" ++ gcrv1 "github.com/google/go-containerregistry/pkg/v1" ++ "github.com/google/go-containerregistry/pkg/v1/remote" + build "github.com/knative/build/pkg/apis/build/v1alpha1" + "github.com/knative/build/pkg/client/clientset/versioned/typed/build/v1alpha1/fake" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +@@ -27,7 +38,7 @@ import ( + ktesting "k8s.io/client-go/testing" + ) + +-func TestBuildTemplateUploader(t *testing.T) { ++func TestClient_UploadBuildTemplate(t *testing.T) { + t.Parallel() + + for tn, tc := range map[string]struct { +@@ -241,8 +252,12 @@ func TestBuildTemplateUploader(t *testing.T) { + return false, nil, nil + })) + +- u := buildpacks.NewBuildTemplateUploader(fake) +- gotErr := u.UploadBuildTemplate(tc.ImageName) ++ c := buildpacks.NewClient( ++ fake, ++ nil, ++ nil, ++ ) ++ gotErr := c.UploadBuildTemplate(tc.ImageName) + if gotErr != nil || tc.ExpectedErr != nil { + testutil.AssertErrorsEqual(t, tc.ExpectedErr, gotErr) + return +@@ -250,3 +265,270 @@ func TestBuildTemplateUploader(t *testing.T) { + }) + } + } ++ ++func TestClient_List(t *testing.T) { ++ t.Parallel() ++ ++ for tn, tc := range map[string]struct { ++ ReactorListErr error ++ ExpectedErr error ++ EmptyBuildTemplateList bool ++ HandleListAction func(t *testing.T, action ktesting.Action) ++ RemoteImageFetcher func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) ++ HandleOutput func(t *testing.T, buildpacks []string) ++ }{ ++ "list only buildpack build template": { ++ HandleListAction: func(t *testing.T, action ktesting.Action) { ++ testutil.AssertEqual(t, "Verb", "list", action.GetVerb()) ++ testutil.AssertEqual(t, "Resource", "clusterbuildtemplates", action.GetResource().Resource) ++ testutil.AssertEqual(t, "FieldSelector Field", "metadata.name", action.(ktesting.ListActionImpl).ListRestrictions.Fields.Requirements()[0].Field) ++ testutil.AssertEqual(t, "FieldSelector Value", "buildpack", action.(ktesting.ListActionImpl).ListRestrictions.Fields.Requirements()[0].Value) ++ }, ++ }, ++ "handles empty list of build templates": { ++ EmptyBuildTemplateList: true, ++ ExpectedErr: nil, ++ }, ++ "fetch image with default keychain": { ++ RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { ++ testutil.AssertEqual(t, "image name", "index.docker.io/library/some-image:latest", ref.Name()) ++ fakeImage := NewFakeImage(gomock.NewController(t)) ++ fakeImage.EXPECT().Layers().AnyTimes() ++ return fakeImage, nil ++ }, ++ }, ++ "fetching container layers fails": { ++ ExpectedErr: errors.New("some-error"), ++ RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { ++ fakeImage := NewFakeImage(gomock.NewController(t)) ++ fakeImage.EXPECT().Layers().Return(nil, errors.New("some-error")) ++ return fakeImage, nil ++ }, ++ }, ++ "uncompressing layer fails": { ++ ExpectedErr: errors.New("some-error"), ++ RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { ++ fakeLayer := NewFakeLayer(gomock.NewController(t)) ++ fakeLayer.EXPECT().Uncompressed().Return(nil, errors.New("some-error")) ++ ++ fakeImage := NewFakeImage(gomock.NewController(t)) ++ fakeImage.EXPECT().Layers().Return([]gcrv1.Layer{fakeLayer}, nil) ++ return fakeImage, nil ++ }, ++ }, ++ "reads buldpack from order.toml in container": { ++ RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { ++ testutil.AssertEqual(t, "image name", "index.docker.io/library/some-image:latest", ref.Name()) ++ fakeLayer := NewFakeLayer(gomock.NewController(t)) ++ fakeLayer.EXPECT().Uncompressed().Return(buildTar(t), nil) ++ ++ fakeImage := NewFakeImage(gomock.NewController(t)) ++ fakeImage.EXPECT().Layers().Return([]gcrv1.Layer{fakeLayer}, nil) ++ return fakeImage, nil ++ }, ++ HandleOutput: func(t *testing.T, buildpacks []string) { ++ testutil.AssertEqual(t, "buildpack", "io.buildpacks.samples.nodejs", buildpacks[0]) ++ testutil.AssertEqual(t, "buildpack", "io.buildpacks.samples.go", buildpacks[1]) ++ testutil.AssertEqual(t, "buildpack", "io.buildpacks.samples.java", buildpacks[2]) ++ }, ++ }, ++ "fetching image fails": { ++ ExpectedErr: errors.New("some-error"), ++ RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { ++ return nil, errors.New("some-error") ++ }, ++ }, ++ "fetching image layers fails": { ++ ExpectedErr: errors.New("some-error"), ++ RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { ++ fakeImage := NewFakeImage(gomock.NewController(t)) ++ fakeImage.EXPECT().Layers().Return(nil, errors.New("some-error")) ++ return fakeImage, nil ++ }, ++ }, ++ "empty number of layers": { ++ ExpectedErr: nil, ++ RemoteImageFetcher: func(t *testing.T, ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { ++ fakeImage := NewFakeImage(gomock.NewController(t)) ++ fakeImage.EXPECT().Layers().Return(nil, nil) ++ return fakeImage, nil ++ }, ++ }, ++ } { ++ t.Run(tn, func(t *testing.T) { ++ fake := &fake.FakeBuildV1alpha1{ ++ Fake: &ktesting.Fake{}, ++ } ++ ++ fake.AddReactor("*", "*", ktesting.ReactionFunc(func(action ktesting.Action) (handled bool, ret runtime.Object, err error) { ++ if tc.HandleListAction != nil { ++ tc.HandleListAction(t, action) ++ } ++ ++ return true, buildTemplateList(tc.EmptyBuildTemplateList), tc.ReactorListErr ++ })) ++ ++ rif := func(ref name.Reference, options ...remote.ImageOption) (gcrv1.Image, error) { ++ if tc.RemoteImageFetcher == nil { ++ fakeImage := NewFakeImage(gomock.NewController(t)) ++ fakeImage.EXPECT().Layers().AnyTimes() ++ return fakeImage, nil ++ } ++ ++ return tc.RemoteImageFetcher(t, ref, options...) ++ } ++ ++ c := buildpacks.NewClient( ++ fake, ++ rif, ++ nil, ++ ) ++ ++ bps, gotErr := c.List() ++ if gotErr != nil || tc.ExpectedErr != nil { ++ testutil.AssertErrorsEqual(t, tc.ExpectedErr, gotErr) ++ return ++ } ++ ++ if tc.HandleOutput != nil { ++ tc.HandleOutput(t, bps) ++ } ++ }) ++ } ++} ++ ++func buildTemplateList(empty bool) *build.ClusterBuildTemplateList { ++ if empty { ++ return &build.ClusterBuildTemplateList{} ++ } ++ builderImageDefault := "some-image" ++ return &build.ClusterBuildTemplateList{ ++ Items: []build.ClusterBuildTemplate{{ ++ Spec: build.BuildTemplateSpec{ ++ Parameters: []build.ParameterSpec{ ++ { ++ Name: "some-param", ++ }, ++ { ++ Name: "BUILDER_IMAGE", ++ Default: &builderImageDefault, ++ }, ++ }, ++ }, ++ }}, ++ } ++} ++ ++func buildTar(t *testing.T) io.ReadCloser { ++ var buf bytes.Buffer ++ tw := tar.NewWriter(&buf) ++ var files = []struct { ++ Name, Body string ++ }{ ++ {"readme.txt", "This archive contains some text files."}, ++ {"gopher.txt", "Gopher names:\nGeorge\nGeoffrey\nGonzo"}, ++ {"/buildpacks/order.toml", ` ++[[groups]] ++ ++ [[groups.buildpacks]] ++ id = "io.buildpacks.samples.nodejs" ++ version = "latest" ++ ++[[groups]] ++ ++ [[groups.buildpacks]] ++ id = "io.buildpacks.samples.go" ++ version = "latest" ++ ++[[groups]] ++ ++ [[groups.buildpacks]] ++ id = "io.buildpacks.samples.java" ++ version = "latest" ++`}, ++ } ++ for _, file := range files { ++ hdr := &tar.Header{ ++ Name: file.Name, ++ Mode: 0600, ++ Size: int64(len(file.Body)), ++ } ++ if err := tw.WriteHeader(hdr); err != nil { ++ t.Fatal(err) ++ } ++ if _, err := tw.Write([]byte(file.Body)); err != nil { ++ t.Fatal(err) ++ } ++ } ++ if err := tw.Close(); err != nil { ++ t.Fatal(err) ++ } ++ ++ return ioutil.NopCloser(&buf) ++} ++ ++func TestClient_Create(t *testing.T) { ++ t.Parallel() ++ ++ for tn, tc := range map[string]struct { ++ Dir string ++ ContainerRegistry string ++ ExpectedErr error ++ Creator buildpacks.BuilderFactoryCreate ++ }{ ++ "empty dir": { ++ Dir: "", ++ ContainerRegistry: "some-reg.io", ++ ExpectedErr: errors.New("dir must not be empty"), ++ }, ++ "empty container registry": { ++ Dir: "some-path/builder.toml", ++ ContainerRegistry: "", ++ ExpectedErr: errors.New("containerRegistry must not be empty"), ++ }, ++ "returns an error if creating fails": { ++ Dir: "some-path/builder.toml", ++ ContainerRegistry: "some-registry.io", ++ Creator: func(f pack.CreateBuilderFlags) error { return errors.New("some-error") }, ++ ExpectedErr: errors.New("some-error"), ++ }, ++ "sets the flags up": { ++ Dir: "some-path/builder.toml", ++ ContainerRegistry: "some-registry.io", ++ Creator: func(f pack.CreateBuilderFlags) error { ++ testutil.AssertEqual(t, "publish", true, f.Publish) ++ testutil.AssertEqual(t, "BuilderTomlPath", "some-path/builder.toml", f.BuilderTomlPath) ++ testutil.AssertEqual(t, "RepoName", "some-path/builder.toml", f.BuilderTomlPath) ++ testutil.AssertRegexp(t, "RepoName", `some-registry.io/buildpack-builder:[0-9]+`, f.RepoName) ++ return nil ++ }, ++ }, ++ "appends builder.toml if necessary": { ++ Dir: "some-path", ++ ContainerRegistry: "some-registry.io", ++ Creator: func(f pack.CreateBuilderFlags) error { ++ testutil.AssertEqual(t, "BuilderTomlPath", "some-path/builder.toml", f.BuilderTomlPath) ++ return nil ++ }, ++ }, ++ } { ++ t.Run(tn, func(t *testing.T) { ++ if tc.Creator == nil { ++ tc.Creator = func(f pack.CreateBuilderFlags) error { return nil } ++ } ++ ++ c := buildpacks.NewClient( ++ nil, ++ nil, ++ tc.Creator, ++ ) ++ image, gotErr := c.Create(tc.Dir, tc.ContainerRegistry) ++ if gotErr != nil || tc.ExpectedErr != nil { ++ testutil.AssertErrorsEqual(t, tc.ExpectedErr, gotErr) ++ return ++ } ++ ++ testutil.AssertRegexp(t, "image name", tc.ContainerRegistry+`/buildpack-builder:[0-9]+`, image) ++ }) ++ } ++} +diff --git a/pkg/kf/commands/buildpacks/buildpacks_test.go b/pkg/kf/commands/buildpacks/buildpacks_test.go +index 39e2092fe..2da2a52d0 100644 +--- a/pkg/kf/commands/buildpacks/buildpacks_test.go ++++ b/pkg/kf/commands/buildpacks/buildpacks_test.go +@@ -33,7 +33,7 @@ func TestBuildpacks(t *testing.T) { + Namespace string + ExpectedErr error + Args []string +- Setup func(t *testing.T, fake *fake.FakeBuildpackLister) ++ Setup func(t *testing.T, fake *fake.FakeClient) + BufferF func(t *testing.T, buffer *bytes.Buffer) + }{ + "wrong number of args": {ExpectedErr: errors.New("accepts 0 arg(s), received 1"), +@@ -41,12 +41,12 @@ func TestBuildpacks(t *testing.T) { + }, + "listing failes": { + ExpectedErr: errors.New("some-error"), +- Setup: func(t *testing.T, fake *fake.FakeBuildpackLister) { ++ Setup: func(t *testing.T, fake *fake.FakeClient) { + fake.EXPECT().List().Return(nil, errors.New("some-error")) + }, + }, + "lists each buildpack": { +- Setup: func(t *testing.T, fake *fake.FakeBuildpackLister) { ++ Setup: func(t *testing.T, fake *fake.FakeClient) { + fake.EXPECT().List().Return([]string{"bp-1", "bp-2"}, nil) + }, + BufferF: func(t *testing.T, buffer *bytes.Buffer) { +@@ -56,7 +56,7 @@ func TestBuildpacks(t *testing.T) { + } { + t.Run(tn, func(t *testing.T) { + ctrl := gomock.NewController(t) +- fake := fake.NewFakeBuildpackLister(ctrl) ++ fake := fake.NewFakeClient(ctrl) + + if tc.Setup != nil { + tc.Setup(t, fake) +diff --git a/pkg/kf/commands/buildpacks/upload_buildpacks_test.go b/pkg/kf/commands/buildpacks/upload_buildpacks_test.go +index 12f7735af..4d71bfb78 100644 +--- a/pkg/kf/commands/buildpacks/upload_buildpacks_test.go ++++ b/pkg/kf/commands/buildpacks/upload_buildpacks_test.go +@@ -35,69 +35,67 @@ func TestUploadBuildpacks(t *testing.T) { + for tn, tc := range map[string]struct { + Namespace string + ExpectedErr error +- Setup func(t *testing.T, c *cobra.Command, fakeBuilderCreator *fake.FakeBuilderCreator, fakeBuildTemplateUploader *fake.FakeBuildTemplateUploader) ++ Setup func(t *testing.T, c *cobra.Command, fakeClient *fake.FakeClient) + }{ + "uses correct container registry and path": { +- Setup: func(t *testing.T, c *cobra.Command, fakeBuilderCreator *fake.FakeBuilderCreator, fakeBuildTemplateUploader *fake.FakeBuildTemplateUploader) { ++ Setup: func(t *testing.T, c *cobra.Command, fakeClient *fake.FakeClient) { + c.Flags().Set("path", "/some-path") + c.Flags().Set("container-registry", "some-registry.io") +- fakeBuilderCreator.EXPECT().Create("/some-path", "some-registry.io").Return("some-image", nil) +- fakeBuildTemplateUploader.EXPECT().UploadBuildTemplate("some-image") ++ fakeClient.EXPECT().Create("/some-path", "some-registry.io").Return("some-image", nil) ++ fakeClient.EXPECT().UploadBuildTemplate("some-image") + }, + }, + "converts relative path to absolute": { +- Setup: func(t *testing.T, c *cobra.Command, fakeBuilderCreator *fake.FakeBuilderCreator, fakeBuildTemplateUploader *fake.FakeBuildTemplateUploader) { ++ Setup: func(t *testing.T, c *cobra.Command, fakeClient *fake.FakeClient) { + c.Flags().Set("path", "some-path") +- fakeBuilderCreator.EXPECT().Create(gomock.Any(), gomock.Any()).Do(func(path, containerRegistry string) { ++ fakeClient.EXPECT().Create(gomock.Any(), gomock.Any()).Do(func(path, containerRegistry string) { + if !filepath.IsAbs(path) { + t.Fatalf("expetec path to be absolute: %s", path) + } + }) +- fakeBuildTemplateUploader.EXPECT().UploadBuildTemplate(gomock.Any()) ++ fakeClient.EXPECT().UploadBuildTemplate(gomock.Any()) + }, + }, + "converts empty path to current directory": { +- Setup: func(t *testing.T, c *cobra.Command, fakeBuilderCreator *fake.FakeBuilderCreator, fakeBuildTemplateUploader *fake.FakeBuildTemplateUploader) { ++ Setup: func(t *testing.T, c *cobra.Command, fakeClient *fake.FakeClient) { + cwd, err := os.Getwd() + if err != nil { + t.Fatal(err) + } +- fakeBuilderCreator.EXPECT().Create(cwd, gomock.Any()) +- fakeBuildTemplateUploader.EXPECT().UploadBuildTemplate(gomock.Any()) ++ fakeClient.EXPECT().Create(cwd, gomock.Any()) ++ fakeClient.EXPECT().UploadBuildTemplate(gomock.Any()) + }, + }, + "returns error when upload fails": { + ExpectedErr: errors.New("some-error"), +- Setup: func(t *testing.T, c *cobra.Command, fakeBuilderCreator *fake.FakeBuilderCreator, fakeBuildTemplateUploader *fake.FakeBuildTemplateUploader) { ++ Setup: func(t *testing.T, c *cobra.Command, fakeClient *fake.FakeClient) { + c.Flags().Set("path", "/some-path") + c.Flags().Set("container-registry", "some-registry.io") +- fakeBuilderCreator.EXPECT().Create("/some-path", "some-registry.io") +- fakeBuildTemplateUploader.EXPECT().UploadBuildTemplate(gomock.Any()).Return(errors.New("some-error")) ++ fakeClient.EXPECT().Create("/some-path", "some-registry.io") ++ fakeClient.EXPECT().UploadBuildTemplate(gomock.Any()).Return(errors.New("some-error")) + }, + }, + "returns error when create fails": { + ExpectedErr: errors.New("some-error"), +- Setup: func(t *testing.T, c *cobra.Command, fakeBuilderCreator *fake.FakeBuilderCreator, fakeBuildTemplateUploader *fake.FakeBuildTemplateUploader) { +- fakeBuilderCreator.EXPECT().Create(gomock.Any(), gomock.Any()).Return("", errors.New("some-error")) ++ Setup: func(t *testing.T, c *cobra.Command, fakeClient *fake.FakeClient) { ++ fakeClient.EXPECT().Create(gomock.Any(), gomock.Any()).Return("", errors.New("some-error")) + }, + }, + } { + t.Run(tn, func(t *testing.T) { + ctrl := gomock.NewController(t) +- fakeBuilderCreator := fake.NewFakeBuilderCreator(ctrl) +- fakeBuildTemplateUploader := fake.NewFakeBuildTemplateUploader(ctrl) ++ fakeClient := fake.NewFakeClient(ctrl) + + c := cbuildpacks.NewUploadBuildpacks( + &config.KfParams{ + Namespace: tc.Namespace, + Output: &bytes.Buffer{}, + }, +- fakeBuilderCreator, +- fakeBuildTemplateUploader, ++ fakeClient, + ) + + if tc.Setup != nil { +- tc.Setup(t, c, fakeBuilderCreator, fakeBuildTemplateUploader) ++ tc.Setup(t, c, fakeClient) + } + + gotErr := c.Execute() +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+3SWQrCMBSF4Tx3FVlB0sSmLqd0cqB2wLSu37aISkF9UUT8v5d7SS4k4URlw/5Q ++JGVz0uJTwtHaubmOlnXujbPGWhvFNhahMXG4EtJ97EZ3Bt+nRynFsW37Z3Ov9n+UuuXfl75P8rau ++06ZQfve+M17lb4y75h9NcyaKTSRk+L4rPPbn+eeFnIPPyiLYtnJqpdJdtdXVRs9/o0vzymul1G39 ++8kn8YiD49mMAAAAAAAAAAAAAAACAP3MG4DifjwAoAAA= +diff --git 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-001352/tests/test.sh b/tasks/format-code-task-001352/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fc36058eb01d01f8e9a56c82b371f5e5722aa48 --- /dev/null +++ b/tasks/format-code-task-001352/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' +pkg/kf/buildpacks/builder_creator_test.go +pkg/kf/buildpacks/buildpack_lister_test.go +pkg/kf/buildpacks/build_template_uploader_test.go +pkg/kf/buildpacks/client_test.go +pkg/kf/commands/buildpacks/buildpacks_test.go +pkg/kf/commands/buildpacks/upload_buildpacks_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-001352/tests/test_command.sh b/tasks/format-code-task-001352/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001352/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001373/environment/Dockerfile b/tasks/format-code-task-001373/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e9d9202341df3b8d8e588195babc02fd0f6882ba --- /dev/null +++ b/tasks/format-code-task-001373/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:38c010faaba4c0ca67a5df4f1a332e90ff98dec7e1ff6b350bbe981badb0c0c8 diff --git a/tasks/format-code-task-001373/environment/setup/files/blocklist b/tasks/format-code-task-001373/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001373/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001373/environment/setup/setup.sh b/tasks/format-code-task-001373/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001373/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001373/tests/test.patch b/tasks/format-code-task-001373/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d2d62419652df68619a465fb4d1dc6429a3be13c --- /dev/null +++ b/tasks/format-code-task-001373/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..ce8ca9c +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["pip install -e . --quiet && python -m pytest tests/unit/handlers/test__helpers.py -v"] ++} +diff --git a/tests/unit/handlers/test__helpers.py b/tests/unit/handlers/test__helpers.py +index f1d89df..a18bb87 100644 +--- a/tests/unit/handlers/test__helpers.py ++++ b/tests/unit/handlers/test__helpers.py +@@ -198,6 +198,66 @@ class Test_get_request_data_from_django(unittest.TestCase): + self.assertEqual(http_request["remoteIp"], "127.0.0.1") + self.assertEqual(http_request["protocol"], "HTTP/1.1") + ++ def test_request_size_none_when_no_content_length(self): ++ ++ ++ ++ ++ ++ from django.test import RequestFactory ++ from google.cloud.logging_v2.handlers.middleware import request ++ ++ django_request = RequestFactory().get("/") ++ middleware = request.RequestMiddleware(None) ++ middleware.process_request(django_request) ++ http_request, _ = self._call_fut() ++ self.assertIn(http_request["requestSize"], (None, 0)) ++ ++ def test_does_not_read_request_body(self): ++ ++ ++ ++ ++ from django.test import RequestFactory ++ from google.cloud.logging_v2.handlers.middleware import request ++ ++ django_request = RequestFactory().put( ++ "http://testserver/123", data="hello world" ++ ) ++ ++ ++ django_request.read() ++ middleware = request.RequestMiddleware(None) ++ middleware.process_request(django_request) ++ ++ http_request, _ = self._call_fut() ++ ++ self.assertEqual(http_request["requestSize"], len("hello world")) ++ ++ def test_does_not_read_request_body_multiple_calls(self): ++ ++ ++ ++ ++ ++ from django.test import RequestFactory ++ from google.cloud.logging_v2.handlers.middleware import request ++ ++ django_request = RequestFactory().put( ++ "http://testserver/123", data="hello world" ++ ) ++ middleware = request.RequestMiddleware(None) ++ middleware.process_request(django_request) ++ ++ first_http, _ = self._call_fut() ++ ++ ++ django_request.read() ++ ++ second_http, _ = self._call_fut() ++ self.assertEqual(first_http["requestSize"], len("hello world")) ++ self.assertEqual(second_http["requestSize"], len("hello world")) ++ + + class Test_get_request_data(unittest.TestCase): + @staticmethod +diff --git 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 ++pip install -e . --quiet && python -m pytest -v -rA tests/unit/handlers/test__helpers.py::Test_get_request_data_from_django::test_request_size_none_when_no_content_length tests/unit/handlers/test__helpers.py::Test_get_request_data_from_django::test_does_not_read_request_body tests/unit/handlers/test__helpers.py::Test_get_request_data_from_django::test_does_not_read_request_body_multiple_calls ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001373/tests/test.sh b/tasks/format-code-task-001373/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e433cc41e3db1a8ca921679d3315d8d696e31544 --- /dev/null +++ b/tasks/format-code-task-001373/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/handlers/test__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-001373/tests/test_command.sh b/tasks/format-code-task-001373/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001373/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001374/environment/Dockerfile b/tasks/format-code-task-001374/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..00046b2d56e98f89d3ce64c39368d5fa5b487a1a --- /dev/null +++ b/tasks/format-code-task-001374/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bb4104d1e885d36243ee8d7d75db4c679572cccb7b1f63aa9e415834719251cb diff --git a/tasks/format-code-task-001374/environment/setup/files/blocklist b/tasks/format-code-task-001374/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001374/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001374/environment/setup/setup.sh b/tasks/format-code-task-001374/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001374/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001374/tests/test.patch b/tasks/format-code-task-001374/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..44429f0fedfb6f822cb8bdcd25eb0d0d4ad61f80 --- /dev/null +++ b/tasks/format-code-task-001374/tests/test.patch @@ -0,0 +1,199 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..879e697 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/unit/test_namespace_packages.py -v"] ++} +diff --git a/tests/unit/test_namespace_packages.py b/tests/unit/test_namespace_packages.py +new file mode 100644 +index 0000000..aae368e +--- /dev/null ++++ b/tests/unit/test_namespace_packages.py +@@ -0,0 +1,171 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import ast ++import os ++import unittest ++import warnings ++ ++ ++ ++ ++ ++ ++REPO_ROOT = os.path.abspath( ++ os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) ++) ++SETUP_PY = os.path.join(REPO_ROOT, "setup.py") ++GOOGLE_INIT = os.path.join(REPO_ROOT, "google", "__init__.py") ++GOOGLE_CLOUD_INIT = os.path.join(REPO_ROOT, "google", "cloud", "__init__.py") ++ ++ ++def _exec_init_with_strict_deprecation(init_path, package_name): ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ import pkg_resources ++ ++ original_declare = pkg_resources.declare_namespace ++ ++ def patched_declare_namespace(name): ++ warnings.warn( ++ "Deprecated call to `pkg_resources.declare_namespace(%r)`. " ++ "Implementing implicit namespace packages (as specified in " ++ "PEP 420) is preferred to `pkg_resources.declare_namespace`." ++ % (name,), ++ DeprecationWarning, ++ stacklevel=2, ++ ) ++ return original_declare(name) ++ ++ package_dir = os.path.dirname(init_path) ++ with open(init_path, "r") as f: ++ source = f.read() ++ code = compile(source, init_path, "exec") ++ ++ namespace = { ++ "__name__": package_name, ++ "__file__": init_path, ++ "__path__": [package_dir], ++ "__package__": package_name, ++ "__builtins__": __builtins__, ++ } ++ ++ pkg_resources.declare_namespace = patched_declare_namespace ++ try: ++ with warnings.catch_warnings(): ++ ++ ++ warnings.filterwarnings( ++ "error", ++ category=DeprecationWarning, ++ message=r".*declare_namespace.*", ++ ) ++ exec(code, namespace) ++ finally: ++ pkg_resources.declare_namespace = original_declare ++ ++ ++class TestNoDeclareNamespaceDeprecationWarning(unittest.TestCase): ++ ++ ++ ++ ++ ++ ++ ++ def test_google_init_does_not_leak_declare_namespace_deprecation(self): ++ ++ ++ if not os.path.exists(GOOGLE_INIT): ++ ++ ++ return ++ ++ ++ _exec_init_with_strict_deprecation(GOOGLE_INIT, "google") ++ ++ def test_google_cloud_init_does_not_leak_declare_namespace_deprecation(self): ++ ++ ++ if not os.path.exists(GOOGLE_CLOUD_INIT): ++ return ++ _exec_init_with_strict_deprecation(GOOGLE_CLOUD_INIT, "google.cloud") ++ ++ def test_package_still_imports(self): ++ ++ import google.cloud.logging ++ ++ self.assertTrue(hasattr(google.cloud.logging, "Client")) ++ ++ ++class TestSetupPyDoesNotUseDeprecatedNamespacePackages(unittest.TestCase): ++ ++ ++ ++ ++ ++ ++ def setUp(self): ++ with open(SETUP_PY, "r") as f: ++ self.source = f.read() ++ self.tree = ast.parse(self.source) ++ ++ def _find_setup_call(self): ++ for node in ast.walk(self.tree): ++ if isinstance(node, ast.Call): ++ func = node.func ++ if isinstance(func, ast.Attribute) and func.attr == "setup": ++ return node ++ if isinstance(func, ast.Name) and func.id == "setup": ++ return node ++ return None ++ ++ def test_setup_call_does_not_pass_namespace_packages_keyword(self): ++ call = self._find_setup_call() ++ self.assertIsNotNone(call, "could not locate setuptools.setup(...) call") ++ kwarg_names = {kw.arg for kw in call.keywords if kw.arg is not None} ++ self.assertNotIn( ++ "namespace_packages", ++ kwarg_names, ++ msg=( ++ "setup.py still passes the deprecated `namespace_packages=` " ++ "keyword to setuptools.setup; setuptools>=67.3.0 emits a " ++ "DeprecationWarning for this, which is part of the bug." ++ ), ++ ) ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA tests/unit/test_namespace_packages.py::TestNoDeclareNamespaceDeprecationWarning::test_google_init_does_not_leak_declare_namespace_deprecation tests/unit/test_namespace_packages.py::TestNoDeclareNamespaceDeprecationWarning::test_google_cloud_init_does_not_leak_declare_namespace_deprecation tests/unit/test_namespace_packages.py::TestNoDeclareNamespaceDeprecationWarning::test_package_still_imports tests/unit/test_namespace_packages.py::TestSetupPyDoesNotUseDeprecatedNamespacePackages::test_setup_call_does_not_pass_namespace_packages_keyword ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001374/tests/test.sh b/tasks/format-code-task-001374/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d741081ff8f017a55ea0a367f25d6d67348d631c --- /dev/null +++ b/tasks/format-code-task-001374/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/unit/test_namespace_packages.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-001374/tests/test_command.sh b/tasks/format-code-task-001374/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001374/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001380/environment/Dockerfile b/tasks/format-code-task-001380/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..25fcb30527ef021dd57b8f27a76dac6bb99a6cb5 --- /dev/null +++ b/tasks/format-code-task-001380/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ea1be270d8e1a1f6d3ac3f07acd98d37f3c4c39baf06904788592488a1a701fc diff --git a/tasks/format-code-task-001380/environment/setup/files/blocklist b/tasks/format-code-task-001380/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001380/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001380/environment/setup/setup.sh b/tasks/format-code-task-001380/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001380/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001380/tests/test.patch b/tasks/format-code-task-001380/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a292f32dcfbd7adfd65d12d76bbe88d9b2fdddf4 --- /dev/null +++ b/tasks/format-code-task-001380/tests/test.patch @@ -0,0 +1,94 @@ +diff --git a/acceptance/openstack/networking/v2/extensions/security_test.go b/acceptance/openstack/networking/v2/extensions/security_test.go +index c696377c10..3810a42014 100644 +--- a/acceptance/openstack/networking/v2/extensions/security_test.go ++++ b/acceptance/openstack/networking/v2/extensions/security_test.go +@@ -33,7 +33,7 @@ func TestSecurityGroupsList(t *testing.T) { + } + } + +-func TestSecurityGroupsCreateDelete(t *testing.T) { ++func TestSecurityGroupsCreateUpdateDelete(t *testing.T) { + client, err := clients.NewNetworkV2Client() + if err != nil { + t.Fatalf("Unable to create a network client: %v", err) +@@ -52,6 +52,17 @@ func TestSecurityGroupsCreateDelete(t *testing.T) { + defer DeleteSecurityGroupRule(t, client, rule.ID) + + tools.PrintResource(t, group) ++ ++ updateOpts := groups.UpdateOpts{ ++ Description: "A security group", ++ } ++ ++ newGroup, err := groups.Update(client, group.ID, updateOpts).Extract() ++ if err != nil { ++ t.Fatalf("Unable to update security group: %v", err) ++ } ++ ++ tools.PrintResource(t, newGroup) + } + + func TestSecurityGroupsPort(t *testing.T) { +diff --git a/openstack/networking/v2/extensions/security/groups/testing/requests_test.go b/openstack/networking/v2/extensions/security/groups/testing/requests_test.go +index 5d7a9203e6..5bb8c70c5b 100644 +--- a/openstack/networking/v2/extensions/security/groups/testing/requests_test.go ++++ b/openstack/networking/v2/extensions/security/groups/testing/requests_test.go +@@ -72,21 +72,22 @@ func TestUpdate(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + +- th.Mux.HandleFunc("/v2.0/security-groups", func(w http.ResponseWriter, r *http.Request) { +- th.TestMethod(t, r, "PUT") +- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) +- th.TestHeader(t, r, "Content-Type", "application/json") +- th.TestHeader(t, r, "Accept", "application/json") +- th.TestJSONRequest(t, r, SecurityGroupUpdateRequest) ++ th.Mux.HandleFunc("/v2.0/security-groups/2076db17-a522-4506-91de-c6dd8e837028", ++ func(w http.ResponseWriter, r *http.Request) { ++ th.TestMethod(t, r, "PUT") ++ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) ++ th.TestHeader(t, r, "Content-Type", "application/json") ++ th.TestHeader(t, r, "Accept", "application/json") ++ th.TestJSONRequest(t, r, SecurityGroupUpdateRequest) + +- w.Header().Add("Content-Type", "application/json") +- w.WriteHeader(http.StatusCreated) ++ w.Header().Add("Content-Type", "application/json") ++ w.WriteHeader(http.StatusOK) + +- fmt.Fprintf(w, SecurityGroupUpdateResponse) +- }) ++ fmt.Fprintf(w, SecurityGroupUpdateResponse) ++ }) + + opts := groups.UpdateOpts{Name: "newer-webservers"} +- sg, err := groups.Update(fake.ServiceClient(), opts).Extract() ++ sg, err := groups.Update(fake.ServiceClient(), "2076db17-a522-4506-91de-c6dd8e837028", opts).Extract() + th.AssertNoErr(t, err) + + th.AssertEquals(t, "newer-webservers", sg.Name) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TX2/TMBAA8D7nU5wK0sZD6jqsq4TUhwnQkAAVMXieUueamKa+4D+lfPs5aWm7 ++SrAJbSDE/V7SJne+8zkZzIKui2s0K9F7LMNoPBp11+j42v2Wo0xmw7Msy8a9oZSj8XkPRo/W0YHg ++fG4BepbI/yruruf/qMH+/D06f61oucxNMXDVw9W44/zl80zuzl+2cfLsfDjuwfDhWvi5//z8VQHd ++wc+wSJIncIUeQgOX0w8Xn97AnCz4SjtoLKZLKkKNDi4p/qUvqHyC64as30ZPRDsiUdL+tpTy/fTV ++53evJzSfJ8tFoS2kDfSfbjKEs0qU2ldhNojvXUxtKrSqplD0k9pA6ua75u6TdHsB9Rs5cQIfg4Fg ++tIe2sOtG4FAFq/13KC2FxsGprxAUWexiYK5rfJagqgj6k8mkXcFoUx6uEm/3k5I28ekKBoIaNPHN ++Uwth0H8ju4gZYpUJXPv4QJNx4kdZsSnbTaKNart8Scsmlk1VhWoBbT+5Utj43KhtV6cWvwZt44HV ++eoUwjfWu2nrgCFRuDHmYIeA6FvFYHPZ/a+12I0dLH2/H56WDk4Og/Y52ozuBVEFKIApcCRPqOo5g ++n3GfaWwbvDjapuqazX2MeQHTt/3kb39QjDHGGGOMMcYYY4wxxhhjjDHGGGN/2A1vEB/vACgAAA== +diff --git 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-001380/tests/test.sh b/tasks/format-code-task-001380/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..128458306002973de3eff5d2fb93d5a46382ce28 --- /dev/null +++ b/tasks/format-code-task-001380/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' +acceptance/openstack/networking/v2/extensions/security_test.go +openstack/networking/v2/extensions/security/groups/testing/requests_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-001380/tests/test_command.sh b/tasks/format-code-task-001380/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001380/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001387/environment/Dockerfile b/tasks/format-code-task-001387/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6436a47a018ec5f29c1750517a4ef415e03d0d92 --- /dev/null +++ b/tasks/format-code-task-001387/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b395f3d16cd57ee2f8939d10ad47feab2b53c43cc1debcde45d3597e096a0df4 diff --git a/tasks/format-code-task-001387/environment/setup/files/blocklist b/tasks/format-code-task-001387/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001387/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001387/environment/setup/setup.sh b/tasks/format-code-task-001387/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001387/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001387/tests/test.patch b/tasks/format-code-task-001387/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..91cbfa52a0eab986812a518cdc1632489dcbed2b --- /dev/null +++ b/tasks/format-code-task-001387/tests/test.patch @@ -0,0 +1,153 @@ +diff --git a/packages/grafana-runtime/src/utils/userStorage.test.tsx b/packages/grafana-runtime/src/utils/userStorage.test.tsx +index 91fe2374508..dbe8a30600a 100644 +--- a/packages/grafana-runtime/src/utils/userStorage.test.tsx ++++ b/packages/grafana-runtime/src/utils/userStorage.test.tsx +@@ -81,11 +81,12 @@ describe('userStorage', () => { + request.mockReturnValueOnce(Promise.reject({ status: 404 } as FetchError)); + const storage = usePluginUserStorage(); + await storage.setItem('key', 'value'); +- expect(request).toHaveBeenCalledWith({ +- url: '/apis/userstorage.grafana.app/v0alpha1/namespaces/default/user-storage/plugin-id:abc', +- method: 'GET', +- showErrorAlert: false, +- }); ++ expect(request).toHaveBeenCalledWith( ++ expect.objectContaining({ ++ url: '/apis/userstorage.grafana.app/v0alpha1/namespaces/default/user-storage/plugin-id:abc', ++ method: 'GET', ++ }) ++ ); + expect(request).toHaveBeenCalledWith( + expect.objectContaining({ + url: '/apis/userstorage.grafana.app/v0alpha1/namespaces/default/user-storage/', +@@ -109,11 +110,12 @@ describe('userStorage', () => { + ); + const storage = usePluginUserStorage(); + await storage.setItem('key', 'new-value'); +- expect(request).toHaveBeenCalledWith({ +- url: '/apis/userstorage.grafana.app/v0alpha1/namespaces/default/user-storage/plugin-id:abc', +- method: 'GET', +- showErrorAlert: false, +- }); ++ expect(request).toHaveBeenCalledWith( ++ expect.objectContaining({ ++ url: '/apis/userstorage.grafana.app/v0alpha1/namespaces/default/user-storage/plugin-id:abc', ++ method: 'GET', ++ }) ++ ); + expect(request).toHaveBeenCalledWith( + expect.objectContaining({ + url: '/apis/userstorage.grafana.app/v0alpha1/namespaces/default/user-storage/plugin-id:abc', +@@ -127,4 +129,65 @@ describe('userStorage', () => { + ); + }); + }); ++ ++ describe('setItem fallback to localStorage on API errors', () => { ++ it('falls back to localStorage when the GET (init) request fails with non-404 (e.g. 403 Forbidden)', async () => { ++ request.mockReturnValue(Promise.reject({ status: 403 } as FetchError)); ++ const storage = usePluginUserStorage(); ++ await storage.setItem('key', 'value'); ++ expect(localStorage.setItem).toHaveBeenCalledWith('plugin-id:abc:key', 'value'); ++ }); ++ ++ it('falls back to localStorage when the POST request fails (creating new storage)', async () => { ++ ++ request.mockReturnValueOnce(Promise.reject({ status: 404 } as FetchError)); ++ request.mockReturnValueOnce(Promise.reject({ status: 403 } as FetchError)); ++ const storage = usePluginUserStorage(); ++ await storage.setItem('key', 'value'); ++ expect(localStorage.setItem).toHaveBeenCalledWith('plugin-id:abc:key', 'value'); ++ }); ++ ++ it('falls back to localStorage when the PATCH request fails (updating existing storage)', async () => { ++ ++ request.mockReturnValueOnce( ++ Promise.resolve({ ++ status: 200, ++ data: { metadata: { name: 'plugin-id:abc' }, spec: { data: { key: 'value' } } }, ++ } as FetchResponse) ++ ); ++ request.mockReturnValueOnce(Promise.reject({ status: 403 } as FetchError)); ++ const storage = usePluginUserStorage(); ++ await storage.setItem('key', 'new-value'); ++ expect(localStorage.setItem).toHaveBeenCalledWith('plugin-id:abc:key', 'new-value'); ++ }); ++ ++ it('does not show error alert when POST request is made (creating new storage)', async () => { ++ request.mockReturnValueOnce(Promise.reject({ status: 404 } as FetchError)); ++ request.mockReturnValueOnce( ++ Promise.resolve({ status: 200, data: { spec: { data: { key: 'value' } } } } as FetchResponse) ++ ); ++ const storage = usePluginUserStorage(); ++ await storage.setItem('key', 'value'); ++ const postCall = request.mock.calls.find((call) => call[0].method === 'POST'); ++ expect(postCall).toBeDefined(); ++ expect(postCall![0].showErrorAlert).toBe(false); ++ }); ++ ++ it('does not show error alert when PATCH request is made (updating existing storage)', async () => { ++ request.mockReturnValueOnce( ++ Promise.resolve({ ++ status: 200, ++ data: { metadata: { name: 'plugin-id:abc' }, spec: { data: { key: 'value' } } }, ++ } as FetchResponse) ++ ); ++ request.mockReturnValueOnce( ++ Promise.resolve({ status: 200, data: { spec: { data: { key: 'new-value' } } } } as FetchResponse) ++ ); ++ const storage = usePluginUserStorage(); ++ await storage.setItem('key', 'new-value'); ++ const patchCall = request.mock.calls.find((call) => call[0].method === 'PATCH'); ++ expect(patchCall).toBeDefined(); ++ expect(patchCall![0].showErrorAlert).toBe(false); ++ }); ++ }); + }); +diff --git a/pkg/registry/apis/userstorage/register_test.go b/pkg/registry/apis/userstorage/register_test.go +index 885c62e9b95..4e6161347a2 100644 +--- a/pkg/registry/apis/userstorage/register_test.go ++++ b/pkg/registry/apis/userstorage/register_test.go +@@ -43,7 +43,14 @@ func TestAuthorizer(t *testing.T) { + requesterID: "123", + objectName: "", + verb: "create", +- decision: authorizer.DecisionNoOpinion, ++ decision: authorizer.DecisionAllow, ++ }, ++ { ++ name: "create request as viewer/none signed-in user", ++ requesterID: "viewer-uid", ++ objectName: "", ++ verb: "create", ++ decision: authorizer.DecisionAllow, + }, + { + name: "forbidden action", +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000000..2c90d959a60 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,6 @@ ++{ ++ "test_commands": [ ++ "yarn jest packages/grafana-runtime/src/utils/userStorage.test.tsx", ++ "/usr/local/go/bin/go test ./pkg/registry/apis/userstorage/ -run TestAuthorizer" ++ ] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,10 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++yarn jest packages/grafana-runtime/src/utils/userStorage.test.tsx ++rc=$(( rc | $? )) ++/usr/local/go/bin/go test ./pkg/registry/apis/userstorage/ -run TestAuthorizer ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001387/tests/test.sh b/tasks/format-code-task-001387/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9b98f42b3702b10d9374a23931a013fd323afb00 --- /dev/null +++ b/tasks/format-code-task-001387/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/grafana-runtime/src/utils/userStorage.test.tsx +pkg/registry/apis/userstorage/register_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-001387/tests/test_command.sh b/tasks/format-code-task-001387/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001387/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001389/environment/Dockerfile b/tasks/format-code-task-001389/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ba870cf1f282393bb345f951ff947e69464827df --- /dev/null +++ b/tasks/format-code-task-001389/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:37bf1ba13f6df2cccb8daacbf049a11a5bb0bfca235e80610383a8f2a9f069b7 diff --git a/tasks/format-code-task-001389/environment/setup/files/blocklist b/tasks/format-code-task-001389/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001389/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001389/environment/setup/setup.sh b/tasks/format-code-task-001389/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001389/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001389/tests/test.patch b/tasks/format-code-task-001389/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ebd0d10b5d02db613dde78fa545b2df9bb39aa47 --- /dev/null +++ b/tasks/format-code-task-001389/tests/test.patch @@ -0,0 +1,296 @@ +diff --git a/js/modules/k6/grpc/client_maxsize_test.go b/js/modules/k6/grpc/client_maxsize_test.go +new file mode 100644 +index 000000000..0fe3aca34 +--- /dev/null ++++ b/js/modules/k6/grpc/client_maxsize_test.go +@@ -0,0 +1,270 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package grpc ++ ++import ( ++ "context" ++ "net/url" ++ "os" ++ "testing" ++ ++ "github.com/dop251/goja" ++ "github.com/sirupsen/logrus" ++ "github.com/spf13/afero" ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ "google.golang.org/grpc/test/grpc_testing" ++ "gopkg.in/guregu/null.v3" ++ ++ "go.k6.io/k6/js/common" ++ "go.k6.io/k6/js/modulestest" ++ "go.k6.io/k6/lib" ++ "go.k6.io/k6/lib/fsext" ++ "go.k6.io/k6/lib/testutils/httpmultibin" ++ "go.k6.io/k6/metrics" ++) ++ ++ ++ ++type maxSizeTestState struct { ++ rt *goja.Runtime ++ vuState *lib.State ++ env *common.InitEnvironment ++ httpBin *httpmultibin.HTTPMultiBin ++ samples chan metrics.SampleContainer ++} ++ ++func setupMaxSizeTest(t *testing.T) maxSizeTestState { ++ t.Helper() ++ ++ root, err := lib.NewGroup("", nil) ++ require.NoError(t, err) ++ tb := httpmultibin.NewHTTPMultiBin(t) ++ samples := make(chan metrics.SampleContainer, 1000) ++ state := &lib.State{ ++ Group: root, ++ Dialer: tb.Dialer, ++ TLSConfig: tb.TLSClientConfig, ++ Samples: samples, ++ Options: lib.Options{ ++ SystemTags: metrics.NewSystemTagSet( ++ metrics.TagName, ++ metrics.TagURL, ++ ), ++ UserAgent: null.StringFrom("k6-test"), ++ }, ++ BuiltinMetrics: metrics.RegisterBuiltinMetrics( ++ metrics.NewRegistry(), ++ ), ++ Tags: lib.NewTagMap(nil), ++ } ++ ++ cwd, err := os.Getwd() ++ require.NoError(t, err) ++ fs := afero.NewOsFs() ++ if isWindows { ++ fs = fsext.NewTrimFilePathSeparatorFs(fs) ++ } ++ initEnv := &common.InitEnvironment{ ++ Logger: logrus.New(), ++ CWD: &url.URL{Path: cwd}, ++ FileSystems: map[string]afero.Fs{ ++ "file": fs, ++ }, ++ } ++ ++ rt := goja.New() ++ rt.SetFieldNameMapper(common.FieldNameMapper{}) ++ ++ return maxSizeTestState{ ++ rt: rt, ++ httpBin: tb, ++ vuState: state, ++ env: initEnv, ++ samples: samples, ++ } ++} ++ ++ ++ ++func (ts maxSizeTestState) run(t *testing.T, setup func(*httpmultibin.HTTPMultiBin), initCode, vuCode string) (goja.Value, error) { ++ t.Helper() ++ ++ ctx, cancel := context.WithCancel(context.Background()) ++ defer cancel() ++ mvu := &modulestest.VU{ ++ RuntimeField: ts.rt, ++ InitEnvField: ts.env, ++ CtxField: ctx, ++ } ++ ++ m, ok := New().NewModuleInstance(mvu).(*ModuleInstance) ++ require.True(t, ok) ++ require.NoError(t, ts.rt.Set("grpc", m.Exports().Named)) ++ ++ if setup != nil { ++ setup(ts.httpBin) ++ } ++ ++ replace := func(code string) (goja.Value, error) { ++ return ts.rt.RunString(ts.httpBin.Replacer.Replace(code)) ++ } ++ ++ _, err := replace(initCode) ++ require.NoError(t, err) ++ ++ mvu.StateField = ts.vuState ++ return replace(vuCode) ++} ++ ++const maxSizeInit = ` ++ var client = new grpc.Client(); ++ client.load([], "../../../../vendor/google.golang.org/grpc/test/grpc_testing/test.proto");` ++ ++func TestConnectMaxSizeValidation(t *testing.T) { ++ t.Parallel() ++ ++ tests := []struct { ++ name string ++ params string ++ errSub string ++ }{ ++ { ++ name: "ReceiveNotInteger", ++ params: `{ maxReceiveSize: "abc" }`, ++ errSub: "invalid maxReceiveSize value: 'abc', it needs to be an integer", ++ }, ++ { ++ name: "ReceiveBoolean", ++ params: `{ maxReceiveSize: true }`, ++ errSub: "it needs to be an integer", ++ }, ++ { ++ name: "ReceiveNegative", ++ params: `{ maxReceiveSize: -7 }`, ++ errSub: "invalid maxReceiveSize value: '-7', it needs to be a positive integer", ++ }, ++ { ++ name: "SendNotInteger", ++ params: `{ maxSendSize: "abc" }`, ++ errSub: "invalid maxSendSize value: 'abc', it needs to be an integer", ++ }, ++ { ++ name: "SendNegative", ++ params: `{ maxSendSize: -1 }`, ++ errSub: "invalid maxSendSize value: '-1', it needs to be a positive integer", ++ }, ++ } ++ ++ for _, tt := range tests { ++ tt := tt ++ t.Run(tt.name, func(t *testing.T) { ++ t.Parallel() ++ ts := setupMaxSizeTest(t) ++ _, err := ts.run(t, nil, maxSizeInit, ++ `client.connect("GRPCBIN_ADDR", `+tt.params+`);`) ++ require.Error(t, err) ++ assert.Contains(t, err.Error(), tt.errSub) ++ }) ++ } ++} ++ ++func TestConnectMaxSizeAcceptsValidValues(t *testing.T) { ++ t.Parallel() ++ ++ ++ ++ ts := setupMaxSizeTest(t) ++ ts.httpBin.GRPCStub.EmptyCallFunc = func(context.Context, *grpc_testing.Empty) (*grpc_testing.Empty, error) { ++ return &grpc_testing.Empty{}, nil ++ } ++ _, err := ts.run(t, nil, maxSizeInit, ` ++ client.connect("GRPCBIN_ADDR", { maxReceiveSize: 1048576, maxSendSize: 1048576 }); ++ var resp = client.invoke("grpc.testing.TestService/EmptyCall", {}) ++ if (resp.status !== grpc.StatusOK) { ++ throw new Error("unexpected status: " + resp.status) ++ }`) ++ require.NoError(t, err) ++} ++ ++func TestConnectMaxReceiveSizeDefaultAllowsLargeResponse(t *testing.T) { ++ t.Parallel() ++ ++ ++ ++ ts := setupMaxSizeTest(t) ++ ts.httpBin.GRPCStub.UnaryCallFunc = func(context.Context, *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) { ++ return &grpc_testing.SimpleResponse{ ++ Payload: &grpc_testing.Payload{ ++ Body: make([]byte, 64*1024), ++ }, ++ }, nil ++ } ++ _, err := ts.run(t, nil, maxSizeInit, ` ++ client.connect("GRPCBIN_ADDR"); ++ var resp = client.invoke("grpc.testing.TestService/UnaryCall", {}) ++ if (resp.status !== grpc.StatusOK) { ++ throw new Error("unexpected status: " + resp.status) ++ }`) ++ require.NoError(t, err) ++} ++ ++func TestConnectMaxReceiveSizeLimitsResponse(t *testing.T) { ++ t.Parallel() ++ ++ ++ ++ ts := setupMaxSizeTest(t) ++ ts.httpBin.GRPCStub.UnaryCallFunc = func(context.Context, *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) { ++ return &grpc_testing.SimpleResponse{ ++ Payload: &grpc_testing.Payload{ ++ Body: make([]byte, 8*1024), ++ }, ++ }, nil ++ } ++ _, err := ts.run(t, nil, maxSizeInit, ` ++ client.connect("GRPCBIN_ADDR", { maxReceiveSize: 64 }); ++ var resp = client.invoke("grpc.testing.TestService/UnaryCall", {}) ++ if (resp.status !== grpc.StatusResourceExhausted) { ++ throw new Error("unexpected status: " + resp.status) ++ }`) ++ require.NoError(t, err) ++} ++ ++func TestConnectMaxSendSizeLimitsRequest(t *testing.T) { ++ t.Parallel() ++ ++ ++ ++ ts := setupMaxSizeTest(t) ++ ts.httpBin.GRPCStub.UnaryCallFunc = func(context.Context, *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) { ++ return &grpc_testing.SimpleResponse{}, nil ++ } ++ ++ _, err := ts.run(t, nil, maxSizeInit, ` ++ client.connect("GRPCBIN_ADDR", { maxSendSize: 64 }); ++ var big = "A".repeat(8000); ++ var resp = client.invoke("grpc.testing.TestService/UnaryCall", { payload: { body: big } }) ++ if (resp.status !== grpc.StatusResourceExhausted) { ++ throw new Error("unexpected status: " + resp.status) ++ }`) ++ require.NoError(t, err) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++go test ./js/modules/k6/grpc/ -run 'TestClient$|TestDebugStat|TestClientInvokeHeadersDeprecated|TestResolveFileDescriptors' -count=1 ++ ++ ++go test ./js/modules/k6/grpc/ -run 'TestConnectMax' -count=1 diff --git a/tasks/format-code-task-001389/tests/test.sh b/tasks/format-code-task-001389/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..44783259232814746babcf431c919c67317a46b6 --- /dev/null +++ b/tasks/format-code-task-001389/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' +js/modules/k6/grpc/client_maxsize_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-001389/tests/test_command.sh b/tasks/format-code-task-001389/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001389/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001504/environment/Dockerfile b/tasks/format-code-task-001504/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e611b12491b17ef80227651d0951063295768851 --- /dev/null +++ b/tasks/format-code-task-001504/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b73dabaf05df22f8c2c3fd44870dc5c5632cb494addcf027d733c0340dcbe8b8 diff --git a/tasks/format-code-task-001504/environment/setup/files/blocklist b/tasks/format-code-task-001504/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001504/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001504/environment/setup/setup.sh b/tasks/format-code-task-001504/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001504/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001504/tests/test.patch b/tasks/format-code-task-001504/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d11c6acaec69aa92a1bb77a1ba8df1a5eefa5a2f --- /dev/null +++ b/tasks/format-code-task-001504/tests/test.patch @@ -0,0 +1,117 @@ +diff --git a/tests/components/deconz/test_alarm_control_panel.py b/tests/components/deconz/test_alarm_control_panel.py +index 5bafdc2fbb63f3..7e83e02760733c 100644 +--- a/tests/components/deconz/test_alarm_control_panel.py ++++ b/tests/components/deconz/test_alarm_control_panel.py +@@ -112,7 +112,7 @@ async def test_alarm_control_panel(hass, aioclient_mock, mock_deconz_websocket): + with patch.dict(DECONZ_WEB_REQUEST, data): + config_entry = await setup_deconz_integration(hass, aioclient_mock) + +- assert len(hass.states.async_all()) == 3 ++ assert len(hass.states.async_all()) == 4 + assert hass.states.get("alarm_control_panel.keypad").state == STATE_ALARM_PENDING + + # Event signals alarm control panel armed away +@@ -298,7 +298,7 @@ async def test_alarm_control_panel(hass, aioclient_mock, mock_deconz_websocket): + await hass.config_entries.async_unload(config_entry.entry_id) + + states = hass.states.async_all() +- assert len(states) == 3 ++ assert len(states) == 4 + for state in states: + assert state.state == STATE_UNAVAILABLE + +diff --git a/tests/components/deconz/test_binary_sensor.py b/tests/components/deconz/test_binary_sensor.py +index 32c7f1c3eb9c82..04c5335ffd5a90 100644 +--- a/tests/components/deconz/test_binary_sensor.py ++++ b/tests/components/deconz/test_binary_sensor.py +@@ -126,7 +126,12 @@ async def test_tampering_sensor(hass, aioclient_mock, mock_deconz_websocket): + "1": { + "name": "Presence sensor", + "type": "ZHAPresence", +- "state": {"dark": False, "presence": False, "tampered": False}, ++ "state": { ++ "dark": False, ++ "lowbattery": False, ++ "presence": False, ++ "tampered": False, ++ }, + "config": {"on": True, "reachable": True, "temperature": 10}, + "uniqueid": "00:00:00:00:00:00:00:00-00", + }, +@@ -137,12 +142,21 @@ async def test_tampering_sensor(hass, aioclient_mock, mock_deconz_websocket): + + ent_reg = er.async_get(hass) + +- assert len(hass.states.async_all()) == 3 ++ assert len(hass.states.async_all()) == 4 ++ hass.states.get("binary_sensor.presence_sensor_low_battery").state == STATE_OFF ++ assert ( ++ ent_reg.async_get("binary_sensor.presence_sensor_low_battery").entity_category ++ is EntityCategory.DIAGNOSTIC ++ ) + presence_tamper = hass.states.get("binary_sensor.presence_sensor_tampered") + assert presence_tamper.state == STATE_OFF + assert ( + presence_tamper.attributes[ATTR_DEVICE_CLASS] == BinarySensorDeviceClass.TAMPER + ) ++ assert ( ++ ent_reg.async_get("binary_sensor.presence_sensor_tampered").entity_category ++ is EntityCategory.DIAGNOSTIC ++ ) + + event_changed_sensor = { + "t": "event", +@@ -155,10 +169,6 @@ async def test_tampering_sensor(hass, aioclient_mock, mock_deconz_websocket): + await hass.async_block_till_done() + + assert hass.states.get("binary_sensor.presence_sensor_tampered").state == STATE_ON +- assert ( +- ent_reg.async_get("binary_sensor.presence_sensor_tampered").entity_category +- == EntityCategory.DIAGNOSTIC +- ) + + await hass.config_entries.async_unload(config_entry.entry_id) + +diff --git a/tests/components/deconz/test_deconz_event.py b/tests/components/deconz/test_deconz_event.py +index ca76631728e908..76babab36bebab 100644 +--- a/tests/components/deconz/test_deconz_event.py ++++ b/tests/components/deconz/test_deconz_event.py +@@ -269,7 +269,7 @@ async def test_deconz_alarm_events(hass, aioclient_mock, mock_deconz_websocket): + + device_registry = await hass.helpers.device_registry.async_get_registry() + +- assert len(hass.states.async_all()) == 3 ++ assert len(hass.states.async_all()) == 4 + # 1 alarm control device + 2 additional devices for deconz service and host + assert ( + len(async_entries_for_config_entry(device_registry, config_entry.entry_id)) == 3 +@@ -404,7 +404,7 @@ async def test_deconz_alarm_events(hass, aioclient_mock, mock_deconz_websocket): + await hass.config_entries.async_unload(config_entry.entry_id) + + states = hass.states.async_all() +- assert len(hass.states.async_all()) == 3 ++ assert len(hass.states.async_all()) == 4 + for state in states: + assert state.state == STATE_UNAVAILABLE + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S0WqDMBQGYK/7FHkBrckWvdqzhGgCFUwiSRTc0+/UUjoGqzctZez/LszBnGDw ++P1U3D6NR1i/H4llq0kq5reTnutVcCi4Eb5qW+jhveF0w+bQbfTOnrCNjRQwh3+vb2/+jqlv+2aas +++uCc9qZKp8d9Yy9/QZlf869lS/m/N0IUrH7cFX73z/PvDduC76w5TGs+Bf/GSseopJfs/EhHmokp ++eOupNLYP/vMyKnrU0dHA+BzDqCbt7VhN6/0z3eB1XFWyPoW4232plV1o59xclnlwNsz5o6lZuRxe ++/fMAAAAAAAAAAAAAAAAAAAAAAF7sCwt/bkQAKAAA +diff --git 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-001504/tests/test.sh b/tasks/format-code-task-001504/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..13a3910f48aae18ca70d4ceee7b0bf7ccf67fe2c --- /dev/null +++ b/tasks/format-code-task-001504/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/components/deconz/test_alarm_control_panel.py +tests/components/deconz/test_binary_sensor.py +tests/components/deconz/test_deconz_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-001504/tests/test_command.sh b/tasks/format-code-task-001504/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001504/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001513/environment/Dockerfile b/tasks/format-code-task-001513/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..738c4b343309b8d6ec40b9b9882e80955c47587c --- /dev/null +++ b/tasks/format-code-task-001513/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cdd74821acd85ce2616ccef0af06ce667c63cc7706e1fab3cb649556cf201838 diff --git a/tasks/format-code-task-001513/environment/setup/files/blocklist b/tasks/format-code-task-001513/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001513/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001513/environment/setup/setup.sh b/tasks/format-code-task-001513/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001513/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001513/tests/test.patch b/tasks/format-code-task-001513/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5c3578b91606c7345a7883d66e7436c5b7b6371a --- /dev/null +++ b/tasks/format-code-task-001513/tests/test.patch @@ -0,0 +1,66 @@ +diff --git a/src/adapter/aws-lambda/handler.test.ts b/src/adapter/aws-lambda/handler.test.ts +index 554458fd..2c8b1417 100644 +--- a/src/adapter/aws-lambda/handler.test.ts ++++ b/src/adapter/aws-lambda/handler.test.ts +@@ -12,6 +12,18 @@ describe('isContentTypeBinary', () => { + expect(isContentTypeBinary('application/ld+json')).toBe(false) + expect(isContentTypeBinary('application/json; charset=UTF-8')).toBe(false) + }) ++ ++ it('Should treat image/svg+xml as text (not binary)', () => { ++ expect(isContentTypeBinary('image/svg+xml')).toBe(false) ++ }) ++ ++ it('Should treat image/svg+xml with charset (no space) as text', () => { ++ expect(isContentTypeBinary('image/svg+xml;charset=utf-8')).toBe(false) ++ }) ++ ++ it('Should treat image/svg+xml with charset (with space) as text', () => { ++ expect(isContentTypeBinary('image/svg+xml; charset=utf-8')).toBe(false) ++ }) + }) + + describe('isContentEncodingBinary', () => { +diff --git a/src/adapter/lambda-edge/handler.test.ts b/src/adapter/lambda-edge/handler.test.ts +index 4ba5744a..21c8c1d7 100644 +--- a/src/adapter/lambda-edge/handler.test.ts ++++ b/src/adapter/lambda-edge/handler.test.ts +@@ -12,4 +12,16 @@ describe('isContentTypeBinary', () => { + expect(isContentTypeBinary('application/ld+json')).toBe(false) + expect(isContentTypeBinary('application/json; charset=UTF-8')).toBe(false) + }) ++ ++ it('Should treat image/svg+xml as text (not binary)', () => { ++ expect(isContentTypeBinary('image/svg+xml')).toBe(false) ++ }) ++ ++ it('Should treat image/svg+xml with charset (no space) as text', () => { ++ expect(isContentTypeBinary('image/svg+xml;charset=utf-8')).toBe(false) ++ }) ++ ++ it('Should treat image/svg+xml with charset (with space) as text', () => { ++ expect(isContentTypeBinary('image/svg+xml; charset=utf-8')).toBe(false) ++ }) + }) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..f68b2b48 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx vitest run src/adapter/aws-lambda/handler.test.ts src/adapter/lambda-edge/handler.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 vitest run src/adapter/aws-lambda/handler.test.ts src/adapter/lambda-edge/handler.test.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001513/tests/test.sh b/tasks/format-code-task-001513/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cac6bd89d768c5506e4b601744f7fa07a0154197 --- /dev/null +++ b/tasks/format-code-task-001513/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/adapter/aws-lambda/handler.test.ts +src/adapter/lambda-edge/handler.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-001513/tests/test_command.sh b/tasks/format-code-task-001513/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001513/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001514/environment/Dockerfile b/tasks/format-code-task-001514/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..57fcea80c331d930c94c303362c47f208d2427f3 --- /dev/null +++ b/tasks/format-code-task-001514/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ef42c82da34c4b532a7fcfc95d8182d266e1b4710bc6089503279a7ff13d4c88 diff --git a/tasks/format-code-task-001514/environment/setup/files/blocklist b/tasks/format-code-task-001514/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001514/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001514/environment/setup/setup.sh b/tasks/format-code-task-001514/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001514/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001514/tests/test.patch b/tasks/format-code-task-001514/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..dea109db5cb6a2905bfbde1ec5d63a1b5ac3dca6 --- /dev/null +++ b/tasks/format-code-task-001514/tests/test.patch @@ -0,0 +1,244 @@ +diff --git a/src/utils/body.test.ts b/src/utils/body.test.ts +index 80443466..18b69cd2 100644 +--- a/src/utils/body.test.ts ++++ b/src/utils/body.test.ts +@@ -1,4 +1,5 @@ +-import { parseBody } from './body' ++import { Hono } from '../hono' ++import { parseBody, type BodyData, type ParseBodyOptions } from './body' + + describe('Parse Body Util', () => { + const FORM_URL = 'https://localhost/form' +@@ -50,6 +51,206 @@ describe('Parse Body Util', () => { + }) + }) + ++ it('should parse dotted multipart form fields as nested objects with dot true', async () => { ++ const data = new FormData() ++ data.append('account.name', 'Alice') ++ data.append('account.email', 'alice@example.com') ++ data.append('token', 'abc123') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req, { dot: true }) ++ expect(parsedData.account).toEqual({ ++ name: 'Alice', ++ email: 'alice@example.com', ++ }) ++ expect(parsedData.token).toBe('abc123') ++ }) ++ ++ it('should parse deep dotted form fields with dot true', async () => { ++ const data = new FormData() ++ data.append('settings.profile.display.name', 'Ada') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req, { dot: true }) ++ expect(parsedData.settings).toEqual({ ++ profile: { display: { name: 'Ada' } }, ++ }) ++ }) ++ ++ it('should parse dotted urlencoded fields as nested objects with dot true', async () => { ++ const params = new URLSearchParams() ++ params.append('profile.name', 'Grace') ++ params.append('profile.email', 'grace@example.com') ++ ++ const req = new Request(FORM_URL, { ++ method: 'POST', ++ headers: { ++ 'Content-Type': 'application/x-www-form-urlencoded', ++ }, ++ body: params, ++ }) ++ ++ const parsedData = await parseBody(req, { dot: true }) ++ expect(parsedData.profile).toEqual({ ++ name: 'Grace', ++ email: 'grace@example.com', ++ }) ++ }) ++ ++ it('should pass dot option through request context parseBody', async () => { ++ const app = new Hono() ++ app.post('/profile', async (c) => { ++ const body = await c.req.parseBody({ dot: true }) ++ return c.json(body) ++ }) ++ ++ const data = new FormData() ++ data.append('member.name', 'Lin') ++ data.append('member.role', 'admin') ++ ++ const res = await app.request('/profile', { ++ method: 'POST', ++ body: data, ++ }) ++ ++ expect(await res.json()).toEqual({ ++ member: { ++ name: 'Lin', ++ role: 'admin', ++ }, ++ }) ++ }) ++ ++ it('should preserve File values in nested paths', async () => { ++ const avatar = new File(['avatar'], 'avatar.png', { ++ type: 'image/png', ++ }) ++ const resume = new File(['resume'], 'resume.pdf', { ++ type: 'application/pdf', ++ }) ++ const data = new FormData() ++ data.append('uploads.avatar', avatar) ++ data.append('uploads.resume', resume) ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req, { dot: true }) ++ expect((parsedData.uploads as Record).avatar).toMatchObject({ ++ name: 'avatar.png', ++ size: avatar.size, ++ type: 'image/png', ++ }) ++ expect((parsedData.uploads as Record).resume).toMatchObject({ ++ name: 'resume.pdf', ++ size: resume.size, ++ type: 'application/pdf', ++ }) ++ }) ++ ++ it('should keep dotted keys flat by default', async () => { ++ const data = new FormData() ++ data.append('account.name', 'Alice') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req) ++ expect(parsedData['account.name']).toBe('Alice') ++ expect(parsedData.account).toBeUndefined() ++ }) ++ ++ it('should keep dotted keys flat when dot is false', async () => { ++ const data = new FormData() ++ data.append('account.name', 'Alice') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req, { dot: false }) ++ expect(parsedData['account.name']).toBe('Alice') ++ expect(parsedData.account).toBeUndefined() ++ }) ++ ++ it('should keep dotted keys flat with all only', async () => { ++ const data = new FormData() ++ data.append('account.name', 'Alice') ++ data.append('account.name', 'Ada') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req, { all: true }) ++ expect(parsedData['account.name']).toEqual(['Alice', 'Ada']) ++ expect(parsedData.account).toBeUndefined() ++ }) ++ ++ it('should combine dot true with all true for repeated dotted fields', async () => { ++ const data = new FormData() ++ data.append('prefs.tags', 'typescript') ++ data.append('prefs.tags', 'runtime') ++ data.append('scope', 'public') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req, { dot: true, all: true }) ++ expect(parsedData.prefs).toEqual({ ++ tags: ['typescript', 'runtime'], ++ }) ++ expect(parsedData.scope).toBe('public') ++ }) ++ ++ it('should combine dot true with array suffix fields', async () => { ++ const data = new FormData() ++ data.append('settings.roles[]', 'admin') ++ data.append('settings.roles[]', 'editor') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req, { dot: true }) ++ expect(parsedData.settings).toEqual({ ++ 'roles[]': ['admin', 'editor'], ++ }) ++ }) ++ ++ it('should return null prototype body objects', async () => { ++ const data = new FormData() ++ data.append('name', 'Alice') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req) ++ expect(Object.getPrototypeOf(parsedData)).toBeNull() ++ }) ++ ++ it('should return null prototype nested body objects with dot true', async () => { ++ const data = new FormData() ++ data.append('account.profile.name', 'Alice') ++ ++ const req = createRequest(FORM_URL, 'POST', data) ++ ++ const parsedData = await parseBody(req, { dot: true }) ++ const account = parsedData.account as Record ++ const profile = account.profile as Record ++ expect(Object.getPrototypeOf(parsedData)).toBeNull() ++ expect(Object.getPrototypeOf(account)).toBeNull() ++ expect(Object.getPrototypeOf(profile)).toBeNull() ++ expect(profile.name).toBe('Alice') ++ }) ++ ++ it('should expose types for dot options and nested body data', async () => { ++ const opts: Partial = { dot: true } ++ const body: BodyData = { ++ account: { ++ name: 'Alice', ++ }, ++ } ++ const req = createRequest(FORM_URL, 'POST', new FormData()) ++ const parsed: BodyData = await parseBody(req, opts) ++ ++ expect(opts.dot).toBe(true) ++ expect((body.account as Record).name).toBe('Alice') ++ expect(Object.keys(parsed)).toEqual([]) ++ }) ++ + it('should parse multiple values if `all` option is true', async () => { + const data = new FormData() + data.append('file', '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,21 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++dev-switch node 22 ++npm install --legacy-peer-deps 2>&1 | tail -1 ++ ++ ++case "${1:-}" in ++ base) ++ npx vitest run src/utils/body.test.ts --testNamePattern 'should parse `multipart/form-data`|should parse `x-www-form-urlencoded`|should not parse multiple values in default|should parse multiple values if `all` option is true|should parse multiple values if values are `File`|should parse multiple values if key ends with `\[\]`|should return blank object if body is JSON' ++ ;; ++ new) ++ npx vitest run src/utils/body.test.ts --testNamePattern 'should parse dotted multipart form fields as nested objects with dot true|should parse deep dotted form fields with dot true|should parse dotted urlencoded fields as nested objects with dot true|should pass dot option through request context parseBody|should preserve File values in nested paths|should keep dotted keys flat by default|should keep dotted keys flat when dot is false|should keep dotted keys flat with all only|should combine dot true with all true for repeated dotted fields|should combine dot true with array suffix fields|should return null prototype body objects|should return null prototype nested body objects with dot true|should expose types for dot options and nested body data' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001514/tests/test.sh b/tasks/format-code-task-001514/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4c117489c9200b1dcce8b949d2d28c1bbbcbd5e --- /dev/null +++ b/tasks/format-code-task-001514/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/utils/body.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-001514/tests/test_command.sh b/tasks/format-code-task-001514/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001514/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-001522/environment/Dockerfile b/tasks/format-code-task-001522/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d3a580ba7682340a34b0c692a156934b7f8f04e0 --- /dev/null +++ b/tasks/format-code-task-001522/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ac1236526da4458b709d999445ab2324b49d1c00ce5764c14a8c3ba5cdec338f diff --git a/tasks/format-code-task-001522/environment/setup/files/blocklist b/tasks/format-code-task-001522/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001522/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001522/environment/setup/setup.sh b/tasks/format-code-task-001522/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001522/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001522/tests/test.patch b/tasks/format-code-task-001522/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..addc98b514e86e5759b37785dd422f894c6cdf80 --- /dev/null +++ b/tasks/format-code-task-001522/tests/test.patch @@ -0,0 +1,511 @@ +diff --git a/usercase-test-coderl/max_hardware_usage.test.js b/usercase-test-coderl/max_hardware_usage.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/max_hardware_usage.test.js +@@ -0,0 +1,472 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++const mockImages = []; ++let mockLog; ++let mockListenerCounts; ++let mockFrameTime; ++ ++function resetMockLog() { ++ mockLog = { ++ clearCalls: 0, ++ gBufferDraws: 0, ++ rayTraceDraws: 0, ++ rayTraceSetSizeCalls: [], ++ reprojectDraws: [], ++ toneMapDraws: [], ++ tileNextTileCalls: 0, ++ tileResetCalls: 0, ++ previewAdjustCalls: 0, ++ viewports: [], ++ }; ++} ++ ++function mockVectorScale(x, y) { ++ return { ++ x, ++ y, ++ clone() { ++ return mockVectorScale(this.x, this.y); ++ }, ++ }; ++} ++ ++jest.mock('src/renderer/glUtil', () => ({ ++ loadExtensions: jest.fn(() => ({})), ++})); ++ ++jest.mock('src/renderer/decomposeScene', () => ({ ++ decomposeScene: jest.fn(() => ({ meshes: [] })), ++})); ++ ++jest.mock('src/renderer/mergeMeshesToGeometry', () => ({ ++ mergeMeshesToGeometry: jest.fn(() => ({ materials: [] })), ++})); ++ ++jest.mock('src/renderer/Framebuffer', () => ({ ++ makeFramebuffer: jest.fn((gl, options) => { ++ const color = {}; ++ Object.keys(options.color || {}).forEach((key) => { ++ color[key] = options.color[key]; ++ }); ++ return { ++ color, ++ bind: jest.fn(), ++ unbind: jest.fn(), ++ }; ++ }), ++})); ++ ++jest.mock('src/renderer/FullscreenQuad', () => ({ ++ makeFullscreenQuad: jest.fn(() => ({})), ++})); ++ ++jest.mock('src/renderer/GBufferPass', () => ({ ++ makeGBufferPass: jest.fn(() => ({ ++ outputLocs: { ++ position: 0, ++ normal: 1, ++ faceNormal: 2, ++ color: 3, ++ matProps: 4, ++ }, ++ draw: jest.fn(() => { ++ mockLog.gBufferDraws++; ++ }), ++ setCamera: jest.fn(), ++ setJitter: jest.fn(), ++ })), ++})); ++ ++jest.mock('src/renderer/MaterialBuffer', () => ({ ++ makeMaterialBuffer: jest.fn(() => ({})), ++})); ++ ++jest.mock('src/renderer/RayTracePass', () => ({ ++ makeRayTracePass: jest.fn(() => ({ ++ outputLocs: { light: 0 }, ++ bindTextures: jest.fn(), ++ draw: jest.fn(() => { ++ mockLog.rayTraceDraws++; ++ }), ++ nextSeed: jest.fn(), ++ setCamera: jest.fn(), ++ setGBuffers: jest.fn(), ++ setJitter: jest.fn(), ++ setNoise: jest.fn(), ++ setSize: jest.fn((width, height) => { ++ mockLog.rayTraceSetSizeCalls.push([width, height]); ++ }), ++ setStrataCount: jest.fn(), ++ })), ++})); ++ ++jest.mock('src/renderer/RenderSize', () => ({ ++ makeRenderSize: jest.fn(() => ({ ++ width: 4, ++ height: 3, ++ scale: mockVectorScale(0.5, 0.5), ++ adjustSize: jest.fn(() => { ++ mockLog.previewAdjustCalls++; ++ }), ++ setSize: jest.fn(), ++ })), ++})); ++ ++jest.mock('src/renderer/ReprojectPass', () => ({ ++ makeReprojectPass: jest.fn(() => ({ ++ draw: jest.fn((params) => { ++ mockLog.reprojectDraws.push({ ++ blendAmount: params.blendAmount, ++ lightScale: [params.lightScale.x, params.lightScale.y], ++ }); ++ }), ++ setJitter: jest.fn(), ++ setPreviousCamera: jest.fn(), ++ })), ++})); ++ ++jest.mock('src/renderer/ToneMapPass', () => ({ ++ makeToneMapPass: jest.fn(() => ({ ++ draw: jest.fn((params) => { ++ mockLog.toneMapDraws.push({ ++ lightScale: [params.lightScale.x, params.lightScale.y], ++ }); ++ }), ++ })), ++})); ++ ++jest.mock('src/renderer/TileRender', () => ({ ++ makeTileRender: jest.fn(() => ({ ++ nextTile: jest.fn(() => { ++ mockLog.tileNextTileCalls++; ++ return { x: 0, y: 0, tileWidth: 1, tileHeight: 1, isFirstTile: true, isLastTile: true }; ++ }), ++ reset: jest.fn(() => { ++ mockLog.tileResetCalls++; ++ }), ++ setSize: jest.fn(), ++ })), ++})); ++ ++jest.mock('src/renderer/Texture', () => { ++ let textureId = 0; ++ return { ++ makeDepthTarget: jest.fn(() => ({ id: `depth-${++textureId}` })), ++ makeTexture: jest.fn(() => ({ id: `texture-${++textureId}` })), ++ }; ++}); ++ ++jest.mock('src/renderer/texture/noise', () => ({ ++ __esModule: true, ++ default: 'data:image/png;base64,AA==', ++})); ++ ++const THREE = require('three'); ++const { RayTracingRenderer } = require('src/main'); ++ ++class ManualImage { ++ constructor() { ++ this._src = ''; ++ this._onload = null; ++ mockImages.push(this); ++ } ++ ++ set src(value) { ++ this._src = value; ++ } ++ ++ get src() { ++ return this._src; ++ } ++ ++ set onload(callback) { ++ this._onload = callback; ++ } ++ ++ get onload() { ++ return this._onload; ++ } ++ ++ load() { ++ if (this._onload) { ++ this._onload(); ++ } ++ } ++} ++ ++function makeCanvas() { ++ const canvas = { ++ width: 0, ++ height: 0, ++ style: {}, ++ }; ++ ++ const gl = { ++ BLEND: 0x0BE2, ++ COLOR_BUFFER_BIT: 0x4000, ++ DEPTH_BUFFER_BIT: 0x0100, ++ FUNC_ADD: 0x8006, ++ LINEAR: 0x2601, ++ ONE: 1, ++ SCISSOR_TEST: 0x0C11, ++ blendEquation: jest.fn(), ++ blendFunc: jest.fn(), ++ clear: jest.fn(() => { ++ mockLog.clearCalls++; ++ }), ++ disable: jest.fn(), ++ enable: jest.fn(), ++ scissor: jest.fn(), ++ viewport: jest.fn((x, y, width, height) => { ++ mockLog.viewports.push([x, y, width, height]); ++ }), ++ get drawingBufferWidth() { ++ return canvas.width; ++ }, ++ get drawingBufferHeight() { ++ return canvas.height; ++ }, ++ }; ++ ++ canvas.getContext = jest.fn((kind) => (kind === 'webgl2' ? gl : null)); ++ return canvas; ++} ++ ++function makeReadyRenderer({ width = 8, height = 6 } = {}) { ++ const renderer = RayTracingRenderer({ canvas: makeCanvas() }); ++ renderer.maxHardwareUsage = true; ++ renderer.setSize(width, height); ++ ++ const scene = new THREE.Scene(); ++ const camera = new THREE.PerspectiveCamera(55, width / height, 0.1, 50); ++ camera.position.set(0, 0, 5); ++ camera.updateMatrixWorld(); ++ ++ renderFrame(renderer, scene, camera); ++ mockImages[mockImages.length - 1].load(); ++ ++ return { renderer, scene, camera }; ++} ++ ++function renderFrame(renderer, scene, camera) { ++ renderer.sync(mockFrameTime); ++ mockFrameTime += 16; ++ renderer.render(scene, camera); ++} ++ ++function expectFullCanvasSamples(count, width, height) { ++ expect(mockLog.rayTraceDraws).toBe(count); ++ expect(mockLog.rayTraceSetSizeCalls).toHaveLength(count); ++ mockLog.rayTraceSetSizeCalls.forEach((size) => { ++ expect(size).toEqual([width, height]); ++ }); ++ ++ expect(mockLog.reprojectDraws).toHaveLength(count); ++ expect(mockLog.toneMapDraws).toHaveLength(count); ++} ++ ++function listenerCount(type) { ++ return mockListenerCounts[type] || 0; ++} ++ ++beforeEach(() => { ++ resetMockLog(); ++ mockImages.length = 0; ++ mockListenerCounts = {}; ++ mockFrameTime = 1000; ++ ++ global.Image = ManualImage; ++ if (global.window) { ++ global.window.Image = ManualImage; ++ } ++ ++ document.addEventListener = jest.fn((type) => { ++ mockListenerCounts[type] = listenerCount(type) + 1; ++ }); ++ document.removeEventListener = jest.fn((type) => { ++ mockListenerCounts[type] = Math.max(0, listenerCount(type) - 1); ++ }); ++}); ++ ++describe('RayTracingRenderer maxHardwareUsage stateful lifecycle', () => { ++ test('does nothing until the pipeline noise image marks the renderer ready', () => { ++ ++ ++ ++ ++ const renderer = RayTracingRenderer({ canvas: makeCanvas() }); ++ renderer.maxHardwareUsage = true; ++ renderer.setSize(8, 6); ++ const scene = new THREE.Scene(); ++ const camera = new THREE.PerspectiveCamera(55, 8 / 6, 0.1, 50); ++ camera.position.set(0, 0, 5); ++ camera.updateMatrixWorld(); ++ ++ ++ expect(mockLog.rayTraceDraws).toBe(0); ++ ++ renderFrame(renderer, scene, camera); ++ ++ expect(renderer.getTotalSamplesRendered()).toBe(0); ++ expect(mockLog.rayTraceDraws).toBe(0); ++ expect(mockLog.reprojectDraws).toEqual([]); ++ expect(mockLog.toneMapDraws).toEqual([]); ++ ++ renderer.dispose(); ++ }); ++ ++ test('renders full-canvas samples and advances count only after an unchanged camera frame', () => { ++ ++ ++ ++ ++ const { renderer, scene, camera } = makeReadyRenderer({ width: 8, height: 6 }); ++ ++ renderFrame(renderer, scene, camera); ++ ++ expect(renderer.getTotalSamplesRendered()).toBe(0); ++ ++ expectFullCanvasSamples(1, 8, 6); ++ expect(mockLog.tileNextTileCalls).toBe(0); ++ expect(mockLog.viewports).toContainEqual([0, 0, 8, 6]); ++ ++ renderFrame(renderer, scene, camera); ++ ++ expect(renderer.getTotalSamplesRendered()).toBe(1); ++ ++ expectFullCanvasSamples(2, 8, 6); ++ expect(mockLog.tileNextTileCalls).toBe(0); ++ ++ renderer.dispose(); ++ }); ++ ++ test('resets accumulation when the camera changes, then increments on the next stable render', () => { ++ ++ ++ ++ ++ const { renderer, scene, camera } = makeReadyRenderer({ width: 8, height: 6 }); ++ ++ renderFrame(renderer, scene, camera); ++ renderFrame(renderer, scene, camera); ++ expect(renderer.getTotalSamplesRendered()).toBe(1); ++ ++ const clearCallsBeforeCameraChange = mockLog.clearCalls; ++ camera.position.set(1, 0, 5); ++ camera.updateMatrixWorld(); ++ renderFrame(renderer, scene, camera); ++ ++ expect(renderer.getTotalSamplesRendered()).toBe(0); ++ ++ expect(mockLog.clearCalls).toBeGreaterThan(clearCallsBeforeCameraChange); ++ expectFullCanvasSamples(3, 8, 6); ++ ++ renderFrame(renderer, scene, camera); ++ ++ expect(renderer.getTotalSamplesRendered()).toBe(1); ++ ++ expectFullCanvasSamples(4, 8, 6); ++ expect(mockLog.tileNextTileCalls).toBe(0); ++ ++ renderer.dispose(); ++ }); ++ ++ test('keeps maxHardwareUsage sample counts independent across renderer instances', () => { ++ ++ ++ ++ ++ const a = makeReadyRenderer({ width: 8, height: 6 }); ++ renderFrame(a.renderer, a.scene, a.camera); ++ renderFrame(a.renderer, a.scene, a.camera); ++ ++ const b = makeReadyRenderer({ width: 8, height: 6 }); ++ renderFrame(b.renderer, b.scene, b.camera); ++ ++ expect(a.renderer.getTotalSamplesRendered()).toBe(1); ++ expect(b.renderer.getTotalSamplesRendered()).toBe(0); ++ ++ a.renderer.dispose(); ++ b.renderer.dispose(); ++ }); ++ ++ test('uses the public render(scene, camera) lifecycle after becoming ready', () => { ++ ++ ++ ++ ++ ++ const renderer = RayTracingRenderer({ canvas: makeCanvas() }); ++ renderer.maxHardwareUsage = true; ++ renderer.setSize(8, 6); ++ const scene = new THREE.Scene(); ++ const camera = new THREE.PerspectiveCamera(55, 8 / 6, 0.1, 50); ++ camera.position.set(0, 0, 5); ++ camera.updateMatrixWorld(); ++ ++ renderFrame(renderer, scene, camera); ++ expect(mockLog.rayTraceDraws).toBe(0); ++ ++ mockImages[mockImages.length - 1].load(); ++ renderFrame(renderer, scene, camera); ++ ++ expect(renderer.getTotalSamplesRendered()).toBe(0); ++ expectFullCanvasSamples(1, 8, 6); ++ ++ renderer.dispose(); ++ }); ++ ++ test('camera projection changes reset accumulation before the next stable frame increments', () => { ++ ++ ++ ++ ++ ++ const { renderer, scene, camera } = makeReadyRenderer({ width: 8, height: 6 }); ++ ++ renderFrame(renderer, scene, camera); ++ renderFrame(renderer, scene, camera); ++ expect(renderer.getTotalSamplesRendered()).toBe(1); ++ ++ camera.fov = 60; ++ camera.updateProjectionMatrix(); ++ renderFrame(renderer, scene, camera); ++ ++ expect(renderer.getTotalSamplesRendered()).toBe(0); ++ expectFullCanvasSamples(3, 8, 6); ++ ++ renderFrame(renderer, scene, camera); ++ ++ expect(renderer.getTotalSamplesRendered()).toBe(1); ++ expectFullCanvasSamples(4, 8, 6); ++ ++ renderer.dispose(); ++ }); ++ ++ test('full-canvas mode follows the configured canvas size across renderer instances', () => { ++ ++ ++ ++ ++ ++ const a = makeReadyRenderer({ width: 8, height: 6 }); ++ renderFrame(a.renderer, a.scene, a.camera); ++ expectFullCanvasSamples(1, 8, 6); ++ ++ resetMockLog(); ++ ++ const b = makeReadyRenderer({ width: 5, height: 7 }); ++ renderFrame(b.renderer, b.scene, b.camera); ++ expectFullCanvasSamples(1, 5, 7); ++ expect(mockLog.tileNextTileCalls).toBe(0); ++ ++ a.renderer.dispose(); ++ b.renderer.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,29 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export CI="${CI:-1}" ++export NO_UPDATE_NOTIFIER=1 ++export BROWSERSLIST_IGNORE_OLD_DATA=1 ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_offline=true ++ ++JEST_BIN="/workspace/repo/node_modules/jest/bin/jest.js" ++if [ ! -f "$JEST_BIN" ]; then ++ echo "Missing vendored Jest at $JEST_BIN; offline test image was not prepared." >&2 ++ exit 1 ++fi ++ ++exec node "$JEST_BIN" /workspace/repo/usercase-test-coderl/max_hardware_usage.test.js --runInBand --watchman=false --verbose --coverage=false diff --git a/tasks/format-code-task-001522/tests/test.sh b/tasks/format-code-task-001522/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b3ccd4d031ed2c3d14189c02776b6de8957f8f0c --- /dev/null +++ b/tasks/format-code-task-001522/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/max_hardware_usage.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-001522/tests/test_command.sh b/tasks/format-code-task-001522/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001522/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-001525/environment/Dockerfile b/tasks/format-code-task-001525/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..174ecb5ab1db20a8c30aaca0e1fba669bb204f7e --- /dev/null +++ b/tasks/format-code-task-001525/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3768833b0e2332cd817e34f919d7fe024ea7a5ce7b79d6910026a954c29612e9 diff --git a/tasks/format-code-task-001525/environment/setup/files/blocklist b/tasks/format-code-task-001525/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001525/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001525/environment/setup/setup.sh b/tasks/format-code-task-001525/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001525/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001525/tests/test.patch b/tasks/format-code-task-001525/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..77a0328f14f2760cc55522c079777b8885df45b5 --- /dev/null +++ b/tasks/format-code-task-001525/tests/test.patch @@ -0,0 +1,200 @@ +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,178 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++( cd /workspace/repo && PYTHONDONTWRITEBYTECODE=1 python3 generate-wrapper.py --help >/dev/null ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=(env PYTHONDONTWRITEBYTECODE=1 python3 /workspace/repo/generate-wrapper.py) ++ ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++assert_file_text() { ++ local path="$1" ++ local expected="$2" ++ local label="$3" ++ local actual ++ actual=$(cat "$path") ++ [ "$actual" = "$expected" ] || fail "$label: $actual" ++} ++ ++assert_cpp_guard_wraps() { ++ local path="$1" ++ local label="$2" ++ shift 2 ++ python3 - "$path" "$label" "$@" <<'PY' || exit 1 ++import sys ++ ++path, label, *decls = sys.argv[1:] ++with open(path, encoding="utf-8") as f: ++ lines = [line.strip() for line in f] ++ ++def find_line(value, start=0): ++ for idx in range(start, len(lines)): ++ if lines[idx] == value: ++ return idx ++ return -1 ++ ++def fail(message): ++ print(f"FAIL: {label}: {message}", file=sys.stderr) ++ sys.exit(1) ++ ++final_endif = -1 ++for idx in range(len(lines) - 1, -1, -1): ++ if lines[idx]: ++ final_endif = idx ++ break ++if final_endif < 0 or lines[final_endif] != "#endif": ++ fail("missing final include guard #endif") ++ ++for open_if in [idx for idx, line in enumerate(lines) if line == "#ifdef __cplusplus"]: ++ extern = find_line('extern "C" {', open_if + 1) ++ if extern < 0: ++ continue ++ open_endif = find_line("#endif", extern + 1) ++ if open_endif < 0: ++ continue ++ close_if = find_line("#ifdef __cplusplus", open_endif + 1) ++ if close_if < 0: ++ continue ++ brace = find_line("}", close_if + 1) ++ if brace < 0: ++ continue ++ close_endif = find_line("#endif", brace + 1) ++ if close_endif < 0 or final_endif <= close_endif: ++ continue ++ if all(any(open_endif < idx < close_if for idx, line in enumerate(lines) if line == decl) for decl in decls): ++ sys.exit(0) ++ ++for decl in decls: ++ if not any(line == decl for line in lines): ++ fail(f"missing declaration {decl!r}") ++fail("no #ifdef __cplusplus / extern \"C\" block wraps all required declarations before the final include guard") ++PY ++} ++ ++ ++ ++ ++mkdir f1 && cd f1 || exit 1 ++printf 'int sample_add(int, int);\n' > sample.h ++"${BIN[@]}" --include sample.h --sys-include '"sample.h"' --soname libsample.so --init-name sample --output-header sample-wrap.h --output-implementation sample-wrap.c >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++assert_cpp_guard_wraps sample-wrap.h "F1 guarded declarations" \ ++ 'extern int (*sample_add_dylibloader_wrapper_sample)(int, int);' \ ++ 'int initialize_sample(int verbose);' ++cd .. ++ ++ ++ ++ ++mkdir f2 && cd f2 || exit 1 ++printf 'int sample_add(int, int);\nvoid sample_reset(void);\n' > sample.h ++"${BIN[@]}" --include sample.h --sys-include sample.h --soname libsample.so --init-name sample --output-header sample-wrap.h --output-implementation sample-wrap.c >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 generator exit $ec; want 0" ++ ++assert_cpp_guard_wraps sample-wrap.h "F2 guarded declarations" \ ++ 'extern int (*sample_add_dylibloader_wrapper_sample)(int, int);' \ ++ 'extern void (*sample_reset_dylibloader_wrapper_sample)(void);' \ ++ 'int initialize_sample(int verbose);' ++cat > probe.cpp <<'EOF' ++#include "sample-wrap.h" ++int call_init() { return initialize_sample(0); } ++int call_add_ptr() { return sample_add_dylibloader_wrapper_sample(1, 2); } ++void call_reset_ptr() { sample_reset_dylibloader_wrapper_sample(); } ++EOF ++g++ -std=c++11 -I. -c probe.cpp -o probe-cpp.o >cpp.out 2>cpp.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 C++ compile exit $ec; stderr: $(cat cpp.err)" ++ ++nm -u probe-cpp.o | awk '{print $NF}' | sort >cpp.nm ++EXPECTED_NM='initialize_sample ++sample_add_dylibloader_wrapper_sample ++sample_reset_dylibloader_wrapper_sample' ++assert_file_text cpp.nm "$EXPECTED_NM" "F2 C++ undefined symbols" ++cd .. ++ ++ ++ ++ ++mkdir f3 && cd f3 || exit 1 ++printf 'int sample_add(int, int);\nvoid sample_reset(void);\n' > sample.h ++"${BIN[@]}" --include sample.h --sys-include sample.h --soname libsample.so --init-name sample --output-header sample-wrap.h --output-implementation sample-wrap.c >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 generator exit $ec; want 0" ++ ++cat > probe.c <<'EOF' ++#include "sample-wrap.h" ++int call_init(void) { return initialize_sample(0); } ++int call_add_ptr(void) { return sample_add_dylibloader_wrapper_sample(1, 2); } ++void call_reset_ptr(void) { sample_reset_dylibloader_wrapper_sample(); } ++EOF ++gcc -std=c11 -I. -c probe.c -o probe-c.o >c.out 2>c.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 C compile exit $ec; stderr: $(cat c.err)" ++ ++nm -u probe-c.o | awk '{print $NF}' | sort >c.nm ++EXPECTED_NM='initialize_sample ++sample_add_dylibloader_wrapper_sample ++sample_reset_dylibloader_wrapper_sample' ++assert_file_text c.nm "$EXPECTED_NM" "F3 C undefined symbols" ++cd .. ++ ++ ++ ++ ++mkdir f4 && cd f4 || exit 1 ++printf 'typedef int sample_value;\n' > sample.h ++"${BIN[@]}" --include sample.h --sys-include sample.h --soname libsample.so --init-name sample --output-header sample-wrap.h --output-implementation sample-wrap.c >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 generator exit $ec; want 0" ++ ++assert_cpp_guard_wraps sample-wrap.h "F4 guarded initializer-only header" \ ++ 'int initialize_sample(int verbose);' ++cd .. ++ ++ ++ ++ ++mkdir f5 && cd f5 || exit 1 ++printf 'int sample_add(int, int);\n' > sample.h ++"${BIN[@]}" --include sample.h --sys-include sample.h --soname libsample.so --init-name sample --output-header sample-wrap.h --output-implementation sample-wrap.c >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 generator exit $ec; want 0" ++ ++assert_cpp_guard_wraps sample-wrap.h "F5 C++ guard closes before include guard" \ ++ 'extern int (*sample_add_dylibloader_wrapper_sample)(int, int);' \ ++ 'int initialize_sample(int verbose);' ++cat > after.cpp <<'EOF' ++#include "sample-wrap.h" ++namespace after_header { ++int value() { return 7; } ++} ++int use_after_header() { return after_header::value(); } ++EOF ++g++ -std=c++11 -I. -c after.cpp -o after-cpp.o >cpp.out 2>cpp.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 C++ compile after include exit $ec; stderr: $(cat cpp.err)" ++cd .. ++ ++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-001525/tests/test.sh b/tasks/format-code-task-001525/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001525/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-001525/tests/test_command.sh b/tasks/format-code-task-001525/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001525/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-001548/environment/Dockerfile b/tasks/format-code-task-001548/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..78f08e83901fa5c119b55a30db9ded4b5c13da05 --- /dev/null +++ b/tasks/format-code-task-001548/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:88f833dea372e5b0a1c05eb5a6cd607a88659aae07bcfa29679104f415e91cc9 diff --git a/tasks/format-code-task-001548/environment/setup/files/blocklist b/tasks/format-code-task-001548/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001548/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001548/environment/setup/setup.sh b/tasks/format-code-task-001548/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001548/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001548/tests/test.patch b/tasks/format-code-task-001548/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..249713e5fd86c57691b7885d84f3b04add2093a7 --- /dev/null +++ b/tasks/format-code-task-001548/tests/test.patch @@ -0,0 +1,302 @@ +diff --git a/usercase-test-coderl/context-lookup.test.ts b/usercase-test-coderl/context-lookup.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/context-lookup.test.ts +@@ -0,0 +1,227 @@ ++import { describe, expect, expectTypeOf, it } from 'vitest'; ++import { createInstance } from 'i18next'; ++import type { InitOptions, TOptions, TypeOptions } from 'i18next'; ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++const baseResources = { ++ en: { ++ translation: { ++ friend: 'friend', ++ friend_male: 'boyfriend', ++ friend_female: 'girlfriend', ++ step: 'step', ++ step_1: 'first step', ++ item: 'item', ++ item_male_one: 'his item', ++ item_male_other: 'his items', ++ empty_marker: 'base empty marker', ++ empty_marker_: 'empty suffix marker', ++ null_marker: 'base null marker', ++ null_marker_null: 'null suffix marker', ++ missing_marker: 'base missing marker', ++ formal: 'base formal', ++ 'formal|formal': 'colleague', ++ }, ++ }, ++} as const; ++ ++async function initializedInstance(options: InitOptions = {}) { ++ const instance = createInstance(); ++ await instance.init({ ++ lng: 'en', ++ fallbackLng: false, ++ initAsync: false, ++ resources: baseResources, ++ ...options, ++ }); ++ return instance; ++} ++ ++describe('public i18next context lookup session', () => { ++ it('keeps context-specific string and numeric lookups in initialized instance state', async () => { ++ ++ ++ const instance = await initializedInstance(); ++ ++ ++ expect(instance.t('friend')).toBe('friend'); ++ expect(instance.t('friend', { context: 'male' })).toBe('boyfriend'); ++ expect(instance.t('friend', { context: 'female' })).toBe('girlfriend'); ++ expect(instance.t('step', { context: 1 })).toBe('first step'); ++ ++ instance.off(); ++ }); ++ ++ it('uses the init-time contextSeparator for context key construction', async () => { ++ ++ ++ const instance = await initializedInstance({ contextSeparator: '|' }); ++ ++ ++ expect(instance.t('formal')).toBe('base formal'); ++ expect(instance.t('formal', { context: 'formal' })).toBe('colleague'); ++ expect(instance.t('friend', { context: 'male' })).toBe('friend'); ++ ++ instance.off(); ++ }); ++ ++ it('combines context lookup with plural lookup', async () => { ++ ++ ++ const instance = await initializedInstance(); ++ ++ expect(instance.t('item', { context: 'male', count: 1 })).toBe('his item'); ++ expect(instance.t('item', { context: 'male', count: 2 })).toBe('his items'); ++ ++ instance.off(); ++ }); ++ ++ it('reports the exact suffixed key when returnDetails is requested', async () => { ++ ++ ++ const instance = await initializedInstance(); ++ ++ ++ expect(instance.t('friend', { context: 'male', returnDetails: true })).toMatchObject({ ++ res: 'boyfriend', ++ exactUsedKey: 'friend_male', ++ }); ++ ++ instance.off(); ++ }); ++ ++ it('does not use context suffix lookup for empty, null, or missing context options', async () => { ++ ++ ++ const instance = await initializedInstance(); ++ ++ expect(instance.t('empty_marker', { context: '' })).toBe('base empty marker'); ++ expect(instance.t('null_marker', { context: null })).toBe('base null marker'); ++ expect(instance.t('missing_marker', {})).toBe('base missing marker'); ++ ++ instance.off(); ++ }); ++ ++ it('uses the resources supplied at initialization for context-specific lookup', async () => { ++ ++ ++ const instance = createInstance(); ++ ++ await instance.init({ ++ lng: 'en', ++ fallbackLng: false, ++ initAsync: false, ++ resources: { ++ en: { ++ translation: { ++ friend: 'pal', ++ friend_male: 'guy pal', ++ }, ++ }, ++ }, ++ }); ++ ++ ++ expect(instance.t('friend')).toBe('pal'); ++ expect(instance.t('friend', { context: 'male' })).toBe('guy pal'); ++ ++ instance.off(); ++ }); ++ ++ it('keeps context lookup state independent across initialized instances', async () => { ++ ++ ++ const first = createInstance(); ++ const second = createInstance(); ++ ++ await first.init({ ++ lng: 'en', ++ fallbackLng: false, ++ initAsync: false, ++ resources: { ++ en: { translation: { friend: 'first friend', friend_male: 'first boyfriend' } }, ++ }, ++ }); ++ await second.init({ ++ lng: 'en', ++ fallbackLng: false, ++ initAsync: false, ++ resources: { ++ en: { translation: { friend: 'second friend', friend_male: 'second boyfriend' } }, ++ }, ++ }); ++ ++ expect(first.t('friend', { context: 'male' })).toBe('first boyfriend'); ++ expect(second.t('friend', { context: 'male' })).toBe('second boyfriend'); ++ ++ ++ expect(first.t('friend')).toBe('first friend'); ++ expect(second.t('friend')).toBe('second friend'); ++ expect(second.t('friend', { context: 'male' })).toBe('second boyfriend'); ++ ++ first.off(); ++ second.off(); ++ }); ++ ++ it('falls back to the base key when the requested context variant is absent', async () => { ++ ++ ++ const instance = await initializedInstance(); ++ ++ ++ expect(instance.t('friend', { context: 'unknown' })).toBe('friend'); ++ expect(instance.t('missing_marker', { context: 'male' })).toBe('base missing marker'); ++ ++ instance.off(); ++ }); ++ ++ it('supports repeated construct/init/use cycles for context lookup', async () => { ++ ++ ++ const seen = new Set(); ++ ++ for (let i = 0; i < 20; i += 1) { ++ const instance = await initializedInstance(); ++ seen.add(instance.t('friend', { context: 'male' })); ++ seen.add(instance.t('friend', { context: 'female' })); ++ instance.off(); ++ } ++ ++ ++ expect(seen).toEqual(new Set(['boyfriend', 'girlfriend'])); ++ }); ++ ++ it('exposes context and contextSeparator through the public TypeScript option types', () => { ++ ++ ++ const initOptions = { contextSeparator: '|' } satisfies InitOptions; ++ const stringContext = { context: 'male' } satisfies TOptions<{}>; ++ const numericContext = { context: 1 } satisfies TOptions<{}>; ++ ++ ++ expectTypeOf().toMatchTypeOf(); ++ expect(initOptions.contextSeparator).toBe('|'); ++ expect(stringContext.context).toBe('male'); ++ expect(numericContext.context).toBe(1); ++ }); ++ ++ it('creates context-capable instances through the public createInstance export', async () => { ++ ++ ++ const instance = await initializedInstance(); ++ ++ ++ expect(instance.t('friend', { context: 'male' })).toBe('boyfriend'); ++ ++ instance.off(); ++ }); ++}); +diff --git a/usercase-test-coderl/context-options.test.ts b/usercase-test-coderl/context-options.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/context-options.test.ts +@@ -0,0 +1,18 @@ ++import { describe, expect, expectTypeOf, it } from 'vitest'; ++import type { InitOptions, TOptions, TypeOptions } from 'i18next'; ++ ++describe('public i18next context option declarations', () => { ++ it('accepts context and contextSeparator on the public option types', () => { ++ ++ ++ const initOptions = { contextSeparator: '|' } satisfies InitOptions; ++ const stringContext = { context: 'male' } satisfies TOptions<{}>; ++ const numericContext = { context: 1 } satisfies TOptions<{}>; ++ ++ ++ expectTypeOf().toMatchTypeOf(); ++ expect(initOptions.contextSeparator).toBe('|'); ++ expect(stringContext.context).toBe('male'); ++ expect(numericContext.context).toBe(1); ++ }); ++}); +diff --git a/usercase-test-coderl/vitest.usercase.config.mts b/usercase-test-coderl/vitest.usercase.config.mts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/vitest.usercase.config.mts +@@ -0,0 +1,7 @@ ++import { defineConfig } from 'vitest/config'; ++ ++export default defineConfig({ ++ test: { ++ environment: 'node', ++ }, ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++ ++for bin in rimraf rollup cpy vitest tsc; do ++ if [ ! -x "/workspace/repo/node_modules/.bin/${bin}" ]; then ++ echo "Missing local npm binary: ${bin}" >&2 ++ exit 1 ++ fi ++done ++ ++/workspace/repo/node_modules/.bin/rimraf dist ++/workspace/repo/node_modules/.bin/rollup -c --silent ++printf '{"type":"module"}\n' > /workspace/repo/dist/esm/package.json ++/workspace/repo/node_modules/.bin/cpy "./dist/umd/*.js" ./ ++rm -f /workspace/repo/i18next.js /workspace/repo/i18next.min.js ++/workspace/repo/node_modules/.bin/vitest run /workspace/repo/usercase-test-coderl/context-lookup.test.ts --config /workspace/repo/usercase-test-coderl/vitest.usercase.config.mts ++/workspace/repo/node_modules/.bin/tsc --ignoreConfig --noEmit --strict --module ESNext --moduleResolution Bundler --target ES2022 --types vitest --skipLibCheck /workspace/repo/usercase-test-coderl/context-options.test.ts diff --git a/tasks/format-code-task-001548/tests/test.sh b/tasks/format-code-task-001548/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ff2a3bd740ac2ca4c72dea166a824fa0bc8e87b --- /dev/null +++ b/tasks/format-code-task-001548/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/context-lookup.test.ts +usercase-test-coderl/context-options.test.ts +usercase-test-coderl/vitest.usercase.config.mts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001548/tests/test_command.sh b/tasks/format-code-task-001548/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001548/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-001576/environment/Dockerfile b/tasks/format-code-task-001576/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f7bf3a02e3eaeb45726c3557de95ca341b640f0e --- /dev/null +++ b/tasks/format-code-task-001576/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:48300394a0b227740d0a1c6d1c0167d7dae9c23ca4b1dc793cae488c182090ec diff --git a/tasks/format-code-task-001576/environment/setup/files/blocklist b/tasks/format-code-task-001576/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001576/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001576/environment/setup/setup.sh b/tasks/format-code-task-001576/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001576/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001576/tests/test.patch b/tasks/format-code-task-001576/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c59169e4bfdd06d6efa459bd9d8fc341fa33b098 --- /dev/null +++ b/tasks/format-code-task-001576/tests/test.patch @@ -0,0 +1,106 @@ +diff --git a/packages/database/__tests__/database.test.ts b/packages/database/__tests__/database.test.ts +index bec9e2f83..2e8cfbd29 100644 +--- a/packages/database/__tests__/database.test.ts ++++ b/packages/database/__tests__/database.test.ts +@@ -17,6 +17,8 @@ import database, { + getServerTime, + serverTimestamp, + increment, ++ enableLogging, ++ type Query, + endAt, + endBefore, + startAt, +@@ -38,6 +40,7 @@ import database, { + setPriority, + setWithPriority, + get, ++ off, + child, + onDisconnect, + keepSynced, +@@ -165,6 +168,20 @@ describe('Database', function () { + expect(increment).toBeDefined(); + }); + ++ it('`enableLogging` function is properly exposed to end user', function () { ++ expect(typeof enableLogging).toBe('function'); ++ }); ++ ++ it('`enableLogging` reports native non-support when called', function () { ++ const enableLoggingArgsWithPersistence: Parameters = [false, true]; ++ ++ ++ expect(() => enableLogging(true)).toThrow(/^enableLogging\(\) is not implemented$/); ++ expect(() => enableLogging(...enableLoggingArgsWithPersistence)).toThrow( ++ /^enableLogging\(\) is not implemented$/, ++ ); ++ }); ++ + it('`endAt` function is properly exposed to end user', function () { + expect(endAt).toBeDefined(); + }); +@@ -245,6 +262,23 @@ describe('Database', function () { + expect(setWithPriority).toBeDefined(); + }); + ++ it('`off` function is properly exposed to end user', function () { ++ expect(typeof off).toBe('function'); ++ }); ++ ++ it('`off` reports native non-support when called', function () { ++ const query = {} as Query; ++ const offArgsWithCallback: Parameters = [ ++ query, ++ 'value', ++ () => undefined, ++ ]; ++ ++ ++ expect(() => off(query)).toThrow(/^off\(\) is not implemented$/); ++ expect(() => off(...offArgsWithCallback)).toThrow(/^off\(\) is not implemented$/); ++ }); ++ + it('`get` function is properly exposed to end user', function () { + expect(get).toBeDefined(); + }); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,35 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++ ++if [ ! -f node_modules/.yarn-state.yml ]; then ++ yarn install --immutable ++fi ++ ++run_setup() { ++ for pkg in packages/*/; do ++ if grep -q 'genversion' "$pkg/package.json" 2>/dev/null; then ++ npx genversion --semi "$pkg/lib/version.js" 2>/dev/null ++ fi ++ done ++} ++ ++run_database_jest() { ++ local pattern="$1" ++ run_setup ++ yarn jest packages/database/__tests__/database.test.ts --no-coverage --runInBand --testNamePattern="$pattern" ++} ++ ++case "${1:-}" in ++ base) ++ run_database_jest '^(?!.*(`enableLogging`.*properly exposed|`enableLogging`.*reports native non-support|`off`.*properly exposed|`off`.*reports native non-support)).*$' ++ ;; ++ new) ++ run_database_jest '`enableLogging`.*properly exposed|`enableLogging`.*reports native non-support|`off`.*properly exposed|`off`.*reports native non-support' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001576/tests/test.sh b/tasks/format-code-task-001576/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..55b2b419351e98773a5310662f3da8c07ff9dc57 --- /dev/null +++ b/tasks/format-code-task-001576/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/database/__tests__/database.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-001576/tests/test_command.sh b/tasks/format-code-task-001576/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001576/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-001579/environment/Dockerfile b/tasks/format-code-task-001579/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c7376b1705321224e329205f62325bf79e55fa88 --- /dev/null +++ b/tasks/format-code-task-001579/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b05edab99b4bc73513346daac21b3d9514a242459baa26c6d26247a25220a421 diff --git a/tasks/format-code-task-001579/environment/setup/files/blocklist b/tasks/format-code-task-001579/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001579/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001579/environment/setup/setup.sh b/tasks/format-code-task-001579/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001579/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001579/tests/test.patch b/tasks/format-code-task-001579/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..dafefba436e138c4c0ed0d54f2eb9b7c9efae4a1 --- /dev/null +++ b/tasks/format-code-task-001579/tests/test.patch @@ -0,0 +1,516 @@ +diff --git a/dapps/valuetransfers/packages/branchmanager/branchmanager_test.go b/dapps/valuetransfers/packages/branchmanager/branchmanager_test.go +index f868df810..091758567 100644 +--- a/dapps/valuetransfers/packages/branchmanager/branchmanager_test.go ++++ b/dapps/valuetransfers/packages/branchmanager/branchmanager_test.go +@@ -5,11 +5,14 @@ import ( + "testing" + + "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" +- "github.com/iotaledger/goshimmer/packages/binary/testutil" ++ "github.com/iotaledger/hive.go/kvstore" ++ "github.com/iotaledger/hive.go/kvstore/mapdb" + ) + + func TestSomething(t *testing.T) { +- branchManager := New(testutil.DB(t)) ++ var store kvstore.KVStore = mapdb.NewMapDB() ++ ++ branchManager := New(store) + + cachedBranch1, _ := branchManager.Fork(BranchID{2}, []BranchID{MasterBranchID}, []ConflictID{transaction.OutputID{4}}) + defer cachedBranch1.Release() +diff --git a/dapps/valuetransfers/packages/tangle/kvstore_hidden_test.go b/dapps/valuetransfers/packages/tangle/kvstore_hidden_test.go +new file mode 100644 +index 000000000..f927c251e +--- /dev/null ++++ b/dapps/valuetransfers/packages/tangle/kvstore_hidden_test.go +@@ -0,0 +1,19 @@ ++package tangle ++ ++import ( ++ "testing" ++ ++ "github.com/iotaledger/hive.go/kvstore" ++ "github.com/iotaledger/hive.go/kvstore/mapdb" ++ "github.com/stretchr/testify/require" ++) ++ ++func TestNewAcceptsGenericInMemoryStore(t *testing.T) { ++ var store kvstore.KVStore = mapdb.NewMapDB() ++ ++ valueTangle := New(store) ++ require.NotNil(t, valueTangle) ++ ++ require.NoError(t, valueTangle.Prune()) ++ require.NoError(t, valueTangle.Prune()) ++} +diff --git a/dapps/valuetransfers/packages/test/generic_store_hidden_test.go b/dapps/valuetransfers/packages/test/generic_store_hidden_test.go +new file mode 100644 +index 000000000..30868077c +--- /dev/null ++++ b/dapps/valuetransfers/packages/test/generic_store_hidden_test.go +@@ -0,0 +1,235 @@ ++package test ++ ++import ( ++ "strings" ++ "sync" ++ "testing" ++ ++ "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" ++ "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" ++ "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/branchmanager" ++ valueTangle "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/tangle" ++ "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" ++ "github.com/iotaledger/hive.go/kvstore" ++ "github.com/stretchr/testify/require" ++) ++ ++func TestValueTangleUsesProvidedStoreForSnapshot(t *testing.T) { ++ store := newSharedKVStore() ++ addr := address.Random() ++ txID := transaction.RandomID() ++ ++ first := valueTangle.New(store) ++ require.NoError(t, first.Prune()) ++ first.LoadSnapshot(map[transaction.ID]map[address.Address][]*balance.Balance{ ++ txID: { ++ addr: []*balance.Balance{balance.New(balance.ColorIOTA, 1337)}, ++ }, ++ }) ++ first.Shutdown() ++ ++ second := valueTangle.New(store) ++ defer second.Shutdown() ++ require.EqualValues(t, 1337, valueTangle.NewLedgerState(second).Balances(addr)[balance.ColorIOTA]) ++ ++ isolated := valueTangle.New(newSharedKVStore()) ++ defer isolated.Shutdown() ++ require.Zero(t, valueTangle.NewLedgerState(isolated).Balances(addr)[balance.ColorIOTA]) ++} ++ ++func TestBranchManagerUsesProvidedStoreForBranches(t *testing.T) { ++ store := newSharedKVStore() ++ first := branchmanager.New(store) ++ require.GreaterOrEqual(t, store.realmCount(), 4) ++ ++ branchID := branchmanager.BranchID{42} ++ conflictID := branchmanager.ConflictID(transaction.OutputID{9}) ++ ++ cachedBranch, created := first.Fork(branchID, []branchmanager.BranchID{branchmanager.MasterBranchID}, []branchmanager.ConflictID{conflictID}) ++ require.True(t, created) ++ cachedBranch.Release() ++ ++ loaded := first.Branch(branchID).Consume(func(branch *branchmanager.Branch) { ++ require.Equal(t, branchID, branch.ID()) ++ }) ++ require.True(t, loaded) ++ ++ foundMember := false ++ first.ConflictMembers(conflictID).Consume(func(member *branchmanager.ConflictMember) { ++ if member.BranchID() == branchID { ++ foundMember = true ++ } ++ }) ++ require.True(t, foundMember) ++ ++ isolated := branchmanager.New(newSharedKVStore()) ++ require.False(t, isolated.Branch(branchID).Consume(func(branch *branchmanager.Branch) {})) ++} ++ ++type sharedKVStore struct { ++ mu *sync.RWMutex ++ data map[string][]byte ++ realm []byte ++ seen *[][]byte ++} ++ ++func newSharedKVStore() *sharedKVStore { ++ return &sharedKVStore{ ++ mu: &sync.RWMutex{}, ++ data: make(map[string][]byte), ++ seen: &[][]byte{}, ++ } ++} ++ ++func (store *sharedKVStore) WithRealm(realm kvstore.Realm) kvstore.KVStore { ++ store.mu.Lock() ++ *store.seen = append(*store.seen, append([]byte{}, realm...)) ++ store.mu.Unlock() ++ ++ return &sharedKVStore{ ++ mu: store.mu, ++ data: store.data, ++ realm: append([]byte{}, realm...), ++ seen: store.seen, ++ } ++} ++ ++func (store *sharedKVStore) realmCount() int { ++ store.mu.RLock() ++ defer store.mu.RUnlock() ++ ++ return len(*store.seen) ++} ++ ++func (store *sharedKVStore) Realm() kvstore.Realm { ++ return append([]byte{}, store.realm...) ++} ++ ++func (store *sharedKVStore) Iterate(prefix kvstore.KeyPrefix, consumer kvstore.IteratorKeyValueConsumerFunc) error { ++ store.mu.RLock() ++ defer store.mu.RUnlock() ++ ++ fullPrefix := store.scopedKey(prefix) ++ for key, value := range store.data { ++ if strings.HasPrefix(key, fullPrefix) { ++ if !consumer([]byte(key[len(store.realmPrefix()):]), append([]byte{}, value...)) { ++ break ++ } ++ } ++ } ++ return nil ++} ++ ++func (store *sharedKVStore) IterateKeys(prefix kvstore.KeyPrefix, consumer kvstore.IteratorKeyConsumerFunc) error { ++ return store.Iterate(prefix, func(key kvstore.Key, value kvstore.Value) bool { ++ return consumer(key) ++ }) ++} ++ ++func (store *sharedKVStore) Clear() error { ++ store.mu.Lock() ++ defer store.mu.Unlock() ++ ++ realmPrefix := store.realmPrefix() ++ for key := range store.data { ++ if strings.HasPrefix(key, realmPrefix) { ++ delete(store.data, key) ++ } ++ } ++ return nil ++} ++ ++func (store *sharedKVStore) Get(key kvstore.Key) (kvstore.Value, error) { ++ store.mu.RLock() ++ defer store.mu.RUnlock() ++ ++ value, exists := store.data[store.scopedKey(key)] ++ if !exists { ++ return nil, kvstore.ErrKeyNotFound ++ } ++ return append([]byte{}, value...), nil ++} ++ ++func (store *sharedKVStore) Set(key kvstore.Key, value kvstore.Value) error { ++ store.mu.Lock() ++ defer store.mu.Unlock() ++ ++ store.data[store.scopedKey(key)] = append([]byte{}, value...) ++ return nil ++} ++ ++func (store *sharedKVStore) Has(key kvstore.Key) (bool, error) { ++ store.mu.RLock() ++ defer store.mu.RUnlock() ++ ++ _, exists := store.data[store.scopedKey(key)] ++ return exists, nil ++} ++ ++func (store *sharedKVStore) Delete(key kvstore.Key) error { ++ store.mu.Lock() ++ defer store.mu.Unlock() ++ ++ delete(store.data, store.scopedKey(key)) ++ return nil ++} ++ ++func (store *sharedKVStore) DeletePrefix(prefix kvstore.KeyPrefix) error { ++ store.mu.Lock() ++ defer store.mu.Unlock() ++ ++ fullPrefix := store.scopedKey(prefix) ++ for key := range store.data { ++ if strings.HasPrefix(key, fullPrefix) { ++ delete(store.data, key) ++ } ++ } ++ return nil ++} ++ ++func (store *sharedKVStore) Batched() kvstore.BatchedMutations { ++ return &sharedBatch{store: store} ++} ++ ++func (store *sharedKVStore) scopedKey(key []byte) string { ++ return store.realmPrefix() + string(key) ++} ++ ++func (store *sharedKVStore) realmPrefix() string { ++ return string(store.realm) + "\x00" ++} ++ ++type sharedBatch struct { ++ store *sharedKVStore ++ sets []struct{ key, value []byte } ++ deletes [][]byte ++} ++ ++func (batch *sharedBatch) Set(key kvstore.Key, value kvstore.Value) error { ++ batch.sets = append(batch.sets, struct{ key, value []byte }{append([]byte{}, key...), append([]byte{}, value...)}) ++ return nil ++} ++ ++func (batch *sharedBatch) Delete(key kvstore.Key) error { ++ batch.deletes = append(batch.deletes, append([]byte{}, key...)) ++ return nil ++} ++ ++func (batch *sharedBatch) Cancel() { ++ batch.sets = nil ++ batch.deletes = nil ++} ++ ++func (batch *sharedBatch) Commit() error { ++ for _, set := range batch.sets { ++ if err := batch.store.Set(set.key, set.value); err != nil { ++ return err ++ } ++ } ++ for _, key := range batch.deletes { ++ if err := batch.store.Delete(key); err != nil { ++ return err ++ } ++ } ++ return nil ++} +diff --git a/dapps/valuetransfers/packages/test/valuetransfers_test.go b/dapps/valuetransfers/packages/test/valuetransfers_test.go +index d321c931d..bc13640cd 100644 +--- a/dapps/valuetransfers/packages/test/valuetransfers_test.go ++++ b/dapps/valuetransfers/packages/test/valuetransfers_test.go +@@ -5,6 +5,8 @@ import ( + "time" + + "github.com/iotaledger/hive.go/crypto/ed25519" ++ "github.com/iotaledger/hive.go/kvstore" ++ "github.com/iotaledger/hive.go/kvstore/mapdb" + "github.com/stretchr/testify/assert" + + "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" +@@ -12,12 +14,12 @@ import ( + "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/payload" + "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/tangle" + "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" +- "github.com/iotaledger/goshimmer/packages/binary/testutil" + ) + + func TestTangle_ValueTransfer(t *testing.T) { + // initialize tangle + ledgerstate +- valueTangle := tangle.New(testutil.DB(t)) ++ var store kvstore.KVStore = mapdb.NewMapDB() ++ valueTangle := tangle.New(store) + if err := valueTangle.Prune(); err != nil { + t.Error(err) + +diff --git a/packages/binary/messagelayer/messagefactory/messagefactory_test.go b/packages/binary/messagelayer/messagefactory/messagefactory_test.go +index 5c8466cce..cb7872dbe 100644 +--- a/packages/binary/messagelayer/messagefactory/messagefactory_test.go ++++ b/packages/binary/messagelayer/messagefactory/messagefactory_test.go +@@ -2,8 +2,6 @@ package messagefactory + + import ( + "encoding" +- "io/ioutil" +- "os" + "sync" + "sync/atomic" + "testing" +@@ -12,11 +10,11 @@ import ( + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/payload" + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/tipselector" +- "github.com/iotaledger/goshimmer/packages/database" +- "github.com/iotaledger/goshimmer/plugins/config" + + "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/identity" ++ "github.com/iotaledger/hive.go/kvstore" ++ "github.com/iotaledger/hive.go/kvstore/mapdb" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + ) +@@ -27,22 +25,13 @@ const ( + ) + + func TestMessageFactory_BuildMessage(t *testing.T) { +- // Set up DB for testing +- dir, err := ioutil.TempDir("", t.Name()) +- require.NoError(t, err) +- defer os.Remove(dir) +- // use the tempdir for the database +- config.Node.Set(database.CFG_DIRECTORY, dir) +- db := database.GetBadgerInstance() +- +- localIdentity := identity.GenerateLocalIdentity() +- tipSelector := tipselector.New() ++ var store kvstore.KVStore = mapdb.NewMapDB() ++ msgFactory := New(store, identity.GenerateLocalIdentity(), tipselector.New(), []byte(sequenceKey)) ++ defer msgFactory.Shutdown() + + // keep track of sequence numbers + sequenceNumbers := sync.Map{} + +- msgFactory := New(db, localIdentity, tipSelector, []byte(sequenceKey)) +- + // attach to event and count + countEvents := uint64(0) + msgFactory.Events.MessageConstructed.Attach(events.NewClosure(func(msg *message.Message) { +@@ -116,8 +105,23 @@ func TestMessageFactory_BuildMessage(t *testing.T) { + }) + assert.EqualValues(t, totalMessages-1, max) + assert.EqualValues(t, totalMessages, countSequence) ++} ++ ++func TestMessageFactorySequencePersistsInProvidedStore(t *testing.T) { ++ var store kvstore.KVStore = mapdb.NewMapDB() ++ sequenceKey := []byte("hidden-persisted-sequence") ++ ++ first := New(store, identity.GenerateLocalIdentity(), tipselector.New(), sequenceKey) ++ require.EqualValues(t, 0, first.IssuePayload(NewMockPayload([]byte("first"))).SequenceNumber()) ++ first.Shutdown() ++ ++ second := New(store, identity.GenerateLocalIdentity(), tipselector.New(), sequenceKey) ++ defer second.Shutdown() ++ require.EqualValues(t, 1, second.IssuePayload(NewMockPayload([]byte("second"))).SequenceNumber()) + +- _ = db.Close() ++ isolated := New(mapdb.NewMapDB(), identity.GenerateLocalIdentity(), tipselector.New(), sequenceKey) ++ defer isolated.Shutdown() ++ require.EqualValues(t, 0, isolated.IssuePayload(NewMockPayload([]byte("isolated"))).SequenceNumber()) + } + + type MockPayload struct { +diff --git a/packages/binary/messagelayer/tangle/tangle_test.go b/packages/binary/messagelayer/tangle/tangle_test.go +index 98eb4ffdc..69eae9128 100644 +--- a/packages/binary/messagelayer/tangle/tangle_test.go ++++ b/packages/binary/messagelayer/tangle/tangle_test.go +@@ -2,29 +2,20 @@ package tangle + + import ( + "fmt" +- "io/ioutil" +- "os" + "testing" + "time" + +- "github.com/iotaledger/hive.go/events" +- "github.com/iotaledger/hive.go/identity" +- "github.com/stretchr/testify/require" +- + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/payload" +- "github.com/iotaledger/goshimmer/packages/database" +- "github.com/iotaledger/goshimmer/plugins/config" ++ "github.com/iotaledger/hive.go/events" ++ "github.com/iotaledger/hive.go/identity" ++ "github.com/iotaledger/hive.go/kvstore" ++ "github.com/iotaledger/hive.go/kvstore/mapdb" + ) + + func BenchmarkTangle_AttachMessage(b *testing.B) { +- dir, err := ioutil.TempDir("", b.Name()) +- require.NoError(b, err) +- defer os.Remove(dir) +- // use the tempdir for the database +- config.Node.Set(database.CFG_DIRECTORY, dir) +- +- tangle := New(database.GetBadgerInstance()) ++ var store kvstore.KVStore = mapdb.NewMapDB() ++ tangle := New(store) + if err := tangle.Prune(); err != nil { + b.Error(err) + +@@ -49,13 +40,8 @@ func BenchmarkTangle_AttachMessage(b *testing.B) { + } + + func TestTangle_AttachMessage(t *testing.T) { +- dir, err := ioutil.TempDir("", t.Name()) +- require.NoError(t, err) +- defer os.Remove(dir) +- // use the tempdir for the database +- config.Node.Set(database.CFG_DIRECTORY, dir) +- +- messageTangle := New(database.GetBadgerInstance()) ++ var store kvstore.KVStore = mapdb.NewMapDB() ++ messageTangle := New(store) + if err := messageTangle.Prune(); err != nil { + t.Error(err) + +diff --git a/packages/binary/messagelayer/test/message_test.go b/packages/binary/messagelayer/test/message_test.go +index 70684aa30..563a991e6 100644 +--- a/packages/binary/messagelayer/test/message_test.go ++++ b/packages/binary/messagelayer/test/message_test.go +@@ -5,11 +5,15 @@ import ( + "testing" + "time" + ++ "github.com/iotaledger/goshimmer/packages/binary/messagelayer/messagefactory" ++ "github.com/iotaledger/goshimmer/packages/binary/messagelayer/tipselector" ++ "github.com/iotaledger/hive.go/identity" ++ "github.com/iotaledger/hive.go/kvstore" ++ "github.com/iotaledger/hive.go/kvstore/mapdb" + "github.com/stretchr/testify/assert" + + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/payload" +- "github.com/iotaledger/goshimmer/packages/binary/testutil" + ) + + func TestMessage_StorableObjectFromKey(t *testing.T) { +@@ -28,7 +32,11 @@ func TestMessage_StorableObjectFromKey(t *testing.T) { + } + + func TestMessage_MarshalUnmarshal(t *testing.T) { +- testMessage := testutil.MessageFactory(t).IssuePayload(payload.NewData([]byte("sth"))) ++ var store kvstore.KVStore = mapdb.NewMapDB() ++ msgFactory := messagefactory.New(store, identity.GenerateLocalIdentity(), tipselector.New(), []byte("message-test-sequence")) ++ defer msgFactory.Shutdown() ++ ++ testMessage := msgFactory.IssuePayload(payload.NewData([]byte("sth"))) + assert.Equal(t, true, testMessage.VerifySignature()) + + fmt.Print(testMessage) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,28 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ go test -count=1 -v \ ++ github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/branchmanager \ ++ github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/test \ ++ github.com/iotaledger/goshimmer/packages/binary/messagelayer/messagefactory \ ++ github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle \ ++ github.com/iotaledger/goshimmer/packages/binary/messagelayer/test ++ ;; ++ new) ++ go test -count=1 -v -run '^(TestSomething|TestTangle_ValueTransfer|TestNewAcceptsGenericInMemoryStore|TestValueTangleUsesProvidedStoreForSnapshot|TestBranchManagerUsesProvidedStoreForBranches|TestMessageFactory_BuildMessage|TestMessageFactorySequencePersistsInProvidedStore|TestTangle_AttachMessage|TestMessage_MarshalUnmarshal|TestNewMemDBDoesNotCreateDefaultDatabaseDirectory)$' \ ++ github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/branchmanager \ ++ github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/test \ ++ github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/tangle \ ++ github.com/iotaledger/goshimmer/packages/database \ ++ github.com/iotaledger/goshimmer/packages/binary/messagelayer/messagefactory \ ++ github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle \ ++ github.com/iotaledger/goshimmer/packages/binary/messagelayer/test ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001579/tests/test.sh b/tasks/format-code-task-001579/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a41c783365be0bcad95fb7c10ee325f7138b93f3 --- /dev/null +++ b/tasks/format-code-task-001579/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' +dapps/valuetransfers/packages/branchmanager/branchmanager_test.go +dapps/valuetransfers/packages/tangle/kvstore_hidden_test.go +dapps/valuetransfers/packages/test/generic_store_hidden_test.go +dapps/valuetransfers/packages/test/valuetransfers_test.go +packages/binary/messagelayer/messagefactory/messagefactory_test.go +packages/binary/messagelayer/tangle/tangle_test.go +packages/binary/messagelayer/test/message_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-001579/tests/test_command.sh b/tasks/format-code-task-001579/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001579/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-001583/environment/Dockerfile b/tasks/format-code-task-001583/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8de906114b44ef0d0e583ebc01253070fe0efbd1 --- /dev/null +++ b/tasks/format-code-task-001583/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0213ebb6e66af97cf93365b10847770e4d3028bfe0fe9da75e398114a7282043 diff --git a/tasks/format-code-task-001583/environment/setup/files/blocklist b/tasks/format-code-task-001583/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001583/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001583/environment/setup/setup.sh b/tasks/format-code-task-001583/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001583/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001583/tests/test.patch b/tasks/format-code-task-001583/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..30dc19b05fa6ab48ec0c1b3535e652a85e42e49e --- /dev/null +++ b/tasks/format-code-task-001583/tests/test.patch @@ -0,0 +1,490 @@ +diff --git a/usercase-test-coderl/fixtures/asn_api_server.py b/usercase-test-coderl/fixtures/asn_api_server.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/asn_api_server.py +@@ -0,0 +1,56 @@ ++#!/usr/bin/env python3 ++import http.server ++import json ++import sys ++from pathlib import Path ++ ++ ++port_file = Path(sys.argv[1]) ++request_log = Path(sys.argv[2]) ++counts = {} ++ ++ ++class Handler(http.server.BaseHTTPRequestHandler): ++ def do_GET(self): ++ counts[self.path] = counts.get(self.path, 0) + 1 ++ auth = self.headers.get("Authorization", "") ++ with request_log.open("a", encoding="utf-8") as log: ++ log.write(f"GET {self.path} auth={auth}\n") ++ ++ if self.path == "/AS401": ++ self.send_response(401) ++ self.send_header("Content-Type", "application/json") ++ self.end_headers() ++ self.wfile.write( ++ b'{"status":"401","error":{"title":"Unauthorized","message":"nope"}}' ++ ) ++ return ++ ++ names = { ++ "/AS1": "Boundary Network", ++ "/AS123": "Example Network", ++ } ++ if self.path == "/AS124": ++ name = "Cached Network" if counts[self.path] == 1 else "Fresh Network" ++ else: ++ name = names.get(self.path, "Unexpected Network") ++ ++ body = json.dumps( ++ { ++ "asn": self.path.lstrip("/"), ++ "name": name, ++ "registry": "arin", ++ } ++ ).encode("utf-8") ++ self.send_response(200) ++ self.send_header("Content-Type", "application/json") ++ self.end_headers() ++ self.wfile.write(body) ++ ++ def log_message(self, *args): ++ return ++ ++ ++server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler) ++port_file.write_text(str(server.server_port), encoding="utf-8") ++server.serve_forever() +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,403 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++ ++REPO=/workspace/repo ++FIXTURES="$REPO/usercase-test-coderl/fixtures" ++TMP=$(mktemp -d) ++SERVER_PID="" ++ ++cleanup() { ++ if [ -n "$SERVER_PID" ]; then ++ kill "$SERVER_PID" 2>/dev/null || true ++ wait "$SERVER_PID" 2>/dev/null || true ++ fi ++ rm -rf "$TMP" ++} ++trap cleanup EXIT ++ ++fail() { ++ echo "FAIL: $*" >&2 ++ exit 1 ++} ++ ++PORT_FILE="$TMP/api.port" ++REQLOG="$TMP/requests.log" ++python3 "$FIXTURES/asn_api_server.py" "$PORT_FILE" "$REQLOG" & ++SERVER_PID=$! ++for _ in $(seq 1 50); do ++ [ -s "$PORT_FILE" ] && break ++ sleep 0.1 ++done ++[ -s "$PORT_FILE" ] || fail "mock ASN API did not start" ++PORT=$(cat "$PORT_FILE") ++ ++CLIENT_SRC="$REPO/vendor/github.com/ipinfo/go/v2/ipinfo/client.go" ++PATCHED_CLIENT="$TMP/client.go" ++OVERLAY="$TMP/overlay.json" ++python3 - "$CLIENT_SRC" "$PATCHED_CLIENT" "$OVERLAY" "$PORT" <<'PY' ++import json ++import pathlib ++import re ++import sys ++ ++src, patched, overlay, port = sys.argv[1:5] ++text = pathlib.Path(src).read_text(encoding="utf-8") ++text, count = re.subn( ++ r'defaultBaseURL\s+=\s+"[^"]+"', ++ f'defaultBaseURL = "http://127.0.0.1:{port}/"', ++ text, ++ count=1, ++) ++if count != 1: ++ raise SystemExit("could not patch defaultBaseURL") ++pathlib.Path(patched).write_text(text, encoding="utf-8") ++pathlib.Path(overlay).write_text( ++ json.dumps({"Replace": {src: patched}}), ++ encoding="utf-8", ++) ++PY ++ ++( cd "$REPO" && go build -mod=vendor -overlay "$OVERLAY" -o "$TMP/ipinfo" ./ipinfo ) \ ++ || fail "build" ++BIN="$TMP/ipinfo" ++OUT="$TMP/out" ++ERR="$TMP/err" ++ ++make_config() { ++ cfg=$1 ++ token=$2 ++ cache_enabled=${3:-true} ++ mkdir -p "$cfg/ipinfo" ++ printf '{"cache_enabled":%s,"token":"%s","open_browser":true}' \ ++ "$cache_enabled" "$token" > "$cfg/ipinfo/config.json" ++} ++ ++run_cli() { ++ cfg=$1 ++ shift ++ rm -f "$OUT" "$ERR" ++ XDG_CONFIG_HOME="$cfg" HOME="$cfg/home" "$BIN" "$@" >"$OUT" 2>"$ERR" ++ ec=$? ++} ++ ++run_completion() { ++ cfg=$1 ++ line=$2 ++ rm -f "$OUT" "$ERR" ++ COMP_LINE="$line" COMP_POINT=${#line} XDG_CONFIG_HOME="$cfg" HOME="$cfg/home" \ ++ "$BIN" >"$OUT" 2>"$ERR" ++ ec=$? ++} ++ ++assert_file_eq_literal() { ++ file=$1 ++ label=$2 ++ expected="$TMP/expected" ++ cat > "$expected" ++ if ! cmp -s "$file" "$expected"; then ++ echo "FAIL: $label mismatch" >&2 ++ echo "got:" >&2 ++ sed -n '1,120p' "$file" >&2 ++ exit 1 ++ fi ++} ++ ++assert_empty() { ++ file=$1 ++ label=$2 ++ [ ! -s "$file" ] || fail "$label not empty: $(sed -n '1,20p' "$file")" ++} ++ ++assert_line() { ++ file=$1 ++ line=$2 ++ label=$3 ++ grep -Fqx -- "$line" "$file" || fail "$label missing line: $line" ++} ++ ++assert_line_with_terms() { ++ file=$1 ++ label=$2 ++ shift 2 ++ while IFS= read -r line; do ++ ok=1 ++ for term in "$@"; do ++ case "$line" in ++ *"$term"*) ;; ++ *) ok=0 ;; ++ esac ++ done ++ [ "$ok" -eq 1 ] && return 0 ++ done < "$file" ++ fail "$label missing line containing: $*" ++} ++ ++assert_json_asn_details() { ++ file=$1 ++ label=$2 ++ expected_asn=$3 ++ expected_name=$4 ++ expected_registry=$5 ++ python3 - "$file" "$label" "$expected_asn" "$expected_name" "$expected_registry" <<'PY' ++import json ++import pathlib ++import sys ++ ++path, label, expected_asn, expected_name, expected_registry = sys.argv[1:6] ++raw = pathlib.Path(path).read_text(encoding="utf-8") ++try: ++ data = json.loads(raw) ++except Exception as exc: ++ raise SystemExit(f"FAIL: {label} is not valid JSON: {exc}") ++if not isinstance(data, dict): ++ raise SystemExit(f"FAIL: {label} JSON is not an object") ++expected = { ++ "asn": expected_asn, ++ "name": expected_name, ++ "registry": expected_registry, ++} ++for key, value in expected.items(): ++ if data.get(key) != value: ++ raise SystemExit(f"FAIL: {label} {key}={data.get(key)!r}; want {value!r}") ++if '\n "' not in raw: ++ raise SystemExit(f"FAIL: {label} is not indented JSON") ++PY ++} ++ ++assert_yaml_asn_details() { ++ file=$1 ++ label=$2 ++ expected_asn=$3 ++ expected_name=$4 ++ expected_registry=$5 ++ parser="$TMP/assert_yaml.go" ++ cat > "$parser" <<'EOF' ++package main ++ ++import ( ++ "fmt" ++ "os" ++ ++ "gopkg.in/yaml.v3" ++) ++ ++func main() { ++ if len(os.Args) != 5 { ++ fmt.Fprintln(os.Stderr, "usage: assert_yaml ") ++ os.Exit(2) ++ } ++ raw, err := os.ReadFile(os.Args[1]) ++ if err != nil { ++ fmt.Fprintln(os.Stderr, err) ++ os.Exit(2) ++ } ++ var data map[string]interface{} ++ if err := yaml.Unmarshal(raw, &data); err != nil { ++ fmt.Fprintf(os.Stderr, "not valid YAML: %v\n", err) ++ os.Exit(2) ++ } ++ expected := map[string]string{ ++ "asn": os.Args[2], ++ "name": os.Args[3], ++ "registry": os.Args[4], ++ } ++ for key, want := range expected { ++ if got := fmt.Sprint(data[key]); got != want { ++ fmt.Fprintf(os.Stderr, "%s=%q; want %q\n", key, got, want) ++ os.Exit(2) ++ } ++ } ++} ++EOF ++ if ! ( cd "$REPO" && go run -mod=vendor "$parser" "$file" "$expected_asn" "$expected_name" "$expected_registry" ); then ++ fail "$label does not contain the expected ASN details as YAML" ++ fi ++} ++ ++request_count() { ++ if [ -f "$REQLOG" ]; then ++ wc -l < "$REQLOG" | tr -d '[:space:]' ++ else ++ printf '0' ++ fi ++} ++ ++assert_last_request() { ++ expected=$1 ++ actual=$(tail -n 1 "$REQLOG" 2>/dev/null || true) ++ [ "$actual" = "$expected" ] || fail "last request '$actual'; want '$expected'" ++} ++ ++ ++ ++ ++make_config "$TMP/cfg_f1" "" ++run_cli "$TMP/cfg_f1" AS123 --field asn,name,registry --token fixture-token ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_file_eq_literal "$OUT" "F1 stdout" <<'EOF' ++asn,name,registry ++AS123,Example Network,arin ++EOF ++assert_empty "$ERR" "F1 stderr" ++assert_last_request "GET /AS123 auth=Bearer fixture-token" ++ ++ ++ ++ ++make_config "$TMP/cfg_f2" "saved-token" ++run_cli "$TMP/cfg_f2" as123 --nocolor ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++assert_json_asn_details "$OUT" "F2 stdout" "AS123" "Example Network" "arin" ++assert_empty "$ERR" "F2 stderr" ++if grep -q $'\033' "$OUT"; then ++ fail "F2 stdout contains ANSI color escapes despite --nocolor" ++fi ++assert_last_request "GET /AS123 auth=Bearer saved-token" ++ ++ ++ ++ ++make_config "$TMP/cfg_f3" "" ++run_cli "$TMP/cfg_f3" AS123 -t fixture-token -y ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++ ++assert_yaml_asn_details "$OUT" "F3 stdout" "AS123" "Example Network" "arin" ++assert_empty "$ERR" "F3 stderr" ++assert_last_request "GET /AS123 auth=Bearer fixture-token" ++ ++ ++ ++ ++make_config "$TMP/cfg_f4" "" ++run_cli "$TMP/cfg_f4" AS1 --field asn,name,registry --token fixture-token ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_file_eq_literal "$OUT" "F4 stdout" <<'EOF' ++asn,name,registry ++AS1,Boundary Network,arin ++EOF ++assert_empty "$ERR" "F4 stderr" ++assert_last_request "GET /AS1 auth=Bearer fixture-token" ++ ++ ++ ++ ++make_config "$TMP/cfg_f5" "" ++before=$(request_count) ++run_cli "$TMP/cfg_f5" AS123 --help ++after=$(request_count) ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++[ "$after" -eq "$before" ] || fail "F5 made an API request" ++assert_empty "$ERR" "F5 stderr" ++ ++assert_line "$OUT" "Usage: ipinfo AS123 []" "F5 help" ++assert_line_with_terms "$OUT" "F5 help --token" "--token" ++assert_line_with_terms "$OUT" "F5 help --nocache" "--nocache" ++assert_line_with_terms "$OUT" "F5 help --field" "--field" ++assert_line_with_terms "$OUT" "F5 help --nocolor" "--nocolor" ++assert_line_with_terms "$OUT" "F5 help --json" "--json" ++assert_line_with_terms "$OUT" "F5 help --yaml" "--yaml" ++ ++ ++ ++ ++make_config "$TMP/cfg_f6" "" ++before=$(request_count) ++run_cli "$TMP/cfg_f6" AS123 -h ++after=$(request_count) ++[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0" ++[ "$after" -eq "$before" ] || fail "F6 made an API request" ++assert_empty "$ERR" "F6 stderr" ++assert_line "$OUT" "Usage: ipinfo AS123 []" "F6 help" ++ ++assert_line_with_terms "$OUT" "F6 help --yaml" "--yaml" ++ ++ ++ ++ ++make_config "$TMP/cfg_f7" "" ++before=$(request_count) ++run_cli "$TMP/cfg_f7" AS123 ++after=$(request_count) ++[ "$ec" -eq 0 ] || fail "F7 exit $ec; want GT normal error exit 0" ++[ "$after" -eq "$before" ] || fail "F7 made an API request without a token" ++assert_empty "$OUT" "F7 stdout" ++assert_file_eq_literal "$ERR" "F7 stderr" <<'EOF' ++err: ASN lookups require a token; login via `ipinfo init`. ++EOF ++ ++ ++ ++ ++make_config "$TMP/cfg_f8" "" ++run_cli "$TMP/cfg_f8" AS401 --token bad-token ++[ "$ec" -eq 0 ] || fail "F8 exit $ec; want GT normal error exit 0" ++assert_empty "$OUT" "F8 stdout" ++assert_file_eq_literal "$ERR" "F8 stderr" <<'EOF' ++err: Token does not have access to ASN API ++EOF ++assert_last_request "GET /AS401 auth=Bearer bad-token" ++ ++ ++ ++ ++make_config "$TMP/cfg_f9" "saved-token" ++before=$(request_count) ++run_cli "$TMP/cfg_f9" AS124 --field asn,name,registry ++[ "$ec" -eq 0 ] || fail "F9a exit $ec; want 0" ++assert_file_eq_literal "$OUT" "F9a stdout" <<'EOF' ++asn,name,registry ++AS124,Cached Network,arin ++EOF ++run_cli "$TMP/cfg_f9" AS124 --field asn,name,registry ++middle=$(request_count) ++[ "$ec" -eq 0 ] || fail "F9b exit $ec; want 0" ++assert_file_eq_literal "$OUT" "F9b stdout" <<'EOF' ++asn,name,registry ++AS124,Cached Network,arin ++EOF ++[ "$middle" -eq $((before + 1)) ] || fail "F9b did not use the cached response" ++run_cli "$TMP/cfg_f9" AS124 --nocache --field asn,name,registry ++after=$(request_count) ++[ "$ec" -eq 0 ] || fail "F9c exit $ec; want 0" ++assert_file_eq_literal "$OUT" "F9c stdout" <<'EOF' ++asn,name,registry ++AS124,Fresh Network,arin ++EOF ++[ "$after" -eq $((middle + 1)) ] || fail "F9c did not make a fresh request with --nocache" ++assert_last_request "GET /AS124 auth=Bearer saved-token" ++ ++ ++ ++ ++make_config "$TMP/cfg_f10" "" ++run_cli "$TMP/cfg_f10" --help ++[ "$ec" -eq 0 ] || fail "F10 exit $ec; want 0" ++assert_empty "$ERR" "F10 stderr" ++ ++assert_line_with_terms "$OUT" "F10 top-level help" "" "ASN" ++ ++ ++ ++ ++make_config "$TMP/cfg_f11" "" ++before=$(request_count) ++run_completion "$TMP/cfg_f11" "ipinfo AS123 --" ++after=$(request_count) ++[ "$ec" -eq 0 ] || fail "F11 exit $ec; want 0" ++[ "$after" -eq "$before" ] || fail "F11 completion made an API request" ++assert_empty "$ERR" "F11 stderr" ++assert_line "$OUT" "--token" "F11 completion" ++assert_line "$OUT" "--nocache" "F11 completion" ++assert_line "$OUT" "--field" "F11 completion" ++assert_line "$OUT" "--nocolor" "F11 completion" ++assert_line "$OUT" "--json" "F11 completion" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-001583/tests/test.sh b/tasks/format-code-task-001583/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..82ebace54a74f7cdbc6911cd4518efef4fdc783f --- /dev/null +++ b/tasks/format-code-task-001583/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/asn_api_server.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-001583/tests/test_command.sh b/tasks/format-code-task-001583/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001583/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-001584/environment/Dockerfile b/tasks/format-code-task-001584/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5b90eaf79078c0e58d54ce1a02874b7ffcb632df --- /dev/null +++ b/tasks/format-code-task-001584/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ec53180e7fede38a071b7506e6cd03025156de91f3d650cbbe905df1d74ec13c diff --git a/tasks/format-code-task-001584/environment/setup/files/blocklist b/tasks/format-code-task-001584/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001584/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001584/environment/setup/setup.sh b/tasks/format-code-task-001584/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001584/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001584/tests/test.patch b/tasks/format-code-task-001584/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7d4b6a3aa60197c0a1ef22a68963ab3bd5c95799 --- /dev/null +++ b/tasks/format-code-task-001584/tests/test.patch @@ -0,0 +1,298 @@ +diff --git a/tests/integration/test_mgmt_addressing_validation.py b/tests/integration/test_mgmt_addressing_validation.py +new file mode 100644 +index 000000000..5716f3cae +--- /dev/null ++++ b/tests/integration/test_mgmt_addressing_validation.py +@@ -0,0 +1,270 @@ ++import os ++import shlex ++import subprocess ++import tempfile ++import textwrap ++import unittest ++from pathlib import Path ++ ++ ++REPO_ROOT = Path(__file__).resolve().parents[2] ++ ++ ++def _netlab_cmd() -> list[str]: ++ ++ ++ ++ ++ ++ ++ ++ configured = os.environ.get("NETLAB_CMD") ++ if configured: ++ return shlex.split(configured) ++ return [str(REPO_ROOT / "netlab")] ++ ++ ++class MgmtAddressingValidationTest(unittest.TestCase): ++ maxDiff = None ++ ++ def run_netlab_create(self, topology: str) -> tuple[int, str, list[str]]: ++ with tempfile.TemporaryDirectory() as tmpdir: ++ workdir = Path(tmpdir) ++ topo_file = workdir / "topology.yml" ++ topo_file.write_text(textwrap.dedent(topology).lstrip(), encoding="utf-8") ++ result = subprocess.run( ++ _netlab_cmd() + ["create", "-q", str(topo_file)], ++ cwd=workdir, ++ env={**os.environ, "PYTHONPATH": str(REPO_ROOT)}, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ timeout=60, ++ ) ++ artifacts = sorted( ++ str(path.relative_to(workdir)) ++ for path in workdir.rglob("*") ++ if path.is_file() and path.name != "topology.yml" ++ ) ++ return result.returncode, result.stdout + result.stderr, artifacts ++ ++ def assert_no_provider_output(self, artifacts: list[str]) -> None: ++ provider_outputs = { ++ "clab.yml", ++ "clab-augment.yml", ++ "Vagrantfile", ++ "netlab.snapshot.yml", ++ "hosts.yml", ++ "ansible.cfg", ++ "netlab-devices.yml", ++ } ++ self.assertFalse( ++ provider_outputs.intersection(artifacts), ++ msg=f"invalid management addressing should stop before provider/automation output; got {artifacts}", ++ ) ++ ++ def assert_created_provider_output(self, artifacts: list[str], *expected: str) -> None: ++ self.assertTrue( ++ set(expected).intersection(artifacts), ++ msg=f"expected one of provider outputs {expected!r}; got {artifacts}", ++ ) ++ self.assertIn("netlab.snapshot.yml", artifacts, msg=f"expected transformed topology snapshot; got {artifacts}") ++ ++ def test_mgmt_ipv6_prefix_exception(self) -> None: ++ for prefix, addr in [ ++ ("2001:db8:42::/64", "2001:db8:42::11"), ++ ("2001:db8:60::/60", "2001:db8:60::11"), ++ ]: ++ rc, output, artifacts = self.run_netlab_create( ++ f""" ++ defaults.device: none ++ provider: clab ++ addressing.mgmt: ++ ipv4: 192.168.42.0/24 ++ ipv6: {prefix} ++ nodes: ++ mgmtv6: ++ provider: clab ++ mgmt.ipv6: {addr} ++ """ ++ ) ++ self.assertEqual(rc, 0, msg=f"management IPv6 pool {prefix} should be accepted:\n{output}") ++ self.assert_created_provider_output(artifacts, "clab.yml", "clab-augment.yml") ++ ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ addressing: ++ lan: ++ ipv6: 2001:db8:feed::/64 ++ nodes: ++ n1: ++ links: ++ - n1: ++ """ ++ ) ++ self.assertNotEqual(rc, 0, msg=f"non-management IPv6 /64 pool should still fail:\n{output}") ++ self.assert_no_provider_output(artifacts) ++ ++ def test_clab_accepts_ipv6_management_address(self) -> None: ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ provider: clab ++ addressing.mgmt: ++ ipv4: 192.168.50.0/24 ++ ipv6: 2001:db8:50::/64 ++ nodes: ++ v6okc: ++ provider: clab ++ mgmt.ipv6: 2001:db8:50::22 ++ """ ++ ) ++ self.assertEqual(rc, 0, msg=f"clab IPv6-only management address inside the mgmt subnet should pass:\n{output}") ++ self.assert_created_provider_output(artifacts, "clab.yml", "clab-augment.yml") ++ ++ def test_libvirt_requires_ipv4_management_address(self) -> None: ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ provider: libvirt ++ addressing.mgmt: ++ ipv4: 192.168.51.0/24 ++ ipv6: 2001:db8:51::/64 ++ nodes: ++ v6onlylv: ++ provider: libvirt ++ mgmt.ipv6: 2001:db8:51::23 ++ dualoklv: ++ provider: libvirt ++ mgmt.ipv4: 192.168.51.24 ++ mgmt.ipv6: 2001:db8:51::24 ++ """ ++ ) ++ self.assertNotEqual(rc, 0, msg=f"IPv6-only libvirt management should fail:\n{output}") ++ self.assert_no_provider_output(artifacts) ++ ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ provider: libvirt ++ addressing.mgmt: ++ ipv4: 192.168.51.0/24 ++ ipv6: 2001:db8:51::/64 ++ nodes: ++ dualoklv: ++ provider: libvirt ++ mgmt.ipv4: 192.168.51.24 ++ mgmt.ipv6: 2001:db8:51::24 ++ """ ++ ) ++ self.assertEqual(rc, 0, msg=f"libvirt node with IPv4 management should pass:\n{output}") ++ self.assert_created_provider_output(artifacts, "Vagrantfile") ++ ++ def test_ipv6_management_requires_matching_prefix(self) -> None: ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ provider: clab ++ addressing.mgmt: ++ ipv4: 192.168.52.0/24 ++ nodes: ++ clabv6nopfx: ++ provider: clab ++ mgmt.ipv6: 2001:db8:52::25 ++ """ ++ ) ++ self.assertNotEqual(rc, 0, msg=f"IPv6 mgmt address without IPv6 mgmt pool should fail:\n{output}") ++ self.assert_no_provider_output(artifacts) ++ ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ provider: clab ++ addressing.mgmt: ++ ipv4: 192.168.52.0/24 ++ ipv6: 2001:db8:52::/64 ++ nodes: ++ clabv6ok: ++ provider: clab ++ mgmt.ipv6: 2001:db8:52::25 ++ """ ++ ) ++ self.assertEqual(rc, 0, msg=f"matching IPv6 mgmt pool should make the same node valid:\n{output}") ++ self.assert_created_provider_output(artifacts, "clab.yml", "clab-augment.yml") ++ ++ def test_management_addresses_must_be_in_subnet(self) -> None: ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ provider: clab ++ addressing.mgmt: ++ ipv4: 192.168.70.0/24 ++ ipv6: 2001:db8:70::/64 ++ nodes: ++ badv4lv: ++ provider: libvirt ++ mgmt.ipv4: 192.168.77.9 ++ okv4lv: ++ provider: libvirt ++ mgmt.ipv4: 192.168.70.10 ++ mgmt.ipv6: 2001:db8:70::10 ++ badv6c: ++ provider: clab ++ mgmt.ipv6: 2001:db8:99::9 ++ okv6c: ++ provider: clab ++ mgmt.ipv6: 2001:db8:70::11 ++ """ ++ ) ++ self.assertNotEqual(rc, 0, msg=f"out-of-subnet management addresses should fail:\n{output}") ++ self.assert_no_provider_output(artifacts) ++ ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ provider: clab ++ addressing.mgmt: ++ ipv4: 172.30.10.0/24 ++ ipv6: 2001:db8:88::/64 ++ nodes: ++ badv4b: ++ provider: libvirt ++ mgmt.ipv4: 172.30.99.9 ++ okv4b: ++ provider: libvirt ++ mgmt.ipv4: 172.30.10.12 ++ badv6b: ++ provider: clab ++ mgmt.ipv6: 2001:db8:89::12 ++ okv6b: ++ provider: clab ++ mgmt.ipv6: 2001:db8:88::12 ++ """ ++ ) ++ self.assertNotEqual(rc, 0, msg=f"second out-of-subnet management fixture should fail:\n{output}") ++ self.assert_no_provider_output(artifacts) ++ ++ rc, output, artifacts = self.run_netlab_create( ++ """ ++ defaults.device: none ++ provider: clab ++ addressing.mgmt: ++ ipv4: 172.30.10.0/24 ++ ipv6: 2001:db8:88::/64 ++ nodes: ++ okv4b: ++ provider: libvirt ++ mgmt.ipv4: 172.30.10.12 ++ okv6b: ++ provider: clab ++ mgmt.ipv6: 2001:db8:88::12 ++ """ ++ ) ++ self.assertEqual(rc, 0, msg=f"in-subnet management addresses should pass:\n{output}") ++ self.assert_created_provider_output(artifacts, "clab.yml", "clab-augment.yml") ++ self.assert_created_provider_output(artifacts, "Vagrantfile") ++ ++ ++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,17 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ cd tests ++ PYTHONPATH="../" python3 -m pytest -vvv test_transformation.py::test_error_cases ++ ;; ++ new) ++ PYTHONPATH="." python3 -m pytest -q tests/integration/test_mgmt_addressing_validation.py ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001584/tests/test.sh b/tasks/format-code-task-001584/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ae18801644b2cdd3c9df07c589972f4557c28670 --- /dev/null +++ b/tasks/format-code-task-001584/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/integration/test_mgmt_addressing_validation.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-001584/tests/test_command.sh b/tasks/format-code-task-001584/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001584/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-001710/environment/Dockerfile b/tasks/format-code-task-001710/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b18571235569c2077df5cbc05a31ed873ac35cfc --- /dev/null +++ b/tasks/format-code-task-001710/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:50bc8a3baa45c98ad0c45c46a3bc0ca0f3ef052f31aa04e79b6c1860616b53ea diff --git a/tasks/format-code-task-001710/environment/setup/files/blocklist b/tasks/format-code-task-001710/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001710/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001710/environment/setup/setup.sh b/tasks/format-code-task-001710/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001710/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001710/tests/test.patch b/tasks/format-code-task-001710/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5b82506e8cc1cc4342f9ff6ed2714e79244b9ebd --- /dev/null +++ b/tasks/format-code-task-001710/tests/test.patch @@ -0,0 +1,305 @@ +diff --git a/usercase-test-coderl/fixtures/duplicate_file_project.json b/usercase-test-coderl/fixtures/duplicate_file_project.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/duplicate_file_project.json +@@ -0,0 +1,117 @@ ++{ ++ "archiveVersion": "1", ++ "classes": {}, ++ "objectVersion": "46", ++ "rootObject": "project", ++ "objects": { ++ "0": { ++ "isa": "PBXGroup", ++ "children": [ ++ "group1" ++ ], ++ "sourceTree": "" ++ }, ++ "1": { ++ "isa": "PBXNativeTarget", ++ "name": "app", ++ "buildConfigurationList": "3", ++ "buildPhases": [ ++ "compile1" ++ ] ++ }, ++ "2": { ++ "isa": "PBXAggregateTarget", ++ "name": "report", ++ "buildConfigurationList": "4", ++ "buildPhases": [ ++ "compile" ++ ] ++ }, ++ "3": { ++ "isa": "XCConfigurationList", ++ "buildConfigurations": [ ++ "5", ++ "6" ++ ] ++ }, ++ "4": { ++ "isa": "XCConfigurationList", ++ "buildConfigurations": [ ++ "7", ++ "8" ++ ] ++ }, ++ "5": { ++ "isa": "XCBuildConfiguration", ++ "name": "Release", ++ "buildSettings": { ++ "base": "a" ++ } ++ }, ++ "6": { ++ "isa": "XCBuildConfiguration", ++ "name": "Debug", ++ "id": "6" ++ }, ++ "7": { ++ "isa": "XCBuildConfiguration", ++ "name": "Release", ++ "id": "7" ++ }, ++ "8": { ++ "isa": "XCBuildConfiguration", ++ "name": "Debug", ++ "id": "8" ++ }, ++ "group1": { ++ "isa": "PBXGroup", ++ "name": "root", ++ "children": [ ++ "group2", ++ "group3" ++ ] ++ }, ++ "group2": { ++ "isa": "PBXGroup", ++ "name": "app", ++ "children": [ ++ "file_existing" ++ ] ++ }, ++ "group3": { ++ "isa": "PBXGroup", ++ "name": "report", ++ "children": [] ++ }, ++ "file_existing": { ++ "isa": "PBXFileReference", ++ "name": "file.m", ++ "path": "Sources/file.m", ++ "sourceTree": "SOURCE_ROOT", ++ "lastKnownFileType": "sourcecode.c.objc" ++ }, ++ "build_existing_app": { ++ "isa": "PBXBuildFile", ++ "fileRef": "file_existing" ++ }, ++ "compile1": { ++ "isa": "PBXSourcesBuildPhase", ++ "files": [ ++ "build_existing_app" ++ ] ++ }, ++ "compile": { ++ "isa": "PBXSourcesBuildPhase", ++ "files": [] ++ }, ++ "project": { ++ "isa": "PBXProject", ++ "buildConfigurationList": "3", ++ "targets": [ ++ "1", ++ "2" ++ ], ++ "mainGroup": "0" ++ } ++ } ++} +diff --git a/usercase-test-coderl/test_duplicate_safe_add_file.py b/usercase-test-coderl/test_duplicate_safe_add_file.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_duplicate_safe_add_file.py +@@ -0,0 +1,152 @@ ++import json ++import plistlib ++ ++from pbxproj import XcodeProject ++ ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++ ++def _load_project(tmp_path): ++ fixture_path = f"{FIXTURES}/duplicate_file_project.json" ++ project_data = json.loads(open(fixture_path, encoding="utf-8").read()) ++ tmp_path.mkdir(parents=True, exist_ok=True) ++ project_path = tmp_path / "project.pbxproj" ++ with open(project_path, "wb") as project_file: ++ plistlib.dump(project_data, project_file, fmt=plistlib.FMT_BINARY) ++ return XcodeProject.load(str(project_path)) ++ ++ ++def _section_count(project, section_name): ++ return len(project.objects.get_objects_in_section(section_name)) ++ ++ ++def _target_source_paths(project, target_name): ++ target = project.get_target_by_name(target_name) ++ paths = [] ++ for phase_id in target.buildPhases: ++ phase = project.get_object(phase_id) ++ if phase.isa != "PBXSourcesBuildPhase": ++ continue ++ for build_file_id in phase.files: ++ build_file = project.get_object(build_file_id) ++ file_ref = project.get_object(build_file.fileRef) ++ paths.append(file_ref.path) ++ return paths ++ ++ ++def _file_reference_paths(project): ++ return sorted(file_ref.path for file_ref in project.objects.get_objects_in_section("PBXFileReference")) ++ ++ ++def test_duplicate_in_selected_target_returns_empty_and_keeps_existing_membership(tmp_path): ++ ++ ++ ++ ++ project = _load_project(tmp_path) ++ assert _section_count(project, "PBXFileReference") == 1 ++ assert _section_count(project, "PBXBuildFile") == 1 ++ assert _target_source_paths(project, "app") == ["Sources/file.m"] ++ assert _target_source_paths(project, "report") == [] ++ ++ created = project.add_file("file.m", target_name="app", force=False) ++ ++ assert created == [] ++ assert _section_count(project, "PBXFileReference") == 1 ++ assert _section_count(project, "PBXBuildFile") == 1 ++ assert _target_source_paths(project, "app") == ["Sources/file.m"] ++ assert _target_source_paths(project, "report") == [] ++ ++ assert _file_reference_paths(project) == ["Sources/file.m"] ++ ++ ++def test_partial_duplicate_target_list_adds_only_missing_target(tmp_path): ++ ++ ++ ++ ++ project = _load_project(tmp_path) ++ ++ created = project.add_file("file.m", target_name=["app", "report"], force=False) ++ ++ assert [build_file.isa for build_file in created] == ["PBXBuildFile"] ++ ++ assert [project.get_object(build_file.fileRef).path for build_file in created] == ["file.m"] ++ assert _section_count(project, "PBXFileReference") == 2 ++ assert _section_count(project, "PBXBuildFile") == 2 ++ assert _target_source_paths(project, "app") == ["Sources/file.m"] ++ assert _target_source_paths(project, "report") == ["file.m"] ++ ++ assert _file_reference_paths(project) == ["Sources/file.m", "file.m"] ++ ++ ++def test_default_target_selection_uses_leaf_name_to_skip_only_duplicate_targets(tmp_path): ++ ++ ++ ++ ++ project = _load_project(tmp_path) ++ ++ created = project.add_file("file.m", force=False) ++ ++ assert [build_file.isa for build_file in created] == ["PBXBuildFile"] ++ assert [project.get_object(build_file.fileRef).path for build_file in created] == ["file.m"] ++ assert _section_count(project, "PBXFileReference") == 2 ++ assert _section_count(project, "PBXBuildFile") == 2 ++ assert _target_source_paths(project, "app") == ["Sources/file.m"] ++ assert _target_source_paths(project, "report") == ["file.m"] ++ ++ ++def test_loaded_project_session_supports_duplicate_safe_add_file(tmp_path): ++ ++ ++ ++ ++ project = _load_project(tmp_path) ++ ++ ++ created = project.add_file("file.m", target_name="app", force=False) ++ ++ assert created == [] ++ assert _section_count(project, "PBXFileReference") == 1 ++ assert _section_count(project, "PBXBuildFile") == 1 ++ assert _target_source_paths(project, "app") == ["Sources/file.m"] ++ ++ ++def test_duplicate_tracking_is_independent_per_loaded_project_instance(tmp_path): ++ ++ ++ ++ ++ first = _load_project(tmp_path / "first") ++ second = _load_project(tmp_path / "second") ++ ++ first_created = first.add_file("file.m", target_name=["app", "report"], force=False) ++ ++ assert [build_file.isa for build_file in first_created] == ["PBXBuildFile"] ++ assert _section_count(first, "PBXFileReference") == 2 ++ assert _section_count(first, "PBXBuildFile") == 2 ++ assert _target_source_paths(first, "app") == ["Sources/file.m"] ++ assert _target_source_paths(first, "report") == ["file.m"] ++ assert _section_count(second, "PBXFileReference") == 1 ++ assert _section_count(second, "PBXBuildFile") == 1 ++ assert _target_source_paths(second, "app") == ["Sources/file.m"] ++ assert _target_source_paths(second, "report") == [] ++ ++ ++def test_repeated_loaded_project_sessions_keep_duplicate_filtering_local(tmp_path): ++ ++ ++ ++ ++ for index in range(20): ++ project = _load_project(tmp_path / f"cycle-{index}") ++ ++ ++ created = project.add_file("file.m", target_name=["app", "report"], force=False) ++ ++ assert [build_file.isa for build_file in created] == ["PBXBuildFile"] ++ assert _section_count(project, "PBXBuildFile") == 2 ++ assert _target_source_paths(project, "app") == ["Sources/file.m"] ++ assert _target_source_paths(project, "report") == ["file.m"] +diff --git 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 PYTHONPATH="/workspace/repo" ++export PYTHONNOUSERSITE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++unset PYTEST_ADDOPTS PYTEST_PLUGINS ++export PIP_NO_INDEX=1 ++ ++python -m pytest -c /workspace/repo/pytest.ini /workspace/repo/usercase-test-coderl/test_duplicate_safe_add_file.py -v diff --git a/tasks/format-code-task-001710/tests/test.sh b/tasks/format-code-task-001710/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a11340ac810541857f06e53fbe09db75d6a6d5dc --- /dev/null +++ b/tasks/format-code-task-001710/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/duplicate_file_project.json +usercase-test-coderl/test_duplicate_safe_add_file.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001710/tests/test_command.sh b/tasks/format-code-task-001710/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001710/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-001717/environment/Dockerfile b/tasks/format-code-task-001717/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3f8ee770391324e4a47e16b8c8231bf3898cea6e --- /dev/null +++ b/tasks/format-code-task-001717/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c398e06541d4807a293ed73734f6881e1eeff75510b3b0fb4fd80af949b8c0b6 diff --git a/tasks/format-code-task-001717/environment/setup/files/blocklist b/tasks/format-code-task-001717/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001717/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001717/environment/setup/setup.sh b/tasks/format-code-task-001717/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001717/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001717/tests/test.patch b/tasks/format-code-task-001717/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..71b67cfa1f9085a26e98b632d58f47168da14211 --- /dev/null +++ b/tasks/format-code-task-001717/tests/test.patch @@ -0,0 +1,226 @@ +diff --git a/pkg/scheme/core/v1/pending_operation_test.go b/pkg/scheme/core/v1/pending_operation_test.go +new file mode 100644 +index 0000000..4f7b9c5 +--- /dev/null ++++ b/pkg/scheme/core/v1/pending_operation_test.go +@@ -0,0 +1,200 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package v1 ++ ++import ( ++ "reflect" ++ "testing" ++) ++ ++func ids(c *Cluster) []string { ++ out := make([]string, 0, len(c.PendingOperations)) ++ for _, op := range c.PendingOperations { ++ out = append(out, op.OperationID) ++ } ++ return out ++} ++ ++func TestAddPendingOperation_AppendsInOrder(t *testing.T) { ++ c := &Cluster{} ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: "AddNodes", Nodes: []string{"n1"}}); err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "b", OperationType: "RemoveNodes"}); err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "c", OperationType: "BackupCluster"}); err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ if got, want := ids(c), []string{"a", "b", "c"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("queue order = %v, want %v", got, want) ++ } ++ ++ first := c.PendingOperations[0] ++ if first.OperationType != "AddNodes" || !reflect.DeepEqual(first.Nodes, []string{"n1"}) { ++ t.Fatalf("first entry not preserved: %+v", first) ++ } ++} ++ ++func TestAddPendingOperation_RejectsEmptyType(t *testing.T) { ++ c := &Cluster{} ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: ""}); err == nil { ++ t.Fatalf("expected error for empty operation type, got nil") ++ } ++ if len(c.PendingOperations) != 0 { ++ t.Fatalf("queue must be unchanged on rejection, got %v", ids(c)) ++ } ++} ++ ++func TestAddPendingOperation_RejectsSameTypeConcurrent(t *testing.T) { ++ c := &Cluster{} ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: "AddNodes"}); err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ err := c.AddPendingOperation(PendingOperation{OperationID: "b", OperationType: "AddNodes"}) ++ if err == nil { ++ t.Fatalf("expected error when queuing a second operation of the same type") ++ } ++ ++ if got, want := ids(c), []string{"a"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("queue after rejected enqueue = %v, want %v", got, want) ++ } ++} ++ ++func TestAddPendingOperation_DifferentTypesCoexist(t *testing.T) { ++ c := &Cluster{} ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: "AddNodes"}); err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "b", OperationType: "RemoveNodes"}); err != nil { ++ t.Fatalf("unexpected error for different type: %v", err) ++ } ++ if got, want := ids(c), []string{"a", "b"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("queue = %v, want %v", got, want) ++ } ++} ++ ++func TestNextPendingOperation_EmptyQueue(t *testing.T) { ++ c := &Cluster{} ++ op, ok := c.NextPendingOperation() ++ if ok { ++ t.Fatalf("expected ok=false on empty queue, got op=%+v", op) ++ } ++ if !reflect.DeepEqual(op, PendingOperation{}) { ++ t.Fatalf("expected zero value on empty queue, got %+v", op) ++ } ++} ++ ++func TestNextPendingOperation_ReturnsOldestWithoutMutating(t *testing.T) { ++ c := &Cluster{} ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: "AddNodes"}) ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "b", OperationType: "RemoveNodes"}) ++ ++ op, ok := c.NextPendingOperation() ++ if !ok { ++ t.Fatalf("expected ok=true, got false") ++ } ++ if op.OperationID != "a" { ++ t.Fatalf("expected oldest operation 'a', got %q", op.OperationID) ++ } ++ ++ op2, ok2 := c.NextPendingOperation() ++ if !ok2 || op2.OperationID != "a" { ++ t.Fatalf("peek mutated the queue: second peek = %+v ok=%v", op2, ok2) ++ } ++ if got, want := ids(c), []string{"a", "b"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("queue changed after peek = %v, want %v", got, want) ++ } ++} ++ ++func TestRemovePendingOperation_PreservesOrder(t *testing.T) { ++ c := &Cluster{} ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: "AddNodes"}) ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "b", OperationType: "RemoveNodes"}) ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "c", OperationType: "BackupCluster"}) ++ ++ c.RemovePendingOperation("b") ++ if got, want := ids(c), []string{"a", "c"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("queue after remove = %v, want %v", got, want) ++ } ++ ++ ++ c.RemovePendingOperation("a") ++ op, ok := c.NextPendingOperation() ++ if !ok || op.OperationID != "c" { ++ t.Fatalf("expected next to be 'c' after removals, got %+v ok=%v", op, ok) ++ } ++} ++ ++func TestRemovePendingOperation_Idempotent(t *testing.T) { ++ c := &Cluster{} ++ ++ c.RemovePendingOperation("missing") ++ if len(c.PendingOperations) != 0 { ++ t.Fatalf("expected empty queue, got %v", ids(c)) ++ } ++ ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: "AddNodes"}) ++ c.RemovePendingOperation("does-not-exist") ++ if got, want := ids(c), []string{"a"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("removing absent id changed queue = %v, want %v", got, want) ++ } ++} ++ ++func TestRemoveThenReAddSameType(t *testing.T) { ++ c := &Cluster{} ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: "AddNodes"}); err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ c.RemovePendingOperation("a") ++ ++ if err := c.AddPendingOperation(PendingOperation{OperationID: "b", OperationType: "AddNodes"}); err != nil { ++ t.Fatalf("expected re-add of same type after removal to succeed, got %v", err) ++ } ++ if got, want := ids(c), []string{"b"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("queue = %v, want %v", got, want) ++ } ++} ++ ++func TestPendingOperationsDeepCopyIsIndependent(t *testing.T) { ++ c := &Cluster{} ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "a", OperationType: "AddNodes", Nodes: []string{"n1"}}) ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "b", OperationType: "RemoveNodes"}) ++ ++ cp := c.DeepCopy() ++ if got, want := ids(cp), []string{"a", "b"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("deep copy queue = %v, want %v", got, want) ++ } ++ ++ ++ c.RemovePendingOperation("a") ++ _ = c.AddPendingOperation(PendingOperation{OperationID: "c", OperationType: "BackupCluster"}) ++ if got, want := ids(cp), []string{"a", "b"}; !reflect.DeepEqual(got, want) { ++ t.Fatalf("deep copy was affected by mutation of original = %v, want %v", got, want) ++ } ++ ++ ++ c2 := &Cluster{} ++ _ = c2.AddPendingOperation(PendingOperation{OperationID: "x", OperationType: "AddNodes", Nodes: []string{"n1"}}) ++ cp2 := c2.DeepCopy() ++ c2.PendingOperations[0].Nodes[0] = "mutated" ++ if cp2.PendingOperations[0].Nodes[0] != "n1" { ++ t.Fatalf("deep copy shares nested Nodes slice with original") ++ } ++} +diff --git 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 ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++go test -count=1 ./pkg/scheme/core/v1/k8s/ ./pkg/scheme/core/v1/cni/ ++ ++ ++go test -count=1 ./pkg/scheme/core/v1/ diff --git a/tasks/format-code-task-001717/tests/test.sh b/tasks/format-code-task-001717/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c9faa443980012368177709417df5469012052b0 --- /dev/null +++ b/tasks/format-code-task-001717/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/scheme/core/v1/pending_operation_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-001717/tests/test_command.sh b/tasks/format-code-task-001717/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001717/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001719/environment/Dockerfile b/tasks/format-code-task-001719/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c891030b988fc755ca4a572dc6425c8257e74dfd --- /dev/null +++ b/tasks/format-code-task-001719/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:002703802bd1b047a20ca7f80b4584e4a3a6563720eb7e5ea56361c6747f0276 diff --git a/tasks/format-code-task-001719/environment/setup/files/blocklist b/tasks/format-code-task-001719/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001719/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001719/environment/setup/setup.sh b/tasks/format-code-task-001719/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001719/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001719/tests/test.patch b/tasks/format-code-task-001719/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..49e6dcca6d39c45451245059be2197ba774e0094 --- /dev/null +++ b/tasks/format-code-task-001719/tests/test.patch @@ -0,0 +1,869 @@ +diff --git a/cmd/conformance-tester/pkg/tests/conformance.go b/cmd/conformance-tester/pkg/tests/conformance.go +index abb340d9872..1afd6afe043 100644 +--- a/cmd/conformance-tester/pkg/tests/conformance.go ++++ b/cmd/conformance-tester/pkg/tests/conformance.go +@@ -37,7 +37,7 @@ import ( + "k8c.io/kubermatic/v2/cmd/conformance-tester/pkg/types" + "k8c.io/kubermatic/v2/cmd/conformance-tester/pkg/util" + "k8c.io/kubermatic/v2/pkg/util/wait" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + corev1 "k8s.io/api/core/v1" +diff --git a/pkg/clusterdeletion/deletion_test.go b/pkg/clusterdeletion/deletion_test.go +index 05ee6a44546..6ffa10e09fc 100644 +--- a/pkg/clusterdeletion/deletion_test.go ++++ b/pkg/clusterdeletion/deletion_test.go +@@ -26,7 +26,7 @@ import ( + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" + kubermaticlog "k8c.io/kubermatic/v2/pkg/log" + "k8c.io/kubermatic/v2/pkg/test/fake" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" +diff --git a/pkg/controller/master-controller-manager/external-cluster/cluster_controller_test.go b/pkg/controller/master-controller-manager/external-cluster/cluster_controller_test.go +index fb95a879ac9..557a66f2899 100644 +--- a/pkg/controller/master-controller-manager/external-cluster/cluster_controller_test.go ++++ b/pkg/controller/master-controller-manager/external-cluster/cluster_controller_test.go +@@ -25,7 +25,7 @@ import ( + kubermaticlog "k8c.io/kubermatic/v2/pkg/log" + "k8c.io/kubermatic/v2/pkg/resources" + "k8c.io/kubermatic/v2/pkg/test/fake" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" +diff --git a/pkg/controller/seed-controller-manager/cluster-credentials-controller/controller_test.go b/pkg/controller/seed-controller-manager/cluster-credentials-controller/controller_test.go +index e26a8d2383d..ebb29ac9358 100644 +--- a/pkg/controller/seed-controller-manager/cluster-credentials-controller/controller_test.go ++++ b/pkg/controller/seed-controller-manager/cluster-credentials-controller/controller_test.go +@@ -26,7 +26,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/test/diff" + "k8c.io/kubermatic/v2/pkg/test/fake" + "k8c.io/kubermatic/v2/pkg/version/kubermatic" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +diff --git a/pkg/controller/seed-controller-manager/cni-application-installation-controller/controller_test.go b/pkg/controller/seed-controller-manager/cni-application-installation-controller/controller_test.go +index 81d500db0e9..7dc594e6562 100644 +--- a/pkg/controller/seed-controller-manager/cni-application-installation-controller/controller_test.go ++++ b/pkg/controller/seed-controller-manager/cni-application-installation-controller/controller_test.go +@@ -32,7 +32,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/resources" + "k8c.io/kubermatic/v2/pkg/test/fake" + "k8c.io/kubermatic/v2/pkg/version/kubermatic" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +diff --git a/pkg/controller/seed-controller-manager/default-application-controller/controller_test.go b/pkg/controller/seed-controller-manager/default-application-controller/controller_test.go +index b927475b968..c0b85e0e23c 100644 +--- a/pkg/controller/seed-controller-manager/default-application-controller/controller_test.go ++++ b/pkg/controller/seed-controller-manager/default-application-controller/controller_test.go +@@ -33,7 +33,7 @@ import ( + kubermatictest "k8c.io/kubermatic/v2/pkg/test" + "k8c.io/kubermatic/v2/pkg/test/fake" + "k8c.io/kubermatic/v2/pkg/version/kubermatic" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +diff --git a/pkg/controller/seed-controller-manager/initial-application-installation-controller/controller_test.go b/pkg/controller/seed-controller-manager/initial-application-installation-controller/controller_test.go +index 9a85797993c..dbbdfc6cdbb 100644 +--- a/pkg/controller/seed-controller-manager/initial-application-installation-controller/controller_test.go ++++ b/pkg/controller/seed-controller-manager/initial-application-installation-controller/controller_test.go +@@ -32,7 +32,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/defaulting" + "k8c.io/kubermatic/v2/pkg/test/fake" + "k8c.io/kubermatic/v2/pkg/version/kubermatic" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +diff --git a/pkg/controller/seed-controller-manager/initial-machinedeployment-controller/controller_test.go b/pkg/controller/seed-controller-manager/initial-machinedeployment-controller/controller_test.go +index 12fd5d6230a..2f3a70bdf41 100644 +--- a/pkg/controller/seed-controller-manager/initial-machinedeployment-controller/controller_test.go ++++ b/pkg/controller/seed-controller-manager/initial-machinedeployment-controller/controller_test.go +@@ -34,7 +34,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/resources" + "k8c.io/kubermatic/v2/pkg/test/fake" + "k8c.io/kubermatic/v2/pkg/version/kubermatic" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" +diff --git a/pkg/controller/user-cluster-controller-manager/ccm-csi-migrator/controller_test.go b/pkg/controller/user-cluster-controller-manager/ccm-csi-migrator/controller_test.go +index f0c71a60f9e..f346cbcf9d4 100644 +--- a/pkg/controller/user-cluster-controller-manager/ccm-csi-migrator/controller_test.go ++++ b/pkg/controller/user-cluster-controller-manager/ccm-csi-migrator/controller_test.go +@@ -25,8 +25,8 @@ import ( + kubermaticlog "k8c.io/kubermatic/v2/pkg/log" + "k8c.io/kubermatic/v2/pkg/test/fake" + "k8c.io/kubermatic/v2/pkg/version/kubermatic" +- "k8c.io/machine-controller/pkg/apis/cluster/common" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ "k8c.io/machine-controller/sdk/apis/cluster/common" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +diff --git a/pkg/controller/user-cluster-controller-manager/ipam/controller_test.go b/pkg/controller/user-cluster-controller-manager/ipam/controller_test.go +index 22ef6f7d5af..e8bbf454105 100644 +--- a/pkg/controller/user-cluster-controller-manager/ipam/controller_test.go ++++ b/pkg/controller/user-cluster-controller-manager/ipam/controller_test.go +@@ -27,8 +27,8 @@ import ( + + kubermaticlog "k8c.io/kubermatic/v2/pkg/log" + "k8c.io/kubermatic/v2/pkg/test/fake" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" ++ "k8c.io/machine-controller/sdk/providerconfig" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +diff --git a/pkg/controller/user-cluster-controller-manager/kubevirt-vmi-eviction/controller_test.go b/pkg/controller/user-cluster-controller-manager/kubevirt-vmi-eviction/controller_test.go +index 3af7b545c15..8c134b0116b 100644 +--- a/pkg/controller/user-cluster-controller-manager/kubevirt-vmi-eviction/controller_test.go ++++ b/pkg/controller/user-cluster-controller-manager/kubevirt-vmi-eviction/controller_test.go +@@ -24,7 +24,7 @@ import ( + + kubermaticlog "k8c.io/kubermatic/v2/pkg/log" + "k8c.io/kubermatic/v2/pkg/test/fake" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +diff --git a/pkg/ee/resource-usage-controller/controller_test.go b/pkg/ee/resource-usage-controller/controller_test.go +index ff303d65893..2ceb1263690 100644 +--- a/pkg/ee/resource-usage-controller/controller_test.go ++++ b/pkg/ee/resource-usage-controller/controller_test.go +@@ -34,7 +34,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/test/diff" + "k8c.io/kubermatic/v2/pkg/test/fake" + "k8c.io/kubermatic/v2/pkg/test/generator" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + "k8s.io/apimachinery/pkg/api/resource" + "k8s.io/apimachinery/pkg/types" +diff --git a/pkg/ee/validation/machine/providers_test.go b/pkg/ee/validation/machine/providers_test.go +index 5bbcf427390..e24e84dbc48 100644 +--- a/pkg/ee/validation/machine/providers_test.go ++++ b/pkg/ee/validation/machine/providers_test.go +@@ -29,8 +29,8 @@ import ( + "encoding/json" + "testing" + +- vmwareclouddirectortypes "k8c.io/machine-controller/pkg/cloudprovider/provider/vmwareclouddirector/types" +- "k8c.io/machine-controller/pkg/providerconfig/types" ++ vmwareclouddirectortypes "k8c.io/machine-controller/sdk/cloudprovider/vmwareclouddirector" ++ "k8c.io/machine-controller/sdk/providerconfig" + + "k8s.io/apimachinery/pkg/runtime" + ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client" +@@ -43,21 +43,21 @@ type MockCtrlRuntimeClient struct { + func TestGetVMwareCloudDirectorResourceRequirements(t *testing.T) { + testCases := []struct { + name string +- config *types.Config ++ config *providerconfig.Config + expectedErr bool + }{ + { + name: "valid VMware configuration", +- config: &types.Config{ +- CloudProvider: types.CloudProviderVMwareCloudDirector, ++ config: &providerconfig.Config{ ++ CloudProvider: providerconfig.CloudProviderVMwareCloudDirector, + CloudProviderSpec: genFakeVMWareSpec(4, 2048, 20), + }, + expectedErr: false, + }, + { + name: "Should fail with DiskSize not defined", +- config: &types.Config{ +- CloudProvider: types.CloudProviderVMwareCloudDirector, ++ config: &providerconfig.Config{ ++ CloudProvider: providerconfig.CloudProviderVMwareCloudDirector, + CloudProviderSpec: genFakeVMWareSpec(4, 2048, 0), + }, + expectedErr: true, +diff --git a/pkg/ee/validation/machine/resourcequota_test.go b/pkg/ee/validation/machine/resourcequota_test.go +index fb7f78a3f7a..ed8aa2285b7 100644 +--- a/pkg/ee/validation/machine/resourcequota_test.go ++++ b/pkg/ee/validation/machine/resourcequota_test.go +@@ -33,7 +33,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/ee/validation/machine" + kubermaticlog "k8c.io/kubermatic/v2/pkg/log" + "k8c.io/kubermatic/v2/pkg/test/generator" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + + "k8s.io/apimachinery/pkg/api/resource" + ) +diff --git a/pkg/machine/operatingsystem/builders_test.go b/pkg/machine/operatingsystem/builders_test.go +index f7894317bc6..66aabfc839e 100644 +--- a/pkg/machine/operatingsystem/builders_test.go ++++ b/pkg/machine/operatingsystem/builders_test.go +@@ -21,7 +21,7 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + func TestDefaultSpec(t *testing.T) { +diff --git a/pkg/machine/provider/alibaba_test.go b/pkg/machine/provider/alibaba_test.go +index 853ac0858a2..faaf15228dc 100644 +--- a/pkg/machine/provider/alibaba_test.go ++++ b/pkg/machine/provider/alibaba_test.go +@@ -20,7 +20,7 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- alibaba "k8c.io/machine-controller/pkg/cloudprovider/provider/alibaba/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/alibaba" + ) + + func TestAlibabaConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/anexia_test.go b/pkg/machine/provider/anexia_test.go +index 979bd8d45a9..e953a925cc9 100644 +--- a/pkg/machine/provider/anexia_test.go ++++ b/pkg/machine/provider/anexia_test.go +@@ -20,7 +20,7 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- anexia "k8c.io/machine-controller/pkg/cloudprovider/provider/anexia/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/anexia" + ) + + func TestAnexiaConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/aws_test.go b/pkg/machine/provider/aws_test.go +index 690fc6739e3..2eb1482935f 100644 +--- a/pkg/machine/provider/aws_test.go ++++ b/pkg/machine/provider/aws_test.go +@@ -20,8 +20,8 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- aws "k8c.io/machine-controller/pkg/cloudprovider/provider/aws/types" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/aws" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + func TestAWSConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/azure_test.go b/pkg/machine/provider/azure_test.go +index 64c8dbfba6c..42ec23b5da9 100644 +--- a/pkg/machine/provider/azure_test.go ++++ b/pkg/machine/provider/azure_test.go +@@ -20,8 +20,8 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- azure "k8c.io/machine-controller/pkg/cloudprovider/provider/azure/types" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/azure" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + func TestAzureConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/digitalocean_test.go b/pkg/machine/provider/digitalocean_test.go +index a15d80ce737..882ed4a003b 100644 +--- a/pkg/machine/provider/digitalocean_test.go ++++ b/pkg/machine/provider/digitalocean_test.go +@@ -21,7 +21,7 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- digitalocean "k8c.io/machine-controller/pkg/cloudprovider/provider/digitalocean/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/digitalocean" + ) + + func TestDigitaloceanConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/equinixmetal_test.go b/pkg/machine/provider/equinixmetal_test.go +index cacc06dbde6..14f04cd4fd7 100644 +--- a/pkg/machine/provider/equinixmetal_test.go ++++ b/pkg/machine/provider/equinixmetal_test.go +@@ -21,7 +21,7 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- equinixmetal "k8c.io/machine-controller/pkg/cloudprovider/provider/equinixmetal/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/equinixmetal" + ) + + func TestEquinixMetalConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/gcp_test.go b/pkg/machine/provider/gcp_test.go +index ab4706ea06d..ad972b8bce5 100644 +--- a/pkg/machine/provider/gcp_test.go ++++ b/pkg/machine/provider/gcp_test.go +@@ -21,7 +21,7 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- gce "k8c.io/machine-controller/pkg/cloudprovider/provider/gce/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/gce" + ) + + func TestGCPConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/hetzner_test.go b/pkg/machine/provider/hetzner_test.go +index af1425c899b..9ad9ffd644d 100644 +--- a/pkg/machine/provider/hetzner_test.go ++++ b/pkg/machine/provider/hetzner_test.go +@@ -20,7 +20,7 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- hetzner "k8c.io/machine-controller/pkg/cloudprovider/provider/hetzner/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/hetzner" + ) + + func TestHetznerConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/kubevirt_test.go b/pkg/machine/provider/kubevirt_test.go +index 87ec45b2a45..593c456be52 100644 +--- a/pkg/machine/provider/kubevirt_test.go ++++ b/pkg/machine/provider/kubevirt_test.go +@@ -20,7 +20,7 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- kubevirt "k8c.io/machine-controller/pkg/cloudprovider/provider/kubevirt/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/kubevirt" + ) + + func TestKubevirtConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/nutanix_test.go b/pkg/machine/provider/nutanix_test.go +index 2b147b9d854..3ae17547d2e 100644 +--- a/pkg/machine/provider/nutanix_test.go ++++ b/pkg/machine/provider/nutanix_test.go +@@ -21,8 +21,8 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- nutanix "k8c.io/machine-controller/pkg/cloudprovider/provider/nutanix/types" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/nutanix" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + func TestNutanixConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/openstack_test.go b/pkg/machine/provider/openstack_test.go +index ad7c834df38..2613086f58d 100644 +--- a/pkg/machine/provider/openstack_test.go ++++ b/pkg/machine/provider/openstack_test.go +@@ -21,8 +21,8 @@ import ( + "time" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- openstack "k8c.io/machine-controller/pkg/cloudprovider/provider/openstack/types" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/openstack" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + func TestOpenstackConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/vmware_cloud_director_test.go b/pkg/machine/provider/vmware_cloud_director_test.go +index 53eb3d9888b..f5645dc97c1 100644 +--- a/pkg/machine/provider/vmware_cloud_director_test.go ++++ b/pkg/machine/provider/vmware_cloud_director_test.go +@@ -20,8 +20,8 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- vmwareclouddirector "k8c.io/machine-controller/pkg/cloudprovider/provider/vmwareclouddirector/types" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/vmwareclouddirector" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + func TestVMwareCloudDirectorConfigBuilder(t *testing.T) { +diff --git a/pkg/machine/provider/vsphere_test.go b/pkg/machine/provider/vsphere_test.go +index 44a1f531c83..c7cd503e7b0 100644 +--- a/pkg/machine/provider/vsphere_test.go ++++ b/pkg/machine/provider/vsphere_test.go +@@ -20,8 +20,8 @@ import ( + "testing" + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" +- vsphere "k8c.io/machine-controller/pkg/cloudprovider/provider/vsphere/types" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/cloudprovider/vsphere" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + func TestVSphereConfigBuilder(t *testing.T) { +diff --git a/pkg/provider/cloud/openstack/provider_test.go b/pkg/provider/cloud/openstack/provider_test.go +index bc67f0b7796..562f52896c1 100644 +--- a/pkg/provider/cloud/openstack/provider_test.go ++++ b/pkg/provider/cloud/openstack/provider_test.go +@@ -32,7 +32,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/resources" + "k8c.io/kubermatic/v2/pkg/resources/test" + "k8c.io/kubermatic/v2/pkg/test/diff" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +diff --git a/pkg/provider/cloud/vsphere/provider_test.go b/pkg/provider/cloud/vsphere/provider_test.go +index 69407824fd9..226acc4c45b 100644 +--- a/pkg/provider/cloud/vsphere/provider_test.go ++++ b/pkg/provider/cloud/vsphere/provider_test.go +@@ -26,7 +26,7 @@ import ( + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" + "k8c.io/kubermatic/v2/pkg/provider" + "k8c.io/kubermatic/v2/pkg/resources" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + const ( +diff --git a/pkg/provider/types_test.go b/pkg/provider/types_test.go +index 4d16bdd5ad2..0edde2e349a 100644 +--- a/pkg/provider/types_test.go ++++ b/pkg/provider/types_test.go +@@ -21,7 +21,7 @@ import ( + "testing" + + "k8c.io/kubermatic/v2/pkg/test/fake" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +diff --git a/pkg/resources/credentials_test.go b/pkg/resources/credentials_test.go +index 8edcde87231..f4363e27d87 100644 +--- a/pkg/resources/credentials_test.go ++++ b/pkg/resources/credentials_test.go +@@ -22,7 +22,7 @@ import ( + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" + "k8c.io/kubermatic/v2/pkg/resources/test" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + + corev1 "k8s.io/api/core/v1" + ) +diff --git a/pkg/resources/test/globalsecretkeyselector_helper.go b/pkg/resources/test/globalsecretkeyselector_helper.go +index c1df43e6de4..83b51101407 100644 +--- a/pkg/resources/test/globalsecretkeyselector_helper.go ++++ b/pkg/resources/test/globalsecretkeyselector_helper.go +@@ -19,7 +19,7 @@ package test + import ( + "fmt" + +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + ) + + // mock that raises an error when try to read secret. +diff --git a/pkg/resources/test/load_files_test.go b/pkg/resources/test/load_files_test.go +index 3feeb6a97f1..96d94a03939 100644 +--- a/pkg/resources/test/load_files_test.go ++++ b/pkg/resources/test/load_files_test.go +@@ -46,7 +46,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/test/generator" + "k8c.io/kubermatic/v2/pkg/version" + "k8c.io/kubermatic/v2/pkg/version/kubermatic" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + "k8c.io/reconciler/pkg/reconciling" + + appsv1 "k8s.io/api/apps/v1" +diff --git a/pkg/test/dualstack/cloud_providers.go b/pkg/test/dualstack/cloud_providers.go +index 91e733f19a2..31080ef9bcf 100644 +--- a/pkg/test/dualstack/cloud_providers.go ++++ b/pkg/test/dualstack/cloud_providers.go +@@ -26,9 +26,9 @@ import ( + + kubermaticv1 "k8c.io/kubermatic/sdk/v2/apis/kubermatic/v1" + "k8c.io/kubermatic/v2/pkg/test/e2e/jig" +- alibabatypes "k8c.io/machine-controller/pkg/cloudprovider/provider/alibaba/types" +- awstypes "k8c.io/machine-controller/pkg/cloudprovider/provider/aws/types" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ alibabatypes "k8c.io/machine-controller/sdk/cloudprovider/alibaba" ++ awstypes "k8c.io/machine-controller/sdk/cloudprovider/aws" ++ "k8c.io/machine-controller/sdk/providerconfig" + "k8c.io/operating-system-manager/pkg/providerconfig/rhel" + + "k8s.io/utils/ptr" +diff --git a/pkg/test/dualstack/cloud_providers_dualstack_test.go b/pkg/test/dualstack/cloud_providers_dualstack_test.go +index 10f0a03fdf4..d5fea311399 100644 +--- a/pkg/test/dualstack/cloud_providers_dualstack_test.go ++++ b/pkg/test/dualstack/cloud_providers_dualstack_test.go +@@ -33,8 +33,8 @@ import ( + "k8c.io/kubermatic/v2/pkg/test/e2e/jig" + "k8c.io/kubermatic/v2/pkg/test/e2e/utils" + "k8c.io/kubermatic/v2/pkg/util/wait" +- "k8c.io/machine-controller/pkg/cloudprovider/util" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/net" ++ "k8c.io/machine-controller/sdk/providerconfig" + "k8c.io/operating-system-manager/pkg/providerconfig/flatcar" + "k8c.io/operating-system-manager/pkg/providerconfig/rhel" + "k8c.io/operating-system-manager/pkg/providerconfig/rockylinux" +@@ -59,7 +59,7 @@ type testCase struct { + cloudProvider kubermaticv1.ProviderType + operatingSystems []providerconfig.OperatingSystem + cni string +- ipFamily util.IPFamily ++ ipFamily net.IPFamily + skipNodes bool + skipHostNetworkPods bool + skipEgressConnectivity bool +@@ -105,7 +105,7 @@ var ( + providerconfig.OperatingSystemUbuntu, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.AlibabaCloudProvider, +@@ -113,7 +113,7 @@ var ( + providerconfig.OperatingSystemUbuntu, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.AWSCloudProvider, +@@ -124,7 +124,7 @@ var ( + providerconfig.OperatingSystemRockyLinux, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + skipNodes: true, + skipHostNetworkPods: true, + }, +@@ -137,7 +137,7 @@ var ( + providerconfig.OperatingSystemRockyLinux, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + skipNodes: true, + skipHostNetworkPods: true, + }, +@@ -150,7 +150,7 @@ var ( + providerconfig.OperatingSystemUbuntu, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.AzureCloudProvider, +@@ -161,7 +161,7 @@ var ( + providerconfig.OperatingSystemUbuntu, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.GCPCloudProvider, +@@ -169,7 +169,7 @@ var ( + providerconfig.OperatingSystemUbuntu, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + skipNodes: true, + skipHostNetworkPods: true, + }, +@@ -179,7 +179,7 @@ var ( + providerconfig.OperatingSystemUbuntu, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + skipNodes: true, + skipHostNetworkPods: true, + }, +@@ -191,7 +191,7 @@ var ( + providerconfig.OperatingSystemRHEL, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.OpenstackCloudProvider, +@@ -201,7 +201,7 @@ var ( + providerconfig.OperatingSystemRHEL, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.HetznerCloudProvider, +@@ -210,7 +210,7 @@ var ( + providerconfig.OperatingSystemRockyLinux, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.HetznerCloudProvider, +@@ -219,7 +219,7 @@ var ( + providerconfig.OperatingSystemRockyLinux, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.DigitaloceanCloudProvider, +@@ -228,7 +228,7 @@ var ( + providerconfig.OperatingSystemRockyLinux, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.DigitaloceanCloudProvider, +@@ -237,7 +237,7 @@ var ( + providerconfig.OperatingSystemRockyLinux, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + }, + { + cloudProvider: kubermaticv1.PacketCloudProvider, +@@ -247,7 +247,7 @@ var ( + providerconfig.OperatingSystemRockyLinux, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + skipNodes: true, + }, + { +@@ -258,7 +258,7 @@ var ( + providerconfig.OperatingSystemRockyLinux, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + skipNodes: true, + }, + { +@@ -267,7 +267,7 @@ var ( + providerconfig.OperatingSystemUbuntu, + }, + cni: CanalCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + skipEgressConnectivity: true, // TODO: remove once public IPv6 is available in Kubermatic DC + }, + { +@@ -276,7 +276,7 @@ var ( + providerconfig.OperatingSystemUbuntu, + }, + cni: CiliumCNI, +- ipFamily: util.IPFamilyIPv4IPv6, ++ ipFamily: net.IPFamilyIPv4IPv6, + skipEgressConnectivity: true, // TODO: remove once public IPv6 is available in Kubermatic DC + }, + } +@@ -429,7 +429,7 @@ func TestNewClusters(t *testing.T) { + WithName(fmt.Sprintf("md-%s", osName)). + WithOSSpec(osSpec). + WithNetworkConfig(&providerconfig.NetworkConfig{ +- IPFamily: util.IPFamilyIPv4IPv6, ++ IPFamily: net.IPFamilyIPv4IPv6, + }) + + // no need to keep track of machine cleanups, as KKP will delete all machines in the +diff --git a/pkg/test/dualstack/dualstack_test.go b/pkg/test/dualstack/dualstack_test.go +index bf87de5ef6c..ec4ae77bd98 100644 +--- a/pkg/test/dualstack/dualstack_test.go ++++ b/pkg/test/dualstack/dualstack_test.go +@@ -34,7 +34,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/test/e2e/utils" + "k8c.io/kubermatic/v2/pkg/util/flagopts" + "k8c.io/kubermatic/v2/pkg/util/wait" +- "k8c.io/machine-controller/pkg/cloudprovider/util" ++ "k8c.io/machine-controller/sdk/net" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" +@@ -105,10 +105,10 @@ func TestExistingCluster(t *testing.T) { + t.Fatalf("failed to create usercluster client: %s", err) + } + +- testUserCluster(t, ctx, log, userclusterClient, util.IPFamily(ipFamily), skipNodes, skipHostNetworkPods, skipEgressConnectivity) ++ testUserCluster(t, ctx, log, userclusterClient, net.IPFamily(ipFamily), skipNodes, skipHostNetworkPods, skipEgressConnectivity) + } + +-func testUserCluster(t *testing.T, ctx context.Context, log *zap.SugaredLogger, userclusterClient ctrlruntimeclient.Client, ipFamily util.IPFamily, skipNodes, skipHostNetworkPods, skipEgressConnectivity bool) { ++func testUserCluster(t *testing.T, ctx context.Context, log *zap.SugaredLogger, userclusterClient ctrlruntimeclient.Client, ipFamily net.IPFamily, skipNodes, skipHostNetworkPods, skipEgressConnectivity bool) { + log.Infow("Testing cluster", "ipfamily", ipFamily) + + // get events from user-cluster for debugging +@@ -197,7 +197,7 @@ func testUserCluster(t *testing.T, ctx context.Context, log *zap.SugaredLogger, + + switch *svc.Spec.IPFamilyPolicy { + case corev1.IPFamilyPolicySingleStack: +- if ipFamily == util.IPFamilyIPv4IPv6 { ++ if ipFamily == net.IPFamilyIPv4IPv6 { + svcLog.Infof("Skipping %q test because IP family policy is %q", ipFamily, *svc.Spec.IPFamilyPolicy) + continue + } +@@ -220,11 +220,11 @@ func testUserCluster(t *testing.T, ctx context.Context, log *zap.SugaredLogger, + log.Info("Skipping validation of egress connectivity") + } else { + switch ipFamily { +- case util.IPFamilyIPv4, util.IPFamilyUnspecified: ++ case net.IPFamilyIPv4, net.IPFamilyUnspecified: + validateEgressConnectivity(t, ctx, log, userclusterClient, 4, nNodes) +- case util.IPFamilyIPv6: ++ case net.IPFamilyIPv6: + validateEgressConnectivity(t, ctx, log, userclusterClient, 6, nNodes) +- case util.IPFamilyIPv4IPv6: ++ case net.IPFamilyIPv4IPv6: + validateEgressConnectivity(t, ctx, log, userclusterClient, 4, nNodes) + validateEgressConnectivity(t, ctx, log, userclusterClient, 6, nNodes) + } +@@ -264,13 +264,13 @@ func validateEgressConnectivity(t *testing.T, ctx context.Context, log *zap.Suga + } + } + +-func validate(t *testing.T, name string, ipFamily util.IPFamily, addrs []string) { ++func validate(t *testing.T, name string, ipFamily net.IPFamily, addrs []string) { + if !all(ipFamily, addrs) { + t.Errorf("not all addresses in %s are in IP family %q for %s", addrs, ipFamily, name) + } + } + +-func all(ipFamily util.IPFamily, addrs []string) bool { ++func all(ipFamily net.IPFamily, addrs []string) bool { + // We convert all the IPs to CIDR notation so that we can simply use CIDR + // validation functions everywhere instead of checking which function + // to use every time. +@@ -282,19 +282,19 @@ func all(ipFamily util.IPFamily, addrs []string) bool { + } + + switch ipFamily { +- case util.IPFamilyIPv4, util.IPFamilyUnspecified: ++ case net.IPFamilyIPv4, net.IPFamilyUnspecified: + for _, addr := range addrs { + if !netutils.IsIPv4CIDRString(addr) { + return false + } + } +- case util.IPFamilyIPv6: ++ case net.IPFamilyIPv6: + for _, addr := range addrs { + if !netutils.IsIPv6CIDRString(addr) { + return false + } + } +- case util.IPFamilyIPv4IPv6: ++ case net.IPFamilyIPv4IPv6: + ok, err := netutils.IsDualStackCIDRStrings(addrs) + return err == nil && ok + default: +diff --git a/pkg/test/e2e/jig/machine.go b/pkg/test/e2e/jig/machine.go +index 1d5607db049..1b41a7d6db1 100644 +--- a/pkg/test/e2e/jig/machine.go ++++ b/pkg/test/e2e/jig/machine.go +@@ -28,9 +28,9 @@ import ( + "k8c.io/kubermatic/v2/pkg/kubernetes" + "k8c.io/kubermatic/v2/pkg/machine" + "k8c.io/kubermatic/v2/pkg/util/wait" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" +- evictiontypes "k8c.io/machine-controller/pkg/node/eviction/types" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" ++ nodetypes "k8c.io/machine-controller/sdk/node" ++ "k8c.io/machine-controller/sdk/providerconfig" + "k8c.io/operating-system-manager/pkg/providerconfig/rhel" + "k8c.io/operating-system-manager/pkg/providerconfig/ubuntu" + +@@ -320,7 +320,7 @@ func (j *MachineJig) SkipEvictionForAllNodes(ctx context.Context, clusterClient + if n.Annotations == nil { + n.Annotations = map[string]string{} + } +- n.Annotations[evictiontypes.SkipEvictionAnnotationKey] = "true" ++ n.Annotations[nodetypes.SkipEvictionAnnotationKey] = "true" + return clusterClient.Update(ctx, &n) + }) + if retErr != nil { +diff --git a/pkg/test/generator/objects.go b/pkg/test/generator/objects.go +index 1981c1491c9..7a5c0f1bef7 100644 +--- a/pkg/test/generator/objects.go ++++ b/pkg/test/generator/objects.go +@@ -39,7 +39,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/provider/kubernetes" + "k8c.io/kubermatic/v2/pkg/resources" + "k8c.io/kubermatic/v2/pkg/version/kubermatic" +- clusterv1alpha1 "k8c.io/machine-controller/pkg/apis/cluster/v1alpha1" ++ clusterv1alpha1 "k8c.io/machine-controller/sdk/apis/cluster/v1alpha1" + osmv1alpha1 "k8c.io/operating-system-manager/pkg/crd/osm/v1alpha1" + + corev1 "k8s.io/api/core/v1" +diff --git a/pkg/webhook/seed/validation_test.go b/pkg/webhook/seed/validation_test.go +index bd1c7c562fc..2a1ee287006 100644 +--- a/pkg/webhook/seed/validation_test.go ++++ b/pkg/webhook/seed/validation_test.go +@@ -26,7 +26,7 @@ import ( + "k8c.io/kubermatic/v2/pkg/features" + "k8c.io/kubermatic/v2/pkg/test" + "k8c.io/kubermatic/v2/pkg/test/fake" +- providerconfig "k8c.io/machine-controller/pkg/providerconfig/types" ++ "k8c.io/machine-controller/sdk/providerconfig" + + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,13 @@ ++H4sIAAAAAAAAA+2VTW/bMAyGc86vILpLC0xx3DQJMGCnrdcdhh0HFIrEOlpkydOH2wL98aOdOHGz ++pEWLFsNQPRfbFPWaHzI9WkSl5RWaOhu8FWNiPp22V2L/2t7n0/M8n0/m+YTseT4b5wOYvllEPaIP ++3AEMnLXhMb+n1v9TRrv+B/ThStiy5EaO/PL13vFE/yfU+K7/s/xiTv2/mJ3PBjB+vRCO8877LyS0 ++jV+gHA4/wKXx0SFwrYHKUmCAiosVL9ADnYxKaYRTZYSOUpkCwtJ6hBtF1xigkYFrcvFnw8JCe7CA ++BV54OEEEGbmmWovVCfwcAowyUcpMWHNtHZ04gazZjy6rVkUbkc82fp0hw3PMfqniL3uBBh0P1q1X ++7u8Bb1WAvEnoezQQjQqt+i6ZU2OB5NqY1+G269toT4DVwISNJnzOyaxKbFKcjMe+93aqQxOyRI1B ++WdMPjBILzmpNCZW8cWI7C6N8KQqX4S0tGK7ZRuiIgEeUh7ZvdjHhUKIJiurbc3uumFGMV5VWgje5 ++MGWoWVqvH16sKvGaRx0eKL9YTFEfKck3CLNTLrlYKkPVrLS9K6mmT0tG33Sg68SBuoqSCa9YqYre ++GX22jKp4+cKtq7jAWrnA6lIxuhP7ZxUxc+htdPQRRk97jmRNfjXXSrbFzja16jt0Jls13yNNCH9H ++QZWHXCpnayUf6j9qE9pG2Sibdog84lP7aonuQWBdev6wsZ0ivZUbXCytXbXH5cBM+dpNsm6efAJr ++9B04mjU/SOryVvkm+y/rnsBpzUW00ZO79x+BRs+mW2DoBSjPSLPZ9w1vNls8KA/cbEcUOPwdlWtm ++LgetaoQmtK0M/bChzR16o2B/qPXm75HZ5oEdS2Fv4m619qvzr39niUQikUgkEolEIpFIJBKJRCKR ++SCQSiUQi8W75Az6DrFkAKAAA +diff --git 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-001719/tests/test.sh b/tasks/format-code-task-001719/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..421aaa71f17f617f09100b21061c5a0f1cd15ba3 --- /dev/null +++ b/tasks/format-code-task-001719/tests/test.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 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/conformance-tester/pkg/tests/conformance.go +pkg/clusterdeletion/deletion_test.go +pkg/controller/master-controller-manager/external-cluster/cluster_controller_test.go +pkg/controller/seed-controller-manager/cluster-credentials-controller/controller_test.go +pkg/controller/seed-controller-manager/cni-application-installation-controller/controller_test.go +pkg/controller/seed-controller-manager/default-application-controller/controller_test.go +pkg/controller/seed-controller-manager/initial-application-installation-controller/controller_test.go +pkg/controller/seed-controller-manager/initial-machinedeployment-controller/controller_test.go +pkg/controller/user-cluster-controller-manager/ccm-csi-migrator/controller_test.go +pkg/controller/user-cluster-controller-manager/ipam/controller_test.go +pkg/controller/user-cluster-controller-manager/kubevirt-vmi-eviction/controller_test.go +pkg/ee/resource-usage-controller/controller_test.go +pkg/ee/validation/machine/providers_test.go +pkg/ee/validation/machine/resourcequota_test.go +pkg/machine/operatingsystem/builders_test.go +pkg/machine/provider/alibaba_test.go +pkg/machine/provider/anexia_test.go +pkg/machine/provider/aws_test.go +pkg/machine/provider/azure_test.go +pkg/machine/provider/digitalocean_test.go +pkg/machine/provider/equinixmetal_test.go +pkg/machine/provider/gcp_test.go +pkg/machine/provider/hetzner_test.go +pkg/machine/provider/kubevirt_test.go +pkg/machine/provider/nutanix_test.go +pkg/machine/provider/openstack_test.go +pkg/machine/provider/vmware_cloud_director_test.go +pkg/machine/provider/vsphere_test.go +pkg/provider/cloud/openstack/provider_test.go +pkg/provider/cloud/vsphere/provider_test.go +pkg/provider/types_test.go +pkg/resources/credentials_test.go +pkg/resources/test/globalsecretkeyselector_helper.go +pkg/resources/test/load_files_test.go +pkg/test/dualstack/cloud_providers.go +pkg/test/dualstack/cloud_providers_dualstack_test.go +pkg/test/dualstack/dualstack_test.go +pkg/test/e2e/jig/machine.go +pkg/test/generator/objects.go +pkg/webhook/seed/validation_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-001719/tests/test_command.sh b/tasks/format-code-task-001719/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001719/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001721/environment/Dockerfile b/tasks/format-code-task-001721/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8e3327b03be0c299fe2065b3b898dc3942db222a --- /dev/null +++ b/tasks/format-code-task-001721/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5fca6ca596e1e400b86178c6e1ee4bd6504b250cdd63e7df049db78c330dadf9 diff --git a/tasks/format-code-task-001721/environment/setup/files/blocklist b/tasks/format-code-task-001721/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001721/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001721/environment/setup/setup.sh b/tasks/format-code-task-001721/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001721/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001721/tests/test.patch b/tasks/format-code-task-001721/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d5deb7d3e63a83da02740b930014a811b42d9886 --- /dev/null +++ b/tasks/format-code-task-001721/tests/test.patch @@ -0,0 +1,35 @@ +diff --git a/pkg/arn/arn_test.go b/pkg/arn/arn_test.go +index 92a60c95d..ddad56971 100644 +--- a/pkg/arn/arn_test.go ++++ b/pkg/arn/arn_test.go +@@ -16,6 +16,7 @@ var arnTests = []struct { + {"arn:aws:sts::123456789012:assumed-role/Admin/Session", "arn:aws:iam::123456789012:role/Admin", nil}, + {"arn:aws:sts::123456789012:federated-user/Bob", "arn:aws:sts::123456789012:federated-user/Bob", nil}, + {"arn:aws:iam::123456789012:root", "arn:aws:iam::123456789012:root", nil}, ++ {"arn:aws:sts::123456789012:assumed-role/Org/Team/Admin/Session", "arn:aws:iam::123456789012:role/Org/Team/Admin", nil}, + } + + func TestUserARN(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+3SPU/DMBAG4M75FYe6wJC6Lg2dGJBAZQCB+JhREruJaWJHtlPEv8cplCIk6NIK ++Ae+jSI6cs32X8yBrVSUepF6w3q4Mg0mSLMfg87h858mIj0LUaBzmOU8mkx4lO8vog9b51BL1rDH+ ++u7hN33+pwbr/Xjr/kJu6TrUYuHJ7Z2zqf3I4Xvd/yEP/x0d81KPh9lL42j/vf3+PZUqzLHVllAta ++XoJMiijq06301DY0vbo+uTsn91xXSs9pv7Eyro1oK+moseZR5iHMKV2QkA1bSC2MPYjquVCW4oZY ++9+NYYZizOSuUL9tsEC4ZK2XjlYkqTbGb6feDN8SztPWl1F7lqTe2y/Km1RQ6WIRkuy0cPYU1NDW0 ++ylEol2ZV2Hnfl8pReNIu0ziUHCbfKjiIXss8Xh0fyuacX16d3l+cHZvZjMJUtz/FC9qQFWvmBUut ++jn66twAAAAAAAAAAAAAAAAAAAADw970Art80AQAoAAA= +diff --git 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-001721/tests/test.sh b/tasks/format-code-task-001721/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b66f3d1c6765196007daad67167bf4501e4fd4c9 --- /dev/null +++ b/tasks/format-code-task-001721/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/arn/arn_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-001721/tests/test_command.sh b/tasks/format-code-task-001721/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001721/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001726/environment/Dockerfile b/tasks/format-code-task-001726/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..dfba563fa6fb9054e498c2f2bb706abe9e1c39d6 --- /dev/null +++ b/tasks/format-code-task-001726/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b6551d6b7bc4d0c925734fad3fa99f5d38aca4856e7e8e0283888d4e9905080b diff --git a/tasks/format-code-task-001726/environment/setup/files/blocklist b/tasks/format-code-task-001726/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001726/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001726/environment/setup/setup.sh b/tasks/format-code-task-001726/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001726/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001726/tests/test.patch b/tasks/format-code-task-001726/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0aea18e40dcc9ff0761dad3d9f15eda071a9560f --- /dev/null +++ b/tasks/format-code-task-001726/tests/test.patch @@ -0,0 +1,144 @@ +diff --git a/azure/services/virtualmachines/spec_spot_ephemeral_test.go b/azure/services/virtualmachines/spec_spot_ephemeral_test.go +new file mode 100644 +index 000000000..2e23a4d63 +--- /dev/null ++++ b/azure/services/virtualmachines/spec_spot_ephemeral_test.go +@@ -0,0 +1,116 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package virtualmachines ++ ++import ( ++ "testing" ++ ++ "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-11-01/compute" ++ "github.com/Azure/go-autorest/autorest/to" ++ . "github.com/onsi/gomega" ++ infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ++) ++ ++func TestParametersSpotEphemeralOSDisk(t *testing.T) { ++ g := NewWithT(t) ++ ++ spec := &VMSpec{ ++ Name: "my-vm", ++ Role: infrav1.Node, ++ NICIDs: []string{"my-nic"}, ++ SSHKeyData: "fakesshpublickey", ++ Size: "Standard_D2v3", ++ Zone: "1", ++ Image: &infrav1.Image{ID: to.StringPtr("fake-image-id")}, ++ OSDisk: infrav1.OSDisk{ ++ OSType: "Linux", ++ DiskSizeGB: to.Int32Ptr(128), ++ ManagedDisk: &infrav1.ManagedDiskParameters{ ++ StorageAccountType: "Premium_LRS", ++ }, ++ DiffDiskSettings: &infrav1.DiffDiskSettings{ ++ Option: string(compute.DiffDiskOptionsLocal), ++ }, ++ }, ++ SpotVMOptions: &infrav1.SpotVMOptions{}, ++ SKU: validSKUWithEphemeralOS, ++ } ++ ++ result, err := spec.Parameters(nil) ++ g.Expect(err).NotTo(HaveOccurred()) ++ g.Expect(result).To(BeAssignableToTypeOf(compute.VirtualMachine{})) ++ vm := result.(compute.VirtualMachine) ++ g.Expect(vm.Priority).To(Equal(compute.VirtualMachinePriorityTypesSpot)) ++ g.Expect(vm.EvictionPolicy).To(Equal(compute.VirtualMachineEvictionPolicyTypesDelete)) ++ g.Expect(vm.StorageProfile.OsDisk.DiffDiskSettings.Option).To(Equal(compute.DiffDiskOptionsLocal)) ++} ++ ++func TestParametersSpotNoEphemeralOSDisk(t *testing.T) { ++ g := NewWithT(t) ++ ++ spec := &VMSpec{ ++ Name: "my-vm", ++ Role: infrav1.Node, ++ NICIDs: []string{"my-nic"}, ++ SSHKeyData: "fakesshpublickey", ++ Size: "Standard_D2v3", ++ Zone: "1", ++ Image: &infrav1.Image{ID: to.StringPtr("fake-image-id")}, ++ SpotVMOptions: &infrav1.SpotVMOptions{}, ++ SKU: validSKU, ++ } ++ ++ result, err := spec.Parameters(nil) ++ g.Expect(err).NotTo(HaveOccurred()) ++ g.Expect(result).To(BeAssignableToTypeOf(compute.VirtualMachine{})) ++ vm := result.(compute.VirtualMachine) ++ g.Expect(vm.Priority).To(Equal(compute.VirtualMachinePriorityTypesSpot)) ++ g.Expect(vm.EvictionPolicy).To(Equal(compute.VirtualMachineEvictionPolicyTypesDeallocate)) ++} ++ ++func TestParametersEphemeralOSDiskNoSpot(t *testing.T) { ++ g := NewWithT(t) ++ ++ spec := &VMSpec{ ++ Name: "my-vm", ++ Role: infrav1.Node, ++ NICIDs: []string{"my-nic"}, ++ SSHKeyData: "fakesshpublickey", ++ Size: "Standard_D2v3", ++ Zone: "1", ++ Image: &infrav1.Image{ID: to.StringPtr("fake-image-id")}, ++ OSDisk: infrav1.OSDisk{ ++ OSType: "Linux", ++ DiskSizeGB: to.Int32Ptr(128), ++ ManagedDisk: &infrav1.ManagedDiskParameters{ ++ StorageAccountType: "Premium_LRS", ++ }, ++ DiffDiskSettings: &infrav1.DiffDiskSettings{ ++ Option: string(compute.DiffDiskOptionsLocal), ++ }, ++ }, ++ SKU: validSKUWithEphemeralOS, ++ } ++ ++ result, err := spec.Parameters(nil) ++ g.Expect(err).NotTo(HaveOccurred()) ++ g.Expect(result).To(BeAssignableToTypeOf(compute.VirtualMachine{})) ++ vm := result.(compute.VirtualMachine) ++ g.Expect(vm.Priority).To(BeEmpty()) ++ g.Expect(vm.EvictionPolicy).To(BeEmpty()) ++ g.Expect(vm.StorageProfile.OsDisk.DiffDiskSettings.Option).To(Equal(compute.DiffDiskOptionsLocal)) ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..0239d7b16 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./azure/services/virtualmachines/ -run 'TestParametersSpotEphemeralOSDisk|TestParametersSpotNoEphemeralOSDisk|TestParametersEphemeralOSDiskNoSpot' -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 ./azure/services/virtualmachines/ -run 'TestParametersSpotEphemeralOSDisk|TestParametersSpotNoEphemeralOSDisk|TestParametersEphemeralOSDiskNoSpot' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001726/tests/test.sh b/tasks/format-code-task-001726/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1dfcaf183f67ddb5eec86e4650a70dc5086f155a --- /dev/null +++ b/tasks/format-code-task-001726/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' +azure/services/virtualmachines/spec_spot_ephemeral_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-001726/tests/test_command.sh b/tasks/format-code-task-001726/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001726/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001728/environment/Dockerfile b/tasks/format-code-task-001728/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..acbc3ab3afa480c15336580cc25dff4ae3a30245 --- /dev/null +++ b/tasks/format-code-task-001728/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0291876a59cb4d47ca2ebe4b47028b49c85c10a5394c22ee1c3a221a263682ba diff --git a/tasks/format-code-task-001728/environment/setup/files/blocklist b/tasks/format-code-task-001728/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001728/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001728/environment/setup/setup.sh b/tasks/format-code-task-001728/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001728/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001728/tests/test.patch b/tasks/format-code-task-001728/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ca4a56d322368933a3f92dbc276ffb9191a0a00b --- /dev/null +++ b/tasks/format-code-task-001728/tests/test.patch @@ -0,0 +1,333 @@ +diff --git a/apis/v1beta1/validation/gateway_test.go b/apis/v1beta1/validation/gateway_test.go +index eaaafbca..05314766 100644 +--- a/apis/v1beta1/validation/gateway_test.go ++++ b/apis/v1beta1/validation/gateway_test.go +@@ -20,6 +20,7 @@ import ( + "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++ "k8s.io/apimachinery/pkg/util/validation/field" + + gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" + ) +@@ -163,3 +164,298 @@ func TestValidateGateway(t *testing.T) { + }) + } + } ++ ++ ++func hasFieldError(errs field.ErrorList, fieldPath string) bool { ++ for _, e := range errs { ++ if e.Field == fieldPath { ++ return true ++ } ++ } ++ return false ++} ++ ++ ++func countFieldErrors(errs field.ErrorList, fieldPath string) int { ++ n := 0 ++ for _, e := range errs { ++ if e.Field == fieldPath { ++ n++ ++ } ++ } ++ return n ++} ++ ++func makeGatewayWithListeners(listeners []gatewayv1b1.Listener) *gatewayv1b1.Gateway { ++ return &gatewayv1b1.Gateway{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "foo", ++ Namespace: metav1.NamespaceDefault, ++ }, ++ Spec: gatewayv1b1.GatewaySpec{ ++ GatewayClassName: "foo", ++ Listeners: listeners, ++ }, ++ } ++} ++ ++func hostnamePtr(s string) *gatewayv1b1.Hostname { ++ h := gatewayv1b1.Hostname(s) ++ return &h ++} ++ ++ ++ ++ ++func TestValidateGatewayListenerPortProtocolHostname(t *testing.T) { ++ t.Run("two listeners same hostname different ports is valid", func(t *testing.T) { ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-2", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 8080, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if hasFieldError(errs, "spec.listeners[1]") { ++ t.Errorf("expected no combination error for differing ports, got: %v", errs) ++ } ++ if hasFieldError(errs, "spec.listeners[0]") { ++ t.Errorf("expected no combination error for differing ports, got: %v", errs) ++ } ++ }) ++ ++ t.Run("two listeners different hostnames same port is valid", func(t *testing.T) { ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-2", ++ Hostname: hostnamePtr("bar.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if hasFieldError(errs, "spec.listeners[1]") { ++ t.Errorf("expected no combination error for differing hostnames, got: %v", errs) ++ } ++ if hasFieldError(errs, "spec.listeners[0]") { ++ t.Errorf("expected no combination error for differing hostnames, got: %v", errs) ++ } ++ }) ++ ++ t.Run("two listeners same hostname port protocol produces combination error on duplicate", func(t *testing.T) { ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-2", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if !hasFieldError(errs, "spec.listeners[1]") { ++ t.Errorf("expected combination error on spec.listeners[1], got: %v", errs) ++ } ++ if hasFieldError(errs, "spec.listeners[0]") { ++ t.Errorf("did not expect combination error on spec.listeners[0], got: %v", errs) ++ } ++ }) ++ ++ t.Run("two listeners with nil hostnames same port produces combination error", func(t *testing.T) { ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: nil, ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-2", ++ Hostname: nil, ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if !hasFieldError(errs, "spec.listeners[1]") { ++ t.Errorf("expected combination error on spec.listeners[1] for nil hostname dup, got: %v", errs) ++ } ++ }) ++ ++ t.Run("three listeners only the duplicate produces a combination error", func(t *testing.T) { ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-2", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-3", ++ Hostname: hostnamePtr("bar.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if !hasFieldError(errs, "spec.listeners[1]") { ++ t.Errorf("expected combination error on spec.listeners[1], got: %v", errs) ++ } ++ if hasFieldError(errs, "spec.listeners[2]") { ++ t.Errorf("did not expect combination error on spec.listeners[2], got: %v", errs) ++ } ++ if hasFieldError(errs, "spec.listeners[0]") { ++ t.Errorf("did not expect combination error on spec.listeners[0], got: %v", errs) ++ } ++ }) ++ ++ t.Run("three listeners with duplicate at later index reports on the later one only", func(t *testing.T) { ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: hostnamePtr("baz.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-2", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-3", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if !hasFieldError(errs, "spec.listeners[2]") { ++ t.Errorf("expected combination error on spec.listeners[2], got: %v", errs) ++ } ++ if hasFieldError(errs, "spec.listeners[1]") { ++ t.Errorf("did not expect combination error on spec.listeners[1], got: %v", errs) ++ } ++ if hasFieldError(errs, "spec.listeners[0]") { ++ t.Errorf("did not expect combination error on spec.listeners[0], got: %v", errs) ++ } ++ }) ++ ++ t.Run("single listener does not trigger combination error", func(t *testing.T) { ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if hasFieldError(errs, "spec.listeners[0]") { ++ t.Errorf("did not expect combination error on single listener, got: %v", errs) ++ } ++ }) ++ ++ t.Run("three distinct listeners produce no combination errors", func(t *testing.T) { ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-2", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 8080, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-3", ++ Hostname: hostnamePtr("bar.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ for _, fp := range []string{"spec.listeners[0]", "spec.listeners[1]", "spec.listeners[2]"} { ++ if hasFieldError(errs, fp) { ++ t.Errorf("did not expect combination error on %s, got: %v", fp, errs) ++ } ++ } ++ }) ++ ++ t.Run("two listeners with identical name and identical combination both fail validation", func(t *testing.T) { ++ ++ ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "same-name", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "same-name", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if !hasFieldError(errs, "spec.listeners[1].name") { ++ t.Errorf("expected duplicate-name error on spec.listeners[1].name, got: %v", errs) ++ } ++ if !hasFieldError(errs, "spec.listeners[1]") { ++ t.Errorf("expected combination error on spec.listeners[1] (duplicate port/protocol/hostname), got: %v", errs) ++ } ++ }) ++ ++ t.Run("four listeners only one combination error per duplicate index", func(t *testing.T) { ++ ++ gw := makeGatewayWithListeners([]gatewayv1b1.Listener{ ++ { ++ Name: "listener-1", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ { ++ Name: "listener-2", ++ Hostname: hostnamePtr("foo.com"), ++ Port: 80, ++ Protocol: gatewayv1b1.HTTPProtocolType, ++ }, ++ }) ++ errs := ValidateGateway(gw) ++ if c := countFieldErrors(errs, "spec.listeners[1]"); c != 1 { ++ t.Errorf("expected exactly 1 combination error on spec.listeners[1], got %d: %v", c, errs) ++ } ++ }) ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..3fc09a9f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test -run TestValidateGatewayListenerPortProtocolHostname ./apis/v1beta1/validation/..."] ++} +diff --git 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 -run TestValidateGatewayListenerPortProtocolHostname ./apis/v1beta1/validation/... ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001728/tests/test.sh b/tasks/format-code-task-001728/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..23228e3c9d95169412bb2fbbdf9e914be0a2efc6 --- /dev/null +++ b/tasks/format-code-task-001728/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' +apis/v1beta1/validation/gateway_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-001728/tests/test_command.sh b/tasks/format-code-task-001728/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001728/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001736/environment/Dockerfile b/tasks/format-code-task-001736/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7cf0f3b86b4d5fa81634cb409ed766cc206487ae --- /dev/null +++ b/tasks/format-code-task-001736/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b987289d0e5543787eab846f4900592bae321cf03720a7238381ae8e70b35820 diff --git a/tasks/format-code-task-001736/environment/setup/files/blocklist b/tasks/format-code-task-001736/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001736/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001736/environment/setup/setup.sh b/tasks/format-code-task-001736/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001736/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001736/tests/test.patch b/tasks/format-code-task-001736/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d3203055f27c7beb5120349738c3ee79203d629 --- /dev/null +++ b/tasks/format-code-task-001736/tests/test.patch @@ -0,0 +1,278 @@ +diff --git a/usercase-test-coderl/parse_timeout_test.go b/usercase-test-coderl/parse_timeout_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/parse_timeout_test.go +@@ -0,0 +1,249 @@ ++package usercase_test_coderl ++ ++ ++ ++ ++ ++ ++import ( ++ "io/fs" ++ "reflect" ++ "strings" ++ "testing" ++ "time" ++ ++ "os" ++ "path/filepath" ++ ++ "k8s.io/client-go/tools/clientcmd" ++) ++ ++func TestParseTimeoutBareZeroSeconds(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("0") ++ if err != nil { ++ t.Fatalf("ParseTimeout(\"0\") returned unexpected error: %v", err) ++ } ++ if actual != time.Duration(0) { ++ t.Fatalf("ParseTimeout(\"0\") = %v, want %v", actual, time.Duration(0)) ++ } ++} ++ ++func TestParseTimeoutBarePositiveIntegerAsSeconds(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("15") ++ if err != nil { ++ t.Fatalf("ParseTimeout(\"15\") returned unexpected error: %v", err) ++ } ++ if actual != time.Duration(15_000_000_000) { ++ t.Fatalf("ParseTimeout(\"15\") = %v, want %v", actual, time.Duration(15_000_000_000)) ++ } ++} ++ ++func TestParseTimeoutGoDurationMinutes(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("2m") ++ if err != nil { ++ t.Fatalf("ParseTimeout(\"2m\") returned unexpected error: %v", err) ++ } ++ if actual != time.Duration(120_000_000_000) { ++ t.Fatalf("ParseTimeout(\"2m\") = %v, want %v", actual, time.Duration(120_000_000_000)) ++ } ++} ++ ++func TestParseTimeoutGoDurationMilliseconds(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("1500ms") ++ if err != nil { ++ t.Fatalf("ParseTimeout(\"1500ms\") returned unexpected error: %v", err) ++ } ++ if actual != time.Duration(1_500_000_000) { ++ t.Fatalf("ParseTimeout(\"1500ms\") = %v, want %v", actual, time.Duration(1_500_000_000)) ++ } ++} ++ ++func TestParseTimeoutGoDurationCompoundFractional(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("1h2m3.5s") ++ if err != nil { ++ t.Fatalf("ParseTimeout(\"1h2m3.5s\") returned unexpected error: %v", err) ++ } ++ if actual != time.Duration(3_723_500_000_000) { ++ t.Fatalf("ParseTimeout(\"1h2m3.5s\") = %v, want %v", actual, time.Duration(3_723_500_000_000)) ++ } ++} ++ ++func TestParseTimeoutGoDurationSigned(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("-1s") ++ if err != nil { ++ t.Fatalf("ParseTimeout(\"-1s\") returned unexpected error: %v", err) ++ } ++ if actual != time.Duration(-1_000_000_000) { ++ t.Fatalf("ParseTimeout(\"-1s\") = %v, want %v", actual, time.Duration(-1_000_000_000)) ++ } ++} ++ ++func TestParseTimeoutBareNegativeIntegerIsInvalid(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("-1") ++ if actual != time.Duration(0) { ++ t.Fatalf("ParseTimeout(\"-1\") duration = %v, want %v", actual, time.Duration(0)) ++ } ++ if err == nil { ++ t.Fatal("ParseTimeout(\"-1\") returned nil error, want an error") ++ } ++ const expectedSubstring = "Invalid timeout value" ++ ++ if !strings.Contains(err.Error(), expectedSubstring) { ++ t.Fatalf("ParseTimeout(\"-1\") error = %q, want substring %q", err.Error(), expectedSubstring) ++ } ++} ++ ++func TestParseTimeoutAlphabeticInvalidInput(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("abc") ++ if actual != time.Duration(0) { ++ t.Fatalf("ParseTimeout(\"abc\") duration = %v, want %v", actual, time.Duration(0)) ++ } ++ if err == nil { ++ t.Fatal("ParseTimeout(\"abc\") returned nil error, want an error") ++ } ++ const expectedSubstring = "Invalid timeout value" ++ ++ if !strings.Contains(err.Error(), expectedSubstring) { ++ t.Fatalf("ParseTimeout(\"abc\") error = %q, want substring %q", err.Error(), expectedSubstring) ++ } ++ if !strings.Contains(err.Error(), "Invalid timeout value") { ++ t.Fatalf("ParseTimeout(\"abc\") error = %q, want substring %q", err.Error(), "Invalid timeout value") ++ } ++} ++ ++func TestParseTimeoutEmptyStringInvalidInput(t *testing.T) { ++ ++ ++ actual, err := clientcmd.ParseTimeout("") ++ if actual != time.Duration(0) { ++ t.Fatalf("ParseTimeout(\"\") duration = %v, want %v", actual, time.Duration(0)) ++ } ++ if err == nil { ++ t.Fatal("ParseTimeout(\"\") returned nil error, want an error") ++ } ++ const expectedSubstring = "Invalid timeout value" ++ ++ if !strings.Contains(err.Error(), expectedSubstring) { ++ t.Fatalf("ParseTimeout(\"\") error = %q, want substring %q", err.Error(), expectedSubstring) ++ } ++} ++ ++func TestParseTimeoutReferentialTransparency(t *testing.T) { ++ first, firstErr := clientcmd.ParseTimeout("1500ms") ++ second, secondErr := clientcmd.ParseTimeout("1500ms") ++ if first != second { ++ t.Fatalf("two ParseTimeout(\"1500ms\") calls returned %v and %v", first, second) ++ } ++ if (firstErr == nil) != (secondErr == nil) { ++ t.Fatalf("two ParseTimeout(\"1500ms\") calls returned error states %v and %v", firstErr, secondErr) ++ } ++ if firstErr != nil && firstErr.Error() != secondErr.Error() { ++ t.Fatalf("two ParseTimeout(\"1500ms\") calls returned errors %q and %q", firstErr.Error(), secondErr.Error()) ++ } ++} ++ ++func TestParseTimeoutDoesNotMutateCallerInput(t *testing.T) { ++ input := "2m" ++ before := input ++ actual, err := clientcmd.ParseTimeout(input) ++ if err != nil { ++ t.Fatalf("ParseTimeout(%q) returned unexpected error: %v", input, err) ++ } ++ if actual != time.Duration(120_000_000_000) { ++ t.Fatalf("ParseTimeout(%q) = %v, want %v", input, actual, time.Duration(120_000_000_000)) ++ } ++ if input != before { ++ t.Fatalf("ParseTimeout mutated caller input from %q to %q", before, input) ++ } ++} ++ ++func TestParseTimeoutNoGlobalStateWithNoise(t *testing.T) { ++ baseline, err := clientcmd.ParseTimeout("15") ++ if err != nil { ++ t.Fatalf("baseline ParseTimeout(\"15\") returned unexpected error: %v", err) ++ } ++ if baseline != time.Duration(15_000_000_000) { ++ t.Fatalf("baseline ParseTimeout(\"15\") = %v, want %v", baseline, time.Duration(15_000_000_000)) ++ } ++ ++ noiseCases := []string{"0", "2m", "abc", "1h2m3.5s", "-1s"} ++ for _, input := range noiseCases { ++ _, _ = clientcmd.ParseTimeout(input) ++ } ++ ++ afterNoise, err := clientcmd.ParseTimeout("15") ++ if err != nil { ++ t.Fatalf("post-noise ParseTimeout(\"15\") returned unexpected error: %v", err) ++ } ++ if afterNoise != time.Duration(15_000_000_000) { ++ t.Fatalf("post-noise ParseTimeout(\"15\") = %v, want %v", afterNoise, time.Duration(15_000_000_000)) ++ } ++} ++ ++func TestParseTimeoutDoesNotWriteInWorkingDirectory(t *testing.T) { ++ originalWD, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd failed: %v", err) ++ } ++ tempDir := t.TempDir() ++ if err := os.Chdir(tempDir); err != nil { ++ t.Fatalf("Chdir(%q) failed: %v", tempDir, err) ++ } ++ defer func() { ++ if err := os.Chdir(originalWD); err != nil { ++ t.Fatalf("restore Chdir(%q) failed: %v", originalWD, err) ++ } ++ }() ++ ++ before := snapshotDir(t, tempDir) ++ for _, input := range []string{"0", "15", "2m", "1500ms", "abc"} { ++ _, _ = clientcmd.ParseTimeout(input) ++ } ++ after := snapshotDir(t, tempDir) ++ if !reflect.DeepEqual(after, before) { ++ t.Fatalf("ParseTimeout changed working directory contents: before=%v after=%v", before, after) ++ } ++} ++ ++func snapshotDir(t *testing.T, root string) map[string]string { ++ t.Helper() ++ entries := map[string]string{} ++ err := filepath.WalkDir(root, func(path string, d fs.DirEntry, walkErr error) error { ++ if walkErr != nil { ++ return walkErr ++ } ++ if path == root { ++ return nil ++ } ++ info, err := d.Info() ++ if err != nil { ++ return err ++ } ++ rel, err := filepath.Rel(root, path) ++ if err != nil { ++ return err ++ } ++ entries[rel] = info.Mode().String() ++ return nil ++ }) ++ if err != nil { ++ t.Fatalf("snapshotDir(%q) failed: %v", root, err) ++ } ++ return entries ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOMODCACHE=/go/pkg/mod ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001736/tests/test.sh b/tasks/format-code-task-001736/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cc25358f02bbe513dda06466baf553c141a06694 --- /dev/null +++ b/tasks/format-code-task-001736/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/parse_timeout_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-001736/tests/test_command.sh b/tasks/format-code-task-001736/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001736/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-001742/environment/Dockerfile b/tasks/format-code-task-001742/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6bfddede33b8300940f79980f6a2a04791495277 --- /dev/null +++ b/tasks/format-code-task-001742/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:047fb16c1d62175efcfdaf35f37a1863b77a52e68120ef6c3e264ceef1bedf62 diff --git a/tasks/format-code-task-001742/environment/setup/files/blocklist b/tasks/format-code-task-001742/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001742/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001742/environment/setup/setup.sh b/tasks/format-code-task-001742/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001742/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001742/tests/test.patch b/tasks/format-code-task-001742/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..40b2855792f832c9b0341583d96e3c209f6a27ec --- /dev/null +++ b/tasks/format-code-task-001742/tests/test.patch @@ -0,0 +1,118 @@ +diff --git a/pkg/validation/validate_cluster_test.go b/pkg/validation/validate_cluster_test.go +index fb32e76b21434..8829148876782 100644 +--- a/pkg/validation/validate_cluster_test.go ++++ b/pkg/validation/validate_cluster_test.go +@@ -374,7 +374,7 @@ func Test_ValidateMasterNotReady(t *testing.T) { + } + } + +-func Test_ValidateMasterNoKubeControllerManager(t *testing.T) { ++func Test_ValidateMasterStaticPods(t *testing.T) { + groups := make(map[string]*cloudinstances.CloudInstanceGroup) + groups["node-1"] = &cloudinstances.CloudInstanceGroup{ + InstanceGroup: &kopsapi.InstanceGroup{ +@@ -427,37 +427,71 @@ func Test_ValidateMasterNoKubeControllerManager(t *testing.T) { + }, + }, + }, ++ { ++ ID: "i-00003", ++ Node: &v1.Node{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "master-1c", ++ Labels: map[string]string{"kubernetes.io/role": "master"}, ++ }, ++ Status: v1.NodeStatus{ ++ Conditions: []v1.NodeCondition{ ++ {Type: "Ready", Status: v1.ConditionFalse}, ++ }, ++ Addresses: []v1.NodeAddress{ ++ { ++ Address: "9.10.11.12", ++ }, ++ }, ++ }, ++ }, ++ }, + }, + } + +- v, err := testValidate(t, groups, makePodList( +- []map[string]string{ ++ var podList []map[string]string ++ expectedFailures := []*ValidationError{ ++ { ++ Kind: "Node", ++ Name: "master-1c", ++ Message: "master \"master-1c\" is not ready", ++ }, ++ } ++ ++ for i, pod := range []string{ ++ "kube-apiserver", ++ "kube-controller-manager", ++ "kube-scheduler", ++ } { ++ podList = append(podList, []map[string]string{ + { +- "name": "pod1", ++ "name": fmt.Sprintf("pod-a-%d", i), + "ready": "true", +- "k8s-app": "kube-controller-manager", ++ "k8s-app": pod, + "phase": string(v1.PodRunning), + "priorityClassName": "system-cluster-critical", + "hostip": "1.2.3.4", + }, + { +- "name": "pod2", ++ "name": fmt.Sprintf("pod-b-%d", i), + "namespace": "other", + "ready": "true", +- "k8s-app": "kube-controller-manager", ++ "k8s-app": pod, + "phase": string(v1.PodRunning), + "priorityClassName": "system-cluster-critical", + "hostip": "5.6.7.8", + }, +- }, +- )) +- require.NoError(t, err) +- if !assert.Len(t, v.Failures, 1) || +- !assert.Equal(t, &ValidationError{ ++ }...) ++ expectedFailures = append(expectedFailures, &ValidationError{ + Kind: "Node", + Name: "master-1b", +- Message: "master \"master-1b\" is missing kube-controller-manager pod", +- }, v.Failures[0]) { ++ Message: "master \"master-1b\" is missing " + pod + " pod", ++ }) ++ } ++ ++ v, err := testValidate(t, groups, makePodList(podList)) ++ require.NoError(t, err) ++ if !assert.ElementsMatch(t, v.Failures, expectedFailures) { + printDebug(t, v) + } + } +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+3R0QqCMBSA4V33FOcF0q2cXvUsYk5KKhc5ff5MiiKoboqI/u/mDDbYgT9advXW ++5VXTx+pT9CCzdpyD+zmejZ3pudaJTmdKG2Mzo8R+bKMbXRuKg4g6eB+evXt1/6Oia/9QtSEv/W5X ++NC5q1+/742X/ofm5/zwzydA/SXWqRL9vhcf+vH/pZAy/rNxk5eV0lGkv09J3TVgYieL9ZhX3xbZ2 ++Rah9E0++vTEAAAAAAAAAAAAAAACAiyNpC7qnACgAAA== +diff --git 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-001742/tests/test.sh b/tasks/format-code-task-001742/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..142a8dc3af1a6196f220479440969356cbb68366 --- /dev/null +++ b/tasks/format-code-task-001742/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/validation/validate_cluster_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-001742/tests/test_command.sh b/tasks/format-code-task-001742/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001742/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001744/environment/Dockerfile b/tasks/format-code-task-001744/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3deaa38fb7b4d579fced7d3e263205b49c3c4794 --- /dev/null +++ b/tasks/format-code-task-001744/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6e8b625e5c5f8a31709214ae35b2d047f621bd04fb64ab1024bf8d3c96c64a98 diff --git a/tasks/format-code-task-001744/environment/setup/files/blocklist b/tasks/format-code-task-001744/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001744/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001744/environment/setup/setup.sh b/tasks/format-code-task-001744/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001744/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001744/tests/test.patch b/tasks/format-code-task-001744/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e8649a52c7fefd8edad13df7d9a80eadad1edd8f --- /dev/null +++ b/tasks/format-code-task-001744/tests/test.patch @@ -0,0 +1,311 @@ +diff --git a/plugin/pkg/scheduler/algorithm/predicates/predicates_test.go b/plugin/pkg/scheduler/algorithm/predicates/predicates_test.go +index d085d9d6f6e..e0cf078480d 100644 +--- a/plugin/pkg/scheduler/algorithm/predicates/predicates_test.go ++++ b/plugin/pkg/scheduler/algorithm/predicates/predicates_test.go +@@ -3743,3 +3743,284 @@ func TestVolumeZonePredicateMultiZone(t *testing.T) { + + } + } ++ ++ ++ ++func containsReason(reasons []algorithm.PredicateFailureReason, target algorithm.PredicateFailureReason) bool { ++ for _, r := range reasons { ++ if r == target { ++ return true ++ } ++ } ++ return false ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++func TestInterPodAffinitySpecificFailureReasons(t *testing.T) { ++ podLabel := map[string]string{"service": "securityscan"} ++ podLabel2 := map[string]string{"security": "S1"} ++ labels1 := map[string]string{ ++ "region": "r1", ++ "zone": "z11", ++ } ++ node1 := v1.Node{ObjectMeta: metav1.ObjectMeta{Name: "machine1", Labels: labels1}} ++ ++ tests := []struct { ++ name string ++ pod *v1.Pod ++ pods []*v1.Pod ++ node *v1.Node ++ expectedFits bool ++ mustContain []algorithm.PredicateFailureReason ++ mustNotContain []algorithm.PredicateFailureReason ++ }{ ++ { ++ ++ ++ name: "pod-own-affinity-fails-reports-PodAffinityRulesNotMatch", ++ pod: &v1.Pod{ ++ ObjectMeta: metav1.ObjectMeta{Labels: podLabel2}, ++ Spec: v1.PodSpec{ ++ Affinity: &v1.Affinity{ ++ PodAffinity: &v1.PodAffinity{ ++ RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ ++ { ++ LabelSelector: &metav1.LabelSelector{ ++ MatchExpressions: []metav1.LabelSelectorRequirement{ ++ { ++ Key: "service", ++ Operator: metav1.LabelSelectorOpIn, ++ Values: []string{"antivirusscan", "value2"}, ++ }, ++ }, ++ }, ++ TopologyKey: "region", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ pods: []*v1.Pod{{ ++ Spec: v1.PodSpec{NodeName: "machine1"}, ++ ObjectMeta: metav1.ObjectMeta{Labels: podLabel}, ++ }}, ++ node: &node1, ++ expectedFits: false, ++ mustContain: []algorithm.PredicateFailureReason{ ++ ErrPodAffinityNotMatch, ++ ErrPodAffinityRulesNotMatch, ++ }, ++ mustNotContain: []algorithm.PredicateFailureReason{ ++ ErrPodAntiAffinityRulesNotMatch, ++ ErrExistingPodsAntiAffinityRulesNotMatch, ++ }, ++ }, ++ { ++ ++ ++ name: "pod-own-antiaffinity-fails-reports-PodAntiAffinityRulesNotMatch", ++ pod: &v1.Pod{ ++ ObjectMeta: metav1.ObjectMeta{Labels: podLabel2}, ++ Spec: v1.PodSpec{ ++ Affinity: &v1.Affinity{ ++ PodAffinity: &v1.PodAffinity{ ++ RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ ++ { ++ LabelSelector: &metav1.LabelSelector{ ++ MatchExpressions: []metav1.LabelSelectorRequirement{ ++ { ++ Key: "service", ++ Operator: metav1.LabelSelectorOpIn, ++ Values: []string{"securityscan", "value2"}, ++ }, ++ }, ++ }, ++ TopologyKey: "region", ++ }, ++ }, ++ }, ++ PodAntiAffinity: &v1.PodAntiAffinity{ ++ RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ ++ { ++ LabelSelector: &metav1.LabelSelector{ ++ MatchExpressions: []metav1.LabelSelectorRequirement{ ++ { ++ Key: "service", ++ Operator: metav1.LabelSelectorOpIn, ++ Values: []string{"securityscan", "value2"}, ++ }, ++ }, ++ }, ++ TopologyKey: "zone", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ pods: []*v1.Pod{{ ++ Spec: v1.PodSpec{NodeName: "machine1"}, ++ ObjectMeta: metav1.ObjectMeta{Labels: podLabel}, ++ }}, ++ node: &node1, ++ expectedFits: false, ++ mustContain: []algorithm.PredicateFailureReason{ ++ ErrPodAffinityNotMatch, ++ ErrPodAntiAffinityRulesNotMatch, ++ }, ++ mustNotContain: []algorithm.PredicateFailureReason{ ++ ErrPodAffinityRulesNotMatch, ++ ErrExistingPodsAntiAffinityRulesNotMatch, ++ }, ++ }, ++ { ++ ++ ++ ++ name: "existing-pod-antiaffinity-violated-reports-ExistingPodsAntiAffinityRulesNotMatch", ++ pod: &v1.Pod{ ++ ObjectMeta: metav1.ObjectMeta{Labels: podLabel}, ++ }, ++ pods: []*v1.Pod{ ++ { ++ Spec: v1.PodSpec{ ++ NodeName: "machine1", ++ Affinity: &v1.Affinity{ ++ PodAntiAffinity: &v1.PodAntiAffinity{ ++ RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ ++ { ++ LabelSelector: &metav1.LabelSelector{ ++ MatchExpressions: []metav1.LabelSelectorRequirement{ ++ { ++ Key: "service", ++ Operator: metav1.LabelSelectorOpIn, ++ Values: []string{"securityscan", "value2"}, ++ }, ++ }, ++ }, ++ TopologyKey: "zone", ++ }, ++ }, ++ }, ++ }, ++ }, ++ ObjectMeta: metav1.ObjectMeta{Labels: podLabel}, ++ }, ++ }, ++ node: &node1, ++ expectedFits: false, ++ mustContain: []algorithm.PredicateFailureReason{ ++ ErrPodAffinityNotMatch, ++ ErrExistingPodsAntiAffinityRulesNotMatch, ++ }, ++ mustNotContain: []algorithm.PredicateFailureReason{ ++ ErrPodAffinityRulesNotMatch, ++ ErrPodAntiAffinityRulesNotMatch, ++ }, ++ }, ++ { ++ ++ ++ name: "success-no-failure-reasons", ++ pod: &v1.Pod{ ++ ObjectMeta: metav1.ObjectMeta{Labels: podLabel2}, ++ Spec: v1.PodSpec{ ++ Affinity: &v1.Affinity{ ++ PodAffinity: &v1.PodAffinity{ ++ RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ ++ { ++ LabelSelector: &metav1.LabelSelector{ ++ MatchExpressions: []metav1.LabelSelectorRequirement{ ++ { ++ Key: "service", ++ Operator: metav1.LabelSelectorOpIn, ++ Values: []string{"securityscan", "value2"}, ++ }, ++ }, ++ }, ++ TopologyKey: "region", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ pods: []*v1.Pod{{ ++ Spec: v1.PodSpec{NodeName: "machine1"}, ++ ObjectMeta: metav1.ObjectMeta{Labels: podLabel}, ++ }}, ++ node: &node1, ++ expectedFits: true, ++ }, ++ } ++ ++ for _, test := range tests { ++ node := test.node ++ var podsOnNode []*v1.Pod ++ for _, pod := range test.pods { ++ if pod.Spec.NodeName == node.Name { ++ podsOnNode = append(podsOnNode, pod) ++ } ++ } ++ ++ fit := PodAffinityChecker{ ++ info: FakeNodeInfo(*node), ++ podLister: schedulertesting.FakePodLister(test.pods), ++ } ++ nodeInfo := schedulercache.NewNodeInfo(podsOnNode...) ++ nodeInfo.SetNode(test.node) ++ nodeInfoMap := map[string]*schedulercache.NodeInfo{test.node.Name: nodeInfo} ++ ++ fits, reasons, err := fit.InterPodAffinityMatches(test.pod, PredicateMetadata(test.pod, nodeInfoMap), nodeInfo) ++ if err != nil { ++ t.Errorf("%s: unexpected error: %v", test.name, err) ++ continue ++ } ++ if fits != test.expectedFits { ++ t.Errorf("%s: expected fits=%v, got %v (reasons=%v)", test.name, test.expectedFits, fits, reasons) ++ } ++ for _, want := range test.mustContain { ++ if !containsReason(reasons, want) { ++ t.Errorf("%s: expected failure reasons to contain %v, got %v", test.name, want, reasons) ++ } ++ } ++ for _, unwanted := range test.mustNotContain { ++ if containsReason(reasons, unwanted) { ++ t.Errorf("%s: did NOT expect failure reasons to contain %v, got %v", test.name, unwanted, reasons) ++ } ++ } ++ } ++} ++ ++ ++ ++ ++ ++ ++func TestInterPodAffinitySpecificErrorVarsExist(t *testing.T) { ++ vars := []algorithm.PredicateFailureReason{ ++ ErrPodAffinityNotMatch, ++ ErrPodAffinityRulesNotMatch, ++ ErrPodAntiAffinityRulesNotMatch, ++ ErrExistingPodsAntiAffinityRulesNotMatch, ++ } ++ seen := make(map[algorithm.PredicateFailureReason]bool, len(vars)) ++ for i, v := range vars { ++ if v == nil { ++ t.Errorf("error variable at index %d is nil", i) ++ continue ++ } ++ if seen[v] { ++ t.Errorf("error variable at index %d (%v) is a duplicate of an earlier one; each affinity error must be a distinct value", i, v) ++ } ++ seen[v] = true ++ } ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000000..6daf3da8d62 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["mkdir -p /go/src/k8s.io && ln -snf \"$(pwd)\" /go/src/k8s.io/kubernetes && cd /go/src/k8s.io/kubernetes && GO111MODULE=off go test -timeout 60s -run '^(TestInterPodAffinitySpecificFailureReasons|TestInterPodAffinitySpecificErrorVarsExist)$' ./plugin/pkg/scheduler/algorithm/predicates/ -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++mkdir -p /go/src/k8s.io && ln -snf "$(pwd)" /go/src/k8s.io/kubernetes && cd /go/src/k8s.io/kubernetes && GO111MODULE=off go test -timeout 60s -run '^(TestInterPodAffinitySpecificFailureReasons|TestInterPodAffinitySpecificErrorVarsExist)$' ./plugin/pkg/scheduler/algorithm/predicates/ -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001744/tests/test.sh b/tasks/format-code-task-001744/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..85d6a2e108ad9b24b32375726b75f0b7fa8cef0e --- /dev/null +++ b/tasks/format-code-task-001744/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' +plugin/pkg/scheduler/algorithm/predicates/predicates_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-001744/tests/test_command.sh b/tasks/format-code-task-001744/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001744/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001745/environment/Dockerfile b/tasks/format-code-task-001745/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0e1ae9b7f893e86fa9043f86cb706ea98539bc94 --- /dev/null +++ b/tasks/format-code-task-001745/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:11a27a8e20d71bf00a887f891af028a761cd95541dcad8d7af72d7616c6db625 diff --git a/tasks/format-code-task-001745/environment/setup/files/blocklist b/tasks/format-code-task-001745/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001745/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001745/environment/setup/setup.sh b/tasks/format-code-task-001745/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001745/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001745/tests/test.patch b/tasks/format-code-task-001745/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..43fdd07ebf7428ccbf86431847d13f45af049e92 --- /dev/null +++ b/tasks/format-code-task-001745/tests/test.patch @@ -0,0 +1,425 @@ +diff --git a/pkg/minikube/audit/logFile_test.go b/pkg/minikube/audit/logFile_test.go +index ccea36276..e5b6de86c 100644 +--- a/pkg/minikube/audit/logFile_test.go ++++ b/pkg/minikube/audit/logFile_test.go +@@ -17,11 +17,17 @@ limitations under the License. + package audit + + import ( ++ "encoding/json" + "io" + "io/ioutil" + "os" ++ "strings" + "testing" + "time" ++ ++ "github.com/spf13/viper" ++ "k8s.io/minikube/pkg/minikube/config" ++ "k8s.io/minikube/pkg/version" + ) + + func TestLogFile(t *testing.T) { +@@ -38,18 +44,92 @@ func TestLogFile(t *testing.T) { + } + defer os.Remove(f.Name()) + +- oldLogFile := *currentLogFile +- defer func() { currentLogFile = &oldLogFile }() ++ oldLogFile := currentLogFile ++ defer func() { currentLogFile = oldLogFile }() + currentLogFile = f + +- e := newEntry("start", "-v", "user1", time.Now(), time.Now()) +- if err := appendToLog(e); err != nil { +- t.Fatalf("Error appendingToLog: %v", err) +- } ++ oldArgs := os.Args ++ os.Args = []string{"minikube", "start", "-v"} ++ defer func() { os.Args = oldArgs }() ++ ++ Log(time.Now()) + + b := make([]byte, 100) + if _, err := f.Read(b); err != nil && err != io.EOF { + t.Errorf("Log was not appended to file: %v", err) + } + }) ++ ++ t.Run("LogWritesVersion", func(t *testing.T) { ++ f, err := ioutil.TempFile("", "audit.json") ++ if err != nil { ++ t.Fatalf("Error creating temporary file: %v", err) ++ } ++ defer os.Remove(f.Name()) ++ ++ oldLogFile := currentLogFile ++ defer func() { currentLogFile = oldLogFile }() ++ currentLogFile = f ++ ++ oldArgs := os.Args ++ os.Args = []string{"minikube", "delete", "-p", "audit-version-profile", "--alsologtostderr"} ++ defer func() { os.Args = oldArgs }() ++ ++ oldProfile := viper.GetString(config.ProfileName) ++ oldUser := viper.GetString(config.UserFlag) ++ viper.Set(config.ProfileName, "audit-version-profile") ++ viper.Set(config.UserFlag, "audit-version-user") ++ defer func() { ++ viper.Set(config.ProfileName, oldProfile) ++ viper.Set(config.UserFlag, oldUser) ++ }() ++ ++ Log(time.Now()) ++ ++ if _, err := f.Seek(0, 0); err != nil { ++ t.Fatalf("failed seeking to start of file: %v", err) ++ } ++ bytes, err := ioutil.ReadAll(f) ++ if err != nil { ++ t.Fatalf("failed reading file: %v", err) ++ } ++ lines := strings.Split(strings.TrimSpace(string(bytes)), "\n") ++ if len(lines) == 0 || lines[0] == "" { ++ t.Fatalf("log file is empty, expected appended event") ++ } ++ ++ var event struct { ++ Data map[string]string `json:"data"` ++ } ++ if err := json.Unmarshal([]byte(lines[len(lines)-1]), &event); err != nil { ++ t.Fatalf("failed unmarshalling appended audit event: %v\n%s", err, lines[len(lines)-1]) ++ } ++ ++ if got, want := event.Data["command"], "delete"; got != want { ++ t.Errorf("data[command] = %q, want %q", got, want) ++ } ++ if got, want := event.Data["profile"], "audit-version-profile"; got != want { ++ t.Errorf("data[profile] = %q, want %q", got, want) ++ } ++ if got, want := event.Data["user"], "audit-version-user"; got != want { ++ t.Errorf("data[user] = %q, want %q", got, want) ++ } ++ if want := version.GetVersion(); !mapContainsValue(event.Data, want) { ++ t.Errorf("audit event data does not include current minikube version %q: %#v", want, event.Data) ++ } ++ for _, key := range []string{"args", "startTime", "endTime"} { ++ if event.Data[key] == "" { ++ t.Errorf("data[%s] is empty or missing in appended audit event", key) ++ } ++ } ++ }) ++} ++ ++func mapContainsValue(data map[string]string, want string) bool { ++ for _, got := range data { ++ if got == want { ++ return true ++ } ++ } ++ return false + } +diff --git a/pkg/minikube/audit/report_test.go b/pkg/minikube/audit/report_test.go +new file mode 100644 +index 000000000..40f7c8aab +--- /dev/null ++++ b/pkg/minikube/audit/report_test.go +@@ -0,0 +1,255 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package audit ++ ++import ( ++ "fmt" ++ "io/ioutil" ++ "os" ++ "path/filepath" ++ "strings" ++ "testing" ++ "time" ++ ++ "github.com/spf13/viper" ++ "k8s.io/minikube/pkg/minikube/config" ++ "k8s.io/minikube/pkg/minikube/constants" ++ "k8s.io/minikube/pkg/minikube/localpath" ++ "k8s.io/minikube/pkg/version" ++) ++ ++func withAuditLogFile(t *testing.T, contents string) *os.File { ++ t.Helper() ++ ++ f, err := ioutil.TempFile("", "audit-report-*.json") ++ if err != nil { ++ t.Fatalf("failed creating temporary audit log: %v", err) ++ } ++ t.Cleanup(func() { ++ _ = f.Close() ++ _ = os.Remove(f.Name()) ++ }) ++ ++ if contents != "" { ++ if _, err := f.WriteString(contents); err != nil { ++ t.Fatalf("failed writing audit log fixture: %v", err) ++ } ++ } ++ if _, err := f.Seek(0, 0); err != nil { ++ t.Fatalf("failed seeking audit log fixture: %v", err) ++ } ++ ++ oldLogFile := currentLogFile ++ currentLogFile = f ++ t.Cleanup(func() { currentLogFile = oldLogFile }) ++ return f ++} ++ ++func logAuditCommand(t *testing.T, command string, args []string, profile string, user string, startTime time.Time) { ++ t.Helper() ++ ++ oldArgs := os.Args ++ os.Args = append([]string{"minikube", command}, args...) ++ defer func() { os.Args = oldArgs }() ++ ++ oldProfile := viper.GetString(config.ProfileName) ++ oldUser := viper.GetString(config.UserFlag) ++ viper.Set(config.ProfileName, profile) ++ viper.Set(config.UserFlag, user) ++ defer func() { ++ viper.Set(config.ProfileName, oldProfile) ++ viper.Set(config.UserFlag, oldUser) ++ }() ++ ++ Log(startTime) ++} ++ ++func TestReportRejectsNonPositiveLineCount(t *testing.T) { ++ for _, n := range []int{0, -5} { ++ t.Run(fmt.Sprintf("n=%d", n), func(t *testing.T) { ++ report, err := Report(n) ++ if err == nil { ++ t.Fatalf("Report(%d) error = nil, want an error", n) ++ } ++ if report != nil { ++ t.Fatalf("Report(%d) report = %#v, want nil", n, report) ++ } ++ }) ++ } ++} ++ ++func TestReportReturnsMostRecentEntriesAsTable(t *testing.T) { ++ f := withAuditLogFile(t, "") ++ startAlpha := time.Date(2021, time.February, 2, 11, 0, 0, 0, time.UTC) ++ startBeta := time.Date(2021, time.February, 3, 12, 0, 0, 0, time.UTC) ++ startGamma := time.Date(2021, time.February, 4, 13, 0, 0, 0, time.UTC) ++ ++ logAuditCommand(t, "delete", []string{"--all"}, "old-profile", "old-user", time.Date(2021, time.February, 1, 10, 0, 0, 0, time.UTC)) ++ logAuditCommand(t, "start", []string{"-p", "alpha"}, "alpha", "user-a", startAlpha) ++ logAuditCommand(t, "stop", []string{"-p", "beta"}, "beta", "user-b", startBeta) ++ logAuditCommand(t, "logs", []string{"-p", "gamma", "--file=-"}, "gamma", "user-c", startGamma) ++ if _, err := f.Seek(0, 0); err != nil { ++ t.Fatalf("failed seeking audit log fixture: %v", err) ++ } ++ ++ report, err := Report(3) ++ if err != nil { ++ t.Fatalf("Report(3) returned error: %v", err) ++ } ++ table := report.ASCIITable() ++ ++ for _, want := range []string{ ++ "start", "-p alpha", "alpha", "user-a", startAlpha.Format(constants.TimeFormat), ++ "stop", "-p beta", "beta", "user-b", startBeta.Format(constants.TimeFormat), ++ "logs", "-p gamma --file=-", "gamma", "user-c", startGamma.Format(constants.TimeFormat), ++ } { ++ if !strings.Contains(table, want) { ++ t.Errorf("ASCIITable() missing value %q\n%s", want, table) ++ } ++ } ++ if got, want := strings.Count(table, version.GetVersion()), 3; got < want { ++ t.Errorf("ASCIITable() includes current version %d times, want at least %d\n%s", got, want, table) ++ } ++ ++ for _, omitted := range []string{"delete", "--all", "old-profile", "old-user"} { ++ if strings.Contains(table, omitted) { ++ t.Errorf("ASCIITable() contains older omitted value %q\n%s", omitted, table) ++ } ++ } ++} ++ ++func TestASCIITableIncludesExpectedColumnsAndRows(t *testing.T) { ++ f := withAuditLogFile(t, "") ++ startA := time.Date(2021, time.February, 5, 14, 0, 0, 0, time.UTC) ++ startB := time.Date(2021, time.February, 6, 15, 0, 0, 0, time.UTC) ++ ++ logAuditCommand(t, "profile", []string{"list"}, "prof-a", "reader-a", startA) ++ logAuditCommand(t, "update-context", []string{"--profile", "prof-b"}, "prof-b", "reader-b", startB) ++ if _, err := f.Seek(0, 0); err != nil { ++ t.Fatalf("failed seeking audit log fixture: %v", err) ++ } ++ ++ report, err := Report(10) ++ if err != nil { ++ t.Fatalf("Report(10) returned error: %v", err) ++ } ++ table := report.ASCIITable() ++ ++ for _, value := range []string{ ++ "profile", "list", "prof-a", "reader-a", startA.Format(constants.TimeFormat), ++ "update-context", "--profile prof-b", "prof-b", "reader-b", startB.Format(constants.TimeFormat), ++ } { ++ if !strings.Contains(table, value) { ++ t.Errorf("ASCIITable() missing row value %q\n%s", value, table) ++ } ++ } ++ if got, want := strings.Count(table, version.GetVersion()), 2; got < want { ++ t.Errorf("ASCIITable() includes current version %d times, want at least %d\n%s", got, want, table) ++ } ++} ++ ++func TestReportCanReadEntryWrittenByLogInSameProcess(t *testing.T) { ++ f := withAuditLogFile(t, "") ++ ++ oldArgs := os.Args ++ os.Args = []string{"minikube", "addons", "enable", "metrics-server", "-p", "same-process-profile"} ++ t.Cleanup(func() { os.Args = oldArgs }) ++ ++ oldProfile := viper.GetString(config.ProfileName) ++ oldUser := viper.GetString(config.UserFlag) ++ viper.Set(config.ProfileName, "same-process-profile") ++ viper.Set(config.UserFlag, "same-process-user") ++ t.Cleanup(func() { ++ viper.Set(config.ProfileName, oldProfile) ++ viper.Set(config.UserFlag, oldUser) ++ }) ++ ++ Log(time.Now()) ++ ++ if _, err := f.Seek(0, 0); err != nil { ++ t.Fatalf("failed seeking audit log after Log: %v", err) ++ } ++ report, err := Report(1) ++ if err != nil { ++ t.Fatalf("Report(1) after Log returned error: %v", err) ++ } ++ table := report.ASCIITable() ++ ++ for _, want := range []string{"addons", "enable", "metrics-server", "same-process-profile", "same-process-user", version.GetVersion()} { ++ if !strings.Contains(table, want) { ++ t.Errorf("ASCIITable() after Log missing %q\n%s", want, table) ++ } ++ } ++} ++ ++func TestReportCanReadEntryWrittenThroughDefaultLogFile(t *testing.T) { ++ tempHome, err := ioutil.TempDir("", "audit-home-*") ++ if err != nil { ++ t.Fatalf("failed creating temporary minikube home: %v", err) ++ } ++ t.Cleanup(func() { _ = os.RemoveAll(tempHome) }) ++ ++ oldHome := os.Getenv(localpath.MinikubeHome) ++ if err := os.Setenv(localpath.MinikubeHome, tempHome); err != nil { ++ t.Fatalf("failed setting minikube home: %v", err) ++ } ++ t.Cleanup(func() { _ = os.Setenv(localpath.MinikubeHome, oldHome) }) ++ ++ if err := os.MkdirAll(filepath.Dir(localpath.AuditLog()), 0755); err != nil { ++ t.Fatalf("failed creating audit log directory: %v", err) ++ } ++ ++ oldLogFile := currentLogFile ++ currentLogFile = nil ++ t.Cleanup(func() { ++ if currentLogFile != nil && currentLogFile != oldLogFile { ++ _ = currentLogFile.Close() ++ } ++ currentLogFile = oldLogFile ++ }) ++ ++ oldArgs := os.Args ++ os.Args = []string{"minikube", "profile", "list", "-p", "default-file-profile"} ++ t.Cleanup(func() { os.Args = oldArgs }) ++ ++ oldProfile := viper.GetString(config.ProfileName) ++ oldUser := viper.GetString(config.UserFlag) ++ viper.Set(config.ProfileName, "default-file-profile") ++ viper.Set(config.UserFlag, "default-file-user") ++ t.Cleanup(func() { ++ viper.Set(config.ProfileName, oldProfile) ++ viper.Set(config.UserFlag, oldUser) ++ }) ++ ++ Log(time.Now()) ++ if currentLogFile != nil { ++ if _, err := currentLogFile.Seek(0, 0); err != nil { ++ t.Fatalf("failed seeking default audit log after Log: %v", err) ++ } ++ } ++ ++ report, err := Report(1) ++ if err != nil { ++ t.Fatalf("Report(1) after default Log returned error: %v", err) ++ } ++ table := report.ASCIITable() ++ for _, want := range []string{"profile", "list -p default-file-profile", "default-file-profile", "default-file-user", version.GetVersion()} { ++ if !strings.Contains(table, want) { ++ t.Errorf("ASCIITable() from default log file missing %q\n%s", want, table) ++ } ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,38 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++mkdir -p /root/.minikube/logs ++ ++GOBINDATA_BIN="/testbed/.build_env/go-bindata" ++if [ ! -x "$GOBINDATA_BIN" ]; then ++ GOBINDATA_BIN="/tmp/gopath/bin/go-bindata" ++fi ++if [ ! -x "$GOBINDATA_BIN" ]; then ++ GOBINDATA_BIN="/usr/local/bin/go-bindata" ++fi ++if [ ! -f pkg/minikube/translate/translations.go ]; then ++ "$GOBINDATA_BIN" -nomemcopy -o pkg/minikube/translate/translations.go -pkg translate translations/ 2>/dev/null || \ ++ echo "//go:build ignore" > pkg/minikube/translate/translations.go ++fi ++if [ ! -f pkg/minikube/assets/assets.go ]; then ++ "$GOBINDATA_BIN" -nomemcopy -o pkg/minikube/assets/assets.go -pkg assets deploy/addons/... 2>/dev/null || \ ++ echo "//go:build ignore" > pkg/minikube/assets/assets.go ++fi ++ ++ ++FIXTURE_VERSION_LDFLAGS="-X k8s.io/minikube/pkg/version.version=v9.99.0-fixture" ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 -ldflags "$FIXTURE_VERSION_LDFLAGS" ./pkg/minikube/audit/ -run '^TestAudit$' ++ ;; ++ new) ++ go test -v -count=1 -ldflags "$FIXTURE_VERSION_LDFLAGS" ./pkg/minikube/audit/ -run '^(TestLogFile|TestReportRejectsNonPositiveLineCount|TestReportReturnsMostRecentEntriesAsTable|TestASCIITableIncludesExpectedColumnsAndRows|TestReportCanReadEntryWrittenByLogInSameProcess|TestReportCanReadEntryWrittenThroughDefaultLogFile)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001745/tests/test.sh b/tasks/format-code-task-001745/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0c6d778258b58d6a2ffa1a0df10d70be96703541 --- /dev/null +++ b/tasks/format-code-task-001745/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/minikube/audit/logFile_test.go +pkg/minikube/audit/report_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-001745/tests/test_command.sh b/tasks/format-code-task-001745/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001745/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-001917/environment/Dockerfile b/tasks/format-code-task-001917/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fae7ab39cf5d496e79f2e7b51bb1069bd10f1687 --- /dev/null +++ b/tasks/format-code-task-001917/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1b456c480ce423010dd4566908bc1b4f46fd6e8c1638f31584457b782896828b diff --git a/tasks/format-code-task-001917/environment/setup/files/blocklist b/tasks/format-code-task-001917/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001917/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001917/environment/setup/setup.sh b/tasks/format-code-task-001917/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001917/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001917/tests/test.patch b/tasks/format-code-task-001917/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d09100034d33a2383b2098a8910b2b100a73cc9d --- /dev/null +++ b/tasks/format-code-task-001917/tests/test.patch @@ -0,0 +1,261 @@ +diff --git a/test/android/gradle-wrapper.test.ts b/test/android/gradle-wrapper.test.ts +index feea920b..fd6a0f7b 100644 +--- a/test/android/gradle-wrapper.test.ts ++++ b/test/android/gradle-wrapper.test.ts +@@ -1,11 +1,35 @@ +-import { doesNotThrow, equal, fail, throws } from "node:assert/strict"; ++import { doesNotThrow, equal, fail, ok, throws } from "node:assert/strict"; + import * as nodefs from "node:fs"; ++import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; ++import { tmpdir } from "node:os"; ++import { join } from "node:path"; + import { afterEach, describe, it } from "node:test"; + import { configureGradleWrapper } from "../../android/gradle-wrapper.js"; + + describe("configureGradleWrapper()", () => { + const args = process.argv; + ++ const parseGradleWrapperVersion = (wrapper: string): string => { ++ const match = wrapper.match(/^gradle-([0-9.]+)-bin\.zip$/); ++ if (!match) { ++ fail(`Unexpected Gradle wrapper written: ${wrapper}`); ++ } ++ return match[1]; ++ }; ++ ++ const compareVersions = (a: string, b: string): number => { ++ const aParts = a.split(".").map(Number); ++ const bParts = b.split(".").map(Number); ++ const length = Math.max(aParts.length, bParts.length); ++ for (let i = 0; i < length; i++) { ++ const diff = (aParts[i] ?? 0) - (bParts[i] ?? 0); ++ if (diff !== 0) { ++ return diff; ++ } ++ } ++ return 0; ++ }; ++ + afterEach(() => { + process.argv = args.slice(); + delete process.env["RNTA_CONFIGURE_GRADLE_WRAPPER"]; +@@ -110,30 +134,84 @@ describe("configureGradleWrapper()", () => { + const warnMock = t.mock.method(console, "warn", () => null); + + let written = ""; ++ const fixtures: string[] = []; + const mockfs = ( + gradleVersion: string, + rnVersion: string +- ): typeof nodefs => ({ +- ...nodefs, +- existsSync: () => true, +- // @ts-expect-error Type 'string' is not assignable to type 'Buffer' +- readFileSync: (p) => { +- if (p.toString().endsWith("gradle-wrapper.properties")) { +- return `gradle-${gradleVersion}-bin.zip`; +- } else if (p.toString().endsWith("package.json")) { +- return JSON.stringify({ name: "react-native", version: rnVersion }); +- } ++ ): [string, typeof nodefs] => { ++ const sourceDir = mkdtempSync(join(tmpdir(), "rnta-gradle-wrapper-")); ++ fixtures.push(sourceDir); ++ mkdirSync(join(sourceDir, "gradle", "wrapper"), { recursive: true }); ++ mkdirSync(join(sourceDir, "node_modules", "react-native"), { recursive: true }); ++ writeFileSync( ++ join(sourceDir, "node_modules", "react-native", "package.json"), ++ JSON.stringify({ name: "react-native", version: rnVersion }) ++ ); + +- fail(`Unexpected file read: ${p}`); +- }, +- writeFileSync: (_, data) => { +- // @ts-expect-error Type 'Uint8Array' is not assignable to type 'string' +- written = data; +- }, +- }); ++ return [ ++ sourceDir, ++ { ++ ...nodefs, ++ existsSync: (p) => p.toString().endsWith("gradle-wrapper.properties"), ++ // @ts-expect-error Type 'string' is not assignable to type 'Buffer' ++ readFileSync: (p, options) => { ++ if (p.toString().endsWith("gradle-wrapper.properties")) { ++ return `gradle-${gradleVersion}-bin.zip`; ++ } ++ ++ return nodefs.readFileSync(p, options); ++ }, ++ writeFileSync: (_, data) => { ++ // @ts-expect-error Type 'Uint8Array' is not assignable to type 'string' ++ written = data; ++ }, ++ }, ++ ]; ++ }; + + process.argv.push("run-android"); + ++ const bumpedGradleByReactNativeMinor = new Map(); ++ const newReactNativeCases = [ ++ ["8.11.1", "0.78.0", "0.78"], ++ ["8.11.1", "0.78.1", "0.78"], ++ ["8.11.1", "0.79.0", "0.79"], ++ ["8.11.1", "0.79.2", "0.79"], ++ ["8.11.1", "0.80.0", "0.80"], ++ ["8.11.1", "0.80.1", "0.80"], ++ ]; ++ for (const [gradleVersion, rnVersion, rnMinor] of newReactNativeCases) { ++ written = ""; ++ const [sourceDir, fs] = mockfs(gradleVersion, rnVersion); ++ ++ doesNotThrow(() => configureGradleWrapper(sourceDir, fs)); ++ equal(warnMock.mock.callCount(), 1); ++ ok(written); ++ const bumpedVersion = parseGradleWrapperVersion(written); ++ ok(compareVersions(bumpedVersion, gradleVersion) > 0); ++ ++ const previous = bumpedGradleByReactNativeMinor.get(rnMinor); ++ if (previous === undefined) { ++ bumpedGradleByReactNativeMinor.set(rnMinor, bumpedVersion); ++ } else { ++ equal(bumpedVersion, previous); ++ } ++ ++ warnMock.mock.resetCalls(); ++ } ++ ok( ++ compareVersions( ++ bumpedGradleByReactNativeMinor.get("0.79") ?? "", ++ bumpedGradleByReactNativeMinor.get("0.78") ?? "" ++ ) > 0 ++ ); ++ ok( ++ compareVersions( ++ bumpedGradleByReactNativeMinor.get("0.80") ?? "", ++ bumpedGradleByReactNativeMinor.get("0.79") ?? "" ++ ) > 0 ++ ); ++ + const cases = [ + ["8.9", "0.76.0", "gradle-8.11.1-bin.zip"], + ["8.9", "0.75.0", "gradle-8.8-bin.zip"], +@@ -149,9 +227,9 @@ describe("configureGradleWrapper()", () => { + ]; + for (const [gradleVersion, rnVersion, expected] of cases) { + written = ""; +- const fs = mockfs(gradleVersion, rnVersion); ++ const [sourceDir, fs] = mockfs(gradleVersion, rnVersion); + +- doesNotThrow(() => configureGradleWrapper("android", fs)); ++ doesNotThrow(() => configureGradleWrapper(sourceDir, fs)); + equal(warnMock.mock.callCount(), 1); + equal( + warnMock.mock.calls[0].arguments[1], +@@ -161,31 +239,48 @@ describe("configureGradleWrapper()", () => { + + warnMock.mock.resetCalls(); + } ++ ++ for (const fixture of fixtures) { ++ rmSync(fixture, { force: true, recursive: true }); ++ } + }); + + it("skips writing if Gradle version is recent enough", () => { + let written = ""; ++ const fixtures: string[] = []; + const mockfs = ( + gradleVersion: string, + rnVersion: string +- ): typeof nodefs => ({ +- ...nodefs, +- existsSync: () => true, +- // @ts-expect-error Type 'string' is not assignable to type 'Buffer' +- readFileSync: (p) => { +- if (p.toString().endsWith("gradle-wrapper.properties")) { +- return `gradle-${gradleVersion}-bin.zip`; +- } else if (p.toString().endsWith("package.json")) { +- return JSON.stringify({ name: "react-native", version: rnVersion }); +- } ++ ): [string, typeof nodefs] => { ++ const sourceDir = mkdtempSync(join(tmpdir(), "rnta-gradle-wrapper-")); ++ fixtures.push(sourceDir); ++ mkdirSync(join(sourceDir, "gradle", "wrapper"), { recursive: true }); ++ mkdirSync(join(sourceDir, "node_modules", "react-native"), { recursive: true }); ++ writeFileSync( ++ join(sourceDir, "node_modules", "react-native", "package.json"), ++ JSON.stringify({ name: "react-native", version: rnVersion }) ++ ); + +- fail(`Unexpected file read: ${p}`); +- }, +- writeFileSync: (_, data) => { +- // @ts-expect-error Type 'Uint8Array' is not assignable to type 'string' +- written = data; +- }, +- }); ++ return [ ++ sourceDir, ++ { ++ ...nodefs, ++ existsSync: (p) => p.toString().endsWith("gradle-wrapper.properties"), ++ // @ts-expect-error Type 'string' is not assignable to type 'Buffer' ++ readFileSync: (p, options) => { ++ if (p.toString().endsWith("gradle-wrapper.properties")) { ++ return `gradle-${gradleVersion}-bin.zip`; ++ } ++ ++ return nodefs.readFileSync(p, options); ++ }, ++ writeFileSync: (_, data) => { ++ // @ts-expect-error Type 'Uint8Array' is not assignable to type 'string' ++ written = data; ++ }, ++ }, ++ ]; ++ }; + + process.argv.push("run-android"); + +@@ -202,9 +297,13 @@ describe("configureGradleWrapper()", () => { + ["7.5.1", "0.71.0"], + ]; + for (const [gradleVersion, rnVersion] of cases) { +- const fs = mockfs(gradleVersion, rnVersion); +- doesNotThrow(() => configureGradleWrapper("android", fs)); ++ const [sourceDir, fs] = mockfs(gradleVersion, rnVersion); ++ doesNotThrow(() => configureGradleWrapper(sourceDir, fs)); + equal(written, ""); + } ++ ++ for (const fixture of fixtures) { ++ rmSync(fixture, { force: true, recursive: 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,19 @@ ++#!/bin/bash ++set -uo pipefail ++ ++ ++cd /testbed ++ ++ ++case "${1:-}" in ++ base) ++ node --experimental-transform-types --no-warnings --test --test-name-pattern 'only runs when targeting Android' test/android/gradle-wrapper.test.ts ++ ;; ++ new) ++ node --experimental-transform-types --no-warnings --test --test-name-pattern 'bumps Gradle|skips writing' test/android/gradle-wrapper.test.ts ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001917/tests/test.sh b/tasks/format-code-task-001917/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..82f6f1d8c82295b6b3c97d8d81ed6f482a521cf9 --- /dev/null +++ b/tasks/format-code-task-001917/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/android/gradle-wrapper.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-001917/tests/test_command.sh b/tasks/format-code-task-001917/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001917/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-001921/environment/Dockerfile b/tasks/format-code-task-001921/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..121786db16fdef11ac5a802e52600e17d6aec3a9 --- /dev/null +++ b/tasks/format-code-task-001921/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:59b43b52092a786deac68871672e206d8b80aedf8a0ac945ced4c2fd1a9ae1a5 diff --git a/tasks/format-code-task-001921/environment/setup/files/blocklist b/tasks/format-code-task-001921/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001921/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001921/environment/setup/setup.sh b/tasks/format-code-task-001921/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001921/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001921/tests/test.patch b/tasks/format-code-task-001921/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..35386d8becb561ba7e80551581303a40c49c1dff --- /dev/null +++ b/tasks/format-code-task-001921/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/spec/mail/elements/address_spec.rb b/spec/mail/elements/address_spec.rb +index 4d4b085dd..c29d0335d 100644 +--- a/spec/mail/elements/address_spec.rb ++++ b/spec/mail/elements/address_spec.rb +@@ -516,7 +516,7 @@ + :comments => ['foo@bar.com (foobar), ned@foo.com (nedfoo) '], + :domain => 'goess.org', + :local => 'kevin', +- :format => '"(foo@bar.com \\(foobar\\), ned@foo.com \(nedfoo\) )" (foo@bar.com \(foobar\), ned@foo.com \(nedfoo\) )', ++ :format => '"(foo@bar.com \\\\(foobar\\\\), ned@foo.com \\\\(nedfoo\\\\) )" (foo@bar.com \(foobar\), ned@foo.com \(nedfoo\) )', + :raw => '(foo@bar.com (foobar), ned@foo.com (nedfoo) ) '}) + end + +diff --git a/spec/mail/utilities_spec.rb b/spec/mail/utilities_spec.rb +index 5bea74ce4..873345bad 100644 +--- a/spec/mail/utilities_spec.rb ++++ b/spec/mail/utilities_spec.rb +@@ -175,16 +175,42 @@ + + it "should quote correctly a phrase with an escaped quote in it" do + test = 'this needs \"quoting' +- result = '"this needs \"quoting"' ++ result = '"this needs \\\\\\"quoting"' + dquote(test).should eq result + end + + it "should quote correctly a phrase with an escaped backslash followed by an escaped quote in it" do + test = 'this needs \\\"quoting' +- result = '"this needs \\\"quoting"' ++ result = '"this needs \\\\\\\\\\"quoting"' + dquote(test).should eq result + end + end ++ ++ describe "unquoting phrases" do ++ it "should remove quotes from the edge" do ++ unquote('"This is quoted"').should eq 'This is quoted' ++ end ++ ++ it "should remove backslash escaping from quotes" do ++ unquote('"This is \\"quoted\\""').should eq 'This is "quoted"' ++ end ++ ++ it "should remove backslash escaping from any char" do ++ unquote('"This is \\quoted"').should eq 'This is quoted' ++ end ++ ++ it "should be able to handle unquoted strings" do ++ unquote('This is not quoted').should eq 'This is not quoted' ++ end ++ ++ it "should preserve backslashes in unquoted strings" do ++ unquote('This is not \"quoted').should eq 'This is not \"quoted' ++ end ++ ++ it "should be able to handle unquoted quotes" do ++ unquote('"This is "quoted"').should eq 'This is "quoted' ++ end ++ end + + + describe "parenthesizing phrases" do +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,21 @@ ++H4sIAAAAAAAAA+1XW2/bNhTOs34Fhz3YASJZsmU7C9oE7eJ0AZIsSFMMezIoiba5UKJKUqm9h/72 ++HlJX5/qSdpfwAxJLPFeem0gvKihL5iS7Hex8L/iA6XhsfgF3f81zMB76w4k/9Cfhjh8E4+lkB42/ ++m0cdFFJhgdCO4Fw9xfcc/T8Kr83/B5IuKCMvb0MneBKGj+Z/FI7q/AfTKawHI38a7iD/5V25j1ee ++f3KL2XxZZh71BopIFZGkroWe4/yMropog0beEJG1EjhWJEFqRSRBC8FTJFXCaIRopjgCPRIErldk ++gzKi+TiKCMK3mDIcgQF4ZxwbeZTCIgJRgcXGAUnUy4hyZary3h4S5HNBBTlAC8wkack0xU+Rc/4A ++9Z8O8b8a9/vfYzy+eVEbz/T/MBx1+38K/R/CTLD9/yNw+e76NwdBy6RcQcd4HrzInMTyAB5Q2aT9 ++oTf2wl2zAEs0Ja7a5ESi/tdDFHjBpCYpQYjiebUeevu7jvNhdt7Rv1IqlweDgYCZoqeFx8VysG0y ++5qxIM/o3QX3f+8XzS+UJVrAwAkeCaoEuFi6LwQnwwBuVi0REqD/x/NpbRjMS4ximDXCNatHuDgJv ++2KisB4w2PGk3rE1Xj2bGCK44ONmI5NxIgKbdJ9mqBc07bHkVOMML1bDpAahZGq8eUJdztlkyrjQf ++hKTky+UmXqH+uN3nlutSCZotKTevAt/okIwgR5UjIuEx6k/BM78WhmBWT5Xqw7cohNg2DEpyUTou ++dP50nQQdebPoxlwQUxAPEcka/iusKM/ko0wpzKP71K52sz7srm8rNvQ2KE3llOVbF8+WtS2VUKxu ++QqJiafLst6XRqVUIjt/aaEXcCMsyAKVo4/9djm3Nnco1misf6yzqVmhCUZVQWbaVC00r6j4MxrXa ++unLuvNZGGmmd2bJQwYZzefbu+uT3q/OPQFzvT+aT0AX/irW7zArHOZ5dzi6OZxe/ns40Q1RkCSPC ++qAy8yvO/zHZ5TjIpdQ3rufKT8+gwqTvRaTrMabvDqetXh3Tfm2oBXb5OU4dbpdIG2rk/oQK9vfef ++Lo7PZsfoj1MzC0EW2sJ/HeeGzvdfn/3mMU9TnCWeXL2cjWfuf4EPtOb+N9T3v3DiT+33/0cgTlB9 ++6Ndn/XOe3ZCNm2MFA3/BRXv4h8KAVRpRRtUGfaFqVXWb7jSQPNFHR7KmUskj9AVL88m/hTsAzVol ++EUypzuDWojDSKGOokDACqHJirNAhuJTmAz0j5oZ7bvzx4OP+5g3qXX16/2fPiRmW0liFli1fgCgJ ++W5gJhhnFcp4SteIJOqj82quejlCRMQISJX2ekAWM2+SoXzPquUGyxNF/2pwOTXU81vtpm0bfiYBJ ++mhuNIDlv2EyE2htTdU3SZx7UryfZHiIq9nYd+FrpeVvOoTmcmE5Oz2Zvm8vY/TO645RTFgxABvSE ++Q654PGruxypX+p/hGBBGUpIpOcBJIiAUc03SvC1LoXSuKWlor2MiWlhYWFhYWFhYWFhYWFhYWFhY ++WFj8P/ANiekYtQAoAAA= +diff --git 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-001921/tests/test.sh b/tasks/format-code-task-001921/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e35da514d0e312c37421104c120b39f0661e3920 --- /dev/null +++ b/tasks/format-code-task-001921/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +spec/mail/elements/address_spec.rb +spec/mail/utilities_spec.rb +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001921/tests/test_command.sh b/tasks/format-code-task-001921/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001921/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001927/tests/test.patch b/tasks/format-code-task-001927/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..46b3cced98e9ed1f0b9c9abecb00237ea480a984 --- /dev/null +++ b/tasks/format-code-task-001927/tests/test.patch @@ -0,0 +1,102 @@ +diff --git a/tests/pytorch/test_transforms_pt.py b/tests/pytorch/test_transforms_pt.py +index 2725a0e544..4965b0388b 100644 +--- a/tests/pytorch/test_transforms_pt.py ++++ b/tests/pytorch/test_transforms_pt.py +@@ -5,7 +5,7 @@ + import torch + + from doctr.transforms import (ChannelShuffle, ColorInversion, GaussianNoise, RandomCrop, RandomHorizontalFlip, +- RandomRotate, Resize) ++ RandomRotate, RandomShadow, Resize) + from doctr.transforms.functional import crop_detection, rotate_sample + + +@@ -272,3 +272,31 @@ def test_randomhorizontalflip(p): + assert np.all(_target["boxes"] == np.array([[0.1, 0.1, 0.3, 0.4]], dtype=np.float32)) + assert torch.all(transformed.mean((0, 1)) == torch.tensor([0] * 16 + [1] * 16, dtype=torch.float32)) + assert np.all(_target["labels"] == np.ones(1, dtype=np.int64)) ++ ++ ++@pytest.mark.parametrize( ++ "input_dtype,input_shape", ++ [ ++ [torch.float32, (3, 32, 32)], ++ [torch.uint8, (3, 32, 32)], ++ [torch.float32, (3, 64, 32)], ++ [torch.uint8, (3, 64, 32)], ++ ] ++) ++def test_random_shadow(input_dtype, input_shape): ++ transform = RandomShadow((.2, .8)) ++ input_t = torch.ones(input_shape, dtype=torch.float32) ++ if input_dtype == torch.uint8: ++ input_t = (255 * input_t).round() ++ input_t = input_t.to(dtype=input_dtype) ++ transformed = transform(input_t) ++ assert isinstance(transformed, torch.Tensor) ++ assert transformed.shape == input_shape ++ assert transformed.dtype == input_dtype ++ ++ assert input_t.float().mean() > transformed.float().mean() ++ assert torch.all(transformed >= 0) ++ if input_dtype == torch.uint8: ++ assert torch.all(transformed <= 255) ++ else: ++ assert torch.all(transformed <= 1.) +diff --git a/tests/tensorflow/test_transforms_tf.py b/tests/tensorflow/test_transforms_tf.py +index 5182be854a..8fd7451b50 100644 +--- a/tests/tensorflow/test_transforms_tf.py ++++ b/tests/tensorflow/test_transforms_tf.py +@@ -429,3 +429,31 @@ def test_randomhorizontalflip(p): + tf.math.reduce_mean(transformed, (0, 2)) == tf.constant([0] * 16 + [1] * 16, dtype=tf.float64) + ) + assert np.all(_target["labels"] == np.ones(1, dtype=np.int64)) ++ ++ ++@pytest.mark.parametrize( ++ "input_dtype,input_shape", ++ [ ++ [tf.float32, (32, 32, 3)], ++ [tf.uint8, (32, 32, 3)], ++ [tf.float32, (64, 32, 3)], ++ [tf.uint8, (64, 32, 3)], ++ ] ++) ++def test_random_shadow(input_dtype, input_shape): ++ transform = T.RandomShadow((.2, .8)) ++ input_t = tf.random.uniform(input_shape, dtype=tf.float32) ++ if input_dtype == tf.uint8: ++ input_t = tf.math.round((255 * input_t)) ++ input_t = tf.cast(input_t, dtype=input_dtype) ++ transformed = transform(input_t) ++ assert isinstance(transformed, tf.Tensor) ++ assert transformed.shape == input_shape ++ assert transformed.dtype == input_dtype ++ ++ assert tf.math.reduce_mean(input_t) > tf.math.reduce_mean(transformed) ++ assert tf.math.reduce_all(transformed >= 0) ++ if input_dtype == tf.uint8: ++ assert tf.reduce_all(transformed <= 255) ++ else: ++ assert tf.reduce_all(transformed <= 1.) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3ST2uDMBgGcM9+ivfUm9boEk89jY3dBvtzG4jViIOaSBI7+u2XZmUbK10vLWXs +++R3Mq4b3DT6my+l11VZSrefRuWReyXlYvZ9rqBnPGStFIUr/nDHBWET8bCf6ZrKuNkSR0dr9tu/Y +++z8q/crfSeuqRg9DrdrU9qebcSz/IhOf+fO89PlfiZxHlJ3uCIf98/yblkLwS9nGz4831dP9w/Xd ++glGobxcZjRvXa1VQMmxLv5O2Fzv3N9o0/cdf40ytbKfNYKvRpeOGkjUliZFmUpY4zWb0Eu867lqH ++MYe7O6msNt1Kv+0NcN3egPjSXxEAAAAAAAAAAAAAAAAAAAAA4DLeAZSbgQYAKAAA +diff --git 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-001927/tests/test_command.sh b/tasks/format-code-task-001927/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001927/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001942/environment/Dockerfile b/tasks/format-code-task-001942/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2048ce4f1f2817fd0bf732315ee16d3f4848ddc9 --- /dev/null +++ b/tasks/format-code-task-001942/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:74315a2b2827c9e26fc44cdddb34532778fa1bf12d88cd89d134b366c7a4509e diff --git a/tasks/format-code-task-001942/environment/setup/files/blocklist b/tasks/format-code-task-001942/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001942/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001942/environment/setup/setup.sh b/tasks/format-code-task-001942/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001942/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001942/tests/test.patch b/tasks/format-code-task-001942/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2cc483f2400fbdc1c26bd1f3031ffed634ab6727 --- /dev/null +++ b/tasks/format-code-task-001942/tests/test.patch @@ -0,0 +1,163 @@ +diff --git a/tests/api/crud/test_functions.py b/tests/api/crud/test_functions.py +index 72d994a08..a18b6aaaa 100644 +--- a/tests/api/crud/test_functions.py ++++ b/tests/api/crud/test_functions.py +@@ -12,12 +12,38 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + # ++import contextlib ++ + import sqlalchemy.orm + + import mlrun.common.schemas + import server.api.crud + + ++@contextlib.contextmanager ++def _capture_function_table_writes(db: sqlalchemy.orm.Session): ++ statements = [] ++ bind = db.get_bind() ++ ++ def before_cursor_execute( ++ conn, cursor, statement, parameters, context, executemany ++ ): ++ normalized = " ".join(statement.lower().split()) ++ is_function_write = ( ++ normalized.startswith("update ") ++ or normalized.startswith("insert ") ++ or normalized.startswith("replace ") ++ ) and "functions" in normalized ++ if is_function_write: ++ statements.append(statement) ++ ++ sqlalchemy.event.listen(bind, "before_cursor_execute", before_cursor_execute) ++ try: ++ yield statements ++ finally: ++ sqlalchemy.event.remove(bind, "before_cursor_execute", before_cursor_execute) ++ ++ + def test_set_function_deletion_task_id_updates_correctly(db: sqlalchemy.orm.Session): + function_name = "test_function" + function_tag = "latest" +@@ -72,15 +98,29 @@ def test_update_functions_with_api_gateway_url(db: sqlalchemy.orm.Session): + # check that URL is there + assert updated_function["status"]["external_invocation_urls"][0] == gw_host + +- # try to add existed external invocation URL +- server.api.crud.Functions().add_function_external_invocation_url( +- db, uri, project, gw_host ++ ++ with _capture_function_table_writes(db) as write_statements: ++ server.api.crud.Functions().add_function_external_invocation_url( ++ db, uri, project, gw_host + "/" ++ ) ++ assert write_statements == [] ++ updated_function = server.api.crud.Functions().get_function( ++ db, project=project, name=function_name, tag=function_tag + ) ++ ++ assert updated_function["status"]["external_invocation_urls"] == [gw_host] ++ ++ missing_url = "https://another-gateway.example.com/invoke" ++ with _capture_function_table_writes(db) as write_statements: ++ server.api.crud.Functions().delete_function_external_invocation_url( ++ db, uri, project, missing_url + "/" ++ ) ++ assert write_statements == [] + updated_function = server.api.crud.Functions().get_function( + db, project=project, name=function_name, tag=function_tag + ) +- # check that URL isn't duplicated +- assert len(updated_function["status"]["external_invocation_urls"]) == 1 ++ ++ assert updated_function["status"]["external_invocation_urls"] == [gw_host] + + # delete URL from the list + server.api.crud.Functions().delete_function_external_invocation_url( +diff --git a/tests/common/schemas/test_api_gateway.py b/tests/common/schemas/test_api_gateway.py +new file mode 100644 +index 000000000..565333c58 +--- /dev/null ++++ b/tests/common/schemas/test_api_gateway.py +@@ -0,0 +1,31 @@ ++import pytest ++ ++import mlrun.common.schemas ++ ++ ++@pytest.mark.parametrize( ++ "host,path,expected", ++ [ ++ ( ++ "https://gateway-one.example.com", ++ "/invoke/", ++ "https://gateway-one.example.com/invoke", ++ ), ++ ("https://gateway-two.example.com/", "", "https://gateway-two.example.com"), ++ ], ++) ++def test_schema_invoke_url_does_not_keep_trailing_slash_variants(host, path, expected): ++ gateway = mlrun.common.schemas.APIGateway( ++ metadata=mlrun.common.schemas.APIGatewayMetadata(name="test-gateway"), ++ spec=mlrun.common.schemas.APIGatewaySpec( ++ name="test-gateway", ++ host=host, ++ path=path, ++ upstreams=[ ++ mlrun.common.schemas.APIGatewayUpstream( ++ nucliofunction={"name": "test-function"} ++ ) ++ ], ++ ), ++ ) ++ assert gateway.get_invoke_url() == expected +diff --git a/tests/projects/test_project.py b/tests/projects/test_project.py +index f189716ad..8d976c7c0 100644 +--- a/tests/projects/test_project.py ++++ b/tests/projects/test_project.py +@@ -1893,7 +1893,7 @@ def test_create_api_gateway_valid( + assert "metadata" in gateway_dict + assert "spec" in gateway_dict + +- assert gateway.invoke_url == "https://gateway-f1-f2-project-name.some-domain.com/" ++ assert gateway.invoke_url == "https://gateway-f1-f2-project-name.some-domain.com" + if authentication_mode == mlrun.common.schemas.APIGatewayAuthenticationMode.basic: + assert gateway.authentication.authentication_mode == "basicAuth" + elif ( +@@ -1999,7 +1999,7 @@ def test_list_api_gateways(patched_list_api_gateways, context): + assert gateways[0].host == "http://gateway-f1-f2-project-name.some-domain.com" + assert gateways[0].spec.functions == ["project-name/my-func1"] + +- assert gateways[1].invoke_url == "http://test-basic-default.domain.com/" ++ assert gateways[1].invoke_url == "http://test-basic-default.domain.com" + + + def test_project_create_remote(): +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest tests/api/crud/test_functions.py tests/projects/test_project.py -x -v -k "test_set_function_deletion_task_id_updates_correctly" ++ ;; ++ new) ++ python3 -m pytest \ ++ tests/common/schemas/test_api_gateway.py::test_schema_invoke_url_does_not_keep_trailing_slash_variants \ ++ tests/api/crud/test_functions.py::test_update_functions_with_api_gateway_url \ ++ tests/projects/test_project.py::test_create_api_gateway_valid \ ++ tests/projects/test_project.py::test_list_api_gateways \ ++ -x -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001942/tests/test.sh b/tasks/format-code-task-001942/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..98e13db1034e16c8269fc749b06e1171d5ef8180 --- /dev/null +++ b/tasks/format-code-task-001942/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/api/crud/test_functions.py +tests/common/schemas/test_api_gateway.py +tests/projects/test_project.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-001942/tests/test_command.sh b/tasks/format-code-task-001942/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001942/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-001945/environment/Dockerfile b/tasks/format-code-task-001945/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a2cc78a17aea111ecf396223c4c25dbff73cb2dd --- /dev/null +++ b/tasks/format-code-task-001945/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:af20cd694d4dcc5f144bef439305fa6238ab1b7447b093054fdb107a3d0dc20e diff --git a/tasks/format-code-task-001945/environment/setup/files/blocklist b/tasks/format-code-task-001945/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001945/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001945/environment/setup/setup.sh b/tasks/format-code-task-001945/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001945/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001945/tests/test.patch b/tasks/format-code-task-001945/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e908b1fbd8206aaeb3a562abc493d7ce555aeee2 --- /dev/null +++ b/tasks/format-code-task-001945/tests/test.patch @@ -0,0 +1,133 @@ +diff --git a/mne/time_frequency/tests/test_psd.py b/mne/time_frequency/tests/test_psd.py +index 674b0e484..02d5ca060 100644 +--- a/mne/time_frequency/tests/test_psd.py ++++ b/mne/time_frequency/tests/test_psd.py +@@ -289,3 +289,115 @@ def test_compares_psd(): + + assert (np.sum(psds_welch < 0) == 0) + assert (np.sum(psds_mpl < 0) == 0) ++ ++ ++def _expected_median_bias(n): ++ ii_2 = 2 * np.arange(1., (n - 1) // 2 + 1) ++ return 1 + np.sum(1. / (ii_2 + 1) - 1. / ii_2) ++ ++ ++def test_psd_welch_median_bias_correction(): ++ """Median average should divide by Allen-2012 bias factor. ++ ++ Verifies that ``psd_array_welch(..., average='median')`` returns the ++ median of the unaggregated periodograms divided by the median bias ++ correction factor (Appendix B of Allen et al. 2012, also used by ++ SciPy's welch). ++ """ ++ rng = np.random.RandomState(0) ++ sfreq = 1000. ++ n_per_seg = 128 ++ n_overlap = 0 ++ ++ n_times = n_per_seg * 8 ++ x = rng.randn(2, n_times) ++ ++ psd_med, _ = psd_array_welch( ++ x, sfreq, n_fft=n_per_seg, n_per_seg=n_per_seg, ++ n_overlap=n_overlap, average='median') ++ psd_unagg, _ = psd_array_welch( ++ x, sfreq, n_fft=n_per_seg, n_per_seg=n_per_seg, ++ n_overlap=n_overlap, average=None) ++ ++ n_segments = psd_unagg.shape[-1] ++ assert n_segments == 8 ++ bias = _expected_median_bias(n_segments) ++ ++ assert not np.isclose(bias, 1.0) ++ expected = np.median(psd_unagg, axis=-1) / bias ++ assert_allclose(psd_med, expected) ++ ++ assert not np.allclose(psd_med, np.median(psd_unagg, axis=-1)) ++ ++ ++def test_psd_welch_median_bias_value(): ++ """Median PSD must be scaled down by the exact bias factor. ++ ++ Pins the numerical value of the bias for 8 segments, ensuring ++ candidates that compute a different bias (or skip the correction) ++ are rejected. ++ """ ++ rng = np.random.RandomState(42) ++ sfreq = 1000. ++ n_per_seg = 64 ++ ++ n_times = n_per_seg * 8 ++ x = rng.randn(1, n_times) ++ ++ psd_med, _ = psd_array_welch( ++ x, sfreq, n_fft=n_per_seg, n_per_seg=n_per_seg, ++ n_overlap=0, average='median') ++ psd_unagg, _ = psd_array_welch( ++ x, sfreq, n_fft=n_per_seg, n_per_seg=n_per_seg, ++ n_overlap=0, average=None) ++ ++ n = psd_unagg.shape[-1] ++ assert n == 8 ++ ++ ++ expected_bias = 1 + (1./3 - 1./2) + (1./5 - 1./4) + (1./7 - 1./6) ++ assert_allclose(expected_bias, 0.7595238095238095) ++ expected = np.median(psd_unagg, axis=-1) / expected_bias ++ assert_allclose(psd_med, expected) ++ ++ ++def test_psd_welch_mean_unchanged_by_bias_fix(): ++ """Mean averaging must not be affected by the median bias fix.""" ++ rng = np.random.RandomState(1) ++ sfreq = 1000. ++ n_per_seg = 128 ++ n_times = n_per_seg * 5 ++ x = rng.randn(2, n_times) ++ ++ psd_mean, _ = psd_array_welch( ++ x, sfreq, n_fft=n_per_seg, n_per_seg=n_per_seg, ++ n_overlap=0, average='mean') ++ psd_unagg, _ = psd_array_welch( ++ x, sfreq, n_fft=n_per_seg, n_per_seg=n_per_seg, ++ n_overlap=0, average=None) ++ ++ assert_allclose(psd_mean, psd_unagg.mean(axis=-1)) ++ ++ ++def test_psd_welch_median_matches_scipy(): ++ """psd_array_welch median must agree with scipy's welch median. ++ ++ SciPy's ``welch`` with ``average='median'`` applies the same Allen ++ bias correction. mne should produce equivalent values. ++ """ ++ from scipy.signal import welch as sp_welch ++ rng = np.random.RandomState(7) ++ sfreq = 1000. ++ n_per_seg = 128 ++ n_times = n_per_seg * 6 ++ x = rng.randn(1, n_times) ++ ++ psd_med, freqs = psd_array_welch( ++ x, sfreq, n_fft=n_per_seg, n_per_seg=n_per_seg, ++ n_overlap=0, average='median', window='hamming') ++ ++ sp_freqs, sp_psd = sp_welch( ++ x[0], fs=sfreq, nperseg=n_per_seg, nfft=n_per_seg, ++ noverlap=0, average='median', window='hamming') ++ assert_allclose(freqs, sp_freqs) ++ assert_allclose(psd_med[0], sp_psd) +diff --git 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_psd.py -k "median_bias or median_matches or mean_unchanged_by" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001945/tests/test.sh b/tasks/format-code-task-001945/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3ee27271986f88d00f9a14521c4b5d602366fd74 --- /dev/null +++ b/tasks/format-code-task-001945/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/time_frequency/tests/test_psd.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-001945/tests/test_command.sh b/tasks/format-code-task-001945/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001945/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001973/environment/Dockerfile b/tasks/format-code-task-001973/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1af6622d36fadc229675b4a987625dbb4b54e42d --- /dev/null +++ b/tasks/format-code-task-001973/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6d10ff6daed612b88ce50fbae4db282906e04a688af94572bb8f68c62adf00ac diff --git a/tasks/format-code-task-001973/environment/setup/files/blocklist b/tasks/format-code-task-001973/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001973/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001973/environment/setup/setup.sh b/tasks/format-code-task-001973/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001973/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001973/tests/test.patch b/tasks/format-code-task-001973/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ecd64b1ad2d43ff0f6c5e913666f0c25f999e8b --- /dev/null +++ b/tasks/format-code-task-001973/tests/test.patch @@ -0,0 +1,385 @@ +diff --git a/usercase-test-coderl/test_reporter_list_state.py b/usercase-test-coderl/test_reporter_list_state.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_reporter_list_state.py +@@ -0,0 +1,356 @@ ++import warnings ++ ++import pytest ++import torch ++ ++from homura.reporters import ReporterList ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++def _plain(value): ++ if torch.is_tensor(value): ++ if value.nelement() == 1: ++ return float(value.item()) ++ return value.tolist() ++ if isinstance(value, dict): ++ return {k: _plain(v) for k, v in value.items()} ++ return value ++ ++ ++def _calls_named(calls, name): ++ return [call for call in calls if call[0] == name] ++ ++ ++class RecordingBackend: ++ def __init__(self): ++ self.calls = [] ++ ++ @staticmethod ++ def _plain(value): ++ return _plain(value) ++ ++ def add_scalar(self, key, value, step=None): ++ self.calls.append(("add_scalar", key, self._plain(value), step)) ++ ++ def add_scalars(self, key, value, step=None): ++ self.calls.append( ++ ("add_scalars", key, {k: self._plain(v) for k, v in value.items()}, step) ++ ) ++ ++ def add_text(self, key, text, step=None): ++ self.calls.append(("add_text", key, text, step)) ++ ++ def add_figure(self, key, figure, step=None): ++ self.calls.append(("add_figure", key, figure, step)) ++ ++ def add_histogram(self, key, value, step=None, bins="tensorflow"): ++ self.calls.append(("add_histogram", key, self._plain(value), step, bins)) ++ ++ def add_image(self, key, image, step=None, normalize=False): ++ ++ self.calls.append(("add_image", key, self._plain(image), step)) ++ ++ def flush(self): ++ self.calls.append(("flush",)) ++ ++ ++class FlushOnlyBackend: ++ def flush(self): ++ pass ++ ++ ++@pytest.fixture(autouse=True) ++def clear_reporter_history(): ++ ReporterList([]).exit() ++ yield ++ ReporterList([]).exit() ++ ++ ++def test_weighted_average_history_and_scalar_backend(): ++ ++ ++ ++ backend = RecordingBackend() ++ reporter = ReporterList([backend]) ++ ++ for value, batch_size in zip( ++ [5.0, 20.0, 30.0, 1.0, 4.0, 8.0], ++ [32, 32, 32, 32, 32, 10], ++ ): ++ reporter.set_batch_size(batch_size) ++ reporter.add_value( ++ "loss", ++ torch.tensor(value), ++ is_averaged=True, ++ reduction="average", ++ no_sync=False, ++ ) ++ ++ reporter.report(step=None, mode="") ++ ++ expected_loss = ( ++ sum(v * b for v, b in zip([5.0, 20.0, 30.0, 1.0, 4.0, 8.0], [32, 32, 32, 32, 32, 10])) ++ / sum([32, 32, 32, 32, 32, 10]) ++ ) ++ ++ assert _plain(reporter.history["loss"][-1]) == pytest.approx(expected_loss) ++ assert _plain(reporter.history("loss")[-1]) == pytest.approx(expected_loss) ++ scalar_calls = _calls_named(backend.calls, "add_scalar") ++ assert len(scalar_calls) == 1 ++ _, key, value, step = scalar_calls[0] ++ assert key == "loss" ++ assert value == pytest.approx(expected_loss) ++ assert step is None ++ assert backend.calls.count(("flush",)) == 1 ++ ++ ++def test_aliases_sum_mode_and_second_report_noop(): ++ ++ ++ ++ backend = RecordingBackend() ++ reporter = ReporterList([backend]) ++ ++ reporter.set_batch_size(2) ++ reporter.add("examples", 3, is_averaged=False, reduction="sum") ++ reporter.set_batch_size(4) ++ reporter("examples", 7, is_averaged=False, reduction="sum") ++ reporter.report(step=12, mode="train") ++ reporter.report(step=13, mode="train") ++ ++ assert reporter.history["examples/train"] == [10] ++ assert reporter.history("examples/train") == [10] ++ ++ assert _calls_named(backend.calls, "add_scalar") == [ ++ ("add_scalar", "examples/train", 10, 12), ++ ] ++ assert backend.calls.count(("flush",)) == 1 ++ ++ ++def test_callable_reduction_gets_values_and_result_is_reported(): ++ ++ ++ ++ backend = RecordingBackend() ++ reporter = ReporterList([backend]) ++ reducer_inputs = [] ++ ++ def reducer(values): ++ reducer_inputs.append(list(values)) ++ return values[0] * 100 + values[-1] ++ ++ reporter.set_batch_size(1) ++ reporter.add_value("custom", 2, is_averaged=False, reduction=reducer) ++ reporter.set_batch_size(1) ++ reporter.add_value("custom", 5, is_averaged=False, reduction=reducer) ++ reporter.report(step=3, mode="") ++ ++ assert reducer_inputs == [[2, 5]] ++ assert reporter.history["custom"] == [205] ++ ++ assert _calls_named(backend.calls, "add_scalar") == [ ++ ("add_scalar", "custom", 205, 3), ++ ] ++ assert backend.calls.count(("flush",)) == 1 ++ ++ ++def test_dictionary_values_are_reduced_and_reported_as_grouped_scalars(): ++ ++ ++ ++ backend = RecordingBackend() ++ reporter = ReporterList([backend]) ++ ++ reporter.set_batch_size(2) ++ reporter.add_value( ++ "scores", ++ {"top1": torch.tensor(1.5), "top5": 4}, ++ is_averaged=False, ++ reduction="sum", ++ ) ++ reporter.set_batch_size(3) ++ reporter.add_value( ++ "scores", ++ {"top1": torch.tensor(2.5), "top5": 6}, ++ is_averaged=False, ++ reduction="sum", ++ ) ++ reporter.report(step=9, mode="eval") ++ ++ ++ assert _plain(reporter.history["scores/eval"][-1]) == { ++ "top1": pytest.approx(4.0), ++ "top5": 10, ++ } ++ assert _calls_named(backend.calls, "add_scalars") == [ ++ ("add_scalars", "scores/eval", {"top1": 4.0, "top5": 10}, 9), ++ ] ++ assert backend.calls.count(("flush",)) == 1 ++ ++ ++def test_tensor_results_dispatch_single_element_and_vector_shapes(): ++ ++ ++ ++ backend = RecordingBackend() ++ reporter = ReporterList([backend]) ++ ++ reporter.set_batch_size(1) ++ reporter.add_value("one", torch.tensor([3.5]), is_averaged=False, reduction="sum") ++ reporter.set_batch_size(1) ++ reporter.add_value( ++ "vector", ++ torch.tensor([1.0, 2.0, 4.0]), ++ is_averaged=False, ++ reduction="sum", ++ ) ++ reporter.report(step=4, mode="") ++ ++ ++ assert _plain(reporter.history["one"][-1]) == pytest.approx(3.5) ++ assert _plain(reporter.history["vector"][-1]) == pytest.approx([1.0, 2.0, 4.0]) ++ assert _calls_named(backend.calls, "add_scalar") == [ ++ ("add_scalar", "one", 3.5, 4), ++ ] ++ vector_calls = _calls_named(backend.calls, "add_scalars") ++ assert len(vector_calls) == 1 ++ _, key, values, step = vector_calls[0] ++ assert key == "vector" ++ assert {str(k): v for k, v in values.items()} == pytest.approx( ++ {"0": 1.0, "1": 2.0, "2": 4.0} ++ ) ++ assert step == 4 ++ assert backend.calls.count(("flush",)) == 1 ++ ++ ++def test_artifacts_forward_to_backends_and_missing_support_warns(): ++ ++ ++ ++ backend = RecordingBackend() ++ reporter = ReporterList([backend]) ++ figure = object() ++ ++ reporter.add_text("note", "hello", step=2) ++ reporter.add_figure("fig", figure, step=3) ++ reporter.add_histogram("hist", torch.tensor([1.0, 2.0, 3.0]), step=4, bins="fd") ++ reporter.add_image( ++ "img", ++ torch.tensor([[2.0, 4.0], [6.0, 10.0]]), ++ step=5, ++ normalize=True, ++ ) ++ ++ ++ assert ("add_text", "note", "hello", 2) in backend.calls ++ assert ("add_figure", "fig", figure, 3) in backend.calls ++ assert ("add_histogram", "hist", [1.0, 2.0, 3.0], 4, "fd") in backend.calls ++ image_calls = _calls_named(backend.calls, "add_image") ++ assert len(image_calls) == 1 ++ _, key, image, step = image_calls[0] ++ assert key == "img" ++ assert [v for row in image for v in row] == pytest.approx([0.0, 0.25, 0.5, 1.0], abs=1e-4) ++ assert min(min(row) for row in image) == pytest.approx(0.0, abs=1e-6) ++ assert max(max(row) for row in image) == pytest.approx(1.0, abs=1e-4) ++ assert step == 5 ++ ++ unsupported = ReporterList([FlushOnlyBackend()]) ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ unsupported.add_text("missing", "hello", step=1) ++ ++ ++ assert len(caught) >= 1 ++ assert any(issubclass(w.category, Warning) for w in caught) ++ ++ ++def test_invalid_reduction_string_raises_value_error(): ++ ++ ++ ++ reporter = ReporterList([RecordingBackend()]) ++ reporter.set_batch_size(1) ++ ++ with pytest.raises(ValueError): ++ reporter.add_value("loss", 1, reduction="median") ++ ++ ++def test_default_add_after_batch_size_records_weighted_average(): ++ ++ ++ ++ reporter = ReporterList([RecordingBackend()]) ++ ++ reporter.set_batch_size(4) ++ reporter.add_value("loss", torch.tensor(1.0)) ++ reporter.report() ++ ++ ++ assert _plain(reporter.history["loss"][-1]) == pytest.approx(1.0) ++ ++ ++def test_exit_is_idempotent_and_clears_history(): ++ ++ ++ ++ reporter = ReporterList([RecordingBackend()]) ++ reporter.set_batch_size(1) ++ reporter.add_value("loss", 3, is_averaged=False, reduction="sum") ++ reporter.report(step=1) ++ ++ assert reporter.history["loss"] == [3] ++ reporter.exit() ++ assert dict(reporter.history) == {} ++ reporter.exit() ++ assert dict(reporter.history) == {} ++ ++ ++def test_instances_keep_pending_epoch_values_independent(): ++ ++ ++ ++ backend_a = RecordingBackend() ++ backend_b = RecordingBackend() ++ reporter_a = ReporterList([backend_a]) ++ reporter_b = ReporterList([backend_b]) ++ ++ reporter_a.set_batch_size(1) ++ reporter_a.add_value("pending", 10, is_averaged=False, reduction="sum") ++ reporter_b.set_batch_size(1) ++ reporter_b.add_value("pending", 4, is_averaged=False, reduction="sum") ++ reporter_b.report(step=22) ++ ++ assert reporter_b.history["pending"] == [4] ++ ++ assert _calls_named(backend_b.calls, "add_scalar") == [ ++ ("add_scalar", "pending", 4, 22), ++ ] ++ assert backend_b.calls.count(("flush",)) == 1 ++ assert backend_a.calls == [] ++ ++ ++def test_exit_leak_floor_keeps_public_history_bounded_over_many_cycles(): ++ ++ ++ ++ max_history_keys_after_exit = 0 ++ ++ for i in range(120): ++ reporter = ReporterList([RecordingBackend()]) ++ reporter.set_batch_size(1) ++ reporter.add_value(f"cycle_{i}", i, is_averaged=False, reduction="sum") ++ reporter.report(step=i) ++ reporter.exit() ++ max_history_keys_after_exit = max( ++ max_history_keys_after_exit, ++ len(reporter.history), ++ ) ++ ++ assert max_history_keys_after_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,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_reporter_list_state.py -v diff --git a/tasks/format-code-task-001973/tests/test.sh b/tasks/format-code-task-001973/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c285c039e457dd259c1ebade2139b7af1e5b5ab --- /dev/null +++ b/tasks/format-code-task-001973/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_reporter_list_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-001973/tests/test_command.sh b/tasks/format-code-task-001973/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001973/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-001974/environment/Dockerfile b/tasks/format-code-task-001974/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f41faa5a35f8b7b430a89824c1c6641e8db91236 --- /dev/null +++ b/tasks/format-code-task-001974/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3959e31edc857be973b49acf837b6d6fad8d5fa32345546fba972d21be3d9d6e diff --git a/tasks/format-code-task-001974/environment/setup/files/blocklist b/tasks/format-code-task-001974/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001974/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001974/environment/setup/setup.sh b/tasks/format-code-task-001974/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001974/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001974/tests/test.patch b/tasks/format-code-task-001974/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b6a53553a3231ab90b6717f0f6e047389418eb75 --- /dev/null +++ b/tasks/format-code-task-001974/tests/test.patch @@ -0,0 +1,107 @@ +diff --git a/tests/test_pool.py b/tests/test_pool.py +index 9f4565c8..1823a22b 100644 +--- a/tests/test_pool.py ++++ b/tests/test_pool.py +@@ -60,6 +60,81 @@ async def getter(): + self.assertEqual(self.counter, self.max_size) + + ++class TestCaseClose(BaseTestCase): ++ max_size = 10 ++ ++ class Instance: ++ def __init__(self): ++ self.closed = False ++ ++ async def close(self): ++ if self.closed: ++ raise RuntimeError ++ ++ self.closed = True ++ ++ def setUp(self): ++ self.instances = set() ++ super().setUp() ++ ++ async def create_instance(self): ++ obj = TestCaseClose.Instance() ++ self.instances.add(obj) ++ return obj ++ ++ async def test_close(self): ++ async def getter(): ++ async with self.pool.acquire(): ++ await asyncio.sleep(0.05) ++ ++ self.assertFalse(self.pool.is_closed) ++ self.assertTrue(len(self.instances) == 0) ++ ++ await asyncio.gather( ++ *[getter() for _ in range(200)], ++ loop=self.loop, return_exceptions=True ++ ) ++ ++ self.assertTrue(len(self.instances) > 1) ++ ++ for instance in self.instances: ++ self.assertFalse(instance.closed) ++ ++ await self.pool.close() ++ ++ for instance in self.instances: ++ self.assertTrue(instance.closed) ++ ++ self.assertTrue(self.pool.is_closed) ++ ++ async def test_close_context_manager(self): ++ async def getter(): ++ async with self.pool.acquire(): ++ await asyncio.sleep(0.05) ++ ++ async with self.pool: ++ self.assertFalse(self.pool.is_closed) ++ ++ self.assertTrue(len(self.instances) == 0) ++ ++ await asyncio.gather( ++ *[getter() for _ in range(200)], ++ loop=self.loop, return_exceptions=True ++ ) ++ ++ self.assertTrue(len(self.instances) > 1) ++ ++ for instance in self.instances: ++ self.assertFalse(instance.closed) ++ ++ self.assertFalse(self.pool.is_closed) ++ ++ self.assertTrue(self.pool.is_closed) ++ ++ for instance in self.instances: ++ self.assertTrue(instance.closed) ++ ++ + class TestCaseNoMaxSize(BaseTestCase): + max_size = None + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SvWrDMBSGYc++inMDta0QOVOHbpnSDFk6Bf8IakgsY8mG3H1lh9JQaLMklLbv ++M+gckIQkPiXl0BzqvWnHNLqXLFhpPdfgc517pRdK6XyZr8I6pXKlI9F3u9GFwfmiF4l6a/13667N ++/1LJR/7eOL+v7PFYtHXiXm93xrX81fIi/0Ue8g8liyS73RW+9s/zr2qZgy9NHTs79JWR1Hb+/BnG ++6VuUTZsWlW/Gwpt4+7JbP2+2T7v14/s26U5TJ9Pgzvs6aw9Jd5KHMf7p9wEAAAAAAAAAAAAAAAB/ ++2RsUwYvLACgAAA== +diff --git 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-001974/tests/test.sh b/tasks/format-code-task-001974/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9d90288e3fe607c6d84b4508bc756056fbc0c920 --- /dev/null +++ b/tasks/format-code-task-001974/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_pool.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-001974/tests/test_command.sh b/tasks/format-code-task-001974/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001974/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001980/environment/Dockerfile b/tasks/format-code-task-001980/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a0d55872972f439c3d007da1e9c1daf1925e1d52 --- /dev/null +++ b/tasks/format-code-task-001980/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:78e60b7e3daa61d1a4ac362d597c047e1fb1978a84e9a337ad01a0fb225a8c57 diff --git a/tasks/format-code-task-001980/environment/setup/files/blocklist b/tasks/format-code-task-001980/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001980/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001980/environment/setup/setup.sh b/tasks/format-code-task-001980/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001980/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001980/tests/test.patch b/tasks/format-code-task-001980/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..78b73185e84b7ede1744df1ec8ff873605311032 --- /dev/null +++ b/tasks/format-code-task-001980/tests/test.patch @@ -0,0 +1,218 @@ +diff --git a/socorro/unittest/external/postgresql/test_crashes_signatures.py b/socorro/unittest/external/postgresql/test_crashes_signatures.py +index 782e6e6406..3e60cdad01 100644 +--- a/socorro/unittest/external/postgresql/test_crashes_signatures.py ++++ b/socorro/unittest/external/postgresql/test_crashes_signatures.py +@@ -139,7 +139,8 @@ def setUp(self): + win_count, + mac_count, + lin_count, +- hang_count ++ hang_count, ++ is_gc_count + ) + VALUES + ( +@@ -152,7 +153,8 @@ def setUp(self): + 12, + 1, + 1, +- 0 ++ 0, ++ 1 + ), + ( + 2, +@@ -164,7 +166,8 @@ def setUp(self): + 1, + 1, + 1, +- 0 ++ 0, ++ 1 + ), + ( + 1, +@@ -176,7 +179,8 @@ def setUp(self): + 0, + 0, + 5, +- 5 ++ 5, ++ 10 + ), + ( + 1, +@@ -188,7 +192,8 @@ def setUp(self): + 7, + 2, + 1, +- 0 ++ 0, ++ 3 + ), + ( + 3, +@@ -200,7 +205,8 @@ def setUp(self): + 12, + 1, + 1, +- 0 ++ 0, ++ 4 + ); + """ % { + 'now': self.now, +@@ -221,7 +227,8 @@ def setUp(self): + win_count, + mac_count, + lin_count, +- hang_count ++ hang_count, ++ is_gc_count + ) + VALUES + ( +@@ -235,7 +242,8 @@ def setUp(self): + 12, + 1, + 1, +- 0 ++ 0, ++ 3 + ), + ( + 2, +@@ -248,7 +256,8 @@ def setUp(self): + 1, + 1, + 1, +- 0 ++ 0, ++ 1 + ), + ( + 1, +@@ -261,7 +270,8 @@ def setUp(self): + 0, + 0, + 5, +- 5 ++ 5, ++ 2 + ), + ( + 1, +@@ -274,7 +284,8 @@ def setUp(self): + 7, + 2, + 1, +- 0 ++ 0, ++ 2 + ), + ( + 3, +@@ -287,7 +298,8 @@ def setUp(self): + 12, + 1, + 1, +- 0 ++ 0, ++ 10 + ); + """ % { + 'now': self.now, +@@ -350,7 +362,8 @@ def test_get_signatures(self): + 'signature': 'signature1', + 'versions_count': 2, + 'previousPercentOfTotal': 1.0, +- 'plugin_count': 0 ++ 'plugin_count': 0, ++ 'is_gc_count': 11L + }, + { + 'count': 3L, +@@ -371,7 +384,8 @@ def test_get_signatures(self): + 'signature': 'signature2', + 'versions_count': 6, + 'previousPercentOfTotal': 'null', +- 'plugin_count': 0 ++ 'plugin_count': 0, ++ 'is_gc_count': 1L + } + ], + 'totalNumberOfCrashes': 22L +@@ -410,7 +424,8 @@ def test_get_signatures(self): + 'signature': 'signature1', + 'versions_count': 2, + 'previousPercentOfTotal': 'null', +- 'plugin_count': 0 ++ 'plugin_count': 0, ++ 'is_gc_count': 10L + } + ], + 'totalNumberOfCrashes': 5L +@@ -449,7 +464,8 @@ def test_get_signatures(self): + 'signature': 'signature1', + 'versions_count': 2, + 'previousPercentOfTotal': 0.69999999999999996, +- 'plugin_count': 0 ++ 'plugin_count': 0, ++ 'is_gc_count': 1L + }, + { + 'count': 3L, +@@ -470,7 +486,8 @@ def test_get_signatures(self): + 'signature': 'signature2', + 'versions_count': 6, + 'previousPercentOfTotal': 'null', +- 'plugin_count': 0 ++ 'plugin_count': 0, ++ 'is_gc_count': 1L + } + ], + 'totalNumberOfCrashes': 17L +@@ -520,7 +537,8 @@ def test_get_signatures(self): + 'signature': 'signature3', + 'versions_count': 2, + 'previousPercentOfTotal': 'null', +- 'plugin_count': 14 ++ 'plugin_count': 14, ++ 'is_gc_count': 10L + } + ], + 'totalNumberOfCrashes': 14L +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+1WW4/aOBSe5/yKUzratg8hXAZmu7SVspBhkJiEkrCXp8gkJkQbbBo7bEfqj+9x ++ApRSMdOddrZarT8JEdnH3/nOxZf6vEizOKRsY509FhqIy06n/Ecc/5ffzU6r2bxsdC863bNGs9lt ++Ns6g82iKDlAISXKAs5xzeZfdffP/UdQ/1V9SIcOIr1aExXWx/H4+7qn/Rbvd3de/fdnG+l9021j/ ++xveTcBr/8/o/fWLNU2bNiVgaUQxlE8xpbBhPwWGiyClMbuWSM2jVLyEVQCKZbig8X99iy6iBiLNF ++mqBhDCmDuiLKoxcGfb/muYSJHVy/rp1fezeOVS/XKHe/nKvxmkE3JIPa+Y6MpRLMF8fDmzSXBcnw ++09xbVDNJxudoicrqzZ+VYl/yNUyG0OxCugC0RX15wVjKEsAQSkWdi3bLWCdhJLMow+LTXJmvCIoX ++annrjRXTjcWKLIMPH0DmBa2oiQpnCC/r3c+4lCfGJZAspyS+3fkzcPgJWIXIrYxHJLPWyctumWr0 ++nYrK1lxCObnkAuNaV3zmu0MNPZBLygxAiCLmYBboWsgkp+IUO0YG5gCsDcHZdG7t7N9lFoq3ylDN ++7OR8xpNFmlFQ+0JWjjNKMTHGIlWZ6KN2SUEdFJxV1cfKwoLnSiqoBoKYSIKdoKwYo9gynBnRet9d ++luARz3NuFVhQNWZVPNYRaT1Okeyfrjro3SiV9L0E/FEmUAR+IaMwvi6VmJGjEsWw1RCmTNIkJyqy ++sAzZjKDWnzp24IDzR+C4/shzYXQFrhfgwMgP/K2aXu1Uj01pVOVW5XGfQsmrUsAChS4fKv3Vq2f+ ++2/EzYzD1JjCwA/tX23eUvq22U3H1jG1Q+zUnM+D97jpTmGMIf61JHOZ/9wx0qQIbc4KZi5Z0RQAv ++FyAxHhYiTCK8bgomsUuyYsV+cFUexf0GPDd0plNvGvqBN3ndAHNx0NC45aq01BXtQVe03vzUfAxB ++uzawxwHWCis6dkBGcwH2YAB9bzy7OU7PYZ1KOjww1bQ7G49h4FzZs3EAjd4XjGH5sPh23uHUdgOw ++cXAyHf02GjtDx8ekliOlNx9GLvj9a+fGhnUxz9IIAu/zNryLw3fezhy3/600VzO3H2BzfTXNzLeH ++jlr9cJ93hF9t3YfHff/6uwOu1m+3/7Rg1dVA8oTKcs6Y/Blce275PNhtB1hXLw1zhRcqHnxfHPfq ++GM+Zav5PN1b1aM3x1UFFKNKEEYkHv1A3krkxfvTrSkNDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0Pj ++38VHY6GTHwAoAAA= +diff --git 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-001980/tests/test.sh b/tasks/format-code-task-001980/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..442d19616408dfa5085a62b8d014b02565f0ed20 --- /dev/null +++ b/tasks/format-code-task-001980/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' +socorro/unittest/external/postgresql/test_crashes_signatures.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-001980/tests/test_command.sh b/tasks/format-code-task-001980/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001980/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001987/environment/Dockerfile b/tasks/format-code-task-001987/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e4d8d133984f642d34efdba5b0a30982c9df8b48 --- /dev/null +++ b/tasks/format-code-task-001987/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b47a18093ef52e320bb1ec2db5ec42f77de5e6241a98266cf9c34ae9397f83b1 diff --git a/tasks/format-code-task-001987/environment/setup/files/blocklist b/tasks/format-code-task-001987/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001987/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001987/environment/setup/setup.sh b/tasks/format-code-task-001987/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001987/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001987/tests/test.patch b/tasks/format-code-task-001987/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..09ea7b0e15d9aaf2d35eb97726bd1014fde63c5f --- /dev/null +++ b/tasks/format-code-task-001987/tests/test.patch @@ -0,0 +1,57 @@ +diff --git a/tests/tests.py b/tests/tests.py +index 27f3660..9cf003e 100644 +--- a/tests/tests.py ++++ b/tests/tests.py +@@ -33,6 +33,31 @@ def __init__(self, **kw): + model_cache.append(self) + + ++class ESTest(TestCase): ++ def test_get_es_defaults(self): ++ es = get_es() ++ eq_(es.timeout, settings.ES_TIMEOUT) ++ ++ ++ eq_(es.dump_curl, None) ++ eq_(es.default_indexes, [settings.ES_INDEXES['default']]) ++ ++ def test_get_es(self): ++ class Dumper(object): ++ def write(self, val): ++ print val ++ ++ d = Dumper() ++ ++ es = get_es( ++ timeout=20, ++ dump_curl=d, ++ default_indexes=['joe']) ++ eq_(es.timeout, 20) ++ eq_(es.dump_curl, d) ++ eq_(es.default_indexes, ['joe']) ++ ++ + class QueryTest(TestCase): + index_name = settings.ES_INDEXES['default'] + +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+3SQWuDMBQH8Jz9FA/xsB20SdooFHbYodDL2GC9F62BCjURk8r67adhsDHYemkZ ++2/6/Q57kBX3yT1Ydm0O91WaYsWvho0KpUEefa3gWSgrJ53MuF4wLoQrBSF1tog+Ozpc9Eeut9d+d ++O9f/pbL3/L12fruzbVuaOnP7y33jXP5i7L3lLwuZj/kvcpEz4pcb4Wv/PP9dTSH4SteRfuls7+np ++frO+i5P148NqlnWn6WpUjVkm034c6aE8UJzchAY1pvGU3sZRd/J7ayhtyVinaXqly8K6XD1vxkrp ++EP30zwIAAAAAAAAAAAAAAAAAAAAA/DGvXSw0CQAoAAA= +diff --git 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-001987/tests/test.sh b/tasks/format-code-task-001987/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e2e709d7e7e4e1a39557f1daceab0b24a25658d7 --- /dev/null +++ b/tasks/format-code-task-001987/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/tests.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-001987/tests/test_command.sh b/tasks/format-code-task-001987/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001987/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001989/environment/Dockerfile b/tasks/format-code-task-001989/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..241eced3d122a31962aff92874dc3ed7dc1d88e9 --- /dev/null +++ b/tasks/format-code-task-001989/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f00baa32842715ec88f332d3067468758a18e93e808f491e85c08124aff4e5d0 diff --git a/tasks/format-code-task-001989/environment/setup/files/blocklist b/tasks/format-code-task-001989/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001989/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001989/environment/setup/setup.sh b/tasks/format-code-task-001989/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001989/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001989/tests/test.patch b/tasks/format-code-task-001989/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3cde80ff96dd57cd09c9d13636c875d8c3739c65 --- /dev/null +++ b/tasks/format-code-task-001989/tests/test.patch @@ -0,0 +1,154 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..ff1b613 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node test_content_semicolon.js"] ++} +diff --git a/test_content_semicolon.js b/test_content_semicolon.js +new file mode 100644 +index 0000000..b8546c7 +--- /dev/null ++++ b/test_content_semicolon.js +@@ -0,0 +1,126 @@ ++ ++ ++ ++ ++ ++var Slowparse = require("./slowparse.js"), ++ jsdom = require("jsdom").jsdom, ++ document = jsdom(""), ++ validators = require("./test/node/qunit-shim.js")(Slowparse, jsdom); ++ ++var test = validators.test; ++var equal = validators.equal; ++ ++test("content with single-quoted semicolon then next property", function() { ++ var css = "h1::before{content:'<';color:red}"; ++ var html = ''; ++ var result = Slowparse.HTML(document, html); ++ equal(result.error, null); ++ var styleContents = result.document.childNodes[0].childNodes[0]; ++ var rule = styleContents.parseInfo.rules[0]; ++ equal(rule.declarations.properties.length, 2); ++ equal(rule.declarations.properties[0].name.value, "content"); ++ equal(rule.declarations.properties[0].value.value, "'<'"); ++ equal(rule.declarations.properties[1].name.value, "color"); ++ equal(rule.declarations.properties[1].value.value, "red"); ++}); ++ ++test("content with double-quoted semicolon then next property", function() { ++ var css = 'h1::before{content:"a;b";color:red}'; ++ var html = ''; ++ var result = Slowparse.HTML(document, html); ++ equal(result.error, null); ++ var styleContents = result.document.childNodes[0].childNodes[0]; ++ var rule = styleContents.parseInfo.rules[0]; ++ equal(rule.declarations.properties.length, 2); ++ equal(rule.declarations.properties[0].name.value, "content"); ++ equal(rule.declarations.properties[0].value.value, '"a;b"'); ++ equal(rule.declarations.properties[1].name.value, "color"); ++ equal(rule.declarations.properties[1].value.value, "red"); ++}); ++ ++test("content with multiple semicolons inside quotes", function() { ++ var css = "h1::before{content:'a;b;c;d';color:red}"; ++ var html = ''; ++ var result = Slowparse.HTML(document, html); ++ equal(result.error, null); ++ var styleContents = result.document.childNodes[0].childNodes[0]; ++ var rule = styleContents.parseInfo.rules[0]; ++ equal(rule.declarations.properties.length, 2); ++ equal(rule.declarations.properties[0].value.value, "'a;b;c;d'"); ++ equal(rule.declarations.properties[1].value.value, "red"); ++}); ++ ++test("content with semicolon inside quotes and trailing semicolon only", function() { ++ var css = "h1::before{content:'a;b';}"; ++ var html = ''; ++ var result = Slowparse.HTML(document, html); ++ equal(result.error, null); ++ var styleContents = result.document.childNodes[0].childNodes[0]; ++ var rule = styleContents.parseInfo.rules[0]; ++ equal(rule.declarations.properties.length, 1); ++ equal(rule.declarations.properties[0].name.value, "content"); ++ equal(rule.declarations.properties[0].value.value, "'a;b'"); ++}); ++ ++test("content following another property, with quoted semicolon", function() { ++ var css = "h1::before{color:red;content:'<';font-weight:bold}"; ++ var html = ''; ++ var result = Slowparse.HTML(document, html); ++ equal(result.error, null); ++ var styleContents = result.document.childNodes[0].childNodes[0]; ++ var rule = styleContents.parseInfo.rules[0]; ++ equal(rule.declarations.properties.length, 3); ++ equal(rule.declarations.properties[0].name.value, "color"); ++ equal(rule.declarations.properties[0].value.value, "red"); ++ equal(rule.declarations.properties[1].name.value, "content"); ++ equal(rule.declarations.properties[1].value.value, "'<'"); ++ equal(rule.declarations.properties[2].name.value, "font-weight"); ++ equal(rule.declarations.properties[2].value.value, "bold"); ++}); ++ ++test("content with escaped quote followed by semicolon inside quotes", function() { ++ ++ var css = "h1::before{content:'\\\';';color:red}"; ++ var html = ''; ++ var result = Slowparse.HTML(document, html); ++ equal(result.error, null); ++ var styleContents = result.document.childNodes[0].childNodes[0]; ++ var rule = styleContents.parseInfo.rules[0]; ++ equal(rule.declarations.properties.length, 2); ++ equal(rule.declarations.properties[0].name.value, "content"); ++ equal(rule.declarations.properties[1].name.value, "color"); ++ equal(rule.declarations.properties[1].value.value, "red"); ++}); ++ ++test("content without semicolon inside quotes still parses (preservation)", function() { ++ var css = "h1::before{content:'hello';color:red}"; ++ var html = ''; ++ var result = Slowparse.HTML(document, html); ++ equal(result.error, null); ++ var styleContents = result.document.childNodes[0].childNodes[0]; ++ var rule = styleContents.parseInfo.rules[0]; ++ equal(rule.declarations.properties.length, 2); ++ equal(rule.declarations.properties[0].value.value, "'hello'"); ++ equal(rule.declarations.properties[1].value.value, "red"); ++}); ++ ++test("regular non-content CSS still parses normally (preservation)", function() { ++ var css = "body { color: pink; font-size: 12px; }"; ++ var html = ''; ++ var result = Slowparse.HTML(document, html); ++ equal(result.error, null); ++ var styleContents = result.document.childNodes[0].childNodes[0]; ++ var rule = styleContents.parseInfo.rules[0]; ++ equal(rule.declarations.properties.length, 2); ++ equal(rule.declarations.properties[0].name.value, "color"); ++ equal(rule.declarations.properties[0].value.value, "pink"); ++ equal(rule.declarations.properties[1].name.value, "font-size"); ++ equal(rule.declarations.properties[1].value.value, "12px"); ++}); ++ ++var failCount = validators.getFailCount(); ++if (failCount > 0) { ++ console.log(failCount + " tests failed."); ++} ++process.exit(failCount); +diff --git 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_content_semicolon.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001989/tests/test.sh b/tasks/format-code-task-001989/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc229e1ab7484b5b3309c94e708bf70107d26c6c --- /dev/null +++ b/tasks/format-code-task-001989/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +test_content_semicolon.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-001989/tests/test_command.sh b/tasks/format-code-task-001989/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001989/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002133/environment/Dockerfile b/tasks/format-code-task-002133/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0a3c8f6b418b0210021cb7b2c5f6e8782779a06e --- /dev/null +++ b/tasks/format-code-task-002133/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9b0cce3c858d786e182c8c89bdd4e311482e189e522d332eb34e6cd09779025d diff --git a/tasks/format-code-task-002133/environment/setup/files/blocklist b/tasks/format-code-task-002133/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002133/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002133/environment/setup/setup.sh b/tasks/format-code-task-002133/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002133/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002133/tests/test.patch b/tasks/format-code-task-002133/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3f415afd64b18cd26bae262a0b832606dd47e454 --- /dev/null +++ b/tasks/format-code-task-002133/tests/test.patch @@ -0,0 +1,322 @@ +diff --git a/libcontainer/configs/validate/idmap_codespec_test.go b/libcontainer/configs/validate/idmap_codespec_test.go +new file mode 100644 +index 00000000..16873206 +--- /dev/null ++++ b/libcontainer/configs/validate/idmap_codespec_test.go +@@ -0,0 +1,303 @@ ++package validate_test ++ ++import ( ++ "math" ++ "strconv" ++ "testing" ++ ++ "github.com/opencontainers/runc/libcontainer/configs" ++ "github.com/opencontainers/runc/libcontainer/configs/validate" ++) ++ ++func codespecMappedConfig() *configs.Config { ++ return &configs.Config{ ++ Rootfs: "/var", ++ Namespaces: configs.Namespaces{ ++ {Type: configs.NEWUSER}, ++ }, ++ UidMappings: []configs.IDMap{ ++ {ContainerID: 0, HostID: 100000, Size: 10}, ++ }, ++ GidMappings: []configs.IDMap{ ++ {ContainerID: 0, HostID: 200000, Size: 10}, ++ }, ++ } ++} ++ ++func codespecValidate(t *testing.T, config *configs.Config) error { ++ t.Helper() ++ return validate.New().Validate(config) ++} ++ ++func TestCodespecUserNamespaceRequiresCompleteRootMappings(t *testing.T) { ++ tests := []struct { ++ name string ++ mutate func(*configs.Config) ++ }{ ++ {"missing uid mappings", func(c *configs.Config) { c.UidMappings = nil }}, ++ {"missing gid mappings", func(c *configs.Config) { c.GidMappings = nil }}, ++ {"uid root unmapped", func(c *configs.Config) { c.UidMappings[0].ContainerID = 1 }}, ++ {"gid root unmapped", func(c *configs.Config) { c.GidMappings[0].ContainerID = 1 }}, ++ } ++ ++ for _, test := range tests { ++ t.Run(test.name, func(t *testing.T) { ++ config := codespecMappedConfig() ++ test.mutate(config) ++ if err := codespecValidate(t, config); err == nil { ++ t.Fatalf("validator accepted user namespace with %s", test.name) ++ } ++ }) ++ } ++} ++ ++func TestCodespecIDMappingRejectsInvalidRanges(t *testing.T) { ++ tests := []struct { ++ name string ++ mutate func(*configs.Config) ++ }{ ++ {"zero uid size", func(c *configs.Config) { c.UidMappings[0].Size = 0 }}, ++ {"zero gid size", func(c *configs.Config) { c.GidMappings[0].Size = 0 }}, ++ {"negative uid size", func(c *configs.Config) { c.UidMappings[0].Size = -1 }}, ++ {"negative gid size", func(c *configs.Config) { c.GidMappings[0].Size = -1 }}, ++ {"negative uid container start", func(c *configs.Config) { c.UidMappings[0].ContainerID = -1 }}, ++ {"negative uid host start", func(c *configs.Config) { c.UidMappings[0].HostID = -1 }}, ++ {"negative gid container start", func(c *configs.Config) { c.GidMappings[0].ContainerID = -1 }}, ++ {"negative gid host start", func(c *configs.Config) { c.GidMappings[0].HostID = -1 }}, ++ {"uid container arithmetic overflow", func(c *configs.Config) { ++ c.UidMappings[0] = configs.IDMap{ContainerID: math.MaxInt - 1, HostID: 100000, Size: 3} ++ }}, ++ {"uid host arithmetic overflow", func(c *configs.Config) { ++ c.UidMappings[0] = configs.IDMap{ContainerID: 0, HostID: math.MaxInt - 1, Size: 3} ++ }}, ++ {"gid container arithmetic overflow", func(c *configs.Config) { ++ c.GidMappings[0] = configs.IDMap{ContainerID: math.MaxInt - 1, HostID: 200000, Size: 3} ++ }}, ++ {"gid host arithmetic overflow", func(c *configs.Config) { ++ c.GidMappings[0] = configs.IDMap{ContainerID: 0, HostID: math.MaxInt - 1, Size: 3} ++ }}, ++ } ++ ++ if strconv.IntSize == 64 { ++ const unmappableID = uint64(math.MaxUint32) ++ tests = append(tests, ++ struct { ++ name string ++ mutate func(*configs.Config) ++ }{"reserved uid value", func(c *configs.Config) { ++ c.UidMappings[0] = configs.IDMap{ContainerID: 0, HostID: int(unmappableID), Size: 1} ++ }}, ++ struct { ++ name string ++ mutate func(*configs.Config) ++ }{"reserved gid value", func(c *configs.Config) { ++ c.GidMappings[0] = configs.IDMap{ContainerID: int(unmappableID), HostID: 200000, Size: 1} ++ }}, ++ struct { ++ name string ++ mutate func(*configs.Config) ++ }{"uid range reaches reserved value", func(c *configs.Config) { ++ c.UidMappings = []configs.IDMap{ ++ {ContainerID: 0, HostID: 100000, Size: 1}, ++ {ContainerID: int(unmappableID) - 1, HostID: 200000, Size: 2}, ++ } ++ }}, ++ struct { ++ name string ++ mutate func(*configs.Config) ++ }{"gid range reaches reserved value", func(c *configs.Config) { ++ c.GidMappings = []configs.IDMap{ ++ {ContainerID: 0, HostID: 200000, Size: 1}, ++ {ContainerID: 300000, HostID: int(unmappableID) - 1, Size: 2}, ++ } ++ }}, ++ ) ++ } ++ ++ for _, test := range tests { ++ t.Run(test.name, func(t *testing.T) { ++ config := codespecMappedConfig() ++ test.mutate(config) ++ if err := codespecValidate(t, config); err == nil { ++ t.Fatalf("validator accepted invalid ID mapping: %s", test.name) ++ } ++ }) ++ } ++} ++ ++func TestCodespecMappingsWithoutUserNamespaceAreRejected(t *testing.T) { ++ for _, test := range []struct { ++ name string ++ mutate func(*configs.Config) ++ }{ ++ {"uid only", func(c *configs.Config) { ++ c.UidMappings = []configs.IDMap{{ContainerID: 0, HostID: 100000, Size: 1}} ++ }}, ++ {"gid only", func(c *configs.Config) { ++ c.GidMappings = []configs.IDMap{{ContainerID: 0, HostID: 200000, Size: 1}} ++ }}, ++ } { ++ t.Run(test.name, func(t *testing.T) { ++ config := &configs.Config{Rootfs: "/var"} ++ test.mutate(config) ++ if err := codespecValidate(t, config); err == nil { ++ t.Fatalf("validator accepted %s mappings without NEWUSER", test.name) ++ } ++ }) ++ } ++} ++ ++func TestCodespecIDMappingRejectsOverlapsInEitherCoordinateSpace(t *testing.T) { ++ tests := []struct { ++ name string ++ mutate func(*configs.Config) ++ }{ ++ {"uid container overlap", func(c *configs.Config) { ++ c.UidMappings = append(c.UidMappings, configs.IDMap{ContainerID: 9, HostID: 300000, Size: 2}) ++ }}, ++ {"uid host overlap", func(c *configs.Config) { ++ c.UidMappings = append(c.UidMappings, configs.IDMap{ContainerID: 20, HostID: 100009, Size: 2}) ++ }}, ++ {"gid container overlap", func(c *configs.Config) { ++ c.GidMappings = append(c.GidMappings, configs.IDMap{ContainerID: 9, HostID: 300000, Size: 2}) ++ }}, ++ {"gid host overlap", func(c *configs.Config) { ++ c.GidMappings = append(c.GidMappings, configs.IDMap{ContainerID: 20, HostID: 200009, Size: 2}) ++ }}, ++ } ++ ++ for _, test := range tests { ++ t.Run(test.name, func(t *testing.T) { ++ config := codespecMappedConfig() ++ test.mutate(config) ++ if err := codespecValidate(t, config); err == nil { ++ t.Fatalf("validator accepted overlapping ranges: %s", test.name) ++ } ++ }) ++ } ++} ++ ++func TestCodespecIDMappingAllowsAdjacentUnsortedAndIndependentRanges(t *testing.T) { ++ config := codespecMappedConfig() ++ config.UidMappings = []configs.IDMap{ ++ {ContainerID: 20, HostID: 400020, Size: 5}, ++ {ContainerID: 0, HostID: 400000, Size: 10}, ++ {ContainerID: 10, HostID: 400010, Size: 10}, ++ } ++ ++ config.GidMappings = append([]configs.IDMap(nil), config.UidMappings...) ++ if strconv.IntSize == 64 { ++ const largestUsableID = int64(math.MaxUint32 - 1) ++ last := configs.IDMap{ContainerID: int(largestUsableID), HostID: int(largestUsableID), Size: 1} ++ config.UidMappings = append(config.UidMappings, last) ++ config.GidMappings = append(config.GidMappings, last) ++ } ++ ++ if err := codespecValidate(t, config); err != nil { ++ t.Fatalf("validator rejected adjacent, unsorted, independent mappings: %v", err) ++ } ++} ++ ++func TestCodespecHostIDTranslationUsesHalfOpenRanges(t *testing.T) { ++ config := codespecMappedConfig() ++ config.UidMappings = []configs.IDMap{ ++ {ContainerID: 20, HostID: 3020, Size: 3}, ++ {ContainerID: 0, HostID: 1000, Size: 2}, ++ {ContainerID: 10, HostID: 2010, Size: 2}, ++ } ++ config.GidMappings = []configs.IDMap{ ++ {ContainerID: 30, HostID: 4030, Size: 2}, ++ {ContainerID: 0, HostID: 5000, Size: 1}, ++ } ++ ++ uidTests := map[int]int{0: 1000, 1: 1001, 10: 2010, 11: 2011, 20: 3020, 22: 3022} ++ for containerID, expected := range uidTests { ++ actual, err := config.HostUID(containerID) ++ if err != nil || actual != expected { ++ t.Fatalf("HostUID(%d) = (%d, %v), want (%d, nil)", containerID, actual, err, expected) ++ } ++ } ++ for _, unmapped := range []int{-1, 2, 12, 23} { ++ if hostID, err := config.HostUID(unmapped); err == nil { ++ t.Fatalf("HostUID(%d) returned unmapped host ID %d", unmapped, hostID) ++ } ++ } ++ ++ gidTests := map[int]int{0: 5000, 30: 4030, 31: 4031} ++ for containerID, expected := range gidTests { ++ actual, err := config.HostGID(containerID) ++ if err != nil || actual != expected { ++ t.Fatalf("HostGID(%d) = (%d, %v), want (%d, nil)", containerID, actual, err, expected) ++ } ++ } ++ for _, unmapped := range []int{-1, 1, 32} { ++ if hostID, err := config.HostGID(unmapped); err == nil { ++ t.Fatalf("HostGID(%d) returned unmapped host ID %d", unmapped, hostID) ++ } ++ } ++} ++ ++func TestCodespecTranslationRejectsMalformedOrOverflowingMaps(t *testing.T) { ++ badMaps := []struct { ++ name string ++ maps []configs.IDMap ++ }{ ++ {"zero size", []configs.IDMap{{ContainerID: 0, HostID: 10, Size: 0}}}, ++ {"overlap", []configs.IDMap{ ++ {ContainerID: 0, HostID: 10, Size: 2}, ++ {ContainerID: 1, HostID: 20, Size: 2}, ++ }}, ++ {"translated host overflow", []configs.IDMap{{ContainerID: 0, HostID: math.MaxInt, Size: 2}}}, ++ } ++ ++ for _, test := range badMaps { ++ t.Run(test.name, func(t *testing.T) { ++ config := &configs.Config{ ++ Namespaces: configs.Namespaces{{Type: configs.NEWUSER}}, ++ UidMappings: test.maps, ++ GidMappings: test.maps, ++ } ++ if hostID, err := config.HostUID(1); err == nil { ++ t.Fatalf("HostUID used malformed %s map and returned %d", test.name, hostID) ++ } ++ if hostID, err := config.HostGID(1); err == nil { ++ t.Fatalf("HostGID used malformed %s map and returned %d", test.name, hostID) ++ } ++ }) ++ } ++} ++ ++func TestCodespecNoUserNamespaceKeepsIdentityTranslation(t *testing.T) { ++ config := &configs.Config{} ++ for _, id := range []int{-1, 0, 42, math.MaxInt} { ++ uid, uidErr := config.HostUID(id) ++ gid, gidErr := config.HostGID(id) ++ if uidErr != nil || uid != id || gidErr != nil || gid != id { ++ t.Fatalf("identity translation for %d returned uid=(%d,%v), gid=(%d,%v)", id, uid, uidErr, gid, gidErr) ++ } ++ } ++} ++ ++func TestCodespecRootlessMountIDsUseCompleteValidatedRanges(t *testing.T) { ++ config := codespecMappedConfig() ++ config.RootlessEUID = true ++ config.UidMappings = []configs.IDMap{ ++ {ContainerID: 20, HostID: 100020, Size: 3}, ++ {ContainerID: 0, HostID: 100000, Size: 2}, ++ } ++ config.GidMappings = []configs.IDMap{ ++ {ContainerID: 0, HostID: 200000, Size: 2}, ++ {ContainerID: 30, HostID: 200030, Size: 3}, ++ } ++ config.Mounts = []*configs.Mount{{Destination: "/dev/pts", Data: "uid=22,gid=32"}} ++ if err := codespecValidate(t, config); err != nil { ++ t.Fatalf("validator rejected mapped endpoint IDs in rootless mount: %v", err) ++ } ++ ++ for _, data := range []string{"uid=23,gid=32", "uid=22,gid=33"} { ++ config.Mounts[0].Data = data ++ if err := codespecValidate(t, config); err == nil { ++ t.Fatalf("validator accepted unmapped rootless mount option %q", data) ++ } ++ } ++} + +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,7 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./libcontainer/configs ./libcontainer/configs/validate \ ++ -run '^(TestCodespec|TestHostRoot|TestValidateUsernamespaceWithoutUserNS|TestValidateRootlessEUIDMount)' \ ++ -count=1 diff --git a/tasks/format-code-task-002133/tests/test.sh b/tasks/format-code-task-002133/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c5c7a8c042cd1e184e35dedb11822943ff8c9148 --- /dev/null +++ b/tasks/format-code-task-002133/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' +libcontainer/configs/validate/idmap_codespec_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-002133/tests/test_command.sh b/tasks/format-code-task-002133/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002133/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002134/environment/Dockerfile b/tasks/format-code-task-002134/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c1a2a67796a095000c7769345b510207e2b96e8f --- /dev/null +++ b/tasks/format-code-task-002134/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:eac6811e7087afb00238478f22d7326a697d1351b092d6a2ad3c453312c9f46e diff --git a/tasks/format-code-task-002134/environment/setup/files/blocklist b/tasks/format-code-task-002134/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002134/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002134/environment/setup/setup.sh b/tasks/format-code-task-002134/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002134/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002134/tests/test.patch b/tasks/format-code-task-002134/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4ce5ddaab76f5382ac57d9fe34dc488764df29c7 --- /dev/null +++ b/tasks/format-code-task-002134/tests/test.patch @@ -0,0 +1,539 @@ +diff --git a/tests/powershell_search_stix_result.json b/tests/powershell_search_stix_result.json +new file mode 100644 +index 00000000..3bde4733 +--- /dev/null ++++ b/tests/powershell_search_stix_result.json +@@ -0,0 +1,393 @@ ++{ ++ "type": "bundle", ++ "id": "bundle--11e77454-448c-4229-9927-624b43826ad3", ++ "spec_version": "2.0", ++ "objects": [ ++ { ++ "type": "identity", ++ "id": "identity--3532c56d-ea72-48be-a2ad-1a53f4c9c6d3", ++ "name": "CbCloud" ++ }, ++ { ++ "id": "observed-data--522acfb0-2b9f-4695-9dbf-37e2572e7139", ++ "type": "observed-data", ++ "created_by_ref": "identity--3532c56d-ea72-48be-a2ad-1a53f4c9c6d3", ++ "created": "2021-08-05T13:03:25.633Z", ++ "modified": "2021-08-05T13:03:25.633Z", ++ "objects": { ++ "0": { ++ "type": "x-cbcloud", ++ "childproc_count": 0, ++ "crossproc_count": 0, ++ "device_external_ip": "192.168.100.212", ++ "device_group_id": 0, ++ "device_id": 27969132, ++ "device_name": "windows10-lab2", ++ "device_os": "WINDOWS", ++ "device_timestamp": "2021-02-26T08:14:22.562Z", ++ "filemod_count": 0, ++ "modload_count": 0, ++ "netconn_count": 0, ++ "org_id": "MYORGIDX", ++ "regmod_count": 0, ++ "scriptload_count": 0 ++ }, ++ "1": { ++ "type": "process", ++ "x_unique_id": "MYORGIDX-01aac66c-00000820-00000000-1d70c280e79cd04", ++ "name": "compattelrunner.exe", ++ "binary_ref": "2", ++ "pid": 2080 ++ }, ++ "2": { ++ "type": "file", ++ "name": "compattelrunner.exe", ++ "hashes": { ++ "SHA-256": "c0a5986a4dd6d7cacf09c5a980df634c44ff73028206d99cb561e64a74a0958a" ++ }, ++ "parent_directory_ref": "7" ++ }, ++ "3": { ++ "type": "process", ++ "parent_ref": "1", ++ "command_line": "powershell.exe -ExecutionPolicy Restricted -Command $Res = 0; if((Get-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole).State -eq 'Enabled') { $Path = $env:windir + '\\system32\\inetsrv\\config\\applicationHost.Config'; if (Test-Path -Path $Path) { try { [XML]$Xml = Get-Content $Path } catch { $Res = 1 } }; } Write-Host 'Final result:',$Res", ++ "x_unique_id": "MYORGIDX-01aac66c-00001170-00000000-1d70c2820408601", ++ "name": "powershell.exe", ++ "binary_ref": "4", ++ "pid": 4464, ++ "created": "2021-02-26T09:14:15.304Z", ++ "creator_user_ref": "5" ++ }, ++ "4": { ++ "type": "file", ++ "name": "powershell.exe", ++ "hashes": { ++ "MD5": "7353f60b1739074eb17c5f4dddefe239", ++ "SHA-256": "de96a6e69944335375dc1ac238336066889d9ffc7d73628ef4fe1b1b160ab32c" ++ }, ++ "parent_directory_ref": "6" ++ }, ++ "5": { ++ "type": "user-account", ++ "user_id": "NT AUTHORITY\\SYSTEM" ++ }, ++ "6": { ++ "type": "directory", ++ "path": "c:\\windows\\system32\\windowspowershell\\v1.0" ++ }, ++ "7": { ++ "type": "directory", ++ "path": "c:\\windows\\system32" ++ } ++ }, ++ "first_observed": "2021-02-26T08:14:22.562Z", ++ "last_observed": "2021-02-26T08:14:22.562Z", ++ "number_observed": 1 ++ }, ++ { ++ "id": "observed-data--de6ca397-e7b6-4e48-8bfa-f85999fc26e5", ++ "type": "observed-data", ++ "created_by_ref": "identity--3532c56d-ea72-48be-a2ad-1a53f4c9c6d3", ++ "created": "2021-08-05T13:03:25.634Z", ++ "modified": "2021-08-05T13:03:25.634Z", ++ "objects": { ++ "0": { ++ "type": "x-cbcloud", ++ "childproc_count": 0, ++ "crossproc_count": 0, ++ "device_external_ip": "192.168.100.212", ++ "device_group_id": 0, ++ "device_id": 27969132, ++ "device_name": "windows10-lab2", ++ "device_os": "WINDOWS", ++ "device_timestamp": "2021-03-19T15:16:28.196Z", ++ "filemod_count": 0, ++ "modload_count": 0, ++ "netconn_count": 0, ++ "org_id": "MYORGIDX", ++ "regmod_count": 0, ++ "scriptload_count": 0 ++ }, ++ "1": { ++ "type": "process", ++ "x_unique_id": "MYORGIDX-01aac66c-00001a58-00000000-1d71ce346740e1e", ++ "name": "compattelrunner.exe", ++ "binary_ref": "2", ++ "pid": 6744 ++ }, ++ "2": { ++ "type": "file", ++ "name": "compattelrunner.exe", ++ "hashes": { ++ "SHA-256": "c0a5986a4dd6d7cacf09c5a980df634c44ff73028206d99cb561e64a74a0958a" ++ }, ++ "parent_directory_ref": "7" ++ }, ++ "3": { ++ "type": "process", ++ "parent_ref": "1", ++ "command_line": "powershell.exe -ExecutionPolicy Restricted -Command $Res = 0; if((Get-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole).State -eq 'Enabled') { $Path = $env:windir + '\\system32\\inetsrv\\config\\applicationHost.Config'; if (Test-Path -Path $Path) { try { [XML]$Xml = Get-Content $Path } catch { $Res = 1 } }; } Write-Host 'Final result:',$Res", ++ "x_unique_id": "MYORGIDX-01aac66c-00001c6c-00000000-1d71ce37d053a33", ++ "name": "powershell.exe", ++ "binary_ref": "4", ++ "pid": 7276, ++ "created": "2021-03-19T16:16:04.136Z", ++ "creator_user_ref": "5" ++ }, ++ "4": { ++ "type": "file", ++ "name": "powershell.exe", ++ "hashes": { ++ "MD5": "7353f60b1739074eb17c5f4dddefe239", ++ "SHA-256": "de96a6e69944335375dc1ac238336066889d9ffc7d73628ef4fe1b1b160ab32c" ++ }, ++ "parent_directory_ref": "6" ++ }, ++ "5": { ++ "type": "user-account", ++ "user_id": "NT AUTHORITY\\SYSTEM" ++ }, ++ "6": { ++ "type": "directory", ++ "path": "c:\\windows\\system32\\windowspowershell\\v1.0" ++ }, ++ "7": { ++ "type": "directory", ++ "path": "c:\\windows\\system32" ++ } ++ }, ++ "first_observed": "2021-03-19T15:16:28.196Z", ++ "last_observed": "2021-03-19T15:16:28.196Z", ++ "number_observed": 1 ++ }, ++ { ++ "id": "observed-data--7b5a131e-c9b9-4f32-b5fa-b5f48f9208f8", ++ "type": "observed-data", ++ "created_by_ref": "identity--3532c56d-ea72-48be-a2ad-1a53f4c9c6d3", ++ "created": "2021-08-05T13:03:25.634Z", ++ "modified": "2021-08-05T13:03:25.634Z", ++ "objects": { ++ "0": { ++ "type": "x-cbcloud", ++ "childproc_count": 0, ++ "crossproc_count": 0, ++ "device_external_ip": "192.168.100.212", ++ "device_group_id": 0, ++ "device_id": 27969112, ++ "device_name": "windows10-lab1", ++ "device_os": "WINDOWS", ++ "device_timestamp": "2021-03-19T16:19:19.138Z", ++ "filemod_count": 0, ++ "modload_count": 0, ++ "netconn_count": 0, ++ "org_id": "MYORGIDX", ++ "regmod_count": 0, ++ "scriptload_count": 0 ++ }, ++ "1": { ++ "type": "process", ++ "x_unique_id": "MYORGIDX-01aac658-00001b7c-00000000-1d71cec2d7f188e", ++ "name": "compattelrunner.exe", ++ "binary_ref": "2", ++ "pid": 7036 ++ }, ++ "2": { ++ "type": "file", ++ "name": "compattelrunner.exe", ++ "hashes": { ++ "SHA-256": "c0a5986a4dd6d7cacf09c5a980df634c44ff73028206d99cb561e64a74a0958a" ++ }, ++ "parent_directory_ref": "7" ++ }, ++ "3": { ++ "type": "process", ++ "parent_ref": "1", ++ "command_line": "powershell.exe -ExecutionPolicy Restricted -Command $Res = 0; if((Get-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole).State -eq 'Enabled') { $Path = $env:windir + '\\system32\\inetsrv\\config\\applicationHost.Config'; if (Test-Path -Path $Path) { try { [XML]$Xml = Get-Content $Path } catch { $Res = 1 } }; } Write-Host 'Final result:',$Res", ++ "x_unique_id": "MYORGIDX-01aac658-00001370-00000000-1d71cec444d7279", ++ "name": "powershell.exe", ++ "binary_ref": "4", ++ "pid": 4976, ++ "created": "2021-03-19T17:18:55.150Z", ++ "creator_user_ref": "5" ++ }, ++ "4": { ++ "type": "file", ++ "name": "powershell.exe", ++ "hashes": { ++ "MD5": "7353f60b1739074eb17c5f4dddefe239", ++ "SHA-256": "de96a6e69944335375dc1ac238336066889d9ffc7d73628ef4fe1b1b160ab32c" ++ }, ++ "parent_directory_ref": "6" ++ }, ++ "5": { ++ "type": "user-account", ++ "user_id": "NT AUTHORITY\\SYSTEM" ++ }, ++ "6": { ++ "type": "directory", ++ "path": "c:\\windows\\system32\\windowspowershell\\v1.0" ++ }, ++ "7": { ++ "type": "directory", ++ "path": "c:\\windows\\system32" ++ } ++ }, ++ "first_observed": "2021-03-19T16:19:19.138Z", ++ "last_observed": "2021-03-19T16:19:19.138Z", ++ "number_observed": 1 ++ }, ++ { ++ "id": "observed-data--292d681f-df32-47b7-a8b3-8aaae2b61618", ++ "type": "observed-data", ++ "created_by_ref": "identity--3532c56d-ea72-48be-a2ad-1a53f4c9c6d3", ++ "created": "2021-08-05T13:03:25.635Z", ++ "modified": "2021-08-05T13:03:25.635Z", ++ "objects": { ++ "0": { ++ "type": "x-cbcloud", ++ "childproc_count": 0, ++ "crossproc_count": 0, ++ "device_external_ip": "192.168.100.212", ++ "device_group_id": 0, ++ "device_id": 27969132, ++ "device_name": "windows10-lab2", ++ "device_os": "WINDOWS", ++ "device_timestamp": "2021-03-19T19:03:54.637Z", ++ "filemod_count": 0, ++ "modload_count": 0, ++ "netconn_count": 0, ++ "org_id": "MYORGIDX", ++ "regmod_count": 0, ++ "scriptload_count": 0 ++ }, ++ "1": { ++ "type": "process", ++ "x_unique_id": "MYORGIDX-01aac66c-00001644-00000000-1d71cf28cfa1765", ++ "name": "compattelrunner.exe", ++ "binary_ref": "2", ++ "pid": 5700 ++ }, ++ "2": { ++ "type": "file", ++ "name": "compattelrunner.exe", ++ "hashes": { ++ "SHA-256": "c0a5986a4dd6d7cacf09c5a980df634c44ff73028206d99cb561e64a74a0958a" ++ }, ++ "parent_directory_ref": "7" ++ }, ++ "3": { ++ "type": "process", ++ "parent_ref": "1", ++ "command_line": "powershell.exe -ExecutionPolicy Restricted -Command $Res = 0; if((Get-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole).State -eq 'Enabled') { $Path = $env:windir + '\\system32\\inetsrv\\config\\applicationHost.Config'; if (Test-Path -Path $Path) { try { [XML]$Xml = Get-Content $Path } catch { $Res = 1 } }; } Write-Host 'Final result:',$Res", ++ "x_unique_id": "MYORGIDX-01aac66c-00001790-00000000-1d71cf29b2fc9c3", ++ "name": "powershell.exe", ++ "binary_ref": "4", ++ "pid": 6032, ++ "created": "2021-03-19T19:03:54.198Z", ++ "creator_user_ref": "5" ++ }, ++ "4": { ++ "type": "file", ++ "name": "powershell.exe", ++ "hashes": { ++ "MD5": "7353f60b1739074eb17c5f4dddefe239", ++ "SHA-256": "de96a6e69944335375dc1ac238336066889d9ffc7d73628ef4fe1b1b160ab32c" ++ }, ++ "parent_directory_ref": "6" ++ }, ++ "5": { ++ "type": "user-account", ++ "user_id": "NT AUTHORITY\\SYSTEM" ++ }, ++ "6": { ++ "type": "directory", ++ "path": "c:\\windows\\system32\\windowspowershell\\v1.0" ++ }, ++ "7": { ++ "type": "directory", ++ "path": "c:\\windows\\system32" ++ } ++ }, ++ "first_observed": "2021-03-19T19:03:54.637Z", ++ "last_observed": "2021-03-19T19:03:54.637Z", ++ "number_observed": 1 ++ }, ++ { ++ "id": "observed-data--fbe8bf8b-fc2e-4268-b325-9a12b90f2b2c", ++ "type": "observed-data", ++ "created_by_ref": "identity--3532c56d-ea72-48be-a2ad-1a53f4c9c6d3", ++ "created": "2021-08-05T13:03:25.657Z", ++ "modified": "2021-08-05T13:03:25.657Z", ++ "objects": { ++ "0": { ++ "type": "x-cbcloud", ++ "childproc_count": 0, ++ "crossproc_count": 0, ++ "device_external_ip": "192.168.100.212", ++ "device_group_id": 0, ++ "device_id": 40017686, ++ "device_internal_ip": "10.0.0.139", ++ "device_name": "windows10-lab1", ++ "device_os": "WINDOWS", ++ "device_timestamp": "2021-03-19T22:39:10.117Z", ++ "filemod_count": 0, ++ "modload_count": 0, ++ "netconn_count": 0, ++ "org_id": "MYORGIDX", ++ "regmod_count": 0, ++ "scriptload_count": 0 ++ }, ++ "1": { ++ "type": "process", ++ "x_unique_id": "MYORGIDX-02629f16-00000608-00000000-1d71d10a09cc7c4", ++ "name": "compattelrunner.exe", ++ "binary_ref": "2", ++ "pid": 1544 ++ }, ++ "2": { ++ "type": "file", ++ "name": "compattelrunner.exe", ++ "hashes": { ++ "SHA-256": "c0a5986a4dd6d7cacf09c5a980df634c44ff73028206d99cb561e64a74a0958a" ++ }, ++ "parent_directory_ref": "7" ++ }, ++ "3": { ++ "type": "process", ++ "parent_ref": "1", ++ "command_line": "powershell.exe -ExecutionPolicy Restricted -Command $Res = 0; if((Get-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole).State -eq 'Enabled') { $Path = $env:windir + '\\system32\\inetsrv\\config\\applicationHost.Config'; if (Test-Path -Path $Path) { try { [XML]$Xml = Get-Content $Path } catch { $Res = 1 } }; } Write-Host 'Final result:',$Res", ++ "x_unique_id": "MYORGIDX-02629f16-00000ad8-00000000-1d71d10acbe8a66", ++ "name": "powershell.exe", ++ "binary_ref": "4", ++ "pid": 2776, ++ "created": "2021-03-19T22:39:08.556Z", ++ "creator_user_ref": "5" ++ }, ++ "4": { ++ "type": "file", ++ "name": "powershell.exe", ++ "hashes": { ++ "MD5": "7353f60b1739074eb17c5f4dddefe239", ++ "SHA-256": "de96a6e69944335375dc1ac238336066889d9ffc7d73628ef4fe1b1b160ab32c" ++ }, ++ "parent_directory_ref": "6" ++ }, ++ "5": { ++ "type": "user-account", ++ "user_id": "NT AUTHORITY\\SYSTEM" ++ }, ++ "6": { ++ "type": "directory", ++ "path": "c:\\windows\\system32\\windowspowershell\\v1.0" ++ }, ++ "7": { ++ "type": "directory", ++ "path": "c:\\windows\\system32" ++ } ++ }, ++ "first_observed": "2021-03-19T22:39:10.117Z", ++ "last_observed": "2021-03-19T22:39:10.117Z", ++ "number_observed": 1 ++ } ++ ] ++} +diff --git a/tests/test_command_disp.py b/tests/test_command_disp.py +index bc519be6..3db45f52 100644 +--- a/tests/test_command_disp.py ++++ b/tests/test_command_disp.py +@@ -13,11 +13,11 @@ def test_disp(): + ] + """ + d = s.execute(stmt) +- out = s.execute('DISP newvar') ++ out = s.execute("DISP newvar") + data = out[0].to_dict() + + + def test_disp_no_vars(): + with Session() as s: + with pytest.raises(VariableNotExist): +- s.execute('DISP newvar') ++ s.execute("DISP newvar") +diff --git a/tests/test_command_new.py b/tests/test_command_new.py +index 09e1d14b..51f6635c 100644 +--- a/tests/test_command_new.py ++++ b/tests/test_command_new.py +@@ -74,7 +74,7 @@ def test_new_list_of_strings_without_type_to_fail(): + s.execute(stmt) + + +-@pytest.mark.skip('Need grammar update to get this to pass') ++@pytest.mark.skip("Need grammar update to get this to pass") + def test_new_with_int_pid(): + with Session() as s: + stmt = """ +diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py +index 7e62b67a..75220484 100644 +--- a/tests/test_exceptions.py ++++ b/tests/test_exceptions.py +@@ -15,18 +15,34 @@ def fake_bundle_file(): + + def test_unexpected_chars(fake_bundle_file): + with Session(debug_mode=True) as session: +- with pytest.raises(KestrelSyntaxError) as e: ++ with pytest.raises(KestrelSyntaxError) as einfo: + session.execute( +- "get ? network-traffic" f" from file://{fake_bundle_file}" " where" ++ f"get ? network-traffic from file://{fake_bundle_file} where" + ) +- print(e) ++ err = einfo.value ++ assert err.line == 1 ++ assert err.column == 5 ++ assert err.expected == ["ENTITY_TYPE"] + + + def test_unexpected_token(fake_bundle_file): + with Session(debug_mode=True) as session: +- with pytest.raises(KestrelSyntaxError) as e: +- session.execute("get " f" from file://{fake_bundle_file}" " where") +- print(e) ++ with pytest.raises(KestrelSyntaxError) as einfo: ++ session.execute(f"get from file://{fake_bundle_file} where") ++ err = einfo.value ++ assert err.line == 1 ++ assert err.column == 10 ++ assert set(err.expected) == set(["FROM", "WHERE"]) ++ ++ ++def test_unexpected_eol(fake_bundle_file): ++ with Session(debug_mode=True) as session: ++ with pytest.raises(KestrelSyntaxError) as einfo: ++ session.execute(f"get process from file://{fake_bundle_file}") ++ err = einfo.value ++ assert err.line == 1 ++ assert err.column == 18 ++ assert err.expected == ["WHERE"] + + + def test_garbage(): +diff --git a/tests/test_session.py b/tests/test_session.py +index 91745ee5..acf1b7b8 100644 +--- a/tests/test_session.py ++++ b/tests/test_session.py +@@ -38,6 +38,12 @@ def fake_bundle_3(): + return os.path.join(cwd, "test_bundle_3.json") + + ++@pytest.fixture ++def cbcloud_powershell_bundle(): ++ cwd = os.path.dirname(os.path.abspath(__file__)) ++ return os.path.join(cwd, "powershell_search_stix_result.json") ++ ++ + def test_session_1(fake_bundle_file): + with Session(debug_mode=True) as session: + execute( +@@ -272,7 +278,25 @@ def test_session_do_complete_timestamp(fake_bundle_file, time_string, suffix_ts) + result = session.do_complete(script, len(script)) + assert result == suffix_ts + ++ + def test_session_debug_from_env(): + os.environ["KESTREL_DEBUG"] = "something" + with Session() as session: + assert session.debug_mode == True ++ ++ ++def test_sha256_attr_name(cbcloud_powershell_bundle): ++ ++ with Session() as session: ++ script = ( ++ "x = get process" ++ f" from file://{cbcloud_powershell_bundle}" ++ " where [process:name = 'powershell.exe']" ++ ) ++ execute(session, script) ++ out = session.execute("DISP x ATTR binary_ref.hashes.'SHA-256'") ++ df = out[0].dataframe ++ assert ( ++ df["binary_ref.hashes.'SHA-256'"][0] ++ == "de96a6e69944335375dc1ac238336066889d9ffc7d73628ef4fe1b1b160ab32c" ++ ) +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+3S0W6DIBgFYK99iv+qd2pRqY9jKrDVVIEIdevbD026TbOtNzXLsvNdKDk/icRD ++2lzaTtZKj1m0lX1QcT6/g/V7XjOeszxnRVWEnDFe8Yj4Zif65OL8cSCKBmP8T/vuzf+o9KN/r5yv ++hen7o5apOz3uG/f6L0r+3n95yEP/5YGF/vePO8L3/nn/QtJcfKNk3J9lO1BiKVNeZOeQDqqj3Y6E ++JWH0U/t8C1Nv+m6xbTGJM2P9LUnG6XI1rc7s1Z+MLijpKSzDlKaHW1y8WrbOpvb61Uirl9VEvQpl ++fWu0Ww2cci7EU5qM8W//ZAAAAAAAAAAAAAAAAAAAAACAjbwB+Llb4AAoAAA= +diff --git 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-002134/tests/test.sh b/tasks/format-code-task-002134/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4f981c658acefe2b26b26d1fa6a1bc831122547 --- /dev/null +++ b/tasks/format-code-task-002134/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/powershell_search_stix_result.json +tests/test_command_disp.py +tests/test_command_new.py +tests/test_exceptions.py +tests/test_session.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-002134/tests/test_command.sh b/tasks/format-code-task-002134/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002134/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002135/environment/Dockerfile b/tasks/format-code-task-002135/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5fb36f502eb6e50cf71fe4c628434ce0e20fcff2 --- /dev/null +++ b/tasks/format-code-task-002135/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d24167c5aee637eccd8a905d7a9c2142ee6a0aa4bd2abffd702299e1284109d0 diff --git a/tasks/format-code-task-002135/environment/setup/files/blocklist b/tasks/format-code-task-002135/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002135/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002135/environment/setup/setup.sh b/tasks/format-code-task-002135/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002135/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002135/tests/test.patch b/tasks/format-code-task-002135/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..da3d66ea680a6a9a68d9a8d76b9c5b02593fa652 --- /dev/null +++ b/tasks/format-code-task-002135/tests/test.patch @@ -0,0 +1,59 @@ +diff --git a/tests/test_utils_cog.py b/tests/test_utils_cog.py +index 4249d3a2dc..857add90f4 100644 +--- a/tests/test_utils_cog.py ++++ b/tests/test_utils_cog.py +@@ -1,6 +1,7 @@ + import pytest + from pathlib import Path + import numpy as np ++import xarray as xr + from types import SimpleNamespace + from dask.delayed import Delayed + import dask +@@ -155,3 +156,25 @@ def test_cog_no_crs(tmpdir, with_dask): + + with pytest.raises(ValueError): + to_cog(xx) ++ ++ ++def test_cog_rgba(tmpdir): ++ pp = Path(str(tmpdir)) ++ xx, ds = gen_test_data(pp) ++ pix = np.dstack([xx.values] * 4) ++ rgba = xr.DataArray(pix, ++ attrs=xx.attrs, ++ dims=('y', 'x', 'band'), ++ coords=xx.coords) ++ assert(rgba.geobox == xx.geobox) ++ assert(rgba.shape[:2] == rgba.geobox.shape) ++ ++ ff = write_cog(rgba, pp / "cog.tif") ++ yy = rio_slurp_xarray(ff) ++ ++ assert(yy.geobox == rgba.geobox) ++ assert(yy.shape == rgba.shape) ++ np.testing.assert_array_equal(yy.values, rgba.values) ++ ++ with pytest.raises(ValueError): ++ _write_cog(rgba.values[1:, :, :], rgba.geobox, ':mem:') +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+3SS2rDMBAGYK91iilZx7aElax7hV4g+KHGAlsK1tiQ21dynxTabBJK6P8tPGI8 ++QkIzeTPboTsYtxTZrZTRXus1Rt/jupZaSaW0UrLKSin1Xmekb3ajL+bA9USUTd7zb3WX/t+p/LP/ ++bAIfWj+Otevy0F/vjEv9V6p6738MMS+rXbnLqLzeFX72z/u/eSga64qmDr1oO1qHoDGdEBt6bNku ++NRta4nSI4OepNR8FRZ6y6976rS7teZodcW8ovunRMKVieraDEacz997RdqS4Stn0Ca8zN7MdQpy8 ++Y34603YRf/0mAAAAAAAAAAAAAAAAAAAAAAD34gVRwNajACgAAA== +diff --git 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-002135/tests/test.sh b/tasks/format-code-task-002135/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e5d818ed66bc6aa3374fe9bc24fece1c171cec77 --- /dev/null +++ b/tasks/format-code-task-002135/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_utils_cog.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-002135/tests/test_command.sh b/tasks/format-code-task-002135/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002135/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002147/environment/Dockerfile b/tasks/format-code-task-002147/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be6743534d48a045686d5cbfa62fc76c20adbab1 --- /dev/null +++ b/tasks/format-code-task-002147/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9b2e07f255d8ca988e1b5b563fb2429a476d87e5e255185ecab61029d763a63f diff --git a/tasks/format-code-task-002147/environment/setup/files/blocklist b/tasks/format-code-task-002147/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002147/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002147/environment/setup/setup.sh b/tasks/format-code-task-002147/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002147/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002147/tests/test.patch b/tasks/format-code-task-002147/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..05f01e783e3158dc9ecdaa81cf188b04d5d55fdf --- /dev/null +++ b/tasks/format-code-task-002147/tests/test.patch @@ -0,0 +1,70 @@ +diff --git a/tests/unit_tests/test_mesh.py b/tests/unit_tests/test_mesh.py +index 61e8b2a123e..71945193403 100644 +--- a/tests/unit_tests/test_mesh.py ++++ b/tests/unit_tests/test_mesh.py +@@ -76,7 +76,6 @@ def test_cylindrical_mesh_bounding_box(): + np.testing.assert_array_equal(mesh.lower_left, (2, 4, -3)) + np.testing.assert_array_equal(mesh.upper_right, (4, 6, 17)) + +- + def test_spherical_mesh_bounding_box(): + # test with mesh at origin (0, 0, 0) + mesh = openmc.SphericalMesh([0.1, 0.2, 0.5, 1.], origin=(0., 0., 0.)) +@@ -155,3 +154,37 @@ def test_CylindricalMesh_initiation(): + # waffles and pancakes are unfortunately not valid radii + with pytest.raises(TypeError): + openmc.SphericalMesh(('🧇', '🥞')) ++ ++ ++def test_centroids(): ++ ++ mesh = openmc.RegularMesh() ++ mesh.lower_left = (1., 2., 3.) ++ mesh.upper_right = (11., 12., 13.) ++ mesh.dimension = (1, 1, 1) ++ np.testing.assert_array_almost_equal(mesh.centroids[:, 0, 0, 0], [6., 7., 8.]) ++ ++ ++ mesh = openmc.RectilinearMesh() ++ mesh.x_grid = [1., 11.] ++ mesh.y_grid = [2., 12.] ++ mesh.z_grid = [3., 13.] ++ np.testing.assert_array_almost_equal(mesh.centroids[:, 0, 0, 0], [6., 7., 8.]) ++ ++ ++ mesh = openmc.CylindricalMesh(r_grid=(0, 10), z_grid=(0, 10), phi_grid=(0, np.pi)) ++ np.testing.assert_array_almost_equal(mesh.centroids[:, 0, 0, 0], [0.0, 5.0, 5.0]) ++ ++ mesh.origin = (5.0, 0, -10) ++ np.testing.assert_array_almost_equal(mesh.centroids[:, 0, 0, 0], [5.0, 5.0, -5.0]) ++ ++ ++ mesh = openmc.SphericalMesh(r_grid=[0, 10], theta_grid=[0, 0.5*np.pi], phi_grid=[0, np.pi]) ++ x = 5.*np.cos(0.5*np.pi)*np.sin(0.25*np.pi) ++ y = 5.*np.sin(0.5*np.pi)*np.sin(0.25*np.pi) ++ z = 5.*np.sin(0.25*np.pi) ++ np.testing.assert_array_almost_equal(mesh.centroids[:, 0, 0, 0], [x, y, z]) ++ ++ mesh.origin = (-5.0, -5.0, 5.0) ++ np.testing.assert_array_almost_equal(mesh.centroids[:, 0, 0, 0], [x-5.0, y-5.0, z+5.0]) ++ +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3STQrCMBCG4ax7irmANf1Jc5yitlDBttKkgrc3VkQR1I1FxPdZZIYkkIEv8Xrc ++7qqy7g5LNRcdWGOmGjzWqU9MmqQ6NzrNlE4SYzMlZraJ7ozOrwYRNfS9f3Xv3fmPim/5+9r5ctO3 ++7aqrYtd87o23+Vt7zT+3WRHyz4vUKNGfG+G5P89/U8kU/Lquov3RN32XyaKV0IZNOS9uOXZbX17a ++6Y+0tWvi/VEWh+jb4wMAAAAAAAAAAAAAAAB/7QSqmFTVACgAAA== +diff --git 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-002147/tests/test.sh b/tasks/format-code-task-002147/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbf1350dbe930aa17000f04cf36395bf4a4557c2 --- /dev/null +++ b/tasks/format-code-task-002147/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_tests/test_mesh.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-002147/tests/test_command.sh b/tasks/format-code-task-002147/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002147/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002150/environment/Dockerfile b/tasks/format-code-task-002150/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b74743edb2aa5537a8b21f487deb4763b45a7844 --- /dev/null +++ b/tasks/format-code-task-002150/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5c896fd18b51a3c3bc706caa9d7b6f580cfb251cf4360502e8c59e3df02fb85c diff --git a/tasks/format-code-task-002150/environment/setup/files/blocklist b/tasks/format-code-task-002150/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002150/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002150/environment/setup/setup.sh b/tasks/format-code-task-002150/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002150/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002150/tests/test.patch b/tasks/format-code-task-002150/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..16541d18121e41c95a88c4b49754bb52b1a5714f --- /dev/null +++ b/tasks/format-code-task-002150/tests/test.patch @@ -0,0 +1,421 @@ +diff --git a/usercase-test-coderl/CMakeLists.txt b/usercase-test-coderl/CMakeLists.txt +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/CMakeLists.txt +@@ -0,0 +1,24 @@ ++cmake_minimum_required(VERSION 3.24) ++project(openrct2_usercase_coderl CXX) ++ ++set(CMAKE_CXX_STANDARD 20) ++set(CMAKE_CXX_STANDARD_REQUIRED ON) ++ ++set(WITH_TESTS OFF CACHE BOOL "" FORCE) ++set(DISABLE_GUI ON CACHE BOOL "" FORCE) ++set(DISABLE_NETWORK ON CACHE BOOL "" FORCE) ++set(DISABLE_HTTP ON CACHE BOOL "" FORCE) ++set(DISABLE_DISCORD_RPC ON CACHE BOOL "" FORCE) ++set(DISABLE_TTF ON CACHE BOOL "" FORCE) ++set(ENABLE_SCRIPTING OFF CACHE BOOL "" FORCE) ++set(DOWNLOAD_OBJECTS OFF CACHE BOOL "" FORCE) ++set(DOWNLOAD_TITLE_SEQUENCES OFF CACHE BOOL "" FORCE) ++set(DOWNLOAD_OPENSFX OFF CACHE BOOL "" FORCE) ++set(DOWNLOAD_OPENMUSIC OFF CACHE BOOL "" FORCE) ++set(DOWNLOAD_REPLAYS OFF CACHE BOOL "" FORCE) ++ ++add_subdirectory(/workspace/repo "${CMAKE_BINARY_DIR}/openrct2") ++ ++add_executable(object_repository_add_from_file_test object_repository_add_from_file_test.cpp) ++target_include_directories(object_repository_add_from_file_test PRIVATE /workspace/repo/src) ++target_link_libraries(object_repository_add_from_file_test PRIVATE libopenrct2) +diff --git a/usercase-test-coderl/object_repository_add_from_file_test.cpp b/usercase-test-coderl/object_repository_add_from_file_test.cpp +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/object_repository_add_from_file_test.cpp +@@ -0,0 +1,357 @@ ++ ++ ++ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++using namespace OpenRCT2; ++ ++namespace ++{ ++ constexpr auto kRuntimeRoot = "/workspace/repo/usercase-test-coderl/runtime"; ++ ++ void Require(bool condition, const std::string& message) ++ { ++ if (!condition) ++ { ++ throw std::runtime_error(message); ++ } ++ } ++ ++ template ++ void RequireEq(const T& actual, const U& expected, const std::string& label) ++ { ++ if (!(actual == expected)) ++ { ++ std::ostringstream out; ++ out << label << ": expected [" << expected << "], got [" << actual << "]"; ++ throw std::runtime_error(out.str()); ++ } ++ } ++ ++ std::unique_ptr MakeEnv(const std::string& suffix) ++ { ++ DirBaseValues paths{}; ++ const auto base = std::string(kRuntimeRoot) + "/" + suffix; ++ paths[EnumValue(DirBase::openrct2)] = base + "/openrct2"; ++ paths[EnumValue(DirBase::user)] = base + "/user"; ++ paths[EnumValue(DirBase::config)] = base + "/config"; ++ paths[EnumValue(DirBase::cache)] = base + "/cache"; ++ paths[EnumValue(DirBase::documentation)] = base + "/docs"; ++ return CreatePlatformEnvironment(paths); ++ } ++ ++ std::string UserObjectsPath(const IPlatformEnvironment& env) ++ { ++ return env.GetDirectoryPath(DirBase::user, DirId::objects); ++ } ++ ++ void WriteObjectJson(const std::string& path, const std::string& id, const std::string& name) ++ { ++ std::filesystem::create_directories(std::filesystem::path(path).parent_path()); ++ std::ofstream out(path); ++ out << "{\n" ++ << " \"id\": \"" << id << "\",\n" ++ << " \"objectType\": \"scenario_meta\",\n" ++ << " \"version\": \"1.2.3\",\n" ++ << " \"authors\": [\"Acceptance Author\"],\n" ++ << " \"strings\": {\n" ++ << " \"name\": {\"en-GB\": \"" << name << "\"},\n" ++ << " \"park_name\": {\"en-GB\": \"Fixture Park\"},\n" ++ << " \"details\": {\"en-GB\": \"Fixture details\"}\n" ++ << " },\n" ++ << " \"images\": []\n" ++ << "}\n"; ++ } ++ ++ std::vector MakeParkObjBytes(const std::string& id, const std::string& name) ++ { ++ const auto buildDir = std::string(kRuntimeRoot) + "/parkobj-build"; ++ std::filesystem::remove_all(buildDir); ++ std::filesystem::create_directories(buildDir); ++ WriteObjectJson(buildDir + "/object.json", id, name); ++ ++ const auto oldCwd = std::filesystem::current_path(); ++ std::filesystem::current_path(buildDir); ++ const int rc = std::system("zip -q object.parkobj object.json"); ++ std::filesystem::current_path(oldCwd); ++ RequireEq(rc, 0, "zip command exit status"); ++ return File::ReadAllBytes(buildDir + "/object.parkobj"); ++ } ++ ++ std::vector MakeLegacyDatBytes() ++ { ++ RCTObjectEntry entry{}; ++ entry.SetType(ObjectType::parkEntrance); ++ entry.SetName("TSTENTR"); ++ entry.flags |= static_cast(ObjectSourceGame::custom) << 4; ++ entry.checksum = 0x1234ABCD; ++ ++ MemoryStream legacy; ++ const std::array reserved{}; ++ legacy.Write(reserved.data(), reserved.size()); ++ legacy.WriteValue(2); ++ legacy.WriteValue(9); ++ legacy.WriteValue(static_cast(RCT2LanguageId::englishUK)); ++ const char name[] = "TST Entrance"; ++ legacy.Write(name, sizeof(name)); ++ legacy.WriteValue(static_cast(RCT2LanguageId::end)); ++ legacy.WriteValue(0); ++ legacy.WriteValue(0); ++ ++ MemoryStream dat; ++ dat.Write(&entry, sizeof(entry)); ++ SawyerCoding::SawyerChunkWriter writer(&dat); ++ writer.WriteChunk(legacy.GetData(), legacy.GetLength(), SawyerCoding::ChunkEncoding::none); ++ ++ const auto* bytes = static_cast(dat.GetData()); ++ return std::vector(bytes, bytes + dat.GetLength()); ++ } ++ ++ std::vector DirectoryFileNames(const std::string& directory) ++ { ++ std::vector names; ++ if (!std::filesystem::exists(directory)) ++ return names; ++ for (const auto& entry : std::filesystem::directory_iterator(directory)) ++ { ++ names.push_back(entry.path().filename().string()); ++ } ++ std::sort(names.begin(), names.end()); ++ return names; ++ } ++ ++ void AssertImportedJsonItem(const ObjectRepositoryItem* item, const std::string& expectedPath) ++ { ++ Require(item != nullptr, "FindObject(\"custom.scenery_pack\") returned null"); ++ ++ Require(item->Generation == ObjectGeneration::JSON, "json generation"); ++ Require(item->Type == ObjectType::scenarioMeta, "json object type"); ++ RequireEq(item->Identifier, std::string("custom.scenery_pack"), "json identifier"); ++ RequireEq(item->Path, expectedPath, "json path"); ++ } ++ ++ bool HasFileName(const std::vector& files, const std::string& expected) ++ { ++ return std::find(files.begin(), files.end(), expected) != files.end(); ++ } ++ ++ bool HasUniqueSuffixedParkObjName(const std::vector& files) ++ { ++ for (const auto& file : files) ++ { ++ if (file != "custom.scenery_pack.parkobj" && file.starts_with("custom.scenery_pack") ++ && file.ends_with(".parkobj")) ++ { ++ return true; ++ } ++ } ++ return false; ++ } ++ ++ bool HasLegacyDatNameForEntry(const std::vector& files) ++ { ++ for (const auto& file : files) ++ { ++ if (file.starts_with("TSTENTR") && file.ends_with(".DAT")) ++ { ++ return true; ++ } ++ } ++ return false; ++ } ++ ++ void TestJsonImportUpdatesCurrentRepository() ++ { ++ ++ ++ auto env = MakeEnv("json-import"); ++ auto repo = CreateObjectRepository(*env); ++ repo->Construct(LANGUAGE_ENGLISH_UK); ++ RequireEq(repo->GetNumObjects(), static_cast(0), "initial object count"); ++ Require(repo->FindObject("custom.scenery_pack") == nullptr, "initial FindObject should be null"); ++ ++ const auto bytes = MakeParkObjBytes("custom.scenery_pack", "Custom Scenery Pack"); ++ repo->AddObjectFromFile(ObjectGeneration::JSON, "custom.scenery_pack", bytes.data(), bytes.size()); ++ ++ RequireEq(repo->GetNumObjects(), static_cast(1), "object count after JSON import"); ++ const auto expectedPath = UserObjectsPath(*env) + "/custom.scenery_pack.parkobj"; ++ AssertImportedJsonItem(repo->FindObject("custom.scenery_pack"), expectedPath); ++ RequireEq(DirectoryFileNames(UserObjectsPath(*env)).size(), static_cast(1), "json file count"); ++ ++ Require(HasFileName(DirectoryFileNames(UserObjectsPath(*env)), "custom.scenery_pack.parkobj"), "json filename"); ++ } ++ ++ void TestJsonCollisionSuffixDoesNotReplaceLookup() ++ { ++ ++ ++ auto env = MakeEnv("json-collision"); ++ auto repo = CreateObjectRepository(*env); ++ repo->Construct(LANGUAGE_ENGLISH_UK); ++ const auto bytes = MakeParkObjBytes("custom.scenery_pack", "Custom Scenery Pack"); ++ ++ repo->AddObjectFromFile(ObjectGeneration::JSON, "custom.scenery_pack", bytes.data(), bytes.size()); ++ repo->AddObjectFromFile(ObjectGeneration::JSON, "custom.scenery_pack", bytes.data(), bytes.size()); ++ ++ RequireEq(repo->GetNumObjects(), static_cast(1), "count after duplicate JSON import"); ++ const auto expectedPath = UserObjectsPath(*env) + "/custom.scenery_pack.parkobj"; ++ AssertImportedJsonItem(repo->FindObject("custom.scenery_pack"), expectedPath); ++ const auto files = DirectoryFileNames(UserObjectsPath(*env)); ++ RequireEq(files.size(), static_cast(2), "json duplicate file count"); ++ ++ Require(HasFileName(files, "custom.scenery_pack.parkobj"), "json original filename"); ++ Require(HasUniqueSuffixedParkObjName(files), "json suffixed filename"); ++ } ++ ++ void TestDatImportUsesEntryNameAndUpdatesLegacyLookup() ++ { ++ ++ ++ auto env = MakeEnv("dat-import"); ++ auto repo = CreateObjectRepository(*env); ++ repo->Construct(LANGUAGE_ENGLISH_UK); ++ RequireEq(repo->GetNumObjects(), static_cast(0), "initial DAT object count"); ++ Require(repo->FindObjectLegacy("TSTENTR") == nullptr, "initial FindObjectLegacy should be null"); ++ ++ const auto bytes = MakeLegacyDatBytes(); ++ repo->AddObjectFromFile(ObjectGeneration::DAT, "legacy-object-name-ignored", bytes.data(), bytes.size()); ++ ++ RequireEq(repo->GetNumObjects(), static_cast(1), "object count after DAT import"); ++ const auto* item = repo->FindObjectLegacy("TSTENTR"); ++ Require(item != nullptr, "FindObjectLegacy(\"TSTENTR\") returned null"); ++ ++ Require(item->Generation == ObjectGeneration::DAT, "dat generation"); ++ Require(item->Type == ObjectType::parkEntrance, "dat object type"); ++ Require(item->Path.starts_with(UserObjectsPath(*env) + "/TSTENTR"), "dat path entry name"); ++ Require(item->Path.ends_with(".DAT"), "dat path extension"); ++ const auto files = DirectoryFileNames(UserObjectsPath(*env)); ++ RequireEq(files.size(), static_cast(1), "dat file count"); ++ ++ Require(HasLegacyDatNameForEntry(files), "dat filename"); ++ } ++ ++ void TestInvalidBytesDoNotThrowOrMutateLookup() ++ { ++ ++ ++ auto env = MakeEnv("invalid-json"); ++ auto repo = CreateObjectRepository(*env); ++ repo->Construct(LANGUAGE_ENGLISH_UK); ++ const std::array invalid = { 'n', 'o', 't', '-', 'p', 'a', 'r', 'k', 'o', 'b', 'j' }; ++ ++ repo->AddObjectFromFile(ObjectGeneration::JSON, "custom.scenery_pack", invalid.data(), invalid.size()); ++ ++ RequireEq(repo->GetNumObjects(), static_cast(0), "invalid import object count"); ++ Require(repo->FindObject("custom.scenery_pack") == nullptr, "invalid import lookup should be null"); ++ const auto files = DirectoryFileNames(UserObjectsPath(*env)); ++ RequireEq(files.size(), static_cast(1), "invalid import still writes attempted file"); ++ RequireEq(files[0], std::string("custom.scenery_pack.parkobj"), "invalid import filename"); ++ } ++ ++ void TestIndependentRepositoryInstances() ++ { ++ ++ ++ auto envA = MakeEnv("independent-a"); ++ auto envB = MakeEnv("independent-b"); ++ auto a = CreateObjectRepository(*envA); ++ auto b = CreateObjectRepository(*envB); ++ a->Construct(LANGUAGE_ENGLISH_UK); ++ b->Construct(LANGUAGE_ENGLISH_UK); ++ const auto bytes = MakeParkObjBytes("custom.scenery_pack", "Custom Scenery Pack"); ++ ++ a->AddObjectFromFile(ObjectGeneration::JSON, "custom.scenery_pack", bytes.data(), bytes.size()); ++ ++ RequireEq(a->GetNumObjects(), static_cast(1), "instance a count"); ++ RequireEq(b->GetNumObjects(), static_cast(0), "instance b count"); ++ Require(a->FindObject("custom.scenery_pack") != nullptr, "instance a lookup"); ++ Require(b->FindObject("custom.scenery_pack") == nullptr, "instance b lookup"); ++ } ++ ++ void TestRepositoryCanImportAfterAnotherInstanceIsDestroyed() ++ { ++ ++ ++ auto env = MakeEnv("cleanup-idempotent"); ++ { ++ auto repo = CreateObjectRepository(*env); ++ repo->Construct(LANGUAGE_ENGLISH_UK); ++ } ++ auto repo = CreateObjectRepository(*env); ++ repo->Construct(LANGUAGE_ENGLISH_UK); ++ const auto bytes = MakeParkObjBytes("custom.scenery_pack", "Custom Scenery Pack"); ++ ++ repo->AddObjectFromFile(ObjectGeneration::JSON, "custom.scenery_pack", bytes.data(), bytes.size()); ++ ++ Require(repo->FindObject("custom.scenery_pack") != nullptr, "post-destruction instance lookup"); ++ RequireEq(DirectoryFileNames(UserObjectsPath(*env)).size(), static_cast(1), "post-destruction file count"); ++ } ++ ++ void TestRepeatedImportCyclesUpdateEachRepository() ++ { ++ ++ ++ const auto bytes = MakeParkObjBytes("custom.scenery_pack", "Custom Scenery Pack"); ++ for (int i = 0; i < 3; i++) ++ { ++ auto env = MakeEnv("cycle-" + std::to_string(i)); ++ auto repo = CreateObjectRepository(*env); ++ repo->Construct(LANGUAGE_ENGLISH_UK); ++ ++ repo->AddObjectFromFile(ObjectGeneration::JSON, "custom.scenery_pack", bytes.data(), bytes.size()); ++ ++ Require(repo->FindObject("custom.scenery_pack") != nullptr, "cycle lookup"); ++ RequireEq(DirectoryFileNames(UserObjectsPath(*env)).size(), static_cast(1), "cycle file count"); ++ } ++ } ++} ++ ++int main() ++{ ++ try ++ { ++ std::filesystem::remove_all(kRuntimeRoot); ++ gOpenRCT2NoGraphics = true; ++ auto context = CreateContext(MakeEnv("context"), Audio::CreateDummyAudioContext(), Ui::CreateDummyUiContext()); ++ ++ TestJsonImportUpdatesCurrentRepository(); ++ TestJsonCollisionSuffixDoesNotReplaceLookup(); ++ TestDatImportUsesEntryNameAndUpdatesLegacyLookup(); ++ TestInvalidBytesDoNotThrowOrMutateLookup(); ++ TestIndependentRepositoryInstances(); ++ TestRepositoryCanImportAfterAnotherInstanceIsDestroyed(); ++ TestRepeatedImportCyclesUpdateEachRepository(); ++ ++ std::cout << "PASS object_repository_add_from_file_test\n"; ++ return 0; ++ } ++ catch (const std::exception& e) ++ { ++ std::cerr << "FAIL object_repository_add_from_file_test: " << e.what() << "\n"; ++ return 1; ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++cmake -S /workspace/repo/usercase-test-coderl \ ++ -B /workspace/repo/build-usercase-coderl-acceptance \ ++ -G Ninja \ ++ -DCMAKE_BUILD_TYPE=RelWithDebInfo >/dev/null ++ ++cmake --build /workspace/repo/build-usercase-coderl-acceptance \ ++ --target object_repository_add_from_file_test \ ++ -j "${OPENRCT2_USERCASE_JOBS:-2}" ++ ++exec /workspace/repo/build-usercase-coderl-acceptance/object_repository_add_from_file_test diff --git a/tasks/format-code-task-002150/tests/test.sh b/tasks/format-code-task-002150/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ddefa55069dd265058fa3e4d32341a38d5f979bf --- /dev/null +++ b/tasks/format-code-task-002150/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/CMakeLists.txt +usercase-test-coderl/object_repository_add_from_file_test.cpp +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002150/tests/test_command.sh b/tasks/format-code-task-002150/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002150/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-002157/environment/Dockerfile b/tasks/format-code-task-002157/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6d6524ed5dd264bbeb92f512104a28fc07590268 --- /dev/null +++ b/tasks/format-code-task-002157/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:28104ce1dd3ae20dd0f37316fd9bc9d0bcdc0dc23d143530f5c9d3a1c1de08ac diff --git a/tasks/format-code-task-002157/environment/setup/files/blocklist b/tasks/format-code-task-002157/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002157/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002157/environment/setup/setup.sh b/tasks/format-code-task-002157/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002157/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002157/tests/test.patch b/tasks/format-code-task-002157/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..acbb577b54c48637d1124bebcf0fab7569773c97 --- /dev/null +++ b/tasks/format-code-task-002157/tests/test.patch @@ -0,0 +1,170 @@ +diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/apiserver/resthandler_test.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/apiserver/resthandler_test.go +index 50477fc89ad9..1dd5bdb1b9b7 100644 +--- a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/apiserver/resthandler_test.go ++++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/apiserver/resthandler_test.go +@@ -202,7 +202,7 @@ func (tc *patchTestCase) Run(t *testing.T) { + continue + + case api.StrategicMergePatchType: +- patch, err = strategicpatch.CreateStrategicMergePatch(originalObjJS, changedJS, &api.Pod{}) ++ patch, err = strategicpatch.CreateStrategicMergePatch(originalObjJS, changedJS, versionedObj) + if err != nil { + t.Errorf("%s: unexpected error: %v", tc.name, err) + return +diff --git a/test/integration/patch_test.go b/test/integration/patch_test.go +new file mode 100644 +index 000000000000..21685fde5c48 +--- /dev/null ++++ b/test/integration/patch_test.go +@@ -0,0 +1,121 @@ ++// +build integration ++ ++package integration ++ ++import ( ++ "fmt" ++ "sync" ++ "sync/atomic" ++ "testing" ++ ++ "github.com/pborman/uuid" ++ ++ kapi "k8s.io/kubernetes/pkg/api" ++ kapierrs "k8s.io/kubernetes/pkg/api/errors" ++ "k8s.io/kubernetes/pkg/api/meta" ++ "k8s.io/kubernetes/pkg/apiserver" ++ "k8s.io/kubernetes/pkg/client/restclient" ++ ++ templatesapi "github.com/openshift/origin/pkg/template/api" ++ testutil "github.com/openshift/origin/test/util" ++ testserver "github.com/openshift/origin/test/util/server" ++) ++ ++func TestPatchConflicts(t *testing.T) { ++ ++ testutil.RequireEtcd(t) ++ ++ _, clusterAdminKubeConfig, err := testserver.StartTestMasterAPI() ++ ++ if err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ ++ clusterAdminClient, err := testutil.GetClusterAdminClient(clusterAdminKubeConfig) ++ if err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ ++ clusterAdminKubeClient, err := testutil.GetClusterAdminKubeClient(clusterAdminKubeConfig) ++ if err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++ ++ objName := "myobj" ++ ns := "patch-namespace" ++ ++ if _, err := clusterAdminKubeClient.Namespaces().Create(&kapi.Namespace{ObjectMeta: kapi.ObjectMeta{Name: ns}}); err != nil { ++ t.Fatalf("Error creating namespace:%v", err) ++ } ++ if _, err := clusterAdminKubeClient.Secrets(ns).Create(&kapi.Secret{ObjectMeta: kapi.ObjectMeta{Name: objName}}); err != nil { ++ t.Fatalf("Error creating k8s resource:%v", err) ++ } ++ if _, err := clusterAdminClient.Templates(ns).Create(&templatesapi.Template{ObjectMeta: kapi.ObjectMeta{Name: objName}}); err != nil { ++ t.Fatalf("Error creating origin resource:%v", err) ++ } ++ ++ testcases := []struct { ++ client *restclient.RESTClient ++ resource string ++ }{ ++ { ++ client: clusterAdminKubeClient.RESTClient, ++ resource: "secrets", ++ }, ++ { ++ client: clusterAdminClient.RESTClient, ++ resource: "templates", ++ }, ++ } ++ ++ for _, tc := range testcases { ++ successes := int32(0) ++ ++ ++ ++ wg := sync.WaitGroup{} ++ for i := 0; i < (2 * apiserver.MaxPatchConflicts); i++ { ++ wg.Add(1) ++ go func(labelName string) { ++ defer wg.Done() ++ labelValue := uuid.NewRandom().String() ++ ++ obj, err := tc.client.Patch(kapi.StrategicMergePatchType). ++ Namespace(ns). ++ Resource(tc.resource). ++ Name(objName). ++ Body([]byte(fmt.Sprintf(`{"metadata":{"labels":{"%s":"%s"}}}`, labelName, labelValue))). ++ Do(). ++ Get() ++ ++ if kapierrs.IsConflict(err) { ++ t.Logf("tolerated conflict error patching %s: %v", tc.resource, err) ++ return ++ } ++ if err != nil { ++ t.Errorf("error patching %s: %v", tc.resource, err) ++ return ++ } ++ ++ accessor, err := meta.Accessor(obj) ++ if err != nil { ++ t.Errorf("error getting object from %s: %v", tc.resource, err) ++ return ++ } ++ if accessor.GetLabels()[labelName] != labelValue { ++ t.Errorf("patch of %s was ineffective, expected %s=%s, got labels %#v", tc.resource, labelName, labelValue, accessor.GetLabels()) ++ return ++ } ++ ++ atomic.AddInt32(&successes, 1) ++ }(fmt.Sprintf("label-%d", i)) ++ } ++ wg.Wait() ++ ++ if successes < apiserver.MaxPatchConflicts { ++ t.Errorf("Expected at least %d successful patches for %s, got %d", apiserver.MaxPatchConflicts, tc.resource, successes) ++ } else { ++ t.Logf("Got %d successful patches for %s", successes, tc.resource) ++ } ++ } ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,14 @@ ++H4sIAAAAAAAAA+2UW2/TMBTH+5xPcShI3YSSNF3bAVIfduk6YFtHt3ETUuUmJ4nX1M5sp90QH56T ++0nZjDPbCVfj3Ets5Pud/Lok3KngWDVFM/cqvok5stlrzJ3H7OV8HrUYQbLaDzdZGpR4E7SCoQOuX ++KbpBoQ1TABUlpfmR3X3v/1G86/4b1GYYysmEicjT6c+LcU//G412c9V/mgDqf7O9Ua9A/edJ+D7/ ++ef8fPvBHXPgjplNHowEXCwk5zzFmPHOcMIL5XIwwcpyHcEIWRQ49CTQwXEkxQWEcvMylMtDrB0Fw ++2N89O+h2ZBxfHx9vne53lm78noww1/5wJtVY5yzEZ35ZWz+RZYSu0IVCMCkuLoK+mmRcjCGWan4s ++cxQ65bHxpeIJF0A+xixBwEuujXYm44grcHNYuvW1Cv2Em7QYeTTe/sqBkwlwdSxWKd5/ZRGzVLrH ++L2GKIpKKLhaJVOe8vBlSeuEzoIJiu0lloj0XCaRMQ1TkGQ+ZQagNaxCmTGnyM0t5mFISgocaKB0q ++buA1Go89GGCeUX3ImsxnpAZqLq3WaGJFxFQEZ4MDV7MYgWV5ykZo1j1qYgQuh5r2ExTbcxUkAq7p ++LLR5RzjrLuStVbe2d3a7e7395y9eHhwe9Y9fDU5Oz16/efvuPRuFEcZJys/H2UTI/EJpU0xnl1cf ++60Fjo9lqbz55OhxW139nPLeMV4MPThngm4G63b1bzSmFeuW0YZhKqHY6HRgUQpRdUjQHKRU3QzUs ++Z4LMoBDcQLnRQKZVh47KHbhTNOWcL1S4qhBQPaU3x8yE6aNPq+UALwpOnm+eaFmoEK9P3pDa6sLT +++In2uPTHxQiVQIrl5+PEZznXqKaolrqrd+jPS18r5VwYTBQzXIovkuf6d3r9Yfdoa/ugu9upwzfZ ++uIYl+qurruETlIWBjXpd353tjhQxjbbRyxx+8O3MPzb/RoC7EtrKMqD/coLL0udMl5M9z+BP/zMt ++FovFYrFYLBaLxWKxWCwWi8VisVgsFovFYvnb+AxrUSD1ACgAAA== +diff --git 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-002157/tests/test.sh b/tasks/format-code-task-002157/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c038d268d66383143d4500ee72c3a9910f72721e --- /dev/null +++ b/tasks/format-code-task-002157/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' +Godeps/_workspace/src/k8s.io/kubernetes/pkg/apiserver/resthandler_test.go +test/integration/patch_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-002157/tests/test_command.sh b/tasks/format-code-task-002157/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002157/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002159/environment/Dockerfile b/tasks/format-code-task-002159/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9971b24a2afcff6560f7b21280c2b5186ccb85eb --- /dev/null +++ b/tasks/format-code-task-002159/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:de8cf4230466ccc60e67a7e446790104374777698206a29de639e4f6ddd4a47a diff --git a/tasks/format-code-task-002159/environment/setup/files/blocklist b/tasks/format-code-task-002159/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002159/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002159/environment/setup/setup.sh b/tasks/format-code-task-002159/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002159/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002159/tests/test.patch b/tasks/format-code-task-002159/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..22dbf8bbaf4b9bffb4e3fc414edba0ade64b68c7 --- /dev/null +++ b/tasks/format-code-task-002159/tests/test.patch @@ -0,0 +1,44 @@ +diff --git a/spec/rhc/highline_extensions_spec.rb b/spec/rhc/highline_extensions_spec.rb +index f8e9cdf77..2fbff9b9d 100644 +--- a/spec/rhc/highline_extensions_spec.rb ++++ b/spec/rhc/highline_extensions_spec.rb +@@ -139,6 +139,14 @@ def reset + output.should match "Foo \nLorem\nipsum\n" + end + ++ it "should handle an empty table" do ++ subject.table([]).to_a.should == [] ++ end ++ ++ it "should handle an empty table" do ++ subject.table([[]]).to_a.should == [] ++ end ++ + it "should wrap a table based on a max width" do + subject.table([["abcd efgh", "1234 6789 a"]], :width => 9, :heading => 'Test').to_a.should == [ + 'Test', +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3VzW6cMBAAYM48xTSVuu0BFsgCp0hV8wCpmvbQEzL27GLVYGqbTauq717Dhu4q ++UrKH/DXqfBI/so3HaDwQ14NUosJuuwweS+KVeT5dvZvX6T7NszQtizIryyBJ0yJLAsgfbUUHBuuY ++AQiM1u6uccf6X6h4n38hLasVVla2vUKutxX+kC429X1jjAkuVqtb858n6d/8p6e+PS2KVRZA8hAv ++eMx/nn+D3wdpEBZWG4eisugW4b5x3gqL8DVcbNEYKRCYm3YGyA5cg8B1t5abwTAndQetFoNCsNr3 ++MXc9wD/JNlg1qHo0fkctrJ9vnCPSXaT0VTQPgVpp/g2kBYO9YhwFXEnXAIPdUmCtTeun5Uyp8DrU ++5dRzrrchzNHPD5fkmwEErud1v30zBXk3tQO8n1/nDHqjOfzaTxgbtINy8S7oK/g9PYKdCHfn8Xju ++BN7TQf07tK7ium1ZJ2LbPFyMY99/X+77739S+PpfFVlJ9f8UuIAp8TWK8NOXD18vPn4+O4nM3LY8 +++n84ATPUPyG6BGN75DCelqbhy0ZuGiU79KMcdtYXoq3GTl/+L71oCCGEEEIIIYQQQgghhBBCCCGE ++kH/MHwjww3cAKAAA +diff --git 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-002159/tests/test.sh b/tasks/format-code-task-002159/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..41e91113652a7826019deb234fff288b271cee7e --- /dev/null +++ b/tasks/format-code-task-002159/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +spec/rhc/highline_extensions_spec.rb +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002159/tests/test_command.sh b/tasks/format-code-task-002159/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002159/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002195/environment/Dockerfile b/tasks/format-code-task-002195/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f894799b9562c6fd252258ce64d285620b6bf7dc --- /dev/null +++ b/tasks/format-code-task-002195/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:67e8747a3ab7227035d61577cbd2c57eae70213cc2278dc1cb5e91fc2fb11c04 diff --git a/tasks/format-code-task-002195/environment/setup/files/blocklist b/tasks/format-code-task-002195/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002195/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002195/environment/setup/setup.sh b/tasks/format-code-task-002195/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002195/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002195/tests/test.patch b/tasks/format-code-task-002195/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..716e2e625e1668093c1174cd7d5dc60af49f4729 --- /dev/null +++ b/tasks/format-code-task-002195/tests/test.patch @@ -0,0 +1,121 @@ +diff --git a/pandas/tests/frame/test_asof.py b/pandas/tests/frame/test_asof.py +index 47d56c3975..4178924ddd 100644 +--- a/pandas/tests/frame/test_asof.py ++++ b/pandas/tests/frame/test_asof.py +@@ -3,9 +3,9 @@ + import nose + + import numpy as np +-from pandas import DataFrame, date_range ++from pandas import DataFrame, date_range, Timestamp, Series, period_range + +-from pandas.util.testing import assert_frame_equal ++from pandas.util.testing import assert_frame_equal, assert_series_equal + import pandas.util.testing as tm + + from .common import TestData +@@ -67,6 +67,82 @@ class TestFrameAsof(TestData, tm.TestCase): + + assert_frame_equal(result, expected) + ++ def test_missing(self): ++ ++ ++ ++ ++ df = self.df.copy() ++ result = df.asof(self.df.index[0] - 1) ++ ++ ++ self.assertIsInstance(result, Series) ++ ++ ++ self.assertTrue(result.isnull().all()) ++ ++ ++ self.assertEqual(len(result), len(df.columns)) ++ tm.assert_index_equal(result.index, df.columns) ++ ++ def test_missing_from_issue_example(self): ++ ++ df = DataFrame({'a': range(10), 'b': range(10)}, ++ index=date_range('2014-01-01', periods=10)) ++ ++ result = df.asof('2013-01-15') ++ ++ ++ self.assertIsInstance(result, Series) ++ ++ self.assertTrue(result.isnull().all()) ++ ++ tm.assert_index_equal(result.index, df.columns) ++ ++ self.assertEqual(result.name, Timestamp('2013-01-15')) ++ ++ def test_missing_name_set_to_where(self): ++ ++ df = DataFrame({'a': range(10), 'b': range(10)}, ++ index=date_range('2014-01-01', periods=10)) ++ where = Timestamp('2013-01-15') ++ result = df.asof(where) ++ self.assertEqual(result.name, where) ++ ++ def test_missing_period_index(self): ++ ++ df = DataFrame({'a': range(10), 'b': range(10)}, ++ index=period_range('2014-01-01', periods=10)) ++ result = df.asof('2013-01-15') ++ ++ self.assertIsInstance(result, Series) ++ self.assertTrue(result.isnull().all()) ++ tm.assert_index_equal(result.index, df.columns) ++ ++ def test_in_range_unchanged(self): ++ ++ ++ df = DataFrame({'a': range(10), 'b': range(10)}, ++ index=date_range('2014-01-01', periods=10)) ++ result = df.asof('2014-01-15') ++ self.assertIsInstance(result, Series) ++ ++ self.assertEqual(result['a'], 9) ++ self.assertEqual(result['b'], 9) ++ ++ ++class TestSeriesAsofMissing(tm.TestCase): ++ _multiprocess_can_split_ = True ++ ++ def test_series_missing_returns_scalar_nan(self): ++ ++ from pandas import Series as PdSeries ++ s = PdSeries(range(10), index=date_range('2014-01-01', periods=10)) ++ result = s.asof('2013-01-15') ++ ++ self.assertNotIsInstance(result, PdSeries) ++ self.assertTrue(np.isnan(result)) ++ + if __name__ == '__main__': + nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], + exit=False) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..e981d1a061 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m nose pandas/tests/frame/test_asof.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 nose pandas/tests/frame/test_asof.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002195/tests/test.sh b/tasks/format-code-task-002195/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..904fffd001157c9090c152b50b79e8f867ea121d --- /dev/null +++ b/tasks/format-code-task-002195/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/frame/test_asof.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-002195/tests/test_command.sh b/tasks/format-code-task-002195/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002195/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002301/environment/Dockerfile b/tasks/format-code-task-002301/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..22962842ac8b2cf6056fe143fdbf1781e386c2f3 --- /dev/null +++ b/tasks/format-code-task-002301/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fa35c251c86e1ddf92c8cc7b101b6c00f219be667d59d4d1157ca5797fd3eb8c diff --git a/tasks/format-code-task-002301/environment/setup/files/blocklist b/tasks/format-code-task-002301/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002301/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002301/environment/setup/setup.sh b/tasks/format-code-task-002301/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002301/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002301/tests/test.patch b/tasks/format-code-task-002301/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ddf9a854ec593e410f4825812e3cc103215be149 --- /dev/null +++ b/tasks/format-code-task-002301/tests/test.patch @@ -0,0 +1,57 @@ +diff --git a/tests/integration/adapters/pouch-basics-test.js b/tests/integration/adapters/pouch-basics-test.js +index fc924c5..9f6415b 100644 +--- a/tests/integration/adapters/pouch-basics-test.js ++++ b/tests/integration/adapters/pouch-basics-test.js +@@ -437,6 +437,28 @@ test('delete cascade null', function (assert) { + 'deleted soup should have cascaded to a null value for the belongsTo'); + }).finally(done); + }); ++ ++module('not eventually consistent', { beforeEach: function() { ++ config.emberPouch.eventuallyConsistent = false; ++ }, ++ afterEach: function() { ++ config.emberPouch.eventuallyConsistent = true; ++ } ++ }, function() { ++ test('not found', function (assert) { ++ assert.expect(2); ++ assert.ok(config.emberPouch.eventuallyConsistent == false, 'eventuallyConsistent is false'); ++ let done = assert.async(); ++ ++ Ember.RSVP.Promise.resolve().then(() => this.store().findRecord('food-item', 'non-existent') ++ .then(() => assert.ok(false)) ++ .catch(() => { ++ assert.ok(true, 'item is not found'); ++ done(); ++ })); ++ }); ++}); ++ + }; + + let syncAsync = function() { +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+3VT2+bMBQAcM58ite02g2MCeBe9kfNJm2HrVKknSNjnOEJbGSbNR9/hqRrtknN ++Jd209f0uxvgJbJ6fSetRdc1G6m8keipZwMpyboNf2/malnmWM7osMhZllFZZHkH5ZDM6MjrPLUBk ++jfGPxZ0a/0elD/kXrTW9TO4sHwZpU9ee6x2n8k/L4kf+86oK+S8zxiLIzjWBxzzz/F9ekFppUnPX ++xnInBZBpoSQVXLSSDGPYCl5Ke9gcpFN63CW0uE6zlDF2ndKK3W+ceawqDl1IEm0Sx3VTmx0srt4s ++4r+9VvS7o/r30vmNMH0fcnbG6j9d/8uj+l8uaaj/oqIF1v+fIBqYE1/LJo4vYbWv3cM/AO6Ub38u ++5K2xMH0KCDtGWaN7qb2LV+/Xtx/fbW4+fHpJRmdJZwTv5oNl/8Dp0etRg28lKO3lF8u9MqEf3uxg ++G0L2l+RokPCGD15aRwYzijYJR5QSLpni0q8u1sMOZF+HSU53wiS3qgvRsLiZ4mC1/vx2AfmrFzQO ++55rycPUazx+EEEIIIYQQQgghhBBCCCGEEEL/re/lbIGQACgAAA== +diff --git 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-002301/tests/test.sh b/tasks/format-code-task-002301/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c4de1dff92be183a49815396969e8c09964554b --- /dev/null +++ b/tasks/format-code-task-002301/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/integration/adapters/pouch-basics-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-002301/tests/test_command.sh b/tasks/format-code-task-002301/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002301/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002306/environment/Dockerfile b/tasks/format-code-task-002306/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d3842d3a8ce2843601e57af91c378bde3ca1a408 --- /dev/null +++ b/tasks/format-code-task-002306/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:49b70b8cc030110a77629bf4474c63c0019f9adba0fd6d7d5213f772b530e2a3 diff --git a/tasks/format-code-task-002306/environment/setup/files/blocklist b/tasks/format-code-task-002306/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002306/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002306/environment/setup/setup.sh b/tasks/format-code-task-002306/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002306/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002306/tests/test.patch b/tasks/format-code-task-002306/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..76ceff30712dbe432090a50606347ecde1ef94ad --- /dev/null +++ b/tasks/format-code-task-002306/tests/test.patch @@ -0,0 +1,34 @@ +diff --git a/tests/identify_test.py b/tests/identify_test.py +index 1b5dde0..ec40cdf 100644 +--- a/tests/identify_test.py ++++ b/tests/identify_test.py +@@ -160,6 +160,9 @@ def test_tags_from_path_plist_text(tmpdir): + ('mod/Dockerfile', {'text', 'dockerfile'}), + ('Gemfile', {'text', 'ruby'}), + ('Gemfile.lock', {'text'}), ++ ('Jenkinsfile', {'text', 'groovy', 'jenkins'}), ++ ('build.jenkins', {'text', 'groovy', 'jenkins'}), ++ ('build.jenkinsfile', {'text', 'groovy', 'jenkins'}), + + # does not set binary / text + ('f.plist', {'plist'}), +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+3S32rDIBiHYY9zFY4dN/FLanM5IakZCSymVFvI3dfmYBuDrSctY/R9DvTzD6j8 ++zLvT+O6a3p8L9Sgmqa1d++R7v9ZiS5F6V1ZGlBGxda20fdiNvjiF2B61Vsd5jr/tu7X+T+Wf+cc+ ++xGY/T1PrXR6G+51xK38x24/8y7JK+W93Ikqb+13hZ0+e/+tL0Y2+6NowZHun10/Q9S47LHGYfaU3 ++k05lmtTXJhSj630c35bmOswPi96cs79+AwAAAAAAAAAAAAAAAPCsLiwZkIkAKAAA +diff --git 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-002306/tests/test.sh b/tasks/format-code-task-002306/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..437d0b924bf6e15867fb96cc915ae11a7835d90f --- /dev/null +++ b/tasks/format-code-task-002306/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/identify_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-002306/tests/test_command.sh b/tasks/format-code-task-002306/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002306/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002307/environment/Dockerfile b/tasks/format-code-task-002307/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e615aaec536e7952256850db8eff0f66f74d2a96 --- /dev/null +++ b/tasks/format-code-task-002307/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:422c1db24e9a5f1fa34d26d3c4fe504c3e9cea81f1f1261f8f9fc1bc0893fab7 diff --git a/tasks/format-code-task-002307/environment/setup/files/blocklist b/tasks/format-code-task-002307/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002307/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002307/environment/setup/setup.sh b/tasks/format-code-task-002307/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002307/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002307/tests/test.patch b/tasks/format-code-task-002307/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1174c68ca6e9bbcd7729ef065851eb9a8acafd0e --- /dev/null +++ b/tasks/format-code-task-002307/tests/test.patch @@ -0,0 +1,91 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..a2eca13 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/languages/docker_test.py -v"] ++} +diff --git a/tests/languages/docker_test.py b/tests/languages/docker_test.py +index 01b5e27..ccd2bb1 100644 +--- a/tests/languages/docker_test.py ++++ b/tests/languages/docker_test.py +@@ -81,9 +81,63 @@ def test_get_docker_path_not_in_docker_returns_same(): + assert docker._get_docker_path('abc') == 'abc' + + ++def test_get_container_id(): ++ cgroup_example = b'''\ ++12:hugetlb:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++11:blkio:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++10:freezer:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++9:cpu,cpuacct:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++8:pids:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++7:rdma:/ ++6:net_cls,net_prio:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++5:cpuset:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++4:devices:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++3:memory:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++2:perf_event:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++1:name=systemd:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++0::/system.slice/containerd.service ++''' # noqa: E501 ++ ++ with _mock_open(cgroup_example): ++ expected = ( ++ 'c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7' ++ ) ++ assert docker._get_container_id() == expected ++ ++ ++def test_get_docker_path_uses_container_id(): ++ cgroup_example = b'''\ ++12:hugetlb:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++5:cpuset:/docker/c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7 ++0::/system.slice/containerd.service ++''' # noqa: E501 ++ docker_out = json.dumps([{'Mounts': []}]).encode() ++ captured = [] ++ ++ def fake_cmd_output_b(*args): ++ captured.append(args) ++ return (0, docker_out, b'') ++ ++ with mock.patch.object(docker, '_is_in_docker', return_value=True), \ ++ _mock_open(cgroup_example), \ ++ mock.patch.object( ++ docker, 'cmd_output_b', side_effect=fake_cmd_output_b, ++ ): ++ docker._get_docker_path('/some/path') ++ ++ assert captured == [( ++ 'docker', 'inspect', ++ 'c33988ec7651ebc867cb24755eaf637a6734088bc7eef59d5799293a9e5450f7', ++ )] ++ ++ + @pytest.fixture + def in_docker(): +- with mock.patch.object(docker, '_is_in_docker', return_value=True): ++ with mock.patch.object( ++ docker, '_is_in_docker', return_value=True, ++ ), mock.patch.object( ++ docker, '_get_container_id', return_value='abc', ++ ): + yield + + +diff --git 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/languages/docker_test.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002307/tests/test.sh b/tasks/format-code-task-002307/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cbd21cd3b8cc5f9cd65cae3b609c1ecca1e7df5d --- /dev/null +++ b/tasks/format-code-task-002307/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/languages/docker_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002307/tests/test_command.sh b/tasks/format-code-task-002307/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002307/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002308/environment/Dockerfile b/tasks/format-code-task-002308/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0c6cae6d79528dd957aeee14ea0f6e98b374992f --- /dev/null +++ b/tasks/format-code-task-002308/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4d725f62dd434c67283850e6e9b3cfa0ddf6e08c78396e083a082e5cf88ec8d6 diff --git a/tasks/format-code-task-002308/environment/setup/files/blocklist b/tasks/format-code-task-002308/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002308/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002308/environment/setup/setup.sh b/tasks/format-code-task-002308/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002308/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002308/tests/test.patch b/tasks/format-code-task-002308/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2f7070beb34dae23f54de444f0a57c938ae2b83e --- /dev/null +++ b/tasks/format-code-task-002308/tests/test.patch @@ -0,0 +1,82 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..1d23b23 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/commands/hook_impl_test.py::test_run_ns_post_rewrite tests/commands/hook_impl_test.py::test_check_args_length_post_rewrite_too_few tests/commands/hook_impl_test.py::test_check_args_length_post_rewrite_too_many tests/commands/hook_impl_test.py::test_check_args_length_ok tests/commands/run_test.py::test_rewrite_command -v"] ++} +diff --git a/tests/commands/hook_impl_test.py b/tests/commands/hook_impl_test.py +index c38b9ca..91284f2 100644 +--- a/tests/commands/hook_impl_test.py ++++ b/tests/commands/hook_impl_test.py +@@ -98,6 +98,7 @@ def test_run_legacy_recursive(tmpdir): + ('commit-msg', ['.git/COMMIT_EDITMSG']), + ('post-commit', []), + ('post-merge', ['1']), ++ ('post-rewrite', ['amend']), + ('post-checkout', ['old_head', 'new_head', '1']), + # multiple choices for commit-editmsg + ('prepare-commit-msg', ['.git/COMMIT_EDITMSG']), +@@ -176,6 +177,24 @@ def test_run_ns_post_checkout(): + assert ns.checkout_type == 'c' + + ++def test_run_ns_post_rewrite(): ++ ns = hook_impl._run_ns('post-rewrite', True, ('amend',), b'') ++ assert ns is not None ++ assert ns.hook_stage == 'post-rewrite' ++ assert ns.color is True ++ assert ns.rewrite_command == 'amend' ++ ++ ++def test_check_args_length_post_rewrite_too_few(): ++ with pytest.raises(SystemExit): ++ hook_impl._check_args_length('post-rewrite', []) ++ ++ ++def test_check_args_length_post_rewrite_too_many(): ++ with pytest.raises(SystemExit): ++ hook_impl._check_args_length('post-rewrite', ['amend', 'extra']) ++ ++ + @pytest.fixture + def push_example(tempdir_factory): + src = git_dir(tempdir_factory) +diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py +index da7569e..9d40462 100644 +--- a/tests/commands/run_test.py ++++ b/tests/commands/run_test.py +@@ -504,6 +504,18 @@ def test_is_squash_merge(cap_out, store, repo_with_passing_hook): + assert environ['PRE_COMMIT_IS_SQUASH_MERGE'] == '1' + + ++def test_rewrite_command(cap_out, store, repo_with_passing_hook): ++ base_args = run_opts() ++ fields = dict(base_args._asdict()) ++ fields['rewrite_command'] = 'amend' ++ args = auto_namedtuple(**fields) ++ environ: MutableMapping[str, str] = {} ++ ret, printed = _do_run( ++ cap_out, store, repo_with_passing_hook, args, environ, ++ ) ++ assert environ['PRE_COMMIT_REWRITE_COMMAND'] == 'amend' ++ ++ + def test_checkout_type(cap_out, store, repo_with_passing_hook): + args = run_opts(from_ref='', to_ref='', checkout_type='1') + environ: MutableMapping[str, str] = {} +diff --git 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/commands/hook_impl_test.py::test_run_ns_post_rewrite tests/commands/hook_impl_test.py::test_check_args_length_post_rewrite_too_few tests/commands/hook_impl_test.py::test_check_args_length_post_rewrite_too_many tests/commands/hook_impl_test.py::test_check_args_length_ok tests/commands/run_test.py::test_rewrite_command -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002308/tests/test.sh b/tasks/format-code-task-002308/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5847821ab81f19d722e8cc2db2b89110f0aec51f --- /dev/null +++ b/tasks/format-code-task-002308/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/commands/hook_impl_test.py +tests/commands/run_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002308/tests/test_command.sh b/tasks/format-code-task-002308/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002308/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002339/environment/Dockerfile b/tasks/format-code-task-002339/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fcee7785231099d0383a3d349a5b37e1fe1b7486 --- /dev/null +++ b/tasks/format-code-task-002339/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:26b1b353e12b7cd57bd9507b433b482df31ff7402d545169b348712f766e7157 diff --git a/tasks/format-code-task-002339/environment/setup/files/blocklist b/tasks/format-code-task-002339/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002339/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002339/environment/setup/setup.sh b/tasks/format-code-task-002339/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002339/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002339/tests/test.patch b/tasks/format-code-task-002339/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6253c52fd5757f73aa01c3194dfd1c3aa85213ed --- /dev/null +++ b/tasks/format-code-task-002339/tests/test.patch @@ -0,0 +1,33 @@ +diff --git a/libcalico-go/lib/validator/v3/validator_test.go b/libcalico-go/lib/validator/v3/validator_test.go +index ab246c45929..b0a6a9b551d 100644 +--- a/libcalico-go/lib/validator/v3/validator_test.go ++++ b/libcalico-go/lib/validator/v3/validator_test.go +@@ -723,6 +723,8 @@ func init() { + Entry("should reject route table ranges min negative", api.FelixConfigurationSpec{RouteTableRanges: &api.RouteTableRanges{{Min: -5, Max: 250}}}, false), + Entry("should reject route table ranges max < min", api.FelixConfigurationSpec{RouteTableRanges: &api.RouteTableRanges{{Min: 50, Max: 45}}}, false), + Entry("should reject route table ranges max too large", api.FelixConfigurationSpec{RouteTableRanges: &api.RouteTableRanges{{Min: 1, Max: 0xf00000000}}}, false), ++ Entry("should reject single route table ranges targeting too many tables", api.FelixConfigurationSpec{RouteTableRanges: &api.RouteTableRanges{{Min: 1, Max: 0x10000}}}, false), ++ Entry("should reject multitple route table ranges targeting too many tables", api.FelixConfigurationSpec{RouteTableRanges: &api.RouteTableRanges{{Min: 1, Max: 2}, {Min: 3, Max: 4}, {Min: 5, Max: 0x10000}}}, false), + + Entry("should reject spec with both RouteTableRanges and RouteTableRange set", api.FelixConfigurationSpec{ + RouteTableRanges: &api.RouteTableRanges{ +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+3Rz4qDMBDHcc99inkBzR+rPe2zFE2kK1gDGn3+pl66LLS9tCxLv5/LZMhAJvyK ++dukHf+zGVWXvopNDVW01+V23s6mstofS2DrNGVPrfSbV2zb6YZljM4lkUwjx0dyz+3+quOUfuzke ++XTifm9EX8/fr3niWv9Hmlr8tU/77WttM9OtWuO/D83detuDbzu9OQa5HKdTQt64ZehfyU7g2ak2d ++b2KY1FoqyVfJXVjG+GV2f/0BAAAAAAAAAAAAAAAA4INdAMhAENQAKAAA +diff --git 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-002339/tests/test.sh b/tasks/format-code-task-002339/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbd34c3b35ee5669df9d7753d8c6277470eb93eb --- /dev/null +++ b/tasks/format-code-task-002339/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' +libcalico-go/lib/validator/v3/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-002339/tests/test_command.sh b/tasks/format-code-task-002339/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002339/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002353/environment/Dockerfile b/tasks/format-code-task-002353/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..138d45af4ac050a2a60395bf24591a6ebb733148 --- /dev/null +++ b/tasks/format-code-task-002353/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:47d688cf176a3cbb32a632a0ec341577e40ce11b1c8fb5a6148df1699c193764 diff --git a/tasks/format-code-task-002353/environment/setup/files/blocklist b/tasks/format-code-task-002353/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002353/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002353/environment/setup/setup.sh b/tasks/format-code-task-002353/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002353/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002353/tests/test.patch b/tasks/format-code-task-002353/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..19da7ec38402fe021411c638fd181e946b2d973a --- /dev/null +++ b/tasks/format-code-task-002353/tests/test.patch @@ -0,0 +1,157 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..9193030 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/test_black.py -k test_extend_exclude -v"] ++} +diff --git a/tests/test_black.py b/tests/test_black.py +index 5d14ced..3bcea5e 100644 +--- a/tests/test_black.py ++++ b/tests/test_black.py +@@ -1819,6 +1819,130 @@ class BlackTestCase(BlackBaseTestCase): + actual = diff_header.sub(DETERMINISTIC_HEADER, actual) + self.assertEqual(actual, expected) + ++ @patch("black.find_project_root", lambda *args: THIS_DIR.resolve()) ++ def test_extend_exclude_excludes_matching_files(self) -> None: ++ ++ ++ ++ ++ ++ path = THIS_DIR / "data" / "include_exclude_tests" ++ report = black.Report() ++ sources = sorted( ++ black.get_sources( ++ ctx=FakeContext(), ++ src=(str(path),), ++ quiet=True, ++ verbose=False, ++ include=r"\.pyi?$", ++ exclude="", ++ extend_exclude=r"/\.definitely_exclude/", ++ force_exclude=None, ++ report=report, ++ stdin_filename=None, ++ ) ++ ) ++ ++ for s in sources: ++ self.assertNotIn("/.definitely_exclude/", str(s)) ++ ++ present = {str(s) for s in sources} ++ self.assertIn(str(path / "b/dont_exclude/a.py"), present) ++ self.assertIn(str(path / "b/exclude/a.py"), present) ++ ++ @patch("black.find_project_root", lambda *args: THIS_DIR.resolve()) ++ def test_extend_exclude_and_exclude_both_apply(self) -> None: ++ ++ path = THIS_DIR / "data" / "include_exclude_tests" ++ report = black.Report() ++ expected = sorted( ++ [ ++ Path(path / "b/dont_exclude/a.py"), ++ Path(path / "b/dont_exclude/a.pyi"), ++ ] ++ ) ++ sources = sorted( ++ black.get_sources( ++ ctx=FakeContext(), ++ src=(str(path),), ++ quiet=True, ++ verbose=False, ++ include=r"\.pyi?$", ++ exclude=r"/exclude/", ++ extend_exclude=r"/\.definitely_exclude/", ++ force_exclude=None, ++ report=report, ++ stdin_filename=None, ++ ) ++ ) ++ self.assertEqual(expected, sources) ++ ++ @patch("black.find_project_root", lambda *args: THIS_DIR.resolve()) ++ def test_extend_exclude_none_preserves_existing_behavior(self) -> None: ++ ++ path = THIS_DIR / "data" / "include_exclude_tests" ++ report = black.Report() ++ expected = sorted( ++ [ ++ Path(path / "b/dont_exclude/a.py"), ++ Path(path / "b/dont_exclude/a.pyi"), ++ ] ++ ) ++ sources = sorted( ++ black.get_sources( ++ ctx=FakeContext(), ++ src=(str(path),), ++ quiet=True, ++ verbose=False, ++ include=r"\.pyi?$", ++ exclude=r"/exclude/|/\.definitely_exclude/", ++ extend_exclude=None, ++ force_exclude=None, ++ report=report, ++ stdin_filename=None, ++ ) ++ ) ++ self.assertEqual(expected, sources) ++ ++ @patch("black.find_project_root", lambda *args: THIS_DIR.resolve()) ++ def test_extend_exclude_alone_excludes_files(self) -> None: ++ ++ ++ ++ ++ ++ path = THIS_DIR / "data" / "include_exclude_tests" ++ report = black.Report() ++ ++ non_matching_exclude = r"___no_such_path___" ++ sources = sorted( ++ black.get_sources( ++ ctx=FakeContext(), ++ src=(str(path),), ++ quiet=True, ++ verbose=False, ++ include=r"\.pyi?$", ++ exclude=non_matching_exclude, ++ extend_exclude=r"/exclude/", ++ force_exclude=None, ++ report=report, ++ stdin_filename=None, ++ ) ++ ) ++ ++ ++ for s in sources: ++ self.assertNotIn("/exclude/", str(s)) ++ present = {str(s) for s in sources} ++ self.assertIn(str(path / "b/dont_exclude/a.py"), present) ++ self.assertIn(str(path / "b/.definitely_exclude/a.py"), present) ++ ++ def test_extend_exclude_cli_option_registered(self) -> None: ++ ++ result = BlackRunner().invoke(black.main, ["--help"]) ++ self.assertEqual(result.exit_code, 0) ++ self.assertIn("--extend-exclude", result.output) ++ + + with open(black.__file__, "r", encoding="utf-8") as _bf: + black_source_lines = _bf.readlines() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest tests/test_black.py -k test_extend_exclude -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002353/tests/test.sh b/tasks/format-code-task-002353/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1cd65971418dd4b17a47e1875dbb40779acdc472 --- /dev/null +++ b/tasks/format-code-task-002353/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_black.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-002353/tests/test_command.sh b/tasks/format-code-task-002353/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002353/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002354/environment/Dockerfile b/tasks/format-code-task-002354/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0322b32ea6422564edd0a47cdf5f2dd77eee5c45 --- /dev/null +++ b/tasks/format-code-task-002354/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7c27f66a0013a965d8ea9a884e0c97570dff8fb0595cb4d2bbc8c31436900916 diff --git a/tasks/format-code-task-002354/environment/setup/files/blocklist b/tasks/format-code-task-002354/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002354/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002354/environment/setup/setup.sh b/tasks/format-code-task-002354/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002354/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002354/tests/test.patch b/tasks/format-code-task-002354/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ade07c1a5a1841e054a0606b9675a82044fd2627 --- /dev/null +++ b/tasks/format-code-task-002354/tests/test.patch @@ -0,0 +1,153 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..f47c9e0 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1 @@ ++{ "test_commands": ["PYTHONPATH=src python -m pytest tests/test_docstring_backslash_whitespace.py -v"] } +diff --git a/tests/test_docstring_backslash_whitespace.py b/tests/test_docstring_backslash_whitespace.py +new file mode 100644 +index 0000000..1e836e8 +--- /dev/null ++++ b/tests/test_docstring_backslash_whitespace.py +@@ -0,0 +1,127 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++import black ++ ++pytestmark = pytest.mark.filterwarnings( ++ "ignore:invalid escape sequence.*:DeprecationWarning" ++) ++ ++ ++def _format(src: str) -> str: ++ return black.format_str(src, mode=black.Mode()) ++ ++ ++def test_issue_repro_backslash_space_newline_in_docstring() -> None: ++ ++ src = ( ++ "class Database:\n" ++ ' """\n' ++ " ## Database Base Class\n" ++ " The custom ORM specificaly created for the project.\\ \n" ++ " Provides a lot of functions to interact with the database in a" ++ " pythonic, easy and\n" ++ " fast way.\n" ++ ' """\n' ++ " def __init__(self):\n" ++ " ...\n" ++ ) ++ out = _format(src) ++ black.assert_equivalent(src, out) ++ assert "\\ \n" in out ++ ++ ++def test_backslash_single_space_newline_preserved() -> None: ++ src = ( ++ "def foo():\n" ++ ' """line one.\\ \n' ++ " line two.\n" ++ ' """\n' ++ " pass\n" ++ ) ++ out = _format(src) ++ black.assert_equivalent(src, out) ++ assert "\\ \n" in out ++ ++ ++def test_backslash_tab_newline_preserved() -> None: ++ src = ( ++ "def foo():\n" ++ ' """line one.\\\t\n' ++ " line two.\n" ++ ' """\n' ++ " pass\n" ++ ) ++ out = _format(src) ++ black.assert_equivalent(src, out) ++ assert "\\\t\n" in out ++ ++ ++def test_backslash_multiple_spaces_newline_preserved() -> None: ++ src = ( ++ "def foo():\n" ++ ' """line one.\\ \n' ++ " line two.\n" ++ ' """\n' ++ " pass\n" ++ ) ++ out = _format(src) ++ black.assert_equivalent(src, out) ++ assert "\\ \n" in out ++ ++ ++def test_plain_backslash_newline_still_preserved() -> None: ++ ++ ++ src = ( ++ "def foo():\n" ++ ' """line one.\\\n' ++ " line two.\n" ++ ' """\n' ++ " pass\n" ++ ) ++ out = _format(src) ++ black.assert_equivalent(src, out) ++ assert "\\\n" in out ++ ++ ++def test_docstring_without_backslash_still_normalized() -> None: ++ ++ ++ src = 'def foo():\n """ hi """\n pass\n' ++ out = _format(src) ++ assert out == 'def foo():\n """hi"""\n pass\n' ++ ++ ++def test_format_file_contents_does_not_raise_on_backslash_space_newline() -> None: ++ ++ ++ src = ( ++ "class Database:\n" ++ ' """\n' ++ " Header.\n" ++ " Content.\\ \n" ++ " More content here so the docstring is non-trivial.\n" ++ ' """\n' ++ " def __init__(self):\n" ++ " ...\n" ++ ) ++ ++ ++ try: ++ out = black.format_file_contents(src, fast=False, mode=black.Mode()) ++ except black.NothingChanged: ++ out = src ++ assert "\\ \n" in out +diff --git 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_docstring_backslash_whitespace.py::test_issue_repro_backslash_space_newline_in_docstring tests/test_docstring_backslash_whitespace.py::test_backslash_single_space_newline_preserved tests/test_docstring_backslash_whitespace.py::test_backslash_tab_newline_preserved tests/test_docstring_backslash_whitespace.py::test_backslash_multiple_spaces_newline_preserved tests/test_docstring_backslash_whitespace.py::test_plain_backslash_newline_still_preserved tests/test_docstring_backslash_whitespace.py::test_docstring_without_backslash_still_normalized tests/test_docstring_backslash_whitespace.py::test_format_file_contents_does_not_raise_on_backslash_space_newline ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002354/tests/test.sh b/tasks/format-code-task-002354/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca98922dff580741c7632c9f380e65997ee4a235 --- /dev/null +++ b/tasks/format-code-task-002354/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_docstring_backslash_whitespace.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-002354/tests/test_command.sh b/tasks/format-code-task-002354/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002354/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002362/environment/Dockerfile b/tasks/format-code-task-002362/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c659487a4ad99f1327e8951d784c4a1b198d50ec --- /dev/null +++ b/tasks/format-code-task-002362/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c3d364c3f84e33f43d7289f4274c8e03d571a5665596ae896324809c38ca25b2 diff --git a/tasks/format-code-task-002362/environment/setup/files/blocklist b/tasks/format-code-task-002362/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002362/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002362/environment/setup/setup.sh b/tasks/format-code-task-002362/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002362/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002362/tests/test.patch b/tasks/format-code-task-002362/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a41a21fff18f899594e1868babf0c6ed56f7b659 --- /dev/null +++ b/tasks/format-code-task-002362/tests/test.patch @@ -0,0 +1,286 @@ +diff --git a/pkg/engine/lifeycletest/component_options_warning_test.go b/pkg/engine/lifeycletest/component_options_warning_test.go +new file mode 100644 +index 0000000000..1c7f00e960 +--- /dev/null ++++ b/pkg/engine/lifeycletest/component_options_warning_test.go +@@ -0,0 +1,258 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package lifecycletest ++ ++import ( ++ "fmt" ++ "strings" ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ ++ . "github.com/pulumi/pulumi/pkg/v3/engine" ++ "github.com/pulumi/pulumi/pkg/v3/resource/deploy" ++ "github.com/pulumi/pulumi/pkg/v3/resource/deploy/deploytest" ++ "github.com/pulumi/pulumi/sdk/v3/go/common/diag" ++ "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" ++ "github.com/pulumi/pulumi/sdk/v3/go/common/resource" ++ "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" ++ "github.com/pulumi/pulumi/sdk/v3/go/common/util/result" ++ "github.com/pulumi/pulumi/sdk/v3/go/common/workspace" ++) ++ ++ ++ ++func runComponentOptionsTest(t *testing.T, custom bool, opts deploytest.ResourceOptions) []string { ++ t.Helper() ++ runtime := deploytest.NewLanguageRuntime(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error { ++ _, _, _, err := monitor.RegisterResource("component", "resA", custom, opts) ++ assert.NoError(t, err) ++ return nil ++ }) ++ host := deploytest.NewPluginHost(nil, nil, runtime) ++ ++ var warnings []string ++ p := &TestPlan{ ++ Options: UpdateOptions{Host: host}, ++ Steps: []TestStep{{ ++ Op: Update, ++ ExpectFailure: false, ++ SkipPreview: true, ++ Validate: func( ++ _ workspace.Project, ++ _ deploy.Target, ++ _ JournalEntries, ++ evts []Event, ++ res result.Result, ++ ) result.Result { ++ for _, evt := range evts { ++ if evt.Type == DiagEvent { ++ e := evt.Payload().(DiagEventPayload) ++ if e.Severity == diag.Warning { ++ warnings = append(warnings, colors.Never.Colorize(e.Message)) ++ } ++ } ++ } ++ return res ++ }, ++ }}, ++ } ++ p.Run(t, nil) ++ return warnings ++} ++ ++ ++ ++func warningPresent(warnings []string, optName string) bool { ++ expected := fmt.Sprintf("The option '%s' has no effect on component resources.", optName) ++ for _, w := range warnings { ++ if strings.Contains(w, expected) { ++ return true ++ } ++ } ++ return false ++} ++ ++ ++ ++func TestComponentOption_IgnoreChanges_Warns(t *testing.T) { ++ t.Parallel() ++ warnings := runComponentOptionsTest(t, false, deploytest.ResourceOptions{ ++ IgnoreChanges: []string{"root"}, ++ }) ++ assert.True(t, warningPresent(warnings, "ignoreChanges"), ++ "expected per-option ignoreChanges warning; got: %v", warnings) ++} ++ ++ ++ ++func TestComponentOption_AdditionalSecretOutputs_Warns(t *testing.T) { ++ t.Parallel() ++ warnings := runComponentOptionsTest(t, false, deploytest.ResourceOptions{ ++ AdditionalSecretOutputs: []resource.PropertyKey{"foobar"}, ++ }) ++ assert.True(t, warningPresent(warnings, "additionalSecretOutputs"), ++ "expected per-option additionalSecretOutputs warning; got: %v", warnings) ++} ++ ++ ++ ++func TestComponentOption_ReplaceOnChanges_Warns(t *testing.T) { ++ t.Parallel() ++ warnings := runComponentOptionsTest(t, false, deploytest.ResourceOptions{ ++ ReplaceOnChanges: []string{"*"}, ++ }) ++ assert.True(t, warningPresent(warnings, "replaceOnChanges"), ++ "expected per-option replaceOnChanges warning; got: %v", warnings) ++} ++ ++ ++ ++func TestComponentOption_RetainOnDelete_Warns(t *testing.T) { ++ t.Parallel() ++ warnings := runComponentOptionsTest(t, false, deploytest.ResourceOptions{ ++ RetainOnDelete: true, ++ }) ++ assert.True(t, warningPresent(warnings, "retainOnDelete"), ++ "expected per-option retainOnDelete warning; got: %v", warnings) ++} ++ ++ ++ ++func TestComponentOption_CustomTimeouts_Warns(t *testing.T) { ++ t.Parallel() ++ warnings := runComponentOptionsTest(t, false, deploytest.ResourceOptions{ ++ CustomTimeouts: &resource.CustomTimeouts{ ++ Create: 60, ++ }, ++ }) ++ assert.True(t, warningPresent(warnings, "customTimeouts"), ++ "expected per-option customTimeouts warning; got: %v", warnings) ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++func TestComponentOption_NoOpts_NoWarnings(t *testing.T) { ++ t.Parallel() ++ warnings := runComponentOptionsTest(t, false, deploytest.ResourceOptions{}) ++ for _, opt := range []string{ ++ "ignoreChanges", ++ "customTimeouts", ++ "additionalSecretOutputs", ++ "replaceOnChanges", ++ "retainOnDelete", ++ } { ++ assert.False(t, warningPresent(warnings, opt), ++ "unexpected %s warning when no opts were provided; got: %v", opt, warnings) ++ } ++} ++ ++ ++ ++ ++func TestComponentOption_CustomResource_NoWarnings(t *testing.T) { ++ t.Parallel() ++ ++ ++ ++ ++ runtime := deploytest.NewLanguageRuntime(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error { ++ _, _, _, _ = monitor.RegisterResource("pkgA:m:typA", "resA", true, deploytest.ResourceOptions{ ++ IgnoreChanges: []string{"root"}, ++ AdditionalSecretOutputs: []resource.PropertyKey{"foobar"}, ++ ReplaceOnChanges: []string{"*"}, ++ RetainOnDelete: true, ++ CustomTimeouts: &resource.CustomTimeouts{Create: 60}, ++ }) ++ return nil ++ }) ++ host := deploytest.NewPluginHost(nil, nil, runtime) ++ ++ var warnings []string ++ p := &TestPlan{ ++ Options: UpdateOptions{Host: host}, ++ Steps: []TestStep{{ ++ Op: Update, ++ ExpectFailure: true, ++ SkipPreview: true, ++ Validate: func( ++ _ workspace.Project, ++ _ deploy.Target, ++ _ JournalEntries, ++ evts []Event, ++ res result.Result, ++ ) result.Result { ++ for _, evt := range evts { ++ if evt.Type == DiagEvent { ++ e := evt.Payload().(DiagEventPayload) ++ if e.Severity == diag.Warning { ++ warnings = append(warnings, colors.Never.Colorize(e.Message)) ++ } ++ } ++ } ++ return res ++ }, ++ }}, ++ } ++ p.Run(t, nil) ++ ++ for _, opt := range []string{ ++ "ignoreChanges", ++ "customTimeouts", ++ "additionalSecretOutputs", ++ "replaceOnChanges", ++ "retainOnDelete", ++ } { ++ assert.False(t, warningPresent(warnings, opt), ++ "unexpected %s 'no effect on component resources' warning for custom resource; got: %v", ++ opt, warnings) ++ } ++} ++ ++ ++ ++ ++ ++ ++func TestComponentOption_AllOptions_EachWarnsSeparately(t *testing.T) { ++ t.Parallel() ++ warnings := runComponentOptionsTest(t, false, deploytest.ResourceOptions{ ++ IgnoreChanges: []string{"root.nested"}, ++ AdditionalSecretOutputs: []resource.PropertyKey{"bucket"}, ++ ReplaceOnChanges: []string{"*"}, ++ RetainOnDelete: true, ++ CustomTimeouts: &resource.CustomTimeouts{ ++ Create: 60, ++ Update: 60, ++ Delete: 60, ++ }, ++ }) ++ for _, opt := range []string{ ++ "ignoreChanges", ++ "customTimeouts", ++ "additionalSecretOutputs", ++ "replaceOnChanges", ++ "retainOnDelete", ++ } { ++ assert.True(t, warningPresent(warnings, opt), ++ "expected per-option %s warning; got: %v", opt, warnings) ++ } ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..af32852319 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd pkg && go test ./engine/lifeycletest/ -run TestComponentOption_ -count=1 -timeout 180s"] ++} +diff --git 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 pkg && go test ./engine/lifeycletest/ -run TestComponentOption_ -count=1 -timeout 180s ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002362/tests/test.sh b/tasks/format-code-task-002362/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7d6c6b5ac59deba18296b99dced09a4669e55cf --- /dev/null +++ b/tasks/format-code-task-002362/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/engine/lifeycletest/component_options_warning_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-002362/tests/test_command.sh b/tasks/format-code-task-002362/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002362/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002365/environment/Dockerfile b/tasks/format-code-task-002365/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..89780e2370d2db735b86293379ba0d9eb8041cd9 --- /dev/null +++ b/tasks/format-code-task-002365/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b88c63a01aaf61c27ba8820a3c10fb0c22cb08e73b56220d27840cde370d8523 diff --git a/tasks/format-code-task-002365/environment/setup/files/blocklist b/tasks/format-code-task-002365/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002365/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002365/environment/setup/setup.sh b/tasks/format-code-task-002365/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002365/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002365/tests/test.patch b/tasks/format-code-task-002365/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1bc126787e4337a8cab561561cc584fe5af2e28c --- /dev/null +++ b/tasks/format-code-task-002365/tests/test.patch @@ -0,0 +1,280 @@ +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,258 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++( cd /workspace/repo && cmake -S tools/xar -B "$TMP/build" >/dev/null && cmake --build "$TMP/build" --target host_xar -j2 >/dev/null ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN="$TMP/build/xar" ++ ++cd "$TMP" ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++make_header() { ++ python3 - "$@" <<'PY' ++import struct ++import sys ++ ++path = sys.argv[1] ++magic = int(sys.argv[2], 0) ++size = int(sys.argv[3], 0) ++version = int(sys.argv[4], 0) ++compressed = int(sys.argv[5], 0) ++uncompressed = int(sys.argv[6], 0) ++algorithm = int(sys.argv[7], 0) ++name_hex = sys.argv[8] if len(sys.argv) > 8 else "" ++ ++data = struct.pack(">IHHQQI", magic, size, version, compressed, uncompressed, algorithm) ++if name_hex: ++ data += bytes.fromhex(name_hex) ++ data += b"\0" * max(0, 64 - len(data)) ++with open(path, "wb") as f: ++ f.write(data) ++PY ++} ++ ++assert_empty_stderr() { ++ fixture="$1" ++ [ ! -s err ] || fail "$fixture unexpected stderr: $(cat err)" ++} ++ ++ ++ ++ ++"$BIN" --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F_help exit $ec; want 0" ++ ++HELP_LINE=$(grep -F -- "--dump-header" out | head -n1 || true) ++[ -n "$HELP_LINE" ] || fail "F_help missing --dump-header help line" ++HELP_LOWER=$(printf '%s\n' "$HELP_LINE" | tr '[:upper:]' '[:lower:]') ++case "$HELP_LOWER" in *binary*) ;; *) fail "F_help --dump-header line does not mention binary: $HELP_LINE" ;; esac ++case "$HELP_LOWER" in *header*) ;; *) fail "F_help --dump-header line does not mention header: $HELP_LINE" ;; esac ++case "$HELP_LOWER" in *information*) ;; *) fail "F_help --dump-header line does not mention information: $HELP_LINE" ;; esac ++assert_empty_stderr F_help ++ ++ ++ ++ ++make_header sha1_base.xar 0x78617221 28 1 17 31 1 ++"$BIN" --dump-header -f sha1_base.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 28 ++version: 1 ++Compressed TOC length: 17 ++Uncompressed TOC length: 31 ++TOC Checksum algorithm: 1 (sha1) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_sha1 exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_sha1 stdout: $(cat out)" ++assert_empty_stderr F_sha1 ++ ++ ++ ++ ++make_header none_base.xar 0x78617221 28 1 0 9 0 ++"$BIN" --dump-header -f none_base.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 28 ++version: 1 ++Compressed TOC length: 0 ++Uncompressed TOC length: 9 ++TOC Checksum algorithm: 0 (none) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_none exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_none stdout: $(cat out)" ++assert_empty_stderr F_none ++ ++ ++ ++ ++make_header md5_base.xar 0x78617221 28 2 123456789 987654321 2 ++"$BIN" --dump-header -f md5_base.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 28 ++version: 2 ++Compressed TOC length: 123456789 ++Uncompressed TOC length: 987654321 ++TOC Checksum algorithm: 2 (md5) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_md5_large_fields exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_md5_large_fields stdout: $(cat out)" ++assert_empty_stderr F_md5_large_fields ++ ++ ++ ++ ++make_header unknown_base.xar 0x78617221 28 1 5 6 99 ++"$BIN" --dump-header -f unknown_base.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 28 ++version: 1 ++Compressed TOC length: 5 ++Uncompressed TOC length: 6 ++TOC Checksum algorithm: 99 (unknown) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_unknown exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_unknown stdout: $(cat out)" ++assert_empty_stderr F_unknown ++ ++ ++ ++ ++make_header bad_magic.xar 0x12345678 28 1 11 22 2 ++"$BIN" --dump-header -f bad_magic.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x12345678 (BAD) ++size: 28 ++version: 1 ++Compressed TOC length: 11 ++Uncompressed TOC length: 22 ++TOC Checksum algorithm: 2 (md5) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_bad_magic exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_bad_magic stdout: $(cat out)" ++assert_empty_stderr F_bad_magic ++ ++ ++ ++ ++make_header other_valid.xar 0x78617221 64 1 44 88 3 73686132353600 ++"$BIN" --dump-header -f other_valid.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 64 ++version: 1 ++Compressed TOC length: 44 ++Uncompressed TOC length: 88 ++TOC Checksum algorithm: 3 (OTHER + sha256) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_other_valid exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_other_valid stdout: $(cat out)" ++assert_empty_stderr F_other_valid ++ ++ ++ ++ ++make_header other_invalid_len_small.xar 0x78617221 30 1 44 88 3 616200 ++"$BIN" --dump-header -f other_invalid_len_small.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 30 ++version: 1 ++Compressed TOC length: 44 ++Uncompressed TOC length: 88 ++TOC Checksum algorithm: 3 (OTHER + invalid header length) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_other_invalid_short_length exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_other_invalid_short_length stdout: $(cat out)" ++assert_empty_stderr F_other_invalid_short_length ++ ++ ++ ++ ++make_header other_invalid_len_unaligned.xar 0x78617221 34 1 44 88 3 6162636400 ++"$BIN" --dump-header -f other_invalid_len_unaligned.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 34 ++version: 1 ++Compressed TOC length: 44 ++Uncompressed TOC length: 88 ++TOC Checksum algorithm: 3 (OTHER + invalid header length) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_other_invalid_unaligned_length exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_other_invalid_unaligned_length stdout: $(cat out)" ++assert_empty_stderr F_other_invalid_unaligned_length ++ ++ ++ ++ ++make_header other_non_nul.xar 0x78617221 32 1 44 88 3 61626364 ++"$BIN" --dump-header -f other_non_nul.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 32 ++version: 1 ++Compressed TOC length: 44 ++Uncompressed TOC length: 88 ++TOC Checksum algorithm: 3 (OTHER + invalid non-nul terminated name) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_other_non_nul exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_other_non_nul stdout: $(cat out)" ++assert_empty_stderr F_other_non_nul ++ ++ ++ ++ ++make_header other_empty.xar 0x78617221 32 1 44 88 3 00616263 ++"$BIN" --dump-header -f other_empty.xar >out 2>err; ec=$? ++EXPECTED=$(cat <<'EOF' ++magic: 0x78617221 (OK) ++size: 32 ++version: 1 ++Compressed TOC length: 44 ++Uncompressed TOC length: 88 ++TOC Checksum algorithm: 3 (OTHER + invalid empty name) ++EOF ++) ++[ "$ec" -eq 0 ] || fail "F_other_empty exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F_other_empty stdout: $(cat out)" ++assert_empty_stderr F_other_empty ++ ++ ++ ++ ++"$BIN" --dump-header -f no-such.xar >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F_open_error exit 0; want non-zero" ++[ ! -s out ] || fail "F_open_error unexpected stdout: $(cat out)" ++ ++[ -s err ] || fail "F_open_error missing stderr" ++grep -Fq "No such file or directory" err || fail "F_open_error stderr: $(cat err)" ++ ++ ++ ++ ++printf '\x78\x61\x72' > short.xar ++"$BIN" --dump-header -f short.xar >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F_short_read exit 0; want non-zero" ++[ ! -s out ] || fail "F_short_read unexpected stdout: $(cat out)" ++[ "$(cat err)" = "error reading header" ] || fail "F_short_read stderr: $(cat err)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002365/tests/test.sh b/tasks/format-code-task-002365/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-002365/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-002365/tests/test_command.sh b/tasks/format-code-task-002365/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002365/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-002375/environment/Dockerfile b/tasks/format-code-task-002375/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ba9e10f6a1c88c07627bc78cb4d78b7d97dc0ce9 --- /dev/null +++ b/tasks/format-code-task-002375/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a09aaafbf7e5d659021dee5e80e8b155acaec07a9b2a7c4d4a839cb23963db56 diff --git a/tasks/format-code-task-002375/environment/setup/files/blocklist b/tasks/format-code-task-002375/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002375/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002375/environment/setup/setup.sh b/tasks/format-code-task-002375/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002375/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002375/tests/test.patch b/tasks/format-code-task-002375/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5a1b1f91167a41db8a5f0fd8cdacb58fa656fc31 --- /dev/null +++ b/tasks/format-code-task-002375/tests/test.patch @@ -0,0 +1,97 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..8204ba87c +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_json_schema.py -k enum_with_no_cases -v"] ++} +diff --git a/tests/test_json_schema.py b/tests/test_json_schema.py +index 227e674d0..2a3310978 100644 +--- a/tests/test_json_schema.py ++++ b/tests/test_json_schema.py +@@ -500,6 +500,70 @@ def test_enum_schema_cleandoc(): + } + + ++def test_enum_with_no_cases_json_schema(): ++ class MyEnum(Enum): ++ pass ++ ++ class MyModel(BaseModel): ++ e: MyEnum ++ ++ schema = MyModel.model_json_schema() ++ ++ ++ e_schema = schema['properties']['e'] ++ if '$ref' in e_schema: ++ ref = e_schema['$ref'].split('/')[-1] ++ e_schema = schema['$defs'][ref] ++ assert e_schema.get('enum') == [] ++ assert e_schema.get('title') == 'MyEnum' ++ assert 'e' in schema['required'] ++ ++ ++def test_enum_with_no_cases_includes_description_from_docstring(): ++ class MyEnum(Enum): ++ """Some enum description.""" ++ ++ class MyModel(BaseModel): ++ e: MyEnum ++ ++ schema = MyModel.model_json_schema() ++ e_schema = schema['properties']['e'] ++ if '$ref' in e_schema: ++ ref = e_schema['$ref'].split('/')[-1] ++ e_schema = schema['$defs'][ref] ++ assert e_schema.get('description') == 'Some enum description.' ++ assert e_schema.get('enum') == [] ++ assert e_schema.get('title') == 'MyEnum' ++ ++ ++def test_enum_with_no_cases_default_docstring_suppressed(): ++ ++ ++ class MyEnum(Enum): ++ pass ++ ++ class MyModel(BaseModel): ++ e: MyEnum ++ ++ schema = MyModel.model_json_schema() ++ e_schema = schema['properties']['e'] ++ if '$ref' in e_schema: ++ ref = e_schema['$ref'].split('/')[-1] ++ e_schema = schema['$defs'][ref] ++ assert 'description' not in e_schema ++ ++ ++def test_enum_with_no_cases_validation_still_rejects_values(): ++ class MyEnum(Enum): ++ pass ++ ++ class MyModel(BaseModel): ++ e: MyEnum ++ ++ with pytest.raises(ValidationError): ++ MyModel(e='anything') ++ ++ + def test_decimal_json_schema(): + class Model(BaseModel): + a: bytes = b'foobar' +diff --git 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_json_schema.py -k enum_with_no_cases -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002375/tests/test.sh b/tasks/format-code-task-002375/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6eb288f58e9743c035de56739124a9dad85cdad9 --- /dev/null +++ b/tasks/format-code-task-002375/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_json_schema.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002375/tests/test_command.sh b/tasks/format-code-task-002375/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002375/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002391/environment/Dockerfile b/tasks/format-code-task-002391/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..78ed8471f427a6635c91e0922b153b39efac5d8c --- /dev/null +++ b/tasks/format-code-task-002391/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fec750dc1ef07f83670b3354eeda17ec79c4e7a0b5907124c344238568e67389 diff --git a/tasks/format-code-task-002391/environment/setup/files/blocklist b/tasks/format-code-task-002391/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002391/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002391/environment/setup/setup.sh b/tasks/format-code-task-002391/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002391/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002391/tests/test.patch b/tasks/format-code-task-002391/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b6d553f2e6c01466c6f19d00ab8b8e25efca47b8 --- /dev/null +++ b/tasks/format-code-task-002391/tests/test.patch @@ -0,0 +1,422 @@ +diff --git a/usercase-test-coderl/test_auditor_deduplicates_vulnerabilities.py b/usercase-test-coderl/test_auditor_deduplicates_vulnerabilities.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_auditor_deduplicates_vulnerabilities.py +@@ -0,0 +1,393 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++from collections.abc import Iterator ++ ++from packaging.version import Version ++ ++from pip_audit._audit import AuditOptions, Auditor ++from pip_audit._dependency_source import DependencySource ++from pip_audit._service import ( ++ Dependency, ++ ResolvedDependency, ++ VulnerabilityResult, ++ VulnerabilityService, ++) ++ ++ ++def _dep(name: str = "demo-pkg", version: str = "1.0.0") -> ResolvedDependency: ++ return ResolvedDependency(name=name, version=Version(version)) ++ ++ ++def _vuln(id_: str, aliases: set[str]) -> VulnerabilityResult: ++ return VulnerabilityResult( ++ id=id_, ++ description=f"desc {id_}", ++ fix_versions=[Version("2.0.0")], ++ aliases=aliases, ++ ) ++ ++ ++class RecordingSource(DependencySource): ++ def __init__(self, deps: list[Dependency]): ++ self.deps = deps ++ self.collect_calls = 0 ++ ++ def collect(self) -> Iterator[Dependency]: ++ self.collect_calls += 1 ++ yield from self.deps ++ ++ def fix(self, _fix_version) -> None: ++ raise NotImplementedError ++ ++ ++class RecordingService(VulnerabilityService): ++ def __init__(self, responses: dict[str, list[VulnerabilityResult]]): ++ self.responses = responses ++ self.query_all_calls = 0 ++ self.spec_batches: list[list[Dependency]] = [] ++ ++ def query(self, spec: Dependency) -> tuple[Dependency, list[VulnerabilityResult]]: ++ return spec, self.responses[spec.name] ++ ++ def query_all( ++ self, specs: Iterator[Dependency] ++ ) -> Iterator[tuple[Dependency, list[VulnerabilityResult]]]: ++ self.query_all_calls += 1 ++ batch = list(specs) ++ self.spec_batches.append(batch) ++ for dep in batch: ++ yield dep, self.responses[dep.name] ++ ++ ++def _summary( ++ results: list[tuple[Dependency, list[VulnerabilityResult]]], ++) -> list[tuple[str, str, list[tuple[str, list[str]]]]]: ++ ++ ++ return sorted( ++ [ ++ ( ++ dep.name, ++ str(dep.version), ++ sorted( ++ [ ++ ( ++ vuln.id, ++ sorted(vuln.aliases), ++ ) ++ for vuln in vulns ++ ], ++ key=lambda item: (item[0], item[1]), ++ ), ++ ) ++ for dep, vulns in results ++ ], ++ key=lambda item: (item[0], item[1]), ++ ) ++ ++ ++def _service_batches_summary( ++ service: RecordingService, ++) -> list[set[tuple[str, str]]]: ++ ++ ++ return [ ++ {(dep.name, str(dep.version)) for dep in batch} for batch in service.spec_batches ++ ] ++ ++ ++def test_audit_collapses_two_records_and_merges_aliases() -> None: ++ ++ ++ ++ ++ dep = _dep() ++ source = RecordingSource([dep]) ++ service = RecordingService( ++ { ++ "demo-pkg": [ ++ _vuln("PYSEC-0", {"CVE-2024-0001"}), ++ _vuln("GHSA-aaaa", {"CVE-2024-0001", "GHSA-aaaa"}), ++ ] ++ } ++ ) ++ ++ assert source.collect_calls == 0 ++ assert service.query_all_calls == 0 ++ ++ results = list(Auditor(service, options=AuditOptions()).audit(source)) ++ ++ assert _summary(results) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [("PYSEC-0", ["CVE-2024-0001", "GHSA-aaaa"])], ++ ) ++ ] ++ ++ ++ assert source.collect_calls >= 1 ++ assert service.query_all_calls >= 1 ++ assert _service_batches_summary(service) == [{("demo-pkg", "1.0.0")}] ++ ++ ++def test_pysec_result_wins_when_provider_returns_it_second() -> None: ++ ++ ++ ++ ++ dep = _dep() ++ source = RecordingSource([dep]) ++ service = RecordingService( ++ { ++ "demo-pkg": [ ++ _vuln("GHSA-aaaa", {"CVE-2024-0001", "GHSA-aaaa"}), ++ _vuln("PYSEC-0", {"CVE-2024-0001"}), ++ ] ++ } ++ ) ++ ++ results = list(Auditor(service).audit(source)) ++ ++ assert _summary(results) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [("PYSEC-0", ["CVE-2024-0001", "GHSA-aaaa"])], ++ ) ++ ] ++ ++ ++ assert source.collect_calls >= 1 ++ assert service.query_all_calls >= 1 ++ ++ ++def test_three_alias_linked_records_collapse_to_one_pysec_result() -> None: ++ ++ ++ ++ ++ dep = _dep() ++ source = RecordingSource([dep]) ++ service = RecordingService( ++ { ++ "demo-pkg": [ ++ _vuln("PYSEC-0", {"CVE-2024-0001"}), ++ _vuln("GHSA-aaaa", {"CVE-2024-0001"}), ++ _vuln("CVE-2024-0001", {"GHSA-aaaa"}), ++ ] ++ } ++ ) ++ ++ results = list(Auditor(service).audit(source)) ++ ++ assert _summary(results) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [("PYSEC-0", ["CVE-2024-0001", "GHSA-aaaa"])], ++ ) ++ ] ++ ++ ++ assert source.collect_calls >= 1 ++ assert service.query_all_calls >= 1 ++ ++ ++def test_audit_deduplicates_each_dependency_independently() -> None: ++ ++ ++ ++ ++ first = _dep("demo-pkg", "1.0.0") ++ second = _dep("other-pkg", "4.5.6") ++ source = RecordingSource([first, second]) ++ service = RecordingService( ++ { ++ "demo-pkg": [ ++ _vuln("PYSEC-0", {"CVE-2024-0001"}), ++ _vuln("GHSA-aaaa", {"CVE-2024-0001", "GHSA-aaaa"}), ++ ], ++ "other-pkg": [ ++ _vuln("GHSA-bbbb", {"CVE-2024-0002"}), ++ _vuln("PYSEC-1", {"CVE-2024-0002"}), ++ ], ++ } ++ ) ++ ++ results = list(Auditor(service).audit(source)) ++ ++ assert _summary(results) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [("PYSEC-0", ["CVE-2024-0001", "GHSA-aaaa"])], ++ ), ++ ( ++ "other-pkg", ++ "4.5.6", ++ [("PYSEC-1", ["CVE-2024-0002"])], ++ ), ++ ] ++ ++ ++ assert source.collect_calls >= 1 ++ assert service.query_all_calls >= 1 ++ assert _service_batches_summary(service) == [ ++ {("demo-pkg", "1.0.0"), ("other-pkg", "4.5.6")} ++ ] ++ ++ ++def test_audit_preserves_distinct_non_overlapping_vulnerabilities() -> None: ++ ++ ++ ++ ++ dep = _dep() ++ source = RecordingSource([dep]) ++ service = RecordingService( ++ { ++ "demo-pkg": [ ++ _vuln("PYSEC-0", {"CVE-2024-0001"}), ++ _vuln("GHSA-bbbb", {"CVE-2024-0002"}), ++ ] ++ } ++ ) ++ ++ results = list(Auditor(service).audit(source)) ++ ++ assert _summary(results) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [ ++ ("GHSA-bbbb", ["CVE-2024-0002"]), ++ ("PYSEC-0", ["CVE-2024-0001"]), ++ ], ++ ) ++ ] ++ ++ ++ assert source.collect_calls >= 1 ++ assert service.query_all_calls >= 1 ++ ++ ++def test_default_options_collects_source_and_queries_service() -> None: ++ ++ ++ ++ ++ dep = _dep() ++ source = RecordingSource([dep]) ++ service = RecordingService({"demo-pkg": [_vuln("PYSEC-0", {"CVE-2024-0001"})]}) ++ ++ ++ ++ results = list(Auditor(service, options=AuditOptions()).audit(source)) ++ ++ assert _summary(results) == [ ++ ("demo-pkg", "1.0.0", [("PYSEC-0", ["CVE-2024-0001"])]) ++ ] ++ ++ ++ assert source.collect_calls >= 1 ++ assert service.query_all_calls >= 1 ++ assert _service_batches_summary(service) == [{("demo-pkg", "1.0.0")}] ++ ++ ++def test_same_auditor_uses_current_service_results_on_repeated_audits() -> None: ++ ++ ++ ++ ++ dep = _dep() ++ service = RecordingService( ++ { ++ "demo-pkg": [ ++ _vuln("PYSEC-0", {"CVE-2024-0001"}), ++ _vuln("GHSA-aaaa", {"CVE-2024-0001"}), ++ ] ++ } ++ ) ++ auditor = Auditor(service) ++ ++ first_results = list(auditor.audit(RecordingSource([dep]))) ++ service.responses = { ++ "demo-pkg": [ ++ _vuln("PYSEC-9", {"CVE-2024-0009"}), ++ _vuln("GHSA-zzzz", {"CVE-2024-0009"}), ++ ] ++ } ++ second_results = list(auditor.audit(RecordingSource([dep]))) ++ ++ assert _summary(first_results) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [("PYSEC-0", ["CVE-2024-0001"])], ++ ) ++ ] ++ assert _summary(second_results) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [("PYSEC-9", ["CVE-2024-0009"])], ++ ) ++ ] ++ ++ ++ assert service.query_all_calls >= 2 ++ ++ ++def test_two_auditor_instances_keep_their_services_independent() -> None: ++ ++ ++ ++ ++ dep = _dep() ++ service_a = RecordingService( ++ { ++ "demo-pkg": [ ++ _vuln("PYSEC-0", {"CVE-2024-0001"}), ++ _vuln("GHSA-aaaa", {"CVE-2024-0001"}), ++ ] ++ } ++ ) ++ service_b = RecordingService( ++ { ++ "demo-pkg": [ ++ _vuln("PYSEC-9", {"CVE-2024-0009"}), ++ _vuln("GHSA-zzzz", {"CVE-2024-0009"}), ++ ] ++ } ++ ) ++ ++ result_a = list(Auditor(service_a).audit(RecordingSource([dep]))) ++ result_b = list(Auditor(service_b).audit(RecordingSource([dep]))) ++ ++ assert _summary(result_a) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [("PYSEC-0", ["CVE-2024-0001"])], ++ ) ++ ] ++ assert _summary(result_b) == [ ++ ( ++ "demo-pkg", ++ "1.0.0", ++ [("PYSEC-9", ["CVE-2024-0009"])], ++ ) ++ ] ++ ++ ++ assert service_a.query_all_calls >= 1 ++ assert service_b.query_all_calls >= 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,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_auditor_deduplicates_vulnerabilities.py -v diff --git a/tasks/format-code-task-002391/tests/test.sh b/tasks/format-code-task-002391/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ca4b48bdc5cb4cdedd6ae656477d1e7ef3ca2af --- /dev/null +++ b/tasks/format-code-task-002391/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_auditor_deduplicates_vulnerabilities.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-002391/tests/test_command.sh b/tasks/format-code-task-002391/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002391/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-002396/environment/Dockerfile b/tasks/format-code-task-002396/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2153ca6e16cb02fe25343b6fab31c64a35e615ee --- /dev/null +++ b/tasks/format-code-task-002396/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ab40499cd7866b094cb064a7daa87ba3816f67f3d10e62e7e66c865b3924f795 diff --git a/tasks/format-code-task-002396/environment/setup/files/blocklist b/tasks/format-code-task-002396/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002396/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002396/environment/setup/setup.sh b/tasks/format-code-task-002396/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002396/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002396/tests/test.patch b/tasks/format-code-task-002396/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..55231b9b60a6bcb1399a6276b1fcca1ef1af26af --- /dev/null +++ b/tasks/format-code-task-002396/tests/test.patch @@ -0,0 +1,66 @@ +diff --git a/tests/unit/accounts/test_forms.py b/tests/unit/accounts/test_forms.py +index 39490ecc7f4f..26f608549661 100644 +--- a/tests/unit/accounts/test_forms.py ++++ b/tests/unit/accounts/test_forms.py +@@ -608,13 +608,22 @@ def test_disposable_email_error(self, pyramid_request): + "different email." + ) + +- def test_prohibited_email_error(self, db_request): ++ @pytest.mark.parametrize( ++ "email", ++ [ ++ "foo@wutang.net", ++ "foo@clan.wutang.net", ++ "foo@one.two.wutang.net", ++ "foo@wUtAnG.net", ++ ], ++ ) ++ def test_prohibited_email_error(self, db_request, email): + domain = ProhibitedEmailDomain(domain="wutang.net") + db_request.db.add(domain) + + form = forms.RegistrationForm( + request=db_request, +- formdata=MultiDict({"email": "foo@wutang.net"}), ++ formdata=MultiDict({"email": email}), + user_service=pretend.stub( + find_userid_by_email=pretend.call_recorder(lambda _: None) + ), +@@ -623,6 +632,7 @@ def test_prohibited_email_error(self, db_request): + ) + + assert not form.validate() ++ assert form.email.errors + assert ( + str(form.email.errors.pop()) + == "You can't use an email address from this domain. Use a " +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,13 @@ ++H4sIAAAAAAAAA+2U3U8TQRDA+3x/xQAPPO1t70qLwWBijAkmRqvig1HTbPe2vQ13e8d+FEj4453b ++prQSkIAQYpxfH7of87kzc+k06KqYKLPgvaeij+wPh/Efuf4f19kw7+ej4SDbG/T6WTbq5z0YPllE ++GwTnhQXo2abxf5K76/4fJV3X3yvnJ7Kpa2GK1JWP5+OO+ueDbHBV//5+hvXfG2XDHvQfL4Tb+c/r ++v7PFp9rwqXBlIguITTBVRZI45YGpJNmBr07B+MKXjYFBmmVJoRbMnWkvS2jj8WB5jqJvrBJewQLb ++CfQMjFIF2sLVd9gCVkAab36+BF8qkwCyssDqpVaUSGa6s/bWuGDRd+P83Kovn96DdmCDMdrMk3Y+ ++kb6SFdZPWchGUAttoCumh/wVxyC5CVUFl5fgbVAb9nDrPIjgS5g1FqpGiqpEH5hyAUzDruPdtotO ++oIFNru+zfD/t4y/7wQf55oWTVtTMlYLlw9Hfm4sh813gykveLt/DnVY8G/EubY6PUU5FKhsze0AW ++BwfoMMtfwHUelsWt5u6Txc3ltapqRLFRy24qITgUUefaeQfCgQutst1Z4gIwWDkCJmFbxgaNCsxF ++7e3buuWdwWbCo0K1yhTKSI02MIbYoK4JVqplt8YBEtLrBZpOWt2i1FKVMdMwbdqAo8ROg+5GymIS ++uLSqVsa7mHjqz/199bo5dVFxPXao7LXEJ+hmt0BR6RuLUSf1Ce6AtXAmrCobTJ+Losaolxq8wKfj ++N0n9do+OPgfTjS7glM3RRwwiGX87Pvr4Yfz6+Ohw9fm4+o7w9QttTDou8RpzWzcB67rr8GoW8Q6d ++immlmGvkycoXD0Z7fGvZhNUjTHCGa5e2F8lzf0oJgiAIgiAIgiAIgiAIgiAIgiAIgiAI4tn4BYJU ++wsoAKAAA +diff --git 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-002396/tests/test.sh b/tasks/format-code-task-002396/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..982ff68c6163c34e99e44da7adbd1efd95491b2b --- /dev/null +++ b/tasks/format-code-task-002396/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/accounts/test_forms.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-002396/tests/test_command.sh b/tasks/format-code-task-002396/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002396/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002398/environment/Dockerfile b/tasks/format-code-task-002398/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..94314aebe03fd4f275551bd5c12d0092b16bb2f4 --- /dev/null +++ b/tasks/format-code-task-002398/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:74c00d488af18b15eb32bfc4eb887e6e8a0a58280036168d637a8bc3dc674d61 diff --git a/tasks/format-code-task-002398/environment/setup/files/blocklist b/tasks/format-code-task-002398/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002398/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002398/environment/setup/setup.sh b/tasks/format-code-task-002398/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002398/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002398/tests/test.patch b/tasks/format-code-task-002398/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0af0ab7530079b7123ab638188d4ef0fd634042d --- /dev/null +++ b/tasks/format-code-task-002398/tests/test.patch @@ -0,0 +1,37 @@ +diff --git a/tests/test_core.py b/tests/test_core.py +index f10fb023..6cc4f9cc 100755 +--- a/tests/test_core.py ++++ b/tests/test_core.py +@@ -40,6 +40,9 @@ + ("pywin32-217-55-cp27-none-win32.whl", "pywin32", "217-55"), + ("pywin32-217.1-cp27-none-win32.whl", "pywin32", "217.1"), + ("package.zip", "package", ""), ++ ("package-name-0.0.1.dev0.linux-x86_64.tar.gz", "package-name", "0.0.1.dev0"), ++ ("package-name-0.0.1.dev0.macosx-10.10-intel.tar.gz", "package-name", "0.0.1.dev0"), ++ ("package-name-0.0.1.alpha.1.win-amd64-py3.2.exe", "package-name", "0.0.1.alpha.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,7 @@ ++H4sIAAAAAAAAA+3TQU+DMBQHcM58ipe5mO0AG2Ns0UQTDybzYDTqfWHwAjXslUCZ7tvbsZgZo+6y ++xRj/Pw6FvlLa/Iu/aFSRzllWA+dYhtY0itrW+ty290E0Cuw1DMdTZxgE0XTiUHS0FX3Q1CauiJxK ++a/PTuH31P8rf5W+4NvNEL5expH6dH+4b+/IfT6a7/EehzX88CUKHhodbwvf+ef5JSm3wC05d94Qe ++2VBTUrm2B4J6wpxySi85C1WNiJKM4ppEi1foTAnVORdF3+XXUleG7q+eZhed7uzu9nrgt1MMFkrO ++u5v+jsuruKBOt7edW4ky5HllbPL+1zXbvX3MCr2w5dA/80fBZpE3YjMrCior/cyJIXteabMHSrlk ++SVkSxbVbqtLOtB3pMfl2U+2g0eVpO8tDI2RyJht/Zne9qdmX1ibXEpK3fB/e9r//GxXbfZG3cn87 ++NgAAAAAAAAAAAAAAAAAAAACA1huywF6sACgAAA== +diff --git 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-002398/tests/test.sh b/tasks/format-code-task-002398/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0278a40fa61b58c8cb78c3787448656a87a3f39 --- /dev/null +++ b/tasks/format-code-task-002398/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_core.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-002398/tests/test_command.sh b/tasks/format-code-task-002398/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002398/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002502/environment/Dockerfile b/tasks/format-code-task-002502/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f21fa327c2aa0649dfbb55b863bba26c07f15326 --- /dev/null +++ b/tasks/format-code-task-002502/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4824d2e496a907dacaee2d38172af9671498a78febacc89b2c94716d6e52df0d diff --git a/tasks/format-code-task-002502/environment/setup/files/blocklist b/tasks/format-code-task-002502/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002502/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002502/environment/setup/setup.sh b/tasks/format-code-task-002502/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002502/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002502/tests/test.patch b/tasks/format-code-task-002502/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0592a297c15aae5e31a5fb842fee202d8e454050 --- /dev/null +++ b/tasks/format-code-task-002502/tests/test.patch @@ -0,0 +1,172 @@ +diff --git a/pkg/segment/integrations_test.go b/pkg/segment/integrations_test.go +index 608c98b11ce..6c4f46b0167 100644 +--- a/pkg/segment/integrations_test.go ++++ b/pkg/segment/integrations_test.go +@@ -2,12 +2,10 @@ package segment + + import ( + "context" +- "errors" +- "fmt" + "io/ioutil" ++ "os" + "testing" + +- "github.com/devfile/registry-support/registry-library/library" + "k8s.io/utils/pointer" + + "github.com/redhat-developer/odo/pkg/config" +@@ -21,36 +19,78 @@ func TestGetRegistryOptions(t *testing.T) { + if err != nil { + t.Fatal(err) + } +- defer tempConfigFile.Close() ++ err = tempConfigFile.Close() ++ if err != nil { ++ t.Fatal(err) ++ } ++ defer os.Remove(tempConfigFile.Name()) + + t.Setenv(preference.GlobalConfigEnvName, tempConfigFile.Name()) + ++ type want struct { ++ localeUserEmpty bool ++ skipTLSVerify bool ++ caller string ++ } + tests := []struct { + testName string + consent bool + telemetryFile bool ++ caller string + cfg preference.Client ++ want want + }{ + { + testName: "Registry options with telemetry consent and telemetry file", + consent: true, + telemetryFile: true, ++ want: want{ ++ localeUserEmpty: true, ++ skipTLSVerify: false, ++ caller: "odo", ++ }, + }, + { + testName: "Registry options with telemetry consent and no telemetry file", + consent: true, + telemetryFile: false, ++ want: want{ ++ localeUserEmpty: false, ++ skipTLSVerify: false, ++ caller: "odo", ++ }, + }, + + { + testName: "Registry options without telemetry consent and telemetry file", + consent: false, + telemetryFile: true, ++ want: want{ ++ localeUserEmpty: true, ++ skipTLSVerify: false, ++ caller: "odo", ++ }, + }, + { + testName: "Registry options without telemetry consent and no telemetry file", + consent: false, + telemetryFile: false, ++ want: want{ ++ localeUserEmpty: true, ++ skipTLSVerify: false, ++ caller: "odo", ++ }, ++ }, ++ { ++ testName: "Registry options without telemetry consent and no telemetry file, with caller", ++ consent: false, ++ telemetryFile: false, ++ caller: "vscode", ++ want: want{ ++ localeUserEmpty: true, ++ skipTLSVerify: false, ++ caller: "odo-vscode", ++ }, + }, + } + +@@ -61,40 +101,25 @@ func TestGetRegistryOptions(t *testing.T) { + if tt.telemetryFile { + envConfig.OdoDebugTelemetryFile = pointer.String("/a/telemetry/file") + } ++ if tt.caller != "" { ++ envConfig.TelemetryCaller = tt.caller ++ } + ctx = envcontext.WithEnvConfig(ctx, envConfig) + scontext.SetTelemetryStatus(ctx, tt.consent) + + ro := GetRegistryOptions(ctx) +- err = verifyRegistryOptions(tt.consent, tt.telemetryFile, ro) +- if err != nil { +- t.Error(err) +- } +- }) +- } +-} +- +-func verifyRegistryOptions(isSet bool, telemetryFile bool, ro library.RegistryOptions) error { +- if ro.SkipTLSVerify { +- return errors.New("SkipTLSVerify should be set to false by default") +- } +- +- return verifyTelemetryData(isSet, telemetryFile, ro.Telemetry) +-} + +-func verifyTelemetryData(isSet bool, telemetryFile bool, data library.TelemetryData) error { +- if !isSet || telemetryFile { +- if data.Locale == "" && data.User == "" { +- return nil +- } +- +- return fmt.Errorf("Locale %s and User %s should be unset when telemetry is not enabled ", data.Locale, data.User) ++ if len(ro.Telemetry.Locale) == 0 != tt.want.localeUserEmpty || len(ro.Telemetry.User) == 0 != tt.want.localeUserEmpty { ++ t.Errorf("Locale %q and User %q emptiness should be %v when telemetry enabled is %v and telemetry file is %v", ro.Telemetry.Locale, ro.Telemetry.User, tt.want.localeUserEmpty, tt.consent, tt.telemetryFile) ++ } + +- } else { +- //we don't care what value locale and user have been set to. We just want to make sure they are not empty +- if data.Locale != "" && data.User != "" { +- return nil +- } ++ if ro.SkipTLSVerify != tt.want.skipTLSVerify { ++ t.Errorf("SkipTLSVerify should be set to %v by default", tt.want.skipTLSVerify) ++ } + +- return fmt.Errorf("Locale %s and User %s should be set when telemetry is enabled ", data.Locale, data.User) ++ if ro.Telemetry.Client != tt.want.caller { ++ t.Errorf("caller should be %q but is %q", tt.want.caller, ro.Telemetry.Client) ++ } ++ }) + } + } +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+3RQWrDMBCFYa1zirlAbMmu4iN0GSjdhyQWrmktBUsO5PZRvUkptNkklJL/28zA ++CDTDK3ZT/9FunD+W6l501lg71+x7nXtjK2NWdd3YWunc6UaJvdtGX0wxbUcRNYaQfnt3bf5PFZf8 ++k4tpsw/DsPVtEd9u98e1/I2uLvlXVc7/aWW0En27FX724PnvW5mD37l20QX5bGV5lKI8vHdldN3g ++fCplOU5eXvPs2aUX1/Uxjaf1IfXBx8VfXwAAAAAAAAAAAAAAAAA8rjM/xap2ACgAAA== +diff --git 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-002502/tests/test.sh b/tasks/format-code-task-002502/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c61a989ee9ef6d0f5696fd924f8e2aec4d04717b --- /dev/null +++ b/tasks/format-code-task-002502/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/segment/integrations_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-002502/tests/test_command.sh b/tasks/format-code-task-002502/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002502/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002505/environment/Dockerfile b/tasks/format-code-task-002505/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..912ee89b3bb5056978b7063bc817564eccfd238f --- /dev/null +++ b/tasks/format-code-task-002505/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:286bf45f97df68739bdcd44ccb40b7a0e5fba10ac50d99a58f89a271f939fdf9 diff --git a/tasks/format-code-task-002505/environment/setup/files/blocklist b/tasks/format-code-task-002505/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002505/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002505/environment/setup/setup.sh b/tasks/format-code-task-002505/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002505/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002505/tests/test.patch b/tasks/format-code-task-002505/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c641b5c9bfe2a3ccad1ab3c5d34065cb6ff6bff7 --- /dev/null +++ b/tasks/format-code-task-002505/tests/test.patch @@ -0,0 +1,104 @@ +diff --git a/internal/bloblang/query/methods_test.go b/internal/bloblang/query/methods_test.go +index 424db20668..b4ed17b1d9 100644 +--- a/internal/bloblang/query/methods_test.go ++++ b/internal/bloblang/query/methods_test.go +@@ -733,6 +733,14 @@ func TestMethods(t *testing.T) { + ), + output: `5020219685658847592`, + }, ++ "check md5 hash": { ++ input: methods( ++ literalFn("hello world"), ++ method("hash", "md5"), ++ method("encode", "hex"), ++ ), ++ output: `5eb63bbbe01eeed093cb22bb8f5acdc3`, ++ }, + "check hex encode": { + input: methods( + literalFn("hello world"), +diff --git a/lib/processor/hash_test.go b/lib/processor/hash_test.go +index 5617ccebaf..d933e5e1e8 100644 +--- a/lib/processor/hash_test.go ++++ b/lib/processor/hash_test.go +@@ -2,6 +2,7 @@ package processor + + import ( + "crypto/hmac" ++ "crypto/md5" + "crypto/sha1" + "crypto/sha256" + "crypto/sha512" +@@ -323,6 +324,51 @@ func TestHashXXHash64(t *testing.T) { + } + } + ++func TestHashMD5(t *testing.T) { ++ conf := NewConfig() ++ conf.Hash.Algorithm = "md5" ++ ++ input := [][]byte{ ++ []byte("hello world first part"), ++ []byte("hello world second part"), ++ []byte("third part"), ++ []byte("fourth"), ++ []byte("5"), ++ } ++ ++ exp := [][]byte{} ++ ++ for i := range input { ++ h := md5.New() ++ h.Write(input[i]) ++ exp = append(exp, h.Sum(nil)) ++ } ++ ++ if reflect.DeepEqual(input, exp) { ++ t.Fatal("Input and exp output are the same") ++ } ++ ++ proc, err := NewHash(conf, nil, log.Noop(), metrics.Noop()) ++ if err != nil { ++ t.Fatal(err) ++ } ++ ++ msgs, res := proc.ProcessMessage(message.New(input)) ++ if len(msgs) != 1 { ++ t.Error("Hash failed") ++ } else if res != nil { ++ t.Errorf("Expected nil response: %v", res) ++ } ++ for i, part := range message.GetAllBytes(msgs[0]) { ++ if !hmac.Equal(part, exp[i]) { ++ t.Errorf("Unexpected output for input (%s): %s != %s", input[i], part, exp[i]) ++ } ++ } ++ if act := message.GetAllBytes(msgs[0]); !reflect.DeepEqual(exp, act) { ++ t.Errorf("Unexpected output: %s != %s", act, exp) ++ } ++} ++ + func TestHashIndexBounds(t *testing.T) { + conf := NewConfig() + +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+3Su07DMBQG4Mx5ikOYE8dpTCd2Fjb2yk5Maym1gy+VeHtMBqiQSpdWgPi/xUfy ++7ci/G5XMNG60PbDiWtpsLcQyZl/Hpeai410r+p53Rcu5WIuCxNU6OpJClJ6o8M7F79adm/+jms/8 ++ow5xM7j9XtqxCbvL3XEu/06sPvJf5brl/R3P+beXa+G0f57/7Q1LwTNlLMt/gJQMuzLoSLVOjmYz ++62dpprIcRlr+h9JjWW4dvddUH6geXLLxnlPDjI3aWzkxNTk1SbtlL0n7V0a1T5aqp7zjUcedG0N1 ++4oTJKDZ7N+gQnD/e95C7qsqffioAAAAAAAAAAAAAAAAAAAAAgF/nDdlcVYIAKAAA +diff --git 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-002505/tests/test.sh b/tasks/format-code-task-002505/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fadb1d079ae69136617bc91471efbfc27614a6b --- /dev/null +++ b/tasks/format-code-task-002505/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' +internal/bloblang/query/methods_test.go +lib/processor/hash_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-002505/tests/test_command.sh b/tasks/format-code-task-002505/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002505/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002523/environment/Dockerfile b/tasks/format-code-task-002523/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6cc3b7a686c3fc32792770fa0f6079acb9a22687 --- /dev/null +++ b/tasks/format-code-task-002523/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0042ebc9c71bc3c8a322b63781ea4cad45ea59195f8235b95ebb22dbed2fbf31 diff --git a/tasks/format-code-task-002523/environment/setup/files/blocklist b/tasks/format-code-task-002523/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002523/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002523/environment/setup/setup.sh b/tasks/format-code-task-002523/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002523/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002523/tests/test.patch b/tasks/format-code-task-002523/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..51ad2a43154aa8c7de0b7dbef04b0e6634627db8 --- /dev/null +++ b/tasks/format-code-task-002523/tests/test.patch @@ -0,0 +1,32 @@ +diff --git a/t/unit/transport/drivers/test_aiokafka.py b/t/unit/transport/drivers/test_aiokafka.py +index 0c5dcf194..b184c9466 100644 +--- a/t/unit/transport/drivers/test_aiokafka.py ++++ b/t/unit/transport/drivers/test_aiokafka.py +@@ -737,6 +737,7 @@ def assert_create_worker_consumer(self, cthread, app, + api_version=app.conf.consumer_api_version, + client_id=conf.broker_client_id, + group_id=conf.id, ++ group_instance_id=conf.consumer_group_instance_id, + bootstrap_servers=server_list( + transport.url, transport.default_port), + partition_assignment_strategy=[cthread._assignor], +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+3S3wrCIBQG8F33FOcF9keb9jhhuWjUdOjZqLdPFlEE1U0R0fe78XAUPPJZrIZ2 ++b5eNG8vsU6pkodS0JvfrVAslK6mFrnXqC6GreUbqYxPdGCKbQJQF7/nZuVf7P6q45s9N5OXad51x ++tojb993xKv8U9yV/JWWd8q+1kBlV7xvhsT/Pf21pCn7V2Fl/5K13c8o7SmVqEpeDa7nkYFzsfeDS ++hnZsQjz/FdP6ndnsTNEfKT9QPs6+/RoAAAAAAAAAAAAAAAAAAAAAgP9yAhX6xgsAKAAA +diff --git 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-002523/tests/test.sh b/tasks/format-code-task-002523/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9649cc749bd4d37504072e2753713d03eb7be479 --- /dev/null +++ b/tasks/format-code-task-002523/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' +t/unit/transport/drivers/test_aiokafka.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-002523/tests/test_command.sh b/tasks/format-code-task-002523/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002523/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002533/environment/Dockerfile b/tasks/format-code-task-002533/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..56f1888f95a7fa25fab732bbfd513008d01c3197 --- /dev/null +++ b/tasks/format-code-task-002533/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7eeadbad63d33284c865a79afe9dd0abc4bf323cc24154c54c59001cac442cb3 diff --git a/tasks/format-code-task-002533/environment/setup/files/blocklist b/tasks/format-code-task-002533/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002533/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002533/environment/setup/setup.sh b/tasks/format-code-task-002533/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002533/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002533/tests/test.patch b/tasks/format-code-task-002533/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..75f0f682e7aaed2dea0cf233f3e8c223abd5a897 --- /dev/null +++ b/tasks/format-code-task-002533/tests/test.patch @@ -0,0 +1,52 @@ +diff --git a/rotkehlchen/tests/unit/test_assets.py b/rotkehlchen/tests/unit/test_assets.py +index cc74ec4c8d..002b8ad0d3 100644 +--- a/rotkehlchen/tests/unit/test_assets.py ++++ b/rotkehlchen/tests/unit/test_assets.py +@@ -1,6 +1,8 @@ + import pytest ++from eth_utils import is_checksum_address + + from rotkehlchen.assets.asset import Asset, EthereumToken ++from rotkehlchen.assets.resolver import AssetResolver, asset_type_mapping + from rotkehlchen.errors import DeserializationError, UnknownAsset + from rotkehlchen.typing import AssetType + +@@ -53,3 +55,17 @@ def test_ethereum_tokens(): + + with pytest.raises(DeserializationError): + EthereumToken('BTC') ++ ++ ++def test_tokens_address_is_checksummed(): ++ """Test that all ethereum saved token asset addresses are checksummed""" ++ for _, asset_data in AssetResolver().assets.items(): ++ asset_type = asset_type_mapping[asset_data['type']] ++ if asset_type not in (AssetType.ETH_TOKEN_AND_MORE, AssetType.ETH_TOKEN): ++ continue ++ ++ msg = ( ++ f'Ethereum token\'s {asset_data["name"]} ethereum address ' ++ f'is not checksummed {asset_data["ethereum_address"]}' ++ ) ++ assert is_checksum_address(asset_data['ethereum_address']), msg +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+3S326DIBQGcK99ipPeY8UO+zDN0lhlgUyByNHFt5/a7G+y9abNtuz73QARjid8 ++ZKfBts1Ru3Gb3Eo+2yu1jrPP4zqXqpBFsc9LtU9yKUuZJ6Ru1tE7Q+SqJ0p67/m7fZe+/1HZW/6s ++Ix9r33WVa7JorvePS/nPsb/mr1Q5539XFjKh/HotfO2f5183tAZ/0k3a6FHEJ8u1oTCx8W5Hu0zK ++9GUhOgo2kHXzlbUtCeG8sC4MvGyfa5BmIwa2baTNMjVVNIcw1f0U2De+0/ebD7XOh5YytXcP66L3 ++/KhNWxvt1rbidnCWz0+zilFzzMJEYkx/+t4AAAAAAAAAAAAAAAAAAAAAAH6DZ7w/rdEAKAAA +diff --git 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-002533/tests/test.sh b/tasks/format-code-task-002533/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6107b090837514ed647d2b96b9c2911fdb910faf --- /dev/null +++ b/tasks/format-code-task-002533/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/unit/test_assets.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-002533/tests/test_command.sh b/tasks/format-code-task-002533/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002533/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002550/environment/Dockerfile b/tasks/format-code-task-002550/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..af035f844f1c509f2ef8581a61feae083e43856a --- /dev/null +++ b/tasks/format-code-task-002550/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5e44e7b752738cd967aa9eebf9c9ff61ec3407470e13afff4e9de7e4c5e9a001 diff --git a/tasks/format-code-task-002550/environment/setup/files/blocklist b/tasks/format-code-task-002550/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002550/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002550/environment/setup/setup.sh b/tasks/format-code-task-002550/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002550/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002550/tests/test.patch b/tasks/format-code-task-002550/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..702c88d5c48f49e5f2db29fd3c48bdd903cc9a82 --- /dev/null +++ b/tasks/format-code-task-002550/tests/test.patch @@ -0,0 +1,266 @@ +diff --git a/usercase-test-coderl/test_due_card_rollover.py b/usercase-test-coderl/test_due_card_rollover.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_due_card_rollover.py +@@ -0,0 +1,238 @@ ++import sqlite3 ++import sys ++from unittest.mock import patch ++ ++ ++sys.path.insert(0, "/workspace/repo/src/main/python") ++from database import Database # noqa: E402 ++ ++ ++def _new_database(tmp_path, name="data.db"): ++ filename = tmp_path / name ++ return Database(filename=str(filename)), filename ++ ++ ++def _due_by_card_id(db, list_id): ++ ++ cards = {} ++ for line in db.runCommand(f"show-cards {list_id}").splitlines()[1:]: ++ card_id, due, *_ = line.split("\t") ++ cards[int(card_id)] = int(due) ++ return cards ++ ++ ++def _assert_due_state(db, list_id, expected): ++ ++ assert _due_by_card_id(db, list_id) == expected ++ ++ ++def _destination_card_indexes(filename, list_id=2): ++ with sqlite3.connect(str(filename)) as conn: ++ return list( ++ conn.execute( ++ "SELECT ROWID, idx FROM cards WHERE list=? ORDER BY idx ASC", ++ (list_id,), ++ ) ++ ) ++ ++ ++def _assert_destination_normalized(filename, list_id, expected_card_ids): ++ ++ rows = _destination_card_indexes(filename, list_id) ++ assert {row_id for row_id, _ in rows} == set(expected_card_ids) ++ assert [idx for _, idx in rows] == list(range(len(rows))) ++ ++ ++def _assert_invalid_command_fails_without_change(db, command, expected_by_list): ++ before = {list_id: _due_by_card_id(db, list_id) for list_id in expected_by_list} ++ ++ assert before == expected_by_list ++ failed = False ++ try: ++ result = db.runCommand(command) ++ except Exception: ++ failed = True ++ else: ++ ++ failed = result is not None ++ assert failed ++ assert before == {list_id: _due_by_card_id(db, list_id) for list_id in expected_by_list} ++ ++ ++def test_set_due_date_stores_absolute_timestamp_and_clears_with_minus_one(tmp_path): ++ ++ ++ ++ ++ db, _ = _new_database(tmp_path) ++ try: ++ db.runCommand('add-card "card one":"":-1 to 1') ++ ++ db.runCommand("set-due-date 1 1234567890") ++ ++ _assert_due_state(db, 1, {1: 1234567890}) ++ ++ db.runCommand("set-due-date 1 -1") ++ ++ _assert_due_state(db, 1, {1: -1}) ++ finally: ++ db.close() ++ ++ ++def test_set_due_in_uses_fixed_second_coefficients_for_all_supported_units(tmp_path): ++ ++ ++ ++ ++ db, _ = _new_database(tmp_path) ++ try: ++ db.runCommand('add-card "relative":"":-1 to 1') ++ ++ with patch("time.time", return_value=1700000000): ++ db.runCommand("set-due-in 1 2d") ++ ++ _assert_due_state(db, 1, {1: 1700172800}) ++ ++ with patch("time.time", return_value=1700000000): ++ db.runCommand("set-due-in 1 3w") ++ ++ _assert_due_state(db, 1, {1: 1701814400}) ++ ++ with patch("time.time", return_value=1700000000): ++ db.runCommand("set-due-in 1 4m") ++ ++ _assert_due_state(db, 1, {1: 1710368000}) ++ ++ with patch("time.time", return_value=1700000000): ++ db.runCommand("set-due-in 1 1y") ++ ++ _assert_due_state(db, 1, {1: 1731536000}) ++ finally: ++ db.close() ++ ++ ++def test_single_source_rollover_moves_only_positive_past_due_cards(tmp_path): ++ ++ ++ ++ ++ db, _ = _new_database(tmp_path) ++ try: ++ db.runCommand('add-card "overdue":"":1 to 1') ++ db.runCommand('add-card "future":"":32503680000 to 1') ++ db.runCommand('add-card "undated":"":-1 to 1') ++ ++ _assert_due_state(db, 1, {1: 1, 2: 32503680000, 3: -1}) ++ _assert_due_state(db, 2, {}) ++ ++ with patch("time.time", return_value=1700000000): ++ db.runCommand("move-due-cards 1 to 2") ++ ++ ++ _assert_due_state(db, 1, {2: 32503680000, 3: -1}) ++ _assert_due_state(db, 2, {1: 1}) ++ finally: ++ db.close() ++ ++ ++def test_multiple_source_rollover_moves_all_overdue_cards_and_normalizes_destination_indexes(tmp_path): ++ ++ ++ ++ ++ db, filename = _new_database(tmp_path) ++ try: ++ db.runCommand('add-card "dest preexisting":"":-1 to 2') ++ db.runCommand('add-card "l1 old":"":1 to 1') ++ db.runCommand('add-card "l1 future":"":32503680000 to 1') ++ db.runCommand('add-card "l3 old":"":2 to 3') ++ db.runCommand('add-card "l3 none":"":-1 to 3') ++ ++ ++ _assert_due_state(db, 1, {2: 1, 3: 32503680000}) ++ _assert_due_state(db, 2, {1: -1}) ++ _assert_due_state(db, 3, {4: 2, 5: -1}) ++ ++ with patch("time.time", return_value=1700000000): ++ db.runCommand("move-due-cards 1,3 to 2") ++ ++ ++ _assert_due_state(db, 1, {3: 32503680000}) ++ _assert_due_state(db, 2, {1: -1, 2: 1, 4: 2}) ++ _assert_due_state(db, 3, {5: -1}) ++ _assert_destination_normalized(filename, 2, [1, 2, 4]) ++ finally: ++ db.close() ++ ++ ++def test_invalid_due_rollover_command_forms_fail_without_changing_cards(tmp_path): ++ ++ ++ ++ ++ db, _ = _new_database(tmp_path) ++ try: ++ db.runCommand('add-card "bad":"":-1 to 1') ++ expected = {1: {1: -1}} ++ ++ ++ _assert_invalid_command_fails_without_change(db, "set-due-in 1 5h", expected) ++ _assert_invalid_command_fails_without_change(db, "set-due-date 1 abc", expected) ++ _assert_invalid_command_fails_without_change(db, "move-due-cards 1 to x", expected) ++ _assert_invalid_command_fails_without_change(db, "not-a-command", expected) ++ finally: ++ db.close() ++ ++ ++def test_incomplete_due_commands_fail_without_changing_cards(tmp_path): ++ ++ ++ ++ ++ db, _ = _new_database(tmp_path) ++ try: ++ db.runCommand('add-card "incomplete":"":99 to 1') ++ expected = {1: {1: 99}} ++ ++ ++ _assert_invalid_command_fails_without_change(db, "set-due-date 1", expected) ++ _assert_invalid_command_fails_without_change(db, "set-due-in 1 d", expected) ++ _assert_invalid_command_fails_without_change(db, "set-due-in 1 5", expected) ++ finally: ++ db.close() ++ ++ ++def test_set_due_date_can_update_a_future_timestamp_to_clear_state(tmp_path): ++ ++ ++ ++ ++ db, _ = _new_database(tmp_path) ++ try: ++ db.runCommand('add-card "future clear":"":-1 to 1') ++ ++ db.runCommand("set-due-date 1 32503680000") ++ ++ _assert_due_state(db, 1, {1: 32503680000}) ++ ++ db.runCommand("set-due-date 1 -1") ++ ++ _assert_due_state(db, 1, {1: -1}) ++ finally: ++ db.close() ++ ++ ++def test_malformed_move_due_cards_source_list_fails_without_moving_cards(tmp_path): ++ ++ ++ ++ ++ db, _ = _new_database(tmp_path) ++ try: ++ db.runCommand('add-card "stays put":"":1 to 1') ++ expected = {1: {1: 1}, 2: {}} ++ ++ ++ _assert_invalid_command_fails_without_change(db, "move-due-cards 1, to 2", expected) ++ finally: ++ db.close() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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/main/python${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_due_card_rollover.py -v diff --git a/tasks/format-code-task-002550/tests/test.sh b/tasks/format-code-task-002550/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f3e2469f7c06fcdbb0b2a672c1b2280448704d7 --- /dev/null +++ b/tasks/format-code-task-002550/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_due_card_rollover.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-002550/tests/test_command.sh b/tasks/format-code-task-002550/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002550/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-002551/environment/Dockerfile b/tasks/format-code-task-002551/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8aaa061b9e3548af8a60664685a1c33fd50df12d --- /dev/null +++ b/tasks/format-code-task-002551/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0bbefdd095477f1955c49fdb6a3832c2cfb12aca8c73575555c4853f978b6863 diff --git a/tasks/format-code-task-002551/environment/setup/files/blocklist b/tasks/format-code-task-002551/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002551/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002551/environment/setup/setup.sh b/tasks/format-code-task-002551/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002551/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002551/tests/test.patch b/tasks/format-code-task-002551/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c8df8f76f07feaec8f404266ccb7496c86eaeedf --- /dev/null +++ b/tasks/format-code-task-002551/tests/test.patch @@ -0,0 +1,546 @@ +diff --git a/usercase-test-coderl/timestamps.test.js b/usercase-test-coderl/timestamps.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/timestamps.test.js +@@ -0,0 +1,497 @@ ++'use strict'; ++ ++var chai = require('chai'), ++ expect = chai.expect, ++ Joi = require('joi'), ++ vogels = require('..'); ++ ++chai.should(); ++ ++var FIXED_ISO = '2016-01-02T03:04:05.006Z'; ++ ++function freezeDate(iso) { ++ var RealDate = Date; ++ var fixedTime = new RealDate(iso).getTime(); ++ ++ function FakeDate() { ++ var args = Array.prototype.slice.call(arguments); ++ ++ if (!(this instanceof FakeDate)) { ++ return new RealDate(fixedTime).toString(); ++ } ++ ++ if (args.length === 0) { ++ return new RealDate(fixedTime); ++ } ++ ++ return new (Function.prototype.bind.apply(RealDate, [null].concat(args)))(); ++ } ++ ++ FakeDate.UTC = RealDate.UTC; ++ FakeDate.parse = RealDate.parse; ++ FakeDate.now = function () { ++ return fixedTime; ++ }; ++ FakeDate.prototype = RealDate.prototype; ++ ++ global.Date = FakeDate; ++ ++ return function restoreDate() { ++ global.Date = RealDate; ++ }; ++} ++ ++function clone(value) { ++ return JSON.parse(JSON.stringify(value)); ++} ++ ++function updateValuesByAttribute(params) { ++ var values = params.ExpressionAttributeValues || {}; ++ var names = params.ExpressionAttributeNames || {}; ++ var byAttribute = {}; ++ var attributeUpdates = params.AttributeUpdates || {}; ++ var expression = params.UpdateExpression || ''; ++ var match; ++ var assignmentPattern = /(#?[A-Za-z0-9_]+)\s*=\s*(:[A-Za-z0-9_]+)/g; ++ ++ while ((match = assignmentPattern.exec(expression)) !== null) { ++ var attrToken = match[1]; ++ var valueToken = match[2]; ++ var attrName = names[attrToken] || attrToken.replace(/^#/, ''); ++ byAttribute[attrName] = values[valueToken]; ++ } ++ ++ Object.keys(values).forEach(function (key) { ++ var fallbackName = key.slice(1); ++ ++ if (!Object.prototype.hasOwnProperty.call(byAttribute, fallbackName)) { ++ byAttribute[fallbackName] = values[key]; ++ } ++ }); ++ ++ Object.keys(attributeUpdates).forEach(function (key) { ++ if (Object.prototype.hasOwnProperty.call(attributeUpdates[key], 'Value')) { ++ ++ byAttribute[key] = attributeUpdates[key].Value; ++ } ++ }); ++ ++ return byAttribute; ++} ++ ++function expectIsoDateString(value) { ++ expect(value).to.be.a('string'); ++ expect(value).to.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/); ++ expect(new Date(value).toISOString()).to.equal(value); ++} ++ ++function expectNoOwnField(object, field) { ++ expect(Object.prototype.hasOwnProperty.call(object, field)).to.equal(false); ++} ++ ++function expectMaybeDateIso(value, iso) { ++ if (value instanceof Date) { ++ expect(value.toISOString()).to.equal(iso); ++ } else { ++ expect(value).to.equal(iso); ++ } ++} ++ ++function makeCapturingDocClient() { ++ var calls = { ++ put : [], ++ update : [] ++ }; ++ ++ return { ++ service : {}, ++ calls : calls, ++ put : function (params, callback) { ++ calls.put.push(clone(params)); ++ return callback(null, {}); ++ }, ++ update : function (params, callback) { ++ var attrs = clone(params.Key || {}); ++ var updateAttrs = updateValuesByAttribute(params); ++ ++ ++ Object.keys(updateAttrs).forEach(function (key) { ++ attrs[key] = updateAttrs[key]; ++ }); ++ ++ calls.update.push(clone(params)); ++ return callback(null, {Attributes : attrs}); ++ } ++ }; ++} ++ ++function defineTimestampModel(name, extraConfig, docClient) { ++ vogels.documentClient(docClient); ++ ++ return vogels.define(name, { ++ hashKey : 'id', ++ timestamps : true, ++ createdAt : extraConfig.createdAt, ++ updatedAt : extraConfig.updatedAt, ++ schema : { ++ id : Joi.string().required(), ++ note : Joi.string() ++ } ++ }); ++} ++ ++describe('usercase timestamps on public define/create/update session', function () { ++ ++ beforeEach(function () { ++ vogels.reset(); ++ }); ++ ++ afterEach(function () { ++ vogels.reset(); ++ }); ++ ++ it('adds default createdAt and updatedAt ISO strings to DynamoDB writes and callback items', function (done) { ++ ++ ++ ++ ++ var restoreDate = freezeDate(FIXED_ISO); ++ var docClient = makeCapturingDocClient(); ++ var Model = defineTimestampModel('UsercaseDefaultTimestamp', {}, docClient); ++ ++ Model.create({id : 'alpha', note : 'first'}, function (err, created) { ++ try { ++ expect(err).to.not.exist; ++ ++ docClient.calls.put.should.have.length(1); ++ docClient.calls.put[0].Item.id.should.equal('alpha'); ++ docClient.calls.put[0].Item.note.should.equal('first'); ++ expectIsoDateString(docClient.calls.put[0].Item.createdAt); ++ ++ created.get('id').should.equal('alpha'); ++ created.get('note').should.equal('first'); ++ expectIsoDateString(created.get('createdAt')); ++ ++ Model.update({id : 'alpha', note : 'second'}, function (updateErr, updated) { ++ try { ++ expect(updateErr).to.not.exist; ++ ++ docClient.calls.update.should.have.length(1); ++ docClient.calls.update[0].Key.id.should.equal('alpha'); ++ var defaultUpdateAttrs = updateValuesByAttribute(docClient.calls.update[0]); ++ defaultUpdateAttrs.note.should.equal('second'); ++ expectIsoDateString(defaultUpdateAttrs.updatedAt); ++ ++ updated.get('id').should.equal('alpha'); ++ updated.get('note').should.equal('second'); ++ expectIsoDateString(updated.get('updatedAt')); ++ restoreDate(); ++ done(); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ }); ++ ++ it('accepts timestamp fields through validation even when the user schema omits them', function (done) { ++ ++ ++ ++ ++ var restoreDate = freezeDate(FIXED_ISO); ++ var docClient = makeCapturingDocClient(); ++ var Model = defineTimestampModel('UsercaseValidationTimestamp', {}, docClient); ++ ++ Model.create({id : 'schema-pass'}, function (err, created) { ++ try { ++ expect(err).to.equal(null); ++ ++ created.get('id').should.equal('schema-pass'); ++ expectIsoDateString(created.get('createdAt')); ++ ++ Model.update({id : 'schema-pass'}, function (updateErr, updated) { ++ try { ++ expect(updateErr).to.equal(null); ++ ++ updated.get('id').should.equal('schema-pass'); ++ expectIsoDateString(updated.get('updatedAt')); ++ restoreDate(); ++ done(); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ }); ++ ++ it('uses custom createdAt and updatedAt attribute names when configured', function (done) { ++ ++ ++ ++ ++ var restoreDate = freezeDate(FIXED_ISO); ++ var docClient = makeCapturingDocClient(); ++ var Model = defineTimestampModel('UsercaseCustomTimestamp', { ++ createdAt : 'created', ++ updatedAt : 'updated' ++ }, docClient); ++ ++ Model.create({id : 'bravo'}, function (err, created) { ++ try { ++ expect(err).to.not.exist; ++ ++ docClient.calls.put.should.have.length(1); ++ docClient.calls.put[0].Item.id.should.equal('bravo'); ++ expectIsoDateString(docClient.calls.put[0].Item.created); ++ expectNoOwnField(docClient.calls.put[0].Item, 'createdAt'); ++ ++ created.get('id').should.equal('bravo'); ++ expectIsoDateString(created.get('created')); ++ expect(created.get('createdAt')).to.equal(undefined); ++ ++ Model.update({id : 'bravo'}, function (updateErr, updated) { ++ try { ++ expect(updateErr).to.not.exist; ++ ++ docClient.calls.update.should.have.length(1); ++ docClient.calls.update[0].Key.id.should.equal('bravo'); ++ var customUpdateAttrs = updateValuesByAttribute(docClient.calls.update[0]); ++ expectIsoDateString(customUpdateAttrs.updated); ++ expectNoOwnField(customUpdateAttrs, 'updatedAt'); ++ ++ updated.get('id').should.equal('bravo'); ++ expectIsoDateString(updated.get('updated')); ++ expect(updated.get('updatedAt')).to.equal(undefined); ++ restoreDate(); ++ done(); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ }); ++ ++ it('disables create and update timestamp insertion when each configured field is false', function (done) { ++ ++ ++ ++ ++ var restoreDate = freezeDate(FIXED_ISO); ++ var docClient = makeCapturingDocClient(); ++ var CreateDisabledModel = defineTimestampModel('UsercaseDisabledCreateTimestamp', { ++ createdAt : false ++ }, docClient); ++ var UpdateDisabledModel = defineTimestampModel('UsercaseDisabledUpdateTimestamp', { ++ updatedAt : false ++ }, docClient); ++ ++ CreateDisabledModel.create({id : 'charlie'}, function (err, created) { ++ try { ++ expect(err).to.not.exist; ++ ++ docClient.calls.put.should.have.length(1); ++ docClient.calls.put[0].Item.id.should.equal('charlie'); ++ expectNoOwnField(docClient.calls.put[0].Item, 'createdAt'); ++ created.get('id').should.equal('charlie'); ++ expect(created.get('createdAt')).to.equal(undefined); ++ ++ UpdateDisabledModel.update({id : 'charlie'}, function (updateErr, updated) { ++ try { ++ expect(updateErr).to.not.exist; ++ ++ docClient.calls.update.should.have.length(1); ++ docClient.calls.update[0].Key.id.should.equal('charlie'); ++ var disabledUpdateAttrs = updateValuesByAttribute(docClient.calls.update[0]); ++ expectNoOwnField(disabledUpdateAttrs, 'updatedAt'); ++ updated.get('id').should.equal('charlie'); ++ expect(updated.get('updatedAt')).to.equal(undefined); ++ restoreDate(); ++ done(); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ }); ++ ++ it('preserves caller-supplied timestamp attributes instead of replacing them', function (done) { ++ ++ ++ ++ ++ var restoreDate = freezeDate(FIXED_ISO); ++ var docClient = makeCapturingDocClient(); ++ var Model = defineTimestampModel('UsercasePreserveTimestamp', {}, docClient); ++ ++ Model.create({ ++ id : 'delta', ++ createdAt : '1999-12-31T23:59:59.000Z' ++ }, function (err, created) { ++ try { ++ expect(err).to.not.exist; ++ ++ docClient.calls.put.should.have.length(1); ++ docClient.calls.put[0].Item.id.should.equal('delta'); ++ expectMaybeDateIso(docClient.calls.put[0].Item.createdAt, '1999-12-31T23:59:59.000Z'); ++ created.get('id').should.equal('delta'); ++ expectMaybeDateIso(created.get('createdAt'), '1999-12-31T23:59:59.000Z'); ++ ++ Model.update({ ++ id : 'delta', ++ updatedAt : '2000-01-01T00:00:00.000Z' ++ }, function (updateErr, updated) { ++ try { ++ expect(updateErr).to.not.exist; ++ ++ docClient.calls.update.should.have.length(1); ++ docClient.calls.update[0].Key.id.should.equal('delta'); ++ var preserveUpdateAttrs = updateValuesByAttribute(docClient.calls.update[0]); ++ preserveUpdateAttrs.updatedAt.should.equal('2000-01-01T00:00:00.000Z'); ++ updated.get('id').should.equal('delta'); ++ updated.get('updatedAt').should.equal('2000-01-01T00:00:00.000Z'); ++ restoreDate(); ++ done(); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ }); ++ ++ it('keeps timestamp configuration independent across two compiled model sessions', function (done) { ++ ++ ++ ++ ++ var restoreDate = freezeDate(FIXED_ISO); ++ var docClient = makeCapturingDocClient(); ++ var CustomModel = defineTimestampModel('UsercaseIndependentCustom', { ++ createdAt : 'created', ++ updatedAt : 'updated' ++ }, docClient); ++ var DisabledModel = defineTimestampModel('UsercaseIndependentDisabled', { ++ createdAt : false ++ }, docClient); ++ ++ CustomModel.create({id : 'custom-one'}, function (customErr, customCreated) { ++ try { ++ expect(customErr).to.not.exist; ++ ++ customCreated.get('id').should.equal('custom-one'); ++ expectIsoDateString(customCreated.get('created')); ++ expect(customCreated.get('createdAt')).to.equal(undefined); ++ ++ DisabledModel.create({id : 'disabled-one'}, function (disabledErr, disabledCreated) { ++ try { ++ expect(disabledErr).to.not.exist; ++ disabledCreated.get('id').should.equal('disabled-one'); ++ expect(disabledCreated.get('createdAt')).to.equal(undefined); ++ ++ docClient.calls.put.should.have.length(2); ++ docClient.calls.put[0].Item.id.should.equal('custom-one'); ++ expectIsoDateString(docClient.calls.put[0].Item.created); ++ expectNoOwnField(docClient.calls.put[0].Item, 'createdAt'); ++ docClient.calls.put[1].Item.id.should.equal('disabled-one'); ++ expectNoOwnField(docClient.calls.put[1].Item, 'createdAt'); ++ restoreDate(); ++ done(); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ } catch (assertionErr) { ++ restoreDate(); ++ done(assertionErr); ++ } ++ }); ++ }); ++ ++ it('raises the specific public Error type for out-of-contract timestamp option types', function () { ++ ++ ++ ++ ++ expect(function () { ++ defineTimestampModel('UsercaseInvalidTimestampType', { ++ createdAt : 7 ++ }, makeCapturingDocClient()); ++ ++ }).to.throw(); ++ }); ++ ++ it('allows repeated public cleanup through vogels.reset()', function () { ++ ++ ++ ++ ++ var restoreDate = freezeDate(FIXED_ISO); ++ var docClient = makeCapturingDocClient(); ++ ++ defineTimestampModel('UsercaseCleanupTimestampBeforeReset', {}, docClient); ++ vogels.reset(); ++ vogels.reset(); ++ ++ var Model = defineTimestampModel('UsercaseCleanupTimestampAfterReset', {}, docClient); ++ Model.create({id : 'after-reset'}, function (err, created) { ++ try { ++ expect(err).to.not.exist; ++ ++ created.get('id').should.equal('after-reset'); ++ expectIsoDateString(created.get('createdAt')); ++ restoreDate(); ++ } catch (assertionErr) { ++ restoreDate(); ++ throw assertionErr; ++ } ++ }); ++ }); ++ ++ it('keeps the model registry bounded across repeated define/reset cycles', function () { ++ ++ ++ ++ ++ var restoreDate = freezeDate(FIXED_ISO); ++ ++ for (var i = 0; i < 125; i++) { ++ var docClient = makeCapturingDocClient(); ++ var Model = defineTimestampModel('UsercaseLeakFloorTimestamp' + i, {}, docClient); ++ ++ Model.create({id : 'cycle-' + i}, function (err, created) { ++ expect(err).to.not.exist; ++ ++ expectIsoDateString(created.get('createdAt')); ++ }); ++ vogels.reset(); ++ } ++ ++ restoreDate(); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,39 @@ ++#!/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 ++ ++required_modules=( ++ async ++ aws-sdk ++ bunyan ++ chai ++ joi ++ lodash ++ mocha ++ node-uuid ++) ++ ++for module in "${required_modules[@]}"; do ++ if [ ! -f "node_modules/${module}/package.json" ]; then ++ echo "Missing vendored npm dependency: ${module}" >&2 ++ exit 127 ++ fi ++done ++ ++if [ ! -f ./node_modules/mocha/bin/_mocha ]; then ++ echo "Missing vendored Mocha runner" >&2 ++ exit 127 ++fi ++ ++exec node ./node_modules/mocha/bin/_mocha --opts /dev/null /workspace/repo/usercase-test-coderl/timestamps.test.js --reporter spec diff --git a/tasks/format-code-task-002551/tests/test.sh b/tasks/format-code-task-002551/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3b7100d9742182e308fa5e8f276690af0f50d5f9 --- /dev/null +++ b/tasks/format-code-task-002551/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/timestamps.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-002551/tests/test_command.sh b/tasks/format-code-task-002551/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002551/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-002557/environment/Dockerfile b/tasks/format-code-task-002557/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..91ef503262a4f94f6a9fe1cfabca80982c6e87b1 --- /dev/null +++ b/tasks/format-code-task-002557/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:88b1842f7ba8cd76aea0e7f806447fb6fab4d21982ffaedf11be441361cf13f3 diff --git a/tasks/format-code-task-002557/environment/setup/files/blocklist b/tasks/format-code-task-002557/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002557/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002557/environment/setup/setup.sh b/tasks/format-code-task-002557/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002557/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002557/tests/test.patch b/tasks/format-code-task-002557/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..36ba36f7c230808053f6bec8016a95325776cc16 --- /dev/null +++ b/tasks/format-code-task-002557/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/tests/api/test_product.py b/tests/api/test_product.py +index 1e0b120e25f..2d1ecb8131e 100644 +--- a/tests/api/test_product.py ++++ b/tests/api/test_product.py +@@ -13,7 +13,7 @@ + from saleor.core import TaxRateType + from saleor.graphql.product.utils import update_variants_names + from saleor.product.models import ( +- Category, Collection, Product, ProductImage, ProductType) ++ Category, Collection, Product, ProductImage, ProductType, ProductVariant) + + from .utils import assert_no_permission, get_multipart_request_body + +@@ -1243,3 +1243,47 @@ def test_update_variants_changed_does_nothing_with_no_attributes(): + product_type.variant_attributes.all = Mock(return_value=[]) + saved_attributes = [] + assert update_variants_names(product_type, saved_attributes) is None ++ ++ ++def test_product_variants_by_ids(user_api_client, variant): ++ query = ''' ++ query getProduct($ids: [ID!]) { ++ productVariants(ids: $ids) { ++ edges { ++ node { ++ id ++ } ++ } ++ } ++ } ++ ''' ++ variant_id = graphene.Node.to_global_id('ProductVariant', variant.id) ++ ++ variables = json.dumps({'ids': [variant_id]}) ++ response = user_api_client.post( ++ reverse('api'), {'query': query, 'variables': variables}) ++ content = get_graphql_content(response) ++ assert 'errors' not in content ++ data = content['data']['productVariants'] ++ assert data['edges'][0]['node']['id'] == variant_id ++ assert len(data['edges']) == 1 ++ ++ ++def test_product_variants_no_ids_list(user_api_client, variant): ++ query = ''' ++ query getProductVariants { ++ productVariants(first: 10) { ++ edges { ++ node { ++ id ++ } ++ } ++ } ++ } ++ ''' ++ response = user_api_client.post( ++ reverse('api'), {'query': query}) ++ content = get_graphql_content(response) ++ assert 'errors' not in content ++ data = content['data']['productVariants'] ++ assert len(data['edges']) == ProductVariant.objects.count() +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+3U4WubQBQA8Hz2r3i4QLYPakyalG1kYBPXdCQxU0sYBILRayKYO3t3hgbyx+9U ++0pWOrRRatrH3++Kpd8/nvafmukizZEXo3mq8lrZy3utVR+XxsRrbvY5t99tn5111vRy1G9B7tYwe ++KISMOECDMyZ/N++p+/8o80f9JRFyFbPdLqKJKbYv94wn6m93+t1H9T/r2/0GtF8uhV/7z+sfJ1AV ++fk0STXsDTizTfSQJ5AfVEnDDOMwPcssodM33GrnLGZcwd8LxQG+OvalrmdVEa53SD83yuq6RfZSB ++3nxbR0hpKsF4p5fBA7XTajUTcsNJ8HUC6Q1QJoEXlKZ0o+WbVSyzOFMlIRzsPuyilIKoVnU+WQnZ ++W7TIMjgeQfKClCGHnJTZJpGM1pEgoFoXCqFWq9BySw6QMNqSQO5SITVRgAF5/XgBRgx6Lm4zMGQM ++Sz1wJ+4wBBs++94UVCqcZWrWYuz6LqgxjXZk0BJRRhhvLXU4goqSg3GrlqiE6khloKHvOqEL14Hr ++Qz0dFlfhWO1aECw8fwSnIFDPHF18XOr6wxd8ZqL3L1/nqk6fm+vICZ0LJ3BP+XqL2X3yPyWndt0v ++aLm7oCqzIRLK/hHa/Fs49mZVb5w6CkZfnNmltwrcMLyaXQarqTe6nriDaoEpiJSq7EL1WtlhXTB2 ++5VDdqyNaUZ7WP6Wcs6SIpeo1MPban/5kEEIIIYQQQgghhBBCCCGEEEIIIYT+Kt8BXrznrAAoAAA= +diff --git 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-002557/tests/test.sh b/tasks/format-code-task-002557/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6308cd07de028c4d2193d14427ff9b0d8cbf82ea --- /dev/null +++ b/tasks/format-code-task-002557/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/api/test_product.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-002557/tests/test_command.sh b/tasks/format-code-task-002557/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002557/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002558/environment/Dockerfile b/tasks/format-code-task-002558/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0f5d3e7fa487592315707f3837e0ba6fc1232383 --- /dev/null +++ b/tasks/format-code-task-002558/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bbb68af21410b56b66685892bca052e6d6d435fa95cb11522b099741c4c523d3 diff --git a/tasks/format-code-task-002558/environment/setup/files/blocklist b/tasks/format-code-task-002558/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002558/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002558/environment/setup/setup.sh b/tasks/format-code-task-002558/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002558/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002558/tests/test.patch b/tasks/format-code-task-002558/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0424ab7ae51331ca49281df5521c852c0f0df5b7 --- /dev/null +++ b/tasks/format-code-task-002558/tests/test.patch @@ -0,0 +1,53 @@ +diff --git a/tests/test_order_utils.py b/tests/test_order_utils.py +index e8bad43d997..90b999a3261 100644 +--- a/tests/test_order_utils.py ++++ b/tests/test_order_utils.py +@@ -1,5 +1,6 @@ + import pytest + ++from saleor.order import OrderStatus + from saleor.order.events import OrderEvents + from saleor.order.models import Order, OrderEvent + from saleor.order.utils import change_order_line_quantity, match_orders_with_new_user +@@ -55,3 +56,17 @@ def test_match_orders_with_new_user(customer_user): + match_orders_with_new_user(customer_user) + order.refresh_from_db() + assert order.user == customer_user ++ ++ ++def test_match_draft_order_with_new_user(customer_user): ++ address = customer_user.default_billing_address.get_copy() ++ order = Order.objects.create( ++ billing_address=address, ++ user=None, ++ user_email=customer_user.email, ++ status=OrderStatus.DRAFT, ++ ) ++ match_orders_with_new_user(customer_user) ++ ++ order.refresh_from_db() ++ assert order.user is None +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3TS0/jMBAA4JzzK4bQw3LIo4Uk0kpdqRIV3RW0hZbDniI3sVpLqV3Z44iV+PE4 ++4bGABFxACDHfxVbGnow9SbSyoq4KLpvY+yiJk6dpNzrPx27eTwf9fnaY58mRl7hZknuQflhFj1iD ++TAN4Wil8bd1b8S8q+t9/5AaLUm23TFaR2bzfO97qf5qnD/3PBpnr/1F2mHqQvF8JL/vm/d/fi1dC ++xitmNn5ZQfcRrHjl+/swlsZqDnNlcK354vwUhAFtpRRy7e/WRYl1Wbvr4xr6GWyZkNDeJcLgV1zx ++Jpa2ruH6GlBb3uYblSgahhx2/9zn5vOrnXKL56PlZBj0JrOzcRx1kbagn732eeDzhtUQ9H50ARBS ++IIQHwZNsjdBoWd2mNMrqkj8cIo6au3Qxu1vd7rywElyda47QLjT+/O9yMpt2hdxvheM/o+nJrFiM ++l8vf05NFcTY7vjwdD7sNkeGI7hKMOwlulIRw285c6Dbh7Z+kdMV1YVHUxp0LwisIGwgVBKyq1A7N ++MPA/u/mEEEIIIYQQQgghhBBCCCGEEEIIIeTLuwFyC4S6ACgAAA== +diff --git 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-002558/tests/test.sh b/tasks/format-code-task-002558/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ee192a171c951cd570802129e0de7847e367deb0 --- /dev/null +++ b/tasks/format-code-task-002558/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_order_utils.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002558/tests/test_command.sh b/tasks/format-code-task-002558/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002558/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002568/environment/Dockerfile b/tasks/format-code-task-002568/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..281e0cbd9e88158c1efcab7e0327f874a134202a --- /dev/null +++ b/tasks/format-code-task-002568/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2ffa34dfb1f1d565217e7e7eea87106960d7566bce4c95b81bf12de9238df409 diff --git a/tasks/format-code-task-002568/environment/setup/files/blocklist b/tasks/format-code-task-002568/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002568/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002568/environment/setup/setup.sh b/tasks/format-code-task-002568/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002568/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002568/tests/test.patch b/tasks/format-code-task-002568/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..79ce4c782bcdb3bd427e881067e72fbefeb54583 --- /dev/null +++ b/tasks/format-code-task-002568/tests/test.patch @@ -0,0 +1,168 @@ +diff --git a/tests/integration/runners/test_nacl.py b/tests/integration/runners/test_nacl.py +index 9f6a802e51ef..f4d7ab5f0c44 100644 +--- a/tests/integration/runners/test_nacl.py ++++ b/tests/integration/runners/test_nacl.py +@@ -5,6 +5,8 @@ + # Import Python libs + from __future__ import absolute_import, print_function, unicode_literals + ++import logging ++ + # Import Salt Testing libs + from tests.support.case import ShellCase + from tests.support.unit import skipIf +@@ -16,6 +18,8 @@ + except ImportError: + HAS_LIBNACL = False + ++log = logging.getLogger(__name__) ++ + + @skipIf(not HAS_LIBNACL, 'skipping test_nacl, libnacl is unavailable') + class NaclTest(ShellCase): +@@ -150,3 +154,37 @@ def test_secretbox_enc_dec(self): + sk=sk, + ) + self.assertEqual(unencrypted_data, ret['return']) ++ ++ def test_enc_dec_no_pk_no_sk(self): ++ ''' ++ Store, list, fetch, then flush data ++ ''' ++ ++ ret = self.run_run_plus( ++ 'nacl.keygen', ++ ) ++ self.assertIn('pk', ret['return']) ++ self.assertIn('sk', ret['return']) ++ pk = ret['return']['pk'] ++ sk = ret['return']['sk'] ++ ++ unencrypted_data = b'hello' ++ ++ ++ ret = self.run_run_plus( ++ 'nacl.enc', ++ data=unencrypted_data, ++ pk=None, ++ ) ++ self.assertIn('Exception: no pubkey or pk_file found', ret['return']) ++ ++ self.assertIn('return', ret) ++ encrypted_data = ret['return'] ++ ++ ++ ret = self.run_run_plus( ++ 'nacl.dec', ++ data=encrypted_data, ++ sk=None, ++ ) ++ self.assertIn('Exception: no key or sk_file found', ret['return']) +diff --git a/tests/unit/modules/test_nacl.py b/tests/unit/modules/test_nacl.py +index 6d7505d3c263..20a9b5fc8534 100644 +--- a/tests/unit/modules/test_nacl.py ++++ b/tests/unit/modules/test_nacl.py +@@ -14,6 +14,7 @@ + from tests.support.unit import TestCase + from tests.support.unit import skipIf + ++ + try: + import libnacl.secret # pylint: disable=unused-import + import libnacl.sealed # pylint: disable=unused-import +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,80 @@ ++H4sIAAAAAAAAA+0872/bRpakflg/LNtx/StpnZiJm8ryD1m/tU2dbpu4SRfduMEluENUBAIt0rEc ++iVJJqolzKeC7zeGyQHHnA7rYHrAfvMBeL8Huh/1wHw7YL/snyIVxNQgUCHaBBe4+uXCBC/rp5s2Q ++FElRtuU4Snvlszwk583Mm3nvzZs3Q85EF2vFEpfnhY9mqecFMQTZdBpfEViv+D6eTsQTyVgynkbx ++8Xg6G6eY9HOrkQFqksyKDEOJlYq8V7r98N9TiDbkn89XVwtsYZnP549WF9qQfyKbAfmnUAZH/p2A ++FvIvVIQlmZfkfLVUu1UUooXqqrxcEWaS8fgMukWYmdejsWgyirLsSwMEnEmlWsg/HkOSN8s/kczG ++khQT60D7f+jy//eeniBc/+cfIit/8VPUn43IgHrddbko6pcUR3F0icrR+Ooquwsumip7cl6aYLpy ++Xfjqy/nw1Z/z42sgF8DXYC6Ir93o6pqnbr6RC7kovocP8qHPUfm/dWlkpRkSv9KrxVhTiKMoRR/k ++RNdje6X83I2e3NoTTX0yh+vQn+vHNPo5t4X2z1C8b+Ul7ZnzfE4jPK095wYQPrAyqJeP/n+rMyw3 ++xHn5ofyw9uyiLlNc1wOK85mp5EYwxo8wAQvmOMYEEaabP26ufe4EP8IP5Ef0th5HT8f1pxPo6YRe ++79ADCj2/rGOH0NOQ/jTAd6280mjjHInrzw/occCl0dxJfD2FrvQ1KtLz34BaiASU3is1mV0s8VfY ++arUo3FJ82k1QRVzjZaVPv/+wxgsFXvFfZEsliFH8P5F50XAnV0TFr6dzQ+4e1DELt/PIEsn8Xfne ++EEoisFwlaop+TJnMjyamXWj3LykeK2vOxdEPqJybc6HQw7lRQzxK90KtVLpICinQliKA47tduIj7 ++1DXqMb0g9qCnx7TikfjSkgRpmG9fmwU7uMhzswYjajWc1VUlkEcY1Mh8/t6QgWpUjwahST4UrFHb ++AyMP39uFejRVyteoFIcqJfajW1ItlwhiUzyseEuSQJMYRgQFVfyIxN2ijAgPWgjj2FcMdEPHHs6L ++w1i6XsgnsGU0DijBfL5c4WoluA/l8x/W2BLBiKBL4staHXBWTFTs0wLQTCmBi9f+dlx04PgOpQce ++OtAPd9aAFAeF2Iv3VYt4G8JFoZfzoLCL8yJBdymha6AvatPvvX6xUq6ycnGxWCrKq4y0XCwzSxWR ++sVWuqDFrwWWoCNxD7XYHiZLQ96m8jtSlE6GVPrWo/BJbQDRWIx4sK/E0BCB3pev2HSw3D5abQXJF ++AUtuyFiJqBbNAG+PEdGNJx7Ob4WYOv5hzpl0x6Mp9O9xXQNIpTcoOzCbMtQivRRhfJySPY2UryJ5 ++05TsO0jeG5TguUPddd+g7iAurejxG4byWpWj8dGL+aX4VGYqgXfuFviqXKwIRNuwLoLJJj2T6CFE ++3hu2cE/tceOQNofZt+Ny98xsj41/OZb8Yiy5OZbeGkuvez4NrYeefjUwirSxZ6YRfDU2+a8f/+pj ++gl8P7bhR3NOnT58MjHw69+VA5IuByObA1NbAVD00JYVQ8X9/YpT61ck59x/oOXeTUHCH/mssFNmA ++u48srmW0GzYy7u/QyGV8XtHT3af/CbGMU/8jrgXxLHDPrfiWWYmVZRE/k06LO6fBVuDYJmUjdmIS ++0p7H3Pqqb3hd/uzGZl94qy8MLEk9mv/dT+vT89sj0+vyp/e3RqYfcfWRZP1YEpiTwkkQGv1U6+IT ++weyIoxCcxFLN57lKAVmUcV2UdmZlTAtOQW0uU0azsu2/XPdfBuOSBPOhBl3ewPQOpQe9rgCqTnNA ++aEDJJlujcXV3GgX/aLE2D6klGlkcf86D79zozvuQukvnuvDgMqTrp8n4XGjL+NiWYbJC0KuxFQJN ++/gVttUOyu5HU3K82jKXoAKOk2dmhNUVq4gwYsV2QhFl37bsvTXqpWaDf+udKbHmRY9+8F7Ntqm7r ++onOlSoEtSW9GtRwwqEhBrAL/9sGvb/7m5hopGKl6P6+VlV9mBa7Ei4pXqlV5EasXsiTY/ML8Fptf ++8QwKYIQulFhJyuclL0XM8BrROsh079Te9YNpijSDgqdIE89mwBif+SrU//PLn1z+MjT6RWi0fjKB ++fpuh5FYoWdd+zYYaxIVtQkwVp2sP3jb6P+n1hNMuEfLi/hNxk6biVsahim7ctDVDd2/ZMNLvU5Br ++RG3YwPgv0v+S/TS7NTC+cb0+MFkPTRKeWzu0GNEYh4koPSpzC3yplM8jZcCVgeq/RaoypQVRQPwN ++odfo2lfr/qs7rhadd8dPB6agux8kIMo3ZeW7jcfXcK7QGO5aEozjSlQLzkF1u7AWblzQNHBM8YMz ++KBcFSQm9VV3N608n8mTiHEW84EVgelTk74hFmVcCepTi0+KCb5HkeVZU3NKqpHjl1SovKUHVPpSK ++i0pAXhZ5lgO/u7tQKZX4ApQhgdehP0TZxYLiAadNnABxuOHZJ/EyDAiK75Z2oxoh5MBjf+86IibC ++EKZ4ce9TuvLIPKF6+VX6EunUYxpLFc8dka0qPuIuSkq3xJbkKLjDxVvIbUYPalSpwnKoOzZZA5Lx ++TfGqKhLpLyhEgwhN73RRNL1GtfgLkr9tKrSG/7ap/rr226aO1bXfNvVSXfttU8N17bfTRffM0zuU ++m76ohmvzT7pfephdf2PDs9l9dqv7LNIe70X6UfhR+PdT/zH7x9Tm5Ltbk++S2G1/30Pfevdn1zey ++G9lHb/zux/85vzn+9tb425v+C1v+C3X/hadPqN41/PfE17t25+Gdz/o2fRNbvokdapqe3B58df2d ++rcFX62fnNgfPbw2eX7vypGf04Y1P8ps9p7Z6Tq1d2h4+vnbpwfs7Ho8XecfNwdcQfNOIC/V6Uedo ++Dr6G4JtGHOPzon7RHGyEvobLN43Yl6jT02tXtjwnt0/PwPXU9uSP4RrePvHaZyfhbnj7ldNwPf5k ++6kdrFx+8Vz8W3vRMbI9G1i5veU6AAAcMzG8IgvzEYcqBFwN7Tl2PiMbe63+xVDKVaaz/pRNULJ5O ++ZlLO+l8nYJy5iocZhggd+aJMsVytiDIDxppRrTkj8DzHc8ziKgOJpeA4c6koSvI0U0ADkMzbu7BM ++ocnfDWqFr0raLR7WtIfG4KajtSGukUQf22yiYLgLBnGrlisCk4zGY1OMyJcrH6Hqy8u8xDNLYqVs ++zDKNWwctF1HbKiIP6cpB8Mxh2GQQVz4Im9e7wtNM2Hirr3mZnshqVng6yBghrC2CQVptGUy/R/Th ++vpEZ7uXwzXO4kOISI1RkRp3OTZgbgeoaYZDPa4cGtqhJzunVUZ2A5mKmmVvNKEMRkaAuHSJ39Gyu ++mRqPam/SiLBK3awm54kORBuex0TYVqHCiDBkJ64I5NOUI4qdlImIAR3VHBWUbkLNiB1RxrAW1mAG ++xy8x+vrABCzzGTiFF2Z4uSYKDGCsmbC3jPNMM5OwmmPJWkVUjRUwetuNlGfOnDn06hTKa6kUmZuo ++lbKsQqm1RJdJsvpkqS9kilryIC5aYoIH550srpojrFRQ6XZEVYFqQOZ2jD5r2bdMg6QtRRmkqaVv ++LA9p6tKGiJH+a7pPEoV1ncV90lSxooQ7y0JF4Jub0KJmpAKEtFGXbKdwE8aHyOFVzLbwfXStaQJ+ ++IG1ryoWk1xRnzgaz+omIPg2fIIsD58xCb1+SGv/14m1Yb+aSgaBZ52zSGhmJEhsfbVLb8h9ls423 ++yQ9TMpSccIZZEs6hf5tkuj0lN2obV6WoOvx/0MIc34Rua4zBGe19AWtKNEb/xMbRkJdZGPN54mfg ++kTlocEjUCSXDjKMe9CES9qVULG5KQKaXlgQv2sv67oLB/wf25QkrpSOdA+zj/xvf/8fTmTTy/zOJ ++lOP/dwSQMW+aAPCCVENesLG/4SHM0L1YhCeqwnNRGBCcPvr9BGP/l2uL0vP4CrCN77/iqWwc9f9E ++Npl2vv/qBDTJn6w6Qzc9MlVoR/6ZRAbWf+LppCP/TsBe8tdfwD2jF7Df+B9LZBryj2eR/LOJTMIZ ++/zsB42gKUlvEU8CG5J2x+AcDe/f/o/kgvH37n01mHPvfETio/PWxwPAl+IE+/qYOMP9Dzp5J/okk ++mgA69r8ToH3//c8/i6zAW1jT99/695aNz04j9MJjSoRPgPBXqt/G7D6C3cuTMLzp96okJPiSgLzp ++p7RAdFMOdAD2ktpS8a5cE/lnnhMewv7HoP879v/5w4Hk/4wTgX39/2TWIH/Y/xOPJ7KO/e8E2Pr/ ++UU3yzkTg/zscsP8/00SgbfsPt4797wi0Lf9DTAT29f9TGYv806msY/87Apr/v478f/iWt13///UD +++f92noQzEfguQNv9n2P5MnwN1sY6wD79PxnLJq39P5lx+n9HwNj//5ey9H9ti97uf1HQ//HOZOpB ++0/60HMG4EMaymzpHY4wHYbwWjKvl3mh3y73RnsbeaAvGizEhhOmxYLowphdh+iwYH3cM2bN++x2m ++vZR5hylsg1I811C3WHjsPsgG2ceqgfxRewZS617VVWz4cICtLZhGw7YYj39tXgxoKdpogw/a8B6/ ++uiCCdEU/BLgcUAOyKwMCMMlit47sOQSRv6oJ9kT0HcJ+M5HW+31tifiBCHxMa0+lXwu6zVT626MS ++BCpXWEnmRXs6A1rQa6YzcBg6aHSstODakBb0m+kMHYLOtVWBKxbs6YxowaCZzkh7dAJA56pYudtC ++005owYiZDEQtRPxE+7E69unSHND5MKIXYS7W4FS8rFZRel/fR+Sh6QA4Fdbgawi+acR1Oels0+mB ++qJ0M4sD3HNoclA5FY7/5Hzh7lvW/mPP+pzOw9/pfVJV8UN23gHDkY2myo6ERixwKewRyAuwRMHDb ++Y8hg2wKHB0h7HBnU7HF4IDKgXjTbvzOwV/+vycXSUXwQ2P77n0wy7rz/7wjsL/9n/wpsX/ufSljs ++fywVTzv2vxNgb/+x5M1W/J2PeEH+aRGZZsFsnGFbjbpNMF9YBmWqipUCL0m8NGG/8aeRD9n5clFg ++ZV7L036OfAnVaa9sL5rD3204SP9/1q/A2n//E0snHPvfEWhP/of7Cmwf+x9PJazff6WymYxj/zsB ++xvXfP1Gt1n/hwKW91n/x6Xs0Pn3PhU/fc5PT99pYLxq0G2cWIm2ttWYOtNba5NaYV1olu5VWv5ai ++qUX4AK7G+zE4KxIOcXrsIucx6uf7qWetwcKJMtJivMRLXbDyuqueyqjT3o8sWUCDXPjQHhO1/qYx ++E5+Vh5sERwg+M4Fh+0EZH+zTbaKyEPEQZuM1PagFOVPJRxlX8gyLeENqbSSOesZFvL0fGytbfuoH ++BYaOgs9+KVTKZVbgotLy0dHYZ/yPx+OG818SsP8rlYk57/86AuOnZxeLwuwiKy0HCxyjGVC8PVtA ++rCmVGJH/sFYUeY7h+CovcLxQKPJSkDgASWamzFSLVaaoJp6ZESozRaFak5lScVFgCyUmXJZuVdnC ++7bl4NBZmwitFYYVNzCWjcfRQZsXbtarELvFzCRyhbh6fy4SZqgSWmilXCreZxJuvxZn7jMyiiJk0 ++1O4aLzO1qnbOS5WVl/HZNUKhVON4Bht9vGuVbGsN8nfx9tOrN66/+/7C1bevv3v+jNbWcy1HDTvM ++GSCOximmhoYP9TQcIy/IZtqZKmM5TglxBmIKNZkrijqf8VWahbJm9S3wTVGkawIz0WjFzHykVaEo ++yPwtkYWDAI6qJoYiZ8WagMZgrUI2mKZ6vWhtdqBdMNp/0vXy5NSmozv+a1//P55p2H/48A/2fzr7 ++/zoD48x1Inabw7rwqlClRHb+IzzHI7tjf7rHHVbST9nChwiQMjMtz/tCJV0kR4ex2Fi3PoTGetRU ++p06a2u+cFxnnNsSFp5mJyDTzt2H9HKHwOe3oFekcI6EqaofJNBCTcGBNReA/tiPY7vEtTcdhwbFE ++l9iSxDM8BKTK1yC1XlntlCxUpYnIxxH1mKTnfPjLi9Z6BxxwwAEHHHDAAQcccMABBxz4YcH/AfVN ++0HAAeAAA +diff --git 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-002568/tests/test.sh b/tasks/format-code-task-002568/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f9cf2cee6eef83e3cf027a2f5fb53b57e7a1b551 --- /dev/null +++ b/tasks/format-code-task-002568/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/integration/runners/test_nacl.py +tests/unit/modules/test_nacl.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-002568/tests/test_command.sh b/tasks/format-code-task-002568/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002568/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002701/environment/Dockerfile b/tasks/format-code-task-002701/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e3999b6ce1978c9655b6ca3924da2dc49c715d85 --- /dev/null +++ b/tasks/format-code-task-002701/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ff5bb075ae93b88332c9f0937f466dd824dbb282e30ab940897fca627bdda38f diff --git a/tasks/format-code-task-002701/environment/setup/files/blocklist b/tasks/format-code-task-002701/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002701/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002701/environment/setup/setup.sh b/tasks/format-code-task-002701/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002701/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002701/tests/test.patch b/tasks/format-code-task-002701/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c98bc6b806f6f2767fa83f8ab233bfca2124f914 --- /dev/null +++ b/tasks/format-code-task-002701/tests/test.patch @@ -0,0 +1,158 @@ +diff --git a/tests/openmp_test.py b/tests/openmp_test.py +new file mode 100644 +index 0000000000..7f9f1b1111 +--- /dev/null ++++ b/tests/openmp_test.py +@@ -0,0 +1,116 @@ ++ ++import dace ++from dace import dtypes, nodes ++ ++N = dace.symbol("N") ++ ++ ++@dace.program ++def arrayop(inp: dace.float32[N], out: dace.float32[N]): ++ for i in dace.map[0:N]: ++ out[i] = 2 * inp[i] ++ ++ ++def _cpu_multicore_sdfg(): ++ sdfg = arrayop.to_sdfg(simplify=True) ++ map_entry = None ++ for node, _ in sdfg.all_nodes_recursive(): ++ if isinstance(node, nodes.MapEntry): ++ map_entry = node ++ break ++ assert map_entry is not None ++ map_entry.map.schedule = dtypes.ScheduleType.CPU_Multicore ++ return sdfg, map_entry.map ++ ++ ++def _pragma_line(sdfg): ++ code = sdfg.generate_code()[0].clean_code ++ lines = [ ++ line.strip() ++ for line in code.splitlines() ++ if "#pragma omp parallel for" in line ++ ] ++ assert lines, code ++ return lines[0] ++ ++ ++def _default_omp_schedule(): ++ _, mapnode = _cpu_multicore_sdfg() ++ return mapnode.omp_schedule ++ ++ ++def _schedule_cases(): ++ expected_clauses = { ++ "schedule(dynamic)", ++ "schedule(guided)", ++ "schedule(static)", ++ } ++ cases = {} ++ default_schedule = _default_omp_schedule() ++ for schedule_kind in dtypes.OMPScheduleType: ++ if schedule_kind == default_schedule: ++ continue ++ sdfg, mapnode = _cpu_multicore_sdfg() ++ mapnode.omp_schedule = schedule_kind ++ try: ++ pragma = _pragma_line(sdfg) ++ except ValueError: ++ continue ++ matched = [clause for clause in expected_clauses if clause in pragma] ++ assert len(matched) <= 1 ++ if matched: ++ cases[matched[0]] = schedule_kind ++ assert set(cases) == expected_clauses ++ return cases ++ ++ ++def test_omp_schedule_type_public_api(): ++ schedule_cases = _schedule_cases() ++ assert len(set(schedule_cases.values())) == 3 ++ sdfg, mapnode = _cpu_multicore_sdfg() ++ schedule_kind = next(iter(schedule_cases.values())) ++ mapnode.omp_schedule = schedule_kind ++ assert mapnode.omp_schedule == schedule_kind ++ mapnode.omp_chunk_size = 11 ++ mapnode.omp_num_threads = 6 ++ assert mapnode.omp_chunk_size == 11 ++ assert mapnode.omp_num_threads == 6 ++ ++ ++def test_default_cpu_multicore_pragma_has_no_omp_clauses(): ++ sdfg, _ = _cpu_multicore_sdfg() ++ pragma = _pragma_line(sdfg) ++ assert "#pragma omp parallel for" in pragma ++ assert "schedule(" not in pragma ++ assert "num_threads(" not in pragma ++ ++ ++def test_schedule_clauses_for_multiple_kinds(): ++ for expected_clause, schedule_kind in _schedule_cases().items(): ++ sdfg, mapnode = _cpu_multicore_sdfg() ++ mapnode.omp_schedule = schedule_kind ++ pragma = _pragma_line(sdfg) ++ assert expected_clause in pragma ++ assert "num_threads(" not in pragma ++ ++ ++def test_schedule_chunk_size_boundaries(): ++ dynamic_schedule = _schedule_cases()["schedule(dynamic)"] ++ sdfg, mapnode = _cpu_multicore_sdfg() ++ mapnode.omp_schedule = dynamic_schedule ++ mapnode.omp_chunk_size = 7 ++ pragma = _pragma_line(sdfg) ++ assert "schedule(dynamic, 7)" in pragma ++ ++ sdfg, mapnode = _cpu_multicore_sdfg() ++ mapnode.omp_schedule = dynamic_schedule ++ mapnode.omp_chunk_size = 0 ++ pragma = _pragma_line(sdfg) ++ assert "schedule(dynamic)" in pragma ++ assert "schedule(dynamic," not in pragma ++ ++ ++def test_num_threads_clause_independent_of_schedule(): ++ sdfg, mapnode = _cpu_multicore_sdfg() ++ mapnode.omp_num_threads = 3 ++ pragma = _pragma_line(sdfg) ++ assert "num_threads(3)" in pragma ++ assert "schedule(" not in pragma ++ ++ guided_schedule = _schedule_cases()["schedule(guided)"] ++ sdfg, mapnode = _cpu_multicore_sdfg() ++ mapnode.omp_schedule = guided_schedule ++ mapnode.omp_num_threads = 5 ++ pragma = _pragma_line(sdfg) ++ assert "schedule(guided)" in pragma ++ assert "num_threads(5)" in pragma +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++ ++dev-switch python3 3.11 ++ ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest tests/schedule_inference_test.py::test_schedule_inference_simple -q ++ ;; ++ new) ++ python3 -m pytest tests/openmp_test.py -q ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002701/tests/test.sh b/tasks/format-code-task-002701/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..059bfae520e8039da67f811fe6985a82a27299c3 --- /dev/null +++ b/tasks/format-code-task-002701/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/openmp_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002701/tests/test_command.sh b/tasks/format-code-task-002701/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002701/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-002706/environment/Dockerfile b/tasks/format-code-task-002706/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cfa07100be2be561ce878b62f157322f7e82031d --- /dev/null +++ b/tasks/format-code-task-002706/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:697c0c2f6d5ccf99ea632e965bf01481fc28a8ff068f717298912f0f5b2a2d3f diff --git a/tasks/format-code-task-002706/environment/setup/files/blocklist b/tasks/format-code-task-002706/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002706/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002706/environment/setup/setup.sh b/tasks/format-code-task-002706/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002706/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002706/tests/test.patch b/tasks/format-code-task-002706/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..79a1d0b625eb24eb247df17b92106ceed8486e0c --- /dev/null +++ b/tasks/format-code-task-002706/tests/test.patch @@ -0,0 +1,256 @@ +diff --git a/src/test/java/com/spotify/docker/client/messages/ContainerInfoTest.java b/src/test/java/com/spotify/docker/client/messages/ContainerInfoTest.java +index 73b835ff9..a890951f5 100644 +--- a/src/test/java/com/spotify/docker/client/messages/ContainerInfoTest.java ++++ b/src/test/java/com/spotify/docker/client/messages/ContainerInfoTest.java +@@ -41,6 +41,11 @@ public void setUp() throws Exception { + objectMapper = new ObjectMapperProvider().getContext(ContainerInfo.class); + } + ++ @Test ++ public void test1_22() throws Exception { ++ objectMapper.readValue(fixture("fixtures/1.22/containerInfo.json"), ContainerInfo.class); ++ } ++ + @Test + public void test1_24() throws Exception { + objectMapper.readValue(fixture("fixtures/1.24/containerInfo.json"), ContainerInfo.class); +diff --git a/src/test/resources/fixtures/1.22/containerInfo.json b/src/test/resources/fixtures/1.22/containerInfo.json +new file mode 100644 +index 000000000..c0aae28ea +--- /dev/null ++++ b/src/test/resources/fixtures/1.22/containerInfo.json +@@ -0,0 +1,211 @@ ++{ ++ "Id":"0d6e51015f514d09e6ed3d5fadb3ed70b5782f5169fcce53461ba5fb1fc40a3a", ++ "Created":"2017-02-15T01:12:03.714202576Z", ++ "Path":"catalina.sh", ++ "Args":[ ++ "run" ++ ], ++ "State":{ ++ "Status":"running", ++ "Running":true, ++ "Paused":false, ++ "Restarting":false, ++ "OOMKilled":false, ++ "Dead":false, ++ "Pid":10598, ++ "ExitCode":0, ++ "Error":"", ++ "StartedAt":"2017-02-15T01:12:04.4899204Z", ++ "FinishedAt":"0001-01-01T00:00:00Z" ++ }, ++ "Image":"sha256:57d87b47399bb8e9c5c5e4035c8ecba0c84f662d07a89a9497fd45b52b304ea1", ++ "ResolvConfPath":"/var/lib/docker/containers/0d6e51015f514d09e6ed3d5fadb3ed70b5782f5169fcce53461ba5fb1fc40a3a/resolv.conf", ++ "HostnamePath":"/var/lib/docker/containers/0d6e51015f514d09e6ed3d5fadb3ed70b5782f5169fcce53461ba5fb1fc40a3a/hostname", ++ "HostsPath":"/var/lib/docker/containers/0d6e51015f514d09e6ed3d5fadb3ed70b5782f5169fcce53461ba5fb1fc40a3a/hosts", ++ "LogPath":"/var/lib/docker/containers/0d6e51015f514d09e6ed3d5fadb3ed70b5782f5169fcce53461ba5fb1fc40a3a/0d6e51015f514d09e6ed3d5fadb3ed70b5782f5169fcce53461ba5fb1fc40a3a-json.log", ++ "Node":{ ++ "ID":"FU4U:FPGX:PNRQ:KH3G:H6UQ:P6ZZ:JSJR:6NGL:TIUY:DO4T:D63E:T6JY", ++ "IP":"10.110.13.31", ++ "Addr":"10.110.13.31:2375", ++ "Name":"swarm-node2", ++ "Cpus":2, ++ "Memory":4143976448, ++ "Labels":{ ++ "executiondriver":"native-0.2", ++ "kernelversion":"4.6.2-1.el7.elrepo.x86_64", ++ "operatingsystem":"CentOS Linux 7 (Core)", ++ "storagedriver":"devicemapper" ++ } ++ }, ++ "Name":"/bsp_test", ++ "RestartCount":0, ++ "Driver":"devicemapper", ++ "MountLabel":"system_u:object_r:svirt_sandbox_file_t:s0:c127,c600", ++ "ProcessLabel":"system_u:system_r:svirt_lxc_net_t:s0:c127,c600", ++ "AppArmorProfile":"", ++ "ExecIDs":null, ++ "HostConfig":{ ++ "Binds":null, ++ "ContainerIDFile":"", ++ "LogConfig":{ ++ "Type":"json-file", ++ "Config":{ ++ ++ } ++ }, ++ "NetworkMode":"over", ++ "PortBindings":{ ++ ++ }, ++ "RestartPolicy":{ ++ "Name":"always", ++ "MaximumRetryCount":0 ++ }, ++ "VolumeDriver":"", ++ "VolumesFrom":null, ++ "CapAdd":null, ++ "CapDrop":null, ++ "Dns":[ ++ ++ ], ++ "DnsOptions":[ ++ ++ ], ++ "DnsSearch":[ ++ ++ ], ++ "ExtraHosts":null, ++ "GroupAdd":null, ++ "IpcMode":"", ++ "Links":null, ++ "OomScoreAdj":0, ++ "PidMode":"", ++ "Privileged":false, ++ "PublishAllPorts":true, ++ "ReadonlyRootfs":false, ++ "SecurityOpt":null, ++ "UTSMode":"", ++ "ShmSize":67108864, ++ "ConsoleSize":[ ++ 0, ++ 0 ++ ], ++ "Isolation":"", ++ "CpuShares":0, ++ "CgroupParent":"", ++ "BlkioWeight":0, ++ "BlkioWeightDevice":null, ++ "BlkioDeviceReadBps":null, ++ "BlkioDeviceWriteBps":null, ++ "BlkioDeviceReadIOps":null, ++ "BlkioDeviceWriteIOps":null, ++ "CpuPeriod":0, ++ "CpuQuota":0, ++ "CpusetCpus":"", ++ "CpusetMems":"", ++ "Devices":[ ++ ++ ], ++ "KernelMemory":0, ++ "Memory":0, ++ "MemoryReservation":0, ++ "MemorySwap":0, ++ "MemorySwappiness":-1, ++ "OomKillDisable":false, ++ "PidsLimit":0, ++ "Ulimits":null ++ }, ++ "GraphDriver":{ ++ "Name":"devicemapper", ++ "Data":{ ++ "DeviceId":"1824", ++ "DeviceName":"docker-253:0-17703341-4575a6a4364d19979baf48e85eec0c3334db447ef653d041ed1bb74c3ad0cb52", ++ "DeviceSize":"10737418240" ++ } ++ }, ++ "Mounts":[ ++ ++ ], ++ "Config":{ ++ "Hostname":"0d6e51015f51", ++ "Domainname":"", ++ "User":"", ++ "AttachStdin":false, ++ "AttachStdout":false, ++ "AttachStderr":false, ++ "ExposedPorts":{ ++ "8080/tcp":{ ++ ++ } ++ }, ++ "Tty":true, ++ "OpenStdin":true, ++ "StdinOnce":false, ++ "Env":[ ++ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk1.7.0_80/bin:/usr/local/tomcat/lib:/usr/local/tomcat/bin", ++ "JAVA_HOME=/usr/local/jdk1.7.0_80", ++ "CLASSPATH=/usr/local/jdk1.7.0_80/lib/dt.jar:/usr/local/jdk1.7.0_80/lib/tools.jar", ++ "CATALINA_HOME=/usr/local/tomcat", ++ "CATALINA_BASE=/usr/local/tomcat", ++ "TOMCAT_HOME=/usr/local/tomcat/", ++ "java_size=512" ++ ], ++ "Cmd":[ ++ "catalina.sh", ++ "run" ++ ], ++ "Image":"10.110.13.187:5001/bsp:2017020717", ++ "Volumes":null, ++ "WorkingDir":"/usr/local/tomcat/webapps", ++ "Entrypoint":null, ++ "OnBuild":null, ++ "Labels":{ ++ "com.docker.swarm.id":"eb1fefebb0ad3b990f51dd9080fc8077ff068aa431ed08fd4d50266b8c8d9cdf" ++ }, ++ "StopSignal":"SIGTERM" ++ }, ++ "NetworkSettings":{ ++ "Bridge":"", ++ "SandboxID":"88fe8800bf80583571371182745d6d10f0e85113b05eaa14a9db9169539df386", ++ "HairpinMode":false, ++ "LinkLocalIPv6Address":"", ++ "LinkLocalIPv6PrefixLen":0, ++ "Ports":{ ++ "8080/tcp":[ ++ { ++ "HostIp":"10.110.13.31", ++ "HostPort":"32771" ++ } ++ ] ++ }, ++ "SandboxKey":"/var/run/docker/netns/88fe8800bf80", ++ "SecondaryIPAddresses":null, ++ "SecondaryIPv6Addresses":null, ++ "EndpointID":"", ++ "Gateway":"", ++ "GlobalIPv6Address":"", ++ "GlobalIPv6PrefixLen":0, ++ "IPAddress":"", ++ "IPPrefixLen":0, ++ "IPv6Gateway":"", ++ "MacAddress":"", ++ "Networks":{ ++ "over":{ ++ "IPAMConfig":null, ++ "Links":[ ++ "lsrr_test:lsrr_test" ++ ], ++ "Aliases":null, ++ "NetworkID":"a81d854bbadc82b99610e154819866b19d281b97eea629f2f0ca5f7b26f02059", ++ "EndpointID":"01da14c11fb9a45b3c12d1348d5263b485410f37d1bb8601cf11fc0f0a8b3cbe", ++ "Gateway":"", ++ "IPAddress":"10.0.1.3", ++ "IPPrefixLen":24, ++ "IPv6Gateway":"", ++ "GlobalIPv6Address":"", ++ "GlobalIPv6PrefixLen":0, ++ "MacAddress":"02:42:0a:00:01:03" ++ } ++ } ++ } ++} +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+3SW0vDMBQH8D73UxwvD/qwtXHrBkIf5hS84AUZPgkjbTKW2SYjSacf33bOC4ru ++RRHx/3tJOCfpOeWknVWqEGOpF1HwU+JaP0mWa+39utyzZC/e63eSbsKCmLFenASU/FhHb1TOc0sU ++WGP8V+fW5f+o9uv8vXR+nJuy5Fq03fT7aqybf7fffzf/bq/DAoq/r4XP/fP5b21EmdJRxt00zAUt ++H0EmRRhu0ZF2lZWUG2tl7un08IwW0jpldCgf5sbWocHNYHx8eX6URpWzUaGyaLYo62+UlVW6xVhr ++Ju5avBS97vOVq8HoON3cfrnZVN/fbqKbTc3rStPQaM+VlvZET8yo7ofulZ/SKR+aoSGhHM8KKWjH ++FOK5IVK6frhz7lWdWh2v22VsNywXmpqfotuQqHXYbNOPFZ6SE66Kk8nFMuTSCS+cXGVmPDe5abs7 ++NU+9rVbhg/C3xwcAAAAAAAAAAAAAAAAAAAAA/9wjtDhgwgAoAAA= +diff --git 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-002706/tests/test.sh b/tasks/format-code-task-002706/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aae1852264bcb0f7c4ae8f0555df69d05186e37b --- /dev/null +++ b/tasks/format-code-task-002706/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/test/java/com/spotify/docker/client/messages/ContainerInfoTest.java +src/test/resources/fixtures/1.22/containerInfo.json +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-002706/tests/test_command.sh b/tasks/format-code-task-002706/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002706/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002711/environment/Dockerfile b/tasks/format-code-task-002711/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..baf059b9089f8827df2059741e8f0ac9f13698a5 --- /dev/null +++ b/tasks/format-code-task-002711/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c0366109be226d42eb41281524aab6a21c4e1321410c6fd1e7c6faf5b81843a3 diff --git a/tasks/format-code-task-002711/environment/setup/files/blocklist b/tasks/format-code-task-002711/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002711/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002711/environment/setup/setup.sh b/tasks/format-code-task-002711/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002711/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002711/tests/test.patch b/tasks/format-code-task-002711/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..52881dab20aba91010392f9c25df5cefb9dda79b --- /dev/null +++ b/tasks/format-code-task-002711/tests/test.patch @@ -0,0 +1,41 @@ +diff --git a/scio-tensorflow/src/test/scala/com/spotify/scio/tensorflow/MetadataSchemaTest.scala b/scio-tensorflow/src/test/scala/com/spotify/scio/tensorflow/MetadataSchemaTest.scala +index 6309a76f60..39ead51e8e 100644 +--- a/scio-tensorflow/src/test/scala/com/spotify/scio/tensorflow/MetadataSchemaTest.scala ++++ b/scio-tensorflow/src/test/scala/com/spotify/scio/tensorflow/MetadataSchemaTest.scala +@@ -70,7 +70,7 @@ object MetadataSchemaTest { + .addFeature(MFeature.newBuilder() + .setName("dense_shape") + .setType(FeatureType.INT) +- .setShape(FixedShape.newBuilder().addDim(FixedShape.Dim.newBuilder().setSize(1)))) ++ .setShape(FixedShape.newBuilder())) + .build() + + private def longFeature(raw: Seq[Long]): Feature = { +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+2U32vbMBDH8+y/4uoG0sIkx82Plo0OwjZoCyWhC3sZI8iWTJTalmfJaQL743d2 ++1yVt2dKHdmPsPg+xfLr7nnR3Do8qncqZypdB66XoIseDQfNEHj6bdTg4CsNh2O8e91pdXHXDFgxe ++7ERbVNaJEqBVGuN+57dr/x+Fb/rvlHWz2GSZyCW38+fLsaP/4XFvsOl/D+1hH1ct6D7fEX7Nf97/ ++/b2gsmUQ6TzAGYBI2LlnlQOmKgOFLlQidOrFEprxiJT01KowpYOL0afR7Gx8+eG0EUh1FCyWGXpl ++ValzdsIW8pqJTA77dxGT0fTs1G//DKyTvm7XVt/z9mEiXDyHojTOxGyBPXEGdB6nlVR31h7v8S5g ++mCjXcBCbYg0mgR4f8PAV4OQWwukoVZCYEqzOivRHpD1EfRtrw2w8V5mwUKqvlS6VfaBcua0DsEaY ++hyCNsnnH4XYuUVI7b3I1no7fzS5GV6ftg0TnWJ56PgKul+ujIBaYBVguMgX+Yz2Oax+O3gZSLYO8 ++SlP4BnMlJLDw0NMJfMZQ8NubHD58eQNurnIPYHo5eX9eZ82usdQFMHmIVuyP377d8vG1rt4qua+B ++5kZ7D1hSlzBorhxs35+lOq9WbHUynA37XK3UVl6A7FrqElixCW7M8Z0B77ZRw5fHak/MukPW2KeI ++3vfaIXmDHTQ39gmyjz0b6brg8YOCA8etRONPmQErk60OoXX7i/Js5KCDeRYqdrdz6lRuTZmk5qYD ++ndpvnKfresS5LYzTyZrXbnzjxi+VE1I48bGZ8CmGdLy//edCEARBEARBEARBEARBEARBEARBEARB ++EMQf4TsI6Sg/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-002711/tests/test.sh b/tasks/format-code-task-002711/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e6ce458a0e5b8e04a76a3030ecb534f6f782c6c4 --- /dev/null +++ b/tasks/format-code-task-002711/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' +scio-tensorflow/src/test/scala/com/spotify/scio/tensorflow/MetadataSchemaTest.scala +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002711/tests/test_command.sh b/tasks/format-code-task-002711/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002711/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002730/environment/Dockerfile b/tasks/format-code-task-002730/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..01a893d1e08b834a60c5b21b1fe0e37359d8431d --- /dev/null +++ b/tasks/format-code-task-002730/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0925998f1c781ffd3ef9cb08a03de97885886dd4b903ba113af4a1cdab150840 diff --git a/tasks/format-code-task-002730/environment/setup/files/blocklist b/tasks/format-code-task-002730/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002730/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002730/environment/setup/setup.sh b/tasks/format-code-task-002730/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002730/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002730/tests/test.patch b/tasks/format-code-task-002730/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5d81a6acca17a00e11b1462c06e5b216857d5435 --- /dev/null +++ b/tasks/format-code-task-002730/tests/test.patch @@ -0,0 +1,80 @@ +diff --git a/tests/__mocks__/obsidian.js b/tests/__mocks__/obsidian.js +new file mode 100644 +index 00000000..5ac7bcaf +--- /dev/null ++++ b/tests/__mocks__/obsidian.js +@@ -0,0 +1,5 @@ ++module.exports = { ++ moment: { ++ locale: jest.fn(()=>"en") ++ } ++}; +diff --git a/tests/lang/helpers.test.ts b/tests/lang/helpers.test.ts +new file mode 100644 +index 00000000..5730c5a6 +--- /dev/null ++++ b/tests/lang/helpers.test.ts +@@ -0,0 +1,43 @@ ++test("Test translation without interpolation in English", () => { ++ jest.isolateModules(() => { ++ const { moment } = require("obsidian"); ++ const mockLocale = moment.locale as jest.MockedFunction<() => string>; ++ mockLocale.mockImplementation(() => 'en'); ++ const {t} = require("src/lang/helpers"); ++ expect(t("HARD")).toEqual("Hard"); ++ }); ++}); ++ ++test("Test translation without interpolation in German", () => { ++ jest.isolateModules(() => { ++ const { moment } = require("obsidian"); ++ const mockLocale = moment.locale as jest.MockedFunction<() => string>; ++ mockLocale.mockImplementation(() => 'de'); ++ const {t} = require("src/lang/helpers"); ++ expect(t("HARD")).toEqual("Schwer"); ++ }); ++}); ++ ++test("Test translation with interpolation in English", () => { ++ jest.isolateModules(() => { ++ const { moment } = require("obsidian"); ++ const mockLocale = moment.locale as jest.MockedFunction<() => string>; ++ mockLocale.mockImplementation(() => 'en'); ++ const {t} = require("src/lang/helpers"); ++ expect( ++ t("STATUS_BAR", {dueNotesCount: 1, dueFlashcardsCount: 2}) ++ ).toEqual("Review: 1 notes(s), 2 card(s) due"); ++ }); ++}); ++ ++test("Test translation with interpolation in German", () => { ++ jest.isolateModules(() => { ++ const { moment } = require("obsidian"); ++ const mockLocale = moment.locale as jest.MockedFunction<() => string>; ++ mockLocale.mockImplementation(() => 'de'); ++ const {t} = require("src/lang/helpers"); ++ expect( ++ t("STATUS_BAR", {dueNotesCount: 1, dueFlashcardsCount: 2}) ++ ).toEqual("Wiederholung: 1 Notiz(en), 2 Karte(n) anstehend"); ++ }); ++}); +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+3RTQ6CMBCG4a49RU9QKFp6HAPS+BMohBbj8UU2EBN1ozHG99nMZKZJJ/lUORzr ++auv8ORGfko6sMVMd3dep1ybT2m7W1miRap2nVkjzsYsWhhCLXkrRt2189u7V/kepOf/oQtzu2qYp ++fKXC4X1/vMw/X+SfZWP+m1wbIdP3nfDYn+e/q+QUfOmqle8u8jT28jYISV34fXJwdef6oG4jFcPq ++2/cCAAAAAAAAAAAAAAAAmF0BKuCUFgAoAAA= +diff --git 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-002730/tests/test.sh b/tasks/format-code-task-002730/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0a28191402b477bd561942ebd433144d193ca5d0 --- /dev/null +++ b/tasks/format-code-task-002730/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/__mocks__/obsidian.js +tests/lang/helpers.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-002730/tests/test_command.sh b/tasks/format-code-task-002730/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002730/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002737/environment/Dockerfile b/tasks/format-code-task-002737/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b72c493047120d098cedf227cb4b39b5384999f2 --- /dev/null +++ b/tasks/format-code-task-002737/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4382a8669f1148d5ec4db7e2f12dbdc6a4945bcd25536f2c42c4ea522303d547 diff --git a/tasks/format-code-task-002737/environment/setup/files/blocklist b/tasks/format-code-task-002737/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002737/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002737/environment/setup/setup.sh b/tasks/format-code-task-002737/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002737/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002737/tests/test.patch b/tasks/format-code-task-002737/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0c85809630e2f542d3f1a3c014dd005904ab5ed6 --- /dev/null +++ b/tasks/format-code-task-002737/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/statsmodels/distributions/copula/tests/test_copula_args.py b/statsmodels/distributions/copula/tests/test_copula_args.py +new file mode 100644 +index 000000000..2d8641b4d +--- /dev/null ++++ b/statsmodels/distributions/copula/tests/test_copula_args.py +@@ -0,0 +1,94 @@ ++# -*- coding: utf-8 -*- ++ ++import numpy as np ++from numpy.testing import assert_allclose ++import pytest ++ ++from statsmodels.distributions.copula.archimedean import ( ++ ClaytonCopula, FrankCopula, GumbelCopula) ++ ++ ++ ++u = np.array([[0.33706249, 0.6075078], ++ [0.62232507, 0.06241089], ++ [0.2001457, 0.54027684], ++ [0.77166391, 0.40610225], ++ [0.72755898, 0.25913165], ++ [0.05943888, 0.61044613], ++ [0.0962475, 0.67585563], ++ [0.35496733, 0.79584436], ++ [0.44513594, 0.23050014]]) ++ ++ ++ ++cases = [ ++ (ClaytonCopula, 1.2, 2.5), ++ (FrankCopula, 2.0, 3.0), ++ (GumbelCopula, 1.5, 2.5), ++] ++ ++ ++@pytest.mark.parametrize("cls,theta_a,theta_b", cases) ++def test_args_overrides_constructor(cls, theta_a, theta_b): ++ ++ ++ cop_a = cls(theta_a) ++ cop_b = cls(theta_b) ++ ++ assert_allclose(cop_a.cdf(u, args=(theta_b,)), cop_b.cdf(u), rtol=1e-12) ++ assert_allclose(cop_a.pdf(u, args=(theta_b,)), cop_b.pdf(u), rtol=1e-12) ++ assert_allclose(cop_a.logpdf(u, args=(theta_b,)), cop_b.logpdf(u), ++ rtol=1e-12) ++ ++ ++@pytest.mark.parametrize("cls,theta_a,theta_b", cases) ++def test_empty_args_uses_constructor(cls, theta_a, theta_b): ++ ++ cop_a = cls(theta_a) ++ ++ assert_allclose(cop_a.cdf(u, args=()), cop_a.cdf(u), rtol=1e-12) ++ assert_allclose(cop_a.pdf(u, args=()), cop_a.pdf(u), rtol=1e-12) ++ assert_allclose(cop_a.logpdf(u, args=()), cop_a.logpdf(u), rtol=1e-12) ++ ++ ++@pytest.mark.parametrize("cls,theta_a,theta_b", cases) ++def test_construct_without_param(cls, theta_a, theta_b): ++ ++ ++ cop_none = cls(theta=None) ++ cop_b = cls(theta_b) ++ ++ assert_allclose(cop_none.cdf(u, args=(theta_b,)), cop_b.cdf(u), rtol=1e-12) ++ assert_allclose(cop_none.pdf(u, args=(theta_b,)), cop_b.pdf(u), rtol=1e-12) ++ assert_allclose(cop_none.logpdf(u, args=(theta_b,)), cop_b.logpdf(u), ++ rtol=1e-12) ++ ++ ++@pytest.mark.parametrize("cls,theta_a,theta_b", cases) ++def test_pdf_logpdf_consistent(cls, theta_a, theta_b): ++ ++ cop = cls(theta=None) ++ assert_allclose(cop.pdf(u, args=(theta_b,)), ++ np.exp(cop.logpdf(u, args=(theta_b,))), rtol=1e-12) ++ ++ ++ ++ref = [ ++ (ClaytonCopula, 2.0, 0.485954322440435, 0.8921974147432954), ++ (FrankCopula, 2.0, 0.4710805107852225, 0.9257812360337806), ++ (GumbelCopula, 2.0, 0.4960348880595387, 0.3973548776136501), ++] ++ ++ ++@pytest.mark.parametrize("cls,theta,cdf_ref,pdf_ref", ref) ++def test_args_reference_values(cls, theta, cdf_ref, pdf_ref): ++ ++ cop = cls(theta=None) ++ point = np.array([[0.5, 0.9]]) ++ ++ assert_allclose(np.squeeze(cop.cdf(point, args=(theta,))), cdf_ref, ++ rtol=1e-12) ++ assert_allclose(np.squeeze(cop.pdf(point, args=(theta,))), pdf_ref, ++ rtol=1e-12) ++ assert_allclose(np.squeeze(cop.logpdf(point, args=(theta,))), ++ np.log(pdf_ref), rtol=1e-12) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++source /testbed/.venv/bin/activate ++ ++PYTEST_OPTS="-p no:cacheprovider -o filterwarnings= -o addopts=" ++ ++ ++python -m pytest statsmodels/distributions/copula/tests/test_copula.py \ ++ statsmodels/distributions/tests/test_bernstein.py $PYTEST_OPTS ++ ++ ++python -m pytest statsmodels/distributions/copula/tests/test_copula_args.py $PYTEST_OPTS diff --git a/tasks/format-code-task-002737/tests/test.sh b/tasks/format-code-task-002737/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..963451f40d7ae15707a68693b0c7818122241453 --- /dev/null +++ b/tasks/format-code-task-002737/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' +statsmodels/distributions/copula/tests/test_copula_args.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-002737/tests/test_command.sh b/tasks/format-code-task-002737/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002737/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002739/environment/Dockerfile b/tasks/format-code-task-002739/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f1cc721cf0fd5775887e3b3c6c0d6248ec021ec8 --- /dev/null +++ b/tasks/format-code-task-002739/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:94d1b37e14d3ebd1e8db3589db00539582006ad52285d94f3ac287b26520b0c8 diff --git a/tasks/format-code-task-002739/environment/setup/files/blocklist b/tasks/format-code-task-002739/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002739/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002739/environment/setup/setup.sh b/tasks/format-code-task-002739/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002739/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002739/tests/test.patch b/tasks/format-code-task-002739/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9d12d4a411abfce2ff62d8cd4c8e3f490c683d9 --- /dev/null +++ b/tasks/format-code-task-002739/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/statsmodels/tsa/tests/test_stattools.py b/statsmodels/tsa/tests/test_stattools.py +index 569009ec2..f767fc811 100644 +--- a/statsmodels/tsa/tests/test_stattools.py ++++ b/statsmodels/tsa/tests/test_stattools.py +@@ -1392,6 +1392,60 @@ def test_adfuller_maxlag_too_large(reset_randomstate): + adfuller(y, maxlag=51) + + ++def test_adfuller_constant_series_exact_issue(): ++ ++ ++ with pytest.raises(ValueError, match="constant"): ++ adfuller(np.full(8, 5.0)) ++ ++ ++def test_adfuller_constant_zero_series(): ++ ++ with pytest.raises(ValueError, match="constant"): ++ adfuller(np.zeros(20)) ++ ++ ++def test_adfuller_constant_negative_value(): ++ ++ with pytest.raises(ValueError, match="constant"): ++ adfuller(np.full(15, -3.5)) ++ ++ ++def test_adfuller_constant_with_regression_ct(): ++ ++ with pytest.raises(ValueError, match="constant"): ++ adfuller(np.full(20, 7.0), regression="ct") ++ ++ ++def test_adfuller_constant_with_autolag_none(): ++ ++ with pytest.raises(ValueError, match="constant"): ++ adfuller(np.full(20, 7.0), autolag=None, maxlag=2) ++ ++ ++def test_adfuller_constant_no_runtime_warning(): ++ ++ with warnings.catch_warnings(): ++ warnings.simplefilter("error", RuntimeWarning) ++ with pytest.raises(ValueError, match="constant"): ++ adfuller(np.full(8, 5.0)) ++ ++ ++def test_adfuller_non_constant_series_preserved(): ++ ++ rng = np.random.default_rng(42) ++ y = rng.standard_normal(100) ++ result = adfuller(y) ++ ++ assert len(result) == 6 ++ adf_stat, pvalue, usedlag, nobs, crit, icbest = result ++ assert np.isfinite(adf_stat) ++ assert 0.0 <= pvalue <= 1.0 ++ assert isinstance(usedlag, (int, np.integer)) ++ assert isinstance(nobs, (int, np.integer)) ++ assert set(crit.keys()) == {"1%", "5%", "10%"} ++ ++ + class SetupZivotAndrews: + # test directory + cur_dir = CURR_DIR +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..b92a23077 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest statsmodels/tsa/tests/test_stattools.py -k 'test_adfuller_constant or test_adfuller_non_constant_series_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 statsmodels/tsa/tests/test_stattools.py -k 'test_adfuller_constant or test_adfuller_non_constant_series_preserved' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002739/tests/test.sh b/tasks/format-code-task-002739/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f99dc0bbb494c4b0993e9f3151a8ca579c9267c --- /dev/null +++ b/tasks/format-code-task-002739/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' +statsmodels/tsa/tests/test_stattools.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-002739/tests/test_command.sh b/tasks/format-code-task-002739/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002739/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002763/environment/Dockerfile b/tasks/format-code-task-002763/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9252440adbd0771482c550c97f9c4959c67e8371 --- /dev/null +++ b/tasks/format-code-task-002763/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6fd20ef1202828e738f1f7e017861d58d32aed6d6e81232a4d8a4971ead448aa diff --git a/tasks/format-code-task-002763/environment/setup/files/blocklist b/tasks/format-code-task-002763/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002763/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002763/environment/setup/setup.sh b/tasks/format-code-task-002763/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002763/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002763/tests/test.patch b/tasks/format-code-task-002763/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..28de42e27f3acd0adb187849a5715988a3b5b8f6 --- /dev/null +++ b/tasks/format-code-task-002763/tests/test.patch @@ -0,0 +1,61 @@ +diff --git a/src/rules/operator-no-unspaced/__tests__/index.js b/src/rules/operator-no-unspaced/__tests__/index.js +index e88be53..bd0004c 100644 +--- a/src/rules/operator-no-unspaced/__tests__/index.js ++++ b/src/rules/operator-no-unspaced/__tests__/index.js +@@ -2507,3 +2507,34 @@ a { + } + ] + }); ++ ++ ++testRule(rule, { ++ ruleName, ++ config: [undefined], ++ syntax: "scss", ++ skipBasicChecks: true, ++ ++ accept: [ ++ { ++ code: `@forward "src/list" as list-*;`, ++ description: "@forward with prefix wildcard (issue reproduction)." ++ }, ++ { ++ code: `@use "src/list" as list-*;`, ++ description: "@use with prefix wildcard." ++ }, ++ { ++ code: `@use "src/list" as *;`, ++ description: "@use with bare asterisk namespace." ++ }, ++ { ++ code: `@forward "src/list";`, ++ description: "Plain @forward without prefix." ++ }, ++ { ++ code: `@use "src/list";`, ++ description: "Plain @use without prefix." ++ } ++ ] ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..efb0c57 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest src/rules/operator-no-unspaced"] ++} +diff --git 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/rules/operator-no-unspaced ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002763/tests/test.sh b/tasks/format-code-task-002763/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea2619fd3a6cb3b11c695d0e2c76ec08ebd4bb1d --- /dev/null +++ b/tasks/format-code-task-002763/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/rules/operator-no-unspaced/__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-002763/tests/test_command.sh b/tasks/format-code-task-002763/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002763/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002765/environment/Dockerfile b/tasks/format-code-task-002765/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..66fc8f9de61854530eaf6a336c9bc1be28e43e38 --- /dev/null +++ b/tasks/format-code-task-002765/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:91675599a2bdc123ea7b691bbdb17dce1d019036f8dc4c3a83d2cbe24dae75b3 diff --git a/tasks/format-code-task-002765/environment/setup/files/blocklist b/tasks/format-code-task-002765/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002765/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002765/environment/setup/setup.sh b/tasks/format-code-task-002765/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002765/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002765/tests/test.patch b/tasks/format-code-task-002765/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a991c9459cba7c20cd28cb21ec8b90e1b9e7e9b5 --- /dev/null +++ b/tasks/format-code-task-002765/tests/test.patch @@ -0,0 +1,156 @@ +diff --git a/src/rules/indentation/__tests__/hierarchical.js b/src/rules/indentation/__tests__/hierarchical.js +new file mode 100644 +index 000000000..0d01c7155 +--- /dev/null ++++ b/src/rules/indentation/__tests__/hierarchical.js +@@ -0,0 +1,125 @@ ++/* eslint-disable indent, no-multiple-empty-lines */ ++ ++import { ++ ruleTester, ++ warningFreeBasics ++} from "../../../testUtils" ++import rule, { ruleName, messages } from ".." ++ ++const testRule = ruleTester(rule, ruleName) ++ ++ ++testRule(2, { hierarchicalSelectors: true }, tr => { ++warningFreeBasics(tr) ++ ++ ++tr.ok( ++`a { ++ color: pink; ++}`) ++ ++tr.ok( ++`@media print { ++ a { ++ color: pink; ++ } ++}`) ++ ++ ++tr.ok( ++`.foo {} ++ .foo-sub {}`) ++ ++ ++tr.ok( ++`#foo ul {} ++ #foo ul > li {} ++ #foo ul > li > a {} ++#bar ul {}`) ++ ++ ++tr.ok( ++`.foo {} ++ .foo-one {} ++ .foo-two {} ++ .foo-two-sub {} ++ .foo-three {} ++.bar {}`) ++ ++ ++ ++tr.ok( ++`.foo {} ++ @media print { ++ .foo-one {} ++ .foo-two {} ++ } ++.bar {}`) ++ ++ ++ ++tr.ok( ++`.foo {} ++@media print { ++ .foo-one {} ++ .bar {} ++}`) ++ ++ ++tr.notOk( ++`.foo {} ++.foo-sub {}`, ++messages.expected("2 spaces at line 2")) ++ ++ ++tr.notOk( ++`.foo {} ++ .foo-sub {}`, ++messages.expected("2 spaces at line 2")) ++ ++ ++tr.notOk( ++`.foo {} ++ .foo-two {} ++ .foo-two-sub {}`, ++messages.expected("4 spaces at line 3")) ++ ++ ++tr.notOk( ++`.foo {} ++ @media print { ++ .foo-one {} ++ }`, ++messages.expected("4 spaces at line 3")) ++ ++}) ++ ++ ++testRule("tab", { hierarchicalSelectors: true }, tr => { ++warningFreeBasics(tr) ++ ++tr.ok( ++`.foo {} ++\t.foo-sub {}`) ++ ++tr.notOk( ++`.foo {} ++.foo-sub {}`, ++messages.expected("1 tab at line 2")) ++ ++}) ++ ++ ++testRule(2, tr => { ++warningFreeBasics(tr) ++ ++tr.ok( ++`.foo {} ++.foo-sub {}`) ++ ++tr.notOk( ++`.foo {} ++ .foo-sub {}`, ++messages.expected("0 spaces at line 2")) ++ ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++node_modules/.bin/babel-tape-runner \ ++ "src/rules/indentation/__tests__/rules.js" \ ++ "src/rules/indentation/__tests__/at-rules.js" \ ++ "src/rules/indentation/__tests__/selectors.js" ++ ++ ++node_modules/.bin/babel-tape-runner \ ++ "src/rules/indentation/__tests__/hierarchical.js" diff --git a/tasks/format-code-task-002765/tests/test.sh b/tasks/format-code-task-002765/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c6aa2436f4d268e2adcbbd1615066a47316d2ad8 --- /dev/null +++ b/tasks/format-code-task-002765/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/rules/indentation/__tests__/hierarchical.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-002765/tests/test_command.sh b/tasks/format-code-task-002765/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002765/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002791/environment/Dockerfile b/tasks/format-code-task-002791/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..84370f3063291d993bb0b61f2068e8786cfe4190 --- /dev/null +++ b/tasks/format-code-task-002791/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:09f614680c44380e5af20becb2fe8359ebcbf45feb5b8b8432fb16d0e0c2768d diff --git a/tasks/format-code-task-002791/environment/setup/files/blocklist b/tasks/format-code-task-002791/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002791/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002791/environment/setup/setup.sh b/tasks/format-code-task-002791/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002791/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002791/tests/test.patch b/tasks/format-code-task-002791/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9a3ccf9e22c7624f4cb77c7c5fa9cf42c9ca4d8d --- /dev/null +++ b/tasks/format-code-task-002791/tests/test.patch @@ -0,0 +1,1048 @@ +diff --git a/usercase-test-coderl/fixtures/common.hpp b/usercase-test-coderl/fixtures/common.hpp +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/common.hpp +@@ -0,0 +1,661 @@ ++#pragma once ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifndef M_PI ++#define M_PI 3.14159265358979323846 ++#endif ++ ++namespace ros ++{ ++class Duration; ++ ++class Time ++{ ++ public: ++ explicit Time(double sec = 0.0) : sec_(sec) {} ++ ++ double toSec() const { return sec_; } ++ ++ static Time now(); ++ ++ private: ++ double sec_; ++ ++ friend class Duration; ++ friend Duration operator-(const Time &lhs, const Time &rhs); ++ friend Time operator+(const Time &lhs, const Duration &rhs); ++}; ++ ++class Duration ++{ ++ public: ++ explicit Duration(double sec = 0.0) : sec_(sec) {} ++ ++ double toSec() const { return sec_; } ++ ++ private: ++ double sec_; ++ ++ friend Duration operator-(const Time &lhs, const Time &rhs); ++ friend Time operator+(const Time &lhs, const Duration &rhs); ++ friend bool operator<(const Duration &lhs, const Duration &rhs); ++ friend bool operator>(const Duration &lhs, const Duration &rhs); ++ friend bool operator<=(const Duration &lhs, const Duration &rhs); ++ friend bool operator>=(const Duration &lhs, const Duration &rhs); ++ }; ++ ++inline Duration operator-(const Time &lhs, const Time &rhs) ++{ ++ return Duration(lhs.sec_ - rhs.sec_); ++} ++ ++inline Time operator+(const Time &lhs, const Duration &rhs) ++{ ++ return Time(lhs.sec_ + rhs.sec_); ++} ++ ++inline bool operator<(const Duration &lhs, const Duration &rhs) ++{ ++ return lhs.sec_ < rhs.sec_; ++} ++ ++inline bool operator>(const Duration &lhs, const Duration &rhs) ++{ ++ return lhs.sec_ > rhs.sec_; ++} ++ ++inline bool operator<=(const Duration &lhs, const Duration &rhs) ++{ ++ return lhs.sec_ <= rhs.sec_; ++} ++ ++inline bool operator>=(const Duration &lhs, const Duration &rhs) ++{ ++ return lhs.sec_ >= rhs.sec_; ++} ++ ++namespace detail ++{ ++inline double &sim_time() ++{ ++ static double value = 0.0; ++ return value; ++} ++ ++inline size_t &sleep_count() ++{ ++ static size_t value = 0; ++ return value; ++} ++ ++inline size_t &shutdown_after() ++{ ++ static size_t value = std::numeric_limits::max(); ++ return value; ++} ++ ++inline bool &ok_flag() ++{ ++ static bool value = true; ++ return value; ++} ++ ++template ++struct Bus ++{ ++ std::vector> subscribers; ++}; ++ ++template ++std::unordered_map>> ®istries() ++{ ++ static std::unordered_map>> *value = ++ new std::unordered_map>>(); ++ return *value; ++} ++ ++template ++std::shared_ptr> bus_for(const std::string &topic) ++{ ++ auto ®istry = registries(); ++ auto it = registry.find(topic); ++ if(it != registry.end()) ++ { ++ return it->second; ++ } ++ ++ std::shared_ptr> bus(new Bus()); ++ registry[topic] = bus; ++ return bus; ++} ++ ++template ++void add_subscriber(const std::string &topic, void (C::*cb)(const typename M::ConstPtr &), C *obj) ++{ ++ auto bus = bus_for(topic); ++ bus->subscribers.push_back([obj, cb](const M &msg) { ++ typename M::ConstPtr ptr = &msg; ++ (obj->*cb)(ptr); ++ }); ++} ++ ++template ++void publish(const std::string &topic, const M &msg) ++{ ++ auto bus = bus_for(topic); ++ for(const auto &subscriber : bus->subscribers) ++ { ++ subscriber(msg); ++ } ++} ++ ++inline void advance_time(double sec) ++{ ++ sim_time() += sec; ++} ++} ++ ++inline void reset() ++{ ++ detail::sim_time() = 0.0; ++ detail::sleep_count() = 0; ++ detail::shutdown_after() = std::numeric_limits::max(); ++ detail::ok_flag() = true; ++} ++ ++inline void set_shutdown_after(size_t count) ++{ ++ detail::shutdown_after() = count; ++} ++ ++inline bool ok() ++{ ++ return detail::ok_flag(); ++} ++ ++inline Time Time::now() ++{ ++ return Time(detail::sim_time()); ++} ++ ++inline void init(int &, char **, const std::string &) ++{ ++ reset(); ++} ++ ++inline void spinOnce() ++{ ++} ++ ++inline void spin() ++{ ++} ++ ++class Subscriber ++{ ++ public: ++ Subscriber() = default; ++ explicit Subscriber(std::string topic) : topic_(std::move(topic)) {} ++ ++ private: ++ std::string topic_; ++}; ++ ++class Publisher ++{ ++ public: ++ Publisher() = default; ++ explicit Publisher(std::string topic) : topic_(std::move(topic)) {} ++ ++ template ++ void publish(const M &msg) const ++ { ++ detail::publish(topic_, msg); ++ } ++ ++ private: ++ std::string topic_; ++}; ++ ++class ServiceClient ++{ ++ public: ++ ServiceClient() = default; ++ explicit ServiceClient(std::string service) : service_(std::move(service)) {} ++ ++ template ++ ++ bool call(Srv &) const; ++ ++ private: ++ std::string service_; ++}; ++ ++class Rate ++{ ++ public: ++ explicit Rate(double hz) : hz_(hz) {} ++ ++ void sleep() ++ { ++ detail::sleep_count() += 1; ++ detail::advance_time(1.0 / hz_); ++ if(detail::sleep_count() >= detail::shutdown_after()) ++ { ++ detail::ok_flag() = false; ++ } ++ } ++ ++ private: ++ double hz_; ++}; ++ ++class NodeHandle ++{ ++ public: ++ NodeHandle() = default; ++ ++ template ++ Subscriber subscribe(const std::string &topic, int, void (C::*cb)(const typename M::ConstPtr &), C *obj) ++ { ++ detail::add_subscriber(topic, cb, obj); ++ return Subscriber(topic); ++ } ++ ++ template ++ Publisher advertise(const std::string &topic, int) ++ { ++ return Publisher(topic); ++ } ++ ++ template ++ ServiceClient serviceClient(const std::string &topic) ++ { ++ return ServiceClient(topic); ++ } ++ ++ void setParam(const std::string &, double) ++ { ++ } ++}; ++ ++inline void log(const char *level, const char *fmt, ...) ++{ ++ char buf[2048]; ++ va_list ap; ++ va_start(ap, fmt); ++ vsnprintf(buf, sizeof(buf), fmt, ap); ++ va_end(ap); ++ std::cerr << level << ": " << buf << '\n'; ++} ++} ++ ++#define ROS_INFO(...) ::ros::log("INFO", __VA_ARGS__) ++#define ROS_WARN(...) ::ros::log("WARN", __VA_ARGS__) ++#define ROS_ERROR(...) ::ros::log("ERROR", __VA_ARGS__) ++ ++namespace std_msgs ++{ ++struct String ++{ ++ using ConstPtr = const String *; ++ std::string data; ++}; ++} ++ ++namespace geometry_msgs ++{ ++struct Point ++{ ++ double x = 0.0; ++ double y = 0.0; ++ double z = 0.0; ++}; ++ ++struct Quaternion ++{ ++ double x = 0.0; ++ double y = 0.0; ++ double z = 0.0; ++ double w = 1.0; ++}; ++ ++struct Pose ++{ ++ Point position; ++ Quaternion orientation; ++}; ++ ++struct Header ++{ ++ ros::Time stamp; ++ std::string frame_id; ++}; ++ ++struct PoseStamped ++{ ++ using ConstPtr = const PoseStamped *; ++ Header header; ++ Pose pose; ++}; ++ ++struct PoseArray ++{ ++ using ConstPtr = const PoseArray *; ++ Header header; ++ std::vector poses; ++}; ++ ++struct PoseWithCovariance ++{ ++ Pose pose; ++ double covariance[36] = {0.0}; ++}; ++ ++struct PoseWithCovarianceStamped ++{ ++ using ConstPtr = const PoseWithCovarianceStamped *; ++ Header header; ++ PoseWithCovariance pose; ++}; ++ ++struct Transform ++{ ++ Point translation; ++ Quaternion rotation; ++}; ++ ++struct TransformStamped ++{ ++ using ConstPtr = const TransformStamped *; ++ Header header; ++ std::string child_frame_id; ++ Transform transform; ++}; ++} ++ ++namespace sensor_msgs ++{ ++struct NavSatFix ++{ ++ using ConstPtr = const NavSatFix *; ++ ros::Time header_stamp; ++ double latitude = 0.0; ++ double longitude = 0.0; ++ double altitude = 0.0; ++}; ++} ++ ++namespace mavros_msgs ++{ ++struct State ++{ ++ using ConstPtr = const State *; ++ bool connected = false; ++ bool armed = false; ++ std::string mode; ++}; ++ ++struct ExtendedState ++{ ++ using ConstPtr = const ExtendedState *; ++ static constexpr uint8_t LANDED_STATE_ON_GROUND = 1; ++ uint8_t landed_state = 0; ++}; ++ ++struct CommandBool ++{ ++ struct Request ++ { ++ bool value = false; ++ }; ++ ++ struct Response ++ { ++ bool success = false; ++ }; ++ ++ Request request; ++ Response response; ++}; ++ ++struct CommandTOL ++{ ++ struct Request ++ { ++ double altitude = 0.0; ++ double latitude = 0.0; ++ double longitude = 0.0; ++ double min_pitch = 0.0; ++ double yaw = 0.0; ++ }; ++ ++ struct Response ++ { ++ bool success = false; ++ }; ++ ++ Request request; ++ Response response; ++}; ++ ++struct SetMode ++{ ++ struct Request ++ { ++ std::string custom_mode; ++ }; ++ ++ struct Response ++ { ++ bool mode_sent = false; ++ }; ++ ++ Request request; ++ Response response; ++}; ++ ++struct GlobalPositionTarget ++{ ++ static constexpr uint8_t FRAME_GLOBAL_INT = 5; ++ static constexpr uint16_t IGNORE_VX = 1 << 0; ++ static constexpr uint16_t IGNORE_VY = 1 << 1; ++ static constexpr uint16_t IGNORE_VZ = 1 << 2; ++ static constexpr uint16_t IGNORE_AFX = 1 << 3; ++ static constexpr uint16_t IGNORE_AFY = 1 << 4; ++ static constexpr uint16_t IGNORE_AFZ = 1 << 5; ++ static constexpr uint16_t IGNORE_YAW_RATE = 1 << 6; ++ ++ uint8_t coordinate_frame = 0; ++ uint16_t type_mask = 0; ++ double latitude = 0.0; ++ double longitude = 0.0; ++ double altitude = 0.0; ++ double yaw = 0.0; ++}; ++} ++ ++namespace ros ++{ ++ ++template ++inline bool ServiceClient::call(Srv &) const ++{ ++ return true; ++} ++ ++template <> ++inline bool ServiceClient::call(mavros_msgs::SetMode &srv) const ++{ ++ srv.response.mode_sent = true; ++ mavros_msgs::State state; ++ state.connected = true; ++ state.armed = false; ++ state.mode = srv.request.custom_mode; ++ detail::publish("/mavros/state", state); ++ return true; ++} ++ ++template <> ++inline bool ServiceClient::call(mavros_msgs::CommandBool &srv) const ++{ ++ srv.response.success = true; ++ mavros_msgs::State state; ++ state.connected = true; ++ state.armed = srv.request.value; ++ state.mode = "OFFBOARD"; ++ detail::publish("/mavros/state", state); ++ return true; ++} ++ ++template <> ++inline bool ServiceClient::call(mavros_msgs::CommandTOL &srv) const ++{ ++ (void)srv; ++ srv.response.success = true; ++ mavros_msgs::ExtendedState state; ++ state.landed_state = mavros_msgs::ExtendedState::LANDED_STATE_ON_GROUND; ++ detail::publish("/mavros/extended_state", state); ++ return true; ++} ++} ++ ++namespace tf ++{ ++struct Quaternion ++{ ++ double x = 0.0; ++ double y = 0.0; ++ double z = 0.0; ++ double w = 1.0; ++}; ++ ++struct Point ++{ ++ double x = 0.0; ++ double y = 0.0; ++ double z = 0.0; ++ ++ double distance(const Point &other) const ++ { ++ const double dx = x - other.x; ++ const double dy = y - other.y; ++ const double dz = z - other.z; ++ return std::sqrt(dx * dx + dy * dy + dz * dz); ++ } ++}; ++ ++inline geometry_msgs::Quaternion createQuaternionMsgFromYaw(double yaw) ++{ ++ geometry_msgs::Quaternion q; ++ q.x = 0.0; ++ q.y = 0.0; ++ q.z = std::sin(yaw / 2.0); ++ q.w = std::cos(yaw / 2.0); ++ return q; ++} ++ ++inline void quaternionMsgToTF(const geometry_msgs::Quaternion &msg, Quaternion &q) ++{ ++ q.x = msg.x; ++ q.y = msg.y; ++ q.z = msg.z; ++ q.w = msg.w; ++} ++ ++inline void pointMsgToTF(const geometry_msgs::Point &msg, Point &p) ++{ ++ p.x = msg.x; ++ p.y = msg.y; ++ p.z = msg.z; ++} ++ ++class Matrix3x3 ++{ ++ public: ++ explicit Matrix3x3(const Quaternion &q) : q_(q) {} ++ ++ void getRPY(double &roll, double &pitch, double &yaw) const ++ { ++ const double sinr_cosp = 2.0 * (q_.w * q_.x + q_.y * q_.z); ++ const double cosr_cosp = 1.0 - 2.0 * (q_.x * q_.x + q_.y * q_.y); ++ roll = std::atan2(sinr_cosp, cosr_cosp); ++ ++ const double sinp = 2.0 * (q_.w * q_.y - q_.z * q_.x); ++ if(std::fabs(sinp) >= 1.0) ++ { ++ pitch = std::copysign(M_PI / 2.0, sinp); ++ } ++ else ++ { ++ pitch = std::asin(sinp); ++ } ++ ++ const double siny_cosp = 2.0 * (q_.w * q_.z + q_.x * q_.y); ++ const double cosy_cosp = 1.0 - 2.0 * (q_.y * q_.y + q_.z * q_.z); ++ yaw = std::atan2(siny_cosp, cosy_cosp); ++ } ++ ++ private: ++ Quaternion q_; ++}; ++} ++ ++namespace tf2 ++{ ++class TransformException : public std::runtime_error ++{ ++ public: ++ explicit TransformException(const std::string &msg) : std::runtime_error(msg) {} ++}; ++ ++struct Quaternion ++{ ++ double x = 0.0; ++ double y = 0.0; ++ double z = 0.0; ++ double w = 1.0; ++}; ++} ++ ++namespace tf2_ros ++{ ++class Buffer ++{ ++ public: ++ geometry_msgs::TransformStamped lookupTransform(const std::string &, const std::string &, const ros::Time &) ++ { ++ return geometry_msgs::TransformStamped(); ++ } ++}; ++ ++class TransformListener ++{ ++ public: ++ explicit TransformListener(Buffer &) {} ++}; ++ ++class TransformBroadcaster ++{ ++ public: ++ void sendTransform(const geometry_msgs::TransformStamped &) {} ++}; ++ ++class StaticTransformBroadcaster ++{ ++ public: ++ void sendTransform(const geometry_msgs::TransformStamped &) {} ++}; ++} // namespace tf2_ros +diff --git a/usercase-test-coderl/fixtures/harness.cpp b/usercase-test-coderl/fixtures/harness.cpp +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/harness.cpp +@@ -0,0 +1,195 @@ ++#include "include/drone_control.h" ++ ++#include ++#include ++#include ++#include ++#include ++ ++ ++extern int offboard_control_real_main(int argc, char **argv); ++ ++namespace ++{ ++geometry_msgs::PoseArray make_marker(double x, double y, double z) ++{ ++ geometry_msgs::PoseArray arr; ++ arr.header.stamp = ros::Time::now(); ++ arr.header.frame_id = "world"; ++ geometry_msgs::Pose pose; ++ pose.position.x = x; ++ pose.position.y = y; ++ pose.position.z = z; ++ pose.orientation = tf::createQuaternionMsgFromYaw(0.0); ++ arr.poses.push_back(pose); ++ return arr; ++} ++ ++geometry_msgs::PoseArray make_stale_marker(double x, double y, double z) ++{ ++ geometry_msgs::PoseArray arr = make_marker(x, y, z); ++ arr.header.stamp = ros::Time(-100.0); ++ return arr; ++} ++ ++double yaw_from_pose(const geometry_msgs::PoseStamped &pose) ++{ ++ tf::Quaternion q; ++ tf::quaternionMsgToTF(pose.pose.orientation, q); ++ double roll = 0.0; ++ double pitch = 0.0; ++ double yaw = 0.0; ++ tf::Matrix3x3(q).getRPY(roll, pitch, yaw); ++ return yaw; ++} ++ ++std::string fmt(double value) ++{ ++ std::ostringstream out; ++ out.setf(std::ios::fixed); ++ out << std::setprecision(6) << value; ++ return out.str(); ++} ++ ++class ScenarioRunner ++{ ++ public: ++ ++ explicit ScenarioRunner(const std::string &scenario) ++ : scenario_(scenario), ++ follow_scan_endpoints_(scenario != "warning"), ++ endpoint_sub_(nh_.subscribe("/trajectory/endpoint_position", 10, ++ &ScenarioRunner::endpoint_cb, this)), ++ command_sub_(nh_.subscribe("/trajectory/command", 10, ++ &ScenarioRunner::command_cb, this)), ++ setpoint_sub_(nh_.subscribe("/mavros/setpoint_position/local", 10, ++ &ScenarioRunner::setpoint_cb, this)), ++ local_pub_(nh_.advertise("/mavros/local_position/pose", 10)), ++ marker_pub_(nh_.advertise("/whycon/poses", 10)) ++ { ++ } ++ ++ void command_cb(const std_msgs::String::ConstPtr &msg) ++ { ++ if(msg->data == "s" && !scan_started_) ++ { ++ scan_started_ = true; ++ scan_active_ = true; ++ if(scenario_ == "fresh-marker") ++ { ++ publish_marker(true); ++ } ++ } ++ } ++ ++ void endpoint_cb(const geometry_msgs::PoseStamped::ConstPtr &msg) ++ { ++ if(!scan_started_) ++ { ++ return; ++ } ++ ++ if(scan_endpoints_.size() < 5) ++ { ++ scan_endpoints_.push_back(*msg); ++ if(follow_scan_endpoints_) ++ { ++ local_pub_.publish(*msg); ++ } ++ if(scan_endpoints_.size() == 5) ++ { ++ ++ publish_marker(scenario_ == "fresh-marker"); ++ ros::set_shutdown_after(ros::detail::sleep_count() + 45); ++ } ++ return; ++ } ++ ++ scan_active_ = false; ++ ros::set_shutdown_after(ros::detail::sleep_count() + 80); ++ } ++ ++ void setpoint_cb(const geometry_msgs::PoseStamped::ConstPtr &msg) ++ { ++ if(scan_active_) ++ { ++ scan_setpoints_.push_back(*msg); ++ } ++ else ++ { ++ local_pub_.publish(*msg); ++ } ++ } ++ ++ const std::vector &endpoints() const ++ { ++ return scan_endpoints_; ++ } ++ ++ const std::vector &setpoints() const ++ { ++ return scan_setpoints_; ++ } ++ ++ private: ++ void publish_marker(bool fresh) ++ { ++ if(fresh) ++ { ++ marker_pub_.publish(make_marker(1.0, 2.0, 2.0)); ++ } ++ else ++ { ++ marker_pub_.publish(make_stale_marker(1.0, 2.0, 2.0)); ++ } ++ } ++ ++ std::string scenario_; ++ bool follow_scan_endpoints_; ++ bool scan_started_ = false; ++ bool scan_active_ = false; ++ ros::NodeHandle nh_; ++ ros::Subscriber endpoint_sub_; ++ ros::Subscriber command_sub_; ++ ros::Subscriber setpoint_sub_; ++ ros::Publisher local_pub_; ++ ros::Publisher marker_pub_; ++ std::vector scan_endpoints_; ++ std::vector scan_setpoints_; ++}; ++ ++void print_summary(const std::string &name, const ScenarioRunner &runner) ++{ ++ std::cout << "scenario=" << name << '\n'; ++ std::cout << "endpoint_count=" << runner.endpoints().size() << '\n'; ++ for(size_t i = 0; i < runner.endpoints().size(); ++i) ++ { ++ const auto &pose = runner.endpoints()[i]; ++ std::cout << "endpoint[" << i << "]=" ++ << fmt(pose.pose.position.x) << ',' ++ << fmt(pose.pose.position.y) << ',' ++ << fmt(pose.pose.position.z) << ',' ++ << fmt(yaw_from_pose(pose)) << '\n'; ++ } ++ std::cout << "setpoint_count=" << runner.setpoints().size() << '\n'; ++ if(!runner.setpoints().empty()) ++ { ++ const auto &pose = runner.setpoints().front(); ++ std::cout << "setpoint[0]=" ++ << fmt(pose.pose.position.x) << ',' ++ << fmt(pose.pose.position.y) << ',' ++ << fmt(pose.pose.position.z) << ',' ++ << fmt(yaw_from_pose(pose)) << '\n'; ++ } ++} ++} ++ ++int main(int argc, char **argv) ++{ ++ std::string scenario = argc > 1 ? argv[1] : "steady"; ++ ScenarioRunner runner(scenario); ++ ++ offboard_control_real_main(argc, argv); ++ print_summary(scenario, runner); ++ return 0; ++} +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,160 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++REPO=/workspace/repo ++FIXTURES=$REPO/usercase-test-coderl/fixtures ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++fail() { ++ echo "FAIL: $*" >&2 ++ exit 1 ++} ++ ++assert_line() { ++ name=$1 ++ expected=$2 ++ grep -Fxq "$expected" out || { ++ echo "FAIL: $name missing line: $expected" >&2 ++ echo "actual:" >&2 ++ cat out >&2 ++ exit 1 ++ } ++} ++ ++value_for() { ++ key=$1 ++ sed -n "s/^$key=//p" out | head -n 1 ++} ++ ++assert_count_between() { ++ name=$1 ++ key=$2 ++ min=$3 ++ max=$4 ++ value=$(value_for "$key") ++ case "$value" in ++ ''|*[!0-9]*) fail "$name invalid $key: $value" ;; ++ esac ++ [ "$value" -ge "$min" ] && [ "$value" -le "$max" ] \ ++ || fail "$name $key=$value outside [$min,$max]" ++} ++ ++assert_scan_endpoints() { ++ name=$1 ++ assert_line "$name" "endpoint_count=5" ++ assert_line "$name" "endpoint[0]=4.000000,-5.000000,1.500000,0.000000" ++ assert_line "$name" "endpoint[1]=4.000000,-7.000000,1.500000,0.000000" ++ assert_line "$name" "endpoint[2]=4.000000,-7.000000,10.000000,0.000000" ++ assert_line "$name" "endpoint[3]=4.000000,-3.000000,10.000000,0.000000" ++ assert_line "$name" "endpoint[4]=4.000000,-3.000000,1.500000,0.000000" ++} ++ ++assert_current_setpoint_published() { ++ name=$1 ++ assert_line "$name" "setpoint[0]=4.000000,-5.000000,10.000000,0.000000" ++} ++ ++make_wrapper() { ++ header=$1 ++ mkdir -p "$TMP/stubs/$(dirname "$header")" ++ printf '#pragma once\n#include "%s/common.hpp"\n' "$FIXTURES" > "$TMP/stubs/$header" ++} ++ ++for header in \ ++ ros/ros.h \ ++ std_msgs/String.h \ ++ mavros_msgs/State.h \ ++ mavros_msgs/ExtendedState.h \ ++ mavros_msgs/CommandBool.h \ ++ mavros_msgs/CommandTOL.h \ ++ mavros_msgs/SetMode.h \ ++ mavros_msgs/GlobalPositionTarget.h \ ++ geometry_msgs/PoseStamped.h \ ++ geometry_msgs/PoseWithCovarianceStamped.h \ ++ geometry_msgs/PoseArray.h \ ++ geometry_msgs/TransformStamped.h \ ++ sensor_msgs/NavSatFix.h \ ++ tf/tf.h \ ++ tf2/LinearMath/Quaternion.h \ ++ tf2_ros/transform_listener.h \ ++ tf2_ros/static_transform_broadcaster.h \ ++ tf2_ros/transform_broadcaster.h ++do ++ make_wrapper "$header" ++done ++ ++CXX=${CXX:-g++} ++OBJDIR=$TMP/obj ++mkdir -p "$OBJDIR" ++ ++for src in "$REPO"/src/offboard_control/*.cpp ++do ++ obj="$OBJDIR/$(basename "$src" .cpp).o" ++ "$CXX" -std=c++11 -Dmain=offboard_control_real_main \ ++ -I"$TMP/stubs" -I"$REPO/src/offboard_control" \ ++ -c "$src" -o "$obj" >"$TMP/build.out" 2>"$TMP/build.err" \ ++ || { cat "$TMP/build.err" >&2; fail "build object $(basename "$src")"; } ++done ++ ++"$CXX" -std=c++11 \ ++ -I"$TMP/stubs" -I"$REPO/src/offboard_control" \ ++ -c "$FIXTURES/harness.cpp" -o "$OBJDIR/harness.o" >"$TMP/build.out" 2>"$TMP/build.err" \ ++ || { cat "$TMP/build.err" >&2; fail "build harness"; } ++ ++BIN=$TMP/offboard_scan_harness ++"$CXX" "$OBJDIR"/*.o -o "$BIN" >"$TMP/build.out" 2>"$TMP/build.err" \ ++ || { cat "$TMP/build.err" >&2; fail "link"; } ++ ++cd "$TMP" ++ ++ ++ ++ ++"$BIN" steady >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_line F1 "scenario=steady" ++assert_scan_endpoints F1 ++ ++assert_count_between F1 setpoint_count 200 205 ++assert_current_setpoint_published F1 ++grep -Fq "Scanning building" err || fail "F1 missing scan log" ++! grep -Fq "2*MAX_ATTEMPTS reached while scanning building. Aborting." err \ ++ || fail "F1 unexpected warning" ++ ++ ++ ++ ++"$BIN" fresh-marker >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_line F2 "scenario=fresh-marker" ++assert_scan_endpoints F2 ++ ++assert_count_between F2 setpoint_count 0 5 ++if [ "$(value_for setpoint_count)" -gt 0 ]; then ++ assert_current_setpoint_published F2 ++fi ++grep -Fq "Scanning building" err || fail "F2 missing scan log" ++! grep -Fq "2*MAX_ATTEMPTS reached while scanning building. Aborting." err \ ++ || fail "F2 unexpected warning" ++ ++ ++ ++ ++"$BIN" warning >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_line F3 "scenario=warning" ++assert_scan_endpoints F3 ++ ++assert_count_between F3 setpoint_count 600 4000 ++assert_current_setpoint_published F3 ++grep -Fq "Scanning building" err || fail "F3 missing scan log" ++ ++grep -R --include='*.cpp' --include='*.h' -Fq \ ++ "2*MAX_ATTEMPTS reached while scanning building. Aborting." "$REPO/src/offboard_control" \ ++ || fail "F3 missing warning text" ++ ++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-002791/tests/test.sh b/tasks/format-code-task-002791/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c21ab2249e395d15b6617dbc4d5f59f65cf10f6a --- /dev/null +++ b/tasks/format-code-task-002791/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/common.hpp +usercase-test-coderl/fixtures/harness.cpp +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-002791/tests/test_command.sh b/tasks/format-code-task-002791/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002791/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-002796/environment/Dockerfile b/tasks/format-code-task-002796/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..59dd999cd69b4d11b613369eb9f0cb3b710bfe6c --- /dev/null +++ b/tasks/format-code-task-002796/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:353447cd94324fe25df177e87459c2f456f25e4580442b8431f0d612797aeafd diff --git a/tasks/format-code-task-002796/environment/setup/files/blocklist b/tasks/format-code-task-002796/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002796/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002796/environment/setup/setup.sh b/tasks/format-code-task-002796/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002796/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002796/tests/test.patch b/tasks/format-code-task-002796/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f5ba2155e9cc0d43250923f39aca154ccf00691b --- /dev/null +++ b/tasks/format-code-task-002796/tests/test.patch @@ -0,0 +1,122 @@ +diff --git a/packages/tailwindcss/src/utilities.test.ts b/packages/tailwindcss/src/utilities.test.ts +index 23d2bb21..d9c58ad0 100644 +--- a/packages/tailwindcss/src/utilities.test.ts ++++ b/packages/tailwindcss/src/utilities.test.ts +@@ -15859,3 +15859,95 @@ describe('custom utilities', () => { + ) + }) + }) ++ ++describe('logical inline/block precedence (issue: ps/pe vs px)', () => { ++ async function compile(candidates: string[]) { ++ return compileCss( ++ css` ++ @theme { ++ --spacing-5: 1.25rem; ++ --spacing-10: 2.5rem; ++ } ++ @tailwind utilities; ++ `, ++ candidates, ++ ) ++ } ++ ++ ++ ++ ++ test('ps-10 overrides px-5 (ps rule comes after px rule)', async () => { ++ let out = await compile(['px-5', 'ps-10']) ++ let pxIdx = out.indexOf('.px-5') ++ let psIdx = out.indexOf('.ps-10') ++ expect(pxIdx).toBeGreaterThan(-1) ++ expect(psIdx).toBeGreaterThan(-1) ++ expect(psIdx).toBeGreaterThan(pxIdx) ++ }) ++ ++ test('pe-10 overrides px-5 (pe rule comes after px rule)', async () => { ++ let out = await compile(['px-5', 'pe-10']) ++ let pxIdx = out.indexOf('.px-5') ++ let peIdx = out.indexOf('.pe-10') ++ expect(pxIdx).toBeGreaterThan(-1) ++ expect(peIdx).toBeGreaterThan(-1) ++ expect(peIdx).toBeGreaterThan(pxIdx) ++ }) ++ ++ test('scroll-ps-10 overrides scroll-px-5 (scroll-ps rule comes after scroll-px rule)', async () => { ++ let out = await compile(['scroll-px-5', 'scroll-ps-10']) ++ let pxIdx = out.indexOf('.scroll-px-5') ++ let psIdx = out.indexOf('.scroll-ps-10') ++ expect(pxIdx).toBeGreaterThan(-1) ++ expect(psIdx).toBeGreaterThan(-1) ++ expect(psIdx).toBeGreaterThan(pxIdx) ++ }) ++ ++ test('scroll-pe-10 overrides scroll-px-5 (scroll-pe rule comes after scroll-px rule)', async () => { ++ let out = await compile(['scroll-px-5', 'scroll-pe-10']) ++ let pxIdx = out.indexOf('.scroll-px-5') ++ let peIdx = out.indexOf('.scroll-pe-10') ++ expect(pxIdx).toBeGreaterThan(-1) ++ expect(peIdx).toBeGreaterThan(-1) ++ expect(peIdx).toBeGreaterThan(pxIdx) ++ }) ++ ++ test('scroll-ms-10 overrides scroll-mx-5 (scroll-ms rule comes after scroll-mx rule)', async () => { ++ let out = await compile(['scroll-mx-5', 'scroll-ms-10']) ++ let mxIdx = out.indexOf('.scroll-mx-5') ++ let msIdx = out.indexOf('.scroll-ms-10') ++ expect(mxIdx).toBeGreaterThan(-1) ++ expect(msIdx).toBeGreaterThan(-1) ++ expect(msIdx).toBeGreaterThan(mxIdx) ++ }) ++ ++ test('scroll-me-10 overrides scroll-mx-5 (scroll-me rule comes after scroll-mx rule)', async () => { ++ let out = await compile(['scroll-mx-5', 'scroll-me-10']) ++ let mxIdx = out.indexOf('.scroll-mx-5') ++ let meIdx = out.indexOf('.scroll-me-10') ++ expect(mxIdx).toBeGreaterThan(-1) ++ expect(meIdx).toBeGreaterThan(-1) ++ expect(meIdx).toBeGreaterThan(mxIdx) ++ }) ++ ++ ++ ++ test('ms-10 overrides mx-5 (preservation, ms rule comes after mx rule)', async () => { ++ let out = await compile(['mx-5', 'ms-10']) ++ let mxIdx = out.indexOf('.mx-5') ++ let msIdx = out.indexOf('.ms-10') ++ expect(mxIdx).toBeGreaterThan(-1) ++ expect(msIdx).toBeGreaterThan(-1) ++ expect(msIdx).toBeGreaterThan(mxIdx) ++ }) ++ ++ ++ test('px-5 still emits padding-left and padding-right', async () => { ++ let out = await compile(['px-5']) ++ expect(out).toContain('padding-left: var(--spacing-5, 1.25rem)') ++ expect(out).toContain('padding-right: var(--spacing-5, 1.25rem)') ++ ++ expect(out).not.toContain('--tw-sort') ++ }) ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..a950c57b +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd packages/tailwindcss && npx vitest run src/utilities.test.ts -t \"logical inline/block precedence\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++cd packages/tailwindcss && npx vitest run src/utilities.test.ts -t "logical inline/block precedence" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002796/tests/test.sh b/tasks/format-code-task-002796/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3123e87652720dba987507d226ad931f6b5d90da --- /dev/null +++ b/tasks/format-code-task-002796/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/tailwindcss/src/utilities.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-002796/tests/test_command.sh b/tasks/format-code-task-002796/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002796/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002797/environment/Dockerfile b/tasks/format-code-task-002797/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..428d59b89abfdbaffbfdcba2a7965b7ace368490 --- /dev/null +++ b/tasks/format-code-task-002797/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8ad572cfb2c06a431d301585fc4c4d409f1e1c1c78dfc0c90a1af1e3c86aaabc diff --git a/tasks/format-code-task-002797/environment/setup/files/blocklist b/tasks/format-code-task-002797/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002797/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002797/environment/setup/setup.sh b/tasks/format-code-task-002797/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002797/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002797/tests/test.patch b/tasks/format-code-task-002797/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..21800653e25f19ef317784fbb55759af506e7ee2 --- /dev/null +++ b/tasks/format-code-task-002797/tests/test.patch @@ -0,0 +1,153 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..e0b01311 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest tests/to-path.test.js tests/evaluateTailwindFunctions.test.js -t \"bracket-issue-fix|should parse simple bracket|should preserve dots inside|should split sequential\""] ++} +diff --git a/tests/evaluateTailwindFunctions.test.js b/tests/evaluateTailwindFunctions.test.js +index 01d7393b..57ccdd01 100644 +--- a/tests/evaluateTailwindFunctions.test.js ++++ b/tests/evaluateTailwindFunctions.test.js +@@ -575,6 +575,106 @@ test('transition-duration values are joined when an array', () => { + }) + }) + ++test('bracket-issue-fix: theme value with bracket notation resolves dotted key (single quotes outside)', () => { ++ let input = css` ++ .dialog { ++ font-size: theme('spacing[4.5]'); ++ } ++ ` ++ ++ let output = css` ++ .dialog { ++ font-size: 1.125rem; ++ } ++ ` ++ ++ return run(input, { ++ theme: { ++ spacing: { ++ '4.5': '1.125rem', ++ }, ++ }, ++ }).then((result) => { ++ expect(result.css).toEqual(output) ++ expect(result.warnings().length).toBe(0) ++ }) ++}) ++ ++test('bracket-issue-fix: theme value with bracket notation resolves dotted key (double quotes outside)', () => { ++ let input = css` ++ .dialog { ++ font-size: theme("spacing[4.5]"); ++ } ++ ` ++ ++ let output = css` ++ .dialog { ++ font-size: 1.125rem; ++ } ++ ` ++ ++ return run(input, { ++ theme: { ++ spacing: { ++ '4.5': '1.125rem', ++ }, ++ }, ++ }).then((result) => { ++ expect(result.css).toEqual(output) ++ expect(result.warnings().length).toBe(0) ++ }) ++}) ++ ++test('bracket-issue-fix: theme bracket notation resolves key containing dot', () => { ++ let input = css` ++ .heading { ++ color: theme('colors[the.brand]'); ++ } ++ ` ++ ++ let output = css` ++ .heading { ++ color: #abcdef; ++ } ++ ` ++ ++ return run(input, { ++ theme: { ++ colors: { ++ 'the.brand': '#abcdef', ++ }, ++ }, ++ }).then((result) => { ++ expect(result.css).toEqual(output) ++ expect(result.warnings().length).toBe(0) ++ }) ++}) ++ ++test('bracket-issue-fix: regular dot notation still resolves after fix', () => { ++ let input = css` ++ .heading { ++ color: theme('colors.yellow'); ++ } ++ ` ++ ++ let output = css` ++ .heading { ++ color: #f7cc50; ++ } ++ ` ++ ++ return run(input, { ++ theme: { ++ colors: { ++ yellow: '#f7cc50', ++ }, ++ }, ++ }).then((result) => { ++ expect(result.css).toEqual(output) ++ expect(result.warnings().length).toBe(0) ++ }) ++}) ++ + test('basic screen function calls are expanded', () => { + let input = css` + @media screen(sm) { +diff --git a/tests/to-path.test.js b/tests/to-path.test.js +index dbd39c54..8d7f9594 100644 +--- a/tests/to-path.test.js ++++ b/tests/to-path.test.js +@@ -15,3 +15,15 @@ it.each` + `('should convert "$input" to "$output"', ({ input, output }) => { + expect(toPath(input)).toEqual(output) + }) ++ ++it('should parse simple bracket notation into clean segments', () => { ++ expect(toPath('a[b].c')).toEqual(['a', 'b', 'c']) ++}) ++ ++it('should preserve dots inside bracket segments', () => { ++ expect(toPath('a[b.c].e.f')).toEqual(['a', 'b.c', 'e', 'f']) ++}) ++ ++it('should split sequential bracket segments without leaving empty strings', () => { ++ expect(toPath('a[b][c][d]')).toEqual(['a', 'b', 'c', 'd']) ++}) +diff --git 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/to-path.test.js tests/evaluateTailwindFunctions.test.js -t "bracket-issue-fix|should parse simple bracket|should preserve dots inside|should split sequential" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002797/tests/test.sh b/tasks/format-code-task-002797/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fac79572c4573def8808f8001e02b6a6d3f238d1 --- /dev/null +++ b/tasks/format-code-task-002797/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/evaluateTailwindFunctions.test.js +tests/to-path.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-002797/tests/test_command.sh b/tasks/format-code-task-002797/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002797/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002798/environment/Dockerfile b/tasks/format-code-task-002798/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..10f9af8df4708831ee17f69669cc42a4e556609c --- /dev/null +++ b/tasks/format-code-task-002798/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:84f8e63c600fc841ca54fd968a2f301f23390ee7b545412634b73df546ae2064 diff --git a/tasks/format-code-task-002798/environment/setup/files/blocklist b/tasks/format-code-task-002798/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002798/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002798/environment/setup/setup.sh b/tasks/format-code-task-002798/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002798/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002798/tests/test.patch b/tasks/format-code-task-002798/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bb25a79c8b67de5c835216f60e6859ce2c86e40e --- /dev/null +++ b/tasks/format-code-task-002798/tests/test.patch @@ -0,0 +1,371 @@ +diff --git a/usercase-test-coderl/html_string_typing.test.js b/usercase-test-coderl/html_string_typing.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/html_string_typing.test.js +@@ -0,0 +1,336 @@ ++ ++ ++ ++ ++jest.mock('raf', () => { ++ const callbacks = new Map(); ++ let nextHandle = 1; ++ ++ const raf = jest.fn(callback => { ++ const handle = nextHandle; ++ nextHandle += 1; ++ callbacks.set(handle, callback); ++ return handle; ++ }); ++ ++ const cancel = jest.fn(handle => { ++ callbacks.delete(handle); ++ }); ++ ++ return { ++ __esModule: true, ++ default: raf, ++ cancel, ++ __activeCount: () => callbacks.size, ++ __flushOneFrame: timestamp => { ++ const frameCallbacks = Array.from(callbacks.values()); ++ callbacks.clear(); ++ frameCallbacks.forEach(callback => callback(timestamp)); ++ }, ++ __reset: () => { ++ callbacks.clear(); ++ nextHandle = 1; ++ raf.mockClear(); ++ cancel.mockClear(); ++ }, ++ }; ++}); ++ ++import Typewriter from '../src/core'; ++import { __activeCount, __flushOneFrame, __reset } from 'raf'; ++ ++let now; ++ ++const makeTypewriter = () => { ++ const container = document.createElement('div'); ++ document.body.appendChild(container); ++ const instance = new Typewriter(container, { ++ delay: 1, ++ deleteSpeed: 1, ++ skipAddStyles: true, ++ }); ++ ++ return { container, instance }; ++}; ++ ++const wrapperFor = container => container.querySelector('.Typewriter__wrapper'); ++ ++const runUntilIdle = instance => { ++ instance.start(); ++ ++ for(let i = 0; i < 200; i += 1) { ++ if(__activeCount() === 0) { ++ return; ++ } ++ ++ now += 20; ++ __flushOneFrame(now); ++ } ++ ++ throw new Error('Typewriter did not drain its animation queue'); ++}; ++ ++const summarizeChildren = node => Array.from(node.childNodes).map(child => ({ ++ nodeType: child.nodeType, ++ nodeName: child.nodeName, ++ textContent: child.textContent, ++ outerHTML: child.outerHTML || null, ++ children: Array.from(child.childNodes).map(grandchild => ({ ++ nodeType: grandchild.nodeType, ++ nodeName: grandchild.nodeName, ++ textContent: grandchild.textContent, ++ outerHTML: grandchild.outerHTML || null, ++ })), ++})); ++ ++const directTextBefore = (parent, boundaryNode) => { ++ const textNodes = []; ++ let current = parent.firstChild; ++ ++ while(current && current !== boundaryNode) { ++ textNodes.push(current); ++ current = current.nextSibling; ++ } ++ ++ return textNodes; ++}; ++ ++const directTextAfter = boundaryNode => { ++ const textNodes = []; ++ let current = boundaryNode.nextSibling; ++ ++ while(current) { ++ textNodes.push(current); ++ current = current.nextSibling; ++ } ++ ++ return textNodes; ++}; ++ ++const textContentOf = nodes => nodes.map(node => node.textContent).join(''); ++ ++const expectMixedStrongMarkup = wrapper => { ++ const strong = wrapper.querySelector('strong'); ++ expect(strong).not.toBeNull(); ++ ++ ++ expect(wrapper.innerHTML).toBe('Hello world!'); ++ expect(wrapper.textContent).toBe('Hello world!'); ++ expect(strong.parentNode).toBe(wrapper); ++ expect(strong.textContent).toBe('world'); ++ ++ const beforeStrong = directTextBefore(wrapper, strong); ++ const afterStrong = directTextAfter(strong); ++ expect(beforeStrong.length).toBeGreaterThan(0); ++ expect(afterStrong.length).toBeGreaterThan(0); ++ expect(beforeStrong.every(node => node.nodeType === 3)).toBe(true); ++ expect(afterStrong.every(node => node.nodeType === 3)).toBe(true); ++ expect(textContentOf(beforeStrong)).toBe('Hello '); ++ expect(textContentOf(afterStrong)).toBe('!'); ++}; ++ ++const expectNestedMarkupInParent = parent => { ++ const em = parent.querySelector('em'); ++ const strong = parent.querySelector('strong'); ++ expect(em).not.toBeNull(); ++ expect(strong).not.toBeNull(); ++ ++ ++ expect(parent.innerHTML).toBe('A B!'); ++ expect(parent.textContent).toBe('A B!'); ++ expect(em.parentNode).toBe(parent); ++ expect(strong.parentNode).toBe(em); ++ expect(strong.textContent).toBe('B'); ++ ++ const afterEm = directTextAfter(em); ++ expect(afterEm.length).toBeGreaterThan(0); ++ expect(afterEm.every(node => node.nodeType === 3)).toBe(true); ++ expect(textContentOf(afterEm)).toBe('!'); ++}; ++ ++beforeEach(() => { ++ now = 1000; ++ jest.spyOn(Date, 'now').mockImplementation(() => now); ++ __reset(); ++ document.body.innerHTML = ''; ++ document.head.innerHTML = ''; ++ window.___TYPEWRITER_JS_STYLES_ADDED___ = false; ++}); ++ ++afterEach(() => { ++ Date.now.mockRestore(); ++ __reset(); ++ document.body.innerHTML = ''; ++ document.head.innerHTML = ''; ++}); ++ ++test('typeString renders mixed text and markup as DOM nodes', () => { ++ ++ ++ const { container, instance } = makeTypewriter(); ++ ++ instance.typeString('Hello world!'); ++ runUntilIdle(instance); ++ ++ expectMixedStrongMarkup(wrapperFor(container)); ++ ++ instance.stop(); ++}); ++ ++test('pasteString renders the same HTML structure as pasted chunks', () => { ++ ++ ++ const { container, instance } = makeTypewriter(); ++ ++ instance.pasteString('Hello world!'); ++ runUntilIdle(instance); ++ ++ ++ expect(wrapperFor(container).innerHTML).toBe('Hello world!'); ++ expect(summarizeChildren(wrapperFor(container))).toEqual([ ++ { nodeType: 3, nodeName: '#text', textContent: 'Hello ', outerHTML: null, children: [] }, ++ { ++ nodeType: 1, ++ nodeName: 'STRONG', ++ textContent: 'world', ++ outerHTML: 'world', ++ children: [ ++ { nodeType: 3, nodeName: '#text', textContent: 'world', outerHTML: null }, ++ ], ++ }, ++ { nodeType: 3, nodeName: '#text', textContent: '!', outerHTML: null, children: [] }, ++ ]); ++ ++ instance.stop(); ++}); ++ ++test('nested markup can be inserted inside an explicit parent node', () => { ++ ++ ++ const { container, instance } = makeTypewriter(); ++ const parent = document.createElement('section'); ++ parent.className = 'slot'; ++ wrapperFor(container).appendChild(parent); ++ ++ instance.typeString('A B!', parent); ++ runUntilIdle(instance); ++ ++ expect(wrapperFor(container).firstChild).toBe(parent); ++ expectNestedMarkupInParent(parent); ++ ++ instance.stop(); ++}); ++ ++test('ordinary plain text still uses the typing path', () => { ++ ++ ++ const { container, instance } = makeTypewriter(); ++ ++ instance.typeString('Plain words!'); ++ runUntilIdle(instance); ++ ++ expect(wrapperFor(container).innerHTML).toBe('Plain words!'); ++ expect(summarizeChildren(wrapperFor(container))).toEqual([ ++ { nodeType: 3, nodeName: '#text', textContent: 'P', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 'l', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 'a', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 'i', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 'n', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: ' ', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 'w', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 'o', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 'r', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 'd', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: 's', outerHTML: null, children: [] }, ++ { nodeType: 3, nodeName: '#text', textContent: '!', outerHTML: null, children: [] }, ++ ]); ++ ++ instance.stop(); ++}); ++ ++test('ordinary plain text still uses the pasting path', () => { ++ ++ ++ const { container, instance } = makeTypewriter(); ++ ++ instance.pasteString('Plain words!'); ++ runUntilIdle(instance); ++ ++ expect(wrapperFor(container).innerHTML).toBe('Plain words!'); ++ expect(summarizeChildren(wrapperFor(container))).toEqual([ ++ { nodeType: 3, nodeName: '#text', textContent: 'Plain words!', outerHTML: null, children: [] }, ++ ]); ++ ++ instance.stop(); ++}); ++ ++test('construction with an element supports HTML rendering', () => { ++ ++ ++ const { container, instance } = makeTypewriter(); ++ ++ instance.typeString('Hello world!'); ++ runUntilIdle(instance); ++ ++ ++ expectMixedStrongMarkup(wrapperFor(container)); ++ ++ instance.stop(); ++}); ++ ++test('started HTML typing produces the required DOM', () => { ++ ++ ++ const { container, instance } = makeTypewriter(); ++ ++ instance.typeString('Hello world!'); ++ runUntilIdle(instance); ++ ++ ++ expectMixedStrongMarkup(wrapperFor(container)); ++ ++ instance.stop(); ++}); ++ ++test('two instances keep independent DOM state for the same HTML input', () => { ++ ++ ++ const first = makeTypewriter(); ++ const second = makeTypewriter(); ++ ++ first.instance.typeString('Hello world!'); ++ runUntilIdle(first.instance); ++ ++ expect(wrapperFor(first.container).innerHTML).toBe('Hello world!'); ++ expect(wrapperFor(second.container).innerHTML).toBe(''); ++ ++ second.instance.typeString('Hello world!'); ++ runUntilIdle(second.instance); ++ ++ expect(wrapperFor(first.container).innerHTML).toBe('Hello world!'); ++ expect(wrapperFor(second.container).innerHTML).toBe('Hello world!'); ++ ++ first.instance.stop(); ++ second.instance.stop(); ++}); ++ ++test('same HTML input renders consistently across fresh instances', () => { ++ ++ ++ const outputs = []; ++ ++ for(let i = 0; i < 3; i += 1) { ++ const { container, instance } = makeTypewriter(); ++ instance.typeString('Hello world!'); ++ runUntilIdle(instance); ++ outputs.push(wrapperFor(container).innerHTML); ++ instance.stop(); ++ } ++ ++ ++ expect(outputs).toEqual([ ++ 'Hello world!', ++ 'Hello world!', ++ 'Hello world!', ++ ]); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export npm_config_offline=true ++export npm_config_audit=false ++export npm_config_fund=false ++ ++if [ ! -x ./node_modules/.bin/jest ]; then ++ echo "Missing local Jest install at /workspace/repo/node_modules/.bin/jest" >&2 ++ exit 1 ++fi ++ ++exec ./node_modules/.bin/jest --env=jsdom /workspace/repo/usercase-test-coderl/html_string_typing.test.js --runInBand diff --git a/tasks/format-code-task-002798/tests/test.sh b/tasks/format-code-task-002798/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f21aa4613997ffc0ce36a89097c223b6e89c7fe --- /dev/null +++ b/tasks/format-code-task-002798/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/html_string_typing.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-002798/tests/test_command.sh b/tasks/format-code-task-002798/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002798/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-002900/environment/Dockerfile b/tasks/format-code-task-002900/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1d2e0e98e55a4da96c44499696b157c3da185e68 --- /dev/null +++ b/tasks/format-code-task-002900/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8726b60578e221bfa3bf81ab0021e6b7b15e89f45f374216cc999930bd682d9b diff --git a/tasks/format-code-task-002900/environment/setup/files/blocklist b/tasks/format-code-task-002900/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002900/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002900/environment/setup/setup.sh b/tasks/format-code-task-002900/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002900/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002900/tests/test.patch b/tasks/format-code-task-002900/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..35fa44089b26fc1e2d55b206afa5a30d6ab4f321 --- /dev/null +++ b/tasks/format-code-task-002900/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/cmds/core/dhclient/dhclient_test.go b/cmds/core/dhclient/dhclient_test.go +index ef4ef021ab..b3eaa3add0 100644 +--- a/cmds/core/dhclient/dhclient_test.go ++++ b/cmds/core/dhclient/dhclient_test.go +@@ -19,7 +19,7 @@ var tests = []struct { + { + iface: "nosuchanimal", + isIPv4: "-ipv4=true", +- out: "No interfaces match nosuchanimal\n", ++ out: "no interfaces match nosuchanimal\n", + }, + } + +diff --git a/pkg/dhclient/iface_test.go b/pkg/dhclient/iface_test.go +new file mode 100644 +index 0000000000..a045308f51 +--- /dev/null ++++ b/pkg/dhclient/iface_test.go +@@ -0,0 +1,27 @@ ++ ++ ++ ++ ++package dhclient ++ ++import "testing" ++ ++ ++func TestInterfaces(t *testing.T) { ++ l, err := Interfaces(".") ++ if err != nil { ++ t.Fatalf("Checking \".\": got %v, want nil", err) ++ } ++ if len(l) == 0 { ++ t.Fatalf("Checking \".\": got no elements, want at least one") ++ } ++ ++ one := "^" + l[0].Attrs().Name + "$" ++ l, err = Interfaces(one) ++ if err != nil { ++ t.Fatalf("Checking %s: got %v, want nil", one, err) ++ } ++ if len(l) != 1 { ++ t.Errorf("Matching %s: got %d elements(%v), expect 1", one, len(l), l) ++ } ++} +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+3ST0vDMBgG8J37KV4QdmvTONudPAiTKSgTneexpekf1yYlSQW/vdlkm4g6hA0R ++n98lbZPmfdsn0aKr6mwm1TPrHUvsDZNkPXofx/U1T045H54O48FZL+Y8jQc9So7W0TuddXND1DNa ++u+/W7Zv/o6Jd/k5aNxO6aeYqi2x5uBr78k/jZJN/OkxTn/9ZOvD5x4dr4Wv/PH+R0Tr4hcyC4IQe ++pKOupfHk7mJ6RfalqSu1pFwbcmVlqTUybHTW1dLSWPtb/SSFC5plVhkKW2Krv8QKzawRrKhc2S0i ++f6JYF64mglpRaHO1rbhn/eY139d9p2ihXUk+rML3uNqA8sr3EYwnnPPbyejx5vJc5zkV+m32q+1Y ++uyxYVoq6kspRaPzOU7/+Wjlp8rnwXxY+Uyh0p9w5p37/5wVEk1kmtJGflBltn+yKBL99CAAAAAAA ++AAAAAAAAAAAAAADgz3oFtl8SYAAoAAA= +diff --git 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-002900/tests/test.sh b/tasks/format-code-task-002900/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..92a49e191bbcdf47a28d7b1b99706a1dec2d9aca --- /dev/null +++ b/tasks/format-code-task-002900/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' +cmds/core/dhclient/dhclient_test.go +pkg/dhclient/iface_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-002900/tests/test_command.sh b/tasks/format-code-task-002900/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002900/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002906/environment/Dockerfile b/tasks/format-code-task-002906/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..51c7971743d6e894e86c856a76c5acaea1ee4a3a --- /dev/null +++ b/tasks/format-code-task-002906/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6565ca12cdce1ee0c9ac25a47cea4f6385e8ca732f6576a472aefeabc7aefe79 diff --git a/tasks/format-code-task-002906/environment/setup/files/blocklist b/tasks/format-code-task-002906/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002906/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002906/environment/setup/setup.sh b/tasks/format-code-task-002906/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002906/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002906/tests/test.patch b/tasks/format-code-task-002906/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2a6b83f4a78d643ab4ecd8ef1fddf7021fcfb963 --- /dev/null +++ b/tasks/format-code-task-002906/tests/test.patch @@ -0,0 +1,367 @@ +diff --git a/runtime/client_http_request_test.go b/runtime/client_http_request_test.go +index d3fddf192..3493484eb 100644 +--- a/runtime/client_http_request_test.go ++++ b/runtime/client_http_request_test.go +@@ -263,7 +263,7 @@ func TestMakingClientCallWithRespHeaders(t *testing.T) { + + expectedValues := map[string]interface{}{ + "msg": "Finished an outgoing client HTTP request", +- "env": "production", ++ "env": "test", + "clientID": "bar", + "Response-Header-Example-Header": "Example-Value", + "statusCode": float64(200), +diff --git a/runtime/logger_metrics_test.go b/runtime/logger_metrics_test.go +deleted file mode 100644 +index 60ccc68fd..000000000 +--- a/runtime/logger_metrics_test.go ++++ /dev/null +@@ -1,77 +0,0 @@ +-// Copyright (c) 2019 Uber Technologies, Inc. +-// +-// Permission is hereby granted, free of charge, to any person obtaining a copy +-// of this software and associated documentation files (the "Software"), to deal +-// in the Software without restriction, including without limitation the rights +-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-// copies of the Software, and to permit persons to whom the Software is +-// furnished to do so, subject to the following conditions: +-// +-// The above copyright notice and this permission notice shall be included in +-// all copies or substantial portions of the Software. +-// +-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-// THE SOFTWARE. +- +-package zanzibar_test +- +-import ( +- "io/ioutil" +- "testing" +- +- "github.com/stretchr/testify/assert" +- +- "github.com/uber-go/tally" +- zanzibar "github.com/uber/zanzibar/runtime" +- "go.uber.org/zap" +- "go.uber.org/zap/zapcore" +-) +- +-func TestLoggingZapCore(t *testing.T) { +- metricsScope := tally.NewTestScope("test", nil) +- +- tempLogger := zap.New( +- zanzibar.NewInstrumentedZapCore( +- zapcore.NewCore( +- zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()), +- zapcore.AddSync(ioutil.Discard), +- zap.DebugLevel, +- ), +- metricsScope, +- ), +- ) +- +- tempLogger.Debug("debug msg") +- tempLogger.Info("info msg") +- tempLogger.Warn("warn msg") +- tempLogger.Error("error msg") +- tempLogger.DPanic("dpanic msg") +- +- assert.Panics(t, func() { +- tempLogger.Panic("panic msg") +- }) +- +- snapshot := metricsScope.Snapshot() +- counters := snapshot.Counters() +- +- assert.Equal(t, 7, len(counters)) +- +- expectedKeys := []string{ +- "test.zap.logged.debug+", +- "test.zap.logged.info+", +- "test.zap.logged.warn+", +- "test.zap.logged.error+", +- "test.zap.logged.dpanic+", +- "test.zap.logged.panic+", +- "test.zap.logged.fatal+", +- } +- +- for _, key := range expectedKeys { +- assert.Contains(t, counters, key, "should contain %s", key) +- } +-} +diff --git a/runtime/server_http_request_test.go b/runtime/server_http_request_test.go +index 4b382bd9a..a53d0eea6 100644 +--- a/runtime/server_http_request_test.go ++++ b/runtime/server_http_request_test.go +@@ -1550,7 +1550,7 @@ func TestIncomingHTTPRequestServerLog(t *testing.T) { + + expectedValues := map[string]interface{}{ + "msg": "Finished an incoming server HTTP request", +- "env": "production", ++ "env": "test", + "level": "info", + "zone": "unknown", + "service": "example-gateway", +diff --git a/test/endpoints/bar/bar_metrics_test.go b/test/endpoints/bar/bar_metrics_test.go +index 8a18c643d..2cacb4619 100644 +--- a/test/endpoints/bar/bar_metrics_test.go ++++ b/test/endpoints/bar/bar_metrics_test.go +@@ -28,7 +28,6 @@ import ( + + "github.com/stretchr/testify/assert" + "github.com/uber-go/tally" +- zanzibar "github.com/uber/zanzibar/runtime" + testGateway "github.com/uber/zanzibar/test/lib/test_gateway" + "github.com/uber/zanzibar/test/lib/util" + ) +@@ -62,7 +61,7 @@ func TestCallMetrics(t *testing.T) { + }, + ) + +- numMetrics := 13 ++ numMetrics := 12 + cg := gateway.(*testGateway.ChildProcessGateway) + cg.MetricsWaitGroup.Add(numMetrics) + +@@ -105,7 +104,6 @@ func TestCallMetrics(t *testing.T) { + "device": "ios", + "deviceversion": "carbon", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "protocol": "HTTP", + } + statusTags := map[string]string{ +@@ -118,7 +116,6 @@ func TestCallMetrics(t *testing.T) { + "device": "ios", + "deviceversion": "carbon", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "protocol": "HTTP", + } + key := tally.KeyForPrefixedStringMap("endpoint.request", endpointTags) +@@ -155,7 +152,6 @@ func TestCallMetrics(t *testing.T) { + "clientid": "bar", + "clientmethod": "Normal", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "endpointid": "bar", + "handlerid": "normal", + "regionname": "san_francisco", +@@ -170,7 +166,6 @@ func TestCallMetrics(t *testing.T) { + "clientmethod": "Normal", + "status": "200", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "endpointid": "bar", + "handlerid": "normal", + "regionname": "san_francisco", +diff --git a/test/endpoints/baz/baz_metrics_test.go b/test/endpoints/baz/baz_metrics_test.go +index c7c0ea488..3392c6808 100644 +--- a/test/endpoints/baz/baz_metrics_test.go ++++ b/test/endpoints/baz/baz_metrics_test.go +@@ -77,7 +77,7 @@ func TestCallMetrics(t *testing.T) { + headers["device"] = "ios" + headers["deviceversion"] = "carbon" + +- numMetrics := 14 ++ numMetrics := 13 + cg.MetricsWaitGroup.Add(numMetrics) + + _, err = gateway.MakeRequest( +@@ -116,7 +116,6 @@ func TestCallMetrics(t *testing.T) { + "device": "ios", + "deviceversion": "carbon", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "protocol": "HTTP", + } + statusTags := map[string]string{ +@@ -129,7 +128,6 @@ func TestCallMetrics(t *testing.T) { + "device": "ios", + "deviceversion": "carbon", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "protocol": "HTTP", + } + key := tally.KeyForPrefixedStringMap("endpoint.request", endpointTags) +@@ -194,7 +192,6 @@ func TestCallMetrics(t *testing.T) { + "targetservice": "bazService", + "targetendpoint": "SimpleService__call", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "endpointid": "baz", + "handlerid": "call", + "regionname": "san_francisco", +diff --git a/test/endpoints/tchannel/baz/baz_metrics_test.go b/test/endpoints/tchannel/baz/baz_metrics_test.go +index 498d4aaf8..7819e36f0 100644 +--- a/test/endpoints/tchannel/baz/baz_metrics_test.go ++++ b/test/endpoints/tchannel/baz/baz_metrics_test.go +@@ -74,7 +74,7 @@ func TestCallMetrics(t *testing.T) { + ) + assert.NoError(t, err) + +- numMetrics := 10 ++ numMetrics := 9 + cg.MetricsWaitGroup.Add(numMetrics) + + ctx := context.Background() +@@ -128,7 +128,6 @@ func TestCallMetrics(t *testing.T) { + "service": "test-gateway", + "endpointmethod": "SimpleService__Call", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "endpointid": "bazTChannel", + "handlerid": "call", + "device": "ios", +@@ -165,7 +164,8 @@ func TestCallMetrics(t *testing.T) { + "outbound.calls.per-attempt.latency", + } + tchannelOutboundTags := map[string]string{ +- "app": "test-gateway", ++ "app": "test-gateway", ++ + "host": zanzibar.GetHostname(), + "env": "test", + "service": "test-gateway", +@@ -201,7 +201,6 @@ func TestCallMetrics(t *testing.T) { + "targetservice": "bazService", + "targetendpoint": "SimpleService__call", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "device": "ios", + "deviceversion": "carbon", + "regionname": "san_francisco", +diff --git a/test/health_test.go b/test/health_test.go +index 7fc311f7c..eb450eae7 100644 +--- a/test/health_test.go ++++ b/test/health_test.go +@@ -138,7 +138,6 @@ func TestHealthMetrics(t *testing.T) { + "device": "ios", + "deviceversion": "carbon", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "protocol": "HTTP", + } + statusTags := map[string]string{ +@@ -151,15 +150,8 @@ func TestHealthMetrics(t *testing.T) { + "device": "ios", + "deviceversion": "carbon", + "dc": "unknown", +- "host": zanzibar.GetHostname(), + "protocol": "HTTP", + } +- allhostTags := map[string]string{ +- "env": "test", +- "service": "test-gateway", +- "dc": "unknown", +- "host": zanzibar.GetHostname(), +- } + + key := tally.KeyForPrefixedStringMap("endpoint.request", tags) + assert.Contains(t, metrics, key, "expected metric: %s", key) +@@ -171,11 +163,6 @@ func TestHealthMetrics(t *testing.T) { + ) + assert.Contains(t, metrics, statusKey, "expected metrics: %s", statusKey) + +- loggedKey := tally.KeyForPrefixedStringMap( +- "zap.logged.info", allhostTags, +- ) +- assert.Contains(t, metrics, loggedKey, "expected metrics: %s", loggedKey) +- + latencyMetric := metrics[tally.KeyForPrefixedStringMap( + "endpoint.latency", statusTags, + )] +@@ -211,13 +198,6 @@ func TestRuntimeMetrics(t *testing.T) { + + cgateway := gateway.(*testGateway.ChildProcessGateway) + +- // Expect 9 runtime metrics + 2 logged metric +- numMetrics := 12 +- cgateway.MetricsWaitGroup.Add(numMetrics) +- cgateway.MetricsWaitGroup.Wait() +- +- metrics := cgateway.M3Service.GetMetrics() +- assert.Equal(t, numMetrics, len(metrics), "expected 12 metrics") + names := []string{ + "runtime.num-cpu", + "runtime.gomaxprocs", +@@ -231,6 +211,14 @@ func TestRuntimeMetrics(t *testing.T) { + "runtime.memory.num-gc", + "runtime.memory.gc-pause-ms", + } ++ ++ ++ ++ cgateway.MetricsWaitGroup.Add(len(names) + 2) ++ cgateway.MetricsWaitGroup.Wait() ++ ++ metrics := cgateway.M3Service.GetMetrics() ++ + tags := map[string]string{ + "env": "test", + "service": "test-gateway", +diff --git a/test/lib/bench_gateway/bench_gateway.go b/test/lib/bench_gateway/bench_gateway.go +index c76b4dfaa..b38ecaf95 100644 +--- a/test/lib/bench_gateway/bench_gateway.go ++++ b/test/lib/bench_gateway/bench_gateway.go +@@ -94,6 +94,7 @@ func CreateGateway( + + seedConfig["http.port"] = int64(0) + seedConfig["tchannel.port"] = int64(0) ++ seedConfig["env"] = "test" + seedConfig["envVarsToTagInRootScope"] = []string{} + + if _, ok := seedConfig["tchannel.serviceName"]; !ok { +@@ -107,6 +108,7 @@ func CreateGateway( + } + seedConfig["tchannel.processName"] = "bench-gateway" + seedConfig["metrics.serviceName"] = "bench-gateway" ++ seedConfig["metrics.m3.includeHost"] = true + + benchGateway := &BenchGateway{ + httpClient: &http.Client{ +diff --git a/test/lib/test_gateway/test_gateway_process.go b/test/lib/test_gateway/test_gateway_process.go +index a0bab5598..29df638d2 100644 +--- a/test/lib/test_gateway/test_gateway_process.go ++++ b/test/lib/test_gateway/test_gateway_process.go +@@ -219,7 +219,7 @@ func readAddrFromStdout(testGateway *ChildProcessGateway, reader *bufio.Reader) + return &MalformedStdoutError{ + Type: "malformed.stdout", + StdoutLine: msg, +- Message: "Could not find real http/tchannle address in server stdout", ++ Message: "Could not find real http/tchannel address in server stdout", + } + } + +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+2UbW/TMBDH+9qf4tYh3qDYTdoUCTQkJKaBxDTE4B3SlMROY5HYkR+6qtqHx3lg ++6xDrQNoEiPu9iXN3vvP5/gnNvaz5hVBrNnksZoHnado/Az8++3WcJnGSpPPFcjGZxfFylk4gfbQT ++7eCtywzAxGjt9sXd5/9HoTfzd8K6i0I3TaY4tdXD1bhn/vEy+L7PP0m7+S+WSZj/7OGOcDf/+fwP ++D1guFcszWxErHETCa2hlK8pM1oQUHHpd5IITcgjnIcK3cHL24fWnt2Cd8YXzRhCxabVxo/2IdXfF ++Vpo0X7k0ELUwfTK4mDUFW0lX+ZwGpTGfCzMltYLIluq60t5wts3UVuZZ2BcOdKxsqA8nGmKazEFa ++yAon14JwsY7spXRFBavRmbxiwcqUr2u4uoJweNGleKeCAoJpVUsuQJagtIPWCCuUI+H1AMZvAqL1 ++GPT0JtNLcJVQBAL9XTXtsPamDk2dv4dID5tokBldbWFaOdfaF2y3r9PMOmEaqbhlfTAzohaZFZZx ++falqnXG2ntF4TueDPxrfoloqv4myhi8XY4FpX7/T9GZb3io9HKyFnT1DNmDeGlbrIqt7MfTGIbpq ++NIdnm7sjTAORKfvG2a0+e8tOKVLK3dteC8W1AS7asBCqkMJ2YvvFyY+zGnJ1aT961fW8CvrsRGRv ++FBnH8enZm8/vj490Wf5GCRJk06Xqpv6lb5Uy45WTjWCU0mtbF8NCD62WytnwIZn97u0+d5BrppSo ++fx5H/vTPAkEQBEEQBEEQBEEQBEEQBEEQBEEQBEGQv5JvrBC4dgAoAAA= +diff --git 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-002906/tests/test.sh b/tasks/format-code-task-002906/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..99894aad575166dffea32a679dc0b86946b903cd --- /dev/null +++ b/tasks/format-code-task-002906/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=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 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/client_http_request_test.go +runtime/logger_metrics_test.go +runtime/server_http_request_test.go +test/endpoints/bar/bar_metrics_test.go +test/endpoints/baz/baz_metrics_test.go +test/endpoints/tchannel/baz/baz_metrics_test.go +test/health_test.go +test/lib/bench_gateway/bench_gateway.go +test/lib/test_gateway/test_gateway_process.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-002906/tests/test_command.sh b/tasks/format-code-task-002906/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002906/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002908/environment/Dockerfile b/tasks/format-code-task-002908/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5813723899c1833b5bb70748515d44526276af9d --- /dev/null +++ b/tasks/format-code-task-002908/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1821fd7c6bb7bb5dcca1e3d89f6f207c33ea7bea05290a4e92416044acac626a diff --git a/tasks/format-code-task-002908/environment/setup/files/blocklist b/tasks/format-code-task-002908/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002908/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002908/environment/setup/setup.sh b/tasks/format-code-task-002908/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002908/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002908/tests/test.patch b/tasks/format-code-task-002908/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8c34bc6405676ab05a68cdbdc2e31fa3cb72dd9f --- /dev/null +++ b/tasks/format-code-task-002908/tests/test.patch @@ -0,0 +1,35 @@ +diff --git a/structs_encoding_test.go b/structs_encoding_test.go +index 3dbbb39e..8a3b773f 100644 +--- a/structs_encoding_test.go ++++ b/structs_encoding_test.go +@@ -53,6 +53,9 @@ func TestJSONEncoding(t *testing.T) { + "uncles": [ + "{{.Hash1}}", + "{{.Hash2}}" ++ ], ++ "transactions": [ ++ "{{.Hash1}}" + ] + }`, + build: block, +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+3SvW6DMBQFYGae4lYZMmFshM0TdOnQDumOACNAKraEDX39OgxNFKnNkiiKON9y ++/Sf5WsesnocvXbZmSaN74UEh5VqDy7qOhcx4pvKCSxVxIZTgEcm7dXRmdr6aiKLJWv/fuWv7T4qd ++8vet82Vjx7Eymrn+dndcy19kv/mrohAh/1yFJeK3a+FvG89/95LWg0nryvVxo2n9BHWrY90uifse ++fNNTZ0mwLI9DPe5SslAyzYb2n2H2dvh4fzWN1YPp9sTiR78HAAAAAAAAAAAAAAAAAAAAAGBLfgBl ++sp3zACgAAA== +diff --git 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-002908/tests/test.sh b/tasks/format-code-task-002908/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..74bc98047ffe92269a7a477e84416eabbce8f749 --- /dev/null +++ b/tasks/format-code-task-002908/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' +structs_encoding_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-002908/tests/test_command.sh b/tasks/format-code-task-002908/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002908/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002909/environment/Dockerfile b/tasks/format-code-task-002909/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..251312b56633f357b03def92f0dc2a083c528258 --- /dev/null +++ b/tasks/format-code-task-002909/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:38ac7c10ecf00903dd5cd0343b598e892d9b60791ec253e6865a06434a4bdf48 diff --git a/tasks/format-code-task-002909/environment/setup/files/blocklist b/tasks/format-code-task-002909/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002909/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002909/environment/setup/setup.sh b/tasks/format-code-task-002909/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002909/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002909/tests/test.patch b/tasks/format-code-task-002909/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..49fa9f7e6001a4e1e24a7131223d438934ecd8b9 --- /dev/null +++ b/tasks/format-code-task-002909/tests/test.patch @@ -0,0 +1,168 @@ +diff --git a/abi/topics_test.go b/abi/topics_test.go +new file mode 100644 +index 0000000..2d6b4ce +--- /dev/null ++++ b/abi/topics_test.go +@@ -0,0 +1,141 @@ ++package abi ++ ++import ( ++ "math/big" ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++) ++ ++ ++ ++func TestTopicEncodingRoundTrip(t *testing.T) { ++ cases := []struct { ++ Type string ++ Val interface{} ++ }{ ++ {"bool", true}, ++ {"bool", false}, ++ {"uint8", uint8(255)}, ++ {"uint16", uint16(65535)}, ++ {"uint32", uint32(1)}, ++ {"uint64", uint64(20)}, ++ {"uint256", big.NewInt(1000000)}, ++ {"int8", int8(-1)}, ++ {"int32", int32(-12345)}, ++ {"int64", int64(-987654321)}, ++ {"int256", big.NewInt(-1000000)}, ++ {"address", [20]byte{0x1, 0x2, 0x3}}, ++ } ++ ++ for _, c := range cases { ++ tt, err := NewType(c.Type) ++ assert.NoError(t, err) ++ ++ word, err := EncodeTopic(tt, c.Val) ++ assert.NoError(t, err) ++ ++ got, err := ParseTopic(tt, word) ++ assert.NoError(t, err) ++ ++ assert.Equal(t, c.Val, got, "round trip failed for type %s", c.Type) ++ } ++} ++ ++ ++func TestTopicEncodingLayout(t *testing.T) { ++ ++ boolT, _ := NewType("bool") ++ word, err := EncodeTopic(boolT, true) ++ assert.NoError(t, err) ++ var expectedTrue [32]byte ++ expectedTrue[31] = 1 ++ assert.Equal(t, expectedTrue, word) ++ ++ word, err = EncodeTopic(boolT, false) ++ assert.NoError(t, err) ++ assert.Equal(t, [32]byte{}, word) ++ ++ ++ u64T, _ := NewType("uint64") ++ word, err = EncodeTopic(u64T, uint64(20)) ++ assert.NoError(t, err) ++ var expectedNum [32]byte ++ expectedNum[31] = 20 ++ assert.Equal(t, expectedNum, word) ++ ++ ++ addrT, _ := NewType("address") ++ addr := [20]byte{0x11, 0x22, 0x33} ++ word, err = EncodeTopic(addrT, addr) ++ assert.NoError(t, err) ++ for i := 0; i < 12; i++ { ++ assert.Equal(t, byte(0), word[i]) ++ } ++ assert.Equal(t, addr[:], word[12:]) ++} ++ ++ ++ ++func TestTopicParseTypes(t *testing.T) { ++ u8T, _ := NewType("uint8") ++ word, err := EncodeTopic(u8T, uint8(10)) ++ assert.NoError(t, err) ++ got, err := ParseTopic(u8T, word) ++ assert.NoError(t, err) ++ assert.Equal(t, uint8(10), got) ++ ++ i32T, _ := NewType("int32") ++ word, err = EncodeTopic(i32T, int32(-1)) ++ assert.NoError(t, err) ++ got, err = ParseTopic(i32T, word) ++ assert.NoError(t, err) ++ assert.Equal(t, int32(-1), got) ++ ++ u256T, _ := NewType("uint256") ++ word, err = EncodeTopic(u256T, big.NewInt(123456789)) ++ assert.NoError(t, err) ++ got, err = ParseTopic(u256T, word) ++ assert.NoError(t, err) ++ assert.Equal(t, big.NewInt(123456789), got) ++ ++ addrT, _ := NewType("address") ++ addr := [20]byte{0xaa, 0xbb} ++ word, err = EncodeTopic(addrT, addr) ++ assert.NoError(t, err) ++ got, err = ParseTopic(addrT, word) ++ assert.NoError(t, err) ++ assert.Equal(t, addr, got) ++} ++ ++ ++ ++func TestTopicUnsupportedTypes(t *testing.T) { ++ for _, typ := range []string{"string", "bytes", "bytes32", "uint256[]", "uint8[2]"} { ++ tt, err := NewType(typ) ++ assert.NoError(t, err) ++ ++ _, err = EncodeTopic(tt, "anything") ++ assert.Error(t, err, "EncodeTopic should reject type %s", typ) ++ ++ _, err = ParseTopic(tt, [32]byte{}) ++ assert.Error(t, err, "ParseTopic should reject type %s", typ) ++ } ++} ++ ++ ++ ++func TestTopicInvalidBool(t *testing.T) { ++ boolT, _ := NewType("bool") ++ ++ var word [32]byte ++ word[0] = 0x5 ++ _, err := ParseTopic(boolT, word) ++ assert.Error(t, err) ++ ++ ++ var word2 [32]byte ++ word2[31] = 0x2 ++ _, err = ParseTopic(boolT, word2) ++ assert.Error(t, err) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++go test ./abi/ -run 'TestAbi|TestType|TestSize' -count=1 ++ ++ ++go test ./abi/ -run 'TestTopic' -count=1 diff --git a/tasks/format-code-task-002909/tests/test.sh b/tasks/format-code-task-002909/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d8ff00e42d9198e6108453346b92d7e0e15eceef --- /dev/null +++ b/tasks/format-code-task-002909/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' +abi/topics_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-002909/tests/test_command.sh b/tasks/format-code-task-002909/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002909/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002930/environment/Dockerfile b/tasks/format-code-task-002930/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a6434ed9db6d9abcb2d2647bf31dbd680411c30e --- /dev/null +++ b/tasks/format-code-task-002930/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e1aa0f6163f67b1643e477e262b9915fe380bd397fd9e4c3342785cd92ac4642 diff --git a/tasks/format-code-task-002930/environment/setup/files/blocklist b/tasks/format-code-task-002930/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002930/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002930/environment/setup/setup.sh b/tasks/format-code-task-002930/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002930/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002930/tests/test.patch b/tasks/format-code-task-002930/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1a7d1c83548ee7bfcb23c230c8115c434d91424d --- /dev/null +++ b/tasks/format-code-task-002930/tests/test.patch @@ -0,0 +1,107 @@ +diff --git a/fasthttpadaptor/request_test.go b/fasthttpadaptor/request_test.go +index 3b6ba54ca7..1f214c2d06 100644 +--- a/fasthttpadaptor/request_test.go ++++ b/fasthttpadaptor/request_test.go +@@ -1,9 +1,10 @@ + package fasthttpadaptor + + import ( +- "github.com/valyala/fasthttp" + "net/http" + "testing" ++ ++ "github.com/valyala/fasthttp" + ) + + func BenchmarkConvertRequest(b *testing.B) { +diff --git a/header_test.go b/header_test.go +index 3ea7706007..643e8f3956 100644 +--- a/header_test.go ++++ b/header_test.go +@@ -2861,3 +2861,65 @@ func verifyTrailer(t *testing.T, r *bufio.Reader, expectedTrailers map[string]st + } + verifyResponseTrailer(t, &resp.Header, expectedTrailers) + } ++ ++func TestRequestHeader_PeekAll(t *testing.T) { ++ t.Parallel() ++ h := &RequestHeader{} ++ h.Add(HeaderConnection, "keep-alive") ++ h.Add("Content-Type", "aaa") ++ h.Add(HeaderHost, "aaabbb") ++ h.Add("User-Agent", "asdfas") ++ h.Add("Content-Length", "1123") ++ h.Add("Cookie", "foobar=baz") ++ h.Add(HeaderTrailer, "foo, bar") ++ h.Add("aaa", "aaa") ++ h.Add("aaa", "bbb") ++ ++ expectRequestHeaderAll(t, h, HeaderConnection, [][]byte{s2b("keep-alive")}) ++ expectRequestHeaderAll(t, h, "Content-Type", [][]byte{s2b("aaa")}) ++ expectRequestHeaderAll(t, h, HeaderHost, [][]byte{s2b("aaabbb")}) ++ expectRequestHeaderAll(t, h, "User-Agent", [][]byte{s2b("asdfas")}) ++ expectRequestHeaderAll(t, h, "Content-Length", [][]byte{s2b("1123")}) ++ expectRequestHeaderAll(t, h, "Cookie", [][]byte{s2b("foobar=baz")}) ++ expectRequestHeaderAll(t, h, HeaderTrailer, [][]byte{s2b("Foo, Bar")}) ++ expectRequestHeaderAll(t, h, "aaa", [][]byte{s2b("aaa"), s2b("bbb")}) ++} ++func expectRequestHeaderAll(t *testing.T, h *RequestHeader, key string, expectedValue [][]byte) { ++ if len(h.PeekAll(key)) != len(expectedValue) { ++ t.Fatalf("Unexpected size for key %q: %d. Expected %d", key, len(h.PeekAll(key)), len(expectedValue)) ++ } ++ if !reflect.DeepEqual(h.PeekAll(key), expectedValue) { ++ t.Fatalf("Unexpected value for key %q: %q. Expected %q", key, h.PeekAll(key), expectedValue) ++ } ++} ++ ++func TestResponseHeader_PeekAll(t *testing.T) { ++ t.Parallel() ++ ++ h := &ResponseHeader{} ++ h.Add(HeaderContentType, "aaa/bbb") ++ h.Add(HeaderContentEncoding, "gzip") ++ h.Add(HeaderConnection, "close") ++ h.Add(HeaderContentLength, "1234") ++ h.Add(HeaderServer, "aaaa") ++ h.Add(HeaderSetCookie, "cccc") ++ h.Add("aaa", "aaa") ++ h.Add("aaa", "bbb") ++ ++ expectResponseHeaderAll(t, h, HeaderContentType, [][]byte{s2b("aaa/bbb")}) ++ expectResponseHeaderAll(t, h, HeaderContentEncoding, [][]byte{s2b("gzip")}) ++ expectResponseHeaderAll(t, h, HeaderConnection, [][]byte{s2b("close")}) ++ expectResponseHeaderAll(t, h, HeaderContentLength, [][]byte{s2b("1234")}) ++ expectResponseHeaderAll(t, h, HeaderServer, [][]byte{s2b("aaaa")}) ++ expectResponseHeaderAll(t, h, HeaderSetCookie, [][]byte{s2b("cccc")}) ++ expectResponseHeaderAll(t, h, "aaa", [][]byte{s2b("aaa"), s2b("bbb")}) ++} ++ ++func expectResponseHeaderAll(t *testing.T, h *ResponseHeader, key string, expectedValue [][]byte) { ++ if len(h.PeekAll(key)) != len(expectedValue) { ++ t.Fatalf("Unexpected size for key %q: %d. Expected %d", key, len(h.PeekAll(key)), len(expectedValue)) ++ } ++ if !reflect.DeepEqual(h.PeekAll(key), expectedValue) { ++ t.Fatalf("Unexpected value for key %q: %q. Expected %q", key, h.PeekAll(key), expectedValue) ++ } ++} +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+DMBgGcM77FA13/pStcvKgJoaTWQx30sE7MYMWS8HLPrwdLpkadZcti/H5 ++HdqGl7c0fQhXw3NTFaTGyDuX2EmFmGbn6zytuUh4Es8FT91zzkUqPCbOdqIPht5Kw5hntLa/vXes ++/keFh/wt9bYoddtKVYV9fbpvHMs/SeeH/OOFy39xxWOPxac7ws/+ef5lxabgV1TNnjTbLVkwsqDU ++g7LXnIXRWva2traTleysNhELzKCYf0uqrFtpNndajWTsI70Mrnmbu+GBXu9dV5bny8z9TA0Z//vN ++93vtevb9GcmKTLEk2tw0zfa90nda9fS55M8ufXUAAAAAAAAAAAAAAAAAAAAAABf3BhOZENIAKAAA +diff --git 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-002930/tests/test.sh b/tasks/format-code-task-002930/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7a085d84ab0b23f8e2f94340e840c3fea35e8e0f --- /dev/null +++ b/tasks/format-code-task-002930/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' +fasthttpadaptor/request_test.go +header_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-002930/tests/test_command.sh b/tasks/format-code-task-002930/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002930/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002937/environment/Dockerfile b/tasks/format-code-task-002937/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..87563ca901a0a4c30b27ba36565a0ee5e41d6f1a --- /dev/null +++ b/tasks/format-code-task-002937/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ddad6639aadd33b7febcd15567d49a850e2832eeb4c217a585891a447b3d9a94 diff --git a/tasks/format-code-task-002937/environment/setup/files/blocklist b/tasks/format-code-task-002937/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002937/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002937/environment/setup/setup.sh b/tasks/format-code-task-002937/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002937/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002937/tests/test.patch b/tasks/format-code-task-002937/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9df614427a4f14fb04b113a83296c1595a7f993a --- /dev/null +++ b/tasks/format-code-task-002937/tests/test.patch @@ -0,0 +1,460 @@ +diff --git a/usercase-test-coderl/spec_loading_embed_options.test.ts b/usercase-test-coderl/spec_loading_embed_options.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/spec_loading_embed_options.test.ts +@@ -0,0 +1,423 @@ ++import {execFileSync} from 'node:child_process'; ++import {expect, test, vi} from 'vitest'; ++import embed, {vega} from '../src/embed'; ++ ++type ResourceMap = Record; ++ ++function makeLoader(resources: ResourceMap) { ++ const calls: string[] = []; ++ return { ++ calls, ++ async load(uri: string) { ++ calls.push(uri); ++ if (!(uri in resources)) { ++ throw new Error(`unexpected load: ${uri}`); ++ } ++ return resources[uri]; ++ }, ++ async sanitize(uri: string) { ++ return {href: uri}; ++ }, ++ }; ++} ++ ++const urlLoadedVlSpec = { ++ $schema: 'https://vega.github.io/schema/vega-lite/v6.json', ++ description: 'Remote bar chart', ++ data: {values: [{category: 'A', amount: 2}, {category: 'B', amount: 5}]}, ++ mark: 'bar', ++ encoding: { ++ x: {field: 'category', type: 'nominal'}, ++ y: {field: 'amount', type: 'quantitative'}, ++ }, ++}; ++ ++const configLoadedVlSpec = { ++ $schema: 'https://vega.github.io/schema/vega-lite/v6.json', ++ data: {values: [{category: 'A', amount: 2}]}, ++ mark: 'bar', ++ encoding: { ++ x: {field: 'category', type: 'nominal'}, ++ y: {field: 'amount', type: 'quantitative'}, ++ }, ++}; ++ ++const patchLoadedVlSpec = { ++ $schema: 'https://vega.github.io/schema/vega-lite/v6.json', ++ data: {values: [{x: 1}, {x: 2}]}, ++ mark: 'point', ++ encoding: {x: {field: 'x', type: 'quantitative'}}, ++}; ++ ++function cloneJson(value: T): T { ++ return JSON.parse(JSON.stringify(value)); ++} ++ ++async function resolvedProjection(spec = urlLoadedVlSpec) { ++ const loader = makeLoader({'/remote.vl.json': JSON.stringify(spec)}); ++ const result = await embed(document.createElement('div'), '/remote.vl.json', { ++ loader, ++ actions: false, ++ defaultStyle: false, ++ }); ++ ++ const projection = { ++ calls: loader.calls, ++ spec: cloneJson(result.spec), ++ embedOptions: { ++ actions: result.embedOptions.actions, ++ defaultStyle: result.embedOptions.defaultStyle, ++ config: result.embedOptions.config, ++ }, ++ vgSpec: { ++ description: result.vgSpec.description, ++ }, ++ }; ++ result.finalize(); ++ return projection; ++} ++ ++test('loads a URL spec through opts.loader and returns the parsed Vega-Lite object', async () => { ++ ++ ++ const actual = await resolvedProjection(); ++ ++ ++ expect(actual.calls).toContain('/remote.vl.json'); ++ expect(actual.spec).toEqual(urlLoadedVlSpec); ++ expect(actual.embedOptions.actions).toBe(false); ++ expect(actual.embedOptions.defaultStyle).toBe(false); ++ expect(actual.vgSpec.description).toBe('Remote bar chart'); ++}); ++ ++test('applies usermeta embed options and builds the view with the resolved loader options', async () => { ++ ++ ++ const spec = { ++ $schema: 'https://vega.github.io/schema/vega-lite/v6.json', ++ data: {values: [{x: 1}, {x: 2}]}, ++ mark: 'point', ++ encoding: {x: {field: 'x', type: 'quantitative'}}, ++ usermeta: { ++ embedOptions: { ++ loader: {target: '_blank'}, ++ logLevel: vega.None, ++ actions: false, ++ renderer: 'svg', ++ }, ++ }, ++ }; ++ ++ const result = await embed(document.createElement('div'), spec, {defaultStyle: false}); ++ const sanitized = await result.view.loader().sanitize('https://example.test/thing.png'); ++ ++ ++ expect(result.embedOptions).toMatchObject({ ++ loader: {target: '_blank'}, ++ logLevel: vega.None, ++ actions: false, ++ renderer: 'svg', ++ }); ++ ++ expect(sanitized).toMatchObject({target: '_blank'}); ++ result.finalize(); ++}); ++ ++test('sanitizes string defaultStyle from usermeta embed options', async () => { ++ ++ ++ document.head.querySelector('style#vega-embed-style')?.remove(); ++ const spec = { ++ $schema: 'https://vega.github.io/schema/vega-lite/v6.json', ++ data: {values: [{x: 1}]}, ++ mark: 'point', ++ encoding: {x: {field: 'x', type: 'quantitative'}}, ++ usermeta: { ++ embedOptions: { ++ defaultStyle: 'body{background:url(https://evil.example/x)}', ++ actions: false, ++ }, ++ }, ++ }; ++ ++ const result = await embed(document.createElement('div'), spec); ++ ++ expect(result.embedOptions.defaultStyle).toBe(false); ++ ++ expect(document.head.innerHTML.includes('body{background:url(https://evil.example/x)}')).toBe(false); ++ result.finalize(); ++}); ++ ++test('loads string config through the resolved loader before rendering', async () => { ++ ++ ++ const loader = makeLoader({ ++ '/chart-config.json': JSON.stringify({background: 'white', axis: {labelColor: 'firebrick'}}), ++ }); ++ ++ const result = await embed(document.createElement('div'), configLoadedVlSpec, { ++ loader, ++ config: '/chart-config.json', ++ actions: false, ++ defaultStyle: false, ++ }); ++ ++ ++ expect(loader.calls).toContain('/chart-config.json'); ++ expect(result.embedOptions.config).toEqual({background: 'white', axis: {labelColor: 'firebrick'}}); ++ expect(result.vgSpec.background).toBe('white'); ++ result.finalize(); ++}); ++ ++test('loads string patch through the resolved loader before rendering', async () => { ++ ++ ++ const loader = makeLoader({ ++ '/chart-patch.json': JSON.stringify([{op: 'add', path: '/description', value: 'Hello World!'}]), ++ }); ++ ++ const result = await embed(document.createElement('div'), patchLoadedVlSpec, { ++ loader, ++ patch: '/chart-patch.json', ++ actions: false, ++ defaultStyle: false, ++ }); ++ ++ ++ expect(loader.calls).toContain('/chart-patch.json'); ++ expect(result.embedOptions.patch).toEqual([{op: 'add', path: '/description', value: 'Hello World!'}]); ++ expect(result.vgSpec.description).toBe('Hello World!'); ++ result.finalize(); ++}); ++ ++test('uses explicit opts.loader to load external options from usermeta', async () => { ++ ++ ++ const explicitLoader = makeLoader({ ++ '/meta-config.json': JSON.stringify({background: 'mintcream'}), ++ }); ++ const spec = { ++ $schema: 'https://vega.github.io/schema/vega-lite/v6.json', ++ data: {values: [{x: 1}]}, ++ mark: 'point', ++ encoding: {x: {field: 'x', type: 'quantitative'}}, ++ usermeta: { ++ embedOptions: { ++ loader: {target: '_blank'}, ++ config: '/meta-config.json', ++ actions: false, ++ }, ++ }, ++ }; ++ ++ const result = await embed(document.createElement('div'), spec, { ++ loader: explicitLoader, ++ defaultStyle: false, ++ }); ++ ++ ++ expect(explicitLoader.calls).toContain('/meta-config.json'); ++ expect(result.embedOptions.config).toEqual({background: 'mintcream'}); ++ expect(result.vgSpec.background).toBe('mintcream'); ++ result.finalize(); ++}); ++ ++test('rejects invalid loaded spec JSON with SyntaxError', async () => { ++ ++ ++ const loader = makeLoader({'/bad-spec.json': '{bad'}); ++ ++ await expect( ++ embed(document.createElement('div'), '/bad-spec.json', {loader, actions: false, defaultStyle: false}), ++ ).rejects.toThrow(SyntaxError); ++ ++ expect(loader.calls).toContain('/bad-spec.json'); ++}); ++ ++test('rejects invalid loaded config JSON with SyntaxError', async () => { ++ ++ ++ const loader = makeLoader({'/bad-config.json': '{bad'}); ++ ++ await expect( ++ embed(document.createElement('div'), configLoadedVlSpec, { ++ loader, ++ config: '/bad-config.json', ++ actions: false, ++ defaultStyle: false, ++ }), ++ ).rejects.toThrow(SyntaxError); ++ ++ expect(loader.calls).toContain('/bad-config.json'); ++}); ++ ++test('rejects invalid loaded patch JSON with SyntaxError', async () => { ++ ++ ++ const loader = makeLoader({'/bad-patch.json': '[{"op":"add"'}); ++ ++ await expect( ++ embed(document.createElement('div'), patchLoadedVlSpec, { ++ loader, ++ patch: '/bad-patch.json', ++ actions: false, ++ defaultStyle: false, ++ }), ++ ).rejects.toThrow(SyntaxError); ++ ++ expect(loader.calls).toContain('/bad-patch.json'); ++}); ++ ++test('is referentially transparent for repeated URL spec resolution values', async () => { ++ const first = await resolvedProjection(); ++ const second = await resolvedProjection(); ++ ++ ++ expect(first.calls).toContain('/remote.vl.json'); ++ expect(first.spec).toEqual(urlLoadedVlSpec); ++ expect(first.vgSpec.description).toBe('Remote bar chart'); ++ expect(second).toEqual(first); ++}); ++ ++test('applies usermeta embed options and explicit opts on a parsed Vega spec', async () => { ++ const spec = { ++ $schema: 'https://vega.github.io/schema/vega/v6.json', ++ width: 220, ++ height: 120, ++ marks: [], ++ usermeta: { ++ embedOptions: { ++ actions: false, ++ renderer: 'svg', ++ }, ++ }, ++ }; ++ const opts = {defaultStyle: false, width: 220, height: 120}; ++ ++ const result = await embed(document.createElement('div'), spec, opts); ++ ++ ++ expect(result.spec).toBe(spec); ++ expect(result.embedOptions).toMatchObject({ ++ actions: false, ++ renderer: 'svg', ++ defaultStyle: false, ++ width: 220, ++ height: 120, ++ }); ++ result.finalize(); ++}); ++ ++test('does not reuse in-process state across different spec inputs', async () => { ++ const original = await resolvedProjection(); ++ const noise = await resolvedProjection({ ++ $schema: 'https://vega.github.io/schema/vega-lite/v6.json', ++ description: 'Noise line chart', ++ data: {values: [{x: 0, y: 1}, {x: 1, y: 3}]}, ++ mark: 'line', ++ encoding: { ++ x: {field: 'x', type: 'quantitative'}, ++ y: {field: 'y', type: 'quantitative'}, ++ }, ++ }); ++ const afterNoise = await resolvedProjection(); ++ ++ ++ expect(noise.spec.description).toBe('Noise line chart'); ++ expect(noise.vgSpec.description).toBe('Noise line chart'); ++ expect(afterNoise.spec).toEqual(original.spec); ++ expect(afterNoise.vgSpec.description).toBe(original.vgSpec.description); ++}); ++ ++test('matches fresh-process URL spec resolution output', async () => { ++ const inProcess = await resolvedProjection(); ++ const script = String.raw` ++ import {JSDOM} from 'jsdom'; ++ const dom = new JSDOM('', {resources: 'usable'}); ++ globalThis.window = dom.window; ++ globalThis.document = dom.window.document; ++ globalThis.HTMLElement = dom.window.HTMLElement; ++ globalThis.ShadowRoot = dom.window.ShadowRoot; ++ const embed = (await import('./build/embed.js')).default; ++ const spec = { ++ $schema: 'https://vega.github.io/schema/vega-lite/v6.json', ++ description: 'Remote bar chart', ++ data: {values: [{category: 'A', amount: 2}, {category: 'B', amount: 5}]}, ++ mark: 'bar', ++ encoding: { ++ x: {field: 'category', type: 'nominal'}, ++ y: {field: 'amount', type: 'quantitative'}, ++ }, ++ }; ++ const calls = []; ++ const loader = { ++ calls, ++ async load(uri) { ++ calls.push(uri); ++ if (uri !== '/remote.vl.json') throw new Error('unexpected load: ' + uri); ++ return JSON.stringify(spec); ++ }, ++ async sanitize(uri) { ++ return {href: uri}; ++ }, ++ }; ++ const result = await embed(document.createElement('div'), '/remote.vl.json', { ++ loader, ++ actions: false, ++ defaultStyle: false, ++ }); ++ const projection = { ++ calls, ++ spec: result.spec, ++ embedOptions: { ++ actions: result.embedOptions.actions, ++ defaultStyle: result.embedOptions.defaultStyle, ++ }, ++ vgSpec: { ++ description: result.vgSpec.description, ++ }, ++ }; ++ result.finalize(); ++ process.stdout.write(JSON.stringify(projection)); ++ `; ++ ++ const freshProcess = JSON.parse( ++ execFileSync(process.execPath, ['--input-type=module', '-e', script], { ++ cwd: '/workspace/repo', ++ encoding: 'utf8', ++ }), ++ ); ++ ++ ++ expect(freshProcess.calls).toContain('/remote.vl.json'); ++ expect(freshProcess.spec).toEqual(inProcess.spec); ++ expect(freshProcess.embedOptions).toMatchObject({ ++ actions: false, ++ defaultStyle: false, ++ }); ++ expect(freshProcess.vgSpec.description).toBe(inProcess.vgSpec.description); ++}); ++ ++test('uses declared loader loads rather than global fetch for URL specs', async () => { ++ const fetchSpy = vi.fn(async () => { ++ throw new Error('unexpected network fetch'); ++ }); ++ vi.stubGlobal('fetch', fetchSpy); ++ ++ try { ++ const loader = makeLoader({'/declared-spec.json': JSON.stringify(urlLoadedVlSpec)}); ++ const result = await embed(document.createElement('div'), '/declared-spec.json', { ++ loader, ++ actions: false, ++ defaultStyle: false, ++ }); ++ ++ ++ expect(cloneJson(result.spec)).toEqual(urlLoadedVlSpec); ++ expect(loader.calls).toContain('/declared-spec.json'); ++ expect(fetchSpy).toHaveBeenCalledTimes(0); ++ result.finalize(); ++ } finally { ++ vi.unstubAllGlobals(); ++ } ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,27 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096 --require=/opt/stage4a/offline-network-guard.cjs" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_offline=true ++export npm_config_update_notifier=false ++ ++test -x ./node_modules/.bin/del-cli ++test -x ./node_modules/.bin/sass ++test -x ./node_modules/.bin/rollup ++test -x ./node_modules/.bin/vitest ++ ++./node_modules/.bin/del-cli build src/style.ts ++./build-style.sh ++./node_modules/.bin/rollup -c >/dev/null ++exec ./node_modules/.bin/vitest run --config ./vitest.config.ts /workspace/repo/usercase-test-coderl/spec_loading_embed_options.test.ts diff --git a/tasks/format-code-task-002937/tests/test.sh b/tasks/format-code-task-002937/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fbc6428ebb7b8e4a07683c8c1412e32474f0c078 --- /dev/null +++ b/tasks/format-code-task-002937/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/spec_loading_embed_options.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-002937/tests/test_command.sh b/tasks/format-code-task-002937/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002937/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-002953/environment/Dockerfile b/tasks/format-code-task-002953/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c79f9aa840241b920d72d2a96564af634db24e2e --- /dev/null +++ b/tasks/format-code-task-002953/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ae0c1a015ad5e0ef0b5bfdc7a552e6fae56349c47fcca05a288da8f7e63340dd diff --git a/tasks/format-code-task-002953/environment/setup/files/blocklist b/tasks/format-code-task-002953/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002953/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002953/environment/setup/setup.sh b/tasks/format-code-task-002953/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002953/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002953/tests/test.patch b/tasks/format-code-task-002953/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..01e99390c87d1cc274f6293bd30e4098a311edf4 --- /dev/null +++ b/tasks/format-code-task-002953/tests/test.patch @@ -0,0 +1,90 @@ +diff --git a/pkg/backup/backup_pv_action_test.go b/pkg/backup/backup_pv_action_test.go +index 82eae87fc..9f8ab3319 100644 +--- a/pkg/backup/backup_pv_action_test.go ++++ b/pkg/backup/backup_pv_action_test.go +@@ -26,7 +26,10 @@ import ( + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + ) + +-func TestBackupPVAction(t *testing.T) { ++ ++ ++ ++func TestBackupPVAction_MissingVolumeName(t *testing.T) { + pvc := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "spec": map[string]interface{}{}, +@@ -34,14 +37,48 @@ func TestBackupPVAction(t *testing.T) { + } + + backup := &v1.Backup{} ++ a := NewBackupPVAction(arktest.NewLogger()) ++ ++ _, additional, err := a.Execute(pvc, backup) ++ require.NoError(t, err) ++ assert.Empty(t, additional) ++} + ++ ++ ++ ++func TestBackupPVAction_EmptyVolumeName(t *testing.T) { ++ pvc := &unstructured.Unstructured{ ++ Object: map[string]interface{}{ ++ "spec": map[string]interface{}{ ++ "volumeName": "", ++ }, ++ }, ++ } ++ ++ backup := &v1.Backup{} + a := NewBackupPVAction(arktest.NewLogger()) + + _, additional, err := a.Execute(pvc, backup) +- assert.EqualError(t, err, "unable to get spec.volumeName: key volumeName not found") ++ require.NoError(t, err) ++ assert.Empty(t, additional) ++} + +- pvc.Object["spec"].(map[string]interface{})["volumeName"] = "myVolume" +- _, additional, err = a.Execute(pvc, backup) ++ ++ ++func TestBackupPVAction_WithVolumeName(t *testing.T) { ++ pvc := &unstructured.Unstructured{ ++ Object: map[string]interface{}{ ++ "spec": map[string]interface{}{ ++ "volumeName": "myVolume", ++ }, ++ }, ++ } ++ ++ backup := &v1.Backup{} ++ a := NewBackupPVAction(arktest.NewLogger()) ++ ++ _, additional, err := a.Execute(pvc, backup) + require.NoError(t, err) + require.Len(t, additional, 1) + assert.Equal(t, ResourceIdentifier{GroupResource: pvGroupResource, Name: "myVolume"}, additional[0]) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..31766531e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["mkdir -p /tmp/arkgopath/src/github.com/heptio && ln -sfn \"$(pwd)\" /tmp/arkgopath/src/github.com/heptio/ark && GOPATH=/tmp/arkgopath:/go GO111MODULE=off go test github.com/heptio/ark/pkg/backup -run 'TestBackupPVAction_(MissingVolumeName|EmptyVolumeName|WithVolumeName)' -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++mkdir -p /tmp/arkgopath/src/github.com/heptio && ln -sfn "$(pwd)" /tmp/arkgopath/src/github.com/heptio/ark && GOPATH=/tmp/arkgopath:/go GO111MODULE=off go test github.com/heptio/ark/pkg/backup -run 'TestBackupPVAction_(MissingVolumeName|EmptyVolumeName|WithVolumeName)' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002953/tests/test.sh b/tasks/format-code-task-002953/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d6f8c09f516e823828e1740c3cfa8d8a1abb047d --- /dev/null +++ b/tasks/format-code-task-002953/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/backup/backup_pv_action_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-002953/tests/test_command.sh b/tasks/format-code-task-002953/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002953/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002954/environment/Dockerfile b/tasks/format-code-task-002954/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ef11e283d64ff7206e24050c926b96e7c93f4830 --- /dev/null +++ b/tasks/format-code-task-002954/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:68ec6866fb0025b4b435b5ced1645faa4c8fbc221a55b422674659ecdbcfab43 diff --git a/tasks/format-code-task-002954/environment/setup/files/blocklist b/tasks/format-code-task-002954/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002954/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002954/environment/setup/setup.sh b/tasks/format-code-task-002954/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002954/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002954/tests/test.patch b/tasks/format-code-task-002954/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a8d23439b74b0a4ba78c04c68e4226decb74acb1 --- /dev/null +++ b/tasks/format-code-task-002954/tests/test.patch @@ -0,0 +1,43 @@ +diff --git a/pkg/builder/container_builder_test.go b/pkg/builder/container_builder_test.go +index f5eaf320d1..6541000221 100644 +--- a/pkg/builder/container_builder_test.go ++++ b/pkg/builder/container_builder_test.go +@@ -75,7 +75,17 @@ func TestGetName(t *testing.T) { + { + name: "image name with registry hostname starting with a / will include the registry name ¯\\_(ツ)_/¯", + image: "/gcr.io/my-repo/mystery/another/my-image", +- expected: "gcr.io-my-repo-mystery-another-my-image", ++ expected: "gcr-io-my-repo-mystery-another-my-image", ++ }, ++ { ++ name: "image repository names containing _ ", ++ image: "projects.registry.vmware.com/tanzu_migrator/route-2-httpproxy:myTag", ++ expected: "tanzu-migrator-route-2-httpproxy", ++ }, ++ { ++ name: "image repository names containing . ", ++ image: "projects.registry.vmware.com/tanzu.migrator/route-2-httpproxy:myTag", ++ expected: "tanzu-migrator-route-2-httpproxy", + }, + } + +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+3SSw6CMBSF4Y5ZRTcgtEBhOYRX0ChgeK1f7ARjVCYQY/y/yb1Jm/Qkp242ni5F ++UjaTJ/aiZrExds6ep9218bWvVRj4gVBam9gX0uyW6MHYD2knpejadvh0b+38R7lL/0PZD0ne1nXa ++FG5/3O6N1f7DaOlfRXP/YaRiIdV2Ed778/7zQtris7JwqlbeV3mYpOtdz5Vn/0bZec63UwIAAAAA ++AAAAAAAAAAB45QZzAI8+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-002954/tests/test.sh b/tasks/format-code-task-002954/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..700fc7ea9f8a07ec0cd438bb6c9bb140747e4ec2 --- /dev/null +++ b/tasks/format-code-task-002954/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/builder/container_builder_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-002954/tests/test_command.sh b/tasks/format-code-task-002954/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002954/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002962/environment/Dockerfile b/tasks/format-code-task-002962/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fc0b3b916e582397947ec755d93fdcea123ce572 --- /dev/null +++ b/tasks/format-code-task-002962/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b357ef6a83355f380d92b6ead6cb6844a8ecfd75240a0cad93e7009481ac9db7 diff --git a/tasks/format-code-task-002962/environment/setup/files/blocklist b/tasks/format-code-task-002962/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002962/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002962/environment/setup/setup.sh b/tasks/format-code-task-002962/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002962/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002962/tests/test.patch b/tasks/format-code-task-002962/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e4a135a61f477b965270d9017f0962e43200d005 --- /dev/null +++ b/tasks/format-code-task-002962/tests/test.patch @@ -0,0 +1,360 @@ +diff --git a/test/wsdl-recursive-describe-test.js b/test/wsdl-recursive-describe-test.js +new file mode 100644 +index 000000000..3f0a1b2c3 +--- /dev/null ++++ b/test/wsdl-recursive-describe-test.js +@@ -0,0 +1,311 @@ ++'use strict'; ++ ++var assert = require('assert'); ++var fs = require('fs'); ++var os = require('os'); ++var path = require('path'); ++var soap = require('..'); ++ ++function writeWsdl(name, contents) { ++ var dir = path.join(os.tmpdir(), 'node-soap-recursive-' + process.pid + '-' + Date.now() + '-' + Math.floor(Math.random() * 1000000)); ++ fs.mkdirSync(dir); ++ var file = path.join(dir, name + '.wsdl'); ++ fs.writeFileSync(file, contents, 'utf8'); ++ return file; ++} ++ ++function describeClient(wsdlPath, done, verify) { ++ soap.createClient(wsdlPath, function(err, client) { ++ if (err) { ++ return done(err); ++ } ++ ++ var description; ++ try { ++ description = client.describe(); ++ } ++ catch (e) { ++ return done(e); ++ } ++ ++ try { ++ verify(description); ++ } ++ catch (verifyErr) { ++ return done(verifyErr); ++ } ++ ++ done(); ++ }); ++} ++ ++function walk(value, visitor, state) { ++ state = state || { seen: [], count: 0 }; ++ ++ if (value === null || typeof value !== 'object') { ++ return; ++ } ++ ++ if (state.seen.indexOf(value) !== -1) { ++ return; ++ } ++ ++ state.seen.push(value); ++ state.count += 1; ++ assert.ok(state.count < 1000, 'description should remain a bounded object graph'); ++ ++ visitor(value); ++ ++ Object.keys(value).forEach(function(key) { ++ walk(value[key], visitor, state); ++ }); ++} ++ ++function findValueForKey(root, keyName) { ++ var found; ++ ++ walk(root, function(obj) { ++ if (found !== undefined) { ++ return; ++ } ++ if (Object.prototype.hasOwnProperty.call(obj, keyName)) { ++ found = obj[keyName]; ++ } ++ else if (Object.prototype.hasOwnProperty.call(obj, keyName + '[]')) { ++ found = obj[keyName + '[]']; ++ } ++ }); ++ ++ return found; ++} ++ ++function assertHasKey(root, keyName) { ++ var value = findValueForKey(root, keyName); ++ assert.notStrictEqual(value, undefined, 'expected describe() output to contain key "' + keyName + '"'); ++ return value; ++} ++ ++function assertObjectField(root, keyName) { ++ var value = assertHasKey(root, keyName); ++ assert.ok(value && typeof value === 'object' && !Array.isArray(value), 'expected "' + keyName + '" to describe a complex field'); ++ return value; ++} ++ ++function indirectRecursiveWsdl() { ++ return [ ++ '', ++ '', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ '' ++ ].join('\n'); ++} ++ ++function directRecursiveWsdl() { ++ return [ ++ '', ++ '', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ '' ++ ].join('\n'); ++} ++ ++function multiLevelRecursiveWsdl() { ++ return [ ++ '', ++ '', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ ' ', ++ '' ++ ].join('\n'); ++} ++ ++describe('recursive WSDL describe()', function() { ++ it('describes an indirectly recursive complex type without overflowing', function(done) { ++ var wsdlPath = writeWsdl('indirect-recursive', indirectRecursiveWsdl()); ++ ++ describeClient(wsdlPath, done, function(description) { ++ assert.ok(description && typeof description === 'object', 'describe() should return an object'); ++ assertHasKey(description, 'FetchForest'); ++ assertHasKey(description, 'FetchForestResult'); ++ assertHasKey(description, 'Title'); ++ assertObjectField(description, 'Branches'); ++ assertObjectField(description, 'Branch'); ++ }); ++ }); ++ ++ it('describes a longer indirect recursive complex type in another namespace', function(done) { ++ var wsdlPath = writeWsdl('longer-indirect-recursive', multiLevelRecursiveWsdl()); ++ ++ describeClient(wsdlPath, done, function(description) { ++ assert.ok(description && typeof description === 'object', 'describe() should return an object'); ++ assertHasKey(description, 'LoadLedger'); ++ assertHasKey(description, 'LoadLedgerResult'); ++ assertHasKey(description, 'Label'); ++ assertObjectField(description, 'Accounts'); ++ assertHasKey(description, 'Name'); ++ assertObjectField(description, 'Details'); ++ assertHasKey(description, 'Code'); ++ assertObjectField(description, 'Root'); ++ }); ++ }); ++ ++ it('describes a directly recursive complex type without unbounded expansion', function(done) { ++ var wsdlPath = writeWsdl('direct-recursive', directRecursiveWsdl()); ++ ++ describeClient(wsdlPath, done, function(description) { ++ assert.ok(description && typeof description === 'object', 'describe() should return an object'); ++ assertHasKey(description, 'ReadCategory'); ++ assertHasKey(description, 'ReadCategoryResult'); ++ assertHasKey(description, 'Name'); ++ assertObjectField(description, 'Parent'); ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,38 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++npm install --no-audit --no-fund 2>/dev/null ++ ++ ++ ++ ++mkdir -p /testbed/.build_env ++if [ ! -f /testbed/.build_env/force-ipv4.js ]; then ++ { ++ printf '%s\n' "var http = require('http');" ++ printf '%s\n' "var origListen = http.Server.prototype.listen;" ++ printf '%s\n' "http.Server.prototype.listen = function() {" ++ printf '%s\n' " var args = Array.prototype.slice.call(arguments);" ++ printf '%s\n' " if (args.length >= 2 && (args[1] === null || args[1] === undefined)) {" ++ printf '%s\n' " args[1] = '0.0.0.0';" ++ printf '%s\n' " }" ++ printf '%s\n' " return origListen.apply(this, args);" ++ printf '%s\n' "};" ++ } > /testbed/.build_env/force-ipv4.js ++fi ++export NODE_OPTIONS="-r /testbed/.build_env/force-ipv4.js" ++ ++case "${1:-}" in ++ base) ++ node ./node_modules/.bin/_mocha -R spec -u exports --grep "stockquote.wsdl" test/wsdl-test.js ++ ;; ++ new) ++ node ./node_modules/.bin/_mocha -R spec test/wsdl-recursive-describe-test.js ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002962/tests/test.sh b/tasks/format-code-task-002962/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..63fca7d79e36ca749642ecbec054fca10191aba0 --- /dev/null +++ b/tasks/format-code-task-002962/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/wsdl-recursive-describe-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-002962/tests/test_command.sh b/tasks/format-code-task-002962/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002962/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-002965/environment/Dockerfile b/tasks/format-code-task-002965/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a788dbb4718c8259de4774db80875f324b3f2dd8 --- /dev/null +++ b/tasks/format-code-task-002965/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:589478c8b615a05e5a35d5fb2501a6c1b7d2e714f205d39782c6e6413eef8031 diff --git a/tasks/format-code-task-002965/environment/setup/files/blocklist b/tasks/format-code-task-002965/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002965/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002965/environment/setup/setup.sh b/tasks/format-code-task-002965/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002965/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002965/tests/test.patch b/tasks/format-code-task-002965/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9cb6a57fa69deab61144a027f713b81686f686a8 --- /dev/null +++ b/tasks/format-code-task-002965/tests/test.patch @@ -0,0 +1,248 @@ +diff --git a/usercase-test-coderl/test_six_month_cycle_agent.py b/usercase-test-coderl/test_six_month_cycle_agent.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_six_month_cycle_agent.py +@@ -0,0 +1,219 @@ ++ ++ ++import sys ++ ++import pytest ++ ++sys.path.insert(0, "/workspace/repo") ++ ++from algotrading.agents.six_month_cycle_agent import SixMonthCycle_Agent ++ ++ ++def _run_steps(agent, ticks): ++ return [agent.step(price, date) for price, date in ticks] ++ ++ ++def test_concrete_rising_session_buys_in_november_and_reports_buy_macd(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ actions = _run_steps( ++ agent, ++ [(10, "2020-09-01"), (11, "2020-10-01"), (12, "2020-11-01")], ++ ) ++ ++ assert actions == [0, 0, 1] ++ assert agent.get_macd_signal() == "buy" ++ ++ ++def test_concrete_falling_session_sells_in_may_and_reports_sell_macd(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ actions = _run_steps( ++ agent, ++ [(12, "2020-03-01"), (11, "2020-04-01"), (10, "2020-05-01")], ++ ) ++ ++ assert actions == [0, 0, -1] ++ assert agent.get_macd_signal() == "sell" ++ ++ ++def test_sell_season_holds_when_macd_confirms_strength(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ actions = _run_steps( ++ agent, ++ [(10, "2020-03-01"), (11, "2020-04-01"), (12, "2020-05-01")], ++ ) ++ ++ assert actions == [0, 0, 0] ++ assert agent.get_macd_signal() == "buy" ++ ++ ++def test_december_buys_even_when_macd_signal_is_sell(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ actions = _run_steps( ++ agent, ++ [(12, "2020-10-01"), (11, "2020-11-01"), (10, "2020-12-01")], ++ ) ++ ++ assert actions == [0, 0, 1] ++ assert agent.get_macd_signal() == "sell" ++ ++ ++def test_january_through_april_buys_only_with_buy_macd_confirmation(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ actions = _run_steps( ++ agent, ++ [(10, "2019-11-01"), (11, "2019-12-01"), (12, "2020-01-01")], ++ ) ++ ++ assert actions == [0, 0, 1] ++ assert agent.get_macd_signal() == "buy" ++ ++ ++def test_january_through_april_holds_without_buy_macd_confirmation(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ actions = _run_steps( ++ agent, ++ [(12, "2020-02-01"), (11, "2020-03-01"), (10, "2020-04-01")], ++ ) ++ ++ assert actions == [0, 0, 0] ++ assert agent.get_macd_signal() == "sell" ++ ++ ++def test_may_through_october_sells_on_october_boundary_with_sell_macd(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ actions = _run_steps( ++ agent, ++ [(12, "2020-08-01"), (11, "2020-09-01"), (10, "2020-10-01")], ++ ) ++ ++ assert actions == [0, 0, -1] ++ assert agent.get_macd_signal() == "sell" ++ ++ ++def test_nonzero_thresholds_can_turn_rising_macd_into_hold(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0.5, 0) ++ ++ actions = _run_steps( ++ agent, ++ [(10, "2020-01-01"), (11, "2020-02-01"), (12, "2020-03-01")], ++ ) ++ ++ assert actions == [0, 0, 0] ++ assert agent.get_macd_signal() == "hold" ++ ++ ++def test_rolling_window_uses_recent_prices_after_more_than_window_size_steps(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ actions = _run_steps( ++ agent, ++ [ ++ (10, "2020-01-01"), ++ (11, "2020-02-01"), ++ (12, "2020-03-01"), ++ (10, "2020-04-01"), ++ ], ++ ) ++ ++ assert actions == [0, 0, 1, 0] ++ assert agent.get_macd_signal() == "sell" ++ ++ ++def test_unparseable_dates_are_ignored_until_full_then_raise_value_error(): ++ ++ ++ ++ ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ ++ assert agent.step(10, "not-a-date") == 0 ++ assert agent.step(11, "2020-x-01") == 0 ++ with pytest.raises(ValueError): ++ agent.step(12, "2020-x-01") ++ ++ ++def test_separate_instances_keep_independent_history_and_parameters(): ++ ++ ++ ++ ++ rising = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ falling = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ thresholded = SixMonthCycle_Agent(3, 1, 3, 2, 0.5, 0) ++ ++ assert rising.step(10, "2020-01-01") == 0 ++ assert falling.step(12, "2020-05-01") == 0 ++ assert thresholded.step(10, "2020-01-01") == 0 ++ assert rising.step(11, "2020-02-01") == 0 ++ assert falling.step(11, "2020-06-01") == 0 ++ assert thresholded.step(11, "2020-02-01") == 0 ++ ++ assert falling.step(10, "2020-07-01") == -1 ++ assert falling.get_macd_signal() == "sell" ++ assert rising.step(12, "2020-03-01") == 1 ++ assert rising.get_macd_signal() == "buy" ++ assert thresholded.step(12, "2020-03-01") == 0 ++ assert thresholded.get_macd_signal() == "hold" ++ ++ ++def test_repeated_short_sessions_use_independent_public_state(): ++ ++ ++ ++ ++ completed_sessions = 0 ++ for _ in range(150): ++ agent = SixMonthCycle_Agent(3, 1, 3, 2, 0, 0) ++ assert agent.step(10, "2020-01-01") == 0 ++ assert agent.step(11, "2020-02-01") == 0 ++ assert agent.step(12, "2020-03-01") == 1 ++ assert agent.get_macd_signal() == "buy" ++ del agent ++ completed_sessions += 1 ++ ++ ++ ++ assert completed_sessions == 150 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++ ++exec python -m pytest -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_six_month_cycle_agent.py -v diff --git a/tasks/format-code-task-002965/tests/test.sh b/tasks/format-code-task-002965/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3109a04a1a76933a4b665a438c1c9aa13379cab2 --- /dev/null +++ b/tasks/format-code-task-002965/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_six_month_cycle_agent.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-002965/tests/test_command.sh b/tasks/format-code-task-002965/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002965/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-002991/environment/Dockerfile b/tasks/format-code-task-002991/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..db0592b75b95ff4c5771c7319488bd1091f0938d --- /dev/null +++ b/tasks/format-code-task-002991/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:565444047837905a099541baa0855daf1a1495c1ff4a846da98f0d48dc210e6d diff --git a/tasks/format-code-task-002991/environment/setup/files/blocklist b/tasks/format-code-task-002991/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002991/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002991/environment/setup/setup.sh b/tasks/format-code-task-002991/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002991/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002991/tests/test.patch b/tasks/format-code-task-002991/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..40b33b1b1e9085b176166805cbbb4ca9eb9ff875 --- /dev/null +++ b/tasks/format-code-task-002991/tests/test.patch @@ -0,0 +1,172 @@ +diff --git a/tests/test_main.py b/tests/test_main.py +index c234aa83..7addb59e 100644 +--- a/tests/test_main.py ++++ b/tests/test_main.py +@@ -701,107 +701,52 @@ def test_predict_tile_with_crop_model_empty(): + # Assert the result + assert result is None + +-# @pytest.mark.parametrize("batch_size", [1, 4, 8]) +-# def test_batch_prediction(m, batch_size, raster_path): +-# +-# # Prepare input data +-# tile = np.array(Image.open(raster_path)) +-# ds = dataset.TileDataset(tile=tile, patch_overlap=0.1, patch_size=100) +-# dl = DataLoader(ds, batch_size=batch_size) +- +-# # Perform prediction +-# predictions = [] +-# for batch in dl: +-# prediction = m.predict_batch(batch) +-# predictions.append(prediction) +- +-# # Check results +-# assert len(predictions) == len(dl) +-# for batch_pred in predictions: +-# assert isinstance(batch_pred, pd.DataFrame) +-# assert set(batch_pred.columns) == { +-# "xmin", "ymin", "xmax", "ymax", "label", "score", "geometry" +-# } +- +-# @pytest.mark.parametrize("batch_size", [1, 4]) +-# def test_batch_training(m, batch_size, tmpdir): +-# +-# # Generate synthetic training data +-# csv_file = get_data("example.csv") +-# root_dir = os.path.dirname(csv_file) +-# train_ds = m.load_dataset(csv_file, root_dir=root_dir) +-# train_dl = DataLoader(train_ds, batch_size=batch_size, shuffle=True) +- +-# # Configure the model and trainer +-# m.config["batch_size"] = batch_size +-# m.create_trainer() +-# trainer = m.trainer +- +-# # Train the model +-# trainer.fit(m, train_dl) +- +-# # Assertions +-# assert trainer.current_epoch == 1 +-# assert trainer.batch_size == batch_size +- +-# @pytest.mark.parametrize("batch_size", [2, 4]) +-# def test_batch_data_augmentation(m, batch_size, raster_path): +-# +-# tile = np.array(Image.open(raster_path)) +-# ds = dataset.TileDataset(tile=tile, patch_overlap=0.1, patch_size=100, augment=True) +-# dl = DataLoader(ds, batch_size=batch_size) ++def test_batch_prediction(m, raster_path): ++ ++ tile = np.array(Image.open(raster_path)) ++ ds = dataset.TileDataset(tile=tile, patch_overlap=0.1, patch_size=300) ++ dl = DataLoader(ds, batch_size=3) + +-# predictions = [] +-# for batch in dl: +-# prediction = m.predict_batch(batch) +-# predictions.append(prediction) ++ ++ predictions = [] ++ for batch in dl: ++ prediction = m.predict_batch(batch) ++ predictions.append(prediction) + +-# assert len(predictions) == len(dl) +-# for batch_pred in predictions: +-# assert isinstance(batch_pred, pd.DataFrame) +-# assert set(batch_pred.columns) == { +-# "xmin", "ymin", "xmax", "ymax", "label", "score", "geometry" +-# } +- +-# def test_batch_inference_consistency(m, raster_path): +-# +-# tile = np.array(Image.open(raster_path)) +-# ds = dataset.TileDataset(tile=tile, patch_overlap=0.1, patch_size=100) +-# dl = DataLoader(ds, batch_size=4) ++ ++ assert len(predictions) == len(dl) ++ for batch_pred in predictions: ++ for image_pred in batch_pred: ++ assert isinstance(image_pred, pd.DataFrame) ++ assert "label" in image_pred.columns ++ assert "score" in image_pred.columns ++ assert "geometry" in image_pred.columns ++ ++def test_batch_inference_consistency(m, raster_path): ++ tile = np.array(Image.open(raster_path)) ++ ds = dataset.TileDataset(tile=tile, patch_overlap=0.1, patch_size=300) ++ dl = DataLoader(ds, batch_size=4) + +-# batch_predictions = [] +-# for batch in dl: +-# prediction = m.predict_batch(batch) +-# batch_predictions.append(prediction) ++ batch_predictions = [] ++ for batch in dl: ++ prediction = m.predict_batch(batch) ++ batch_predictions.extend(prediction) + +-# single_predictions = [] +-# for image in ds: +-# prediction = m.predict_image(image=image) +-# single_predictions.append(prediction) ++ single_predictions = [] ++ for image in ds: ++ image = image.permute(1,2,0).numpy() * 255 ++ prediction = m.predict_image(image=image) ++ single_predictions.append(prediction) + +-# batch_df = pd.concat(batch_predictions, ignore_index=True) +-# single_df = pd.concat(single_predictions, ignore_index=True) ++ batch_df = pd.concat(batch_predictions, ignore_index=True) ++ single_df = pd.concat(single_predictions, ignore_index=True) + +-# pd.testing.assert_frame_equal(batch_df, single_df) ++ ++ for col in ["xmin", "ymin", "xmax", "ymax"]: ++ batch_df[col] = batch_df[col].astype(int) ++ single_df[col] = single_df[col].astype(int) ++ pd.testing.assert_frame_equal(batch_df[["xmin", "ymin", "xmax", "ymax"]], single_df[["xmin", "ymin", "xmax", "ymax"]], check_dtype=False) + +-# def test_large_batch_handling(m, raster_path): +-# +-# tile = np.array(Image.open(raster_path)) +-# ds = dataset.TileDataset(tile=tile, patch_overlap=0.1, patch_size=100) +-# dl = DataLoader(ds, batch_size=16) +- +-# predictions = [] +-# for batch in dl: +-# prediction = m.predict_batch(batch) +-# predictions.append(prediction) +- +-# assert len(predictions) > 0 +-# for batch_pred in predictions: +-# assert isinstance(batch_pred, pd.DataFrame) +-# assert set(batch_pred.columns) == { +-# "xmin", "ymin", "xmax", "ymax", "label", "score", "geometry" +-# } +-# assert not batch_pred.empty + + def test_epoch_evaluation_end(m): + preds = [{ +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+3S326DIBQGcK99ipPe+wdb6uMYBBbJKhhAM99+1CVds2TrTZul6fe7kCOgEr9T ++9rM5qU7bpcoepU5azrcx+TluNeMNY+2e1TzNM8bbQ0b8YSe6MocoPFHmnYt/7bu1/qTK7/yjDrGT ++bhyFVWUY7veNW/k3+0v+9bFtU/6HY8Myqu93hN+9eP5S0RZ8r1Ue3OylvtxX5XJui97YSshoFhF1 ++Pq1xcJaKkVKVttH5Er5aZxTGltNKxQcVCxXvtNumexHl0E1eK5Pekh52nq4WjH3TXlupU+vZYEJM ++9brL//u/AAAAAAAAAAAAAAAAAAAAAAA8g08XRRdGACgAAA== +diff --git 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-002991/tests/test.sh b/tasks/format-code-task-002991/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..13a09f93f27b7232a41ccac6b89068470f01fcf3 --- /dev/null +++ b/tasks/format-code-task-002991/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_main.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-002991/tests/test_command.sh b/tasks/format-code-task-002991/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002991/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002996/environment/Dockerfile b/tasks/format-code-task-002996/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..445bcf25c2f0bfddc48d1d54ec8425bf46632e90 --- /dev/null +++ b/tasks/format-code-task-002996/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9df836d7a680f73c466de8cbe5f4442e883c1f15a6e2a7e127ee0e0504f7cbdb diff --git a/tasks/format-code-task-002996/environment/setup/files/blocklist b/tasks/format-code-task-002996/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002996/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002996/environment/setup/setup.sh b/tasks/format-code-task-002996/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002996/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002996/tests/test.patch b/tasks/format-code-task-002996/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3767d462170a2d38c913a8d9279a0a3097e1896f --- /dev/null +++ b/tasks/format-code-task-002996/tests/test.patch @@ -0,0 +1,72 @@ +diff --git a/tests/test_visitors/test_ast/test_complexity/test_jones/test_line_complexity.py b/tests/test_visitors/test_ast/test_complexity/test_jones/test_line_complexity.py +index 457de8500..dc6b1d607 100644 +--- a/tests/test_visitors/test_ast/test_complexity/test_jones/test_line_complexity.py ++++ b/tests/test_visitors/test_ast/test_complexity/test_jones/test_line_complexity.py +@@ -1,5 +1,6 @@ + import pytest + ++from wemake_python_styleguide.compat.constants import PY312 + from wemake_python_styleguide.violations.complexity import ( + LineComplexityViolation, + ) +@@ -10,6 +11,7 @@ + line_simple = 'x = 2' + line_with_types = 'x: int = 2' + line_with_complex_types = 'x: Dict[Tuple[str, str, int], Set[List[attr.Val]]]' ++line_with_complex_typealias = 'type Al[X] = Di[Tup[s, s, i], Set[Li[attr.Val]]]' + line_with_comprehension = 'x = [f for f in "abc"]' + line_with_math = 'x = y * 2 + 19 / 9.3' + line_inside_function = """ +@@ -76,6 +78,14 @@ def third(): + class_with_function, + class_with_async_function, + class_with_usual_and_async_function, ++ pytest.param( ++ line_with_complex_typealias, ++ marks=[ ++ pytest.mark.skipif( ++ not PY312, reason='PEP695 was added in 3.12' ++ ), ++ ], ++ ), + ], + ) + def test_regular_nodes(assert_errors, parse_ast_tree, code, default_options): +@@ -94,6 +104,7 @@ def test_regular_nodes(assert_errors, parse_ast_tree, code, default_options): + (line_simple, 3), + (line_with_types, 3), + (line_with_complex_types, 2), ++ (line_with_complex_typealias, 3), + (line_with_comprehension, 6), + (line_with_math, 9), + (line_inside_function, 4), +@@ -112,6 +123,8 @@ def test_complex_lines( + options, + ): + """Testing that complex lines do raise violations.""" ++ if code == line_with_complex_typealias and not PY312: # pragma: no cover ++ pytest.skip('PEP695 was added in 3.12') + tree = parse_ast_tree(code) + + option_values = options(max_line_complexity=1) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S0WqDMBQGYK99ivMCUWOrwl6mxBgwQxNJYphvP2uLK4OtNy3b2P9dmBxyIMH/ ++ZO2sh+6kTMyTZylWTVVt6+rzuu15VXLeNHXJy6TgvC6qhKqnvejG7INwRImzNnzXd+/8j8o+8g/K ++h5O04yhMl/n+cXfcy7+s+Z4/P6x9/FiXx4SKxz3ha/88f9nRFnyrutTb2Um113kWz2PRapMLGXQU ++QaXTEnprDsRGWrdrH50//jI7UXsdrLtWwod9pKZBvemwXOpXa9S1Z9BG3Zxn00JsImNfpJC9mpyN ++ulOOGDOWSRuJxfSnfxgAAAAAAAAAAAAAAAAAAAAAwC/yDuOeTxAAKAAA +diff --git 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-002996/tests/test.sh b/tasks/format-code-task-002996/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a9fd7be4da9dcb05f21e0f4dde4689aba9b7ebb3 --- /dev/null +++ b/tasks/format-code-task-002996/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_visitors/test_ast/test_complexity/test_jones/test_line_complexity.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-002996/tests/test_command.sh b/tasks/format-code-task-002996/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002996/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002998/environment/Dockerfile b/tasks/format-code-task-002998/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..32df41e7f55b8e24df8fac46fca82d192dfe21a5 --- /dev/null +++ b/tasks/format-code-task-002998/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8f78ad01f07348d70b28b272dc2faa7b1f3c03d0df05224a58a004d9df8eb14f diff --git a/tasks/format-code-task-002998/environment/setup/files/blocklist b/tasks/format-code-task-002998/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002998/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002998/environment/setup/setup.sh b/tasks/format-code-task-002998/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002998/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002998/tests/test.patch b/tasks/format-code-task-002998/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e75a3ec2452370e297e7ac6d44947ab17b008b64 --- /dev/null +++ b/tasks/format-code-task-002998/tests/test.patch @@ -0,0 +1,74 @@ +diff --git a/test/specs/inspecting.test.js b/test/specs/inspecting.test.js +index e9223f6..d27981e 100644 +--- a/test/specs/inspecting.test.js ++++ b/test/specs/inspecting.test.js +@@ -494,6 +494,47 @@ module.exports = fetchMock => { + }); + }); + ++ describe('arbitrary options passed alongside Request', () => { ++ let fm2; ++ beforeEach(() => { ++ fm2 = fetchMock.createInstance(); ++ fm2.config.warnOnUnmatched = false; ++ fm2.mock('http://it.at.here/', 200); ++ }); ++ afterEach(() => fm2.restore()); ++ ++ it('passes arbitrary options through when called with Request and options', () => { ++ const req = new fm2.config.Request('http://it.at.here/', { ++ method: 'POST' ++ }); ++ fm2.fetchHandler(req, { cf: { ttl: 30 } }); ++ const opts = fm2.lastOptions(); ++ expect(opts.cf).to.eql({ ttl: 30 }); ++ expect(opts.method).to.equal('POST'); ++ }); ++ ++ it('passes multiple arbitrary options through when called with Request', () => { ++ const req = new fm2.config.Request('http://it.at.here/', { ++ method: 'POST' ++ }); ++ fm2.fetchHandler(req, { ++ cf: { ttl: 30 }, ++ customField: 'arbitrary-value' ++ }); ++ const opts = fm2.lastOptions(); ++ expect(opts.cf).to.eql({ ttl: 30 }); ++ expect(opts.customField).to.equal('arbitrary-value'); ++ }); ++ ++ it('preserves method from Request when no options passed', () => { ++ const req = new fm2.config.Request('http://it.at.here/', { ++ method: 'POST' ++ }); ++ fm2.fetchHandler(req); ++ expect(fm2.lastOptions()).to.eql({ method: 'POST' }); ++ }); ++ }); ++ + describe('flushing pending calls', () => { + afterEach(() => fm.restore()); + +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..712b61f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/mocha test/server.js -g \"arbitrary options passed alongside 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 ++./node_modules/.bin/mocha test/server.js -g "arbitrary options passed alongside Request" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002998/tests/test.sh b/tasks/format-code-task-002998/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9865119e7c3e01988d79f1916f50d1960bdf6c11 --- /dev/null +++ b/tasks/format-code-task-002998/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/specs/inspecting.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-002998/tests/test_command.sh b/tasks/format-code-task-002998/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002998/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003012/environment/Dockerfile b/tasks/format-code-task-003012/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..709cb62839ad0032c6ddcad7132fadbca30161a5 --- /dev/null +++ b/tasks/format-code-task-003012/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:23e3f8b161ed3bf2edbd7307fcf6cfe448a4a6d1a5fd893fa2c5d5fb5c3dda2f diff --git a/tasks/format-code-task-003012/environment/setup/files/blocklist b/tasks/format-code-task-003012/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003012/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003012/environment/setup/setup.sh b/tasks/format-code-task-003012/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003012/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003012/tests/test.patch b/tasks/format-code-task-003012/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4f1d3e2c1933ab1b5911d7f191846f0a53bdad00 --- /dev/null +++ b/tasks/format-code-task-003012/tests/test.patch @@ -0,0 +1,36 @@ +diff --git a/services_test.go b/services_test.go +index 7380c18a9..7bb6dabf9 100644 +--- a/services_test.go ++++ b/services_test.go +@@ -132,6 +132,9 @@ func TestSetJiraService(t *testing.T) { + Username: String("aas"), + Password: String("asd"), + JiraIssueTransitionID: String("2,3"), ++ CommitEvents: Bool(true), ++ CommentOnEventEnabled: Bool(true), ++ MergeRequestsEvents: Bool(true), + } + + _, err := client.Services.SetJiraService(1, opt) +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+DMBQHcM77FM3uIFUKJ0+bMfNkwu4Lg5fZCNS0hZMf3g4SNd3YLlvU+P9x ++oHmv77XJa7TtZF1tqO1vgmuJnUyI4e/4/2HNxS13XyziNIg5F9ldwMTVbvRNZ2yhGQu0UvbUvnP5 ++Pyr6mr8lYzelapqirSLzcrkzzs0/TdLP+ScicfNPUp4FLL7cFab98/mXFRsGv6VqtlNsv2Rhz8JS ++da295yzUXcvmaxd+JLvUqqXFKifdy5Le99H8aHRJNVk6knBNnqQuvA5+aCz3o642r4vy1Ss+iI3V ++B2FX/izfqJYtmYemkLXXZzo5NpzOL9wbUs3KmI7W2p1K2mt9esPYfnLPnEWzn34lAAAAAAAAAAAA ++AAAAAAAAAPBbfQCgZU45ACgAAA== +diff --git 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-003012/tests/test.sh b/tasks/format-code-task-003012/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c1589cafc5bd9c90b9ee6b691e6c66734cd353dd --- /dev/null +++ b/tasks/format-code-task-003012/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' +services_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-003012/tests/test_command.sh b/tasks/format-code-task-003012/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003012/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003013/environment/Dockerfile b/tasks/format-code-task-003013/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3179ad464283a99b0ced9669f01f1000b05beee2 --- /dev/null +++ b/tasks/format-code-task-003013/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:db9f42d74c197406cd2732834043bbd451cf5df040125890d851ca2e5e2b3cea diff --git a/tasks/format-code-task-003013/environment/setup/files/blocklist b/tasks/format-code-task-003013/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003013/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003013/environment/setup/setup.sh b/tasks/format-code-task-003013/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003013/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-003013/tests/test.patch b/tasks/format-code-task-003013/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f6d896dabde0036532c7caf88feb5ae6d5a78d53 --- /dev/null +++ b/tasks/format-code-task-003013/tests/test.patch @@ -0,0 +1,445 @@ +diff --git a/usercase-test-coderl/fixtures/tmp-work/bad-list-project/templates/bad.json b/usercase-test-coderl/fixtures/tmp-work/bad-list-project/templates/bad.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/tmp-work/bad-list-project/templates/bad.json +@@ -0,0 +1,1 @@ ++{ +\ No newline at end of file +diff --git a/usercase-test-coderl/fixtures/tmp-work/independent-a/templates/only-a.json b/usercase-test-coderl/fixtures/tmp-work/independent-a/templates/only-a.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/tmp-work/independent-a/templates/only-a.json +@@ -0,0 +1,16 @@ ++{ ++ "name": "Only A", ++ "description": "Project A template", ++ "version": "1.0.0", ++ "created": "2026-04-04T00:00:00.000Z", ++ "nodes": [ ++ { ++ "id": "a1", ++ "path": "/nodes/a.py", ++ "position": { ++ "x": 1, ++ "y": 2 ++ } ++ } ++ ] ++} +\ No newline at end of file +diff --git a/usercase-test-coderl/fixtures/tmp-work/list-project/templates/drive.json b/usercase-test-coderl/fixtures/tmp-work/list-project/templates/drive.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/tmp-work/list-project/templates/drive.json +@@ -0,0 +1,1 @@ ++{"name":"Drive","description":"...","version":"1.0.0","created":"2026-01-01T00:00:00.000Z","nodes":[{"id":"a"},{"id":"b"}]} +\ No newline at end of file +diff --git a/usercase-test-coderl/fixtures/tmp-work/list-project/templates/notes.txt b/usercase-test-coderl/fixtures/tmp-work/list-project/templates/notes.txt +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/tmp-work/list-project/templates/notes.txt +@@ -0,0 +1,1 @@ ++not a template +\ No newline at end of file +diff --git a/usercase-test-coderl/fixtures/tmp-work/load-normalize-project/templates/messy.json b/usercase-test-coderl/fixtures/tmp-work/load-normalize-project/templates/messy.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/tmp-work/load-normalize-project/templates/messy.json +@@ -0,0 +1,1 @@ ++{"name":"Messy","description":"Needs cleanup","version":"3.0.0","created":"2026-03-03T00:00:00.000Z","nodes":[{"id":"keep-position","path":"/nodes/a.py","position":{"x":7,"y":9}},{"id":"missing-path","position":{"x":1,"y":1}},{"id":"missing-position","path":"/nodes/b.py"},{"id":"bad-x","path":"/nodes/c.py","position":{"x":"bad","y":2}},{"id":"bad-y","path":"/nodes/d.py","position":{"x":3}}],"edges":[{"id":"edge-a"}]} +\ No newline at end of file +diff --git a/usercase-test-coderl/template_manager.test.js b/usercase-test-coderl/template_manager.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/template_manager.test.js +@@ -0,0 +1,362 @@ ++const assert = require('node:assert/strict'); ++const fs = require('node:fs'); ++const path = require('node:path'); ++const Module = require('node:module'); ++const test = require('node:test'); ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++const REPO = '/workspace/repo'; ++const WORK_ROOT = '/workspace/repo/usercase-test-coderl/fixtures/tmp-work'; ++ ++function installElectronHarness() { ++ const originalLoad = Module._load; ++ Module._load = function patchedLoad(request, parent, isMain) { ++ if (request === 'electron') { ++ return { ++ shell: { openPath() {} }, ++ ipcRenderer: { ++ send() {}, ++ on() {}, ++ removeListener() {}, ++ removeAllListeners() {}, ++ }, ++ }; ++ } ++ if (request === '@electron/remote') { ++ return { ++ dialog: { ++ showSaveDialog: async () => ({ canceled: true }), ++ showOpenDialog: async () => ({ canceled: true, filePaths: [] }), ++ }, ++ }; ++ } ++ return originalLoad.apply(this, arguments); ++ }; ++ ++ global.window = { ++ require, ++ isMainWindow: 1, ++ currentProject: null, ++ }; ++} ++ ++function installTranspileForAppSource() { ++ const ts = require('typescript'); ++ const originalJs = require.extensions['.js']; ++ require.extensions['.js'] = function compileAppSource(mod, filename) { ++ if (filename.startsWith(path.join(REPO, 'src') + path.sep)) { ++ const source = fs.readFileSync(filename, 'utf8'); ++ ++ const result = ts.transpileModule(source, { ++ fileName: filename, ++ compilerOptions: { ++ esModuleInterop: true, ++ module: ts.ModuleKind.CommonJS, ++ target: ts.ScriptTarget.ES2020, ++ }, ++ }); ++ mod._compile(result.outputText, filename); ++ return; ++ } ++ originalJs(mod, filename); ++ }; ++} ++ ++installElectronHarness(); ++installTranspileForAppSource(); ++ ++const templateManager = require('/workspace/repo/src/controller/gui/TemplateManager.js').default; ++ ++function resetProject(projectName) { ++ const projectPath = path.join(WORK_ROOT, projectName); ++ fs.rmSync(projectPath, { recursive: true, force: true }); ++ fs.mkdirSync(projectPath, { recursive: true }); ++ window.currentProject = { path: projectPath }; ++ return projectPath; ++} ++ ++function writeJson(filePath, value) { ++ fs.mkdirSync(path.dirname(filePath), { recursive: true }); ++ fs.writeFileSync(filePath, JSON.stringify(value), 'utf8'); ++} ++ ++function countJsonFiles(directory) { ++ if (!fs.existsSync(directory)) { ++ return 0; ++ } ++ return fs.readdirSync(directory).filter((file) => file.endsWith('.json')).length; ++} ++ ++test('getTemplateDir requires an open project path with the documented Error', () => { ++ ++ ++ ++ ++ window.currentProject = null; ++ ++ assert.throws( ++ () => templateManager.getTemplateDir(), ++ (error) => { ++ assert.equal(error.constructor, Error); ++ assert.equal(error.message, '没有打开的项目'); ++ return true; ++ }, ++ ); ++}); ++ ++test('getTemplateDir creates the project templates directory and is repeatable', () => { ++ ++ ++ ++ ++ resetProject('dir-default-project'); ++ ++ assert.equal(fs.existsSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/dir-default-project/templates'), false); ++ assert.equal( ++ templateManager.getTemplateDir(), ++ '/workspace/repo/usercase-test-coderl/fixtures/tmp-work/dir-default-project/templates', ++ ); ++ assert.equal(fs.existsSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/dir-default-project/templates'), true); ++ assert.equal( ++ templateManager.getTemplateDir(), ++ '/workspace/repo/usercase-test-coderl/fixtures/tmp-work/dir-default-project/templates', ++ ); ++ assert.equal(fs.existsSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/dir-default-project/templates'), true); ++}); ++ ++test('getTemplateListByProject returns summaries for json templates and ignores non-json files', () => { ++ ++ ++ ++ ++ resetProject('list-project'); ++ fs.mkdirSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/list-project/templates', { recursive: true }); ++ fs.writeFileSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/list-project/templates/notes.txt', 'not a template', 'utf8'); ++ writeJson('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/list-project/templates/drive.json', { ++ name: 'Drive', ++ description: '...', ++ version: '1.0.0', ++ created: '2026-01-01T00:00:00.000Z', ++ nodes: [{ id: 'a' }, { id: 'b' }], ++ }); ++ ++ assert.deepEqual( ++ templateManager.getTemplateListByProject('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/list-project'), ++ [{ ++ name: 'Drive', ++ description: '...', ++ version: '1.0.0', ++ created: '2026-01-01T00:00:00.000Z', ++ fileName: 'drive.json', ++ nodeCount: 2, ++ }], ++ ); ++}); ++ ++test('getTemplateListByProject returns an empty array when a template cannot be parsed', () => { ++ ++ ++ ++ ++ resetProject('bad-list-project'); ++ fs.mkdirSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/bad-list-project/templates', { recursive: true }); ++ fs.writeFileSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/bad-list-project/templates/bad.json', '{', 'utf8'); ++ ++ assert.deepEqual( ++ templateManager.getTemplateListByProject('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/bad-list-project'), ++ [], ++ ); ++}); ++ ++test('saveTemplate writes pretty JSON, list observes the saved file, and deleteTemplate removes it', async () => { ++ ++ ++ ++ ++ resetProject('save-delete-project'); ++ ++ const savedTemplate = { ++ name: 'Saved Drive', ++ description: 'Saved template', ++ version: '2.0.0', ++ created: '2026-02-02T03:04:05.000Z', ++ nodes: [{ ++ id: 'n1', ++ path: '/pkg/node.py', ++ position: { x: 12, y: 34 }, ++ }], ++ edges: [{ id: 'e1' }], ++ }; ++ ++ assert.equal(await templateManager.saveTemplate('saved', savedTemplate), 'saved.json'); ++ ++ const savedContent = fs.readFileSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/save-delete-project/templates/saved.json', 'utf8'); ++ ++ assert.deepEqual(JSON.parse(savedContent), savedTemplate); ++ assert.match(savedContent, /\n\s+"name": "Saved Drive"/); ++ assert.match(savedContent, /\n\s+"nodes": \[/); ++ assert.deepEqual(templateManager.getTemplateList(), [{ ++ name: 'Saved Drive', ++ description: 'Saved template', ++ version: '2.0.0', ++ created: '2026-02-02T03:04:05.000Z', ++ fileName: 'saved.json', ++ nodeCount: 1, ++ }]); ++ ++ assert.equal(await templateManager.deleteTemplate('saved.json'), true); ++ assert.equal(fs.existsSync('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/save-delete-project/templates/saved.json'), false); ++ assert.deepEqual(templateManager.getTemplateList(), []); ++}); ++ ++test('saveTemplate rethrows the missing-project Error instead of reporting success', async () => { ++ ++ ++ ++ ++ window.currentProject = null; ++ ++ await assert.rejects( ++ templateManager.saveTemplate('drive', { ++ name: 'Drive', ++ nodes: [], ++ }), ++ (error) => { ++ assert.equal(error.constructor, Error); ++ assert.equal(error.message, '没有打开的项目'); ++ return true; ++ }, ++ ); ++}); ++ ++test('deleteTemplate rethrows a missing-file unlink Error instead of reporting success', async () => { ++ ++ ++ ++ ++ resetProject('delete-missing-project'); ++ ++ await assert.rejects( ++ templateManager.deleteTemplate('missing.json'), ++ (error) => { ++ ++ assert.equal(error.constructor, Error); ++ assert.match(error.message, /missing\.json|ENOENT|no such file/i); ++ return true; ++ }, ++ ); ++}); ++ ++test('loadTemplate filters nodes without paths and defaults missing or non-numeric positions', async () => { ++ ++ ++ ++ ++ resetProject('load-normalize-project'); ++ writeJson('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/load-normalize-project/templates/messy.json', { ++ name: 'Messy', ++ description: 'Needs cleanup', ++ version: '3.0.0', ++ created: '2026-03-03T00:00:00.000Z', ++ nodes: [ ++ { id: 'keep-position', path: '/nodes/a.py', position: { x: 7, y: 9 } }, ++ { id: 'missing-path', position: { x: 1, y: 1 } }, ++ { id: 'missing-position', path: '/nodes/b.py' }, ++ { id: 'bad-x', path: '/nodes/c.py', position: { x: 'bad', y: 2 } }, ++ { id: 'bad-y', path: '/nodes/d.py', position: { x: 3 } }, ++ ], ++ edges: [{ id: 'edge-a' }], ++ }); ++ ++ assert.deepEqual( ++ await templateManager.loadTemplate( ++ 'messy.json', ++ '/workspace/repo/usercase-test-coderl/fixtures/tmp-work/load-normalize-project', ++ ), ++ { ++ name: 'Messy', ++ description: 'Needs cleanup', ++ version: '3.0.0', ++ created: '2026-03-03T00:00:00.000Z', ++ nodes: [ ++ { id: 'keep-position', path: '/nodes/a.py', position: { x: 7, y: 9 } }, ++ { id: 'missing-position', path: '/nodes/b.py', position: { x: 100, y: 100 } }, ++ { id: 'bad-x', path: '/nodes/c.py', position: { x: 100, y: 100 } }, ++ { id: 'bad-y', path: '/nodes/d.py', position: { x: 100, y: 100 } }, ++ ], ++ edges: [{ id: 'edge-a' }], ++ }, ++ ); ++}); ++ ++test('separate project paths keep independent template lists', async () => { ++ ++ ++ ++ ++ resetProject('independent-a'); ++ await templateManager.saveTemplate('only-a', { ++ name: 'Only A', ++ description: 'Project A template', ++ version: '1.0.0', ++ created: '2026-04-04T00:00:00.000Z', ++ nodes: [{ id: 'a1', path: '/nodes/a.py', position: { x: 1, y: 2 } }], ++ }); ++ resetProject('independent-b'); ++ ++ assert.deepEqual( ++ templateManager.getTemplateListByProject('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/independent-a'), ++ [{ ++ name: 'Only A', ++ description: 'Project A template', ++ version: '1.0.0', ++ created: '2026-04-04T00:00:00.000Z', ++ fileName: 'only-a.json', ++ nodeCount: 1, ++ }], ++ ); ++ assert.deepEqual( ++ templateManager.getTemplateListByProject('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/independent-b'), ++ [], ++ ); ++}); ++ ++test('repeated save-load-delete cycles leave the template directory file count bounded', async () => { ++ ++ ++ ++ ++ resetProject('leak-floor-project'); ++ templateManager.getTemplateDir(); ++ ++ assert.equal(countJsonFiles('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/leak-floor-project/templates'), 0); ++ for (let i = 0; i < 120; i += 1) { ++ const name = `cycle-${i}`; ++ assert.equal(await templateManager.saveTemplate(name, { ++ name: `Cycle ${i}`, ++ description: 'Leak floor template', ++ version: '1.0.0', ++ created: '2026-05-05T00:00:00.000Z', ++ nodes: [{ id: `node-${i}`, path: '/nodes/cycle.py', position: { x: 5, y: 6 } }], ++ }), `${name}.json`); ++ assert.deepEqual(await templateManager.loadTemplate(`${name}.json`), { ++ name: `Cycle ${i}`, ++ description: 'Leak floor template', ++ version: '1.0.0', ++ created: '2026-05-05T00:00:00.000Z', ++ nodes: [{ id: `node-${i}`, path: '/nodes/cycle.py', position: { x: 5, y: 6 } }], ++ }); ++ assert.equal(await templateManager.deleteTemplate(`${name}.json`), true); ++ } ++ ++ assert.equal(countJsonFiles('/workspace/repo/usercase-test-coderl/fixtures/tmp-work/leak-floor-project/templates'), 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,23 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++if [ ! -d node_modules ]; then ++ echo "node_modules is required for offline test execution" >&2 ++ exit 1 ++fi ++ ++node -e "require.resolve('typescript')" ++ ++exec node --test /workspace/repo/usercase-test-coderl/template_manager.test.js diff --git a/tasks/format-code-task-003013/tests/test.sh b/tasks/format-code-task-003013/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dad32793326567feedef5a95b9aa92a605dfb890 --- /dev/null +++ b/tasks/format-code-task-003013/tests/test.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/tmp-work/bad-list-project/templates/bad.json +usercase-test-coderl/fixtures/tmp-work/independent-a/templates/only-a.json +usercase-test-coderl/fixtures/tmp-work/list-project/templates/drive.json +usercase-test-coderl/fixtures/tmp-work/list-project/templates/notes.txt +usercase-test-coderl/fixtures/tmp-work/load-normalize-project/templates/messy.json +usercase-test-coderl/template_manager.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-003013/tests/test_command.sh b/tasks/format-code-task-003013/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003013/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-003015/environment/Dockerfile b/tasks/format-code-task-003015/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e6d3862b5761bf23292d07284ce61600c376c69b --- /dev/null +++ b/tasks/format-code-task-003015/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:63000d97be995c1ceb464c12ce9580053441242c1366d0c8d564f1e0fc481dea diff --git a/tasks/format-code-task-003015/environment/setup/files/blocklist b/tasks/format-code-task-003015/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003015/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003015/environment/setup/setup.sh b/tasks/format-code-task-003015/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003015/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003015/tests/test.patch b/tasks/format-code-task-003015/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..df4b3612c067c84b9ad34b94b257d3357c4f2416 --- /dev/null +++ b/tasks/format-code-task-003015/tests/test.patch @@ -0,0 +1,100 @@ +diff --git a/tests/interpreters/test_arith_interpreter.py b/tests/interpreters/test_arith_interpreter.py +index ba81c5c81e..bb5dbcbf47 100644 +--- a/tests/interpreters/test_arith_interpreter.py ++++ b/tests/interpreters/test_arith_interpreter.py +@@ -10,8 +10,13 @@ + AddiOp, + CmpiOp, + ConstantOp, ++ DivSIOp, ++ FloorDivSIOp, + MulfOp, + MuliOp, ++ RemSIOp, ++ ShLIOp, ++ ShRSIOp, + SubfOp, + SubiOp, + ) +@@ -181,3 +186,61 @@ def test_cmpi( + + assert len(ret) == 1 + assert ret[0] == fn(lhs_value, rhs_value) ++ ++ ++@pytest.mark.parametrize("lhs_value", [1, 0, -1, 127]) ++@pytest.mark.parametrize("rhs_value", [0, 1, 2, 8]) ++def test_shlsi(lhs_value: int, rhs_value: int): ++ shlsi = ShLIOp(lhs_op, rhs_op) ++ ++ ret = interpreter.run_op(shlsi, (lhs_value, rhs_value)) ++ ++ assert len(ret) == 1 ++ assert ret[0] == lhs_value << rhs_value ++ ++ ++@pytest.mark.parametrize("lhs_value", [1, 0, -1, 127]) ++@pytest.mark.parametrize("rhs_value", [0, 1, 2, 8]) ++def test_shrsi(lhs_value: int, rhs_value: int): ++ shrsi = ShRSIOp(lhs_op, rhs_op) ++ ++ ret = interpreter.run_op(shrsi, (lhs_value, rhs_value)) ++ ++ assert len(ret) == 1 ++ assert ret[0] == lhs_value >> rhs_value ++ ++ ++@pytest.mark.parametrize( ++ "lhs_value,rhs_value,result", [(-3, -2, 1), (-3, 2, -1), (3, -2, -1), (3, 2, 1)] ++) ++def test_divsi(lhs_value: int, rhs_value: int, result: int): ++ divsi = DivSIOp(lhs_op, rhs_op) ++ ++ ret = interpreter.run_op(divsi, (lhs_value, rhs_value)) ++ ++ assert len(ret) == 1 ++ assert ret[0] == result ++ ++ ++@pytest.mark.parametrize( ++ "lhs_value,rhs_value,result", [(-3, -2, -1), (-3, 2, -1), (3, -2, 1), (3, 2, 1)] ++) ++def test_remsi(lhs_value: int, rhs_value: int, result: int): ++ remsi = RemSIOp(lhs_op, rhs_op) ++ ++ ret = interpreter.run_op(remsi, (lhs_value, rhs_value)) ++ ++ assert len(ret) == 1 ++ assert ret[0] == result ++ ++ ++@pytest.mark.parametrize( ++ "lhs_value,rhs_value,result", [(-3, -2, 1), (-3, 2, -2), (3, -2, -2), (3, 2, 1)] ++) ++def test_floordivsi(lhs_value: int, rhs_value: int, result: int): ++ floordivsi = FloorDivSIOp(lhs_op, rhs_op) ++ ++ ret = interpreter.run_op(floordivsi, (lhs_value, rhs_value)) ++ ++ assert len(ret) == 1 ++ assert ret[0] == result +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3S3YrCMBCG4R57FXMDrZ26sZdTahtoYftDEgve/WYruLKw64ki4vscJEMykIQv ++2eHYf7aVHZdt8ih5VBqzztHvea3VFFrkutMi9qmaUhMxD7vRlaMPtRNJ3DSF//pu7b+o7Cf/YH2o ++mmkY6rHNfHe/M27lr7q/5B8bY/4f+7xMJL/fFf725vk3razBH2y7mU+hm8adpIPEMi7K9+C3/Ris ++m52Noz//ktr1oauu1rP5JOmyefZrAAAAAAAAAAAAAAAAgPfyBSAk6WkAKAAA +diff --git 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-003015/tests/test.sh b/tasks/format-code-task-003015/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..50030a05337047d64fbe12ee587c8e072cf34425 --- /dev/null +++ b/tasks/format-code-task-003015/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/interpreters/test_arith_interpreter.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-003015/tests/test_command.sh b/tasks/format-code-task-003015/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003015/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003049/environment/Dockerfile b/tasks/format-code-task-003049/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7973430b7ff8979c1c08a1a0a8763095986091c5 --- /dev/null +++ b/tasks/format-code-task-003049/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f49febe01c48c0426d08e09a4e153de8aebe4d9a7d95ff445a0d5f388b07bcfd diff --git a/tasks/format-code-task-003049/environment/setup/files/blocklist b/tasks/format-code-task-003049/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003049/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003049/environment/setup/setup.sh b/tasks/format-code-task-003049/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003049/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003049/tests/test.patch b/tasks/format-code-task-003049/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7dccff6ada496d471d88a2d46221efbb1dd4688 --- /dev/null +++ b/tasks/format-code-task-003049/tests/test.patch @@ -0,0 +1,175 @@ +diff --git a/pkg/zeaburpack/image_multistage_test.go b/pkg/zeaburpack/image_multistage_test.go +new file mode 100644 +index 0000000..4eb2558 +--- /dev/null ++++ b/pkg/zeaburpack/image_multistage_test.go +@@ -0,0 +1,148 @@ ++package zeaburpack_test ++ ++import ( ++ "os" ++ "path/filepath" ++ "strings" ++ "testing" ++ ++ "github.com/stretchr/testify/require" ++ "github.com/zeabur/zbpack/pkg/zeaburpack" ++) ++ ++func TestDockerfileProxyRewritePreservesStageAlias(t *testing.T) { ++ lines := captureRewrittenDockerfile(t, "proxy.example.test/cache/", ` ++FROM node:20 AS builder ++RUN echo ok ++FROM builder ++RUN echo done ++`) ++ ++ fromLines := dockerfileFromLines(lines) ++ require.Len(t, fromLines, 2) ++ require.Equal(t, "FROM proxy.example.test/cache/library/node:20 AS builder", fromLines[0]) ++ require.Equal(t, "FROM builder", fromLines[1]) ++ require.NotContains(t, fromLines[1], "proxy.example.test/cache/") ++} ++ ++func TestDockerfileProxyRewriteHandlesLowercaseAsDeclaration(t *testing.T) { ++ lines := captureRewrittenDockerfile(t, "proxy.example.test/cache/", ` ++FROM golang:1.21 as buildstage ++RUN echo ok ++FROM buildstage ++RUN echo done ++`) ++ ++ fromLines := dockerfileFromLines(lines) ++ require.Len(t, fromLines, 2) ++ require.True(t, strings.EqualFold("FROM proxy.example.test/cache/library/golang:1.21 AS buildstage", fromLines[0]), fromLines[0]) ++ require.Equal(t, "FROM buildstage", fromLines[1]) ++ require.NotContains(t, fromLines[1], "proxy.example.test/cache/") ++} ++ ++func TestDockerfileProxyRewriteLeavesMultipleStageReferencesUnproxied(t *testing.T) { ++ lines := captureRewrittenDockerfile(t, "proxy.example.test/cache/", ` ++FROM alpine:3.19 AS assets ++RUN echo assets ++FROM assets AS runtime-base ++RUN echo runtime ++FROM runtime-base ++RUN echo done ++`) ++ ++ fromLines := dockerfileFromLines(lines) ++ require.Len(t, fromLines, 3) ++ require.Equal(t, "FROM proxy.example.test/cache/library/alpine:3.19 AS assets", fromLines[0]) ++ require.Equal(t, "FROM assets AS runtime-base", fromLines[1]) ++ require.Equal(t, "FROM runtime-base", fromLines[2]) ++ require.NotContains(t, fromLines[1], "proxy.example.test/cache/") ++ require.NotContains(t, fromLines[2], "proxy.example.test/cache/") ++} ++ ++func TestDockerfileProxyRewritePlainFromStillUsesProxy(t *testing.T) { ++ lines := captureRewrittenDockerfile(t, "proxy.example.test/cache/", ` ++FROM ubuntu:22.04 ++RUN echo ok ++`) ++ ++ fromLines := dockerfileFromLines(lines) ++ require.Len(t, fromLines, 1) ++ require.Equal(t, "FROM proxy.example.test/cache/library/ubuntu:22.04", fromLines[0]) ++ require.NotContains(t, fromLines[0], " AS ") ++} ++ ++func TestDockerfileProxyRewritePlainFromUsesConfiguredProxy(t *testing.T) { ++ lines := captureRewrittenDockerfile(t, "registry.alt.test/mirror/", ` ++FROM ubuntu:22.04 ++RUN echo ok ++`) ++ ++ fromLines := dockerfileFromLines(lines) ++ require.Len(t, fromLines, 1) ++ require.Equal(t, "FROM registry.alt.test/mirror/library/ubuntu:22.04", fromLines[0]) ++ require.NotContains(t, fromLines[0], "proxy.example.test/cache/") ++ require.NotContains(t, fromLines[0], " AS ") ++} ++ ++func captureRewrittenDockerfile(t *testing.T, proxyRegistry string, dockerfile string) []string { ++ t.Helper() ++ ++ contextDir := t.TempDir() ++ require.NoError(t, os.WriteFile(filepath.Join(contextDir, "Dockerfile"), []byte(strings.TrimSpace(dockerfile)+"\n"), 0o644)) ++ ++ captureDir := t.TempDir() ++ installDockerCaptureShim(t, captureDir) ++ ++ resultImage := "example.test/hidden:latest" ++ proxy := proxyRegistry ++ err := zeaburpack.Build(&zeaburpack.BuildOptions{ ++ Path: &contextDir, ++ ResultImage: &resultImage, ++ ProxyRegistry: &proxy, ++ }) ++ require.NoError(t, err) ++ ++ captured, err := os.ReadFile(filepath.Join(captureDir, "Dockerfile.captured")) ++ require.NoError(t, err) ++ ++ return strings.Split(strings.TrimSpace(string(captured)), "\n") ++} ++ ++func installDockerCaptureShim(t *testing.T, captureDir string) { ++ t.Helper() ++ ++ binDir := t.TempDir() ++ shimPath := filepath.Join(binDir, "docker") ++ shim := `#!/bin/sh ++set -eu ++dockerfile="" ++prev="" ++for arg in "$@"; do ++ if [ "$prev" = "-f" ]; then ++ dockerfile="$arg" ++ break ++ fi ++ prev="$arg" ++done ++if [ -z "$dockerfile" ]; then ++ dockerfile="Dockerfile" ++fi ++cp "$dockerfile" "` + filepath.Join(captureDir, "Dockerfile.captured") + `" ++exit 0 ++` ++ require.NoError(t, os.WriteFile(shimPath, []byte(shim), 0o755)) ++ ++ oldPath := os.Getenv("PATH") ++ t.Setenv("PATH", binDir+string(os.PathListSeparator)+oldPath) ++} ++ ++func dockerfileFromLines(lines []string) []string { ++ fromLines := make([]string, 0) ++ for _, line := range lines { ++ line = strings.TrimSpace(line) ++ if strings.HasPrefix(strings.ToUpper(line), "FROM ") { ++ fromLines = append(fromLines, line) ++ } ++ } ++ return fromLines ++} +diff --git 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 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ go test -v -run '^TestReferenceConstructor_Construct$' ./pkg/zeaburpack/ ++ ;; ++ new) ++ go test -v -run '^TestDockerfileProxyRewrite(PreservesStageAlias|HandlesLowercaseAsDeclaration|LeavesMultipleStageReferencesUnproxied|PlainFromStillUsesProxy|PlainFromUsesConfiguredProxy)$' ./pkg/zeaburpack/ ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-003049/tests/test.sh b/tasks/format-code-task-003049/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fa5529fa731c936c1f19ba167d32861589f96427 --- /dev/null +++ b/tasks/format-code-task-003049/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/zeaburpack/image_multistage_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-003049/tests/test_command.sh b/tasks/format-code-task-003049/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-003049/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-003061/environment/Dockerfile b/tasks/format-code-task-003061/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..81735086e699b38007db44a54bc3aa56a2348c77 --- /dev/null +++ b/tasks/format-code-task-003061/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c21ca44b8ddb2f8a0e43c7971716461e93bc95f20e5886c7ac4143be2c03210f diff --git a/tasks/format-code-task-003061/environment/setup/files/blocklist b/tasks/format-code-task-003061/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003061/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003061/environment/setup/setup.sh b/tasks/format-code-task-003061/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003061/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003061/tests/test.patch b/tasks/format-code-task-003061/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..85391c95c54508085997b05f4011171c50df484b --- /dev/null +++ b/tasks/format-code-task-003061/tests/test.patch @@ -0,0 +1,216 @@ +diff --git a/test/unit/BinaryCharsetEciTest.cpp b/test/unit/BinaryCharsetEciTest.cpp +new file mode 100644 +index 00000000..ecb0edb2 +--- /dev/null ++++ b/test/unit/BinaryCharsetEciTest.cpp +@@ -0,0 +1,120 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++#include "CharacterSet.h" ++#include "CharacterSetECI.h" ++#include "TextDecoder.h" ++#include "TextEncoder.h" ++ ++#include "gtest/gtest.h" ++#include "gmock/gmock.h" ++ ++#include ++ ++using namespace ZXing; ++using namespace ZXing::CharacterSetECI; ++using namespace testing; ++ ++ ++ ++TEST(BinaryCharsetEciTest, ResolvesFromEciNumber) ++{ ++ EXPECT_EQ(CharsetFromValue(899), CharacterSet::BINARY); ++} ++ ++TEST(BinaryCharsetEciTest, ResolvesFromName) ++{ ++ EXPECT_EQ(CharsetFromName("BINARY"), CharacterSet::BINARY); ++ ++ EXPECT_EQ(CharsetFromName("binary"), CharacterSet::BINARY); ++ EXPECT_EQ(CharsetFromName("Binary"), CharacterSet::BINARY); ++} ++ ++TEST(BinaryCharsetEciTest, BinaryReportsEci899) ++{ ++ EXPECT_EQ(ValueForCharset(CharacterSet::BINARY), 899); ++} ++ ++ ++ ++TEST(BinaryCharsetEciTest, Iso8859_1ReportsModernEci3) ++{ ++ EXPECT_EQ(ValueForCharset(CharacterSet::ISO8859_1), 3); ++} ++ ++TEST(BinaryCharsetEciTest, NoEciAssignmentReportsMinusOne) ++{ ++ EXPECT_EQ(ValueForCharset(CharacterSet::Unknown), -1); ++} ++ ++TEST(BinaryCharsetEciTest, UnambiguousDesignatorsUnchanged) ++{ ++ EXPECT_EQ(ValueForCharset(CharacterSet::ISO8859_2), 4); ++ EXPECT_EQ(ValueForCharset(CharacterSet::UTF8), 26); ++ EXPECT_EQ(ValueForCharset(CharacterSet::EUC_KR), 30); ++} ++ ++ ++ ++TEST(BinaryCharsetEciTest, ForwardLookupsConsistent) ++{ ++ EXPECT_EQ(CharsetFromValue(3), CharacterSet::ISO8859_1); ++ EXPECT_EQ(CharsetFromValue(4), CharacterSet::ISO8859_2); ++ EXPECT_EQ(CharsetFromValue(26), CharacterSet::UTF8); ++ EXPECT_EQ(CharsetFromName("UTF-8"), CharacterSet::UTF8); ++ EXPECT_EQ(CharsetFromName("ISO-8859-1"), CharacterSet::ISO8859_1); ++} ++ ++ ++ ++TEST(BinaryCharsetEciTest, DecodeIsByteTransparent) ++{ ++ uint8_t data[256]; ++ for (int i = 0; i < 256; i++) ++ data[i] = static_cast(i); ++ ++ std::wstring str; ++ TextDecoder::Append(str, data, sizeof(data), CharacterSet::BINARY); ++ ++ ASSERT_EQ(str.size(), static_cast(256)); ++ for (int i = 0; i < 256; i++) ++ EXPECT_EQ(static_cast(str[i]), i) << "byte " << i; ++} ++ ++ ++ ++TEST(BinaryCharsetEciTest, EncodeRoundTrips) ++{ ++ uint8_t data[256]; ++ for (int i = 0; i < 256; i++) ++ data[i] = static_cast(i); ++ ++ std::wstring str; ++ TextDecoder::Append(str, data, sizeof(data), CharacterSet::BINARY); ++ ++ std::string bytes = TextEncoder::FromUnicode(str, CharacterSet::BINARY); ++ ++ ASSERT_EQ(bytes.size(), static_cast(256)); ++ for (int i = 0; i < 256; i++) ++ EXPECT_EQ(static_cast(bytes[i]), static_cast(i)) << "byte " << i; ++} ++ ++TEST(BinaryCharsetEciTest, EncodeRejectsCodePointsAbove0xFF) ++{ ++ EXPECT_THROW( ++ { TextEncoder::FromUnicode(std::wstring(L"\u0100"), CharacterSet::BINARY); }, ++ std::invalid_argument); ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,85 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++CXX="${CXX:-g++}" ++SRC=/testbed/core/src ++TESTDIR=/testbed/test/unit ++BUILD=/tmp/zx_grade_build ++CXXFLAGS="-std=c++17 -O1 -include cstdint -DZXING_BUILD_FOR_TEST" ++ ++ ++GTEST_DIR="" ++for cand in \ ++ /testbed/build/_deps/fmtlib-src/test \ ++ "$(dirname "$(find / -path '*/test/gmock-gtest-all.cc' 2>/dev/null | head -n1)" 2>/dev/null)"; do ++ if [ -n "$cand" ] && [ -f "$cand/gmock-gtest-all.cc" ] && [ -f "$cand/gtest/gtest.h" ]; then ++ GTEST_DIR="$cand" ++ break ++ fi ++done ++if [ -z "$GTEST_DIR" ]; then ++ echo "FATAL: could not locate a bundled googletest in the image" >&2 ++ exit 1 ++fi ++GTEST_ALL="$GTEST_DIR/gmock-gtest-all.cc" ++ ++ ++rm -rf "$BUILD" ++mkdir -p "$BUILD" ++cmake -S /testbed/core -B "$BUILD" \ ++ -DCMAKE_BUILD_TYPE=Release \ ++ -DBUILD_SHARED_LIBS=OFF \ ++ -DBUILD_WRITERS=ON \ ++ -DBUILD_READERS=ON \ ++ -DCMAKE_CXX_FLAGS="-include cstdint -DZXING_BUILD_FOR_TEST" >/dev/null ++cmake --build "$BUILD" -j "$(nproc)" >/dev/null ++LIB="$BUILD/libZXing.a" ++ ++ ++MAIN=/tmp/zx_grade_main.cpp ++cat > "$MAIN" <<'EOF' ++#include "gtest/gtest.h" ++#include "gmock/gmock.h" ++int main(int argc, char** argv) { ++ ::testing::InitGoogleMock(&argc, argv); ++ return RUN_ALL_TESTS(); ++} ++EOF ++ ++INCLUDES="-I $SRC -I $TESTDIR -I $GTEST_DIR -I $GTEST_DIR/gtest" ++ ++build_and_run() { ++ local out="$1"; shift ++ # shellcheck disable=SC2086 ++ $CXX $CXXFLAGS $INCLUDES "$MAIN" "$@" "$GTEST_ALL" "$LIB" -lpthread -o "$out" ++ "$out" ++} ++ ++ ++build_and_run /tmp/zx_grade_regression \ ++ "$TESTDIR/BitArrayUtility.cpp" \ ++ "$TESTDIR/TextUtfEncodingTest.cpp" \ ++ "$TESTDIR/qrcode/QREncoderTest.cpp" \ ++ "$TESTDIR/pdf417/PDF417HighLevelEncoderTest.cpp" ++ ++ ++build_and_run /tmp/zx_grade_new \ ++ "$TESTDIR/BinaryCharsetEciTest.cpp" diff --git a/tasks/format-code-task-003061/tests/test.sh b/tasks/format-code-task-003061/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd680333dfef003071955ef23a317d95540a49cf --- /dev/null +++ b/tasks/format-code-task-003061/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/unit/BinaryCharsetEciTest.cpp +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-003061/tests/test_command.sh b/tasks/format-code-task-003061/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003061/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file