Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/format-code-task-000001/environment/Dockerfile +3 -0
- tasks/format-code-task-000001/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000001/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000001/tests/test.patch +216 -0
- tasks/format-code-task-000001/tests/test.sh +39 -0
- tasks/format-code-task-000001/tests/test_command.sh +1 -0
- tasks/format-code-task-000008/environment/Dockerfile +3 -0
- tasks/format-code-task-000008/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000008/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000008/tests/test.patch +208 -0
- tasks/format-code-task-000008/tests/test.sh +39 -0
- tasks/format-code-task-000008/tests/test_command.sh +1 -0
- tasks/format-code-task-000030/environment/Dockerfile +3 -0
- tasks/format-code-task-000030/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000030/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000030/tests/test.patch +124 -0
- tasks/format-code-task-000030/tests/test.sh +39 -0
- tasks/format-code-task-000030/tests/test_command.sh +1 -0
- tasks/format-code-task-000037/environment/Dockerfile +3 -0
- tasks/format-code-task-000037/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000037/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000037/tests/test.patch +131 -0
- tasks/format-code-task-000037/tests/test.sh +39 -0
- tasks/format-code-task-000037/tests/test_command.sh +1 -0
- tasks/format-code-task-000039/environment/Dockerfile +3 -0
- tasks/format-code-task-000039/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000039/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000039/tests/test.patch +354 -0
- tasks/format-code-task-000039/tests/test.sh +40 -0
- tasks/format-code-task-000039/tests/test_command.sh +1 -0
- tasks/format-code-task-000053/environment/Dockerfile +3 -0
- tasks/format-code-task-000053/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000053/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000053/tests/test.patch +385 -0
- tasks/format-code-task-000053/tests/test.sh +48 -0
- tasks/format-code-task-000053/tests/test_command.sh +1 -0
- tasks/format-code-task-000055/environment/Dockerfile +3 -0
- tasks/format-code-task-000055/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000055/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000055/tests/test.sh +41 -0
- tasks/format-code-task-000062/environment/Dockerfile +3 -0
- tasks/format-code-task-000062/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000062/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000062/tests/test.patch +85 -0
- tasks/format-code-task-000062/tests/test.sh +40 -0
- tasks/format-code-task-000062/tests/test_command.sh +1 -0
- tasks/format-code-task-000065/environment/Dockerfile +3 -0
- tasks/format-code-task-000065/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000065/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000065/tests/test.patch +212 -0
tasks/format-code-task-000001/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f0701aeb7d0813fe06c2b72bb6b558df48cefb21be6a283fbb0250b317b45e12
|
tasks/format-code-task-000001/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000001/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000001/tests/test.patch
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/state/transition_recoverable_test.go b/state/transition_recoverable_test.go
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 00000000..2a31e771
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/state/transition_recoverable_test.go
|
| 6 |
+
@@ -0,0 +1,114 @@
|
| 7 |
+
+package state
|
| 8 |
+
+
|
| 9 |
+
+import (
|
| 10 |
+
+ "math/big"
|
| 11 |
+
+ "testing"
|
| 12 |
+
+
|
| 13 |
+
+ "github.com/0xPolygon/polygon-sdk/chain"
|
| 14 |
+
+ "github.com/0xPolygon/polygon-sdk/state/runtime"
|
| 15 |
+
+ "github.com/0xPolygon/polygon-sdk/types"
|
| 16 |
+
+ "github.com/hashicorp/go-hclog"
|
| 17 |
+
+ "github.com/stretchr/testify/assert"
|
| 18 |
+
+)
|
| 19 |
+
+
|
| 20 |
+
+
|
| 21 |
+
+
|
| 22 |
+
+func newRecoverableTransition(
|
| 23 |
+
+ preState map[types.Address]*PreState,
|
| 24 |
+
+ blockGasLimit uint64,
|
| 25 |
+
+ remainingGas uint64,
|
| 26 |
+
+) *Transition {
|
| 27 |
+
+ return &Transition{
|
| 28 |
+
+ logger: hclog.NewNullLogger(),
|
| 29 |
+
+ r: &Executor{config: &chain.Params{}},
|
| 30 |
+
+ state: newTestTxn(preState),
|
| 31 |
+
+ config: chain.ForksInTime{},
|
| 32 |
+
+ ctx: runtime.TxContext{GasLimit: int64(blockGasLimit)},
|
| 33 |
+
+ gasPool: remainingGas,
|
| 34 |
+
+ }
|
| 35 |
+
+}
|
| 36 |
+
+
|
| 37 |
+
+func TestWriteTransactionRecoverability(t *testing.T) {
|
| 38 |
+
+ sender := types.StringToAddress("1")
|
| 39 |
+
+ receiver := types.StringToAddress("2")
|
| 40 |
+
+
|
| 41 |
+
+ testTable := []struct {
|
| 42 |
+
+ name string
|
| 43 |
+
+ preState map[types.Address]*PreState
|
| 44 |
+
+ blockGasLimit uint64
|
| 45 |
+
+ remainingGas uint64
|
| 46 |
+
+ txGas uint64
|
| 47 |
+
+ txGasPrice int64
|
| 48 |
+
+ txNonce uint64
|
| 49 |
+
+ isRecoverable bool
|
| 50 |
+
+ }{
|
| 51 |
+
+ {
|
| 52 |
+
+ name: "gas exceeding the block gas limit is non-recoverable",
|
| 53 |
+
+ preState: map[types.Address]*PreState{
|
| 54 |
+
+ sender: {Nonce: 0, Balance: 100000000000},
|
| 55 |
+
+ },
|
| 56 |
+
+ blockGasLimit: 8000000,
|
| 57 |
+
+ remainingGas: 8000000,
|
| 58 |
+
+ txGas: 10000000,
|
| 59 |
+
+ txGasPrice: 1,
|
| 60 |
+
+ txNonce: 0,
|
| 61 |
+
+ isRecoverable: false,
|
| 62 |
+
+ },
|
| 63 |
+
+ {
|
| 64 |
+
+ name: "fits the block but not the remaining gas is recoverable",
|
| 65 |
+
+ preState: map[types.Address]*PreState{
|
| 66 |
+
+ sender: {Nonce: 0, Balance: 100000000000},
|
| 67 |
+
+ },
|
| 68 |
+
+ blockGasLimit: 8000000,
|
| 69 |
+
+ remainingGas: 1000000,
|
| 70 |
+
+ txGas: 5000000,
|
| 71 |
+
+ txGasPrice: 1,
|
| 72 |
+
+ txNonce: 0,
|
| 73 |
+
+ isRecoverable: true,
|
| 74 |
+
+ },
|
| 75 |
+
+ {
|
| 76 |
+
+ name: "incorrect nonce is recoverable",
|
| 77 |
+
+ preState: map[types.Address]*PreState{
|
| 78 |
+
+ sender: {Nonce: 5, Balance: 100000000000},
|
| 79 |
+
+ },
|
| 80 |
+
+ blockGasLimit: 8000000,
|
| 81 |
+
+ remainingGas: 8000000,
|
| 82 |
+
+ txGas: 21000,
|
| 83 |
+
+ txGasPrice: 1,
|
| 84 |
+
+ txNonce: 0,
|
| 85 |
+
+ isRecoverable: true,
|
| 86 |
+
+ },
|
| 87 |
+
+ {
|
| 88 |
+
+ name: "not enough funds to cover the gas cost is recoverable",
|
| 89 |
+
+ preState: map[types.Address]*PreState{
|
| 90 |
+
+ sender: {Nonce: 0, Balance: 10},
|
| 91 |
+
+ },
|
| 92 |
+
+ blockGasLimit: 8000000,
|
| 93 |
+
+ remainingGas: 8000000,
|
| 94 |
+
+ txGas: 21000,
|
| 95 |
+
+ txGasPrice: 1000,
|
| 96 |
+
+ txNonce: 0,
|
| 97 |
+
+ isRecoverable: true,
|
| 98 |
+
+ },
|
| 99 |
+
+ }
|
| 100 |
+
+
|
| 101 |
+
+ for _, tc := range testTable {
|
| 102 |
+
+ t.Run(tc.name, func(t *testing.T) {
|
| 103 |
+
+ transition := newRecoverableTransition(tc.preState, tc.blockGasLimit, tc.remainingGas)
|
| 104 |
+
+
|
| 105 |
+
+ txn := &types.Transaction{
|
| 106 |
+
+ From: sender,
|
| 107 |
+
+ To: &receiver,
|
| 108 |
+
+ Nonce: tc.txNonce,
|
| 109 |
+
+ Gas: tc.txGas,
|
| 110 |
+
+ GasPrice: big.NewInt(tc.txGasPrice),
|
| 111 |
+
+ Value: big.NewInt(0),
|
| 112 |
+
+ }
|
| 113 |
+
+
|
| 114 |
+
+ appErr := transition.Write(txn)
|
| 115 |
+
+ if assert.NotNil(t, appErr, "expected the write to fail") {
|
| 116 |
+
+ assert.Equal(t, tc.isRecoverable, appErr.IsRecoverable)
|
| 117 |
+
+ }
|
| 118 |
+
+ })
|
| 119 |
+
+ }
|
| 120 |
+
+}
|
| 121 |
+
diff --git a/txpool/decrease_nonce_test.go b/txpool/decrease_nonce_test.go
|
| 122 |
+
new file mode 100644
|
| 123 |
+
index 00000000..363c9b23
|
| 124 |
+
--- /dev/null
|
| 125 |
+
+++ b/txpool/decrease_nonce_test.go
|
| 126 |
+
@@ -0,0 +1,69 @@
|
| 127 |
+
+package txpool
|
| 128 |
+
+
|
| 129 |
+
+import (
|
| 130 |
+
+ "math/big"
|
| 131 |
+
+ "testing"
|
| 132 |
+
+
|
| 133 |
+
+ "github.com/0xPolygon/polygon-sdk/types"
|
| 134 |
+
+ "github.com/hashicorp/go-hclog"
|
| 135 |
+
+ "github.com/stretchr/testify/assert"
|
| 136 |
+
+)
|
| 137 |
+
+
|
| 138 |
+
+func TestDecreaseAccountNonce(t *testing.T) {
|
| 139 |
+
+ pool, err := NewTxPool(hclog.NewNullLogger(), false, forks.At(0), &mockStore{}, nil, nil)
|
| 140 |
+
+ assert.NoError(t, err)
|
| 141 |
+
+ pool.EnableDev()
|
| 142 |
+
+
|
| 143 |
+
+ addr := types.Address{0x1}
|
| 144 |
+
+
|
| 145 |
+
+ tx0 := &types.Transaction{
|
| 146 |
+
+ From: addr,
|
| 147 |
+
+ Nonce: 0,
|
| 148 |
+
+ Gas: validGasLimit,
|
| 149 |
+
+ GasPrice: big.NewInt(1),
|
| 150 |
+
+ Value: big.NewInt(0),
|
| 151 |
+
+ }
|
| 152 |
+
+ tx1 := &types.Transaction{
|
| 153 |
+
+ From: addr,
|
| 154 |
+
+ Nonce: 1,
|
| 155 |
+
+ Gas: validGasLimit,
|
| 156 |
+
+ GasPrice: big.NewInt(1),
|
| 157 |
+
+ Value: big.NewInt(0),
|
| 158 |
+
+ }
|
| 159 |
+
+ assert.NoError(t, pool.addImpl("", tx0))
|
| 160 |
+
+ assert.NoError(t, pool.addImpl("", tx1))
|
| 161 |
+
+
|
| 162 |
+
+ nonce, ok := pool.GetNonce(addr)
|
| 163 |
+
+ assert.True(t, ok)
|
| 164 |
+
+ assert.Equal(t, uint64(2), nonce)
|
| 165 |
+
+
|
| 166 |
+
+
|
| 167 |
+
+ pool.DecreaseAccountNonce(tx1)
|
| 168 |
+
+
|
| 169 |
+
+ nonce, ok = pool.GetNonce(addr)
|
| 170 |
+
+ assert.True(t, ok)
|
| 171 |
+
+ assert.Equal(t, uint64(1), nonce)
|
| 172 |
+
+}
|
| 173 |
+
+
|
| 174 |
+
+func TestDecreaseAccountNonce_UntrackedAccount(t *testing.T) {
|
| 175 |
+
+ pool, err := NewTxPool(hclog.NewNullLogger(), false, forks.At(0), &mockStore{}, nil, nil)
|
| 176 |
+
+ assert.NoError(t, err)
|
| 177 |
+
+ pool.EnableDev()
|
| 178 |
+
+
|
| 179 |
+
+ untracked := types.Address{0x9}
|
| 180 |
+
+ tx := &types.Transaction{
|
| 181 |
+
+ From: untracked,
|
| 182 |
+
+ Nonce: 0,
|
| 183 |
+
+ Gas: validGasLimit,
|
| 184 |
+
+ GasPrice: big.NewInt(1),
|
| 185 |
+
+ Value: big.NewInt(0),
|
| 186 |
+
+ }
|
| 187 |
+
+
|
| 188 |
+
+
|
| 189 |
+
+ assert.NotPanics(t, func() {
|
| 190 |
+
+ pool.DecreaseAccountNonce(tx)
|
| 191 |
+
+ })
|
| 192 |
+
+
|
| 193 |
+
+ _, ok := pool.GetNonce(untracked)
|
| 194 |
+
+ assert.False(t, ok)
|
| 195 |
+
+}
|
| 196 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 197 |
+
new file mode 100755
|
| 198 |
+
--- /dev/null
|
| 199 |
+
+++ b/mimo_test_command.sh
|
| 200 |
+
@@ -0,0 +1,16 @@
|
| 201 |
+
+#!/usr/bin/env bash
|
| 202 |
+
+
|
| 203 |
+
+
|
| 204 |
+
+
|
| 205 |
+
+set -euo pipefail
|
| 206 |
+
+HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| 207 |
+
+cd /testbed
|
| 208 |
+
+
|
| 209 |
+
+
|
| 210 |
+
+
|
| 211 |
+
+
|
| 212 |
+
+go test ./state/... ./txpool/... ./types/...
|
| 213 |
+
+
|
| 214 |
+
+
|
| 215 |
+
+go test -run 'TestWriteTransactionRecoverability' ./state/
|
| 216 |
+
+go test -run 'TestDecreaseAccountNonce' ./txpool/
|
tasks/format-code-task-000001/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
state/transition_recoverable_test.go
|
| 25 |
+
txpool/decrease_nonce_test.go
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000001/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000008/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f83df347542976209efc13596eabae5e46f35b4330f7fae6fa9e487c5493f0dd
|
tasks/format-code-task-000008/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000008/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/workspace/repo
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000008/tests/test.patch
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/usercase-test-coderl/fixtures/open_flags_scene.py b/usercase-test-coderl/fixtures/open_flags_scene.py
|
| 2 |
+
new file mode 100644
|
| 3 |
+
--- /dev/null
|
| 4 |
+
+++ b/usercase-test-coderl/fixtures/open_flags_scene.py
|
| 5 |
+
@@ -0,0 +1,11 @@
|
| 6 |
+
+from manimlib.scene.scene import Scene
|
| 7 |
+
+
|
| 8 |
+
+
|
| 9 |
+
+class EmptyScene(Scene):
|
| 10 |
+
+ def construct(self):
|
| 11 |
+
+ self.wait(0.1)
|
| 12 |
+
+
|
| 13 |
+
+
|
| 14 |
+
+class OtherScene(Scene):
|
| 15 |
+
+ def construct(self):
|
| 16 |
+
+ self.wait(0.1)
|
| 17 |
+
diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh
|
| 18 |
+
new file mode 100755
|
| 19 |
+
--- /dev/null
|
| 20 |
+
+++ b/usercase-test-coderl/usecase.sh
|
| 21 |
+
@@ -0,0 +1,170 @@
|
| 22 |
+
+#!/usr/bin/env bash
|
| 23 |
+
+
|
| 24 |
+
+set -u
|
| 25 |
+
+export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC
|
| 26 |
+
+
|
| 27 |
+
+
|
| 28 |
+
+
|
| 29 |
+
+export PYTHONPATH="/workspace/repo:${PYTHONPATH:-}"
|
| 30 |
+
+
|
| 31 |
+
+command -v xvfb-run >/dev/null 2>&1 \
|
| 32 |
+
+ || { echo "FAIL: xvfb-run is required for ManimGL rendering in this environment" >&2; exit 1; }
|
| 33 |
+
+
|
| 34 |
+
+MANIMGL_BIN=$(command -v manimgl || true)
|
| 35 |
+
+MANIM_RENDER_BIN=$(command -v manim-render || true)
|
| 36 |
+
+[ -n "$MANIMGL_BIN" ] || { echo "FAIL: manimgl not found after build" >&2; exit 1; }
|
| 37 |
+
+[ -n "$MANIM_RENDER_BIN" ] || { echo "FAIL: manim-render not found after build" >&2; exit 1; }
|
| 38 |
+
+
|
| 39 |
+
+ROOT=/workspace/repo/usercase-test-coderl
|
| 40 |
+
+SCENE="$ROOT/fixtures/open_flags_scene.py"
|
| 41 |
+
+TMP=$(mktemp -d)
|
| 42 |
+
+trap 'rm -rf "$TMP"' EXIT
|
| 43 |
+
+cd "$TMP" || exit 1
|
| 44 |
+
+fail() { echo "FAIL: $*" >&2; exit 1; }
|
| 45 |
+
+
|
| 46 |
+
+mkdir -p "$TMP/bin" "$TMP/media"
|
| 47 |
+
+cat > "$TMP/bin/xdg-open" <<'SH'
|
| 48 |
+
+#!/usr/bin/env bash
|
| 49 |
+
+printf '%s\n' "$*" >> "$XDG_OPEN_LOG"
|
| 50 |
+
+exit 0
|
| 51 |
+
+SH
|
| 52 |
+
+chmod +x "$TMP/bin/xdg-open"
|
| 53 |
+
+export PATH="$TMP/bin:$PATH"
|
| 54 |
+
+export XDG_OPEN_LOG="$TMP/xdg-open.log"
|
| 55 |
+
+
|
| 56 |
+
+run_render() {
|
| 57 |
+
+ local bin="$1"
|
| 58 |
+
+ shift
|
| 59 |
+
+ : > "$XDG_OPEN_LOG"
|
| 60 |
+
+ rm -rf "$TMP/media"
|
| 61 |
+
+ mkdir -p "$TMP/media"
|
| 62 |
+
+ xvfb-run -a "$bin" "$SCENE" EmptyScene "$@" -r 16x16 --fps 1 --quiet >out 2>err
|
| 63 |
+
+ ec=$?
|
| 64 |
+
+}
|
| 65 |
+
+
|
| 66 |
+
+assert_no_crash_output() {
|
| 67 |
+
+
|
| 68 |
+
+
|
| 69 |
+
+ ! grep -Eiq 'Traceback|SyntaxError|Exception:' out err \
|
| 70 |
+
+ || fail "$1 unexpected crash output: stdout=$(cat out) stderr=$(cat err)"
|
| 71 |
+
+}
|
| 72 |
+
+
|
| 73 |
+
+help_block_for() {
|
| 74 |
+
+ grep -A1 -F -- "$1" out | tr '[:upper:]' '[:lower:]'
|
| 75 |
+
+}
|
| 76 |
+
+
|
| 77 |
+
+assert_finder_log_reveals() {
|
| 78 |
+
+ local label="$1"
|
| 79 |
+
+ local file="$2"
|
| 80 |
+
+ local dir
|
| 81 |
+
+ dir=$(dirname "$file")
|
| 82 |
+
+ local log
|
| 83 |
+
+ log=$(cat "$XDG_OPEN_LOG")
|
| 84 |
+
+
|
| 85 |
+
+
|
| 86 |
+
+
|
| 87 |
+
+ case "$log" in
|
| 88 |
+
+ "-R $file"|"--reveal $file"|"--select $file"|"$dir") ;;
|
| 89 |
+
+ *) fail "$label opener log: $log" ;;
|
| 90 |
+
+ esac
|
| 91 |
+
+}
|
| 92 |
+
+
|
| 93 |
+
+
|
| 94 |
+
+
|
| 95 |
+
+
|
| 96 |
+
+"$MANIMGL_BIN" --help >out 2>err; ec=$?
|
| 97 |
+
+[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0"
|
| 98 |
+
+
|
| 99 |
+
+
|
| 100 |
+
+open_help=$(help_block_for "--open")
|
| 101 |
+
+printf '%s\n' "$open_help" | grep -Fq -- "--open" || fail "F1 missing --open help"
|
| 102 |
+
+printf '%s\n' "$open_help" | grep -Eq -- '(^|[[:space:]])-o([,[:space:]]|$)' \
|
| 103 |
+
+ || fail "F1 missing -o help alias"
|
| 104 |
+
+printf '%s\n' "$open_help" | grep -Eq -- '(open|launch).*(saved|output|file)|(saved|output|file).*(open|launch)' \
|
| 105 |
+
+ || fail "F1 --open help does not describe opening the saved file"
|
| 106 |
+
+
|
| 107 |
+
+
|
| 108 |
+
+finder_help=$(help_block_for "--finder")
|
| 109 |
+
+printf '%s\n' "$finder_help" | grep -Fq -- "--finder" || fail "F1 missing --finder help"
|
| 110 |
+
+printf '%s\n' "$finder_help" | grep -Eq -- '(show|reveal|browser|file manager|file explorer)' \
|
| 111 |
+
+ || fail "F1 --finder help does not describe showing/revealing output"
|
| 112 |
+
+printf '%s\n' "$finder_help" | grep -Eq -- '(output|file|directory|folder)' \
|
| 113 |
+
+ || fail "F1 --finder help does not mention the output file/location"
|
| 114 |
+
+assert_no_crash_output F1
|
| 115 |
+
+
|
| 116 |
+
+
|
| 117 |
+
+
|
| 118 |
+
+
|
| 119 |
+
+run_render "$MANIMGL_BIN" --open --video_dir "$TMP/media" --file_name opened_movie
|
| 120 |
+
+[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0"
|
| 121 |
+
+assert_no_crash_output F2
|
| 122 |
+
+[ -f "$TMP/media/opened_movie.mp4" ] || fail "F2 missing movie file"
|
| 123 |
+
+[ "$(cat "$XDG_OPEN_LOG")" = "$TMP/media/opened_movie.mp4" ] \
|
| 124 |
+
+ || fail "F2 opener log: $(cat "$XDG_OPEN_LOG")"
|
| 125 |
+
+
|
| 126 |
+
+
|
| 127 |
+
+
|
| 128 |
+
+
|
| 129 |
+
+run_render "$MANIMGL_BIN" -o --video_dir "$TMP/media" --file_name short_open_movie
|
| 130 |
+
+[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0"
|
| 131 |
+
+assert_no_crash_output F3
|
| 132 |
+
+[ -f "$TMP/media/short_open_movie.mp4" ] || fail "F3 missing movie file"
|
| 133 |
+
+[ "$(cat "$XDG_OPEN_LOG")" = "$TMP/media/short_open_movie.mp4" ] \
|
| 134 |
+
+ || fail "F3 opener log: $(cat "$XDG_OPEN_LOG")"
|
| 135 |
+
+
|
| 136 |
+
+
|
| 137 |
+
+
|
| 138 |
+
+
|
| 139 |
+
+run_render "$MANIMGL_BIN" --finder --video_dir "$TMP/media" --file_name revealed_movie
|
| 140 |
+
+[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0"
|
| 141 |
+
+assert_no_crash_output F4
|
| 142 |
+
+[ -f "$TMP/media/revealed_movie.mp4" ] || fail "F4 missing movie file"
|
| 143 |
+
+assert_finder_log_reveals F4 "$TMP/media/revealed_movie.mp4"
|
| 144 |
+
+
|
| 145 |
+
+
|
| 146 |
+
+
|
| 147 |
+
+
|
| 148 |
+
+run_render "$MANIMGL_BIN" --open --skip_animations --video_dir "$TMP/media" --file_name opened_image
|
| 149 |
+
+[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0"
|
| 150 |
+
+assert_no_crash_output F5
|
| 151 |
+
+[ -f "$TMP/media/opened_image.png" ] || fail "F5 missing image file"
|
| 152 |
+
+[ ! -e "$TMP/media/opened_image.mp4" ] || fail "F5 unexpectedly wrote a movie"
|
| 153 |
+
+[ "$(cat "$XDG_OPEN_LOG")" = "$TMP/media/opened_image.png" ] \
|
| 154 |
+
+ || fail "F5 opener log: $(cat "$XDG_OPEN_LOG")"
|
| 155 |
+
+
|
| 156 |
+
+
|
| 157 |
+
+
|
| 158 |
+
+
|
| 159 |
+
+run_render "$MANIM_RENDER_BIN" --finder --skip_animations --video_dir "$TMP/media" --file_name revealed_image
|
| 160 |
+
+[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0"
|
| 161 |
+
+assert_no_crash_output F6
|
| 162 |
+
+[ -f "$TMP/media/revealed_image.png" ] || fail "F6 missing image file"
|
| 163 |
+
+[ ! -e "$TMP/media/revealed_image.mp4" ] || fail "F6 unexpectedly wrote a movie"
|
| 164 |
+
+assert_finder_log_reveals F6 "$TMP/media/revealed_image.png"
|
| 165 |
+
+
|
| 166 |
+
+
|
| 167 |
+
+
|
| 168 |
+
+
|
| 169 |
+
+run_render "$MANIM_RENDER_BIN" --open --video_dir "$TMP/media" --file_name render_cmd_movie
|
| 170 |
+
+[ "$ec" -eq 0 ] || fail "F7 exit $ec; want 0"
|
| 171 |
+
+assert_no_crash_output F7
|
| 172 |
+
+[ -f "$TMP/media/render_cmd_movie.mp4" ] || fail "F7 missing movie file"
|
| 173 |
+
+[ "$(cat "$XDG_OPEN_LOG")" = "$TMP/media/render_cmd_movie.mp4" ] \
|
| 174 |
+
+ || fail "F7 opener log: $(cat "$XDG_OPEN_LOG")"
|
| 175 |
+
+
|
| 176 |
+
+
|
| 177 |
+
+
|
| 178 |
+
+
|
| 179 |
+
+: > "$XDG_OPEN_LOG"
|
| 180 |
+
+printf 'this is not python !!!\n' > "$TMP/broken_scene.py"
|
| 181 |
+
+xvfb-run -a "$MANIMGL_BIN" "$TMP/broken_scene.py" --open --video_dir "$TMP/media" --file_name no_scene -r 16x16 --fps 1 --quiet >out 2>err
|
| 182 |
+
+ec=$?
|
| 183 |
+
+[ "$ec" -ne 0 ] || fail "F8 exit 0; want non-zero"
|
| 184 |
+
+
|
| 185 |
+
+
|
| 186 |
+
+[ ! -e "$TMP/media/no_scene.mp4" ] || fail "F8 unexpectedly wrote a movie"
|
| 187 |
+
+[ ! -e "$TMP/media/no_scene.png" ] || fail "F8 unexpectedly wrote an image"
|
| 188 |
+
+[ ! -s "$XDG_OPEN_LOG" ] || fail "F8 opener should not be called: $(cat "$XDG_OPEN_LOG")"
|
| 189 |
+
+
|
| 190 |
+
+echo "PASS"
|
| 191 |
+
+exit 0
|
| 192 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 193 |
+
new file mode 100755
|
| 194 |
+
--- /dev/null
|
| 195 |
+
+++ b/mimo_test_command.sh
|
| 196 |
+
@@ -0,0 +1,12 @@
|
| 197 |
+
+#!/usr/bin/env bash
|
| 198 |
+
+
|
| 199 |
+
+
|
| 200 |
+
+
|
| 201 |
+
+
|
| 202 |
+
+export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096"
|
| 203 |
+
+export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC"
|
| 204 |
+
+export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC"
|
| 205 |
+
+export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g"
|
| 206 |
+
+set -e
|
| 207 |
+
+cd /workspace/repo
|
| 208 |
+
+exec bash /workspace/repo/usercase-test-coderl/usecase.sh
|
tasks/format-code-task-000008/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/workspace/repo
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
usercase-test-coderl/fixtures/open_flags_scene.py
|
| 25 |
+
usercase-test-coderl/usecase.sh
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000008/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /workspace/repo/mimo_test_command.sh
|
tasks/format-code-task-000030/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e8a9ca146420b25fb170db312469d9b11d8eb9783ac4586ec2e33a33c0bf4311
|
tasks/format-code-task-000030/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000030/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000030/tests/test.patch
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/tests/blob/blobCorsRequest.test.ts b/tests/blob/blobCorsRequest.test.ts
|
| 2 |
+
index f46468450..7fc25f36c 100644
|
| 3 |
+
--- a/tests/blob/blobCorsRequest.test.ts
|
| 4 |
+
+++ b/tests/blob/blobCorsRequest.test.ts
|
| 5 |
+
@@ -7,6 +7,7 @@ import * as assert from "assert";
|
| 6 |
+
|
| 7 |
+
import { configLogger } from "../../src/common/Logger";
|
| 8 |
+
import BlobTestServerFactory from "../BlobTestServerFactory";
|
| 9 |
+
+import { RestError } from "@azure/core-http";
|
| 10 |
+
import {
|
| 11 |
+
EMULATOR_ACCOUNT_KEY,
|
| 12 |
+
EMULATOR_ACCOUNT_NAME,
|
| 13 |
+
@@ -531,6 +532,77 @@ describe("Blob Cors requests test", () => {
|
| 14 |
+
assert.ok(res._response.status === 200);
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
+ context(
|
| 18 |
+
+ "OPTIONS request should work with matching rule containing wildcard in Origin @loki @sql",
|
| 19 |
+
+ async () => {
|
| 20 |
+
+ const testCases = [
|
| 21 |
+
+ { origin: undefined, expected: 403 },
|
| 22 |
+
+ { origin: "contoso.com", expected: 403 },
|
| 23 |
+
+ { origin: "bar.notcontoso.com", expected: 403 },
|
| 24 |
+
+ { origin: "foo.contoso.com", expected: 200 },
|
| 25 |
+
+ { origin: "foo.bar.baz.contoso.com", expected: 200 },
|
| 26 |
+
+ { origin: "foo.CONTOSO.com", expected: 200 }
|
| 27 |
+
+ ];
|
| 28 |
+
+
|
| 29 |
+
+ testCases.forEach(async (testCase) => {
|
| 30 |
+
+ it(`${testCase.origin}`, async () => {
|
| 31 |
+
+ const serviceProperties = await serviceClient.getProperties();
|
| 32 |
+
+
|
| 33 |
+
+ const newCORS = {
|
| 34 |
+
+ allowedHeaders: "header",
|
| 35 |
+
+ allowedMethods: "GET",
|
| 36 |
+
+ allowedOrigins: "*.contoso.com",
|
| 37 |
+
+ exposedHeaders: "*",
|
| 38 |
+
+ maxAgeInSeconds: 8888
|
| 39 |
+
+ };
|
| 40 |
+
+
|
| 41 |
+
+ serviceProperties.cors = [newCORS];
|
| 42 |
+
+
|
| 43 |
+
+ await serviceClient.setProperties(serviceProperties);
|
| 44 |
+
+
|
| 45 |
+
+ await sleep(100);
|
| 46 |
+
+
|
| 47 |
+
+ const origin = testCase.origin;
|
| 48 |
+
+ const requestMethod = "GET";
|
| 49 |
+
+ const expectedStatus = testCase.expected;
|
| 50 |
+
+
|
| 51 |
+
+ const pipeline = newPipeline(
|
| 52 |
+
+ new StorageSharedKeyCredential(
|
| 53 |
+
+ EMULATOR_ACCOUNT_NAME,
|
| 54 |
+
+ EMULATOR_ACCOUNT_KEY
|
| 55 |
+
+ ),
|
| 56 |
+
+ {
|
| 57 |
+
+ retryOptions: { maxTries: 1 },
|
| 58 |
+
+
|
| 59 |
+
+ keepAliveOptions: { enable: false }
|
| 60 |
+
+ }
|
| 61 |
+
+ );
|
| 62 |
+
+ pipeline.factories.unshift(
|
| 63 |
+
+ new OPTIONSRequestPolicyFactory(origin, requestMethod)
|
| 64 |
+
+ );
|
| 65 |
+
+ const serviceClientForOptions = new BlobServiceClient(
|
| 66 |
+
+ baseURL,
|
| 67 |
+
+ pipeline
|
| 68 |
+
+ );
|
| 69 |
+
+
|
| 70 |
+
+ let status: number = 0;
|
| 71 |
+
+ try {
|
| 72 |
+
+ const res = await serviceClientForOptions.getProperties();
|
| 73 |
+
+ status = res._response.status;
|
| 74 |
+
+ } catch (e: any) {
|
| 75 |
+
+ if (!(e instanceof RestError)) {
|
| 76 |
+
+ throw e;
|
| 77 |
+
+ }
|
| 78 |
+
+
|
| 79 |
+
+ status = e.response?.status || 0;
|
| 80 |
+
+ }
|
| 81 |
+
+
|
| 82 |
+
+ assert.ok(status === expectedStatus);
|
| 83 |
+
+ });
|
| 84 |
+
+ });
|
| 85 |
+
+ }
|
| 86 |
+
+ );
|
| 87 |
+
+
|
| 88 |
+
it("Response of request to service without cors rules should not contains cors info @loki @sql", async () => {
|
| 89 |
+
const serviceProperties = await serviceClient.getProperties();
|
| 90 |
+
|
| 91 |
+
@@ -714,9 +786,8 @@ describe("Blob Cors requests test", () => {
|
| 92 |
+
pipeline.factories.unshift(new OriginPolicyFactory(origin));
|
| 93 |
+
const serviceClientWithOrigin = new BlobServiceClient(baseURL, pipeline);
|
| 94 |
+
|
| 95 |
+
- const containerClientWithOrigin = serviceClientWithOrigin.getContainerClient(
|
| 96 |
+
- "notexistcontainer"
|
| 97 |
+
- );
|
| 98 |
+
+ const containerClientWithOrigin =
|
| 99 |
+
+ serviceClientWithOrigin.getContainerClient("notexistcontainer");
|
| 100 |
+
|
| 101 |
+
try {
|
| 102 |
+
await containerClientWithOrigin.getProperties();
|
| 103 |
+
diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
|
| 104 |
+
new file mode 100644
|
| 105 |
+
--- /dev/null
|
| 106 |
+
+++ b/mimo_build_env.tar.gz.b64
|
| 107 |
+
@@ -0,0 +1,6 @@
|
| 108 |
+
+H4sIAAAAAAAAA+3ST0+DMBgGcM77FP0CQCEWTyaajUSN2RLcLl4If5qtEejsWxY/vl0vLia6y5Zp
|
| 109 |
+
+fH6HvoW28IaHqB5V15Zy2MXBuXDnWghfna/VzxORJkl2lXGRBNzNeBowcbaODoxkK8NYYLS2P+07
|
| 110 |
+
+tv5HRZ/5W0m2bHTfV0Mb0eZ07ziWfyoO8uf7/F3NAsZP18L3/nn+Tct88LVsJ8P2nTVGE4Xud2Dz
|
| 111 |
+
+xSwvl0/PZZE/5tNluZrfrZb3i+LhJZ/dcLbf3OtmU7EwNPJtVEYyS+GgWxkbuVZkpXFLgw6t6qUe
|
| 112 |
+
+LbmrtZFbdtvpV+VPNaMhtXPnXAMU152u/TDVhgr3SHc3sn6gyaW/EwAAAAAAAAAAAAAAAAAAAADA
|
| 113 |
+
+b/QBSL+fCwAoAAA=
|
| 114 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 115 |
+
new file mode 100755
|
| 116 |
+
--- /dev/null
|
| 117 |
+
+++ b/mimo_test_command.sh
|
| 118 |
+
@@ -0,0 +1,6 @@
|
| 119 |
+
+#!/usr/bin/env bash
|
| 120 |
+
+
|
| 121 |
+
+set -uo pipefail
|
| 122 |
+
+cd /testbed || exit 1
|
| 123 |
+
+base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
|
| 124 |
+
+exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
|
tasks/format-code-task-000030/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
tests/blob/blobCorsRequest.test.ts
|
| 25 |
+
mimo_build_env.tar.gz.b64
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000030/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000037/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3920c30b14a52e951a66b08c4fd83ea4591a427f0376ad54cd7813f86ae3eae2
|
tasks/format-code-task-000037/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000037/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000037/tests/test.patch
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/packages/components/psammead-social-embed/src/Notice/index.test.jsx b/packages/components/psammead-social-embed/src/Notice/index.test.jsx
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 000000000..ad2a67723
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/packages/components/psammead-social-embed/src/Notice/index.test.jsx
|
| 6 |
+
@@ -0,0 +1,103 @@
|
| 7 |
+
+import React from 'react';
|
| 8 |
+
+import { render } from '@testing-library/react';
|
| 9 |
+
+import 'jest-styled-components';
|
| 10 |
+
+import Notice from './index';
|
| 11 |
+
+
|
| 12 |
+
+const renderNotice = () =>
|
| 13 |
+
+ render(
|
| 14 |
+
+ <Notice
|
| 15 |
+
+ provider="twitter"
|
| 16 |
+
+ service="news"
|
| 17 |
+
+ text="Sorry but we're having trouble displaying this content"
|
| 18 |
+
+ linkText="View content on %provider_name%"
|
| 19 |
+
+ linkTextSuffixVisuallyHidden=", external"
|
| 20 |
+
+ linkHref="embed-url"
|
| 21 |
+
+ warningText="Warning: BBC is not responsible for third party content"
|
| 22 |
+
+ />,
|
| 23 |
+
+ );
|
| 24 |
+
+
|
| 25 |
+
+const KNOWN_COLOR_VALUES = [
|
| 26 |
+
+ '#222222',
|
| 27 |
+
+ '#3F3F42',
|
| 28 |
+
+ '#6E6E73',
|
| 29 |
+
+ '#AEAEB5',
|
| 30 |
+
+ '#404040',
|
| 31 |
+
+ '#000000',
|
| 32 |
+
+ '#FFFFFF',
|
| 33 |
+
+ 'inherit',
|
| 34 |
+
+ 'transparent',
|
| 35 |
+
+ 'currentColor',
|
| 36 |
+
+];
|
| 37 |
+
+
|
| 38 |
+
+const hasRule = (element, property, value, modifier) => {
|
| 39 |
+
+ try {
|
| 40 |
+
+ if (modifier) {
|
| 41 |
+
+ expect(element).toHaveStyleRule(property, value, { modifier });
|
| 42 |
+
+ } else {
|
| 43 |
+
+ expect(element).toHaveStyleRule(property, value);
|
| 44 |
+
+ }
|
| 45 |
+
+ return true;
|
| 46 |
+
+ } catch (e) {
|
| 47 |
+
+ return false;
|
| 48 |
+
+ }
|
| 49 |
+
+};
|
| 50 |
+
+
|
| 51 |
+
+const getExplicitColor = (wrapper, modifier) => {
|
| 52 |
+
+ for (let i = 0; i < KNOWN_COLOR_VALUES.length; i += 1) {
|
| 53 |
+
+ const c = KNOWN_COLOR_VALUES[i];
|
| 54 |
+
+ if (hasRule(wrapper, 'color', c, modifier)) return c;
|
| 55 |
+
+ }
|
| 56 |
+
+ return null;
|
| 57 |
+
+};
|
| 58 |
+
+
|
| 59 |
+
+const getWrapperColor = wrapper => {
|
| 60 |
+
+ for (let i = 0; i < KNOWN_COLOR_VALUES.length; i += 1) {
|
| 61 |
+
+ const c = KNOWN_COLOR_VALUES[i];
|
| 62 |
+
+ if (hasRule(wrapper, 'color', c)) return c;
|
| 63 |
+
+ }
|
| 64 |
+
+ return null;
|
| 65 |
+
+};
|
| 66 |
+
+
|
| 67 |
+
+
|
| 68 |
+
+const effectiveColorIs = (wrapper, modifier, color) => {
|
| 69 |
+
+ if (!modifier) return hasRule(wrapper, 'color', color);
|
| 70 |
+
+ const explicit = getExplicitColor(wrapper, modifier);
|
| 71 |
+
+ if (explicit && explicit !== 'inherit') return explicit === color;
|
| 72 |
+
+ return getWrapperColor(wrapper) === color;
|
| 73 |
+
+};
|
| 74 |
+
+
|
| 75 |
+
+describe('Notice fallback colours', () => {
|
| 76 |
+
+ it('paragraph text should render as C_SHADOW (#3F3F42)', () => {
|
| 77 |
+
+ const { container } = renderNotice();
|
| 78 |
+
+ expect(effectiveColorIs(container.firstChild, 'p', '#3F3F42')).toBe(true);
|
| 79 |
+
+ });
|
| 80 |
+
+
|
| 81 |
+
+ it('warning (small) text should render as C_SHADOW (#3F3F42)', () => {
|
| 82 |
+
+ const { container } = renderNotice();
|
| 83 |
+
+ expect(effectiveColorIs(container.firstChild, 'small', '#3F3F42')).toBe(
|
| 84 |
+
+ true,
|
| 85 |
+
+ );
|
| 86 |
+
+ });
|
| 87 |
+
+
|
| 88 |
+
+ it('paragraph text should no longer render as C_EBON (#222222)', () => {
|
| 89 |
+
+ const { container } = renderNotice();
|
| 90 |
+
+ expect(effectiveColorIs(container.firstChild, 'p', '#222222')).toBe(false);
|
| 91 |
+
+ });
|
| 92 |
+
+
|
| 93 |
+
+ it('link should render as C_EBON (#222222)', () => {
|
| 94 |
+
+ const { container } = renderNotice();
|
| 95 |
+
+ expect(effectiveColorIs(container.firstChild, 'a', '#222222')).toBe(true);
|
| 96 |
+
+ });
|
| 97 |
+
+
|
| 98 |
+
+ it('link should not render as C_SHADOW (#3F3F42)', () => {
|
| 99 |
+
+ const { container } = renderNotice();
|
| 100 |
+
+ expect(effectiveColorIs(container.firstChild, 'a', '#3F3F42')).toBe(false);
|
| 101 |
+
+ });
|
| 102 |
+
+
|
| 103 |
+
+ it('visited link should remain C_METAL (#6E6E73)', () => {
|
| 104 |
+
+ const { container } = renderNotice();
|
| 105 |
+
+ expect(container.firstChild).toHaveStyleRule('color', '#6E6E73', {
|
| 106 |
+
+ modifier: 'a:visited',
|
| 107 |
+
+ });
|
| 108 |
+
+ });
|
| 109 |
+
+});
|
| 110 |
+
diff --git a/test_commands.json b/test_commands.json
|
| 111 |
+
new file mode 100644
|
| 112 |
+
index 000000000..4d8854ef1
|
| 113 |
+
--- /dev/null
|
| 114 |
+
+++ b/test_commands.json
|
| 115 |
+
@@ -0,0 +1,3 @@
|
| 116 |
+
+{
|
| 117 |
+
+ "test_commands": ["npx jest packages/components/psammead-social-embed/src/Notice/index.test.jsx --no-coverage --ci"]
|
| 118 |
+
+}
|
| 119 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 120 |
+
new file mode 100755
|
| 121 |
+
--- /dev/null
|
| 122 |
+
+++ b/mimo_test_command.sh
|
| 123 |
+
@@ -0,0 +1,8 @@
|
| 124 |
+
+#!/usr/bin/env bash
|
| 125 |
+
+
|
| 126 |
+
+set -uo pipefail
|
| 127 |
+
+cd /testbed
|
| 128 |
+
+rc=0
|
| 129 |
+
+npx jest packages/components/psammead-social-embed/src/Notice/index.test.jsx --no-coverage --ci
|
| 130 |
+
+rc=$(( rc | $? ))
|
| 131 |
+
+exit $rc
|
tasks/format-code-task-000037/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
packages/components/psammead-social-embed/src/Notice/index.test.jsx
|
| 25 |
+
test_commands.json
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000037/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000039/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:36ca2c575bd37e62dc399f5da74ebc9aceb950e4f418103b3cfa3e96e993557b
|
tasks/format-code-task-000039/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000039/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000039/tests/test.patch
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/backend/aopp_approval_external_test.go b/backend/aopp_approval_external_test.go
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 000000000..58d8dce33
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/backend/aopp_approval_external_test.go
|
| 6 |
+
@@ -0,0 +1,236 @@
|
| 7 |
+
+
|
| 8 |
+
+
|
| 9 |
+
+
|
| 10 |
+
+
|
| 11 |
+
+
|
| 12 |
+
+
|
| 13 |
+
+
|
| 14 |
+
+
|
| 15 |
+
+
|
| 16 |
+
+
|
| 17 |
+
+
|
| 18 |
+
+
|
| 19 |
+
+
|
| 20 |
+
+
|
| 21 |
+
+package backend_test
|
| 22 |
+
+
|
| 23 |
+
+import (
|
| 24 |
+
+ "fmt"
|
| 25 |
+
+ "net/http"
|
| 26 |
+
+ "net/http/httptest"
|
| 27 |
+
+ "net/url"
|
| 28 |
+
+ "testing"
|
| 29 |
+
+
|
| 30 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend"
|
| 31 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/arguments"
|
| 32 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc"
|
| 33 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/types"
|
| 34 |
+
+ coinpkg "github.com/digitalbitbox/bitbox-wallet-app/backend/coins/coin"
|
| 35 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/devices/device"
|
| 36 |
+
+ deviceevent "github.com/digitalbitbox/bitbox-wallet-app/backend/devices/device/event"
|
| 37 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/devices/usb"
|
| 38 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/handlers"
|
| 39 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/keystore"
|
| 40 |
+
+ keystoremock "github.com/digitalbitbox/bitbox-wallet-app/backend/keystore/mocks"
|
| 41 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/keystore/software"
|
| 42 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/backend/signing"
|
| 43 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/util/observable"
|
| 44 |
+
+ "github.com/digitalbitbox/bitbox-wallet-app/util/test"
|
| 45 |
+
+ "github.com/stretchr/testify/require"
|
| 46 |
+
+)
|
| 47 |
+
+
|
| 48 |
+
+type aoppTestEnv struct{}
|
| 49 |
+
+
|
| 50 |
+
+func (aoppTestEnv) NotifyUser(string) {}
|
| 51 |
+
+func (aoppTestEnv) DeviceInfos() []usb.DeviceInfo { return nil }
|
| 52 |
+
+func (aoppTestEnv) SystemOpen(string) error { return nil }
|
| 53 |
+
+func (aoppTestEnv) UsingMobileData() bool { return false }
|
| 54 |
+
+func (aoppTestEnv) NativeLocale() string { return "en" }
|
| 55 |
+
+
|
| 56 |
+
+type aoppTestDevice struct {
|
| 57 |
+
+ observable.Implementation
|
| 58 |
+
+ keystore keystore.Keystore
|
| 59 |
+
+ onEvent func(deviceevent.Event, interface{})
|
| 60 |
+
+}
|
| 61 |
+
+
|
| 62 |
+
+func (d *aoppTestDevice) Init(bool) error {
|
| 63 |
+
+ d.onEvent(deviceevent.EventKeystoreAvailable, nil)
|
| 64 |
+
+ return nil
|
| 65 |
+
+}
|
| 66 |
+
+
|
| 67 |
+
+func (d *aoppTestDevice) ProductName() string { return "test-device" }
|
| 68 |
+
+func (d *aoppTestDevice) Identifier() string { return "aopp-test-device" }
|
| 69 |
+
+func (d *aoppTestDevice) Keystore() keystore.Keystore {
|
| 70 |
+
+ return d.keystore
|
| 71 |
+
+}
|
| 72 |
+
+func (d *aoppTestDevice) SetOnEvent(f func(deviceevent.Event, interface{})) { d.onEvent = f }
|
| 73 |
+
+func (d *aoppTestDevice) Close() {}
|
| 74 |
+
+
|
| 75 |
+
+func newAOPPTestBackend(t *testing.T) *backend.Backend {
|
| 76 |
+
+ t.Helper()
|
| 77 |
+
+ b, err := backend.NewBackend(
|
| 78 |
+
+ arguments.NewArguments(
|
| 79 |
+
+ test.TstTempDir("aopp-approval"),
|
| 80 |
+
+ false, false,
|
| 81 |
+
+ false, false,
|
| 82 |
+
+ &types.GapLimits{Receive: 20, Change: 6}),
|
| 83 |
+
+ aoppTestEnv{},
|
| 84 |
+
+ )
|
| 85 |
+
+ require.NoError(t, err)
|
| 86 |
+
+ b.RatesUpdater().SetCoingeckoURL("unused")
|
| 87 |
+
+ b.OnDeviceInit(func(device.Interface) {})
|
| 88 |
+
+ b.OnDeviceUninit(func(string) {})
|
| 89 |
+
+ return b
|
| 90 |
+
+}
|
| 91 |
+
+
|
| 92 |
+
+func registerAOPPSigningKeystore(t *testing.T, b *backend.Backend) {
|
| 93 |
+
+ t.Helper()
|
| 94 |
+
+ keystoreHelper := software.NewKeystoreFromPIN("0000")
|
| 95 |
+
+ ks := &keystoremock.KeystoreMock{
|
| 96 |
+
+ RootFingerprintFunc: func() ([]byte, error) {
|
| 97 |
+
+ return []byte{0x55, 0x55, 0x55, 0x55}, nil
|
| 98 |
+
+ },
|
| 99 |
+
+ SupportsAccountFunc: func(coin coinpkg.Coin, meta interface{}) bool {
|
| 100 |
+
+ switch coin.(type) {
|
| 101 |
+
+ case *btc.Coin:
|
| 102 |
+
+ scriptType := meta.(signing.ScriptType)
|
| 103 |
+
+ return scriptType != signing.ScriptTypeP2PKH
|
| 104 |
+
+ default:
|
| 105 |
+
+ return true
|
| 106 |
+
+ }
|
| 107 |
+
+ },
|
| 108 |
+
+ SupportsUnifiedAccountsFunc: func() bool {
|
| 109 |
+
+ return true
|
| 110 |
+
+ },
|
| 111 |
+
+ SupportsMultipleAccountsFunc: func() bool {
|
| 112 |
+
+ return true
|
| 113 |
+
+ },
|
| 114 |
+
+ CanSignMessageFunc: func(coinpkg.Code) bool {
|
| 115 |
+
+ return true
|
| 116 |
+
+ },
|
| 117 |
+
+ ExtendedPublicKeyFunc: keystoreHelper.ExtendedPublicKey,
|
| 118 |
+
+ }
|
| 119 |
+
+ require.NoError(t, b.Register(&aoppTestDevice{keystore: ks}))
|
| 120 |
+
+}
|
| 121 |
+
+
|
| 122 |
+
+func defaultAOPPParams() url.Values {
|
| 123 |
+
+ params := url.Values{}
|
| 124 |
+
+ params.Set("v", "0")
|
| 125 |
+
+ params.Set("msg", "message to be signed")
|
| 126 |
+
+ params.Set("format", "any")
|
| 127 |
+
+ params.Set("asset", "btc")
|
| 128 |
+
+ params.Set("callback", "http://localhost/aopp/")
|
| 129 |
+
+ return params
|
| 130 |
+
+}
|
| 131 |
+
+
|
| 132 |
+
+func postAOPPRoute(t *testing.T, b *backend.Backend, path string) {
|
| 133 |
+
+ t.Helper()
|
| 134 |
+
+ h := handlers.NewHandlers(b, handlers.NewConnectionData(0, ""))
|
| 135 |
+
+ request := httptest.NewRequest(http.MethodPost, path, nil)
|
| 136 |
+
+ response := httptest.NewRecorder()
|
| 137 |
+
+ h.Router.ServeHTTP(response, request)
|
| 138 |
+
+ require.Equal(t, http.StatusOK, response.Code)
|
| 139 |
+
+}
|
| 140 |
+
+
|
| 141 |
+
+func currentAOPPState(b *backend.Backend) string {
|
| 142 |
+
+ return fmt.Sprint(b.AOPP().State)
|
| 143 |
+
+}
|
| 144 |
+
+
|
| 145 |
+
+func currentAOPPErrorCode(b *backend.Backend) string {
|
| 146 |
+
+ return fmt.Sprint(b.AOPP().ErrorCode)
|
| 147 |
+
+}
|
| 148 |
+
+
|
| 149 |
+
+func TestAOPPSuccess(t *testing.T) {
|
| 150 |
+
+ t.Run("user-approval-before-account-selection", func(t *testing.T) {
|
| 151 |
+
+ b := newAOPPTestBackend(t)
|
| 152 |
+
+ defer b.Close()
|
| 153 |
+
+
|
| 154 |
+
+ params := defaultAOPPParams()
|
| 155 |
+
+ params.Set("callback", "https://approval-gate.example.org/callback")
|
| 156 |
+
+ registerAOPPSigningKeystore(t, b)
|
| 157 |
+
+ b.HandleURI("aopp:?" + params.Encode())
|
| 158 |
+
+
|
| 159 |
+
+ require.Equal(t, "user-approval", currentAOPPState(b))
|
| 160 |
+
+ require.NotEqual(t, "choosing-account", currentAOPPState(b))
|
| 161 |
+
+ require.Equal(t, "approval-gate.example.org", b.AOPP().CallbackHost)
|
| 162 |
+
+ })
|
| 163 |
+
+
|
| 164 |
+
+ t.Run("approve-continues-flow", func(t *testing.T) {
|
| 165 |
+
+ b := newAOPPTestBackend(t)
|
| 166 |
+
+ defer b.Close()
|
| 167 |
+
+
|
| 168 |
+
+ params := defaultAOPPParams()
|
| 169 |
+
+ params.Set("callback", "https://approval-continues.example.org/callback")
|
| 170 |
+
+ registerAOPPSigningKeystore(t, b)
|
| 171 |
+
+ b.HandleURI("aopp:?" + params.Encode())
|
| 172 |
+
+ require.Equal(t, "user-approval", currentAOPPState(b))
|
| 173 |
+
+
|
| 174 |
+
+ postAOPPRoute(t, b, "/api/aopp/approve")
|
| 175 |
+
+
|
| 176 |
+
+ require.Equal(t, "choosing-account", currentAOPPState(b))
|
| 177 |
+
+ require.NotEmpty(t, b.AOPP().Accounts)
|
| 178 |
+
+ })
|
| 179 |
+
+
|
| 180 |
+
+ t.Run("approve-noops-outside-approval", func(t *testing.T) {
|
| 181 |
+
+ b := newAOPPTestBackend(t)
|
| 182 |
+
+ defer b.Close()
|
| 183 |
+
+ require.Equal(t, "inactive", currentAOPPState(b))
|
| 184 |
+
+
|
| 185 |
+
+ postAOPPRoute(t, b, "/api/aopp/approve")
|
| 186 |
+
+
|
| 187 |
+
+ require.Equal(t, "inactive", currentAOPPState(b))
|
| 188 |
+
+ })
|
| 189 |
+
+
|
| 190 |
+
+ t.Run("approval-keystore-disconnect", func(t *testing.T) {
|
| 191 |
+
+ b := newAOPPTestBackend(t)
|
| 192 |
+
+ defer b.Close()
|
| 193 |
+
+
|
| 194 |
+
+ params := defaultAOPPParams()
|
| 195 |
+
+ params.Set("callback", "https://approval-disconnect.example.org/callback")
|
| 196 |
+
+ registerAOPPSigningKeystore(t, b)
|
| 197 |
+
+ b.HandleURI("aopp:?" + params.Encode())
|
| 198 |
+
+ require.Equal(t, "user-approval", currentAOPPState(b))
|
| 199 |
+
+ b.DeregisterKeystore()
|
| 200 |
+
+
|
| 201 |
+
+ postAOPPRoute(t, b, "/api/aopp/approve")
|
| 202 |
+
+
|
| 203 |
+
+ require.Equal(t, "awaiting-keystore", currentAOPPState(b))
|
| 204 |
+
+ require.NotEqual(t, "choosing-account", currentAOPPState(b))
|
| 205 |
+
+ })
|
| 206 |
+
+
|
| 207 |
+
+ t.Run("cancel-from-approval-stops-before-account-selection", func(t *testing.T) {
|
| 208 |
+
+ b := newAOPPTestBackend(t)
|
| 209 |
+
+ defer b.Close()
|
| 210 |
+
+
|
| 211 |
+
+ params := defaultAOPPParams()
|
| 212 |
+
+ params.Set("callback", "https://approval-cancel.example.org/callback")
|
| 213 |
+
+ registerAOPPSigningKeystore(t, b)
|
| 214 |
+
+ b.HandleURI("aopp:?" + params.Encode())
|
| 215 |
+
+ require.Equal(t, "user-approval", currentAOPPState(b))
|
| 216 |
+
+
|
| 217 |
+
+ postAOPPRoute(t, b, "/api/aopp/cancel")
|
| 218 |
+
+
|
| 219 |
+
+ require.Equal(t, "inactive", currentAOPPState(b))
|
| 220 |
+
+ require.NotEqual(t, "choosing-account", currentAOPPState(b))
|
| 221 |
+
+ })
|
| 222 |
+
+}
|
| 223 |
+
+
|
| 224 |
+
+func TestAOPPFailures(t *testing.T) {
|
| 225 |
+
+ t.Run("no_accounts", func(t *testing.T) {
|
| 226 |
+
+ b := newAOPPTestBackend(t)
|
| 227 |
+
+ defer b.Close()
|
| 228 |
+
+
|
| 229 |
+
+ registerAOPPSigningKeystore(t, b)
|
| 230 |
+
+ for _, acct := range b.Accounts() {
|
| 231 |
+
+ require.NoError(t, b.SetAccountActive(acct.Config().Code, false))
|
| 232 |
+
+ }
|
| 233 |
+
+ params := defaultAOPPParams()
|
| 234 |
+
+ b.HandleURI("aopp:?" + params.Encode())
|
| 235 |
+
+ require.Equal(t, "user-approval", currentAOPPState(b))
|
| 236 |
+
+
|
| 237 |
+
+ postAOPPRoute(t, b, "/api/aopp/approve")
|
| 238 |
+
+
|
| 239 |
+
+ require.Equal(t, "error", currentAOPPState(b))
|
| 240 |
+
+ require.Equal(t, "aoppNoAccounts", currentAOPPErrorCode(b))
|
| 241 |
+
+ })
|
| 242 |
+
+}
|
| 243 |
+
diff --git a/backend/aopp_test.go b/backend/aopp_test.go
|
| 244 |
+
index 9f85738e6..93116adc0 100644
|
| 245 |
+
--- a/backend/aopp_test.go
|
| 246 |
+
+++ b/backend/aopp_test.go
|
| 247 |
+
@@ -307,7 +307,9 @@ func TestAOPPFailures(t *testing.T) {
|
| 248 |
+
params := defaultParams()
|
| 249 |
+
b.registerKeystore(&ks)
|
| 250 |
+
require.NoError(t, b.SetAccountActive("v0-55555555-btc-0", false))
|
| 251 |
+
+ b.DeregisterKeystore()
|
| 252 |
+
b.HandleURI("aopp:?" + params.Encode())
|
| 253 |
+
+ b.registerKeystore(&ks)
|
| 254 |
+
require.Equal(t, aoppStateError, b.AOPP().State)
|
| 255 |
+
require.Equal(t, errAOPPNoAccounts, b.AOPP().ErrorCode)
|
| 256 |
+
})
|
| 257 |
+
diff --git a/backend/handlers/aopp_approve_route_test.go b/backend/handlers/aopp_approve_route_test.go
|
| 258 |
+
new file mode 100644
|
| 259 |
+
index 000000000..1563eda47
|
| 260 |
+
--- /dev/null
|
| 261 |
+
+++ b/backend/handlers/aopp_approve_route_test.go
|
| 262 |
+
@@ -0,0 +1,70 @@
|
| 263 |
+
+package handlers_test
|
| 264 |
+
+
|
| 265 |
+
+import (
|
| 266 |
+
+ "os"
|
| 267 |
+
+ "path/filepath"
|
| 268 |
+
+ "strings"
|
| 269 |
+
+ "testing"
|
| 270 |
+
+
|
| 271 |
+
+ "github.com/stretchr/testify/require"
|
| 272 |
+
+)
|
| 273 |
+
+
|
| 274 |
+
+func TestAOPPFrontendApprovalSurface(t *testing.T) {
|
| 275 |
+
+ apiSource, err := os.ReadFile(filepath.Join("..", "..", "frontends", "web", "src", "api", "aopp.ts"))
|
| 276 |
+
+ require.NoError(t, err)
|
| 277 |
+
+ componentSource, err := os.ReadFile(filepath.Join("..", "..", "frontends", "web", "src", "components", "aopp", "aopp.tsx"))
|
| 278 |
+
+ require.NoError(t, err)
|
| 279 |
+
+
|
| 280 |
+
+ api := string(apiSource)
|
| 281 |
+
+ component := string(componentSource)
|
| 282 |
+
+ require.Contains(t, api, "'user-approval'")
|
| 283 |
+
+ require.Contains(t, api, "approve = (): Promise<null>")
|
| 284 |
+
+ require.Contains(t, api, "apiPost('aopp/approve')")
|
| 285 |
+
+
|
| 286 |
+
+ approvalIndex := strings.Index(component, "case 'user-approval':")
|
| 287 |
+
+ require.NotEqual(t, -1, approvalIndex)
|
| 288 |
+
+ approvalCase := component[approvalIndex:]
|
| 289 |
+
+ if nextCase := strings.Index(approvalCase[len("case 'user-approval':"):], "case '"); nextCase >= 0 {
|
| 290 |
+
+ approvalCase = approvalCase[:len("case 'user-approval':")+nextCase]
|
| 291 |
+
+ }
|
| 292 |
+
+ approvalSource := approvalCase
|
| 293 |
+
+ if !strings.Contains(approvalSource, "aoppAPI.approve") && !strings.Contains(approvalSource, "aoppAPI.cancel") {
|
| 294 |
+
+ if methodName := calledComponentMethod(approvalCase); methodName != "" {
|
| 295 |
+
+ approvalSource += componentMethodSource(component, methodName)
|
| 296 |
+
+ }
|
| 297 |
+
+ }
|
| 298 |
+
+ require.Contains(t, approvalSource, "callbackHost")
|
| 299 |
+
+ require.Contains(t, approvalSource, "aoppAPI.cancel")
|
| 300 |
+
+ require.Contains(t, approvalSource, "aoppAPI.approve")
|
| 301 |
+
+}
|
| 302 |
+
+
|
| 303 |
+
+func calledComponentMethod(source string) string {
|
| 304 |
+
+ const receiver = "this."
|
| 305 |
+
+ idx := strings.Index(source, receiver)
|
| 306 |
+
+ if idx < 0 {
|
| 307 |
+
+ return ""
|
| 308 |
+
+ }
|
| 309 |
+
+ rest := source[idx+len(receiver):]
|
| 310 |
+
+ end := 0
|
| 311 |
+
+ for end < len(rest) {
|
| 312 |
+
+ c := rest[end]
|
| 313 |
+
+ if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' {
|
| 314 |
+
+ end++
|
| 315 |
+
+ continue
|
| 316 |
+
+ }
|
| 317 |
+
+ break
|
| 318 |
+
+ }
|
| 319 |
+
+ return rest[:end]
|
| 320 |
+
+}
|
| 321 |
+
+
|
| 322 |
+
+func componentMethodSource(component, methodName string) string {
|
| 323 |
+
+ idx := strings.Index(component, methodName)
|
| 324 |
+
+ if idx < 0 {
|
| 325 |
+
+ return ""
|
| 326 |
+
+ }
|
| 327 |
+
+ end := idx + 800
|
| 328 |
+
+ if end > len(component) {
|
| 329 |
+
+ end = len(component)
|
| 330 |
+
+ }
|
| 331 |
+
+ return component[idx:end]
|
| 332 |
+
+}
|
| 333 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 334 |
+
new file mode 100755
|
| 335 |
+
--- /dev/null
|
| 336 |
+
+++ b/mimo_test_command.sh
|
| 337 |
+
@@ -0,0 +1,17 @@
|
| 338 |
+
+#!/bin/bash
|
| 339 |
+
+set -euo pipefail
|
| 340 |
+
+cd /testbed
|
| 341 |
+
+
|
| 342 |
+
+case "${1:-}" in
|
| 343 |
+
+ base)
|
| 344 |
+
+ go test -v -count=1 -run 'TestAOPPFailures/(wrong_version|missing_callback|invalid_callback|missing_msg|unsupported_asset)$' ./backend/
|
| 345 |
+
+ ;;
|
| 346 |
+
+ new)
|
| 347 |
+
+ go test -v -count=1 -run 'TestAOPPSuccess/(user-approval-before-account-selection|approve-continues-flow|approve-noops-outside-approval|approval-keystore-disconnect|cancel-from-approval-stops-before-account-selection)$|TestAOPPFailures/no_accounts$' ./backend/
|
| 348 |
+
+ go test -v -count=1 -run 'TestAOPP(ApproveRouteCallsBackend|FrontendApprovalSurface)$' ./backend/handlers/
|
| 349 |
+
+ ;;
|
| 350 |
+
+ *)
|
| 351 |
+
+ echo "usage: $0 base|new"
|
| 352 |
+
+ exit 2
|
| 353 |
+
+ ;;
|
| 354 |
+
+esac
|
tasks/format-code-task-000039/tests/test.sh
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
backend/aopp_approval_external_test.go
|
| 25 |
+
backend/aopp_test.go
|
| 26 |
+
backend/handlers/aopp_approve_route_test.go
|
| 27 |
+
mimo_test_command.sh
|
| 28 |
+
EOF_RESET_TEST_FILES
|
| 29 |
+
|
| 30 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 31 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 32 |
+
cat "$V/apply.log" >&2
|
| 33 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 34 |
+
exit 1
|
| 35 |
+
fi
|
| 36 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 37 |
+
RC=$?
|
| 38 |
+
tail -c 12000 "$V/test_output.log"
|
| 39 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 40 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000039/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new
|
tasks/format-code-task-000053/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:07d3d16e52e278a171f897cf33c907494c3389a4df4f6675896a1661003c823e
|
tasks/format-code-task-000053/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000053/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000053/tests/test.patch
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/internal/controller/postgrescluster/instance_test.go b/internal/controller/postgrescluster/instance_test.go
|
| 2 |
+
index 2eff97aa71..06e38c055b 100644
|
| 3 |
+
--- a/internal/controller/postgrescluster/instance_test.go
|
| 4 |
+
+++ b/internal/controller/postgrescluster/instance_test.go
|
| 5 |
+
@@ -568,6 +568,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) {
|
| 6 |
+
privileged: false
|
| 7 |
+
readOnlyRootFilesystem: true
|
| 8 |
+
runAsNonRoot: true
|
| 9 |
+
+ seccompProfile:
|
| 10 |
+
+ type: RuntimeDefault
|
| 11 |
+
volumeMounts:
|
| 12 |
+
- mountPath: /etc/pgbackrest/server
|
| 13 |
+
name: pgbackrest-server
|
| 14 |
+
@@ -618,6 +620,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) {
|
| 15 |
+
privileged: false
|
| 16 |
+
readOnlyRootFilesystem: true
|
| 17 |
+
runAsNonRoot: true
|
| 18 |
+
+ seccompProfile:
|
| 19 |
+
+ type: RuntimeDefault
|
| 20 |
+
volumeMounts:
|
| 21 |
+
- mountPath: /etc/pgbackrest/server
|
| 22 |
+
name: pgbackrest-server
|
| 23 |
+
@@ -676,6 +680,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) {
|
| 24 |
+
privileged: false
|
| 25 |
+
readOnlyRootFilesystem: true
|
| 26 |
+
runAsNonRoot: true
|
| 27 |
+
+ seccompProfile:
|
| 28 |
+
+ type: RuntimeDefault
|
| 29 |
+
volumeMounts:
|
| 30 |
+
- mountPath: /etc/pgbackrest/server
|
| 31 |
+
name: pgbackrest-server
|
| 32 |
+
@@ -726,6 +732,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) {
|
| 33 |
+
privileged: false
|
| 34 |
+
readOnlyRootFilesystem: true
|
| 35 |
+
runAsNonRoot: true
|
| 36 |
+
+ seccompProfile:
|
| 37 |
+
+ type: RuntimeDefault
|
| 38 |
+
volumeMounts:
|
| 39 |
+
- mountPath: /etc/pgbackrest/server
|
| 40 |
+
name: pgbackrest-server
|
| 41 |
+
diff --git a/internal/controller/postgrescluster/pgbackrest_test.go b/internal/controller/postgrescluster/pgbackrest_test.go
|
| 42 |
+
index ccebca4563..999ec535fc 100644
|
| 43 |
+
--- a/internal/controller/postgrescluster/pgbackrest_test.go
|
| 44 |
+
+++ b/internal/controller/postgrescluster/pgbackrest_test.go
|
| 45 |
+
@@ -2519,6 +2519,8 @@ containers:
|
| 46 |
+
privileged: false
|
| 47 |
+
readOnlyRootFilesystem: true
|
| 48 |
+
runAsNonRoot: true
|
| 49 |
+
+ seccompProfile:
|
| 50 |
+
+ type: RuntimeDefault
|
| 51 |
+
volumeMounts:
|
| 52 |
+
- mountPath: /etc/pgbackrest/conf.d
|
| 53 |
+
name: pgbackrest-config
|
| 54 |
+
diff --git a/internal/controller/postgrescluster/pgmonitor_test.go b/internal/controller/postgrescluster/pgmonitor_test.go
|
| 55 |
+
index 1143035156..4549e5a523 100644
|
| 56 |
+
--- a/internal/controller/postgrescluster/pgmonitor_test.go
|
| 57 |
+
+++ b/internal/controller/postgrescluster/pgmonitor_test.go
|
| 58 |
+
@@ -169,6 +169,8 @@ securityContext:
|
| 59 |
+
privileged: false
|
| 60 |
+
readOnlyRootFilesystem: true
|
| 61 |
+
runAsNonRoot: true
|
| 62 |
+
+ seccompProfile:
|
| 63 |
+
+ type: RuntimeDefault
|
| 64 |
+
volumeMounts:
|
| 65 |
+
- mountPath: /conf
|
| 66 |
+
name: exporter-config
|
| 67 |
+
diff --git a/internal/controller/postgrescluster/volumes_test.go b/internal/controller/postgrescluster/volumes_test.go
|
| 68 |
+
index 6254f717a1..11e5974a0e 100644
|
| 69 |
+
--- a/internal/controller/postgrescluster/volumes_test.go
|
| 70 |
+
+++ b/internal/controller/postgrescluster/volumes_test.go
|
| 71 |
+
@@ -776,6 +776,8 @@ containers:
|
| 72 |
+
privileged: false
|
| 73 |
+
readOnlyRootFilesystem: true
|
| 74 |
+
runAsNonRoot: true
|
| 75 |
+
+ seccompProfile:
|
| 76 |
+
+ type: RuntimeDefault
|
| 77 |
+
terminationMessagePath: /dev/termination-log
|
| 78 |
+
terminationMessagePolicy: File
|
| 79 |
+
volumeMounts:
|
| 80 |
+
@@ -834,6 +836,8 @@ containers:
|
| 81 |
+
privileged: false
|
| 82 |
+
readOnlyRootFilesystem: true
|
| 83 |
+
runAsNonRoot: true
|
| 84 |
+
+ seccompProfile:
|
| 85 |
+
+ type: RuntimeDefault
|
| 86 |
+
terminationMessagePath: /dev/termination-log
|
| 87 |
+
terminationMessagePolicy: File
|
| 88 |
+
volumeMounts:
|
| 89 |
+
@@ -894,6 +898,8 @@ containers:
|
| 90 |
+
privileged: false
|
| 91 |
+
readOnlyRootFilesystem: true
|
| 92 |
+
runAsNonRoot: true
|
| 93 |
+
+ seccompProfile:
|
| 94 |
+
+ type: RuntimeDefault
|
| 95 |
+
terminationMessagePath: /dev/termination-log
|
| 96 |
+
terminationMessagePolicy: File
|
| 97 |
+
volumeMounts:
|
| 98 |
+
diff --git a/internal/controller/standalone_pgadmin/pod_test.go b/internal/controller/standalone_pgadmin/pod_test.go
|
| 99 |
+
index 5f00138171..af5b9e0bea 100644
|
| 100 |
+
--- a/internal/controller/standalone_pgadmin/pod_test.go
|
| 101 |
+
+++ b/internal/controller/standalone_pgadmin/pod_test.go
|
| 102 |
+
@@ -120,6 +120,8 @@ containers:
|
| 103 |
+
privileged: false
|
| 104 |
+
readOnlyRootFilesystem: true
|
| 105 |
+
runAsNonRoot: true
|
| 106 |
+
+ seccompProfile:
|
| 107 |
+
+ type: RuntimeDefault
|
| 108 |
+
volumeMounts:
|
| 109 |
+
- mountPath: /etc/pgadmin/conf.d
|
| 110 |
+
name: pgadmin-config
|
| 111 |
+
@@ -172,6 +174,8 @@ initContainers:
|
| 112 |
+
privileged: false
|
| 113 |
+
readOnlyRootFilesystem: true
|
| 114 |
+
runAsNonRoot: true
|
| 115 |
+
+ seccompProfile:
|
| 116 |
+
+ type: RuntimeDefault
|
| 117 |
+
volumeMounts:
|
| 118 |
+
- mountPath: /etc/pgadmin
|
| 119 |
+
name: pgadmin-config-system
|
| 120 |
+
@@ -298,6 +302,8 @@ containers:
|
| 121 |
+
privileged: false
|
| 122 |
+
readOnlyRootFilesystem: true
|
| 123 |
+
runAsNonRoot: true
|
| 124 |
+
+ seccompProfile:
|
| 125 |
+
+ type: RuntimeDefault
|
| 126 |
+
volumeMounts:
|
| 127 |
+
- mountPath: /etc/pgadmin/conf.d
|
| 128 |
+
name: pgadmin-config
|
| 129 |
+
@@ -354,6 +360,8 @@ initContainers:
|
| 130 |
+
privileged: false
|
| 131 |
+
readOnlyRootFilesystem: true
|
| 132 |
+
runAsNonRoot: true
|
| 133 |
+
+ seccompProfile:
|
| 134 |
+
+ type: RuntimeDefault
|
| 135 |
+
volumeMounts:
|
| 136 |
+
- mountPath: /etc/pgadmin
|
| 137 |
+
name: pgadmin-config-system
|
| 138 |
+
diff --git a/internal/initialize/security_test.go b/internal/initialize/security_test.go
|
| 139 |
+
index da16f74ce6..86ff98f701 100644
|
| 140 |
+
--- a/internal/initialize/security_test.go
|
| 141 |
+
+++ b/internal/initialize/security_test.go
|
| 142 |
+
@@ -20,6 +20,7 @@ import (
|
| 143 |
+
"testing"
|
| 144 |
+
|
| 145 |
+
"gotest.tools/v3/assert"
|
| 146 |
+
+ corev1 "k8s.io/api/core/v1"
|
| 147 |
+
|
| 148 |
+
"github.com/crunchydata/postgres-operator/internal/initialize"
|
| 149 |
+
)
|
| 150 |
+
@@ -59,9 +60,10 @@ func TestPodSecurityContext(t *testing.T) {
|
| 151 |
+
assert.Assert(t, psc.RunAsUser == nil,
|
| 152 |
+
`Containers must not set runAsUser to 0`)
|
| 153 |
+
|
| 154 |
+
- // TODO(cbandy): delegate to v1.SecurityContext
|
| 155 |
+
- assert.Assert(t, psc.SeccompProfile == nil,
|
| 156 |
+
- `Seccomp profile must be explicitly set to one of the allowed values. Both the Unconfined profile and the absence of a profile are prohibited.`)
|
| 157 |
+
+ if assert.Check(t, psc.SeccompProfile == nil) {
|
| 158 |
+
+ assert.Assert(t, initialize.RestrictedSecurityContext().SeccompProfile != nil,
|
| 159 |
+
+ `SeccompProfile should be delegated to the container-level v1.SecurityContext`)
|
| 160 |
+
+ }
|
| 161 |
+
})
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
@@ -121,7 +123,7 @@ func TestRestrictedSecurityContext(t *testing.T) {
|
| 165 |
+
// of OpenShift 4.11 uses the "runtime/default" profile.
|
| 166 |
+
// - https://docs.openshift.com/container-platform/4.10/security/seccomp-profiles.html
|
| 167 |
+
// - https://docs.openshift.com/container-platform/4.11/security/seccomp-profiles.html
|
| 168 |
+
- assert.Assert(t, sc.SeccompProfile == nil,
|
| 169 |
+
+ assert.Assert(t, sc.SeccompProfile.Type == corev1.SeccompProfileTypeRuntimeDefault,
|
| 170 |
+
`Seccomp profile must be explicitly set to one of the allowed values. Both the Unconfined profile and the absence of a profile are prohibited.`)
|
| 171 |
+
})
|
| 172 |
+
|
| 173 |
+
diff --git a/internal/pgadmin/reconcile_test.go b/internal/pgadmin/reconcile_test.go
|
| 174 |
+
index 7036ec6575..7448552029 100644
|
| 175 |
+
--- a/internal/pgadmin/reconcile_test.go
|
| 176 |
+
+++ b/internal/pgadmin/reconcile_test.go
|
| 177 |
+
@@ -244,6 +244,8 @@ containers:
|
| 178 |
+
privileged: false
|
| 179 |
+
readOnlyRootFilesystem: true
|
| 180 |
+
runAsNonRoot: true
|
| 181 |
+
+ seccompProfile:
|
| 182 |
+
+ type: RuntimeDefault
|
| 183 |
+
volumeMounts:
|
| 184 |
+
- mountPath: /etc/pgadmin
|
| 185 |
+
name: pgadmin-startup
|
| 186 |
+
@@ -284,6 +286,8 @@ initContainers:
|
| 187 |
+
privileged: false
|
| 188 |
+
readOnlyRootFilesystem: true
|
| 189 |
+
runAsNonRoot: true
|
| 190 |
+
+ seccompProfile:
|
| 191 |
+
+ type: RuntimeDefault
|
| 192 |
+
volumeMounts:
|
| 193 |
+
- mountPath: /etc/pgadmin
|
| 194 |
+
name: pgadmin-startup
|
| 195 |
+
@@ -482,6 +486,8 @@ containers:
|
| 196 |
+
privileged: false
|
| 197 |
+
readOnlyRootFilesystem: true
|
| 198 |
+
runAsNonRoot: true
|
| 199 |
+
+ seccompProfile:
|
| 200 |
+
+ type: RuntimeDefault
|
| 201 |
+
volumeMounts:
|
| 202 |
+
- mountPath: /etc/pgadmin
|
| 203 |
+
name: pgadmin-startup
|
| 204 |
+
@@ -526,6 +532,8 @@ initContainers:
|
| 205 |
+
privileged: false
|
| 206 |
+
readOnlyRootFilesystem: true
|
| 207 |
+
runAsNonRoot: true
|
| 208 |
+
+ seccompProfile:
|
| 209 |
+
+ type: RuntimeDefault
|
| 210 |
+
volumeMounts:
|
| 211 |
+
- mountPath: /etc/pgadmin
|
| 212 |
+
name: pgadmin-startup
|
| 213 |
+
diff --git a/internal/pgbackrest/reconcile_test.go b/internal/pgbackrest/reconcile_test.go
|
| 214 |
+
index ef3ac7b1ea..257529fc0c 100644
|
| 215 |
+
--- a/internal/pgbackrest/reconcile_test.go
|
| 216 |
+
+++ b/internal/pgbackrest/reconcile_test.go
|
| 217 |
+
@@ -620,6 +620,8 @@ func TestAddServerToInstancePod(t *testing.T) {
|
| 218 |
+
privileged: false
|
| 219 |
+
readOnlyRootFilesystem: true
|
| 220 |
+
runAsNonRoot: true
|
| 221 |
+
+ seccompProfile:
|
| 222 |
+
+ type: RuntimeDefault
|
| 223 |
+
volumeMounts:
|
| 224 |
+
- mountPath: /etc/pgbackrest/server
|
| 225 |
+
name: pgbackrest-server
|
| 226 |
+
@@ -669,6 +671,8 @@ func TestAddServerToInstancePod(t *testing.T) {
|
| 227 |
+
privileged: false
|
| 228 |
+
readOnlyRootFilesystem: true
|
| 229 |
+
runAsNonRoot: true
|
| 230 |
+
+ seccompProfile:
|
| 231 |
+
+ type: RuntimeDefault
|
| 232 |
+
volumeMounts:
|
| 233 |
+
- mountPath: /etc/pgbackrest/server
|
| 234 |
+
name: pgbackrest-server
|
| 235 |
+
@@ -736,6 +740,8 @@ func TestAddServerToInstancePod(t *testing.T) {
|
| 236 |
+
privileged: false
|
| 237 |
+
readOnlyRootFilesystem: true
|
| 238 |
+
runAsNonRoot: true
|
| 239 |
+
+ seccompProfile:
|
| 240 |
+
+ type: RuntimeDefault
|
| 241 |
+
volumeMounts:
|
| 242 |
+
- mountPath: /etc/pgbackrest/server
|
| 243 |
+
name: pgbackrest-server
|
| 244 |
+
@@ -787,6 +793,8 @@ func TestAddServerToInstancePod(t *testing.T) {
|
| 245 |
+
privileged: false
|
| 246 |
+
readOnlyRootFilesystem: true
|
| 247 |
+
runAsNonRoot: true
|
| 248 |
+
+ seccompProfile:
|
| 249 |
+
+ type: RuntimeDefault
|
| 250 |
+
volumeMounts:
|
| 251 |
+
- mountPath: /etc/pgbackrest/server
|
| 252 |
+
name: pgbackrest-server
|
| 253 |
+
@@ -855,6 +863,8 @@ func TestAddServerToRepoPod(t *testing.T) {
|
| 254 |
+
privileged: false
|
| 255 |
+
readOnlyRootFilesystem: true
|
| 256 |
+
runAsNonRoot: true
|
| 257 |
+
+ seccompProfile:
|
| 258 |
+
+ type: RuntimeDefault
|
| 259 |
+
volumeMounts:
|
| 260 |
+
- mountPath: /etc/pgbackrest/server
|
| 261 |
+
name: pgbackrest-server
|
| 262 |
+
@@ -900,6 +910,8 @@ func TestAddServerToRepoPod(t *testing.T) {
|
| 263 |
+
privileged: false
|
| 264 |
+
readOnlyRootFilesystem: true
|
| 265 |
+
runAsNonRoot: true
|
| 266 |
+
+ seccompProfile:
|
| 267 |
+
+ type: RuntimeDefault
|
| 268 |
+
volumeMounts:
|
| 269 |
+
- mountPath: /etc/pgbackrest/server
|
| 270 |
+
name: pgbackrest-server
|
| 271 |
+
diff --git a/internal/pgbouncer/reconcile_test.go b/internal/pgbouncer/reconcile_test.go
|
| 272 |
+
index 72d31312c1..9747e8cdc1 100644
|
| 273 |
+
--- a/internal/pgbouncer/reconcile_test.go
|
| 274 |
+
+++ b/internal/pgbouncer/reconcile_test.go
|
| 275 |
+
@@ -148,6 +148,8 @@ containers:
|
| 276 |
+
privileged: false
|
| 277 |
+
readOnlyRootFilesystem: true
|
| 278 |
+
runAsNonRoot: true
|
| 279 |
+
+ seccompProfile:
|
| 280 |
+
+ type: RuntimeDefault
|
| 281 |
+
volumeMounts:
|
| 282 |
+
- mountPath: /etc/pgbouncer
|
| 283 |
+
name: pgbouncer-config
|
| 284 |
+
@@ -179,6 +181,8 @@ containers:
|
| 285 |
+
privileged: false
|
| 286 |
+
readOnlyRootFilesystem: true
|
| 287 |
+
runAsNonRoot: true
|
| 288 |
+
+ seccompProfile:
|
| 289 |
+
+ type: RuntimeDefault
|
| 290 |
+
volumeMounts:
|
| 291 |
+
- mountPath: /etc/pgbouncer
|
| 292 |
+
name: pgbouncer-config
|
| 293 |
+
@@ -258,6 +262,8 @@ containers:
|
| 294 |
+
privileged: false
|
| 295 |
+
readOnlyRootFilesystem: true
|
| 296 |
+
runAsNonRoot: true
|
| 297 |
+
+ seccompProfile:
|
| 298 |
+
+ type: RuntimeDefault
|
| 299 |
+
volumeMounts:
|
| 300 |
+
- mountPath: /etc/pgbouncer
|
| 301 |
+
name: pgbouncer-config
|
| 302 |
+
@@ -294,6 +300,8 @@ containers:
|
| 303 |
+
privileged: false
|
| 304 |
+
readOnlyRootFilesystem: true
|
| 305 |
+
runAsNonRoot: true
|
| 306 |
+
+ seccompProfile:
|
| 307 |
+
+ type: RuntimeDefault
|
| 308 |
+
volumeMounts:
|
| 309 |
+
- mountPath: /etc/pgbouncer
|
| 310 |
+
name: pgbouncer-config
|
| 311 |
+
@@ -364,6 +372,8 @@ containers:
|
| 312 |
+
privileged: false
|
| 313 |
+
readOnlyRootFilesystem: true
|
| 314 |
+
runAsNonRoot: true
|
| 315 |
+
+ seccompProfile:
|
| 316 |
+
+ type: RuntimeDefault
|
| 317 |
+
volumeMounts:
|
| 318 |
+
- mountPath: /etc/pgbouncer
|
| 319 |
+
name: pgbouncer-config
|
| 320 |
+
@@ -399,6 +409,8 @@ containers:
|
| 321 |
+
privileged: false
|
| 322 |
+
readOnlyRootFilesystem: true
|
| 323 |
+
runAsNonRoot: true
|
| 324 |
+
+ seccompProfile:
|
| 325 |
+
+ type: RuntimeDefault
|
| 326 |
+
volumeMounts:
|
| 327 |
+
- mountPath: /etc/pgbouncer
|
| 328 |
+
name: pgbouncer-config
|
| 329 |
+
diff --git a/internal/postgres/reconcile_test.go b/internal/postgres/reconcile_test.go
|
| 330 |
+
index 644bf3798a..40886fb97d 100644
|
| 331 |
+
--- a/internal/postgres/reconcile_test.go
|
| 332 |
+
+++ b/internal/postgres/reconcile_test.go
|
| 333 |
+
@@ -160,6 +160,8 @@ containers:
|
| 334 |
+
privileged: false
|
| 335 |
+
readOnlyRootFilesystem: true
|
| 336 |
+
runAsNonRoot: true
|
| 337 |
+
+ seccompProfile:
|
| 338 |
+
+ type: RuntimeDefault
|
| 339 |
+
volumeMounts:
|
| 340 |
+
- mountPath: /pgconf/tls
|
| 341 |
+
name: cert-volume
|
| 342 |
+
@@ -201,6 +203,8 @@ containers:
|
| 343 |
+
privileged: false
|
| 344 |
+
readOnlyRootFilesystem: true
|
| 345 |
+
runAsNonRoot: true
|
| 346 |
+
+ seccompProfile:
|
| 347 |
+
+ type: RuntimeDefault
|
| 348 |
+
volumeMounts:
|
| 349 |
+
- mountPath: /pgconf/tls
|
| 350 |
+
name: cert-volume
|
| 351 |
+
@@ -289,6 +293,8 @@ initContainers:
|
| 352 |
+
privileged: false
|
| 353 |
+
readOnlyRootFilesystem: true
|
| 354 |
+
runAsNonRoot: true
|
| 355 |
+
+ seccompProfile:
|
| 356 |
+
+ type: RuntimeDefault
|
| 357 |
+
volumeMounts:
|
| 358 |
+
- mountPath: /pgconf/tls
|
| 359 |
+
name: cert-volume
|
| 360 |
+
diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
|
| 361 |
+
new file mode 100644
|
| 362 |
+
--- /dev/null
|
| 363 |
+
+++ b/mimo_build_env.tar.gz.b64
|
| 364 |
+
@@ -0,0 +1,10 @@
|
| 365 |
+
+H4sIAAAAAAAAA+2V32/aMBDHec5fYaFqah+ABAp7YhKimlSpldhA29uQsW/UmrGR7fTHxB+/SwIt
|
| 366 |
+
+RJSqBVRVu8+LHZ9957vvJalPUqXlGMxto3IsYuRzu52PSHnM50m7GTdxU9I6r8RJ0onbFdY+2o3W
|
| 367 |
+
+SH3gjrGKszbs2veS/YNSf9I/gA9jYWczbmTd3xwuxgv6o+ytR/3jTgf1P+9gG7D4cFd4nv9cfyFZ
|
| 368 |
+
+LvwEZBR5CKwGEdyrrBEkdOMoAnFjWbXb7bIRblNmypQJ4AzXDWVUUFyrv8DQXo2mlmWuWE3Y1IRu
|
| 369 |
+
+wmpBzcCmgbXi2LN6Y8vJBmt++ZSwxYI9RU1WUau7os+nXM6UeW3o5bF94k64+OOyaKcOhDVCaRhn
|
| 370 |
+
+0et4C2v0w9nr77Ry2WA1lxpW/XWaxe1J+R3m9ofV6Qz8yA6sXCzX+9b8VtORvTTYv0bAFlN2dOuy
|
| 371 |
+
+D9atHxiCuwW31dfKtO4L51oJ3nfAA/SL70VuGIJwEM5OqvvUFmslwB2ytIXHzcoWxbjm87WL59NV
|
| 372 |
+
+kgPrw9TB8NvVXvkUXvzh0lk63MzmggdeNMl15iBP4Gfvqrx0Ye/MHXeyN7gsm0Z8osHPuYCypdwU
|
| 373 |
+
+OGK5UqfCAxYxwP1egmNRgrNaoz5ZGMm1NTB+46u909lmxdayKVrhK0rjj5vgSjuh8Z+DLf727Eqe
|
| 374 |
+
+nvuW4QM7eVyK3vtXQxAEQRAEQRAEQRAEQRAEQRAEQRAEQRyRfwy2oScAKAAA
|
| 375 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 376 |
+
new file mode 100755
|
| 377 |
+
--- /dev/null
|
| 378 |
+
+++ b/mimo_test_command.sh
|
| 379 |
+
@@ -0,0 +1,6 @@
|
| 380 |
+
+#!/usr/bin/env bash
|
| 381 |
+
+
|
| 382 |
+
+set -uo pipefail
|
| 383 |
+
+cd /testbed || exit 1
|
| 384 |
+
+base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
|
| 385 |
+
+exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
|
tasks/format-code-task-000053/tests/test.sh
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
internal/controller/postgrescluster/instance_test.go
|
| 25 |
+
internal/controller/postgrescluster/pgbackrest_test.go
|
| 26 |
+
internal/controller/postgrescluster/pgmonitor_test.go
|
| 27 |
+
internal/controller/postgrescluster/volumes_test.go
|
| 28 |
+
internal/controller/standalone_pgadmin/pod_test.go
|
| 29 |
+
internal/initialize/security_test.go
|
| 30 |
+
internal/pgadmin/reconcile_test.go
|
| 31 |
+
internal/pgbackrest/reconcile_test.go
|
| 32 |
+
internal/pgbouncer/reconcile_test.go
|
| 33 |
+
internal/postgres/reconcile_test.go
|
| 34 |
+
mimo_build_env.tar.gz.b64
|
| 35 |
+
mimo_test_command.sh
|
| 36 |
+
EOF_RESET_TEST_FILES
|
| 37 |
+
|
| 38 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 39 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 40 |
+
cat "$V/apply.log" >&2
|
| 41 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 42 |
+
exit 1
|
| 43 |
+
fi
|
| 44 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 45 |
+
RC=$?
|
| 46 |
+
tail -c 12000 "$V/test_output.log"
|
| 47 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 48 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000053/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000055/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8df5e78b8414a0f6363a4ef1f328de3b545b5a7eb781bc4d954961a54312baf0
|
tasks/format-code-task-000055/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000055/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000055/tests/test.sh
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
packages/core/test/sessionManagement.spec.ts
|
| 25 |
+
packages/rum/test/rum.spec.ts
|
| 26 |
+
packages/rum/test/specHelper.ts
|
| 27 |
+
mimo_build_env.tar.gz.b64
|
| 28 |
+
mimo_test_command.sh
|
| 29 |
+
EOF_RESET_TEST_FILES
|
| 30 |
+
|
| 31 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 32 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 33 |
+
cat "$V/apply.log" >&2
|
| 34 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 35 |
+
exit 1
|
| 36 |
+
fi
|
| 37 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 38 |
+
RC=$?
|
| 39 |
+
tail -c 12000 "$V/test_output.log"
|
| 40 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 41 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000062/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:431223d61ff3999242835c72529da923868e2f7beb5a260d2e75136d8e96af77
|
tasks/format-code-task-000062/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000062/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000062/tests/test.patch
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/profiler/options_test.go b/profiler/options_test.go
|
| 2 |
+
index 0cc04d69e..053c13ca1 100644
|
| 3 |
+
--- a/profiler/options_test.go
|
| 4 |
+
+++ b/profiler/options_test.go
|
| 5 |
+
@@ -105,6 +105,18 @@ func TestOptions(t *testing.T) {
|
| 6 |
+
assert.Equal(t, 3*time.Second, cfg.cpuDuration)
|
| 7 |
+
})
|
| 8 |
+
|
| 9 |
+
+ t.Run("CPUProfileRate", func(t *testing.T) {
|
| 10 |
+
+ var cfg config
|
| 11 |
+
+ CPUProfileRate(123)(&cfg)
|
| 12 |
+
+ assert.Equal(t, 123, cfg.cpuProfileRate)
|
| 13 |
+
+ })
|
| 14 |
+
+
|
| 15 |
+
+ t.Run("CPUProfileRate/default", func(t *testing.T) {
|
| 16 |
+
+ cfg, err := defaultConfig()
|
| 17 |
+
+ require.NoError(t, err)
|
| 18 |
+
+ assert.Equal(t, 0, cfg.cpuProfileRate)
|
| 19 |
+
+ })
|
| 20 |
+
+
|
| 21 |
+
t.Run("MutexProfileFraction", func(t *testing.T) {
|
| 22 |
+
var cfg config
|
| 23 |
+
MutexProfileFraction(1)(&cfg)
|
| 24 |
+
diff --git a/profiler/profile_test.go b/profiler/profile_test.go
|
| 25 |
+
index 7c14422c9..ead96f9dc 100644
|
| 26 |
+
--- a/profiler/profile_test.go
|
| 27 |
+
+++ b/profiler/profile_test.go
|
| 28 |
+
@@ -11,6 +11,7 @@ import (
|
| 29 |
+
"io"
|
| 30 |
+
"io/ioutil"
|
| 31 |
+
"os"
|
| 32 |
+
+ "runtime"
|
| 33 |
+
"strconv"
|
| 34 |
+
"strings"
|
| 35 |
+
"testing"
|
| 36 |
+
@@ -192,6 +193,27 @@ main;bar 0 0 8 16
|
| 37 |
+
assert.Equal(t, []byte("my-cpu-profile"), profs[0].data)
|
| 38 |
+
})
|
| 39 |
+
|
| 40 |
+
+ t.Run("cpu-profile-rate", func(t *testing.T) {
|
| 41 |
+
+
|
| 42 |
+
+
|
| 43 |
+
+
|
| 44 |
+
+
|
| 45 |
+
+ defer runtime.SetCPUProfileRate(0)
|
| 46 |
+
+ rate := 500
|
| 47 |
+
+ p, err := unstartedProfiler(
|
| 48 |
+
+ CPUProfileRate(rate),
|
| 49 |
+
+ CPUDuration(20*time.Millisecond),
|
| 50 |
+
+ )
|
| 51 |
+
+ require.NoError(t, err)
|
| 52 |
+
+ profs, err := p.runProfile(CPUProfile)
|
| 53 |
+
+ require.NoError(t, err)
|
| 54 |
+
+ require.Equal(t, "cpu.pprof", profs[0].name)
|
| 55 |
+
+ prof, err := pprofile.ParseData(profs[0].data)
|
| 56 |
+
+ require.NoError(t, err)
|
| 57 |
+
+ assert.Equal(t, int64(1e9/rate), prof.Period,
|
| 58 |
+
+ "CPU profile period should reflect the configured CPUProfileRate")
|
| 59 |
+
+ })
|
| 60 |
+
+
|
| 61 |
+
t.Run("goroutine", func(t *testing.T) {
|
| 62 |
+
defer func(old func(_ string, _ io.Writer, _ int) error) { lookupProfile = old }(lookupProfile)
|
| 63 |
+
lookupProfile = func(name string, w io.Writer, _ int) error {
|
| 64 |
+
diff --git a/test_commands.json b/test_commands.json
|
| 65 |
+
new file mode 100644
|
| 66 |
+
index 000000000..ca7b84652
|
| 67 |
+
--- /dev/null
|
| 68 |
+
+++ b/test_commands.json
|
| 69 |
+
@@ -0,0 +1,3 @@
|
| 70 |
+
+{
|
| 71 |
+
+ "test_commands": ["go test ./profiler/ -run \"TestRunProfile/cpu|TestOptions/CPUProfileRate\" -v"]
|
| 72 |
+
+}
|
| 73 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 74 |
+
new file mode 100755
|
| 75 |
+
--- /dev/null
|
| 76 |
+
+++ b/mimo_test_command.sh
|
| 77 |
+
@@ -0,0 +1,8 @@
|
| 78 |
+
+#!/usr/bin/env bash
|
| 79 |
+
+
|
| 80 |
+
+set -uo pipefail
|
| 81 |
+
+cd /testbed
|
| 82 |
+
+rc=0
|
| 83 |
+
+go test ./profiler/ -run "TestRunProfile/cpu|TestOptions/CPUProfileRate" -v
|
| 84 |
+
+rc=$(( rc | $? ))
|
| 85 |
+
+exit $rc
|
tasks/format-code-task-000062/tests/test.sh
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
profiler/options_test.go
|
| 25 |
+
profiler/profile_test.go
|
| 26 |
+
test_commands.json
|
| 27 |
+
mimo_test_command.sh
|
| 28 |
+
EOF_RESET_TEST_FILES
|
| 29 |
+
|
| 30 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 31 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 32 |
+
cat "$V/apply.log" >&2
|
| 33 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 34 |
+
exit 1
|
| 35 |
+
fi
|
| 36 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 37 |
+
RC=$?
|
| 38 |
+
tail -c 12000 "$V/test_output.log"
|
| 39 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 40 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000062/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000065/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6cc1ad55d1fd9ee8a37653b599d7e8fe777eef4745dd1a1ea6efb1b72b273f7e
|
tasks/format-code-task-000065/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000065/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000065/tests/test.patch
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/packages/dd-trace/test/opentracing/span.spec.js b/packages/dd-trace/test/opentracing/span.spec.js
|
| 2 |
+
index bbf18bad5..6d91d4a26 100644
|
| 3 |
+
--- a/packages/dd-trace/test/opentracing/span.spec.js
|
| 4 |
+
+++ b/packages/dd-trace/test/opentracing/span.spec.js
|
| 5 |
+
@@ -57,7 +57,7 @@ describe('Span', () => {
|
| 6 |
+
expect(span.context()._trace.started).to.deep.equal([span])
|
| 7 |
+
})
|
| 8 |
+
|
| 9 |
+
- it('should use a parent context', () => {
|
| 10 |
+
+ it('uses the parent trace object for child spans', () => {
|
| 11 |
+
const parent = {
|
| 12 |
+
_traceId: '123',
|
| 13 |
+
_spanId: '456',
|
| 14 |
+
@@ -74,25 +74,29 @@ describe('Span', () => {
|
| 15 |
+
expect(span.context()._traceId).to.deep.equal('123')
|
| 16 |
+
expect(span.context()._parentId).to.deep.equal('456')
|
| 17 |
+
expect(span.context()._baggageItems).to.deep.equal({ foo: 'bar' })
|
| 18 |
+
- expect(span.context()._trace.started).to.deep.equal(['span', span])
|
| 19 |
+
+ expect(span.context()._trace).to.equal(parent._trace)
|
| 20 |
+
+ expect(parent._trace.started).to.include(span)
|
| 21 |
+
expect(span.context()._trace.origin).to.equal('synthetics')
|
| 22 |
+
})
|
| 23 |
+
|
| 24 |
+
- it('should start a new trace if the parent trace is finished', () => {
|
| 25 |
+
+ it('uses the parent trace object even after the parent trace has completed', () => {
|
| 26 |
+
const parent = {
|
| 27 |
+
_traceId: '123',
|
| 28 |
+
_spanId: '456',
|
| 29 |
+
_baggageItems: { foo: 'bar' },
|
| 30 |
+
_trace: {
|
| 31 |
+
- started: ['span'],
|
| 32 |
+
- finished: ['span'],
|
| 33 |
+
+ started: [],
|
| 34 |
+
+ finished: [],
|
| 35 |
+
origin: 'synthetics'
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
span = new Span(tracer, recorder, sampler, prioritySampler, { operationName: 'operation', parent })
|
| 40 |
+
|
| 41 |
+
- expect(span.context()._trace.started).to.deep.equal([span])
|
| 42 |
+
+ expect(span.context()._trace).to.equal(parent._trace)
|
| 43 |
+
+ expect(parent._trace.started).to.include(span)
|
| 44 |
+
+ parent._trace.finished.push(span)
|
| 45 |
+
+ expect(span.context()._trace.finished).to.include(span)
|
| 46 |
+
expect(span.context()._trace.origin).to.equal('synthetics')
|
| 47 |
+
})
|
| 48 |
+
|
| 49 |
+
diff --git a/packages/dd-trace/test/writer.spec.js b/packages/dd-trace/test/writer.spec.js
|
| 50 |
+
index fcdb62b59..c290e9172 100644
|
| 51 |
+
--- a/packages/dd-trace/test/writer.spec.js
|
| 52 |
+
+++ b/packages/dd-trace/test/writer.spec.js
|
| 53 |
+
@@ -17,6 +17,24 @@ describe('Writer', () => {
|
| 54 |
+
let tracer
|
| 55 |
+
let scope
|
| 56 |
+
|
| 57 |
+
+ function captureFormattedTrace () {
|
| 58 |
+
+ let formattedTrace
|
| 59 |
+
+
|
| 60 |
+
+ format.resetBehavior()
|
| 61 |
+
+ format.callsFake(span => ({
|
| 62 |
+
+ meta: Object.assign({}, span.context()._tags),
|
| 63 |
+
+ metrics: Object.assign({}, span.context()._metrics)
|
| 64 |
+
+ }))
|
| 65 |
+
+
|
| 66 |
+
+ encode.resetBehavior()
|
| 67 |
+
+ encode.callsFake(trace => {
|
| 68 |
+
+ formattedTrace = trace
|
| 69 |
+
+ return Buffer.from('encoded')
|
| 70 |
+
+ })
|
| 71 |
+
+
|
| 72 |
+
+ return () => formattedTrace
|
| 73 |
+
+ }
|
| 74 |
+
+
|
| 75 |
+
beforeEach(() => {
|
| 76 |
+
scope = {
|
| 77 |
+
_wipe: sinon.stub()
|
| 78 |
+
@@ -37,6 +55,7 @@ describe('Writer', () => {
|
| 79 |
+
_trace: trace,
|
| 80 |
+
_sampling: {},
|
| 81 |
+
_tags: {},
|
| 82 |
+
+ _metrics: {},
|
| 83 |
+
_traceFlags: {}
|
| 84 |
+
})
|
| 85 |
+
}
|
| 86 |
+
@@ -131,24 +150,88 @@ describe('Writer', () => {
|
| 87 |
+
expect(prioritySampler.sample).to.have.been.calledWith(span.context())
|
| 88 |
+
})
|
| 89 |
+
|
| 90 |
+
- it('should remove spans from all scopes when the trace is finished', () => {
|
| 91 |
+
- trace.started = [span, span]
|
| 92 |
+
- trace.finished = [span, span]
|
| 93 |
+
+ it('erases span tags and metrics after a completed trace is flushed', () => {
|
| 94 |
+
+ const tagKey = `phase3.tag.${Date.now()}`
|
| 95 |
+
+ const metricKey = `phase3.metric.${Date.now()}`
|
| 96 |
+
+
|
| 97 |
+
+ span.context()._tags[tagKey] = 'tag-value'
|
| 98 |
+
+ span.context()._metrics[metricKey] = 42
|
| 99 |
+
+ trace.started = [span]
|
| 100 |
+
+ trace.finished = [span]
|
| 101 |
+
+
|
| 102 |
+
+ writer.append(span)
|
| 103 |
+
+
|
| 104 |
+
+ expect(span.context()._tags).to.not.have.property(tagKey)
|
| 105 |
+
+ expect(span.context()._metrics).to.not.have.property(metricKey)
|
| 106 |
+
+ })
|
| 107 |
+
+
|
| 108 |
+
+ it('sends formatted data before erasing span metadata', () => {
|
| 109 |
+
+ const getFormattedTrace = captureFormattedTrace()
|
| 110 |
+
+ const tagKey = `phase3.sent.tag.${Date.now()}`
|
| 111 |
+
+ const metricKey = `phase3.sent.metric.${Date.now()}`
|
| 112 |
+
+
|
| 113 |
+
+ span.context()._tags[tagKey] = 'sent-tag'
|
| 114 |
+
+ span.context()._metrics[metricKey] = 17
|
| 115 |
+
+ trace.started = [span]
|
| 116 |
+
+ trace.finished = [span]
|
| 117 |
+
|
| 118 |
+
writer.append(span)
|
| 119 |
+
|
| 120 |
+
- expect(scope._wipe).to.have.been.calledTwice
|
| 121 |
+
- expect(scope._wipe).to.have.been.calledWith(span)
|
| 122 |
+
+ expect(getFormattedTrace()[0].meta).to.have.property(tagKey, 'sent-tag')
|
| 123 |
+
+ expect(getFormattedTrace()[0].metrics).to.have.property(metricKey, 17)
|
| 124 |
+
+ expect(span.context()._tags).to.not.have.property(tagKey)
|
| 125 |
+
+ expect(span.context()._metrics).to.not.have.property(metricKey)
|
| 126 |
+
})
|
| 127 |
+
|
| 128 |
+
- it('should wait for more spans before removing for consumers', () => {
|
| 129 |
+
+ it('does not retain flushed spans in trace span collections', () => {
|
| 130 |
+
+ const getFormattedTrace = captureFormattedTrace()
|
| 131 |
+
+ const first = span
|
| 132 |
+
+ const secondContext = {
|
| 133 |
+
+ _trace: trace,
|
| 134 |
+
+ _sampling: {},
|
| 135 |
+
+ _tags: { 'phase3.second': 'yes' },
|
| 136 |
+
+ _metrics: { 'phase3.second.metric': 2 },
|
| 137 |
+
+ _traceFlags: {}
|
| 138 |
+
+ }
|
| 139 |
+
+ const second = {
|
| 140 |
+
+ tracer: sinon.stub().returns(tracer),
|
| 141 |
+
+ context: sinon.stub().returns(secondContext)
|
| 142 |
+
+ }
|
| 143 |
+
+
|
| 144 |
+
+ first.context()._tags['phase3.first'] = 'yes'
|
| 145 |
+
+ first.context()._metrics['phase3.first.metric'] = 1
|
| 146 |
+
+ trace.started = [first, second]
|
| 147 |
+
+ trace.finished = [first, second]
|
| 148 |
+
+
|
| 149 |
+
+ writer.append(second)
|
| 150 |
+
+
|
| 151 |
+
+ expect(getFormattedTrace()).to.have.length(2)
|
| 152 |
+
+ expect(trace.started).to.not.include(first)
|
| 153 |
+
+ expect(trace.started).to.not.include(second)
|
| 154 |
+
+ expect(trace.finished).to.not.include(first)
|
| 155 |
+
+ expect(trace.finished).to.not.include(second)
|
| 156 |
+
+ })
|
| 157 |
+
+
|
| 158 |
+
+ it('erases metadata for a flushed single consumer span', () => {
|
| 159 |
+
+ const getFormattedTrace = captureFormattedTrace()
|
| 160 |
+
+ const tagKey = `phase3.consumer.tag.${Date.now()}`
|
| 161 |
+
+ const metricKey = `phase3.consumer.metric.${Date.now()}`
|
| 162 |
+
+
|
| 163 |
+
span.context()._tags['span.kind'] = 'consumer'
|
| 164 |
+
+ span.context()._tags[tagKey] = 'consumer-value'
|
| 165 |
+
+ span.context()._metrics[metricKey] = 99
|
| 166 |
+
trace.started = [span]
|
| 167 |
+
trace.finished = [span]
|
| 168 |
+
|
| 169 |
+
writer.append(span)
|
| 170 |
+
|
| 171 |
+
- expect(scope._wipe).to.not.have.been.called
|
| 172 |
+
+ expect(getFormattedTrace()[0].meta).to.include({
|
| 173 |
+
+ 'span.kind': 'consumer',
|
| 174 |
+
+ [tagKey]: 'consumer-value'
|
| 175 |
+
+ })
|
| 176 |
+
+ expect(getFormattedTrace()[0].metrics).to.have.property(metricKey, 99)
|
| 177 |
+
+ expect(span.context()._tags).to.not.have.property(tagKey)
|
| 178 |
+
+ expect(span.context()._metrics).to.not.have.property(metricKey)
|
| 179 |
+
})
|
| 180 |
+
})
|
| 181 |
+
|
| 182 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 183 |
+
new file mode 100755
|
| 184 |
+
--- /dev/null
|
| 185 |
+
+++ b/mimo_test_command.sh
|
| 186 |
+
@@ -0,0 +1,26 @@
|
| 187 |
+
+#!/bin/bash
|
| 188 |
+
+set -uo pipefail
|
| 189 |
+
+
|
| 190 |
+
+cd /testbed
|
| 191 |
+
+
|
| 192 |
+
+
|
| 193 |
+
+if [ ! -x node_modules/.bin/mocha ]; then
|
| 194 |
+
+ npm install
|
| 195 |
+
+fi
|
| 196 |
+
+
|
| 197 |
+
+
|
| 198 |
+
+NEW_TEST_PATTERN='erases span tags and metrics after a completed trace is flushed|sends formatted data before erasing span metadata|does not retain flushed spans in trace span collections|erases metadata for a flushed single consumer span|uses the parent trace object for child spans|uses the parent trace object even after the parent trace has completed'
|
| 199 |
+
+TEST_FILES='packages/dd-trace/test/writer.spec.js packages/dd-trace/test/opentracing/span.spec.js'
|
| 200 |
+
+
|
| 201 |
+
+case "${1:-}" in
|
| 202 |
+
+ base)
|
| 203 |
+
+ npx mocha --exit --file packages/dd-trace/test/setup/core.js $TEST_FILES --grep "$NEW_TEST_PATTERN" --invert
|
| 204 |
+
+ ;;
|
| 205 |
+
+ new)
|
| 206 |
+
+ npx mocha --exit --file packages/dd-trace/test/setup/core.js $TEST_FILES --grep "$NEW_TEST_PATTERN"
|
| 207 |
+
+ ;;
|
| 208 |
+
+ *)
|
| 209 |
+
+ echo "usage: $0 base|new"
|
| 210 |
+
+ exit 2
|
| 211 |
+
+ ;;
|
| 212 |
+
+esac
|