AdithyaSK HF Staff commited on
Commit
a3dcdac
·
verified ·
1 Parent(s): 197607f

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. tasks/format-code-task-000014/environment/Dockerfile +3 -0
  2. tasks/format-code-task-000014/environment/setup/files/blocklist +33 -0
  3. tasks/format-code-task-000014/environment/setup/setup.sh +34 -0
  4. tasks/format-code-task-000014/tests/test.patch +523 -0
  5. tasks/format-code-task-000014/tests/test.sh +38 -0
  6. tasks/format-code-task-000014/tests/test_command.sh +1 -0
  7. tasks/format-code-task-000023/environment/Dockerfile +3 -0
  8. tasks/format-code-task-000023/environment/setup/files/blocklist +33 -0
  9. tasks/format-code-task-000023/environment/setup/setup.sh +34 -0
  10. tasks/format-code-task-000023/tests/test.patch +174 -0
  11. tasks/format-code-task-000023/tests/test.sh +38 -0
  12. tasks/format-code-task-000023/tests/test_command.sh +1 -0
  13. tasks/format-code-task-000047/environment/Dockerfile +3 -0
  14. tasks/format-code-task-000047/environment/setup/files/blocklist +33 -0
  15. tasks/format-code-task-000047/environment/setup/setup.sh +34 -0
  16. tasks/format-code-task-000047/tests/test.patch +195 -0
  17. tasks/format-code-task-000047/tests/test.sh +39 -0
  18. tasks/format-code-task-000047/tests/test_command.sh +1 -0
  19. tasks/format-code-task-000049/environment/Dockerfile +3 -0
  20. tasks/format-code-task-000049/environment/setup/files/blocklist +33 -0
  21. tasks/format-code-task-000049/environment/setup/setup.sh +34 -0
  22. tasks/format-code-task-000049/tests/test.patch +387 -0
  23. tasks/format-code-task-000049/tests/test.sh +38 -0
  24. tasks/format-code-task-000049/tests/test_command.sh +1 -0
  25. tasks/format-code-task-000071/environment/Dockerfile +3 -0
  26. tasks/format-code-task-000071/environment/setup/files/blocklist +33 -0
  27. tasks/format-code-task-000071/environment/setup/setup.sh +34 -0
  28. tasks/format-code-task-000071/tests/test.patch +0 -0
  29. tasks/format-code-task-000071/tests/test.sh +47 -0
  30. tasks/format-code-task-000071/tests/test_command.sh +1 -0
  31. tasks/format-code-task-000076/environment/Dockerfile +3 -0
  32. tasks/format-code-task-000076/environment/setup/files/blocklist +33 -0
  33. tasks/format-code-task-000076/environment/setup/setup.sh +34 -0
  34. tasks/format-code-task-000076/tests/test.patch +50 -0
  35. tasks/format-code-task-000076/tests/test.sh +39 -0
  36. tasks/format-code-task-000076/tests/test_command.sh +1 -0
  37. tasks/format-code-task-000078/environment/Dockerfile +3 -0
  38. tasks/format-code-task-000078/environment/setup/files/blocklist +33 -0
  39. tasks/format-code-task-000078/environment/setup/setup.sh +34 -0
  40. tasks/format-code-task-000078/tests/test.patch +58 -0
  41. tasks/format-code-task-000078/tests/test.sh +39 -0
  42. tasks/format-code-task-000078/tests/test_command.sh +1 -0
  43. tasks/format-code-task-000082/environment/Dockerfile +3 -0
  44. tasks/format-code-task-000082/environment/setup/files/blocklist +33 -0
  45. tasks/format-code-task-000082/environment/setup/setup.sh +34 -0
  46. tasks/format-code-task-000082/tests/test.patch +269 -0
  47. tasks/format-code-task-000082/tests/test.sh +38 -0
  48. tasks/format-code-task-000082/tests/test_command.sh +1 -0
  49. tasks/format-code-task-000085/environment/Dockerfile +3 -0
  50. tasks/format-code-task-000085/environment/setup/files/blocklist +33 -0
tasks/format-code-task-000014/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:2c7c021648118dd49b4be28cd89fd85d6e510e31a6a95588847e3959b64fe03f
tasks/format-code-task-000014/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-000014/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-000014/tests/test.patch ADDED
@@ -0,0 +1,523 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/usercase-test-coderl/kafka_producer_stateful_test.go b/usercase-test-coderl/kafka_producer_stateful_test.go
2
+ new file mode 100644
3
+ --- /dev/null
4
+ +++ b/usercase-test-coderl/kafka_producer_stateful_test.go
5
+ @@ -0,0 +1,494 @@
6
+ +package usercase_test_coderl
7
+ +
8
+ +import (
9
+ + "fmt"
10
+ + "os"
11
+ + "reflect"
12
+ + "runtime"
13
+ + "sort"
14
+ + "strings"
15
+ + "testing"
16
+ + "unsafe"
17
+ +
18
+ + "github.com/8treenet/freedom/infra/kafka"
19
+ + "github.com/IBM/sarama"
20
+ +)
21
+ +
22
+ +
23
+ +
24
+ +
25
+ +
26
+ +
27
+ +
28
+ +
29
+ +
30
+ +
31
+ +
32
+ +
33
+ +
34
+ +
35
+ +
36
+ +
37
+ +
38
+ +
39
+ +
40
+ +
41
+ +
42
+ +func TestKafkaProducerStartNewMsgAndPublishSession(t *testing.T) {
43
+ +
44
+ +
45
+ +
46
+ +
47
+ + impl := closeableProducer(t)
48
+ + mustNoError(t, impl.Close())
49
+ +
50
+ + broker := newProducerBroker(t, "orders")
51
+ + defer broker.Close()
52
+ + defer impl.Close()
53
+ +
54
+ + cfg := sarama.NewConfig()
55
+ + cfg.Version = sarama.V2_1_0_0
56
+ + cfg.Producer.RequiredAcks = sarama.WaitForLocal
57
+ + cfg.Producer.Return.Errors = false
58
+ + cfg.Producer.Return.Successes = false
59
+ + if cfg.Producer.Return.Errors != false {
60
+ + t.Fatalf("fresh cfg Return.Errors = %v, want false", cfg.Producer.Return.Errors)
61
+ + }
62
+ + if cfg.Producer.Return.Successes != false {
63
+ + t.Fatalf("fresh cfg Return.Successes = %v, want false", cfg.Producer.Return.Successes)
64
+ + }
65
+ +
66
+ + producer := kafka.GetProducer()
67
+ + producer.Start([]string{broker.Addr()}, cfg)
68
+ + if cfg.Producer.Return.Errors != true {
69
+ + t.Fatalf("after Start Return.Errors = %v, want true", cfg.Producer.Return.Errors)
70
+ + }
71
+ + if cfg.Producer.Return.Successes != true {
72
+ + t.Fatalf("after Start Return.Successes = %v, want true", cfg.Producer.Return.Successes)
73
+ + }
74
+ + mustNoError(t, producer.Restart())
75
+ +
76
+ + msg := producer.NewMsg("orders", []byte("paid"))
77
+ +
78
+ + if msg == nil {
79
+ + t.Fatal("NewMsg returned nil")
80
+ + }
81
+ + if msg.GetMessageKey() != "" {
82
+ + t.Fatalf("fresh msg key = %q, want empty string", msg.GetMessageKey())
83
+ + }
84
+ +
85
+ + if len(msg.GetHeader()) != 0 {
86
+ + t.Fatalf("fresh msg headers = %#v, want no headers", msg.GetHeader())
87
+ + }
88
+ +
89
+ + headerReturn := msg.SetMessageKey("order-1").
90
+ + SetHeader(map[string]interface{}{"x-request-id": "r1"}).
91
+ + SetHeader(map[string]interface{}{"attempt": 2})
92
+ +
93
+ + if headerReturn == nil {
94
+ + t.Fatal("SetHeader chain returned nil")
95
+ + }
96
+ + msg = headerReturn
97
+ + if msg.GetMessageKey() != "order-1" {
98
+ + t.Fatalf("after SetMessageKey key = %q, want %q", msg.GetMessageKey(), "order-1")
99
+ + }
100
+ + if got := fmt.Sprint(msg.GetHeader()["x-request-id"]); got != "r1" {
101
+ + t.Fatalf("header x-request-id = %q, want %q", got, "r1")
102
+ + }
103
+ + if got := fmt.Sprint(msg.GetHeader()["attempt"]); got != "2" {
104
+ + t.Fatalf("header attempt = %q, want %q", got, "2")
105
+ + }
106
+ +
107
+ + mustNoError(t, msg.Publish())
108
+ + sent := onlyProducedRecord(t, broker, "orders")
109
+ + if sent.topic != "orders" {
110
+ + t.Fatalf("produced topic = %q, want %q", sent.topic, "orders")
111
+ + }
112
+ +
113
+ + if sent.partition < 0 {
114
+ + t.Fatalf("produced partition = %d, want a valid non-negative partition", sent.partition)
115
+ + }
116
+ + if sent.key != "order-1" {
117
+ + t.Fatalf("produced key = %q, want %q", sent.key, "order-1")
118
+ + }
119
+ + if sent.value != "paid" {
120
+ + t.Fatalf("produced value = %q, want %q", sent.value, "paid")
121
+ + }
122
+ + if !reflect.DeepEqual(sent.headers, map[string]string{"attempt": "2", "x-request-id": "r1"}) {
123
+ + t.Fatalf("produced headers = %#v, want %#v", sent.headers, map[string]string{"attempt": "2", "x-request-id": "r1"})
124
+ + }
125
+ + if msg.GetExecution() != nil {
126
+ + t.Fatalf("after successful Publish execution = %v, want nil", msg.GetExecution())
127
+ + }
128
+ +}
129
+ +
130
+ +func TestKafkaProducerGeneratedMessageKeySession(t *testing.T) {
131
+ +
132
+ +
133
+ +
134
+ +
135
+ + impl := closeableProducer(t)
136
+ + mustNoError(t, impl.Close())
137
+ +
138
+ + broker := newProducerBroker(t, "orders")
139
+ + defer broker.Close()
140
+ + defer impl.Close()
141
+ +
142
+ + cfg := sarama.NewConfig()
143
+ + cfg.Version = sarama.V2_1_0_0
144
+ + kafka.GetProducer().Start([]string{broker.Addr()}, cfg)
145
+ + mustNoError(t, kafka.GetProducer().Restart())
146
+ +
147
+ + msg := kafka.GetProducer().NewMsg("orders", []byte("paid"))
148
+ + if msg.GetMessageKey() != "" {
149
+ + t.Fatalf("fresh generated-key msg key = %q, want empty string", msg.GetMessageKey())
150
+ + }
151
+ + mustNoError(t, msg.Publish())
152
+ +
153
+ + sent := onlyProducedRecord(t, broker, "orders")
154
+ +
155
+ + generated := sent.key
156
+ + if len(generated) != 32 {
157
+ + t.Fatalf("generated key length = %d, want 32", len(generated))
158
+ + }
159
+ + if strings.Contains(generated, "-") != false {
160
+ + t.Fatalf("generated key contains dash = %v, want false", strings.Contains(generated, "-"))
161
+ + }
162
+ + if generated != strings.ToUpper(generated) {
163
+ + t.Fatalf("generated key = %q, want uppercase", generated)
164
+ + }
165
+ + if sent.value != "paid" {
166
+ + t.Fatalf("produced generated-key value = %q, want %q", sent.value, "paid")
167
+ + }
168
+ +}
169
+ +
170
+ +func TestKafkaProducerPublishBeforeInitializedReturnsSpecificError(t *testing.T) {
171
+ +
172
+ +
173
+ +
174
+ +
175
+ + impl := closeableProducer(t)
176
+ + mustNoError(t, impl.Close())
177
+ +
178
+ + msg := kafka.GetProducer().NewMsg("orders", []byte("paid"))
179
+ + err := msg.Publish()
180
+ + if err == nil {
181
+ + t.Fatal("Publish before initialized error = nil, want producer is not initialized")
182
+ + }
183
+ + if err.Error() != "producer is not initialized" {
184
+ + t.Fatalf("Publish before initialized error = %q, want %q", err.Error(), "producer is not initialized")
185
+ + }
186
+ + if msg.GetExecution() == nil {
187
+ + t.Fatal("GetExecution after failed Publish = nil, want producer is not initialized error")
188
+ + }
189
+ + if msg.GetExecution().Error() != "producer is not initialized" {
190
+ + t.Fatalf("GetExecution after failed Publish = %q, want %q", msg.GetExecution().Error(), "producer is not initialized")
191
+ + }
192
+ +}
193
+ +
194
+ +func TestKafkaMessagesKeepIndependentState(t *testing.T) {
195
+ +
196
+ +
197
+ +
198
+ +
199
+ + a := kafka.GetProducer().NewMsg("orders", []byte("paid"))
200
+ + b := kafka.GetProducer().NewMsg("orders", []byte("refunded"))
201
+ +
202
+ + a.SetMessageKey("order-1").SetHeader(map[string]interface{}{"x-request-id": "r1"})
203
+ + if a.GetMessageKey() != "order-1" {
204
+ + t.Fatalf("message a key = %q, want %q", a.GetMessageKey(), "order-1")
205
+ + }
206
+ + if got := fmt.Sprint(a.GetHeader()["x-request-id"]); got != "r1" {
207
+ + t.Fatalf("message a header x-request-id = %q, want %q", got, "r1")
208
+ + }
209
+ + if b.GetMessageKey() != "" {
210
+ + t.Fatalf("message b key = %q, want empty string", b.GetMessageKey())
211
+ + }
212
+ +
213
+ + if len(b.GetHeader()) != 0 {
214
+ + t.Fatalf("message b headers = %#v, want no headers", b.GetHeader())
215
+ + }
216
+ +
217
+ + b.SetMessageKey("order-2").SetHeader(map[string]interface{}{"x-request-id": "r2", "attempt": 1})
218
+ + if a.GetMessageKey() != "order-1" {
219
+ + t.Fatalf("message a key after mutating b = %q, want %q", a.GetMessageKey(), "order-1")
220
+ + }
221
+ + if fmt.Sprint(a.GetHeader()["x-request-id"]) != "r1" {
222
+ + t.Fatalf("message a x-request-id after mutating b = %q, want %q", fmt.Sprint(a.GetHeader()["x-request-id"]), "r1")
223
+ + }
224
+ + if b.GetMessageKey() != "order-2" {
225
+ + t.Fatalf("message b key = %q, want %q", b.GetMessageKey(), "order-2")
226
+ + }
227
+ + if fmt.Sprint(b.GetHeader()["x-request-id"]) != "r2" {
228
+ + t.Fatalf("message b x-request-id = %q, want %q", fmt.Sprint(b.GetHeader()["x-request-id"]), "r2")
229
+ + }
230
+ + if fmt.Sprint(b.GetHeader()["attempt"]) != "1" {
231
+ + t.Fatalf("message b attempt = %q, want %q", fmt.Sprint(b.GetHeader()["attempt"]), "1")
232
+ + }
233
+ +}
234
+ +
235
+ +func TestKafkaProducerCloseIsIdempotent(t *testing.T) {
236
+ +
237
+ +
238
+ +
239
+ +
240
+ + impl := closeableProducer(t)
241
+ + mustNoError(t, impl.Close())
242
+ + mustNoError(t, impl.Close())
243
+ +}
244
+ +
245
+ +func TestKafkaProducerCloseReleasesResourcesAcrossCycles(t *testing.T) {
246
+ +
247
+ +
248
+ +
249
+ +
250
+ + impl := closeableProducer(t)
251
+ + mustNoError(t, impl.Close())
252
+ +
253
+ + broker := newProducerBroker(t, "orders")
254
+ + defer broker.Close()
255
+ + defer impl.Close()
256
+ +
257
+ + runtime.GC()
258
+ + baseFDs := countFDs(t)
259
+ + baseGoroutines := runtime.NumGoroutine()
260
+ +
261
+ + for i := 0; i < 120; i++ {
262
+ + cfg := sarama.NewConfig()
263
+ + cfg.Version = sarama.V2_1_0_0
264
+ + kafka.GetProducer().Start([]string{broker.Addr()}, cfg)
265
+ + mustNoError(t, kafka.GetProducer().Restart())
266
+ + msg := kafka.GetProducer().NewMsg("orders", []byte("paid")).SetMessageKey(fmt.Sprintf("order-%d", i))
267
+ + mustNoError(t, msg.Publish())
268
+ + mustNoError(t, impl.Close())
269
+ + }
270
+ +
271
+ + runtime.GC()
272
+ + afterFDs := countFDs(t)
273
+ + afterGoroutines := runtime.NumGoroutine()
274
+ +
275
+ + if afterFDs > baseFDs+30 {
276
+ + t.Fatalf("fd count after 120 producer cycles = %d, want <= %d", afterFDs, baseFDs+30)
277
+ + }
278
+ +
279
+ + if afterGoroutines > baseGoroutines+30 {
280
+ + t.Fatalf("goroutines after 120 producer cycles = %d, want <= %d", afterGoroutines, baseGoroutines+30)
281
+ + }
282
+ +}
283
+ +
284
+ +func TestZZZKafkaProducerMiddlewareOrderStopAndExecution(t *testing.T) {
285
+ +
286
+ +
287
+ +
288
+ +
289
+ + impl := closeableProducer(t)
290
+ + mustNoError(t, impl.Close())
291
+ +
292
+ + broker := newProducerBroker(t, "orders")
293
+ + defer broker.Close()
294
+ + defer impl.Close()
295
+ +
296
+ + cfg := sarama.NewConfig()
297
+ + cfg.Version = sarama.V2_1_0_0
298
+ + kafka.GetProducer().Start([]string{broker.Addr()}, cfg)
299
+ + mustNoError(t, kafka.GetProducer().Restart())
300
+ +
301
+ + var events []string
302
+ + kafka.InstallMiddleware(
303
+ + func(msg *kafka.Msg) {
304
+ + events = append(events, "first-before:"+msg.GetMessageKey())
305
+ + if msg.IsStopped() != false {
306
+ + t.Fatalf("first middleware IsStopped = %v, want false", msg.IsStopped())
307
+ + }
308
+ + msg.Next()
309
+ + if msg.GetExecution() != nil {
310
+ + t.Fatalf("first middleware GetExecution after Next = %v, want nil", msg.GetExecution())
311
+ + }
312
+ + events = append(events, "first-after")
313
+ + },
314
+ + func(msg *kafka.Msg) {
315
+ + events = append(events, "second-before:"+fmt.Sprint(len(msg.GetHeader())))
316
+ + msg.Next()
317
+ + events = append(events, "second-after")
318
+ + },
319
+ + )
320
+ +
321
+ + msg := kafka.GetProducer().NewMsg("orders", []byte("paid")).
322
+ + SetMessageKey("order-1").
323
+ + SetHeader(map[string]interface{}{"x-request-id": "r1"})
324
+ + mustNoError(t, msg.Publish())
325
+ + if !reflect.DeepEqual(events, []string{"first-before:order-1", "second-before:1", "second-after", "first-after"}) {
326
+ + t.Fatalf("middleware events = %#v, want %#v", events, []string{"first-before:order-1", "second-before:1", "second-after", "first-after"})
327
+ + }
328
+ + if msg.IsStopped() != false {
329
+ + t.Fatalf("published middleware msg IsStopped = %v, want false", msg.IsStopped())
330
+ + }
331
+ + if msg.GetExecution() != nil {
332
+ + t.Fatalf("published middleware msg GetExecution = %v, want nil", msg.GetExecution())
333
+ + }
334
+ + if countProduceRequests(broker) != 1 {
335
+ + t.Fatalf("produce requests after continued middleware = %d, want 1", countProduceRequests(broker))
336
+ + }
337
+ +
338
+ + var stopEvents []string
339
+ + kafka.InstallMiddleware(func(msg *kafka.Msg) {
340
+ + stopEvents = append(stopEvents, "stop-before")
341
+ + msg.Stop()
342
+ + stopEvents = append(stopEvents, fmt.Sprintf("stopped:%v", msg.IsStopped()))
343
+ + })
344
+ +
345
+ + stopped := kafka.GetProducer().NewMsg("orders", []byte("blocked")).SetMessageKey("order-stop")
346
+ + if err := stopped.Publish(); err != nil {
347
+ + t.Fatalf("stopped Publish error = %v, want nil", err)
348
+ + }
349
+ + if !reflect.DeepEqual(stopEvents, []string{"stop-before", "stopped:true"}) {
350
+ + t.Fatalf("stop middleware events = %#v, want %#v", stopEvents, []string{"stop-before", "stopped:true"})
351
+ + }
352
+ + if stopped.IsStopped() != true {
353
+ + t.Fatalf("stopped msg IsStopped = %v, want true", stopped.IsStopped())
354
+ + }
355
+ + if stopped.GetExecution() != nil {
356
+ + t.Fatalf("stopped msg GetExecution = %v, want nil", stopped.GetExecution())
357
+ + }
358
+ + if countProduceRequests(broker) != 1 {
359
+ + t.Fatalf("produce requests after stopped middleware = %d, want 1", countProduceRequests(broker))
360
+ + }
361
+ +}
362
+ +
363
+ +type producedRecord struct {
364
+ + topic string
365
+ + partition int32
366
+ + key string
367
+ + value string
368
+ + headers map[string]string
369
+ +}
370
+ +
371
+ +func closeableProducer(t *testing.T) *kafka.ProducerImpl {
372
+ + t.Helper()
373
+ + impl, ok := kafka.GetProducer().(*kafka.ProducerImpl)
374
+ + if !ok {
375
+ + t.Fatalf("GetProducer concrete type = %T, want *kafka.ProducerImpl", kafka.GetProducer())
376
+ + }
377
+ + return impl
378
+ +}
379
+ +
380
+ +func newProducerBroker(t *testing.T, topic string) *sarama.MockBroker {
381
+ + t.Helper()
382
+ + broker := sarama.NewMockBroker(t, 1)
383
+ + broker.SetHandlerByMap(map[string]sarama.MockResponse{
384
+ + "ApiVersionsRequest": sarama.NewMockApiVersionsResponse(t),
385
+ + "MetadataRequest": sarama.NewMockMetadataResponse(t).
386
+ + SetBroker(broker.Addr(), broker.BrokerID()).
387
+ + SetLeader(topic, 0, broker.BrokerID()),
388
+ + "ProduceRequest": sarama.NewMockProduceResponse(t).
389
+ + SetVersion(7).
390
+ + SetError(topic, 0, sarama.ErrNoError),
391
+ + })
392
+ + return broker
393
+ +}
394
+ +
395
+ +func onlyProducedRecord(t *testing.T, broker *sarama.MockBroker, topic string) producedRecord {
396
+ + t.Helper()
397
+ + records := producedRecords(t, broker)
398
+ + var matches []producedRecord
399
+ + for _, record := range records {
400
+ + if record.topic == topic {
401
+ + matches = append(matches, record)
402
+ + }
403
+ + }
404
+ + if len(matches) != 1 {
405
+ + t.Fatalf("produced records for %q = %d (%#v), want 1", topic, len(matches), matches)
406
+ + }
407
+ + return matches[0]
408
+ +}
409
+ +
410
+ +func countProduceRequests(broker *sarama.MockBroker) int {
411
+ + count := 0
412
+ + for _, exchange := range broker.History() {
413
+ + if _, ok := exchange.Request.(*sarama.ProduceRequest); ok {
414
+ + count++
415
+ + }
416
+ + }
417
+ + return count
418
+ +}
419
+ +
420
+ +func producedRecords(t *testing.T, broker *sarama.MockBroker) []producedRecord {
421
+ + t.Helper()
422
+ + var out []producedRecord
423
+ + for _, exchange := range broker.History() {
424
+ + req, ok := exchange.Request.(*sarama.ProduceRequest)
425
+ + if !ok {
426
+ + continue
427
+ + }
428
+ + for topic, partitions := range produceRequestRecords(req) {
429
+ + for partition, records := range partitions {
430
+ + if records.RecordBatch != nil {
431
+ + for _, record := range records.RecordBatch.Records {
432
+ + out = append(out, producedRecord{
433
+ + topic: topic,
434
+ + partition: partition,
435
+ + key: string(record.Key),
436
+ + value: string(record.Value),
437
+ + headers: recordHeaders(record.Headers),
438
+ + })
439
+ + }
440
+ + continue
441
+ + }
442
+ + if records.MsgSet != nil {
443
+ + for _, block := range records.MsgSet.Messages {
444
+ + for _, msgBlock := range block.Messages() {
445
+ + out = append(out, producedRecord{
446
+ + topic: topic,
447
+ + partition: partition,
448
+ + key: string(msgBlock.Msg.Key),
449
+ + value: string(msgBlock.Msg.Value),
450
+ + headers: map[string]string{},
451
+ + })
452
+ + }
453
+ + }
454
+ + }
455
+ + }
456
+ + }
457
+ + }
458
+ + sort.Slice(out, func(i, j int) bool {
459
+ + if out[i].topic != out[j].topic {
460
+ + return out[i].topic < out[j].topic
461
+ + }
462
+ + if out[i].partition != out[j].partition {
463
+ + return out[i].partition < out[j].partition
464
+ + }
465
+ + return out[i].key < out[j].key
466
+ + })
467
+ + return out
468
+ +}
469
+ +
470
+ +func produceRequestRecords(req *sarama.ProduceRequest) map[string]map[int32]sarama.Records {
471
+ + value := reflect.ValueOf(req).Elem().FieldByName("records")
472
+ + return reflect.NewAt(value.Type(), unsafe.Pointer(value.UnsafeAddr())).
473
+ + Elem().
474
+ + Interface().(map[string]map[int32]sarama.Records)
475
+ +}
476
+ +
477
+ +func recordHeaders(headers []*sarama.RecordHeader) map[string]string {
478
+ + out := make(map[string]string, len(headers))
479
+ + for _, header := range headers {
480
+ + out[string(header.Key)] = string(header.Value)
481
+ + }
482
+ + return out
483
+ +}
484
+ +
485
+ +func countFDs(t *testing.T) int {
486
+ + t.Helper()
487
+ + entries, err := os.ReadDir("/proc/self/fd")
488
+ + if err != nil {
489
+ + t.Fatalf("read /proc/self/fd: %v", err)
490
+ + }
491
+ + return len(entries)
492
+ +}
493
+ +
494
+ +func mustNoError(t *testing.T, err error) {
495
+ + t.Helper()
496
+ + if err != nil {
497
+ + t.Fatalf("unexpected error: %v", err)
498
+ + }
499
+ +}
500
+ diff --git a/mimo_test_command.sh b/mimo_test_command.sh
501
+ new file mode 100755
502
+ --- /dev/null
503
+ +++ b/mimo_test_command.sh
504
+ @@ -0,0 +1,19 @@
505
+ +#!/usr/bin/env bash
506
+ +
507
+ +
508
+ +
509
+ +
510
+ +export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096"
511
+ +export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC"
512
+ +export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC"
513
+ +export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g"
514
+ +set -e
515
+ +cd /workspace/repo
516
+ +set -euo pipefail
517
+ +
518
+ +cd /workspace/repo
519
+ +
520
+ +export GOPROXY=off
521
+ +export GOSUMDB=off
522
+ +export GOTOOLCHAIN=local
523
+ +exec go test -v -count=1 ./usercase-test-coderl/...
tasks/format-code-task-000014/tests/test.sh ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/kafka_producer_stateful_test.go
25
+ mimo_test_command.sh
26
+ EOF_RESET_TEST_FILES
27
+
28
+ ); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
29
+ if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
30
+ cat "$V/apply.log" >&2
31
+ echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
32
+ exit 1
33
+ fi
34
+ timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
35
+ RC=$?
36
+ tail -c 12000 "$V/test_output.log"
37
+ if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
38
+ echo "test command exited $RC"
tasks/format-code-task-000014/tests/test_command.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ bash /workspace/repo/mimo_test_command.sh
tasks/format-code-task-000023/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:df1ec1afb6406e966b4e45334caf0d1ca873927e0fdb1203f91e0097ace9da10
tasks/format-code-task-000023/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-000023/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-000023/tests/test.patch ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/tests/functional/project/test_project_manager_cache_contract.py b/tests/functional/project/test_project_manager_cache_contract.py
2
+ new file mode 100644
3
+ index 000000000..e9a040eb0
4
+ --- /dev/null
5
+ +++ b/tests/functional/project/test_project_manager_cache_contract.py
6
+ @@ -0,0 +1,157 @@
7
+ +from types import SimpleNamespace
8
+ +
9
+ +from ape.managers.project import ProjectManager
10
+ +from ape.types import ContractType
11
+ +
12
+ +
13
+ +class RecordingCompiler:
14
+ + def __init__(self):
15
+ + self.calls = []
16
+ +
17
+ + def compile(self, paths):
18
+ + paths = list(paths)
19
+ + self.calls.append(tuple(str(path) for path in paths))
20
+ + return [
21
+ + ContractType(
22
+ + contractName=f"{path.stem}:{path.read_text()}",
23
+ + sourceId=str(path),
24
+ + abi=[],
25
+ + )
26
+ + for path in paths
27
+ + ]
28
+ +
29
+ +
30
+ +class CompilerManagerStub:
31
+ + def __init__(self, compiler):
32
+ + self.compiler = compiler
33
+ + self.registered_compilers = {".foo": compiler}
34
+ +
35
+ + def compile(self, paths):
36
+ + return {
37
+ + contract.contractName: contract
38
+ + for contract in self.compiler.compile(paths)
39
+ + }
40
+ +
41
+ +
42
+ +def make_project(tmp_path, compiler=None):
43
+ + compiler = compiler or RecordingCompiler()
44
+ + config = SimpleNamespace(PROJECT_FOLDER=tmp_path, name="", dependencies=[])
45
+ + return ProjectManager(tmp_path, config, CompilerManagerStub(compiler)), compiler
46
+ +
47
+ +
48
+ +def test_missing_contract_directory_has_no_unknown_extensions(tmp_path):
49
+ + project, _ = make_project(tmp_path)
50
+ +
51
+ + assert project.sources_missing is True
52
+ + assert project.extensions_with_missing_compilers == []
53
+ +
54
+ +
55
+ +def test_empty_contract_directory_is_reported_as_missing(tmp_path):
56
+ + project, _ = make_project(tmp_path)
57
+ + (tmp_path / "contracts").mkdir()
58
+ + assert project.sources_missing is True
59
+ + assert project.extensions_with_missing_compilers == []
60
+ +
61
+ +
62
+ +def make_nested_sources(tmp_path):
63
+ + project, _ = make_project(tmp_path)
64
+ + contracts = tmp_path / "contracts"
65
+ + (contracts / "nested").mkdir(parents=True)
66
+ + for relative in (
67
+ + "z.foo",
68
+ + "a.bar",
69
+ + "q.zeta",
70
+ + "nested/m.foo",
71
+ + "nested/b.bar",
72
+ + "nested/a.alpha",
73
+ + ):
74
+ + (contracts / relative).write_text(relative)
75
+ + return project, contracts
76
+ +
77
+ +
78
+ +def test_sources_are_recursive_and_sorted(tmp_path):
79
+ + project, contracts = make_nested_sources(tmp_path)
80
+ + assert [path.relative_to(contracts).as_posix() for path in project.sources] == [
81
+ + "nested/m.foo",
82
+ + "z.foo",
83
+ + ]
84
+ +
85
+ +
86
+ +def test_unknown_extensions_are_recursive_and_sorted(tmp_path):
87
+ + project, _ = make_nested_sources(tmp_path)
88
+ + assert project.extensions_with_missing_compilers == [".alpha", ".bar", ".zeta"]
89
+ +
90
+ +
91
+ +def test_corrupt_manifest_cache_is_ignored_and_rebuilt(tmp_path):
92
+ + project, compiler = make_project(tmp_path)
93
+ + contracts = tmp_path / "contracts"
94
+ + contracts.mkdir()
95
+ + source = contracts / "one.foo"
96
+ + source.write_text("v1")
97
+ + cache = tmp_path / ".build" / "__local__.json"
98
+ + cache.parent.mkdir()
99
+ + cache.write_text("not-json")
100
+ +
101
+ + loaded = project.load_contracts()
102
+ +
103
+ + assert set(loaded) == {"one:v1"}
104
+ + assert compiler.calls == [(str(source),)]
105
+ +
106
+ +
107
+ +def setup_cached_sources(tmp_path):
108
+ + project, compiler = make_project(tmp_path)
109
+ + contracts = tmp_path / "contracts"
110
+ + contracts.mkdir()
111
+ + first = contracts / "first.foo"
112
+ + second = contracts / "second.foo"
113
+ + first.write_text("v1")
114
+ + second.write_text("v1")
115
+ +
116
+ + initial = project.load_contracts()
117
+ + assert set(initial) == {"first:v1", "second:v1"}
118
+ + assert compiler.calls[-1] == (str(first), str(second))
119
+ + return project, compiler, contracts, first, second
120
+ +
121
+ +
122
+ +def test_incremental_cache_compiles_only_changed_and_new_sources(tmp_path):
123
+ + project, compiler, contracts, first, second = setup_cached_sources(tmp_path)
124
+ + first.write_text("v2")
125
+ + third = contracts / "third.foo"
126
+ + third.write_text("v1")
127
+ + updated = project.load_contracts()
128
+ + assert compiler.calls[-1] == (str(first), str(third))
129
+ + assert "second:v1" in updated
130
+ + assert "third:v1" in updated
131
+ +
132
+ +
133
+ +def test_changed_source_replaces_its_stale_contract_types(tmp_path):
134
+ + project, _, _, first, _ = setup_cached_sources(tmp_path)
135
+ + first.write_text("v2")
136
+ + updated = project.load_contracts()
137
+ + assert "first:v1" not in updated
138
+ + assert updated["first:v2"].sourceId == str(first)
139
+ +
140
+ +
141
+ +def test_deleted_source_drops_its_cached_contract_types(tmp_path):
142
+ + project, _, _, _, second = setup_cached_sources(tmp_path)
143
+ + second.unlink()
144
+ + project.load_contracts()
145
+ +
146
+ + reloaded_project, _ = make_project(tmp_path)
147
+ + after_delete = reloaded_project.load_contracts()
148
+ + assert set(after_delete) == {"first:v1"}
149
+ +
150
+ +
151
+ +def test_force_rebuild_recompiles_all_current_sources(tmp_path):
152
+ + project, compiler = make_project(tmp_path)
153
+ + contracts = tmp_path / "contracts"
154
+ + contracts.mkdir()
155
+ + first = contracts / "first.foo"
156
+ + second = contracts / "second.foo"
157
+ + first.write_text("v1")
158
+ + second.write_text("v1")
159
+ +
160
+ + project.load_contracts()
161
+ + project.load_contracts(use_cache=False)
162
+ +
163
+ + assert compiler.calls[-1] == (str(first), str(second))
164
+ diff --git a/mimo_test_command.sh b/mimo_test_command.sh
165
+ new file mode 100755
166
+ --- /dev/null
167
+ +++ b/mimo_test_command.sh
168
+ @@ -0,0 +1,6 @@
169
+ +#!/bin/bash
170
+ +set -euo pipefail
171
+ +
172
+ +
173
+ +pytest -q tests/functional/project/test_project_manager_cache_contract.py
174
+ +
tasks/format-code-task-000023/tests/test.sh ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/functional/project/test_project_manager_cache_contract.py
25
+ mimo_test_command.sh
26
+ EOF_RESET_TEST_FILES
27
+
28
+ ); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
29
+ if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
30
+ cat "$V/apply.log" >&2
31
+ echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
32
+ exit 1
33
+ fi
34
+ timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
35
+ RC=$?
36
+ tail -c 12000 "$V/test_output.log"
37
+ if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
38
+ echo "test command exited $RC"
tasks/format-code-task-000023/tests/test_command.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ bash /testbed/mimo_test_command.sh
tasks/format-code-task-000047/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:1b67b35306e761ceb70521c02b9cb92a908cccf12262767ed336012e4e76ff93
tasks/format-code-task-000047/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-000047/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-000047/tests/test.patch ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/test/imagebuilder.test.ts b/test/imagebuilder.test.ts
2
+ index 3c5285b..f56c5a7 100644
3
+ --- a/test/imagebuilder.test.ts
4
+ +++ b/test/imagebuilder.test.ts
5
+ @@ -1,5 +1,6 @@
6
+ import * as cdk from 'aws-cdk-lib';
7
+ import { aws_ec2 as ec2 } from 'aws-cdk-lib';
8
+ +import { Template } from 'aws-cdk-lib/assertions';
9
+ import { Architecture, ContainerImageBuilder, Os } from '../src';
10
+ import { AmiBuilder } from '../src/providers/image-builders/ami';
11
+
12
+ @@ -83,3 +84,161 @@ test('Container image builder supported OS', () => {
13
+ });
14
+ }).toThrowError('Unsupported architecture: ARM64. Consider CodeBuild for faster image builds.');
15
+ });
16
+ +
17
+ +function countDockerComponents(stack: cdk.Stack): number {
18
+ + const template = Template.fromStack(stack);
19
+ + const components = template.findResources('AWS::ImageBuilder::Component');
20
+ + let count = 0;
21
+ + for (const key of Object.keys(components)) {
22
+ + const props = components[key].Properties;
23
+ + if (props && props.Description === 'Install latest version of Docker') {
24
+ + count += 1;
25
+ + }
26
+ + }
27
+ + return count;
28
+ +}
29
+ +
30
+ +
31
+ +
32
+ +
33
+ +
34
+ +function dockerProps(value: boolean): any {
35
+ + return { installDocker: value, docker: value };
36
+ +}
37
+ +
38
+ +test('AMI builder installs Docker by default on Linux', () => {
39
+ + const app = new cdk.App();
40
+ + const stack = new cdk.Stack(app, 'test');
41
+ + const vpc = new ec2.Vpc(stack, 'vpc');
42
+ +
43
+ + new AmiBuilder(stack, 'linux x64', {
44
+ + os: Os.LINUX,
45
+ + architecture: Architecture.X86_64,
46
+ + vpc,
47
+ + });
48
+ +
49
+ + expect(countDockerComponents(stack)).toBe(1);
50
+ +});
51
+ +
52
+ +test('AMI builder installs Docker by default on Windows', () => {
53
+ + const app = new cdk.App();
54
+ + const stack = new cdk.Stack(app, 'test');
55
+ + const vpc = new ec2.Vpc(stack, 'vpc');
56
+ +
57
+ + new AmiBuilder(stack, 'win x64', {
58
+ + os: Os.WINDOWS,
59
+ + architecture: Architecture.X86_64,
60
+ + vpc,
61
+ + });
62
+ +
63
+ + expect(countDockerComponents(stack)).toBe(1);
64
+ +});
65
+ +
66
+ +test('AMI builder skips Docker on Windows when installDocker is false', () => {
67
+ + const app = new cdk.App();
68
+ + const stack = new cdk.Stack(app, 'test');
69
+ + const vpc = new ec2.Vpc(stack, 'vpc');
70
+ +
71
+ + new AmiBuilder(stack, 'win x64', {
72
+ + os: Os.WINDOWS,
73
+ + architecture: Architecture.X86_64,
74
+ + vpc,
75
+ + ...dockerProps(false),
76
+ + });
77
+ +
78
+ + expect(countDockerComponents(stack)).toBe(0);
79
+ +});
80
+ +
81
+ +test('AMI builder skips Docker on Linux when installDocker is false', () => {
82
+ + const app = new cdk.App();
83
+ + const stack = new cdk.Stack(app, 'test');
84
+ + const vpc = new ec2.Vpc(stack, 'vpc');
85
+ +
86
+ + new AmiBuilder(stack, 'linux x64', {
87
+ + os: Os.LINUX,
88
+ + architecture: Architecture.X86_64,
89
+ + vpc,
90
+ + ...dockerProps(false),
91
+ + });
92
+ +
93
+ + expect(countDockerComponents(stack)).toBe(0);
94
+ +});
95
+ +
96
+ +test('AMI builder installs Docker on Windows when installDocker is explicitly true', () => {
97
+ + const app = new cdk.App();
98
+ + const stack = new cdk.Stack(app, 'test');
99
+ + const vpc = new ec2.Vpc(stack, 'vpc');
100
+ +
101
+ + new AmiBuilder(stack, 'win x64', {
102
+ + os: Os.WINDOWS,
103
+ + architecture: Architecture.X86_64,
104
+ + vpc,
105
+ + ...dockerProps(true),
106
+ + });
107
+ +
108
+ + expect(countDockerComponents(stack)).toBe(1);
109
+ +});
110
+ +
111
+ +test('AMI builder installs Docker on Linux when installDocker is explicitly true', () => {
112
+ + const app = new cdk.App();
113
+ + const stack = new cdk.Stack(app, 'test');
114
+ + const vpc = new ec2.Vpc(stack, 'vpc');
115
+ +
116
+ + new AmiBuilder(stack, 'linux x64', {
117
+ + os: Os.LINUX,
118
+ + architecture: Architecture.X86_64,
119
+ + vpc,
120
+ + ...dockerProps(true),
121
+ + });
122
+ +
123
+ + expect(countDockerComponents(stack)).toBe(1);
124
+ +});
125
+ +
126
+ +test('AMI builder retains non-Docker components when installDocker is false on Windows', () => {
127
+ + const app = new cdk.App();
128
+ + const stack = new cdk.Stack(app, 'test');
129
+ + const vpc = new ec2.Vpc(stack, 'vpc');
130
+ +
131
+ + new AmiBuilder(stack, 'win x64', {
132
+ + os: Os.WINDOWS,
133
+ + architecture: Architecture.X86_64,
134
+ + vpc,
135
+ + ...dockerProps(false),
136
+ + });
137
+ +
138
+ + const template = Template.fromStack(stack);
139
+ + const components = template.findResources('AWS::ImageBuilder::Component');
140
+ + const descriptions = Object.keys(components).map(k => components[k].Properties?.Description);
141
+ +
142
+ + expect(descriptions).toEqual(expect.arrayContaining([
143
+ + expect.stringMatching(/CloudWatch/),
144
+ + 'Install latest version of AWS CLI',
145
+ + 'Install latest version of gh',
146
+ + 'Install latest version of git',
147
+ + 'Install latest version of GitHub Actions Runner',
148
+ + ]));
149
+ + expect(descriptions).not.toContain('Install latest version of Docker');
150
+ +});
151
+ +
152
+ +test('AMI builder retains non-Docker components when installDocker is false on Linux', () => {
153
+ + const app = new cdk.App();
154
+ + const stack = new cdk.Stack(app, 'test');
155
+ + const vpc = new ec2.Vpc(stack, 'vpc');
156
+ +
157
+ + new AmiBuilder(stack, 'linux x64', {
158
+ + os: Os.LINUX,
159
+ + architecture: Architecture.X86_64,
160
+ + vpc,
161
+ + ...dockerProps(false),
162
+ + });
163
+ +
164
+ + const template = Template.fromStack(stack);
165
+ + const components = template.findResources('AWS::ImageBuilder::Component');
166
+ + const descriptions = Object.keys(components).map(k => components[k].Properties?.Description);
167
+ + expect(descriptions).toEqual(expect.arrayContaining([
168
+ + 'Install latest version of gh',
169
+ + 'Install latest version of git',
170
+ + 'Install latest version of GitHub Actions Runner',
171
+ + ]));
172
+ + expect(descriptions).not.toContain('Install latest version of Docker');
173
+ +});
174
+ diff --git a/test_commands.json b/test_commands.json
175
+ new file mode 100644
176
+ index 0000000..b489dc5
177
+ --- /dev/null
178
+ +++ b/test_commands.json
179
+ @@ -0,0 +1,3 @@
180
+ +{
181
+ + "test_commands": ["npx jest test/imagebuilder.test.ts --no-coverage"]
182
+ +}
183
+ diff --git a/mimo_test_command.sh b/mimo_test_command.sh
184
+ new file mode 100755
185
+ --- /dev/null
186
+ +++ b/mimo_test_command.sh
187
+ @@ -0,0 +1,8 @@
188
+ +#!/usr/bin/env bash
189
+ +
190
+ +set -uo pipefail
191
+ +cd /testbed
192
+ +rc=0
193
+ +npx jest test/imagebuilder.test.ts --no-coverage
194
+ +rc=$(( rc | $? ))
195
+ +exit $rc
tasks/format-code-task-000047/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
+ test/imagebuilder.test.ts
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-000047/tests/test_command.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ bash /testbed/mimo_test_command.sh
tasks/format-code-task-000049/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:61f60677512e77b14dbd2882794c2534c481ea5ed7a45fc7921aee940804de83
tasks/format-code-task-000049/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-000049/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-000049/tests/test.patch ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/flocker/control/test/test_httpapi.py b/flocker/control/test/test_httpapi.py
2
+ index 806837648..9d7258ac9 100644
3
+ --- a/flocker/control/test/test_httpapi.py
4
+ +++ b/flocker/control/test/test_httpapi.py
5
+ @@ -173,6 +173,304 @@ RealTestsAPI, MemoryTestsAPI = buildIntegrationTests(
6
+ VersionTestsMixin, "API", _build_app)
7
+
8
+
9
+ +class CreateContainerTestsMixin(APITestsMixin):
10
+ + """
11
+ + Black-box tests for creating container configuration through the HTTP API.
12
+ + """
13
+ + def _request_json(self, method, path, body, expected_code):
14
+ + """
15
+ + Issue a JSON request through the existing HTTP API test harness and
16
+ + return a ``Deferred`` firing with the decoded response body.
17
+ +
18
+ + This helper intentionally does not inspect route handlers, decorators,
19
+ + schemas, or private helpers.
20
+ + """
21
+ + requesting = self.assertResponseCode(
22
+ + method, path, body, expected_code)
23
+ + requesting.addCallback(readBody)
24
+ + requesting.addCallback(loads)
25
+ + return requesting
26
+ +
27
+ + def _applications_for_host(self, host):
28
+ + """
29
+ + Return the configured applications for ``host`` from the persisted
30
+ + configuration.
31
+ + """
32
+ + deployment = self.persistence_service.get()
33
+ + matching = [
34
+ + node for node in deployment.nodes
35
+ + if node.hostname == host
36
+ + ]
37
+ + if not matching:
38
+ + return []
39
+ + return list(matching[0].applications)
40
+ +
41
+ + def _configured_applications_named(self, name):
42
+ + """
43
+ + Return all configured applications with the supplied public container
44
+ + name, across all hosts.
45
+ + """
46
+ + deployment = self.persistence_service.get()
47
+ + return [
48
+ + application
49
+ + for node in deployment.nodes
50
+ + for application in node.applications
51
+ + if application.name == name
52
+ + ]
53
+ +
54
+ + def _assert_application_present(self, host, name, image):
55
+ + """
56
+ + Assert that the persisted configuration contains a container with the
57
+ + supplied public values on ``host``.
58
+ + """
59
+ + expected_image = DockerImage.from_string(image)
60
+ + matches = [
61
+ + application for application in self._applications_for_host(host)
62
+ + if application.name == name and application.image == expected_image
63
+ + ]
64
+ + self.assertEqual(
65
+ + len(matches), 1,
66
+ + "Expected exactly one configured container named {!r} with image "
67
+ + "{!r} on host {!r}; found {!r}".format(
68
+ + name, image, host, self._applications_for_host(host)))
69
+ +
70
+ + def _assert_duplicate_name_conflict(self, response_json):
71
+ + """
72
+ + Assert only the public error shape and duplicate-name semantics.
73
+ + The exact prose is intentionally not locked down because the reference
74
+ + patch's docs and implementation disagree on the full sentence.
75
+ + """
76
+ +
77
+ +
78
+ + self.assertIn(u"description", response_json)
79
+ + self.assertNotIn(u"message", response_json)
80
+ + self.assertTrue(isinstance(response_json[u"description"], unicode))
81
+ + self.assertTrue(response_json[u"description"])
82
+ +
83
+ + def test_create_container_response_echoes_request(self):
84
+ + """
85
+ + Creating a container returns 201 Created and echoes the public
86
+ + host/name/image values from the request body.
87
+ + """
88
+ + container_json = {
89
+ + u"host": self.NODE_B,
90
+ + u"name": u"postgres",
91
+ + u"image": u"postgres",
92
+ + }
93
+ + return self.assertResult(
94
+ + b"POST", b"/configuration/containers",
95
+ + container_json, CREATED, container_json)
96
+ +
97
+ + def test_create_container_persists_on_requested_existing_host(self):
98
+ + """
99
+ + Creating a container on an existing host persists it on that host and
100
+ + preserves unrelated existing configuration.
101
+ + """
102
+ + saving = self.persistence_service.save(Deployment(
103
+ + nodes={
104
+ + Node(
105
+ + hostname=self.NODE_A,
106
+ + applications=[
107
+ + Application(
108
+ + name=u"postgres",
109
+ + image=DockerImage.from_string(u"postgres")),
110
+ + ]),
111
+ + Node(hostname=self.NODE_B),
112
+ + }))
113
+ +
114
+ + def saved(_):
115
+ + return self.assertResponseCode(
116
+ + b"POST", b"/configuration/containers",
117
+ + {
118
+ + u"host": self.NODE_A,
119
+ + u"name": u"another_postgres",
120
+ + u"image": u"postgres:latest",
121
+ + },
122
+ + CREATED)
123
+ + saving.addCallback(saved)
124
+ +
125
+ + def created(_):
126
+ + self._assert_application_present(
127
+ + self.NODE_A, u"postgres", u"postgres")
128
+ + self._assert_application_present(
129
+ + self.NODE_A, u"another_postgres", u"postgres:latest")
130
+ + self.assertEqual(
131
+ + [],
132
+ + [
133
+ + application for application
134
+ + in self._applications_for_host(self.NODE_B)
135
+ + if application.name == u"another_postgres"
136
+ + ])
137
+ + saving.addCallback(created)
138
+ + return saving
139
+ +
140
+ + def test_create_container_persists_on_new_host(self):
141
+ + """
142
+ + Creating a container for a host absent from the current configuration
143
+ + persists a host entry containing that container.
144
+ + """
145
+ + d = self.assertResponseCode(
146
+ + b"POST", b"/configuration/containers",
147
+ + {
148
+ + u"host": self.NODE_B,
149
+ + u"name": u"redis_cache",
150
+ + u"image": u"redis:latest",
151
+ + },
152
+ + CREATED)
153
+ +
154
+ + def created(_):
155
+ + self._assert_application_present(
156
+ + self.NODE_B, u"redis_cache", u"redis:latest")
157
+ + d.addCallback(created)
158
+ + return d
159
+ +
160
+ + def test_create_container_persists_arbitrary_public_values(self):
161
+ + """
162
+ + Container creation is not limited to the fixture hosts, names, and
163
+ + images used by other tests.
164
+ + """
165
+ + host = u"198.51.100.7"
166
+ + name = u"api_worker"
167
+ + image = u"clusterhq/api-worker:1.2.3"
168
+ + container_json = {
169
+ + u"host": host,
170
+ + u"name": name,
171
+ + u"image": image,
172
+ + }
173
+ + d = self.assertResult(
174
+ + b"POST", b"/configuration/containers",
175
+ + container_json, CREATED, container_json)
176
+ +
177
+ + def created(_):
178
+ + self._assert_application_present(host, name, image)
179
+ + d.addCallback(created)
180
+ + return d
181
+ +
182
+ + def test_duplicate_container_name_rejected_on_same_host(self):
183
+ + """
184
+ + A second container with an existing name is rejected on the same host,
185
+ + even if another public field differs.
186
+ + """
187
+ + first = {
188
+ + u"host": self.NODE_A,
189
+ + u"name": u"postgres",
190
+ + u"image": u"postgres",
191
+ + }
192
+ + second = {
193
+ + u"host": self.NODE_A,
194
+ + u"name": u"postgres",
195
+ + u"image": u"postgres:alternate",
196
+ + }
197
+ + d = self.assertResponseCode(
198
+ + b"POST", b"/configuration/containers", first, CREATED)
199
+ +
200
+ + def created(_):
201
+ + return self._request_json(
202
+ + b"POST", b"/configuration/containers", second, CONFLICT)
203
+ + d.addCallback(created)
204
+ +
205
+ + def conflicted(response_json):
206
+ + self._assert_duplicate_name_conflict(response_json)
207
+ + self.assertEqual(
208
+ + 1, len(self._configured_applications_named(u"postgres")))
209
+ + d.addCallback(conflicted)
210
+ + return d
211
+ +
212
+ + def test_duplicate_container_name_rejected_on_different_host(self):
213
+ + """
214
+ + Container names are unique across configured hosts, not merely within
215
+ + the target host.
216
+ + """
217
+ + first = {
218
+ + u"host": self.NODE_A,
219
+ + u"name": u"web",
220
+ + u"image": u"nginx",
221
+ + }
222
+ + second = {
223
+ + u"host": self.NODE_B,
224
+ + u"name": u"web",
225
+ + u"image": u"redis",
226
+ + }
227
+ + d = self.assertResponseCode(
228
+ + b"POST", b"/configuration/containers", first, CREATED)
229
+ +
230
+ + def created(_):
231
+ + return self._request_json(
232
+ + b"POST", b"/configuration/containers", second, CONFLICT)
233
+ + d.addCallback(created)
234
+ +
235
+ + def conflicted(response_json):
236
+ + self._assert_duplicate_name_conflict(response_json)
237
+ + self.assertEqual(
238
+ + 1, len(self._configured_applications_named(u"web")))
239
+ + d.addCallback(conflicted)
240
+ + return d
241
+ +
242
+ + def test_duplicate_container_name_rejected_when_existing_on_other_host_first(self):
243
+ + """
244
+ + Duplicate-name detection is global even when the existing container is
245
+ + on a different host than the original fixture order.
246
+ + """
247
+ + first = {
248
+ + u"host": self.NODE_B,
249
+ + u"name": u"api_worker",
250
+ + u"image": u"clusterhq/api-worker:1.0",
251
+ + }
252
+ + second = {
253
+ + u"host": self.NODE_A,
254
+ + u"name": u"api_worker",
255
+ + u"image": u"clusterhq/api-worker:2.0",
256
+ + }
257
+ + d = self.assertResponseCode(
258
+ + b"POST", b"/configuration/containers", first, CREATED)
259
+ +
260
+ + def created(_):
261
+ + return self._request_json(
262
+ + b"POST", b"/configuration/containers", second, CONFLICT)
263
+ + d.addCallback(created)
264
+ +
265
+ + def conflicted(response_json):
266
+ + self._assert_duplicate_name_conflict(response_json)
267
+ + self.assertEqual(
268
+ + 1, len(self._configured_applications_named(u"api_worker")))
269
+ + d.addCallback(conflicted)
270
+ + return d
271
+ +
272
+ + def test_duplicate_container_name_rejected_with_same_image(self):
273
+ + """
274
+ + Duplicate-name detection is by name, not by the full container body.
275
+ + """
276
+ + first = {
277
+ + u"host": self.NODE_A,
278
+ + u"name": u"same_image_worker",
279
+ + u"image": u"redis:latest",
280
+ + }
281
+ + second = {
282
+ + u"host": self.NODE_B,
283
+ + u"name": u"same_image_worker",
284
+ + u"image": u"redis:latest",
285
+ + }
286
+ + d = self.assertResponseCode(
287
+ + b"POST", b"/configuration/containers", first, CREATED)
288
+ +
289
+ + def created(_):
290
+ + return self._request_json(
291
+ + b"POST", b"/configuration/containers", second, CONFLICT)
292
+ + d.addCallback(created)
293
+ +
294
+ + def conflicted(response_json):
295
+ + self._assert_duplicate_name_conflict(response_json)
296
+ + self.assertEqual(
297
+ + 1,
298
+ + len(self._configured_applications_named(u"same_image_worker")))
299
+ + d.addCallback(conflicted)
300
+ + return d
301
+ +
302
+ +
303
+ +RealTestsCreateContainer, MemoryTestsCreateContainer = buildIntegrationTests(
304
+ + CreateContainerTestsMixin, "CreateContainer", _build_app)
305
+ +
306
+ +
307
+ class CreateDatasetTestsMixin(APITestsMixin):
308
+ """
309
+ Tests for the dataset creation endpoint at ``/configuration/datasets``.
310
+ @@ -276,6 +574,42 @@ class CreateDatasetTestsMixin(APITestsMixin):
311
+ """
312
+ return self._dataset_id_collision_test(self.NODE_A, unicode.title)
313
+
314
+ + def test_duplicate_dataset_id_conflict_uses_description_not_message(self):
315
+ + """
316
+ + Duplicate dataset_id conflicts keep returning 409 but use the standard
317
+ + ``description`` error field instead of the older ``message`` field.
318
+ + """
319
+ + dataset_id = unicode(uuid4())
320
+ + first_dataset = {
321
+ + u"primary": self.NODE_A,
322
+ + u"dataset_id": dataset_id,
323
+ + }
324
+ + second_dataset = {
325
+ + u"primary": self.NODE_B,
326
+ + u"dataset_id": dataset_id,
327
+ + }
328
+ + d = self.assertResponseCode(
329
+ + b"POST", b"/configuration/datasets", first_dataset, CREATED)
330
+ +
331
+ + def created(_):
332
+ + requesting = self.assertResponseCode(
333
+ + b"POST", b"/configuration/datasets",
334
+ + second_dataset, CONFLICT)
335
+ + requesting.addCallback(readBody)
336
+ + requesting.addCallback(loads)
337
+ + return requesting
338
+ + d.addCallback(created)
339
+ +
340
+ + def conflicted(response_json):
341
+ +
342
+ +
343
+ + self.assertIn(u"description", response_json)
344
+ + self.assertNotIn(u"message", response_json)
345
+ + self.assertTrue(isinstance(response_json[u"description"], unicode))
346
+ + self.assertTrue(response_json[u"description"])
347
+ + d.addCallback(conflicted)
348
+ + return d
349
+ +
350
+ def test_unknown_primary_node(self):
351
+ """
352
+ If a ``POST`` request made to the endpoint indicates a non-existent
353
+ diff --git a/mimo_test_command.sh b/mimo_test_command.sh
354
+ new file mode 100755
355
+ --- /dev/null
356
+ +++ b/mimo_test_command.sh
357
+ @@ -0,0 +1,30 @@
358
+ +#!/bin/bash
359
+ +set -uo pipefail
360
+ +cd /testbed
361
+ +
362
+ +
363
+ +
364
+ +set +u
365
+ +source .build_env/.venv/bin/activate
366
+ +set -u
367
+ +
368
+ +
369
+ +case "${1:-}" in
370
+ + base)
371
+ + python -m pytest \
372
+ + flocker/control/test/test_schemas.py \
373
+ + flocker/control/test/test_httpapi.py \
374
+ + -v \
375
+ + -k "not CreateContainer and not test_duplicate_dataset_id_conflict_uses_description_not_message"
376
+ + ;;
377
+ + new)
378
+ + python -m pytest \
379
+ + flocker/control/test/test_httpapi.py \
380
+ + -v \
381
+ + -k "CreateContainer or test_duplicate_dataset_id_conflict_uses_description_not_message"
382
+ + ;;
383
+ + *)
384
+ + echo "usage: $0 base|new"
385
+ + exit 2
386
+ + ;;
387
+ +esac
tasks/format-code-task-000049/tests/test.sh ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ flocker/control/test/test_httpapi.py
25
+ mimo_test_command.sh
26
+ EOF_RESET_TEST_FILES
27
+
28
+ ); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
29
+ if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
30
+ cat "$V/apply.log" >&2
31
+ echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
32
+ exit 1
33
+ fi
34
+ timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
35
+ RC=$?
36
+ tail -c 12000 "$V/test_output.log"
37
+ if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
38
+ echo "test command exited $RC"
tasks/format-code-task-000049/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-000071/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:d97d9bf30c418a4d3a4732a5cdcbbcf3af21b918750549629861ab7ec24bac84
tasks/format-code-task-000071/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-000071/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-000071/tests/test.patch ADDED
The diff for this file is too large to render. See raw diff
 
tasks/format-code-task-000071/tests/test.sh ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ datadog/tests/cassettes/TestAccDatadogDashboardGeomap.freeze
25
+ datadog/tests/cassettes/TestAccDatadogDashboardGeomap.yaml
26
+ datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.freeze
27
+ datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.yaml
28
+ datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.freeze
29
+ datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.yaml
30
+ datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.freeze
31
+ datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.yaml
32
+ datadog/tests/resource_datadog_dashboard_geomap_test.go
33
+ mimo_build_env.tar.gz.b64
34
+ mimo_test_command.sh
35
+ EOF_RESET_TEST_FILES
36
+
37
+ ); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
38
+ if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
39
+ cat "$V/apply.log" >&2
40
+ echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
41
+ exit 1
42
+ fi
43
+ timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
44
+ RC=$?
45
+ tail -c 12000 "$V/test_output.log"
46
+ if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
47
+ echo "test command exited $RC"
tasks/format-code-task-000071/tests/test_command.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ bash /testbed/mimo_test_command.sh
tasks/format-code-task-000076/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:4f92177ad8e43e011f3805cf5a3b5919165d7172dcec59ddd6b23e7669d2ec11
tasks/format-code-task-000076/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-000076/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-000076/tests/test.patch ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/tests/test_color_deconvolution.py b/tests/test_color_deconvolution.py
2
+ index 7177c5617..2de55c9db 100644
3
+ --- a/tests/test_color_deconvolution.py
4
+ +++ b/tests/test_color_deconvolution.py
5
+ @@ -37,3 +37,17 @@ def test_roundtrip(self):
6
+ conv_result.Wc, 255)
7
+
8
+ np.testing.assert_allclose(im, im_reconv, atol=1)
9
+ +
10
+ + def test_short_array(self):
11
+ + im_path = datastore.fetch('Easy1.png')
12
+ + im = skimage.io.imread(im_path)[..., :3]
13
+ +
14
+ + w = [[0.650, 0.072],
15
+ + [0.704, 0.990],
16
+ + [0.286, 0.105]]
17
+ +
18
+ + conv_result = htk_dcv.color_deconvolution(im, w, 255)
19
+ +
20
+ + im_reconv = htk_dcv.color_convolution(conv_result.StainsFloat,
21
+ + conv_result.Wc, 255)
22
+ + np.testing.assert_allclose(im, im_reconv, atol=1)
23
+ diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
24
+ new file mode 100644
25
+ --- /dev/null
26
+ +++ b/mimo_build_env.tar.gz.b64
27
+ @@ -0,0 +1,12 @@
28
+ +H4sIAAAAAAAAA+2UUU/bMBDH+5xPccq6rRlz2rQrPCD2sA6mShugbUjwVLnxtfWW2FHsFCrGd5+d
29
+ +QGFojD2Apon7PdTu3eV8vv8l8bSSmZigWnZbj0XPsTUc1qvj9lrvk2E/6fc2t5Jh0uolyWYvacHw
30
+ +0Sq6QWUsLwFapdb2T3H3+f9T4mv9LRo7SXWecyVis3i4M+7RPxkOtm7p/2azP2hB7+FKuJsnrn8q
31
+ +oBZ+iiIwuipThK4ubDMMSz8WU6m6PLVyyS0GwTMYK9exLAO7QChK/Q1TC1IBCmn5NEPItUDoKA0C
32
+ +C/Pah61elgg8K5GLlQ/1T/rUUVDIwhmafAwhBsaUZv7BZlcPJ5NGZ9xKraD/9kUCP8By6eIHvpp3
33
+ +PgJGK7twbjyzqIwLNNDx58IcLZzKAgWcLlBBiYUGadxq0EbB/tGnw5PJeH/08ej97k67U9RZBsBS
34
+ +CGVe6NKCqvJite3uKZXt1H9il3MiVZpVAjtRFEbB4cnoYH9v/OE6Q5z0WarVTM7dNS5jTRTsHn+d
35
+ +fDna2xsf3xG6rp+ZajaTZ1EQzHQJxepsImTpW3elVXchjdW5TI393p0ht5W70++9Buc5Kls3sJvx
36
+ +KWZ/EaeqNENeboPQATjcmITtyzrC2nJZmC/qVew261DPlBvcCdvnzv7cOy/CtSttpKqzhbWga9d8
37
+ +YwOYWfDS6cUO+sBmh+MRtK/6C2zc/kUyYNrlOfeHXbTPr7t7Ea7NcXrjDKEVBvVPcHPs3RR9rpqp
38
+ +dJ8CPzLeY4JGIWC5u6e3NOarz2Smy4lAJ91SZ5XvmbsnsGVdExfCvUNmJwz+9etNEARBEARBEARB
39
+ +EARBEARBEARBEARBEMQT4CdZvc8vACgAAA==
40
+ diff --git a/mimo_test_command.sh b/mimo_test_command.sh
41
+ new file mode 100755
42
+ --- /dev/null
43
+ +++ b/mimo_test_command.sh
44
+ @@ -0,0 +1,6 @@
45
+ +#!/usr/bin/env bash
46
+ +
47
+ +set -uo pipefail
48
+ +cd /testbed || exit 1
49
+ +base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
50
+ +exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
tasks/format-code-task-000076/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/test_color_deconvolution.py
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-000076/tests/test_command.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ bash /testbed/mimo_test_command.sh
tasks/format-code-task-000078/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:a5414de8f9504855344787400ecfe484631d88378f5e153229a32c4cc6ac7242
tasks/format-code-task-000078/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-000078/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-000078/tests/test.patch ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/tests/e2e/configure.sh b/tests/e2e/configure.sh
2
+ index 5dd75410..4810268f 100755
3
+ --- a/tests/e2e/configure.sh
4
+ +++ b/tests/e2e/configure.sh
5
+ @@ -20,7 +20,7 @@ beforeAll() {
6
+ }
7
+
8
+ beforeEach() {
9
+ - rm -f ./temp-config
10
+ + rm -rf ./temp-config ./temp-config-dir
11
+ }
12
+
13
+ afterAll() {
14
+ @@ -70,6 +70,22 @@ config="$("$DOPPLER_BINARY" configure get config --configuration=./temp-config -
15
+
16
+ beforeEach
17
+
18
+ +
19
+ +mkdir ./temp-config-dir
20
+ +"$DOPPLER_BINARY" configure set config 123 --config-dir=./temp-config-dir --scope=/ --silent
21
+ +config="$("$DOPPLER_BINARY" configure get config --configuration=./temp-config-dir/.doppler.yaml --scope=/ --plain)"
22
+ +[[ "$config" == "123" ]] || error "ERROR: config-dir not properly used"
23
+ +
24
+ +beforeEach
25
+ +
26
+ +
27
+ +mkdir ./temp-config-dir
28
+ +"$DOPPLER_BINARY" configure set config 123 --config-dir=./temp-config-dir --configuration ./temp-config --scope=/ --silent
29
+ +config="$("$DOPPLER_BINARY" configure get config --configuration=./temp-config --scope=/ --plain)"
30
+ +[[ "$config" == "123" ]] || error "ERROR: configuration not properly used when specified with config-dir"
31
+ +
32
+ +beforeEach
33
+ +
34
+ # test unset
35
+ "$DOPPLER_BINARY" configure set config 123 --configuration=./temp-config --scope=/ --silent
36
+ "$DOPPLER_BINARY" configure unset config --configuration=./temp-config --scope=/ --silent
37
+ diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
38
+ new file mode 100644
39
+ --- /dev/null
40
+ +++ b/mimo_build_env.tar.gz.b64
41
+ @@ -0,0 +1,6 @@
42
+ +H4sIAAAAAAAAA+3SwU6DQBAGYM48xQTPsECFnnqwqYkmRmsPRk8NsNuFCCxZoNG3F6i2jYn2YBtj
43
+ +/L/LALPZnWXGidss50tRrplxKm5nHARD7HyOw7MX+J7vhmEXDdfzQtczKDhZRXvauok0kaGVar5b
44
+ +dyj/Rzm7/jeibpaJKoqo5E6dHu+MQ/0fjUe7/vvdd+889EYGuccr4Wv/vP8Jp6HxseCmeUbTfhqo
45
+ +SQVxVVW50BRnZaRfTalomBSy1TZl53yVR7KeWPYjyaxJ29jp5ofNNvmre5bkGaueJVsLXWeqdOZa
46
+ +SR0VD5vXCRdruz/coiLKSkeqvoRFWw4FJKpcZbLVgoQvqF9mipdK6YZmd/P5zeViOb2+vVg8TayP
47
+ +C7D3wiwzjup0e68h1qzbhW337Obb/O1fDwAAAAAAAAAAAAAAAAAAAADwY29RmGj0ACgAAA==
48
+ diff --git a/mimo_test_command.sh b/mimo_test_command.sh
49
+ new file mode 100755
50
+ --- /dev/null
51
+ +++ b/mimo_test_command.sh
52
+ @@ -0,0 +1,6 @@
53
+ +#!/usr/bin/env bash
54
+ +
55
+ +set -uo pipefail
56
+ +cd /testbed || exit 1
57
+ +base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
58
+ +exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
tasks/format-code-task-000078/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/e2e/configure.sh
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-000078/tests/test_command.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ bash /testbed/mimo_test_command.sh
tasks/format-code-task-000082/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:eadb7b98150fdecfa17f54df7616bb6b2fb5067853f86a29f0f6788a2f52202d
tasks/format-code-task-000082/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-000082/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-000082/tests/test.patch ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/sei/sei_task_test.go b/sei/sei_task_test.go
2
+ new file mode 100644
3
+ index 0000000..9bf152f
4
+ --- /dev/null
5
+ +++ b/sei/sei_task_test.go
6
+ @@ -0,0 +1,242 @@
7
+ +package sei_test
8
+ +
9
+ +import (
10
+ + "bytes"
11
+ + "encoding/hex"
12
+ + "strings"
13
+ + "testing"
14
+ +
15
+ + "github.com/edgeware/mp4ff/sei"
16
+ +)
17
+ +
18
+ +
19
+ +
20
+ +
21
+ +
22
+ +const seiHEVCHDR = "891800000300000300000300000300000300000300000300000300000300000300000300009004000003000080"
23
+ +
24
+ +
25
+ +
26
+ +const sei0Hex = "0007810f1c0050744080"
27
+ +
28
+ +func TestExtractSEIDataSingleMessage(t *testing.T) {
29
+ + raw, err := hex.DecodeString(sei0Hex)
30
+ + if err != nil {
31
+ + t.Fatal(err)
32
+ + }
33
+ + datas, err := sei.ExtractSEIData(bytes.NewReader(raw))
34
+ + if err != nil {
35
+ + t.Fatal(err)
36
+ + }
37
+ + if len(datas) != 1 {
38
+ + t.Fatalf("got %d messages, want 1", len(datas))
39
+ + }
40
+ + if datas[0].Type() != 0 {
41
+ + t.Errorf("got type %d, want 0", datas[0].Type())
42
+ + }
43
+ + if datas[0].Size() != 7 {
44
+ + t.Errorf("got size %d, want 7", datas[0].Size())
45
+ + }
46
+ + wantPayload, _ := hex.DecodeString("810f1c00507440")
47
+ + if !bytes.Equal(datas[0].Payload(), wantPayload) {
48
+ + t.Errorf("got payload %x, want %x", datas[0].Payload(), wantPayload)
49
+ + }
50
+ +}
51
+ +
52
+ +func TestExtractSEIDataMultiMessageWithEmulation(t *testing.T) {
53
+ + raw, err := hex.DecodeString(seiHEVCHDR)
54
+ + if err != nil {
55
+ + t.Fatal(err)
56
+ + }
57
+ + datas, err := sei.ExtractSEIData(bytes.NewReader(raw))
58
+ + if err != nil {
59
+ + t.Fatal(err)
60
+ + }
61
+ + if len(datas) != 2 {
62
+ + t.Fatalf("got %d messages, want 2", len(datas))
63
+ + }
64
+ + wantTypes := []uint{137, 144}
65
+ + wantSizes := []uint{24, 4}
66
+ + for i := range datas {
67
+ + if datas[i].Type() != wantTypes[i] {
68
+ + t.Errorf("message %d: got type %d, want %d", i, datas[i].Type(), wantTypes[i])
69
+ + }
70
+ + if datas[i].Size() != wantSizes[i] {
71
+ + t.Errorf("message %d: got size %d, want %d", i, datas[i].Size(), wantSizes[i])
72
+ + }
73
+ +
74
+ + if uint(len(datas[i].Payload())) != wantSizes[i] {
75
+ + t.Errorf("message %d: payload len %d, want %d", i, len(datas[i].Payload()), wantSizes[i])
76
+ + }
77
+ + }
78
+ +
79
+ +
80
+ + for i := range datas {
81
+ + msg, err := sei.DecodeSEIMessage(&datas[i], sei.HEVC)
82
+ + if err != nil {
83
+ + t.Fatal(err)
84
+ + }
85
+ + if msg.Type() != wantTypes[i] {
86
+ + t.Errorf("decoded message %d: got type %d, want %d", i, msg.Type(), wantTypes[i])
87
+ + }
88
+ + if !bytes.Equal(msg.Payload(), datas[i].Payload()) {
89
+ + t.Errorf("decoded message %d: payload not round-tripped", i)
90
+ + }
91
+ + }
92
+ +}
93
+ +
94
+ +func TestMasteringDisplayColourVolumeFields(t *testing.T) {
95
+ + hex137 := "11223344556677889900aabbccddeeff0011223344556677"
96
+ + pl, err := hex.DecodeString(hex137)
97
+ + if err != nil {
98
+ + t.Fatal(err)
99
+ + }
100
+ + msg, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIMasteringDisplayColourVolumeType, pl), sei.HEVC)
101
+ + if err != nil {
102
+ + t.Fatal(err)
103
+ + }
104
+ + if msg.Type() != sei.SEIMasteringDisplayColourVolumeType {
105
+ + t.Errorf("got type %d, want %d", msg.Type(), sei.SEIMasteringDisplayColourVolumeType)
106
+ + }
107
+ + if msg.Size() != 24 {
108
+ + t.Errorf("got size %d, want 24", msg.Size())
109
+ + }
110
+ + m, ok := msg.(*sei.MasteringDisplayColourVolumeSEI)
111
+ + if !ok {
112
+ + t.Fatalf("decoded message is not *MasteringDisplayColourVolumeSEI, got %T", msg)
113
+ + }
114
+ + if m.DisplayPrimariesX != [3]uint16{0x1122, 0x5566, 0x9900} {
115
+ + t.Errorf("DisplayPrimariesX = %v", m.DisplayPrimariesX)
116
+ + }
117
+ + if m.DisplayPrimariesY != [3]uint16{0x3344, 0x7788, 0xaabb} {
118
+ + t.Errorf("DisplayPrimariesY = %v", m.DisplayPrimariesY)
119
+ + }
120
+ + if m.WhitePointX != 0xccdd || m.WhitePointY != 0xeeff {
121
+ + t.Errorf("white point = (%#x, %#x)", m.WhitePointX, m.WhitePointY)
122
+ + }
123
+ + if m.MaxDisplayMasteringLuminance != 0x00112233 {
124
+ + t.Errorf("MaxDisplayMasteringLuminance = %#x", m.MaxDisplayMasteringLuminance)
125
+ + }
126
+ + if m.MinDisplayMasteringLuminance != 0x44556677 {
127
+ + t.Errorf("MinDisplayMasteringLuminance = %#x", m.MinDisplayMasteringLuminance)
128
+ + }
129
+ + if !bytes.Equal(msg.Payload(), pl) {
130
+ + t.Errorf("payload round-trip mismatch: got %x, want %x", msg.Payload(), pl)
131
+ + }
132
+ +}
133
+ +
134
+ +func TestMasteringDisplayColourVolumeEncode(t *testing.T) {
135
+ + m := &sei.MasteringDisplayColourVolumeSEI{
136
+ + DisplayPrimariesX: [3]uint16{1, 2, 3},
137
+ + DisplayPrimariesY: [3]uint16{4, 5, 6},
138
+ + WhitePointX: 7,
139
+ + WhitePointY: 8,
140
+ + MaxDisplayMasteringLuminance: 9,
141
+ + MinDisplayMasteringLuminance: 10,
142
+ + }
143
+ + pl := m.Payload()
144
+ + if len(pl) != 24 {
145
+ + t.Fatalf("payload length %d, want 24", len(pl))
146
+ + }
147
+ + msg, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIMasteringDisplayColourVolumeType, pl), sei.HEVC)
148
+ + if err != nil {
149
+ + t.Fatal(err)
150
+ + }
151
+ + d, ok := msg.(*sei.MasteringDisplayColourVolumeSEI)
152
+ + if !ok {
153
+ + t.Fatalf("decoded message is not *MasteringDisplayColourVolumeSEI, got %T", msg)
154
+ + }
155
+ + if *d != *m {
156
+ + t.Errorf("round-trip mismatch: got %+v, want %+v", *d, *m)
157
+ + }
158
+ +}
159
+ +
160
+ +func TestMasteringDisplayColourVolumeSizeError(t *testing.T) {
161
+ + for _, n := range []int{0, 23, 25} {
162
+ + _, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIMasteringDisplayColourVolumeType, make([]byte, n)), sei.HEVC)
163
+ + if err == nil {
164
+ + t.Errorf("payload length %d: expected an error, got nil", n)
165
+ + }
166
+ + }
167
+ +}
168
+ +
169
+ +func TestContentLightLevelFields(t *testing.T) {
170
+ + hex144 := "11223344"
171
+ + pl, err := hex.DecodeString(hex144)
172
+ + if err != nil {
173
+ + t.Fatal(err)
174
+ + }
175
+ + msg, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIContentLightLevelInformationType, pl), sei.HEVC)
176
+ + if err != nil {
177
+ + t.Fatal(err)
178
+ + }
179
+ + if msg.Type() != sei.SEIContentLightLevelInformationType {
180
+ + t.Errorf("got type %d, want %d", msg.Type(), sei.SEIContentLightLevelInformationType)
181
+ + }
182
+ + if msg.Size() != 4 {
183
+ + t.Errorf("got size %d, want 4", msg.Size())
184
+ + }
185
+ + c, ok := msg.(*sei.ContentLightLevelInformationSEI)
186
+ + if !ok {
187
+ + t.Fatalf("decoded message is not *ContentLightLevelInformationSEI, got %T", msg)
188
+ + }
189
+ + if c.MaxContentLightLevel != 0x1122 {
190
+ + t.Errorf("MaxContentLightLevel = %#x", c.MaxContentLightLevel)
191
+ + }
192
+ + if c.MaxPicAverageLightLevel != 0x3344 {
193
+ + t.Errorf("MaxPicAverageLightLevel = %#x", c.MaxPicAverageLightLevel)
194
+ + }
195
+ + if !bytes.Equal(msg.Payload(), pl) {
196
+ + t.Errorf("payload round-trip mismatch: got %x, want %x", msg.Payload(), pl)
197
+ + }
198
+ +}
199
+ +
200
+ +func TestContentLightLevelSizeError(t *testing.T) {
201
+ + for _, n := range []int{0, 3, 5} {
202
+ + _, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIContentLightLevelInformationType, make([]byte, n)), sei.HEVC)
203
+ + if err == nil {
204
+ + t.Errorf("payload length %d: expected an error, got nil", n)
205
+ + }
206
+ + }
207
+ +}
208
+ +
209
+ +func TestGenericFallback(t *testing.T) {
210
+ + pl, _ := hex.DecodeString("deadbeef")
211
+ + for _, codec := range []sei.Codec{sei.AVC, sei.HEVC} {
212
+ + msg, err := sei.DecodeSEIMessage(sei.NewSEIData(99, pl), codec)
213
+ + if err != nil {
214
+ + t.Fatalf("unexpected error for unknown type: %v", err)
215
+ + }
216
+ + if msg.Type() != 99 {
217
+ + t.Errorf("got type %d, want 99", msg.Type())
218
+ + }
219
+ + if msg.Size() != 4 {
220
+ + t.Errorf("got size %d, want 4", msg.Size())
221
+ + }
222
+ + if !bytes.Equal(msg.Payload(), pl) {
223
+ + t.Errorf("payload mismatch: got %x, want %x", msg.Payload(), pl)
224
+ + }
225
+ + }
226
+ +}
227
+ +
228
+ +func TestSEITypeString(t *testing.T) {
229
+ + cases := []struct {
230
+ + id uint
231
+ + want string
232
+ + }{
233
+ + {sei.SEIPicTimingType, "SEIPicTimingType (1)"},
234
+ + {sei.SEIMasteringDisplayColourVolumeType, "SEIMasteringDisplayColourVolumeType (137)"},
235
+ + {sei.SEIContentLightLevelInformationType, "SEIContentLightLevelInformationType (144)"},
236
+ + }
237
+ + for _, tc := range cases {
238
+ + got := sei.SEIType(tc.id).String()
239
+ + if got != tc.want {
240
+ + t.Errorf("SEIType(%d).String() = %q, want %q", tc.id, got, tc.want)
241
+ + }
242
+ + }
243
+ +
244
+ + got := sei.SEIType(200).String()
245
+ + if !strings.HasSuffix(got, "(200)") {
246
+ + t.Errorf("SEIType(200).String() = %q, want suffix %q", got, "(200)")
247
+ + }
248
+ +}
249
+ diff --git a/mimo_test_command.sh b/mimo_test_command.sh
250
+ new file mode 100755
251
+ --- /dev/null
252
+ +++ b/mimo_test_command.sh
253
+ @@ -0,0 +1,16 @@
254
+ +#!/usr/bin/env bash
255
+ +
256
+ +
257
+ +
258
+ +
259
+ +set -euo pipefail
260
+ +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
261
+ +cd /testbed
262
+ +
263
+ +
264
+ +
265
+ +
266
+ +go test ./bits/ ./avc/ ./hevc/
267
+ +
268
+ +
269
+ +go test ./sei/
tasks/format-code-task-000082/tests/test.sh ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ sei/sei_task_test.go
25
+ mimo_test_command.sh
26
+ EOF_RESET_TEST_FILES
27
+
28
+ ); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
29
+ if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
30
+ cat "$V/apply.log" >&2
31
+ echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
32
+ exit 1
33
+ fi
34
+ timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
35
+ RC=$?
36
+ tail -c 12000 "$V/test_output.log"
37
+ if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
38
+ echo "test command exited $RC"
tasks/format-code-task-000082/tests/test_command.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ bash /testbed/mimo_test_command.sh
tasks/format-code-task-000085/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:a11491cccf73e66a7e48338d50bd3787a1d7ebb25b096a0a00b185889bd9034a
tasks/format-code-task-000085/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