diff --git a/tasks/format-code-task-000014/environment/Dockerfile b/tasks/format-code-task-000014/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..188f001d0b2f8ea3e991829b68f905487080deb7 --- /dev/null +++ b/tasks/format-code-task-000014/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2c7c021648118dd49b4be28cd89fd85d6e510e31a6a95588847e3959b64fe03f diff --git a/tasks/format-code-task-000014/environment/setup/files/blocklist b/tasks/format-code-task-000014/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000014/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000014/environment/setup/setup.sh b/tasks/format-code-task-000014/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000014/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000014/tests/test.patch b/tasks/format-code-task-000014/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..45486e095db39b9201c3abd5df026a95d3fe6e6b --- /dev/null +++ b/tasks/format-code-task-000014/tests/test.patch @@ -0,0 +1,523 @@ +diff --git a/usercase-test-coderl/kafka_producer_stateful_test.go b/usercase-test-coderl/kafka_producer_stateful_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/kafka_producer_stateful_test.go +@@ -0,0 +1,494 @@ ++package usercase_test_coderl ++ ++import ( ++ "fmt" ++ "os" ++ "reflect" ++ "runtime" ++ "sort" ++ "strings" ++ "testing" ++ "unsafe" ++ ++ "github.com/8treenet/freedom/infra/kafka" ++ "github.com/IBM/sarama" ++) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++func TestKafkaProducerStartNewMsgAndPublishSession(t *testing.T) { ++ ++ ++ ++ ++ impl := closeableProducer(t) ++ mustNoError(t, impl.Close()) ++ ++ broker := newProducerBroker(t, "orders") ++ defer broker.Close() ++ defer impl.Close() ++ ++ cfg := sarama.NewConfig() ++ cfg.Version = sarama.V2_1_0_0 ++ cfg.Producer.RequiredAcks = sarama.WaitForLocal ++ cfg.Producer.Return.Errors = false ++ cfg.Producer.Return.Successes = false ++ if cfg.Producer.Return.Errors != false { ++ t.Fatalf("fresh cfg Return.Errors = %v, want false", cfg.Producer.Return.Errors) ++ } ++ if cfg.Producer.Return.Successes != false { ++ t.Fatalf("fresh cfg Return.Successes = %v, want false", cfg.Producer.Return.Successes) ++ } ++ ++ producer := kafka.GetProducer() ++ producer.Start([]string{broker.Addr()}, cfg) ++ if cfg.Producer.Return.Errors != true { ++ t.Fatalf("after Start Return.Errors = %v, want true", cfg.Producer.Return.Errors) ++ } ++ if cfg.Producer.Return.Successes != true { ++ t.Fatalf("after Start Return.Successes = %v, want true", cfg.Producer.Return.Successes) ++ } ++ mustNoError(t, producer.Restart()) ++ ++ msg := producer.NewMsg("orders", []byte("paid")) ++ ++ if msg == nil { ++ t.Fatal("NewMsg returned nil") ++ } ++ if msg.GetMessageKey() != "" { ++ t.Fatalf("fresh msg key = %q, want empty string", msg.GetMessageKey()) ++ } ++ ++ if len(msg.GetHeader()) != 0 { ++ t.Fatalf("fresh msg headers = %#v, want no headers", msg.GetHeader()) ++ } ++ ++ headerReturn := msg.SetMessageKey("order-1"). ++ SetHeader(map[string]interface{}{"x-request-id": "r1"}). ++ SetHeader(map[string]interface{}{"attempt": 2}) ++ ++ if headerReturn == nil { ++ t.Fatal("SetHeader chain returned nil") ++ } ++ msg = headerReturn ++ if msg.GetMessageKey() != "order-1" { ++ t.Fatalf("after SetMessageKey key = %q, want %q", msg.GetMessageKey(), "order-1") ++ } ++ if got := fmt.Sprint(msg.GetHeader()["x-request-id"]); got != "r1" { ++ t.Fatalf("header x-request-id = %q, want %q", got, "r1") ++ } ++ if got := fmt.Sprint(msg.GetHeader()["attempt"]); got != "2" { ++ t.Fatalf("header attempt = %q, want %q", got, "2") ++ } ++ ++ mustNoError(t, msg.Publish()) ++ sent := onlyProducedRecord(t, broker, "orders") ++ if sent.topic != "orders" { ++ t.Fatalf("produced topic = %q, want %q", sent.topic, "orders") ++ } ++ ++ if sent.partition < 0 { ++ t.Fatalf("produced partition = %d, want a valid non-negative partition", sent.partition) ++ } ++ if sent.key != "order-1" { ++ t.Fatalf("produced key = %q, want %q", sent.key, "order-1") ++ } ++ if sent.value != "paid" { ++ t.Fatalf("produced value = %q, want %q", sent.value, "paid") ++ } ++ if !reflect.DeepEqual(sent.headers, map[string]string{"attempt": "2", "x-request-id": "r1"}) { ++ t.Fatalf("produced headers = %#v, want %#v", sent.headers, map[string]string{"attempt": "2", "x-request-id": "r1"}) ++ } ++ if msg.GetExecution() != nil { ++ t.Fatalf("after successful Publish execution = %v, want nil", msg.GetExecution()) ++ } ++} ++ ++func TestKafkaProducerGeneratedMessageKeySession(t *testing.T) { ++ ++ ++ ++ ++ impl := closeableProducer(t) ++ mustNoError(t, impl.Close()) ++ ++ broker := newProducerBroker(t, "orders") ++ defer broker.Close() ++ defer impl.Close() ++ ++ cfg := sarama.NewConfig() ++ cfg.Version = sarama.V2_1_0_0 ++ kafka.GetProducer().Start([]string{broker.Addr()}, cfg) ++ mustNoError(t, kafka.GetProducer().Restart()) ++ ++ msg := kafka.GetProducer().NewMsg("orders", []byte("paid")) ++ if msg.GetMessageKey() != "" { ++ t.Fatalf("fresh generated-key msg key = %q, want empty string", msg.GetMessageKey()) ++ } ++ mustNoError(t, msg.Publish()) ++ ++ sent := onlyProducedRecord(t, broker, "orders") ++ ++ generated := sent.key ++ if len(generated) != 32 { ++ t.Fatalf("generated key length = %d, want 32", len(generated)) ++ } ++ if strings.Contains(generated, "-") != false { ++ t.Fatalf("generated key contains dash = %v, want false", strings.Contains(generated, "-")) ++ } ++ if generated != strings.ToUpper(generated) { ++ t.Fatalf("generated key = %q, want uppercase", generated) ++ } ++ if sent.value != "paid" { ++ t.Fatalf("produced generated-key value = %q, want %q", sent.value, "paid") ++ } ++} ++ ++func TestKafkaProducerPublishBeforeInitializedReturnsSpecificError(t *testing.T) { ++ ++ ++ ++ ++ impl := closeableProducer(t) ++ mustNoError(t, impl.Close()) ++ ++ msg := kafka.GetProducer().NewMsg("orders", []byte("paid")) ++ err := msg.Publish() ++ if err == nil { ++ t.Fatal("Publish before initialized error = nil, want producer is not initialized") ++ } ++ if err.Error() != "producer is not initialized" { ++ t.Fatalf("Publish before initialized error = %q, want %q", err.Error(), "producer is not initialized") ++ } ++ if msg.GetExecution() == nil { ++ t.Fatal("GetExecution after failed Publish = nil, want producer is not initialized error") ++ } ++ if msg.GetExecution().Error() != "producer is not initialized" { ++ t.Fatalf("GetExecution after failed Publish = %q, want %q", msg.GetExecution().Error(), "producer is not initialized") ++ } ++} ++ ++func TestKafkaMessagesKeepIndependentState(t *testing.T) { ++ ++ ++ ++ ++ a := kafka.GetProducer().NewMsg("orders", []byte("paid")) ++ b := kafka.GetProducer().NewMsg("orders", []byte("refunded")) ++ ++ a.SetMessageKey("order-1").SetHeader(map[string]interface{}{"x-request-id": "r1"}) ++ if a.GetMessageKey() != "order-1" { ++ t.Fatalf("message a key = %q, want %q", a.GetMessageKey(), "order-1") ++ } ++ if got := fmt.Sprint(a.GetHeader()["x-request-id"]); got != "r1" { ++ t.Fatalf("message a header x-request-id = %q, want %q", got, "r1") ++ } ++ if b.GetMessageKey() != "" { ++ t.Fatalf("message b key = %q, want empty string", b.GetMessageKey()) ++ } ++ ++ if len(b.GetHeader()) != 0 { ++ t.Fatalf("message b headers = %#v, want no headers", b.GetHeader()) ++ } ++ ++ b.SetMessageKey("order-2").SetHeader(map[string]interface{}{"x-request-id": "r2", "attempt": 1}) ++ if a.GetMessageKey() != "order-1" { ++ t.Fatalf("message a key after mutating b = %q, want %q", a.GetMessageKey(), "order-1") ++ } ++ if fmt.Sprint(a.GetHeader()["x-request-id"]) != "r1" { ++ t.Fatalf("message a x-request-id after mutating b = %q, want %q", fmt.Sprint(a.GetHeader()["x-request-id"]), "r1") ++ } ++ if b.GetMessageKey() != "order-2" { ++ t.Fatalf("message b key = %q, want %q", b.GetMessageKey(), "order-2") ++ } ++ if fmt.Sprint(b.GetHeader()["x-request-id"]) != "r2" { ++ t.Fatalf("message b x-request-id = %q, want %q", fmt.Sprint(b.GetHeader()["x-request-id"]), "r2") ++ } ++ if fmt.Sprint(b.GetHeader()["attempt"]) != "1" { ++ t.Fatalf("message b attempt = %q, want %q", fmt.Sprint(b.GetHeader()["attempt"]), "1") ++ } ++} ++ ++func TestKafkaProducerCloseIsIdempotent(t *testing.T) { ++ ++ ++ ++ ++ impl := closeableProducer(t) ++ mustNoError(t, impl.Close()) ++ mustNoError(t, impl.Close()) ++} ++ ++func TestKafkaProducerCloseReleasesResourcesAcrossCycles(t *testing.T) { ++ ++ ++ ++ ++ impl := closeableProducer(t) ++ mustNoError(t, impl.Close()) ++ ++ broker := newProducerBroker(t, "orders") ++ defer broker.Close() ++ defer impl.Close() ++ ++ runtime.GC() ++ baseFDs := countFDs(t) ++ baseGoroutines := runtime.NumGoroutine() ++ ++ for i := 0; i < 120; i++ { ++ cfg := sarama.NewConfig() ++ cfg.Version = sarama.V2_1_0_0 ++ kafka.GetProducer().Start([]string{broker.Addr()}, cfg) ++ mustNoError(t, kafka.GetProducer().Restart()) ++ msg := kafka.GetProducer().NewMsg("orders", []byte("paid")).SetMessageKey(fmt.Sprintf("order-%d", i)) ++ mustNoError(t, msg.Publish()) ++ mustNoError(t, impl.Close()) ++ } ++ ++ runtime.GC() ++ afterFDs := countFDs(t) ++ afterGoroutines := runtime.NumGoroutine() ++ ++ if afterFDs > baseFDs+30 { ++ t.Fatalf("fd count after 120 producer cycles = %d, want <= %d", afterFDs, baseFDs+30) ++ } ++ ++ if afterGoroutines > baseGoroutines+30 { ++ t.Fatalf("goroutines after 120 producer cycles = %d, want <= %d", afterGoroutines, baseGoroutines+30) ++ } ++} ++ ++func TestZZZKafkaProducerMiddlewareOrderStopAndExecution(t *testing.T) { ++ ++ ++ ++ ++ impl := closeableProducer(t) ++ mustNoError(t, impl.Close()) ++ ++ broker := newProducerBroker(t, "orders") ++ defer broker.Close() ++ defer impl.Close() ++ ++ cfg := sarama.NewConfig() ++ cfg.Version = sarama.V2_1_0_0 ++ kafka.GetProducer().Start([]string{broker.Addr()}, cfg) ++ mustNoError(t, kafka.GetProducer().Restart()) ++ ++ var events []string ++ kafka.InstallMiddleware( ++ func(msg *kafka.Msg) { ++ events = append(events, "first-before:"+msg.GetMessageKey()) ++ if msg.IsStopped() != false { ++ t.Fatalf("first middleware IsStopped = %v, want false", msg.IsStopped()) ++ } ++ msg.Next() ++ if msg.GetExecution() != nil { ++ t.Fatalf("first middleware GetExecution after Next = %v, want nil", msg.GetExecution()) ++ } ++ events = append(events, "first-after") ++ }, ++ func(msg *kafka.Msg) { ++ events = append(events, "second-before:"+fmt.Sprint(len(msg.GetHeader()))) ++ msg.Next() ++ events = append(events, "second-after") ++ }, ++ ) ++ ++ msg := kafka.GetProducer().NewMsg("orders", []byte("paid")). ++ SetMessageKey("order-1"). ++ SetHeader(map[string]interface{}{"x-request-id": "r1"}) ++ mustNoError(t, msg.Publish()) ++ if !reflect.DeepEqual(events, []string{"first-before:order-1", "second-before:1", "second-after", "first-after"}) { ++ t.Fatalf("middleware events = %#v, want %#v", events, []string{"first-before:order-1", "second-before:1", "second-after", "first-after"}) ++ } ++ if msg.IsStopped() != false { ++ t.Fatalf("published middleware msg IsStopped = %v, want false", msg.IsStopped()) ++ } ++ if msg.GetExecution() != nil { ++ t.Fatalf("published middleware msg GetExecution = %v, want nil", msg.GetExecution()) ++ } ++ if countProduceRequests(broker) != 1 { ++ t.Fatalf("produce requests after continued middleware = %d, want 1", countProduceRequests(broker)) ++ } ++ ++ var stopEvents []string ++ kafka.InstallMiddleware(func(msg *kafka.Msg) { ++ stopEvents = append(stopEvents, "stop-before") ++ msg.Stop() ++ stopEvents = append(stopEvents, fmt.Sprintf("stopped:%v", msg.IsStopped())) ++ }) ++ ++ stopped := kafka.GetProducer().NewMsg("orders", []byte("blocked")).SetMessageKey("order-stop") ++ if err := stopped.Publish(); err != nil { ++ t.Fatalf("stopped Publish error = %v, want nil", err) ++ } ++ if !reflect.DeepEqual(stopEvents, []string{"stop-before", "stopped:true"}) { ++ t.Fatalf("stop middleware events = %#v, want %#v", stopEvents, []string{"stop-before", "stopped:true"}) ++ } ++ if stopped.IsStopped() != true { ++ t.Fatalf("stopped msg IsStopped = %v, want true", stopped.IsStopped()) ++ } ++ if stopped.GetExecution() != nil { ++ t.Fatalf("stopped msg GetExecution = %v, want nil", stopped.GetExecution()) ++ } ++ if countProduceRequests(broker) != 1 { ++ t.Fatalf("produce requests after stopped middleware = %d, want 1", countProduceRequests(broker)) ++ } ++} ++ ++type producedRecord struct { ++ topic string ++ partition int32 ++ key string ++ value string ++ headers map[string]string ++} ++ ++func closeableProducer(t *testing.T) *kafka.ProducerImpl { ++ t.Helper() ++ impl, ok := kafka.GetProducer().(*kafka.ProducerImpl) ++ if !ok { ++ t.Fatalf("GetProducer concrete type = %T, want *kafka.ProducerImpl", kafka.GetProducer()) ++ } ++ return impl ++} ++ ++func newProducerBroker(t *testing.T, topic string) *sarama.MockBroker { ++ t.Helper() ++ broker := sarama.NewMockBroker(t, 1) ++ broker.SetHandlerByMap(map[string]sarama.MockResponse{ ++ "ApiVersionsRequest": sarama.NewMockApiVersionsResponse(t), ++ "MetadataRequest": sarama.NewMockMetadataResponse(t). ++ SetBroker(broker.Addr(), broker.BrokerID()). ++ SetLeader(topic, 0, broker.BrokerID()), ++ "ProduceRequest": sarama.NewMockProduceResponse(t). ++ SetVersion(7). ++ SetError(topic, 0, sarama.ErrNoError), ++ }) ++ return broker ++} ++ ++func onlyProducedRecord(t *testing.T, broker *sarama.MockBroker, topic string) producedRecord { ++ t.Helper() ++ records := producedRecords(t, broker) ++ var matches []producedRecord ++ for _, record := range records { ++ if record.topic == topic { ++ matches = append(matches, record) ++ } ++ } ++ if len(matches) != 1 { ++ t.Fatalf("produced records for %q = %d (%#v), want 1", topic, len(matches), matches) ++ } ++ return matches[0] ++} ++ ++func countProduceRequests(broker *sarama.MockBroker) int { ++ count := 0 ++ for _, exchange := range broker.History() { ++ if _, ok := exchange.Request.(*sarama.ProduceRequest); ok { ++ count++ ++ } ++ } ++ return count ++} ++ ++func producedRecords(t *testing.T, broker *sarama.MockBroker) []producedRecord { ++ t.Helper() ++ var out []producedRecord ++ for _, exchange := range broker.History() { ++ req, ok := exchange.Request.(*sarama.ProduceRequest) ++ if !ok { ++ continue ++ } ++ for topic, partitions := range produceRequestRecords(req) { ++ for partition, records := range partitions { ++ if records.RecordBatch != nil { ++ for _, record := range records.RecordBatch.Records { ++ out = append(out, producedRecord{ ++ topic: topic, ++ partition: partition, ++ key: string(record.Key), ++ value: string(record.Value), ++ headers: recordHeaders(record.Headers), ++ }) ++ } ++ continue ++ } ++ if records.MsgSet != nil { ++ for _, block := range records.MsgSet.Messages { ++ for _, msgBlock := range block.Messages() { ++ out = append(out, producedRecord{ ++ topic: topic, ++ partition: partition, ++ key: string(msgBlock.Msg.Key), ++ value: string(msgBlock.Msg.Value), ++ headers: map[string]string{}, ++ }) ++ } ++ } ++ } ++ } ++ } ++ } ++ sort.Slice(out, func(i, j int) bool { ++ if out[i].topic != out[j].topic { ++ return out[i].topic < out[j].topic ++ } ++ if out[i].partition != out[j].partition { ++ return out[i].partition < out[j].partition ++ } ++ return out[i].key < out[j].key ++ }) ++ return out ++} ++ ++func produceRequestRecords(req *sarama.ProduceRequest) map[string]map[int32]sarama.Records { ++ value := reflect.ValueOf(req).Elem().FieldByName("records") ++ return reflect.NewAt(value.Type(), unsafe.Pointer(value.UnsafeAddr())). ++ Elem(). ++ Interface().(map[string]map[int32]sarama.Records) ++} ++ ++func recordHeaders(headers []*sarama.RecordHeader) map[string]string { ++ out := make(map[string]string, len(headers)) ++ for _, header := range headers { ++ out[string(header.Key)] = string(header.Value) ++ } ++ return out ++} ++ ++func countFDs(t *testing.T) int { ++ t.Helper() ++ entries, err := os.ReadDir("/proc/self/fd") ++ if err != nil { ++ t.Fatalf("read /proc/self/fd: %v", err) ++ } ++ return len(entries) ++} ++ ++func mustNoError(t *testing.T, err error) { ++ t.Helper() ++ if err != nil { ++ t.Fatalf("unexpected error: %v", err) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-000014/tests/test.sh b/tasks/format-code-task-000014/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ff420ff0bf655a63a41fdc1e968c58d339b5e9b --- /dev/null +++ b/tasks/format-code-task-000014/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/kafka_producer_stateful_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000014/tests/test_command.sh b/tasks/format-code-task-000014/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000014/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000023/environment/Dockerfile b/tasks/format-code-task-000023/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f047ea79c35bf20ace275fe4897a98e8d96efe43 --- /dev/null +++ b/tasks/format-code-task-000023/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:df1ec1afb6406e966b4e45334caf0d1ca873927e0fdb1203f91e0097ace9da10 diff --git a/tasks/format-code-task-000023/environment/setup/files/blocklist b/tasks/format-code-task-000023/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000023/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000023/environment/setup/setup.sh b/tasks/format-code-task-000023/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000023/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000023/tests/test.patch b/tasks/format-code-task-000023/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5ab3c2a707fc07a6a217d0459bc79af42fa64da3 --- /dev/null +++ b/tasks/format-code-task-000023/tests/test.patch @@ -0,0 +1,174 @@ +diff --git a/tests/functional/project/test_project_manager_cache_contract.py b/tests/functional/project/test_project_manager_cache_contract.py +new file mode 100644 +index 000000000..e9a040eb0 +--- /dev/null ++++ b/tests/functional/project/test_project_manager_cache_contract.py +@@ -0,0 +1,157 @@ ++from types import SimpleNamespace ++ ++from ape.managers.project import ProjectManager ++from ape.types import ContractType ++ ++ ++class RecordingCompiler: ++ def __init__(self): ++ self.calls = [] ++ ++ def compile(self, paths): ++ paths = list(paths) ++ self.calls.append(tuple(str(path) for path in paths)) ++ return [ ++ ContractType( ++ contractName=f"{path.stem}:{path.read_text()}", ++ sourceId=str(path), ++ abi=[], ++ ) ++ for path in paths ++ ] ++ ++ ++class CompilerManagerStub: ++ def __init__(self, compiler): ++ self.compiler = compiler ++ self.registered_compilers = {".foo": compiler} ++ ++ def compile(self, paths): ++ return { ++ contract.contractName: contract ++ for contract in self.compiler.compile(paths) ++ } ++ ++ ++def make_project(tmp_path, compiler=None): ++ compiler = compiler or RecordingCompiler() ++ config = SimpleNamespace(PROJECT_FOLDER=tmp_path, name="", dependencies=[]) ++ return ProjectManager(tmp_path, config, CompilerManagerStub(compiler)), compiler ++ ++ ++def test_missing_contract_directory_has_no_unknown_extensions(tmp_path): ++ project, _ = make_project(tmp_path) ++ ++ assert project.sources_missing is True ++ assert project.extensions_with_missing_compilers == [] ++ ++ ++def test_empty_contract_directory_is_reported_as_missing(tmp_path): ++ project, _ = make_project(tmp_path) ++ (tmp_path / "contracts").mkdir() ++ assert project.sources_missing is True ++ assert project.extensions_with_missing_compilers == [] ++ ++ ++def make_nested_sources(tmp_path): ++ project, _ = make_project(tmp_path) ++ contracts = tmp_path / "contracts" ++ (contracts / "nested").mkdir(parents=True) ++ for relative in ( ++ "z.foo", ++ "a.bar", ++ "q.zeta", ++ "nested/m.foo", ++ "nested/b.bar", ++ "nested/a.alpha", ++ ): ++ (contracts / relative).write_text(relative) ++ return project, contracts ++ ++ ++def test_sources_are_recursive_and_sorted(tmp_path): ++ project, contracts = make_nested_sources(tmp_path) ++ assert [path.relative_to(contracts).as_posix() for path in project.sources] == [ ++ "nested/m.foo", ++ "z.foo", ++ ] ++ ++ ++def test_unknown_extensions_are_recursive_and_sorted(tmp_path): ++ project, _ = make_nested_sources(tmp_path) ++ assert project.extensions_with_missing_compilers == [".alpha", ".bar", ".zeta"] ++ ++ ++def test_corrupt_manifest_cache_is_ignored_and_rebuilt(tmp_path): ++ project, compiler = make_project(tmp_path) ++ contracts = tmp_path / "contracts" ++ contracts.mkdir() ++ source = contracts / "one.foo" ++ source.write_text("v1") ++ cache = tmp_path / ".build" / "__local__.json" ++ cache.parent.mkdir() ++ cache.write_text("not-json") ++ ++ loaded = project.load_contracts() ++ ++ assert set(loaded) == {"one:v1"} ++ assert compiler.calls == [(str(source),)] ++ ++ ++def setup_cached_sources(tmp_path): ++ project, compiler = make_project(tmp_path) ++ contracts = tmp_path / "contracts" ++ contracts.mkdir() ++ first = contracts / "first.foo" ++ second = contracts / "second.foo" ++ first.write_text("v1") ++ second.write_text("v1") ++ ++ initial = project.load_contracts() ++ assert set(initial) == {"first:v1", "second:v1"} ++ assert compiler.calls[-1] == (str(first), str(second)) ++ return project, compiler, contracts, first, second ++ ++ ++def test_incremental_cache_compiles_only_changed_and_new_sources(tmp_path): ++ project, compiler, contracts, first, second = setup_cached_sources(tmp_path) ++ first.write_text("v2") ++ third = contracts / "third.foo" ++ third.write_text("v1") ++ updated = project.load_contracts() ++ assert compiler.calls[-1] == (str(first), str(third)) ++ assert "second:v1" in updated ++ assert "third:v1" in updated ++ ++ ++def test_changed_source_replaces_its_stale_contract_types(tmp_path): ++ project, _, _, first, _ = setup_cached_sources(tmp_path) ++ first.write_text("v2") ++ updated = project.load_contracts() ++ assert "first:v1" not in updated ++ assert updated["first:v2"].sourceId == str(first) ++ ++ ++def test_deleted_source_drops_its_cached_contract_types(tmp_path): ++ project, _, _, _, second = setup_cached_sources(tmp_path) ++ second.unlink() ++ project.load_contracts() ++ ++ reloaded_project, _ = make_project(tmp_path) ++ after_delete = reloaded_project.load_contracts() ++ assert set(after_delete) == {"first:v1"} ++ ++ ++def test_force_rebuild_recompiles_all_current_sources(tmp_path): ++ project, compiler = make_project(tmp_path) ++ contracts = tmp_path / "contracts" ++ contracts.mkdir() ++ first = contracts / "first.foo" ++ second = contracts / "second.foo" ++ first.write_text("v1") ++ second.write_text("v1") ++ ++ project.load_contracts() ++ project.load_contracts(use_cache=False) ++ ++ assert compiler.calls[-1] == (str(first), str(second)) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++pytest -q tests/functional/project/test_project_manager_cache_contract.py ++ diff --git a/tasks/format-code-task-000023/tests/test.sh b/tasks/format-code-task-000023/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f25bc11009a0ef4be6e1f467cb18e952a53058c9 --- /dev/null +++ b/tasks/format-code-task-000023/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/functional/project/test_project_manager_cache_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000023/tests/test_command.sh b/tasks/format-code-task-000023/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000023/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000047/environment/Dockerfile b/tasks/format-code-task-000047/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..710760ad3b1dd6ece31b96621e4af48809af7adc --- /dev/null +++ b/tasks/format-code-task-000047/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1b67b35306e761ceb70521c02b9cb92a908cccf12262767ed336012e4e76ff93 diff --git a/tasks/format-code-task-000047/environment/setup/files/blocklist b/tasks/format-code-task-000047/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000047/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000047/environment/setup/setup.sh b/tasks/format-code-task-000047/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000047/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000047/tests/test.patch b/tasks/format-code-task-000047/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6b66d2206ccb647b04f43b9e6b4a8f9defa93ba0 --- /dev/null +++ b/tasks/format-code-task-000047/tests/test.patch @@ -0,0 +1,195 @@ +diff --git a/test/imagebuilder.test.ts b/test/imagebuilder.test.ts +index 3c5285b..f56c5a7 100644 +--- a/test/imagebuilder.test.ts ++++ b/test/imagebuilder.test.ts +@@ -1,5 +1,6 @@ + import * as cdk from 'aws-cdk-lib'; + import { aws_ec2 as ec2 } from 'aws-cdk-lib'; ++import { Template } from 'aws-cdk-lib/assertions'; + import { Architecture, ContainerImageBuilder, Os } from '../src'; + import { AmiBuilder } from '../src/providers/image-builders/ami'; + +@@ -83,3 +84,161 @@ test('Container image builder supported OS', () => { + }); + }).toThrowError('Unsupported architecture: ARM64. Consider CodeBuild for faster image builds.'); + }); ++ ++function countDockerComponents(stack: cdk.Stack): number { ++ const template = Template.fromStack(stack); ++ const components = template.findResources('AWS::ImageBuilder::Component'); ++ let count = 0; ++ for (const key of Object.keys(components)) { ++ const props = components[key].Properties; ++ if (props && props.Description === 'Install latest version of Docker') { ++ count += 1; ++ } ++ } ++ return count; ++} ++ ++ ++ ++ ++ ++function dockerProps(value: boolean): any { ++ return { installDocker: value, docker: value }; ++} ++ ++test('AMI builder installs Docker by default on Linux', () => { ++ const app = new cdk.App(); ++ const stack = new cdk.Stack(app, 'test'); ++ const vpc = new ec2.Vpc(stack, 'vpc'); ++ ++ new AmiBuilder(stack, 'linux x64', { ++ os: Os.LINUX, ++ architecture: Architecture.X86_64, ++ vpc, ++ }); ++ ++ expect(countDockerComponents(stack)).toBe(1); ++}); ++ ++test('AMI builder installs Docker by default on Windows', () => { ++ const app = new cdk.App(); ++ const stack = new cdk.Stack(app, 'test'); ++ const vpc = new ec2.Vpc(stack, 'vpc'); ++ ++ new AmiBuilder(stack, 'win x64', { ++ os: Os.WINDOWS, ++ architecture: Architecture.X86_64, ++ vpc, ++ }); ++ ++ expect(countDockerComponents(stack)).toBe(1); ++}); ++ ++test('AMI builder skips Docker on Windows when installDocker is false', () => { ++ const app = new cdk.App(); ++ const stack = new cdk.Stack(app, 'test'); ++ const vpc = new ec2.Vpc(stack, 'vpc'); ++ ++ new AmiBuilder(stack, 'win x64', { ++ os: Os.WINDOWS, ++ architecture: Architecture.X86_64, ++ vpc, ++ ...dockerProps(false), ++ }); ++ ++ expect(countDockerComponents(stack)).toBe(0); ++}); ++ ++test('AMI builder skips Docker on Linux when installDocker is false', () => { ++ const app = new cdk.App(); ++ const stack = new cdk.Stack(app, 'test'); ++ const vpc = new ec2.Vpc(stack, 'vpc'); ++ ++ new AmiBuilder(stack, 'linux x64', { ++ os: Os.LINUX, ++ architecture: Architecture.X86_64, ++ vpc, ++ ...dockerProps(false), ++ }); ++ ++ expect(countDockerComponents(stack)).toBe(0); ++}); ++ ++test('AMI builder installs Docker on Windows when installDocker is explicitly true', () => { ++ const app = new cdk.App(); ++ const stack = new cdk.Stack(app, 'test'); ++ const vpc = new ec2.Vpc(stack, 'vpc'); ++ ++ new AmiBuilder(stack, 'win x64', { ++ os: Os.WINDOWS, ++ architecture: Architecture.X86_64, ++ vpc, ++ ...dockerProps(true), ++ }); ++ ++ expect(countDockerComponents(stack)).toBe(1); ++}); ++ ++test('AMI builder installs Docker on Linux when installDocker is explicitly true', () => { ++ const app = new cdk.App(); ++ const stack = new cdk.Stack(app, 'test'); ++ const vpc = new ec2.Vpc(stack, 'vpc'); ++ ++ new AmiBuilder(stack, 'linux x64', { ++ os: Os.LINUX, ++ architecture: Architecture.X86_64, ++ vpc, ++ ...dockerProps(true), ++ }); ++ ++ expect(countDockerComponents(stack)).toBe(1); ++}); ++ ++test('AMI builder retains non-Docker components when installDocker is false on Windows', () => { ++ const app = new cdk.App(); ++ const stack = new cdk.Stack(app, 'test'); ++ const vpc = new ec2.Vpc(stack, 'vpc'); ++ ++ new AmiBuilder(stack, 'win x64', { ++ os: Os.WINDOWS, ++ architecture: Architecture.X86_64, ++ vpc, ++ ...dockerProps(false), ++ }); ++ ++ const template = Template.fromStack(stack); ++ const components = template.findResources('AWS::ImageBuilder::Component'); ++ const descriptions = Object.keys(components).map(k => components[k].Properties?.Description); ++ ++ expect(descriptions).toEqual(expect.arrayContaining([ ++ expect.stringMatching(/CloudWatch/), ++ 'Install latest version of AWS CLI', ++ 'Install latest version of gh', ++ 'Install latest version of git', ++ 'Install latest version of GitHub Actions Runner', ++ ])); ++ expect(descriptions).not.toContain('Install latest version of Docker'); ++}); ++ ++test('AMI builder retains non-Docker components when installDocker is false on Linux', () => { ++ const app = new cdk.App(); ++ const stack = new cdk.Stack(app, 'test'); ++ const vpc = new ec2.Vpc(stack, 'vpc'); ++ ++ new AmiBuilder(stack, 'linux x64', { ++ os: Os.LINUX, ++ architecture: Architecture.X86_64, ++ vpc, ++ ...dockerProps(false), ++ }); ++ ++ const template = Template.fromStack(stack); ++ const components = template.findResources('AWS::ImageBuilder::Component'); ++ const descriptions = Object.keys(components).map(k => components[k].Properties?.Description); ++ expect(descriptions).toEqual(expect.arrayContaining([ ++ 'Install latest version of gh', ++ 'Install latest version of git', ++ 'Install latest version of GitHub Actions Runner', ++ ])); ++ expect(descriptions).not.toContain('Install latest version of Docker'); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..b489dc5 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest test/imagebuilder.test.ts --no-coverage"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest test/imagebuilder.test.ts --no-coverage ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000047/tests/test.sh b/tasks/format-code-task-000047/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7327481f1dc3c50d442a94f2fbea655b68471043 --- /dev/null +++ b/tasks/format-code-task-000047/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/imagebuilder.test.ts +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000047/tests/test_command.sh b/tasks/format-code-task-000047/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000047/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000049/environment/Dockerfile b/tasks/format-code-task-000049/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bd0076976f843349c8015ca83910bc3b1da7a10d --- /dev/null +++ b/tasks/format-code-task-000049/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:61f60677512e77b14dbd2882794c2534c481ea5ed7a45fc7921aee940804de83 diff --git a/tasks/format-code-task-000049/environment/setup/files/blocklist b/tasks/format-code-task-000049/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000049/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000049/environment/setup/setup.sh b/tasks/format-code-task-000049/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000049/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000049/tests/test.patch b/tasks/format-code-task-000049/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..39d1c2b736852d2c35cd38a9a8555a19f6863edc --- /dev/null +++ b/tasks/format-code-task-000049/tests/test.patch @@ -0,0 +1,387 @@ +diff --git a/flocker/control/test/test_httpapi.py b/flocker/control/test/test_httpapi.py +index 806837648..9d7258ac9 100644 +--- a/flocker/control/test/test_httpapi.py ++++ b/flocker/control/test/test_httpapi.py +@@ -173,6 +173,304 @@ RealTestsAPI, MemoryTestsAPI = buildIntegrationTests( + VersionTestsMixin, "API", _build_app) + + ++class CreateContainerTestsMixin(APITestsMixin): ++ """ ++ Black-box tests for creating container configuration through the HTTP API. ++ """ ++ def _request_json(self, method, path, body, expected_code): ++ """ ++ Issue a JSON request through the existing HTTP API test harness and ++ return a ``Deferred`` firing with the decoded response body. ++ ++ This helper intentionally does not inspect route handlers, decorators, ++ schemas, or private helpers. ++ """ ++ requesting = self.assertResponseCode( ++ method, path, body, expected_code) ++ requesting.addCallback(readBody) ++ requesting.addCallback(loads) ++ return requesting ++ ++ def _applications_for_host(self, host): ++ """ ++ Return the configured applications for ``host`` from the persisted ++ configuration. ++ """ ++ deployment = self.persistence_service.get() ++ matching = [ ++ node for node in deployment.nodes ++ if node.hostname == host ++ ] ++ if not matching: ++ return [] ++ return list(matching[0].applications) ++ ++ def _configured_applications_named(self, name): ++ """ ++ Return all configured applications with the supplied public container ++ name, across all hosts. ++ """ ++ deployment = self.persistence_service.get() ++ return [ ++ application ++ for node in deployment.nodes ++ for application in node.applications ++ if application.name == name ++ ] ++ ++ def _assert_application_present(self, host, name, image): ++ """ ++ Assert that the persisted configuration contains a container with the ++ supplied public values on ``host``. ++ """ ++ expected_image = DockerImage.from_string(image) ++ matches = [ ++ application for application in self._applications_for_host(host) ++ if application.name == name and application.image == expected_image ++ ] ++ self.assertEqual( ++ len(matches), 1, ++ "Expected exactly one configured container named {!r} with image " ++ "{!r} on host {!r}; found {!r}".format( ++ name, image, host, self._applications_for_host(host))) ++ ++ def _assert_duplicate_name_conflict(self, response_json): ++ """ ++ Assert only the public error shape and duplicate-name semantics. ++ The exact prose is intentionally not locked down because the reference ++ patch's docs and implementation disagree on the full sentence. ++ """ ++ ++ ++ self.assertIn(u"description", response_json) ++ self.assertNotIn(u"message", response_json) ++ self.assertTrue(isinstance(response_json[u"description"], unicode)) ++ self.assertTrue(response_json[u"description"]) ++ ++ def test_create_container_response_echoes_request(self): ++ """ ++ Creating a container returns 201 Created and echoes the public ++ host/name/image values from the request body. ++ """ ++ container_json = { ++ u"host": self.NODE_B, ++ u"name": u"postgres", ++ u"image": u"postgres", ++ } ++ return self.assertResult( ++ b"POST", b"/configuration/containers", ++ container_json, CREATED, container_json) ++ ++ def test_create_container_persists_on_requested_existing_host(self): ++ """ ++ Creating a container on an existing host persists it on that host and ++ preserves unrelated existing configuration. ++ """ ++ saving = self.persistence_service.save(Deployment( ++ nodes={ ++ Node( ++ hostname=self.NODE_A, ++ applications=[ ++ Application( ++ name=u"postgres", ++ image=DockerImage.from_string(u"postgres")), ++ ]), ++ Node(hostname=self.NODE_B), ++ })) ++ ++ def saved(_): ++ return self.assertResponseCode( ++ b"POST", b"/configuration/containers", ++ { ++ u"host": self.NODE_A, ++ u"name": u"another_postgres", ++ u"image": u"postgres:latest", ++ }, ++ CREATED) ++ saving.addCallback(saved) ++ ++ def created(_): ++ self._assert_application_present( ++ self.NODE_A, u"postgres", u"postgres") ++ self._assert_application_present( ++ self.NODE_A, u"another_postgres", u"postgres:latest") ++ self.assertEqual( ++ [], ++ [ ++ application for application ++ in self._applications_for_host(self.NODE_B) ++ if application.name == u"another_postgres" ++ ]) ++ saving.addCallback(created) ++ return saving ++ ++ def test_create_container_persists_on_new_host(self): ++ """ ++ Creating a container for a host absent from the current configuration ++ persists a host entry containing that container. ++ """ ++ d = self.assertResponseCode( ++ b"POST", b"/configuration/containers", ++ { ++ u"host": self.NODE_B, ++ u"name": u"redis_cache", ++ u"image": u"redis:latest", ++ }, ++ CREATED) ++ ++ def created(_): ++ self._assert_application_present( ++ self.NODE_B, u"redis_cache", u"redis:latest") ++ d.addCallback(created) ++ return d ++ ++ def test_create_container_persists_arbitrary_public_values(self): ++ """ ++ Container creation is not limited to the fixture hosts, names, and ++ images used by other tests. ++ """ ++ host = u"198.51.100.7" ++ name = u"api_worker" ++ image = u"clusterhq/api-worker:1.2.3" ++ container_json = { ++ u"host": host, ++ u"name": name, ++ u"image": image, ++ } ++ d = self.assertResult( ++ b"POST", b"/configuration/containers", ++ container_json, CREATED, container_json) ++ ++ def created(_): ++ self._assert_application_present(host, name, image) ++ d.addCallback(created) ++ return d ++ ++ def test_duplicate_container_name_rejected_on_same_host(self): ++ """ ++ A second container with an existing name is rejected on the same host, ++ even if another public field differs. ++ """ ++ first = { ++ u"host": self.NODE_A, ++ u"name": u"postgres", ++ u"image": u"postgres", ++ } ++ second = { ++ u"host": self.NODE_A, ++ u"name": u"postgres", ++ u"image": u"postgres:alternate", ++ } ++ d = self.assertResponseCode( ++ b"POST", b"/configuration/containers", first, CREATED) ++ ++ def created(_): ++ return self._request_json( ++ b"POST", b"/configuration/containers", second, CONFLICT) ++ d.addCallback(created) ++ ++ def conflicted(response_json): ++ self._assert_duplicate_name_conflict(response_json) ++ self.assertEqual( ++ 1, len(self._configured_applications_named(u"postgres"))) ++ d.addCallback(conflicted) ++ return d ++ ++ def test_duplicate_container_name_rejected_on_different_host(self): ++ """ ++ Container names are unique across configured hosts, not merely within ++ the target host. ++ """ ++ first = { ++ u"host": self.NODE_A, ++ u"name": u"web", ++ u"image": u"nginx", ++ } ++ second = { ++ u"host": self.NODE_B, ++ u"name": u"web", ++ u"image": u"redis", ++ } ++ d = self.assertResponseCode( ++ b"POST", b"/configuration/containers", first, CREATED) ++ ++ def created(_): ++ return self._request_json( ++ b"POST", b"/configuration/containers", second, CONFLICT) ++ d.addCallback(created) ++ ++ def conflicted(response_json): ++ self._assert_duplicate_name_conflict(response_json) ++ self.assertEqual( ++ 1, len(self._configured_applications_named(u"web"))) ++ d.addCallback(conflicted) ++ return d ++ ++ def test_duplicate_container_name_rejected_when_existing_on_other_host_first(self): ++ """ ++ Duplicate-name detection is global even when the existing container is ++ on a different host than the original fixture order. ++ """ ++ first = { ++ u"host": self.NODE_B, ++ u"name": u"api_worker", ++ u"image": u"clusterhq/api-worker:1.0", ++ } ++ second = { ++ u"host": self.NODE_A, ++ u"name": u"api_worker", ++ u"image": u"clusterhq/api-worker:2.0", ++ } ++ d = self.assertResponseCode( ++ b"POST", b"/configuration/containers", first, CREATED) ++ ++ def created(_): ++ return self._request_json( ++ b"POST", b"/configuration/containers", second, CONFLICT) ++ d.addCallback(created) ++ ++ def conflicted(response_json): ++ self._assert_duplicate_name_conflict(response_json) ++ self.assertEqual( ++ 1, len(self._configured_applications_named(u"api_worker"))) ++ d.addCallback(conflicted) ++ return d ++ ++ def test_duplicate_container_name_rejected_with_same_image(self): ++ """ ++ Duplicate-name detection is by name, not by the full container body. ++ """ ++ first = { ++ u"host": self.NODE_A, ++ u"name": u"same_image_worker", ++ u"image": u"redis:latest", ++ } ++ second = { ++ u"host": self.NODE_B, ++ u"name": u"same_image_worker", ++ u"image": u"redis:latest", ++ } ++ d = self.assertResponseCode( ++ b"POST", b"/configuration/containers", first, CREATED) ++ ++ def created(_): ++ return self._request_json( ++ b"POST", b"/configuration/containers", second, CONFLICT) ++ d.addCallback(created) ++ ++ def conflicted(response_json): ++ self._assert_duplicate_name_conflict(response_json) ++ self.assertEqual( ++ 1, ++ len(self._configured_applications_named(u"same_image_worker"))) ++ d.addCallback(conflicted) ++ return d ++ ++ ++RealTestsCreateContainer, MemoryTestsCreateContainer = buildIntegrationTests( ++ CreateContainerTestsMixin, "CreateContainer", _build_app) ++ ++ + class CreateDatasetTestsMixin(APITestsMixin): + """ + Tests for the dataset creation endpoint at ``/configuration/datasets``. +@@ -276,6 +574,42 @@ class CreateDatasetTestsMixin(APITestsMixin): + """ + return self._dataset_id_collision_test(self.NODE_A, unicode.title) + ++ def test_duplicate_dataset_id_conflict_uses_description_not_message(self): ++ """ ++ Duplicate dataset_id conflicts keep returning 409 but use the standard ++ ``description`` error field instead of the older ``message`` field. ++ """ ++ dataset_id = unicode(uuid4()) ++ first_dataset = { ++ u"primary": self.NODE_A, ++ u"dataset_id": dataset_id, ++ } ++ second_dataset = { ++ u"primary": self.NODE_B, ++ u"dataset_id": dataset_id, ++ } ++ d = self.assertResponseCode( ++ b"POST", b"/configuration/datasets", first_dataset, CREATED) ++ ++ def created(_): ++ requesting = self.assertResponseCode( ++ b"POST", b"/configuration/datasets", ++ second_dataset, CONFLICT) ++ requesting.addCallback(readBody) ++ requesting.addCallback(loads) ++ return requesting ++ d.addCallback(created) ++ ++ def conflicted(response_json): ++ ++ ++ self.assertIn(u"description", response_json) ++ self.assertNotIn(u"message", response_json) ++ self.assertTrue(isinstance(response_json[u"description"], unicode)) ++ self.assertTrue(response_json[u"description"]) ++ d.addCallback(conflicted) ++ return d ++ + def test_unknown_primary_node(self): + """ + If a ``POST`` request made to the endpoint indicates a non-existent +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++set +u ++source .build_env/.venv/bin/activate ++set -u ++ ++ ++case "${1:-}" in ++ base) ++ python -m pytest \ ++ flocker/control/test/test_schemas.py \ ++ flocker/control/test/test_httpapi.py \ ++ -v \ ++ -k "not CreateContainer and not test_duplicate_dataset_id_conflict_uses_description_not_message" ++ ;; ++ new) ++ python -m pytest \ ++ flocker/control/test/test_httpapi.py \ ++ -v \ ++ -k "CreateContainer or test_duplicate_dataset_id_conflict_uses_description_not_message" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000049/tests/test.sh b/tasks/format-code-task-000049/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..71304fcbbfde47507b1434b3afc601de5b4a60e4 --- /dev/null +++ b/tasks/format-code-task-000049/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +flocker/control/test/test_httpapi.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000049/tests/test_command.sh b/tasks/format-code-task-000049/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000049/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000071/environment/Dockerfile b/tasks/format-code-task-000071/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bde91960280ab7574282a93c0a50ea09d25ebb75 --- /dev/null +++ b/tasks/format-code-task-000071/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d97d9bf30c418a4d3a4732a5cdcbbcf3af21b918750549629861ab7ec24bac84 diff --git a/tasks/format-code-task-000071/environment/setup/files/blocklist b/tasks/format-code-task-000071/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000071/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000071/environment/setup/setup.sh b/tasks/format-code-task-000071/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000071/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000071/tests/test.patch b/tasks/format-code-task-000071/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..15549950cf0ad9a84abc10b057674ab3167c76e5 --- /dev/null +++ b/tasks/format-code-task-000071/tests/test.patch @@ -0,0 +1,1445 @@ +diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardGeomap.freeze b/datadog/tests/cassettes/TestAccDatadogDashboardGeomap.freeze +index 00a9dd2bf9..8ca2823e96 100644 +--- a/datadog/tests/cassettes/TestAccDatadogDashboardGeomap.freeze ++++ b/datadog/tests/cassettes/TestAccDatadogDashboardGeomap.freeze +@@ -1 +1 @@ +-2021-03-01T13:47:20.127781-05:00 +\ No newline at end of file ++2021-04-27T08:58:27.619962+02:00 +\ No newline at end of file +diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardGeomap.yaml b/datadog/tests/cassettes/TestAccDatadogDashboardGeomap.yaml +index 252b678285..102e0b2830 100644 +--- a/datadog/tests/cassettes/TestAccDatadogDashboardGeomap.yaml ++++ b/datadog/tests/cassettes/TestAccDatadogDashboardGeomap.yaml +@@ -3,7 +3,7 @@ version: 1 + interactions: + - request: + body: | +- {"description":"Created using the Datadog provider in Terraform","id":"","is_read_only":true,"layout_type":"ordered","notify_list":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardGeomap-local-1614624440","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"style":{"palette":"hostmap_blues","palette_flip":false},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"custom_links":[{"label":"Test Custom Link label","link":"https://app.datadoghq.com/dashboard/lists"}],"requests":[{"log_query":{"compute":{"aggregation":"count"},"index":"*","search":{"query":""}}}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"1h"},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"requests":[{"rum_query":{"compute":{"aggregation":"count"},"index":"*","search":{"query":""}}}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"},"type":"geomap","view":{"focus":"WORLD"}}}]} ++ {"description":"Created using the Datadog provider in Terraform","id":"","is_read_only":true,"layout_type":"ordered","notify_list":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardGeomap-local-1619506707","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"style":{"palette":"hostmap_blues","palette_flip":false},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"custom_links":[{"label":"Test Custom Link label","link":"https://app.datadoghq.com/dashboard/lists"}],"requests":[{"log_query":{"compute":{"aggregation":"count"},"index":"*","search":{"query":""}}}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"1h"},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"requests":[{"rum_query":{"compute":{"aggregation":"count"},"index":"*","search":{"query":""}}}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"},"type":"geomap","view":{"focus":"WORLD"}}}]} + form: {} + headers: + Accept: +@@ -13,11 +13,11 @@ interactions: + Dd-Operation-Id: + - CreateDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/dashboard + method: POST + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"c6k-dfq-zy2","title":"tf-TestAccDatadogDashboardGeomap-local-1614624440","url":"/dashboard/c6k-dfq-zy2/tf-testaccdatadogdashboardgeomap-local-1614624440","created_at":"2021-03-01T18:47:21.983758+00:00","modified_at":"2021-03-01T18:47:21.983758+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1395441594444468},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":1839284831799485},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6954656752143036}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3s6-igk-ih5","title":"tf-TestAccDatadogDashboardGeomap-local-1619506707","url":"/dashboard/3s6-igk-ih5/tf-testaccdatadogdashboardgeomap-local-1619506707","created_at":"2021-04-27T06:58:29.156444+00:00","modified_at":"2021-04-27T06:58:29.156444+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":2235960280314117},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":481676151794705},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":2786918167906999}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -28,7 +28,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:24 GMT ++ - Tue, 27 Apr 2021 06:58:32 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -38,9 +38,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - HbtaOKlJ6OCrx9tMXO6ivMTrEM+g0c93HDp08trmOmgdHozC5J+vn10F0H4WPjCU ++ - gYZcaADwbKcv7Hm19HJx6WsLoKuOijDWAt2viPeCfWqUgyKY+9e1xZdmMJeXV3YV + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -55,11 +55,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/c6k-dfq-zy2 ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3s6-igk-ih5 + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"c6k-dfq-zy2","title":"tf-TestAccDatadogDashboardGeomap-local-1614624440","url":"/dashboard/c6k-dfq-zy2/tf-testaccdatadogdashboardgeomap-local-1614624440","created_at":"2021-03-01T18:47:21.983758+00:00","modified_at":"2021-03-01T18:47:21.983758+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1395441594444468},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":1839284831799485},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6954656752143036}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3s6-igk-ih5","title":"tf-TestAccDatadogDashboardGeomap-local-1619506707","url":"/dashboard/3s6-igk-ih5/tf-testaccdatadogdashboardgeomap-local-1619506707","created_at":"2021-04-27T06:58:29.156444+00:00","modified_at":"2021-04-27T06:58:29.156444+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":2235960280314117},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":481676151794705},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":2786918167906999}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -70,7 +70,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:24 GMT ++ - Tue, 27 Apr 2021 06:58:32 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -80,9 +80,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - HbtaOKlJ6OCrx9tMXO6ivMTrEM+g0c93HDp08trmOmgdHozC5J+vn10F0H4WPjCU ++ - twvpGlmuom5y6A0pjGtXzTf554cmwJgTcCZ71fK4H/RDi+v5ehBK0zQiRcTJQG5C + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -97,11 +97,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/c6k-dfq-zy2 ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3s6-igk-ih5 + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"c6k-dfq-zy2","title":"tf-TestAccDatadogDashboardGeomap-local-1614624440","url":"/dashboard/c6k-dfq-zy2/tf-testaccdatadogdashboardgeomap-local-1614624440","created_at":"2021-03-01T18:47:21.983758+00:00","modified_at":"2021-03-01T18:47:21.983758+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1395441594444468},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":1839284831799485},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6954656752143036}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3s6-igk-ih5","title":"tf-TestAccDatadogDashboardGeomap-local-1619506707","url":"/dashboard/3s6-igk-ih5/tf-testaccdatadogdashboardgeomap-local-1619506707","created_at":"2021-04-27T06:58:29.156444+00:00","modified_at":"2021-04-27T06:58:29.156444+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":2235960280314117},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":481676151794705},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":2786918167906999}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -112,7 +112,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:25 GMT ++ - Tue, 27 Apr 2021 06:58:32 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -122,9 +122,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - dPySkcOzIZtKyMKDAAzuysY3gNGGj6RtYogGuSb76E8mPvoqzREyRp6lPYm91hQU ++ - F5gm0Rce1/Abr9/0Fw8HAqWfiz0FdiH8er/AXnN6lOn3L6KyGgbsLCwgPlob1No8 + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -139,11 +139,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/c6k-dfq-zy2 ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3s6-igk-ih5 + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"c6k-dfq-zy2","title":"tf-TestAccDatadogDashboardGeomap-local-1614624440","url":"/dashboard/c6k-dfq-zy2/tf-testaccdatadogdashboardgeomap-local-1614624440","created_at":"2021-03-01T18:47:21.983758+00:00","modified_at":"2021-03-01T18:47:21.983758+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1395441594444468},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":1839284831799485},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6954656752143036}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3s6-igk-ih5","title":"tf-TestAccDatadogDashboardGeomap-local-1619506707","url":"/dashboard/3s6-igk-ih5/tf-testaccdatadogdashboardgeomap-local-1619506707","created_at":"2021-04-27T06:58:29.156444+00:00","modified_at":"2021-04-27T06:58:29.156444+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":2235960280314117},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":481676151794705},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":2786918167906999}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -154,7 +154,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:25 GMT ++ - Tue, 27 Apr 2021 06:58:33 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -164,9 +164,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - mNzaoDhdDKO7t4QSrAe5X7pHd0bJND187D+vRbwoluXouE2m1UaQQX0RGCvRpLVE ++ - tpRCH6w417YjBovRJ8VmtuXmNONVYiRp2c8d2AxjPdGBn8PCtgG4vAztrx3qUZAN + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -181,11 +181,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/c6k-dfq-zy2 ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3s6-igk-ih5 + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"c6k-dfq-zy2","title":"tf-TestAccDatadogDashboardGeomap-local-1614624440","url":"/dashboard/c6k-dfq-zy2/tf-testaccdatadogdashboardgeomap-local-1614624440","created_at":"2021-03-01T18:47:21.983758+00:00","modified_at":"2021-03-01T18:47:21.983758+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1395441594444468},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":1839284831799485},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6954656752143036}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3s6-igk-ih5","title":"tf-TestAccDatadogDashboardGeomap-local-1619506707","url":"/dashboard/3s6-igk-ih5/tf-testaccdatadogdashboardgeomap-local-1619506707","created_at":"2021-04-27T06:58:29.156444+00:00","modified_at":"2021-04-27T06:58:29.156444+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":2235960280314117},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":481676151794705},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":2786918167906999}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -196,7 +196,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:25 GMT ++ - Tue, 27 Apr 2021 06:58:33 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -206,9 +206,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - l4HFlaRP3QwYSqoGKhzbYfv7zgkK63HIRR7YkyVYZspq0lGjjTBwoK8V/alf+XYt ++ - mNzaoDhdDKO7t4QSrAe5X7pHd0bJND187D+vRbwoluXouE2m1UaQQX0RGCvRpLVE + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -223,11 +223,11 @@ interactions: + Dd-Operation-Id: + - DeleteDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/c6k-dfq-zy2 ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3s6-igk-ih5 + method: DELETE + response: +- body: '{"deleted_dashboard_id":"c6k-dfq-zy2"}' ++ body: '{"deleted_dashboard_id":"3s6-igk-ih5"}' + headers: + Cache-Control: + - no-cache +@@ -238,7 +238,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:26 GMT ++ - Tue, 27 Apr 2021 06:58:34 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -248,9 +248,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - dCmL/3rURV6BPeaqeP3Rxigq41m5CAb17XjrRE42uZ01zpr07HVhbL5/3TWMkvgu ++ - Um4CoU685QqAscnxhS5BD+goWu2yX1Jd4zCfGzSsEvPPIm1qURZaF8dlLl/OEY4I + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -265,11 +265,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/c6k-dfq-zy2 ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3s6-igk-ih5 + method: GET + response: +- body: '{"errors": ["Dashboard with ID c6k-dfq-zy2 not found"]}' ++ body: '{"errors": ["Dashboard with ID 3s6-igk-ih5 not found"]}' + headers: + Cache-Control: + - no-cache +@@ -280,7 +280,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:26 GMT ++ - Tue, 27 Apr 2021 06:58:34 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -290,7 +290,7 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 404 Not Found +diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.freeze b/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.freeze +new file mode 100644 +index 0000000000..12046087a1 +--- /dev/null ++++ b/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.freeze +@@ -0,0 +1 @@ ++2021-04-27T08:58:27.619933+02:00 +\ No newline at end of file +diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.yaml b/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.yaml +new file mode 100644 +index 0000000000..d8271a5a99 +--- /dev/null ++++ b/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.yaml +@@ -0,0 +1,298 @@ ++--- ++version: 1 ++interactions: ++- request: ++ body: | ++ {"description":"Created using the Datadog provider in Terraform","id":"","is_read_only":true,"layout_type":"ordered","notify_list":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardGeomapFormula-local-1619506707","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}],"response_format":"scalar"}],"style":{"palette":"hostmap_blues","palette_flip":false},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"queries":[{"compute":{"aggregation":"count"},"data_source":"rum","indexes":["*"],"name":"query1","search":{"query":"abc"}}],"response_format":"scalar"}],"style":{"palette":"hostmap_blues","palette_flip":false},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"custom_links":[{"label":"my custom link","link":"https://app.datadoghq.com/dashboard/lists"}],"requests":[{"formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count"},"data_source":"security_signals","indexes":["*"],"name":"query1"}],"response_format":"scalar"}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"},"type":"geomap","view":{"focus":"WORLD"}}}]} ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Content-Type: ++ - application/json ++ Dd-Operation-Id: ++ - CreateDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard ++ method: POST ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3jk-mfp-nsn","title":"tf-TestAccDatadogDashboardGeomapFormula-local-1619506707","url":"/dashboard/3jk-mfp-nsn/tf-testaccdatadogdashboardgeomapformula-local-1619506707","created_at":"2021-04-27T06:58:29.303490+00:00","modified_at":"2021-04-27T06:58:29.303490+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1149146342854926},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5478869481740425},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":18914160855721}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:32 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - Um4CoU685QqAscnxhS5BD+goWu2yX1Jd4zCfGzSsEvPPIm1qURZaF8dlLl/OEY4I ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3jk-mfp-nsn ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3jk-mfp-nsn","title":"tf-TestAccDatadogDashboardGeomapFormula-local-1619506707","url":"/dashboard/3jk-mfp-nsn/tf-testaccdatadogdashboardgeomapformula-local-1619506707","created_at":"2021-04-27T06:58:29.303490+00:00","modified_at":"2021-04-27T06:58:29.303490+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1149146342854926},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5478869481740425},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":18914160855721}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:32 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - SY1h8ScsWq+kYmtbh63ltMLFAZsQjqfrgvdfAoRX+9TzT1sgMBRYaFRwfWWRRe9a ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3jk-mfp-nsn ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3jk-mfp-nsn","title":"tf-TestAccDatadogDashboardGeomapFormula-local-1619506707","url":"/dashboard/3jk-mfp-nsn/tf-testaccdatadogdashboardgeomapformula-local-1619506707","created_at":"2021-04-27T06:58:29.303490+00:00","modified_at":"2021-04-27T06:58:29.303490+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1149146342854926},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5478869481740425},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":18914160855721}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:32 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - SY1h8ScsWq+kYmtbh63ltMLFAZsQjqfrgvdfAoRX+9TzT1sgMBRYaFRwfWWRRe9a ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3jk-mfp-nsn ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3jk-mfp-nsn","title":"tf-TestAccDatadogDashboardGeomapFormula-local-1619506707","url":"/dashboard/3jk-mfp-nsn/tf-testaccdatadogdashboardgeomapformula-local-1619506707","created_at":"2021-04-27T06:58:29.303490+00:00","modified_at":"2021-04-27T06:58:29.303490+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1149146342854926},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5478869481740425},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":18914160855721}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:33 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - dPySkcOzIZtKyMKDAAzuysY3gNGGj6RtYogGuSb76E8mPvoqzREyRp6lPYm91hQU ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3jk-mfp-nsn ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"3jk-mfp-nsn","title":"tf-TestAccDatadogDashboardGeomapFormula-local-1619506707","url":"/dashboard/3jk-mfp-nsn/tf-testaccdatadogdashboardgeomapformula-local-1619506707","created_at":"2021-04-27T06:58:29.303490+00:00","modified_at":"2021-04-27T06:58:29.303490+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":1149146342854926},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5478869481740425},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":18914160855721}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:34 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - dCmL/3rURV6BPeaqeP3Rxigq41m5CAb17XjrRE42uZ01zpr07HVhbL5/3TWMkvgu ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - DeleteDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3jk-mfp-nsn ++ method: DELETE ++ response: ++ body: '{"deleted_dashboard_id":"3jk-mfp-nsn"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:34 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - mNzaoDhdDKO7t4QSrAe5X7pHd0bJND187D+vRbwoluXouE2m1UaQQX0RGCvRpLVE ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/3jk-mfp-nsn ++ method: GET ++ response: ++ body: '{"errors": ["Dashboard with ID 3jk-mfp-nsn not found"]}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:34 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 404 Not Found ++ code: 404 ++ duration: "" +diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.freeze b/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.freeze +new file mode 100644 +index 0000000000..a807f71eb9 +--- /dev/null ++++ b/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.freeze +@@ -0,0 +1 @@ ++2021-04-27T08:58:27.620391+02:00 +\ No newline at end of file +diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.yaml b/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.yaml +new file mode 100644 +index 0000000000..01b977dabe +--- /dev/null ++++ b/datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.yaml +@@ -0,0 +1,340 @@ ++--- ++version: 1 ++interactions: ++- request: ++ body: | ++ {"description":"Created using the Datadog provider in Terraform","id":"","is_read_only":true,"layout_type":"ordered","notify_list":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardGeomapFormula_import-local-1619506707","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}],"response_format":"scalar"}],"style":{"palette":"hostmap_blues","palette_flip":false},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"queries":[{"compute":{"aggregation":"count"},"data_source":"rum","indexes":["*"],"name":"query1","search":{"query":"abc"}}],"response_format":"scalar"}],"style":{"palette":"hostmap_blues","palette_flip":false},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"custom_links":[{"label":"my custom link","link":"https://app.datadoghq.com/dashboard/lists"}],"requests":[{"formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count"},"data_source":"security_signals","indexes":["*"],"name":"query1"}],"response_format":"scalar"}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"},"type":"geomap","view":{"focus":"WORLD"}}}]} ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Content-Type: ++ - application/json ++ Dd-Operation-Id: ++ - CreateDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard ++ method: POST ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"myq-qpv-k3m","title":"tf-TestAccDatadogDashboardGeomapFormula_import-local-1619506707","url":"/dashboard/myq-qpv-k3m/tf-testaccdatadogdashboardgeomapformulaimport-local-1619506707","created_at":"2021-04-27T06:58:29.153119+00:00","modified_at":"2021-04-27T06:58:29.153119+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5661738832269822},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":8505986293990458},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":3442821028347668}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:32 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - PhosSd3Ch1B6B0DXI71steKUi7XhPDttnPiIP1NdXTw0VJNWpoUnYyBmODS5ne3q ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/myq-qpv-k3m ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"myq-qpv-k3m","title":"tf-TestAccDatadogDashboardGeomapFormula_import-local-1619506707","url":"/dashboard/myq-qpv-k3m/tf-testaccdatadogdashboardgeomapformulaimport-local-1619506707","created_at":"2021-04-27T06:58:29.153119+00:00","modified_at":"2021-04-27T06:58:29.153119+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5661738832269822},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":8505986293990458},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":3442821028347668}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:32 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - tpRCH6w417YjBovRJ8VmtuXmNONVYiRp2c8d2AxjPdGBn8PCtgG4vAztrx3qUZAN ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/myq-qpv-k3m ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"myq-qpv-k3m","title":"tf-TestAccDatadogDashboardGeomapFormula_import-local-1619506707","url":"/dashboard/myq-qpv-k3m/tf-testaccdatadogdashboardgeomapformulaimport-local-1619506707","created_at":"2021-04-27T06:58:29.153119+00:00","modified_at":"2021-04-27T06:58:29.153119+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5661738832269822},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":8505986293990458},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":3442821028347668}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:33 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - dPySkcOzIZtKyMKDAAzuysY3gNGGj6RtYogGuSb76E8mPvoqzREyRp6lPYm91hQU ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/myq-qpv-k3m ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"myq-qpv-k3m","title":"tf-TestAccDatadogDashboardGeomapFormula_import-local-1619506707","url":"/dashboard/myq-qpv-k3m/tf-testaccdatadogdashboardgeomapformulaimport-local-1619506707","created_at":"2021-04-27T06:58:29.153119+00:00","modified_at":"2021-04-27T06:58:29.153119+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5661738832269822},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":8505986293990458},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":3442821028347668}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:33 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - l8RQo2maZqJf6GFThBbKNE6dvthz6njusVtau3dPXJWL2RLFoN81H+BLPB/1xgs1 ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/myq-qpv-k3m ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"myq-qpv-k3m","title":"tf-TestAccDatadogDashboardGeomapFormula_import-local-1619506707","url":"/dashboard/myq-qpv-k3m/tf-testaccdatadogdashboardgeomapformulaimport-local-1619506707","created_at":"2021-04-27T06:58:29.153119+00:00","modified_at":"2021-04-27T06:58:29.153119+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5661738832269822},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":8505986293990458},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":3442821028347668}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:34 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - nLnnBNvlCFDECRnZvzDb0z4sAO35G+IMidcAs8vrCKyjvsKWE8Yd9S3n6OjZ1qRN ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/myq-qpv-k3m ++ method: GET ++ response: ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"myq-qpv-k3m","title":"tf-TestAccDatadogDashboardGeomapFormula_import-local-1619506707","url":"/dashboard/myq-qpv-k3m/tf-testaccdatadogdashboardgeomapformulaimport-local-1619506707","created_at":"2021-04-27T06:58:29.153119+00:00","modified_at":"2021-04-27T06:58:29.153119+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"formulas":[{"formula":"query1 + query2","limit":{"count":10,"order":"asc"}}],"response_format":"scalar","queries":[{"aggregator":"sum","data_source":"metrics","name":"query1","query":"avg:system.cpu.system{*} by {datacenter}"},{"aggregator":"sum","data_source":"metrics","name":"query2","query":"avg:system.load.1{*} by {datacenter}"}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5661738832269822},{"definition":{"requests":[{"formulas":[{"formula":"query1","limit":{"count":25,"order":"desc"}}],"response_format":"scalar","queries":[{"search":{"query":"abc"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":8505986293990458},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"my custom link"}],"time":{"live_span":"4h"},"requests":[{"formulas":[{"formula":"query1"}],"response_format":"scalar","queries":[{"data_source":"security_signals","compute":{"aggregation":"count"},"name":"query1","indexes":["*"]}]}],"type":"geomap","view":{"focus":"WORLD"}},"id":3442821028347668}],"layout_type":"ordered"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:34 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - twvpGlmuom5y6A0pjGtXzTf554cmwJgTcCZ71fK4H/RDi+v5ehBK0zQiRcTJQG5C ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - DeleteDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/myq-qpv-k3m ++ method: DELETE ++ response: ++ body: '{"deleted_dashboard_id":"myq-qpv-k3m"}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:34 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Debug: ++ - 5gfwVh/5HZ+AnGd/Di93w3NEWC6KMHT9KzmHEiRJmNdOjBtAsbOcgVFyqEChw71h ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 200 OK ++ code: 200 ++ duration: "" ++- request: ++ body: "" ++ form: {} ++ headers: ++ Accept: ++ - application/json ++ Dd-Operation-Id: ++ - GetDashboard ++ User-Agent: ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/myq-qpv-k3m ++ method: GET ++ response: ++ body: '{"errors": ["Dashboard with ID myq-qpv-k3m not found"]}' ++ headers: ++ Cache-Control: ++ - no-cache ++ Connection: ++ - keep-alive ++ Content-Security-Policy: ++ - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report ++ Content-Type: ++ - application/json ++ Date: ++ - Tue, 27 Apr 2021 06:58:35 GMT ++ Pragma: ++ - no-cache ++ Strict-Transport-Security: ++ - max-age=15724800; ++ Vary: ++ - Accept-Encoding ++ X-Content-Type-Options: ++ - nosniff ++ X-Dd-Version: ++ - "35.4397207" ++ X-Frame-Options: ++ - SAMEORIGIN ++ status: 404 Not Found ++ code: 404 ++ duration: "" +diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.freeze b/datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.freeze +index 44e69b7998..c9fd84193a 100644 +--- a/datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.freeze ++++ b/datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.freeze +@@ -1 +1 @@ +-2021-03-01T13:47:20.127779-05:00 +\ No newline at end of file ++2021-04-27T08:58:27.619914+02:00 +\ No newline at end of file +diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.yaml b/datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.yaml +index f2527de257..b9c3cd1d8f 100644 +--- a/datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.yaml ++++ b/datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.yaml +@@ -3,7 +3,7 @@ version: 1 + interactions: + - request: + body: | +- {"description":"Created using the Datadog provider in Terraform","id":"","is_read_only":true,"layout_type":"ordered","notify_list":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardGeomap_import-local-1614624440","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"style":{"palette":"hostmap_blues","palette_flip":false},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"custom_links":[{"label":"Test Custom Link label","link":"https://app.datadoghq.com/dashboard/lists"}],"requests":[{"log_query":{"compute":{"aggregation":"count"},"index":"*","search":{"query":""}}}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"1h"},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"requests":[{"rum_query":{"compute":{"aggregation":"count"},"index":"*","search":{"query":""}}}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"},"type":"geomap","view":{"focus":"WORLD"}}}]} ++ {"description":"Created using the Datadog provider in Terraform","id":"","is_read_only":true,"layout_type":"ordered","notify_list":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardGeomap_import-local-1619506707","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"style":{"palette":"hostmap_blues","palette_flip":false},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"custom_links":[{"label":"Test Custom Link label","link":"https://app.datadoghq.com/dashboard/lists"}],"requests":[{"log_query":{"compute":{"aggregation":"count"},"index":"*","search":{"query":""}}}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"1h"},"type":"geomap","view":{"focus":"WORLD"}}},{"definition":{"requests":[{"rum_query":{"compute":{"aggregation":"count"},"index":"*","search":{"query":""}}}],"style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"},"type":"geomap","view":{"focus":"WORLD"}}}]} + form: {} + headers: + Accept: +@@ -13,11 +13,11 @@ interactions: + Dd-Operation-Id: + - CreateDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/dashboard + method: POST + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"i7z-h73-btb","title":"tf-TestAccDatadogDashboardGeomap_import-local-1614624440","url":"/dashboard/i7z-h73-btb/tf-testaccdatadogdashboardgeomapimport-local-1614624440","created_at":"2021-03-01T18:47:21.298453+00:00","modified_at":"2021-03-01T18:47:21.298453+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5257848164284472},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":4080615887771550},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6973049843836176}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"r87-rkv-9zm","title":"tf-TestAccDatadogDashboardGeomap_import-local-1619506707","url":"/dashboard/r87-rkv-9zm/tf-testaccdatadogdashboardgeomapimport-local-1619506707","created_at":"2021-04-27T06:58:29.156112+00:00","modified_at":"2021-04-27T06:58:29.156112+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":4639613529631183},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":658528929802208},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":8526536237626829}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -28,7 +28,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:24 GMT ++ - Tue, 27 Apr 2021 06:58:32 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -38,9 +38,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - S1wfaMZOKGT/IoMw6fqAwAwGWo2vQ44sjF3YzuETnQfxZO2T5eJbs0aX3UKb9Dwu ++ - tpRCH6w417YjBovRJ8VmtuXmNONVYiRp2c8d2AxjPdGBn8PCtgG4vAztrx3qUZAN + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -55,11 +55,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/i7z-h73-btb ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/r87-rkv-9zm + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"i7z-h73-btb","title":"tf-TestAccDatadogDashboardGeomap_import-local-1614624440","url":"/dashboard/i7z-h73-btb/tf-testaccdatadogdashboardgeomapimport-local-1614624440","created_at":"2021-03-01T18:47:21.298453+00:00","modified_at":"2021-03-01T18:47:21.298453+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5257848164284472},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":4080615887771550},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6973049843836176}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"r87-rkv-9zm","title":"tf-TestAccDatadogDashboardGeomap_import-local-1619506707","url":"/dashboard/r87-rkv-9zm/tf-testaccdatadogdashboardgeomapimport-local-1619506707","created_at":"2021-04-27T06:58:29.156112+00:00","modified_at":"2021-04-27T06:58:29.156112+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":4639613529631183},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":658528929802208},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":8526536237626829}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -70,7 +70,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:24 GMT ++ - Tue, 27 Apr 2021 06:58:32 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -80,9 +80,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - l4HFlaRP3QwYSqoGKhzbYfv7zgkK63HIRR7YkyVYZspq0lGjjTBwoK8V/alf+XYt ++ - l8RQo2maZqJf6GFThBbKNE6dvthz6njusVtau3dPXJWL2RLFoN81H+BLPB/1xgs1 + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -97,11 +97,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/i7z-h73-btb ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/r87-rkv-9zm + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"i7z-h73-btb","title":"tf-TestAccDatadogDashboardGeomap_import-local-1614624440","url":"/dashboard/i7z-h73-btb/tf-testaccdatadogdashboardgeomapimport-local-1614624440","created_at":"2021-03-01T18:47:21.298453+00:00","modified_at":"2021-03-01T18:47:21.298453+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5257848164284472},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":4080615887771550},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6973049843836176}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"r87-rkv-9zm","title":"tf-TestAccDatadogDashboardGeomap_import-local-1619506707","url":"/dashboard/r87-rkv-9zm/tf-testaccdatadogdashboardgeomapimport-local-1619506707","created_at":"2021-04-27T06:58:29.156112+00:00","modified_at":"2021-04-27T06:58:29.156112+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":4639613529631183},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":658528929802208},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":8526536237626829}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -112,7 +112,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:25 GMT ++ - Tue, 27 Apr 2021 06:58:33 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -122,9 +122,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - twvpGlmuom5y6A0pjGtXzTf554cmwJgTcCZ71fK4H/RDi+v5ehBK0zQiRcTJQG5C ++ - 25u1gDlL724DHllbjFT4BhOLorBTilh+aah2uWAUEjFC/+rjczJdiyWrV/HwLwe/ + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -139,11 +139,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/i7z-h73-btb ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/r87-rkv-9zm + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"i7z-h73-btb","title":"tf-TestAccDatadogDashboardGeomap_import-local-1614624440","url":"/dashboard/i7z-h73-btb/tf-testaccdatadogdashboardgeomapimport-local-1614624440","created_at":"2021-03-01T18:47:21.298453+00:00","modified_at":"2021-03-01T18:47:21.298453+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5257848164284472},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":4080615887771550},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6973049843836176}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"r87-rkv-9zm","title":"tf-TestAccDatadogDashboardGeomap_import-local-1619506707","url":"/dashboard/r87-rkv-9zm/tf-testaccdatadogdashboardgeomapimport-local-1619506707","created_at":"2021-04-27T06:58:29.156112+00:00","modified_at":"2021-04-27T06:58:29.156112+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":4639613529631183},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":658528929802208},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":8526536237626829}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -154,7 +154,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:25 GMT ++ - Tue, 27 Apr 2021 06:58:33 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -164,9 +164,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - fIO2C4qGDheGHy4YbS+r3a3CXbh4cbRo7roILOimQyiHGjQdOat0cIpWCkupM1uX ++ - Wjq53IVIwnB4SiR238oOYgHFMq/ZYP0LQ/Dv8C2fFLBwTje/dWJHu6pI6vIOK1zG + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -181,11 +181,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/i7z-h73-btb ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/r87-rkv-9zm + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"i7z-h73-btb","title":"tf-TestAccDatadogDashboardGeomap_import-local-1614624440","url":"/dashboard/i7z-h73-btb/tf-testaccdatadogdashboardgeomapimport-local-1614624440","created_at":"2021-03-01T18:47:21.298453+00:00","modified_at":"2021-03-01T18:47:21.298453+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5257848164284472},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":4080615887771550},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6973049843836176}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"r87-rkv-9zm","title":"tf-TestAccDatadogDashboardGeomap_import-local-1619506707","url":"/dashboard/r87-rkv-9zm/tf-testaccdatadogdashboardgeomapimport-local-1619506707","created_at":"2021-04-27T06:58:29.156112+00:00","modified_at":"2021-04-27T06:58:29.156112+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":4639613529631183},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":658528929802208},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":8526536237626829}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -196,7 +196,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:25 GMT ++ - Tue, 27 Apr 2021 06:58:33 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -206,9 +206,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - nLnnBNvlCFDECRnZvzDb0z4sAO35G+IMidcAs8vrCKyjvsKWE8Yd9S3n6OjZ1qRN ++ - /L+SFFO+m1pPY+hRCpk5325fvfrNl0KmiquUNJolBN/5hu3HIwflqjZSbJ6NxDFG + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -223,11 +223,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/i7z-h73-btb ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/r87-rkv-9zm + method: GET + response: +- body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"i7z-h73-btb","title":"tf-TestAccDatadogDashboardGeomap_import-local-1614624440","url":"/dashboard/i7z-h73-btb/tf-testaccdatadogdashboardgeomapimport-local-1614624440","created_at":"2021-03-01T18:47:21.298453+00:00","modified_at":"2021-03-01T18:47:21.298453+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":5257848164284472},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":4080615887771550},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":6973049843836176}],"layout_type":"ordered"}' ++ body: '{"notify_list":[],"description":"Created using the Datadog provider in Terraform","author_name":null,"template_variable_presets":[],"template_variables":[],"is_read_only":true,"id":"r87-rkv-9zm","title":"tf-TestAccDatadogDashboardGeomap_import-local-1619506707","url":"/dashboard/r87-rkv-9zm/tf-testaccdatadogdashboardgeomapimport-local-1619506707","created_at":"2021-04-27T06:58:29.156112+00:00","modified_at":"2021-04-27T06:58:29.156112+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"q":"avg:system.load.1{*}"}],"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"view":{"focus":"WORLD"}},"id":4639613529631183},{"definition":{"style":{"palette":"hostmap_blues","palette_flip":false},"custom_links":[{"link":"https://app.datadoghq.com/dashboard/lists","label":"Test Custom Link label"}],"time":{"live_span":"1h"},"requests":[{"log_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"type":"geomap","view":{"focus":"WORLD"}},"id":658528929802208},{"definition":{"requests":[{"rum_query":{"index":"*","search":{"query":""},"compute":{"aggregation":"count"}}}],"view":{"focus":"WORLD"},"type":"geomap","style":{"palette":"hostmap_blues","palette_flip":false},"time":{"live_span":"4h"}},"id":8526536237626829}],"layout_type":"ordered"}' + headers: + Cache-Control: + - no-cache +@@ -238,7 +238,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:25 GMT ++ - Tue, 27 Apr 2021 06:58:34 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -248,9 +248,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - 25u1gDlL724DHllbjFT4BhOLorBTilh+aah2uWAUEjFC/+rjczJdiyWrV/HwLwe/ ++ - F5gm0Rce1/Abr9/0Fw8HAqWfiz0FdiH8er/AXnN6lOn3L6KyGgbsLCwgPlob1No8 + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -265,11 +265,11 @@ interactions: + Dd-Operation-Id: + - DeleteDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/i7z-h73-btb ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/r87-rkv-9zm + method: DELETE + response: +- body: '{"deleted_dashboard_id":"i7z-h73-btb"}' ++ body: '{"deleted_dashboard_id":"r87-rkv-9zm"}' + headers: + Cache-Control: + - no-cache +@@ -280,7 +280,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:26 GMT ++ - Tue, 27 Apr 2021 06:58:34 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -290,9 +290,9 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Debug: +- - F5gm0Rce1/Abr9/0Fw8HAqWfiz0FdiH8er/AXnN6lOn3L6KyGgbsLCwgPlob1No8 ++ - 2328yjLSqI4XmR1pVqrPRR/SFcQsbafjEpPmZx7/3PfxUK1nJQQsX+wrMelyVyj+ + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -307,11 +307,11 @@ interactions: + Dd-Operation-Id: + - GetDashboard + User-Agent: +- - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.16+dev (go go1.15.6; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v1/dashboard/i7z-h73-btb ++ - terraform-provider-datadog/dev (terraform 1.16.0; terraform-cli 0.12.7-sdk) datadog-api-client-go/1.0.0-beta.19 (go go1.15.7; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v1/dashboard/r87-rkv-9zm + method: GET + response: +- body: '{"errors": ["Dashboard with ID i7z-h73-btb not found"]}' ++ body: '{"errors": ["Dashboard with ID r87-rkv-9zm not found"]}' + headers: + Cache-Control: + - no-cache +@@ -322,7 +322,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Mon, 01 Mar 2021 18:47:26 GMT ++ - Tue, 27 Apr 2021 06:58:34 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -332,7 +332,7 @@ interactions: + X-Content-Type-Options: + - nosniff + X-Dd-Version: +- - "35.4004047" ++ - "35.4397207" + X-Frame-Options: + - SAMEORIGIN + status: 404 Not Found +diff --git a/datadog/tests/resource_datadog_dashboard_geomap_test.go b/datadog/tests/resource_datadog_dashboard_geomap_test.go +index b3038bfd7a..24452cfea6 100644 +--- a/datadog/tests/resource_datadog_dashboard_geomap_test.go ++++ b/datadog/tests/resource_datadog_dashboard_geomap_test.go +@@ -72,6 +72,115 @@ resource "datadog_dashboard" "geomap_dashboard" { + } + ` + ++const datadogDashboardGeomapFormulaConfig = ` ++resource "datadog_dashboard" "geomap_dashboard" { ++ title = "{{uniq}}" ++ description = "Created using the Datadog provider in Terraform" ++ layout_type = "ordered" ++ is_read_only = "true" ++ widget { ++ geomap_definition { ++ request { ++ formula { ++ formula_expression = "query1 + query2" ++ limit { ++ count = 10 ++ order = "asc" ++ } ++ } ++ query { ++ metric_query { ++ data_source = "metrics" ++ query = "avg:system.cpu.system{*} by {datacenter}" ++ name = "query1" ++ aggregator = "sum" ++ } ++ } ++ query { ++ metric_query { ++ data_source = "metrics" ++ query = "avg:system.load.1{*} by {datacenter}" ++ name = "query2" ++ aggregator = "sum" ++ } ++ } ++ } ++ view { ++ focus = "WORLD" ++ } ++ style { ++ palette = "hostmap_blues" ++ palette_flip = false ++ } ++ } ++ } ++ widget { ++ geomap_definition { ++ request { ++ formula { ++ formula_expression = "query1" ++ limit { ++ count = 25 ++ order = "desc" ++ } ++ } ++ query { ++ event_query { ++ data_source = "rum" ++ indexes = ["*"] ++ name = "query1" ++ compute { ++ aggregation = "count" ++ } ++ search { ++ query = "abc" ++ } ++ } ++ } ++ } ++ view { ++ focus = "WORLD" ++ } ++ style { ++ palette = "hostmap_blues" ++ palette_flip = false ++ } ++ } ++ } ++ widget { ++ geomap_definition { ++ request { ++ formula { ++ formula_expression = "query1" ++ } ++ query { ++ event_query { ++ data_source = "security_signals" ++ name = "query1" ++ indexes = ["*"] ++ compute { ++ aggregation = "count" ++ } ++ } ++ } ++ } ++ style { ++ palette = "hostmap_blues" ++ palette_flip = false ++ } ++ view { ++ focus = "WORLD" ++ } ++ live_span = "4h" ++ custom_link { ++ label = "my custom link" ++ link = "https://app.datadoghq.com/dashboard/lists" ++ } ++ } ++ } ++} ++` ++ + var datadogDashboardGeomapAsserts = []string{ + "description = Created using the Datadog provider in Terraform", + "layout_type = ordered", +@@ -98,6 +207,48 @@ var datadogDashboardGeomapAsserts = []string{ + "widget.2.geomap_definition.0.view.0.focus = WORLD", + } + ++var datadogDashboardGeomapFormulaAsserts = []string{ ++ "title = {{uniq}}", ++ "is_read_only = true", ++ "layout_type = ordered", ++ "description = Created using the Datadog provider in Terraform", ++ "widget.0.geomap_definition.0.request.0.formula.0.formula_expression = query1 + query2", ++ "widget.0.geomap_definition.0.request.0.formula.0.limit.0.count = 10", ++ "widget.0.geomap_definition.0.request.0.formula.0.limit.0.order = asc", ++ "widget.0.geomap_definition.0.request.0.query.0.metric_query.0.data_source = metrics", ++ "widget.0.geomap_definition.0.request.0.query.0.metric_query.0.query = avg:system.cpu.system{*} by {datacenter}", ++ "widget.0.geomap_definition.0.request.0.query.0.metric_query.0.name = query1", ++ "widget.0.geomap_definition.0.request.0.query.0.metric_query.0.aggregator = sum", ++ "widget.0.geomap_definition.0.request.0.query.1.metric_query.0.data_source = metrics", ++ "widget.0.geomap_definition.0.request.0.query.1.metric_query.0.query = avg:system.load.1{*} by {datacenter}", ++ "widget.0.geomap_definition.0.request.0.query.1.metric_query.0.name = query2", ++ "widget.0.geomap_definition.0.request.0.query.1.metric_query.0.aggregator = sum", ++ "widget.0.geomap_definition.0.view.0.focus = WORLD", ++ "widget.0.geomap_definition.0.style.0.palette = hostmap_blues", ++ "widget.0.geomap_definition.0.style.0.palette_flip = false", ++ "widget.1.geomap_definition.0.request.0.formula.0.formula_expression = query1", ++ "widget.1.geomap_definition.0.request.0.formula.0.limit.0.count = 25", ++ "widget.1.geomap_definition.0.request.0.formula.0.limit.0.order = desc", ++ "widget.1.geomap_definition.0.request.0.query.0.event_query.0.data_source = rum", ++ "widget.1.geomap_definition.0.request.0.query.0.event_query.0.indexes.# = 1", ++ "widget.1.geomap_definition.0.request.0.query.0.event_query.0.indexes.0 = *", ++ "widget.1.geomap_definition.0.request.0.query.0.event_query.0.name = query1", ++ "widget.1.geomap_definition.0.request.0.query.0.event_query.0.search.0.query = abc", ++ "widget.1.geomap_definition.0.request.0.query.0.event_query.0.compute.0.aggregation = count", ++ "widget.1.geomap_definition.0.view.0.focus = WORLD", ++ "widget.1.geomap_definition.0.style.0.palette_flip = false", ++ "widget.1.geomap_definition.0.view.0.focus = WORLD", ++ "widget.2.geomap_definition.0.request.0.formula.0.formula_expression = query1", ++ "widget.2.geomap_definition.0.request.0.query.0.event_query.0.data_source = security_signals", ++ "widget.2.geomap_definition.0.request.0.query.0.event_query.0.indexes.# = 1", ++ "widget.2.geomap_definition.0.request.0.query.0.event_query.0.indexes.0 = *", ++ "widget.2.geomap_definition.0.request.0.query.0.event_query.0.name = query1", ++ "widget.2.geomap_definition.0.request.0.query.0.event_query.0.compute.0.aggregation = count", ++ "widget.2.geomap_definition.0.view.0.focus = WORLD", ++ "widget.2.geomap_definition.0.style.0.palette_flip = false", ++ "widget.2.geomap_definition.0.view.0.focus = WORLD", ++} ++ + func TestAccDatadogDashboardGeomap(t *testing.T) { + testAccDatadogDashboardWidgetUtil(t, datadogDashboardGeomapConfig, "datadog_dashboard.geomap_dashboard", datadogDashboardGeomapAsserts) + } +@@ -105,3 +256,11 @@ func TestAccDatadogDashboardGeomap(t *testing.T) { + func TestAccDatadogDashboardGeomap_import(t *testing.T) { + testAccDatadogDashboardWidgetUtilImport(t, datadogDashboardGeomapConfig, "datadog_dashboard.geomap_dashboard") + } ++ ++func TestAccDatadogDashboardGeomapFormula(t *testing.T) { ++ testAccDatadogDashboardWidgetUtil(t, datadogDashboardGeomapFormulaConfig, "datadog_dashboard.geomap_dashboard", datadogDashboardGeomapFormulaAsserts) ++} ++ ++func TestAccDatadogDashboardGeomapFormula_import(t *testing.T) { ++ testAccDatadogDashboardWidgetUtilImport(t, datadogDashboardGeomapFormulaConfig, "datadog_dashboard.geomap_dashboard") ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3RQWvCMBQH8J77KR5l7KZrgq0nB6VVGTso4mWnEptMBWOkTWWDffjVjuLmmO6g ++jOH/d8lL36Mv8G/PyuVKpmq9vXMuxa90g6A+K4dnXbOAMxbyMAw7jl9VjDsUXOxFn5SFFTmRkxtj ++j82d6v9T7X3+VhU2zYzWYi3bxeJ8O07l3+mG+/x9XuXfCXngkH++J/zsyvPPJNXBz5R0XfWyMbml ++6SCN4rjHmvukH48mSe9ZrArVfEuiaZSMhmk0fkgf+089T5Zav3rf2+MvbbfaJ4UV0szrtYU7N7Qr ++qLWlVl6uyZtWtyjLko+pRBSLmRG5HCqjxebm7Wg7Xerd+hNTA5PrciV+N9X80qOWXWplSkuM+5r4 ++/S1z/zo9AAAAAAAAAAAAAAAAAAAAALh272nzONgAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000071/tests/test.sh b/tasks/format-code-task-000071/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..064e8b1dd3b8f22b923d38e7d5c31eb557d120f6 --- /dev/null +++ b/tasks/format-code-task-000071/tests/test.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +datadog/tests/cassettes/TestAccDatadogDashboardGeomap.freeze +datadog/tests/cassettes/TestAccDatadogDashboardGeomap.yaml +datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.freeze +datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula.yaml +datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.freeze +datadog/tests/cassettes/TestAccDatadogDashboardGeomapFormula_import.yaml +datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.freeze +datadog/tests/cassettes/TestAccDatadogDashboardGeomap_import.yaml +datadog/tests/resource_datadog_dashboard_geomap_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000071/tests/test_command.sh b/tasks/format-code-task-000071/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000071/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000076/environment/Dockerfile b/tasks/format-code-task-000076/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0172bccf96eacebdb665aca8a1a4f0789ee418ad --- /dev/null +++ b/tasks/format-code-task-000076/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4f92177ad8e43e011f3805cf5a3b5919165d7172dcec59ddd6b23e7669d2ec11 diff --git a/tasks/format-code-task-000076/environment/setup/files/blocklist b/tasks/format-code-task-000076/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000076/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000076/environment/setup/setup.sh b/tasks/format-code-task-000076/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000076/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000076/tests/test.patch b/tasks/format-code-task-000076/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6554c2c7f1dbdd53f2d7f33510413c7793e1357b --- /dev/null +++ b/tasks/format-code-task-000076/tests/test.patch @@ -0,0 +1,50 @@ +diff --git a/tests/test_color_deconvolution.py b/tests/test_color_deconvolution.py +index 7177c5617..2de55c9db 100644 +--- a/tests/test_color_deconvolution.py ++++ b/tests/test_color_deconvolution.py +@@ -37,3 +37,17 @@ def test_roundtrip(self): + conv_result.Wc, 255) + + np.testing.assert_allclose(im, im_reconv, atol=1) ++ ++ def test_short_array(self): ++ im_path = datastore.fetch('Easy1.png') ++ im = skimage.io.imread(im_path)[..., :3] ++ ++ w = [[0.650, 0.072], ++ [0.704, 0.990], ++ [0.286, 0.105]] ++ ++ conv_result = htk_dcv.color_deconvolution(im, w, 255) ++ ++ im_reconv = htk_dcv.color_convolution(conv_result.StainsFloat, ++ conv_result.Wc, 255) ++ np.testing.assert_allclose(im, im_reconv, atol=1) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,12 @@ ++H4sIAAAAAAAAA+2UUU/bMBDH+5xPccq6rRlz2rQrPCD2sA6mShugbUjwVLnxtfWW2FHsFCrGd5+d ++QGFojD2Apon7PdTu3eV8vv8l8bSSmZigWnZbj0XPsTUc1qvj9lrvk2E/6fc2t5Jh0uolyWYvacHw ++0Sq6QWUsLwFapdb2T3H3+f9T4mv9LRo7SXWecyVis3i4M+7RPxkOtm7p/2azP2hB7+FKuJsnrn8q ++oBZ+iiIwuipThK4ubDMMSz8WU6m6PLVyyS0GwTMYK9exLAO7QChK/Q1TC1IBCmn5NEPItUDoKA0C ++C/Pah61elgg8K5GLlQ/1T/rUUVDIwhmafAwhBsaUZv7BZlcPJ5NGZ9xKraD/9kUCP8By6eIHvpp3 ++PgJGK7twbjyzqIwLNNDx58IcLZzKAgWcLlBBiYUGadxq0EbB/tGnw5PJeH/08ej97k67U9RZBsBS ++CGVe6NKCqvJite3uKZXt1H9il3MiVZpVAjtRFEbB4cnoYH9v/OE6Q5z0WarVTM7dNS5jTRTsHn+d ++fDna2xsf3xG6rp+ZajaTZ1EQzHQJxepsImTpW3elVXchjdW5TI393p0ht5W70++9Buc5Kls3sJvx ++KWZ/EaeqNENeboPQATjcmITtyzrC2nJZmC/qVew261DPlBvcCdvnzv7cOy/CtSttpKqzhbWga9d8 ++YwOYWfDS6cUO+sBmh+MRtK/6C2zc/kUyYNrlOfeHXbTPr7t7Ea7NcXrjDKEVBvVPcHPs3RR9rpqp ++dJ8CPzLeY4JGIWC5u6e3NOarz2Smy4lAJ91SZ5XvmbsnsGVdExfCvUNmJwz+9etNEARBEARBEARB ++EARBEARBEARBEARBEMQT4CdZvc8vACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000076/tests/test.sh b/tasks/format-code-task-000076/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5de3f61955503116ad386abcc1b2408263e0ea71 --- /dev/null +++ b/tasks/format-code-task-000076/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_color_deconvolution.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000076/tests/test_command.sh b/tasks/format-code-task-000076/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000076/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000078/environment/Dockerfile b/tasks/format-code-task-000078/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cdde4c2cd4b44b4d1e0203d10d13bfe1e2c45f76 --- /dev/null +++ b/tasks/format-code-task-000078/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a5414de8f9504855344787400ecfe484631d88378f5e153229a32c4cc6ac7242 diff --git a/tasks/format-code-task-000078/environment/setup/files/blocklist b/tasks/format-code-task-000078/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000078/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000078/environment/setup/setup.sh b/tasks/format-code-task-000078/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000078/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000078/tests/test.patch b/tasks/format-code-task-000078/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3fc379cc6562200c165360ba4386010d087bbd77 --- /dev/null +++ b/tasks/format-code-task-000078/tests/test.patch @@ -0,0 +1,58 @@ +diff --git a/tests/e2e/configure.sh b/tests/e2e/configure.sh +index 5dd75410..4810268f 100755 +--- a/tests/e2e/configure.sh ++++ b/tests/e2e/configure.sh +@@ -20,7 +20,7 @@ beforeAll() { + } + + beforeEach() { +- rm -f ./temp-config ++ rm -rf ./temp-config ./temp-config-dir + } + + afterAll() { +@@ -70,6 +70,22 @@ config="$("$DOPPLER_BINARY" configure get config --configuration=./temp-config - + + beforeEach + ++ ++mkdir ./temp-config-dir ++"$DOPPLER_BINARY" configure set config 123 --config-dir=./temp-config-dir --scope=/ --silent ++config="$("$DOPPLER_BINARY" configure get config --configuration=./temp-config-dir/.doppler.yaml --scope=/ --plain)" ++[[ "$config" == "123" ]] || error "ERROR: config-dir not properly used" ++ ++beforeEach ++ ++ ++mkdir ./temp-config-dir ++"$DOPPLER_BINARY" configure set config 123 --config-dir=./temp-config-dir --configuration ./temp-config --scope=/ --silent ++config="$("$DOPPLER_BINARY" configure get config --configuration=./temp-config --scope=/ --plain)" ++[[ "$config" == "123" ]] || error "ERROR: configuration not properly used when specified with config-dir" ++ ++beforeEach ++ + # test unset + "$DOPPLER_BINARY" configure set config 123 --configuration=./temp-config --scope=/ --silent + "$DOPPLER_BINARY" configure unset config --configuration=./temp-config --scope=/ --silent +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SwU6DQBAGYM48xQTPsECFnnqwqYkmRmsPRk8NsNuFCCxZoNG3F6i2jYn2YBtj ++/L/LALPZnWXGidss50tRrplxKm5nHARD7HyOw7MX+J7vhmEXDdfzQtczKDhZRXvauok0kaGVar5b ++dyj/Rzm7/jeibpaJKoqo5E6dHu+MQ/0fjUe7/vvdd+889EYGuccr4Wv/vP8Jp6HxseCmeUbTfhqo ++SQVxVVW50BRnZaRfTalomBSy1TZl53yVR7KeWPYjyaxJ29jp5ofNNvmre5bkGaueJVsLXWeqdOZa ++SR0VD5vXCRdruz/coiLKSkeqvoRFWw4FJKpcZbLVgoQvqF9mipdK6YZmd/P5zeViOb2+vVg8TayP ++C7D3wiwzjup0e68h1qzbhW337Obb/O1fDwAAAAAAAAAAAAAAAAAAAADwY29RmGj0ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000078/tests/test.sh b/tasks/format-code-task-000078/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..82779151563b85d631b0c95acc282597b8965ab8 --- /dev/null +++ b/tasks/format-code-task-000078/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/e2e/configure.sh +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000078/tests/test_command.sh b/tasks/format-code-task-000078/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000078/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000082/environment/Dockerfile b/tasks/format-code-task-000082/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..21969e3995e8553c9b35255bd0843e532fe903a5 --- /dev/null +++ b/tasks/format-code-task-000082/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:eadb7b98150fdecfa17f54df7616bb6b2fb5067853f86a29f0f6788a2f52202d diff --git a/tasks/format-code-task-000082/environment/setup/files/blocklist b/tasks/format-code-task-000082/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000082/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000082/environment/setup/setup.sh b/tasks/format-code-task-000082/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000082/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000082/tests/test.patch b/tasks/format-code-task-000082/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..70453f9db7c32185bec6ba87594f8382325455ea --- /dev/null +++ b/tasks/format-code-task-000082/tests/test.patch @@ -0,0 +1,269 @@ +diff --git a/sei/sei_task_test.go b/sei/sei_task_test.go +new file mode 100644 +index 0000000..9bf152f +--- /dev/null ++++ b/sei/sei_task_test.go +@@ -0,0 +1,242 @@ ++package sei_test ++ ++import ( ++ "bytes" ++ "encoding/hex" ++ "strings" ++ "testing" ++ ++ "github.com/edgeware/mp4ff/sei" ++) ++ ++ ++ ++ ++ ++const seiHEVCHDR = "891800000300000300000300000300000300000300000300000300000300000300000300009004000003000080" ++ ++ ++ ++const sei0Hex = "0007810f1c0050744080" ++ ++func TestExtractSEIDataSingleMessage(t *testing.T) { ++ raw, err := hex.DecodeString(sei0Hex) ++ if err != nil { ++ t.Fatal(err) ++ } ++ datas, err := sei.ExtractSEIData(bytes.NewReader(raw)) ++ if err != nil { ++ t.Fatal(err) ++ } ++ if len(datas) != 1 { ++ t.Fatalf("got %d messages, want 1", len(datas)) ++ } ++ if datas[0].Type() != 0 { ++ t.Errorf("got type %d, want 0", datas[0].Type()) ++ } ++ if datas[0].Size() != 7 { ++ t.Errorf("got size %d, want 7", datas[0].Size()) ++ } ++ wantPayload, _ := hex.DecodeString("810f1c00507440") ++ if !bytes.Equal(datas[0].Payload(), wantPayload) { ++ t.Errorf("got payload %x, want %x", datas[0].Payload(), wantPayload) ++ } ++} ++ ++func TestExtractSEIDataMultiMessageWithEmulation(t *testing.T) { ++ raw, err := hex.DecodeString(seiHEVCHDR) ++ if err != nil { ++ t.Fatal(err) ++ } ++ datas, err := sei.ExtractSEIData(bytes.NewReader(raw)) ++ if err != nil { ++ t.Fatal(err) ++ } ++ if len(datas) != 2 { ++ t.Fatalf("got %d messages, want 2", len(datas)) ++ } ++ wantTypes := []uint{137, 144} ++ wantSizes := []uint{24, 4} ++ for i := range datas { ++ if datas[i].Type() != wantTypes[i] { ++ t.Errorf("message %d: got type %d, want %d", i, datas[i].Type(), wantTypes[i]) ++ } ++ if datas[i].Size() != wantSizes[i] { ++ t.Errorf("message %d: got size %d, want %d", i, datas[i].Size(), wantSizes[i]) ++ } ++ ++ if uint(len(datas[i].Payload())) != wantSizes[i] { ++ t.Errorf("message %d: payload len %d, want %d", i, len(datas[i].Payload()), wantSizes[i]) ++ } ++ } ++ ++ ++ for i := range datas { ++ msg, err := sei.DecodeSEIMessage(&datas[i], sei.HEVC) ++ if err != nil { ++ t.Fatal(err) ++ } ++ if msg.Type() != wantTypes[i] { ++ t.Errorf("decoded message %d: got type %d, want %d", i, msg.Type(), wantTypes[i]) ++ } ++ if !bytes.Equal(msg.Payload(), datas[i].Payload()) { ++ t.Errorf("decoded message %d: payload not round-tripped", i) ++ } ++ } ++} ++ ++func TestMasteringDisplayColourVolumeFields(t *testing.T) { ++ hex137 := "11223344556677889900aabbccddeeff0011223344556677" ++ pl, err := hex.DecodeString(hex137) ++ if err != nil { ++ t.Fatal(err) ++ } ++ msg, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIMasteringDisplayColourVolumeType, pl), sei.HEVC) ++ if err != nil { ++ t.Fatal(err) ++ } ++ if msg.Type() != sei.SEIMasteringDisplayColourVolumeType { ++ t.Errorf("got type %d, want %d", msg.Type(), sei.SEIMasteringDisplayColourVolumeType) ++ } ++ if msg.Size() != 24 { ++ t.Errorf("got size %d, want 24", msg.Size()) ++ } ++ m, ok := msg.(*sei.MasteringDisplayColourVolumeSEI) ++ if !ok { ++ t.Fatalf("decoded message is not *MasteringDisplayColourVolumeSEI, got %T", msg) ++ } ++ if m.DisplayPrimariesX != [3]uint16{0x1122, 0x5566, 0x9900} { ++ t.Errorf("DisplayPrimariesX = %v", m.DisplayPrimariesX) ++ } ++ if m.DisplayPrimariesY != [3]uint16{0x3344, 0x7788, 0xaabb} { ++ t.Errorf("DisplayPrimariesY = %v", m.DisplayPrimariesY) ++ } ++ if m.WhitePointX != 0xccdd || m.WhitePointY != 0xeeff { ++ t.Errorf("white point = (%#x, %#x)", m.WhitePointX, m.WhitePointY) ++ } ++ if m.MaxDisplayMasteringLuminance != 0x00112233 { ++ t.Errorf("MaxDisplayMasteringLuminance = %#x", m.MaxDisplayMasteringLuminance) ++ } ++ if m.MinDisplayMasteringLuminance != 0x44556677 { ++ t.Errorf("MinDisplayMasteringLuminance = %#x", m.MinDisplayMasteringLuminance) ++ } ++ if !bytes.Equal(msg.Payload(), pl) { ++ t.Errorf("payload round-trip mismatch: got %x, want %x", msg.Payload(), pl) ++ } ++} ++ ++func TestMasteringDisplayColourVolumeEncode(t *testing.T) { ++ m := &sei.MasteringDisplayColourVolumeSEI{ ++ DisplayPrimariesX: [3]uint16{1, 2, 3}, ++ DisplayPrimariesY: [3]uint16{4, 5, 6}, ++ WhitePointX: 7, ++ WhitePointY: 8, ++ MaxDisplayMasteringLuminance: 9, ++ MinDisplayMasteringLuminance: 10, ++ } ++ pl := m.Payload() ++ if len(pl) != 24 { ++ t.Fatalf("payload length %d, want 24", len(pl)) ++ } ++ msg, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIMasteringDisplayColourVolumeType, pl), sei.HEVC) ++ if err != nil { ++ t.Fatal(err) ++ } ++ d, ok := msg.(*sei.MasteringDisplayColourVolumeSEI) ++ if !ok { ++ t.Fatalf("decoded message is not *MasteringDisplayColourVolumeSEI, got %T", msg) ++ } ++ if *d != *m { ++ t.Errorf("round-trip mismatch: got %+v, want %+v", *d, *m) ++ } ++} ++ ++func TestMasteringDisplayColourVolumeSizeError(t *testing.T) { ++ for _, n := range []int{0, 23, 25} { ++ _, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIMasteringDisplayColourVolumeType, make([]byte, n)), sei.HEVC) ++ if err == nil { ++ t.Errorf("payload length %d: expected an error, got nil", n) ++ } ++ } ++} ++ ++func TestContentLightLevelFields(t *testing.T) { ++ hex144 := "11223344" ++ pl, err := hex.DecodeString(hex144) ++ if err != nil { ++ t.Fatal(err) ++ } ++ msg, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIContentLightLevelInformationType, pl), sei.HEVC) ++ if err != nil { ++ t.Fatal(err) ++ } ++ if msg.Type() != sei.SEIContentLightLevelInformationType { ++ t.Errorf("got type %d, want %d", msg.Type(), sei.SEIContentLightLevelInformationType) ++ } ++ if msg.Size() != 4 { ++ t.Errorf("got size %d, want 4", msg.Size()) ++ } ++ c, ok := msg.(*sei.ContentLightLevelInformationSEI) ++ if !ok { ++ t.Fatalf("decoded message is not *ContentLightLevelInformationSEI, got %T", msg) ++ } ++ if c.MaxContentLightLevel != 0x1122 { ++ t.Errorf("MaxContentLightLevel = %#x", c.MaxContentLightLevel) ++ } ++ if c.MaxPicAverageLightLevel != 0x3344 { ++ t.Errorf("MaxPicAverageLightLevel = %#x", c.MaxPicAverageLightLevel) ++ } ++ if !bytes.Equal(msg.Payload(), pl) { ++ t.Errorf("payload round-trip mismatch: got %x, want %x", msg.Payload(), pl) ++ } ++} ++ ++func TestContentLightLevelSizeError(t *testing.T) { ++ for _, n := range []int{0, 3, 5} { ++ _, err := sei.DecodeSEIMessage(sei.NewSEIData(sei.SEIContentLightLevelInformationType, make([]byte, n)), sei.HEVC) ++ if err == nil { ++ t.Errorf("payload length %d: expected an error, got nil", n) ++ } ++ } ++} ++ ++func TestGenericFallback(t *testing.T) { ++ pl, _ := hex.DecodeString("deadbeef") ++ for _, codec := range []sei.Codec{sei.AVC, sei.HEVC} { ++ msg, err := sei.DecodeSEIMessage(sei.NewSEIData(99, pl), codec) ++ if err != nil { ++ t.Fatalf("unexpected error for unknown type: %v", err) ++ } ++ if msg.Type() != 99 { ++ t.Errorf("got type %d, want 99", msg.Type()) ++ } ++ if msg.Size() != 4 { ++ t.Errorf("got size %d, want 4", msg.Size()) ++ } ++ if !bytes.Equal(msg.Payload(), pl) { ++ t.Errorf("payload mismatch: got %x, want %x", msg.Payload(), pl) ++ } ++ } ++} ++ ++func TestSEITypeString(t *testing.T) { ++ cases := []struct { ++ id uint ++ want string ++ }{ ++ {sei.SEIPicTimingType, "SEIPicTimingType (1)"}, ++ {sei.SEIMasteringDisplayColourVolumeType, "SEIMasteringDisplayColourVolumeType (137)"}, ++ {sei.SEIContentLightLevelInformationType, "SEIContentLightLevelInformationType (144)"}, ++ } ++ for _, tc := range cases { ++ got := sei.SEIType(tc.id).String() ++ if got != tc.want { ++ t.Errorf("SEIType(%d).String() = %q, want %q", tc.id, got, tc.want) ++ } ++ } ++ ++ got := sei.SEIType(200).String() ++ if !strings.HasSuffix(got, "(200)") { ++ t.Errorf("SEIType(200).String() = %q, want suffix %q", got, "(200)") ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++go test ./bits/ ./avc/ ./hevc/ ++ ++ ++go test ./sei/ diff --git a/tasks/format-code-task-000082/tests/test.sh b/tasks/format-code-task-000082/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..860d81000aab5cca9b12d8845a4fb8c8f2b3ed61 --- /dev/null +++ b/tasks/format-code-task-000082/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +sei/sei_task_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000082/tests/test_command.sh b/tasks/format-code-task-000082/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000082/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000085/environment/Dockerfile b/tasks/format-code-task-000085/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8f89504ada33e6981b73a1a8771cb1a39f78da72 --- /dev/null +++ b/tasks/format-code-task-000085/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a11491cccf73e66a7e48338d50bd3787a1d7ebb25b096a0a00b185889bd9034a diff --git a/tasks/format-code-task-000085/environment/setup/files/blocklist b/tasks/format-code-task-000085/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000085/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000085/environment/setup/setup.sh b/tasks/format-code-task-000085/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000085/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000085/tests/test.patch b/tasks/format-code-task-000085/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8f25b00eea157d322ef508c6bcc988cd9065988c --- /dev/null +++ b/tasks/format-code-task-000085/tests/test.patch @@ -0,0 +1,186 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..453e98edd +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/envs/test_env_implementation.py -k taxi -v"] ++} +diff --git a/tests/envs/test_env_implementation.py b/tests/envs/test_env_implementation.py +index f9ae75328..445190694 100644 +--- a/tests/envs/test_env_implementation.py ++++ b/tests/envs/test_env_implementation.py +@@ -365,3 +365,159 @@ def test_discrete_action_validation(env_id): + discrete_action = discrete_env.action_space.sample() + discrete_env.step(discrete_action) + discrete_env.close() ++ ++ ++def test_taxi_constructor_signature_defaults(): ++ """`is_rainy` and `fickle_passenger` exist on TaxiEnv.__init__ and default to False.""" ++ import inspect ++ ++ sig = inspect.signature(TaxiEnv.__init__) ++ assert "is_rainy" in sig.parameters ++ assert "fickle_passenger" in sig.parameters ++ assert sig.parameters["is_rainy"].default is False ++ assert sig.parameters["fickle_passenger"].default is False ++ ++ ++ env = TaxiEnv() ++ env.close() ++ ++ env_rainy = TaxiEnv(is_rainy=True) ++ env_rainy.close() ++ env_fickle = TaxiEnv(fickle_passenger=True) ++ env_fickle.close() ++ ++ ++def test_taxi_default_transitions_are_deterministic(): ++ """Without flags, every entry of env.P has exactly one transition with prob 1.0.""" ++ env = TaxiEnv() ++ for state in env.P: ++ for action in env.P[state]: ++ transitions = env.P[state][action] ++ assert len(transitions) == 1, ( ++ f"default Taxi P[{state}][{action}] should have 1 transition, " ++ f"got {len(transitions)}" ++ ) ++ prob = transitions[0][0] ++ assert prob == 1.0 ++ ++ ++def test_taxi_rainy_movement_transitions(): ++ """is_rainy=True: movement actions (0..3) have 3 entries with probs 0.8, 0.1, 0.1.""" ++ env = TaxiEnv(is_rainy=True) ++ for state in env.P: ++ for action in range(4): ++ transitions = env.P[state][action] ++ assert len(transitions) == 3, ( ++ f"rainy Taxi P[{state}][{action}] should have 3 transitions, " ++ f"got {len(transitions)}" ++ ) ++ probs = sorted(t[0] for t in transitions) ++ ++ assert probs == [pytest.approx(0.1), pytest.approx(0.1), pytest.approx(0.8)] ++ assert sum(t[0] for t in transitions) == pytest.approx(1.0) ++ ++ ++def test_taxi_rainy_intended_direction_has_highest_prob(): ++ """is_rainy=True: for movement actions the intended destination state carries 0.8 prob.""" ++ env_dry = TaxiEnv() ++ env_rainy = TaxiEnv(is_rainy=True) ++ ++ state = env_dry.encode(2, 2, 0, 1) ++ for action in range(4): ++ ++ intended_next = env_dry.P[state][action][0][1] ++ rainy_transitions = env_rainy.P[state][action] ++ ++ big_prob_states = [s for p, s, _, _ in rainy_transitions if p == pytest.approx(0.8)] ++ assert len(big_prob_states) == 1 ++ assert big_prob_states[0] == intended_next, ( ++ f"rainy intended next state for action {action} mismatches dry version" ++ ) ++ ++ ++def test_taxi_rainy_pickup_and_dropoff_remain_deterministic(): ++ """is_rainy=True: pickup (4) and dropoff (5) actions still have prob 1.0 single transitions.""" ++ env = TaxiEnv(is_rainy=True) ++ for state in env.P: ++ for action in (4, 5): ++ transitions = env.P[state][action] ++ assert len(transitions) == 1, ( ++ f"rainy Taxi P[{state}][{action}] for pickup/dropoff should have 1 transition, " ++ f"got {len(transitions)}" ++ ) ++ assert transitions[0][0] == 1.0 ++ ++ ++def test_taxi_fickle_passenger_can_change_destination_after_first_move(): ++ """fickle_passenger=True: after pickup + a few movements, the destination may change. ++ ++ The issue spec says the destination changes with probability 0.3 once the taxi has ++ picked up the passenger and moved. The exact step on which the change occurs (the ++ very first move vs. a subsequent move while one square away) is not pinned down by ++ the issue, so we run a few movements and check that across many seeds the destination ++ has changed in a non-trivial fraction of trials. ++ """ ++ trials = 300 ++ changed = 0 ++ for seed in range(trials): ++ env = TaxiEnv(fickle_passenger=True) ++ env.reset(seed=seed) ++ ++ env.unwrapped.s = env.unwrapped.encode(0, 0, 0, 1) ++ ++ obs, _, _, _, _ = env.step(4) ++ _, _, pass_loc, _ = env.unwrapped.decode(obs) ++ assert pass_loc == 4, "passenger should be inside the taxi after pickup" ++ ++ ++ ++ moves = [0, 1, 0, 1, 0] ++ dest = 1 ++ for a in moves: ++ obs, _, _, _, _ = env.step(a) ++ _, _, _, dest = env.unwrapped.decode(obs) ++ if dest != 1: ++ break ++ if dest != 1: ++ changed += 1 ++ env.close() ++ ++ assert 20 < changed < trials, ( ++ f"fickle_passenger destination changes happened {changed}/{trials} times; " ++ "expected destination to change in a non-trivial fraction of trials." ++ ) ++ ++ ++def test_taxi_non_fickle_destination_never_changes(): ++ """fickle_passenger=False (default): destination stays fixed across many pickups+moves.""" ++ for seed in range(50): ++ env = TaxiEnv() ++ env.reset(seed=seed) ++ env.unwrapped.s = env.unwrapped.encode(0, 0, 0, 1) ++ obs, _, _, _, _ = env.step(4) ++ ++ for a in (0, 1, 0, 1, 0): ++ obs, _, _, _, _ = env.step(a) ++ _, _, _, dest = env.unwrapped.decode(obs) ++ assert dest == 1, ( ++ f"non-fickle Taxi destination should remain 1 (got {dest}) for seed={seed}" ++ ) ++ env.close() ++ ++ ++def test_taxi_rainy_step_info_prob_is_consistent_with_P(): ++ """is_rainy=True: step() returns info['prob'] equal to the sampled transition's prob in P.""" ++ env = TaxiEnv(is_rainy=True) ++ env.reset(seed=123) ++ for _ in range(50): ++ a = env.action_space.sample() ++ before_state = env.unwrapped.s ++ obs, _, term, _, info = env.step(a) ++ ++ allowed_probs = {t[0] for t in env.unwrapped.P[before_state][a]} ++ assert info["prob"] in allowed_probs, ( ++ f"step prob {info['prob']} not in P[{before_state}][{a}] probs {allowed_probs}" ++ ) ++ if term: ++ env.reset(seed=123) ++ env.close() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/envs/test_env_implementation.py -k taxi -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000085/tests/test.sh b/tasks/format-code-task-000085/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c9f89798c8e5d3b2f9c2af0a5a05bc6672f813c --- /dev/null +++ b/tasks/format-code-task-000085/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/envs/test_env_implementation.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000085/tests/test_command.sh b/tasks/format-code-task-000085/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000085/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000211/environment/Dockerfile b/tasks/format-code-task-000211/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..296a4346127bb0f2d3a014b12480c3f178d22d48 --- /dev/null +++ b/tasks/format-code-task-000211/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3cdaa4fe016c918896bc7796b32a15357bfc3f64630d323e7fece890806fc855 diff --git a/tasks/format-code-task-000211/environment/setup/files/blocklist b/tasks/format-code-task-000211/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000211/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000211/environment/setup/setup.sh b/tasks/format-code-task-000211/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000211/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000211/tests/test.patch b/tasks/format-code-task-000211/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ac404f0f4ced61204cebcd02696f8243d6ab7a42 --- /dev/null +++ b/tasks/format-code-task-000211/tests/test.patch @@ -0,0 +1,368 @@ +diff --git a/posthog/temporal/tests/data_imports/pipelines/source/test_config.py b/posthog/temporal/tests/data_imports/pipelines/source/test_config.py +new file mode 100644 +index 00000000000..e437b465999 +--- /dev/null ++++ b/posthog/temporal/tests/data_imports/pipelines/source/test_config.py +@@ -0,0 +1,336 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++import dataclasses ++import importlib.util ++import os ++import sys ++import unittest ++ ++def _find_repo_root(start): ++ cur = os.path.abspath(start) ++ while True: ++ if os.path.isdir(os.path.join(cur, "posthog", "temporal", "data_imports")): ++ return cur ++ parent = os.path.dirname(cur) ++ if parent == cur: ++ raise RuntimeError("Could not locate repository root") ++ cur = parent ++ ++ ++MODULE_PATH = os.path.join( ++ _find_repo_root(os.path.dirname(__file__)), ++ "posthog", ++ "temporal", ++ "data_imports", ++ "pipelines", ++ "source", ++ "config.py", ++) ++ ++ ++def _load_config_module(): ++ parent = os.path.dirname(MODULE_PATH) ++ if parent not in sys.path: ++ sys.path.insert(0, parent) ++ spec = importlib.util.spec_from_file_location("source_config_under_test", MODULE_PATH) ++ module = importlib.util.module_from_spec(spec) ++ sys.modules[spec.name] = module ++ assert spec.loader is not None ++ spec.loader.exec_module(module) ++ return module ++ ++ ++config_module = _load_config_module() ++config = config_module.config ++value = config_module.value ++str_to_bool = config_module.str_to_bool ++ ++ ++class TestDecoratorBasics(unittest.TestCase): ++ def test_bare_decorator_produces_dataclass(self): ++ @config ++ class A: ++ x: int ++ y: str ++ ++ self.assertTrue(dataclasses.is_dataclass(A)) ++ a = A(x=1, y="hi") ++ self.assertEqual(a.x, 1) ++ self.assertEqual(a.y, "hi") ++ ++ self.assertEqual(a, A(x=1, y="hi")) ++ self.assertNotEqual(a, A(x=2, y="hi")) ++ self.assertIn("x=1", repr(a)) ++ ++ def test_decorator_with_call_no_args(self): ++ @config() ++ class A: ++ x: int = 5 ++ ++ self.assertTrue(dataclasses.is_dataclass(A)) ++ self.assertEqual(A().x, 5) ++ ++ def test_from_dict_is_classmethod_returning_instance(self): ++ @config ++ class A: ++ x: int ++ y: str ++ ++ a = A.from_dict({"x": 1, "y": "hi"}) ++ self.assertIsInstance(a, A) ++ self.assertEqual(a, A(x=1, y="hi")) ++ ++ ++class TestFlatScalarFields(unittest.TestCase): ++ def test_fields_read_by_name(self): ++ @config ++ class A: ++ host: str ++ port: int ++ ++ a = A.from_dict({"host": "localhost", "port": 5432}) ++ self.assertEqual(a.host, "localhost") ++ self.assertEqual(a.port, 5432) ++ ++ def test_extra_keys_ignored(self): ++ @config ++ class A: ++ host: str ++ ++ a = A.from_dict({"host": "localhost", "unrelated": "ignored", "foo": 1}) ++ self.assertEqual(a.host, "localhost") ++ ++ def test_absent_field_uses_default(self): ++ @config ++ class A: ++ host: str = "default-host" ++ ++ self.assertEqual(A.from_dict({}).host, "default-host") ++ self.assertEqual(A.from_dict({"host": "other"}).host, "other") ++ ++ def test_missing_required_field_raises_type_error(self): ++ @config ++ class A: ++ host: str ++ ++ with self.assertRaises(TypeError): ++ A.from_dict({}) ++ ++ ++class TestClassLevelPrefix(unittest.TestCase): ++ def test_prefix_applied_to_every_field(self): ++ @config(prefix="db") ++ class A: ++ host: str ++ port: int ++ ++ a = A.from_dict({"db_host": "localhost", "db_port": 5432}) ++ self.assertEqual(a.host, "localhost") ++ self.assertEqual(a.port, 5432) ++ ++ def test_unprefixed_key_not_used(self): ++ @config(prefix="db") ++ class A: ++ host: str = "fallback" ++ ++ ++ self.assertEqual(A.from_dict({"host": "nope"}).host, "fallback") ++ ++ ++class TestValueHelper(unittest.TestCase): ++ def test_default(self): ++ @config ++ class A: ++ x: int = value(default=10) ++ ++ self.assertEqual(A.from_dict({}).x, 10) ++ self.assertEqual(A.from_dict({"x": 3}).x, 3) ++ ++ def test_default_factory(self): ++ @config ++ class A: ++ items: list = value(default_factory=list) ++ ++ a = A.from_dict({}) ++ self.assertEqual(a.items, []) ++ b = A.from_dict({}) ++ ++ a.items.append(1) ++ self.assertEqual(b.items, []) ++ ++ def test_alias(self): ++ @config ++ class A: ++ host: str = value(alias="server") ++ ++ self.assertEqual(A.from_dict({"server": "h"}).host, "h") ++ ++ def test_field_prefix(self): ++ @config ++ class A: ++ host: str = value(prefix="db") ++ ++ self.assertEqual(A.from_dict({"db_host": "h"}).host, "h") ++ ++ def test_converter_applied_to_value(self): ++ @config ++ class A: ++ n: int = value(converter=lambda s: int(s) * 2) ++ ++ self.assertEqual(A.from_dict({"n": "5"}).n, 10) ++ ++ def test_converter_not_applied_to_default(self): ++ calls = [] ++ ++ def conv(x): ++ calls.append(x) ++ return x ++ ++ @config ++ class A: ++ n: int = value(default=7, converter=conv) ++ ++ self.assertEqual(A.from_dict({}).n, 7) ++ self.assertEqual(calls, []) ++ ++ ++class TestStrToBool(unittest.TestCase): ++ def test_bool_passthrough(self): ++ self.assertIs(str_to_bool(True), True) ++ self.assertIs(str_to_bool(False), False) ++ ++ def test_truthy_strings(self): ++ for s in ["true", "True", "TRUE", "yes", "Yes", "1"]: ++ self.assertIs(str_to_bool(s), True, s) ++ ++ def test_falsey_strings(self): ++ for s in ["false", "no", "0", "", "maybe", "2"]: ++ self.assertIs(str_to_bool(s), False, s) ++ ++ def test_usable_as_converter(self): ++ @config ++ class A: ++ flag: bool = value(converter=str_to_bool) ++ ++ self.assertIs(A.from_dict({"flag": "yes"}).flag, True) ++ self.assertIs(A.from_dict({"flag": "no"}).flag, False) ++ ++ ++class TestNestedDict(unittest.TestCase): ++ def test_nested_sub_dict_by_field_name(self): ++ @config ++ class Inner: ++ host: str ++ port: int ++ ++ @config ++ class Outer: ++ inner: Inner ++ ++ a = Outer.from_dict({"inner": {"host": "h", "port": 1}}) ++ self.assertEqual(a.inner, Inner(host="h", port=1)) ++ ++ def test_nested_sub_dict_by_alias(self): ++ @config ++ class Inner: ++ host: str ++ ++ @config ++ class Outer: ++ inner: Inner = value(alias="connection") ++ ++ a = Outer.from_dict({"connection": {"host": "h"}}) ++ self.assertEqual(a.inner.host, "h") ++ ++ ++class TestNestedFlatDerivedPrefix(unittest.TestCase): ++ def test_simple_derived_prefix(self): ++ @config ++ class DatabaseConnection: ++ host: str ++ port: int ++ ++ @config ++ class Outer: ++ db: DatabaseConnection ++ ++ a = Outer.from_dict({"database_connection_host": "h", "database_connection_port": 9}) ++ self.assertEqual(a.db, DatabaseConnection(host="h", port=9)) ++ ++ def test_consecutive_capitals_prefix(self): ++ @config ++ class SSHTunnel: ++ host: str ++ ++ @config ++ class Outer: ++ tunnel: SSHTunnel ++ ++ a = Outer.from_dict({"ssh_tunnel_host": "h"}) ++ self.assertEqual(a.tunnel.host, "h") ++ ++ def test_trailing_config_word_dropped(self): ++ @config ++ class SSHTunnelConfig: ++ host: str ++ ++ @config ++ class Outer: ++ tunnel: SSHTunnelConfig ++ ++ a = Outer.from_dict({"ssh_tunnel_host": "h"}) ++ self.assertEqual(a.tunnel.host, "h") ++ ++ ++class TestNestedFlatExplicitPrefix(unittest.TestCase): ++ def test_class_level_prefix_overrides_derived(self): ++ @config(prefix="tun") ++ class SSHTunnel: ++ host: str ++ ++ @config ++ class Outer: ++ tunnel: SSHTunnel ++ ++ a = Outer.from_dict({"tun_host": "h"}) ++ self.assertEqual(a.tunnel.host, "h") ++ ++ def test_field_level_prefix_overrides_class_prefix(self): ++ @config(prefix="tun") ++ class SSHTunnel: ++ host: str ++ ++ @config ++ class Outer: ++ tunnel: SSHTunnel = value(prefix="override") ++ ++ a = Outer.from_dict({"override_host": "h"}) ++ self.assertEqual(a.tunnel.host, "h") ++ ++ ++class TestNestedAccumulatingPrefix(unittest.TestCase): ++ def test_double_nesting_accumulates_prefixes(self): ++ @config ++ class Credentials: ++ user: str ++ ++ @config ++ class DatabaseConnection: ++ creds: Credentials ++ ++ @config ++ class Outer: ++ db: DatabaseConnection ++ ++ a = Outer.from_dict({"database_connection_credentials_user": "alice"}) ++ self.assertEqual(a.db.creds.user, "alice") ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++PY=python3.11 ++ ++ ++ ++$PY -m py_compile \ ++ posthog/temporal/data_imports/pipelines/source/sql.py \ ++ posthog/temporal/data_imports/pipelines/source/__init__.py ++ ++ ++cd posthog/temporal/tests/data_imports/pipelines/source ++$PY -m unittest test_config diff --git a/tasks/format-code-task-000211/tests/test.sh b/tasks/format-code-task-000211/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..41c0f4e1ba25302482ed0925f03ce72b58922fdf --- /dev/null +++ b/tasks/format-code-task-000211/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +posthog/temporal/tests/data_imports/pipelines/source/test_config.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000211/tests/test_command.sh b/tasks/format-code-task-000211/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000211/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000218/environment/Dockerfile b/tasks/format-code-task-000218/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8c067a71bc1cd7d83e3e70078811e2075746ea68 --- /dev/null +++ b/tasks/format-code-task-000218/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fc72b32f1634ad850fba62a1067443e8e87407cab23cf0477f811aaad19dfabc diff --git a/tasks/format-code-task-000218/environment/setup/files/blocklist b/tasks/format-code-task-000218/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000218/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000218/environment/setup/setup.sh b/tasks/format-code-task-000218/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000218/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000218/tests/test.patch b/tasks/format-code-task-000218/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5b6474b28aa1f2e67b7a46d392793c4ab19b4f91 --- /dev/null +++ b/tasks/format-code-task-000218/tests/test.patch @@ -0,0 +1,47 @@ +diff --git a/tests/RuleTest.php b/tests/RuleTest.php +index 4467a7a..92d1133 100644 +--- a/tests/RuleTest.php ++++ b/tests/RuleTest.php +@@ -183,6 +183,22 @@ public function it_converts_string_validation_parameters() + $this->assertEquals(['mobile', 'fixed_line'], $this->getProtectedProperty($rule, 'blockedTypes')); + } + ++ /** @test */ ++ public function it_allows_data_field_names_to_be_parameters() ++ { ++ $base = (new Phone)->setValidator(validator([ ++ 'mobile' => null, ++ 'fixed_line' => null, ++ 'lenient' => null, ++ 'international' => null, ++ ])); ++ ++ $rule = $base->setParameters(['mobile', 'fixed_line', 'lenient', 'international']); ++ $this->assertEquals(['mobile', 'fixed_line'], $this->getProtectedProperty($rule, 'allowedTypes')); ++ $this->assertTrue($this->getProtectedProperty($rule, 'lenient')); ++ $this->assertTrue($this->getProtectedProperty($rule, 'international')); ++ } ++ + /** @test */ + public function it_treats_string_validation_parameters_case_insensitive() + { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3R0QqCMBTGca97ij3B5kTXe0T3oW6gUDN0+vwtuzCC8qaI6P+7OYdzBjvwyWps ++j/bg/KSST0mjbVHMNXqsc6+LTGfp1uhcJ6nWJo5E8bGL7oxDKHshkr7rwqt3a/sfJZf8gxvCoe5O ++p9JbOTTv+2M1f5Mv+es417mJRaTvO+G5P8+/tmIOvnJ2I9XkvO16VbVenZvz6NsgrstB7caj28dO ++xvHm2zcDAAAAAAAAAAAAAAAAuLkAuQ8QawAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000218/tests/test.sh b/tasks/format-code-task-000218/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5bb0ac531f0c5f3e1617bc251ac04fc2189edf30 --- /dev/null +++ b/tasks/format-code-task-000218/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/RuleTest.php +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000218/tests/test_command.sh b/tasks/format-code-task-000218/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000218/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000219/environment/Dockerfile b/tasks/format-code-task-000219/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..38184ba27a9ed6c679af2a39b4918b01c65f849f --- /dev/null +++ b/tasks/format-code-task-000219/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2df961d81e8f1a1ca1ab13309cd5296812c9dfcb85fc26d9564356dc31dca312 diff --git a/tasks/format-code-task-000219/environment/setup/files/blocklist b/tasks/format-code-task-000219/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000219/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000219/environment/setup/setup.sh b/tasks/format-code-task-000219/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000219/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000219/tests/test.patch b/tasks/format-code-task-000219/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d6bbf4dabd27c7635a950602089ebba76c7853d2 --- /dev/null +++ b/tasks/format-code-task-000219/tests/test.patch @@ -0,0 +1,57 @@ +diff --git a/featurex/tests/test_core.py b/featurex/tests/test_core.py +index f77943d2..af6c99ee 100644 +--- a/featurex/tests/test_core.py ++++ b/featurex/tests/test_core.py +@@ -3,7 +3,7 @@ + from featurex.stimuli.video import VideoStim + from featurex.extractors.image import FaceDetectionExtractor + from featurex.export import FSLExporter +-from featurex.core import Timeline ++from featurex.core import Timeline, Value, Event + from featurex.lazy import extract + from os.path import join + import tempfile +@@ -33,3 +33,14 @@ def test_lazy_extraction(self): + assert isinstance(results[0], Timeline) + textfile = join(_get_test_data_path(), 'text', 'scandal.txt') + results = extract([textfile], ['basicstatsextractorcollection']) ++ ++ def test_dummy_code_timeline(self): ++ data = [{'A': 12.0, 'B': 'abc'}, { 'A': 7, 'B': 'def'}, { 'C': 40 }] ++ events = [Event(values=[Value(None, None, x)], duration=1) for x in data] ++ tl = Timeline(events=events, period=1) ++ self.assertEqual(tl.to_df().shape, (5, 4)) ++ tl_dummy = tl.dummy_code() ++ self.assertEqual(tl_dummy.to_df().shape, (7, 4)) ++ tl = Timeline(events=events, period=1) ++ tl_dummy = tl.dummy_code(string_only=False) ++ self.assertEqual(tl_dummy.to_df().shape, (9, 4)) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,13 @@ ++H4sIAAAAAAAAA+2UUU/bMBDH+5xPceseClKTJqUtUge8IHhGE2/TVLnJpbWU2FHshFbiw+/sprQD ++bWwaaJp2v4ckts/23/+7OFo2ssgWqNpR772IifPp1L+J52//nUzHSTI7i88ns15MX/GsB9N3U3RE ++Y6yoAXq11vZnca+N/6NEh/xbNHaR6rIUKovM+u32eCX/4zhOnvI/m55T/iezZNKD+O0k/Jj/PP9p ++Bj7xS8yC4CPcKNPUCA84oGdjpFrB3dautYKzKEngRCFmmEGua1BNWW3hApJoPAEqm0pYuZSFtNvT ++IMM2NA/Spmuo/PSz3fzx1YiGRqopCnh8BFs36Ha9rlFYhFbWthEFUDHKWqsSlQWZg7SQaTRqYAE3 ++0tiA+r7ABwgP0kdRS5Pg6yewa1QBEPt9wxL82PehPsTopk7x2choKdVIpFa2JGm3kqxAKioTEm3Q ++NpXVujAvhvrekKtL8iMeXjhX+mBSSR5V9EMJA0ZuOlVhKVYyBV2hStuw61ujyAo0xsWQIFDavNw/ ++DJUO/S8bSqMLspxSEyJEARZd+C+cKpfO9Tvh8oObStc2IplWg0hTrKwzEbKmLLd0HWRI+mtRosWa ++voyh9C9d8CLLT05pmXsKvvs8MOBj07VQKzQkmNo1Rv74dKij5Wife1liIRXe+M2xjmzXsejWHdLC ++y8YeqduXQCeRimKLNoJbMtXJNXKlhKXajQKnMJTQN1RrOTxbed8cuhouhb0cFFqtBqfz3wgeHp3m ++8laQ8TS9f3A8R69kM3pS7+z+3CivlK6bFZLHLse5LBBCMBWmMpcpZXi7i3GDIss6r73Dwa5OXEF3 ++FfK0j2uZ/f3tTZ/P76l1TY353PcfFC/2p4Jw05rgb19ADMMwDMMwDMMwDMMwDMMwDMMwDMMwDMP8 ++Md8ARHYjfgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000219/tests/test.sh b/tasks/format-code-task-000219/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f651f7ca09bce48671f6038528fe34e440aa00c1 --- /dev/null +++ b/tasks/format-code-task-000219/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +featurex/tests/test_core.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000219/tests/test_command.sh b/tasks/format-code-task-000219/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000219/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000220/environment/Dockerfile b/tasks/format-code-task-000220/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..82d025ba72cc1386ff1e178555ed90cab3cc2ce9 --- /dev/null +++ b/tasks/format-code-task-000220/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dcb9efa91b0c4517eb32db7ea11f61f8b3e1822d724ef7c861d5e58ee80b1a83 diff --git a/tasks/format-code-task-000220/environment/setup/files/blocklist b/tasks/format-code-task-000220/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000220/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000220/environment/setup/setup.sh b/tasks/format-code-task-000220/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000220/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000220/tests/test.patch b/tasks/format-code-task-000220/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..eaf69803a4e8f0de22bed391df36fc832cfce737 --- /dev/null +++ b/tasks/format-code-task-000220/tests/test.patch @@ -0,0 +1,300 @@ +diff --git a/tests/test_usage_manager.py b/tests/test_usage_manager.py +new file mode 100644 +index 0000000..0f050a5 +--- /dev/null ++++ b/tests/test_usage_manager.py +@@ -0,0 +1,261 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++"""Tests for usage tracking and the cleanup of stale virtualenvs.""" ++ ++import importlib ++import os ++import pkgutil ++import tempfile ++import unittest ++from datetime import datetime, timedelta ++ ++import fades ++from fades import cache ++ ++DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%f" ++ ++ ++def get_usage_manager_class(): ++ """Locate the UsageManager class wherever it lives in the fades package.""" ++ for _, modname, _ in pkgutil.iter_modules(fades.__path__, fades.__name__ + '.'): ++ if modname.rsplit('.', 1)[-1] == '__main__': ++ continue ++ try: ++ module = importlib.import_module(modname) ++ except Exception: ++ continue ++ cls = getattr(module, 'UsageManager', None) ++ if cls is not None: ++ return cls ++ raise AssertionError("Could not find a UsageManager class in the fades package") ++ ++ ++class BaseTestCase(unittest.TestCase): ++ """Common helpers.""" ++ ++ def setUp(self): ++ self.UsageManager = get_usage_manager_class() ++ ++ self.basedir = tempfile.mkdtemp(prefix="test-fades-base") ++ ++ fd, self.cache_path = tempfile.mkstemp(prefix="test-fades-cache") ++ os.close(fd) ++ self.addCleanup(lambda: os.path.exists(self.cache_path) and os.remove(self.cache_path)) ++ ++ self.stat_path = os.path.join(self.basedir, 'usage_stats') ++ self.venvscache = cache.VEnvsCache(self.cache_path) ++ ++ def make_venv(self, uuid, create_dir=True): ++ """Register a venv in the cache (and optionally create its dir on disk).""" ++ env_path = os.path.join(self.basedir, uuid) ++ if create_dir: ++ os.makedirs(env_path, exist_ok=True) ++ metadata = { ++ 'env_path': env_path, ++ 'env_bin_path': os.path.join(env_path, 'bin'), ++ 'pip_installed': True, ++ } ++ self.venvscache.store({}, metadata, 'pythonX.Y', options={}) ++ return env_path ++ ++ def read_usage_lines(self): ++ with open(self.stat_path, 'rt') as fh: ++ return [line.strip() for line in fh if line.strip()] ++ ++ def write_usage(self, records): ++ """Write usage records; records is a list of (uuid, datetime).""" ++ with open(self.stat_path, 'wt') as fh: ++ for uuid, when in records: ++ fh.write('{} {}\n'.format(uuid, datetime.strftime(when, DATE_FORMAT))) ++ ++ ++class GetVenvsMetadataTestCase(BaseTestCase): ++ """The cache exposes the metadata of every stored venv.""" ++ ++ def test_empty_cache(self): ++ self.assertEqual(list(self.venvscache.get_venvs_metadata()), []) ++ ++ def test_yields_all_metadata(self): ++ p1 = self.make_venv('uuid-1') ++ p2 = self.make_venv('uuid-2') ++ p3 = self.make_venv('uuid-3') ++ ++ result = list(self.venvscache.get_venvs_metadata()) ++ env_paths = sorted(m['env_path'] for m in result) ++ self.assertEqual(env_paths, sorted([p1, p2, p3])) ++ ++ by_path = {m['env_path']: m for m in result} ++ self.assertEqual(by_path[p1]['env_bin_path'], os.path.join(p1, 'bin')) ++ ++ ++class InitTestCase(BaseTestCase): ++ """Seeding of the usage stats file on construction.""" ++ ++ def test_seeds_file_when_missing(self): ++ self.make_venv('uuid-1') ++ self.make_venv('uuid-2') ++ self.assertFalse(os.path.exists(self.stat_path)) ++ ++ before = datetime.utcnow() ++ self.UsageManager(self.stat_path, self.venvscache) ++ after = datetime.utcnow() ++ ++ self.assertTrue(os.path.exists(self.stat_path)) ++ lines = self.read_usage_lines() ++ self.assertEqual(len(lines), 2) ++ seen = {} ++ for line in lines: ++ uuid, stamp = line.split() ++ seen[uuid] = datetime.strptime(stamp, DATE_FORMAT) ++ self.assertEqual(set(seen), {'uuid-1', 'uuid-2'}) ++ for when in seen.values(): ++ self.assertTrue(before - timedelta(seconds=5) <= when <= after + timedelta(seconds=5)) ++ ++ def test_seeds_empty_when_no_venvs(self): ++ self.UsageManager(self.stat_path, self.venvscache) ++ self.assertTrue(os.path.exists(self.stat_path)) ++ self.assertEqual(self.read_usage_lines(), []) ++ ++ def test_does_not_touch_existing_file(self): ++ self.make_venv('uuid-1') ++ old = datetime.utcnow() - timedelta(days=5) ++ self.write_usage([('some-old-uuid', old)]) ++ original = self.read_usage_lines() ++ ++ self.UsageManager(self.stat_path, self.venvscache) ++ ++ self.assertEqual(self.read_usage_lines(), original) ++ ++ ++class StoreUsageStatTestCase(BaseTestCase): ++ """Recording usage appends a record.""" ++ ++ def test_appends_record(self): ++ env_path = self.make_venv('uuid-1') ++ manager = self.UsageManager(self.stat_path, self.venvscache) ++ ++ self.assertEqual(len(self.read_usage_lines()), 1) ++ ++ before = datetime.utcnow() ++ manager.store_usage_stat({'env_path': env_path}) ++ after = datetime.utcnow() ++ ++ lines = self.read_usage_lines() ++ self.assertEqual(len(lines), 2) ++ uuid, stamp = lines[-1].split() ++ self.assertEqual(uuid, 'uuid-1') ++ when = datetime.strptime(stamp, DATE_FORMAT) ++ self.assertTrue(before - timedelta(seconds=5) <= when <= after + timedelta(seconds=5)) ++ ++ def test_appends_without_dropping_others(self): ++ self.make_venv('uuid-1') ++ env_path2 = self.make_venv('uuid-2') ++ manager = self.UsageManager(self.stat_path, self.venvscache) ++ self.assertEqual(len(self.read_usage_lines()), 2) ++ ++ manager.store_usage_stat({'env_path': env_path2}) ++ ++ lines = self.read_usage_lines() ++ uuids = [line.split()[0] for line in lines] ++ self.assertEqual(uuids.count('uuid-1'), 1) ++ self.assertEqual(uuids.count('uuid-2'), 2) ++ ++ ++class CleanUnusedVenvsTestCase(BaseTestCase): ++ """Removing stale virtualenvs and compacting the usage file.""" ++ ++ def test_removes_stale_keeps_fresh(self): ++ old_path = self.make_venv('uuid-old') ++ fresh_path = self.make_venv('uuid-fresh') ++ now = datetime.utcnow() ++ self.write_usage([ ++ ('uuid-old', now - timedelta(days=100)), ++ ('uuid-fresh', now - timedelta(days=1)), ++ ]) ++ manager = self.UsageManager(self.stat_path, self.venvscache) ++ ++ manager.clean_unused_venvs(42) ++ ++ ++ self.assertFalse(os.path.exists(old_path)) ++ self.assertTrue(os.path.exists(fresh_path)) ++ ++ remaining = [m['env_path'] for m in self.venvscache.get_venvs_metadata()] ++ self.assertEqual(remaining, [fresh_path]) ++ ++ lines = self.read_usage_lines() ++ self.assertEqual([line.split()[0] for line in lines], ['uuid-fresh']) ++ ++ def test_day_boundary_is_strict(self): ++ kept_path = self.make_venv('uuid-kept') ++ gone_path = self.make_venv('uuid-gone') ++ now = datetime.utcnow() ++ self.write_usage([ ++ ('uuid-kept', now - timedelta(days=42)), ++ ('uuid-gone', now - timedelta(days=43)), ++ ]) ++ manager = self.UsageManager(self.stat_path, self.venvscache) ++ ++ manager.clean_unused_venvs(42) ++ ++ self.assertTrue(os.path.exists(kept_path)) ++ self.assertFalse(os.path.exists(gone_path)) ++ remaining = [m['env_path'] for m in self.venvscache.get_venvs_metadata()] ++ self.assertEqual(remaining, [kept_path]) ++ ++ def test_compacts_to_latest_record(self): ++ self.make_venv('uuid-1') ++ now = datetime.utcnow() ++ older = now - timedelta(days=2) ++ newer = now - timedelta(days=1) ++ ++ self.write_usage([ ++ ('uuid-1', older), ++ ('uuid-1', newer), ++ ]) ++ manager = self.UsageManager(self.stat_path, self.venvscache) ++ ++ manager.clean_unused_venvs(10000) ++ ++ lines = self.read_usage_lines() ++ self.assertEqual(len(lines), 1) ++ uuid, stamp = lines[0].split() ++ self.assertEqual(uuid, 'uuid-1') ++ self.assertEqual(datetime.strptime(stamp, DATE_FORMAT), newer) ++ ++ def test_nothing_removed_when_all_fresh(self): ++ p1 = self.make_venv('uuid-1') ++ p2 = self.make_venv('uuid-2') ++ now = datetime.utcnow() ++ self.write_usage([ ++ ('uuid-1', now - timedelta(days=1)), ++ ('uuid-2', now - timedelta(days=2)), ++ ]) ++ manager = self.UsageManager(self.stat_path, self.venvscache) ++ ++ manager.clean_unused_venvs(42) ++ ++ self.assertTrue(os.path.exists(p1)) ++ self.assertTrue(os.path.exists(p2)) ++ remaining = sorted(m['env_path'] for m in self.venvscache.get_venvs_metadata()) ++ self.assertEqual(remaining, sorted([p1, p2])) ++ self.assertEqual(sorted(line.split()[0] for line in self.read_usage_lines()), ++ ['uuid-1', 'uuid-2']) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,28 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++export PYTHONPATH="/testbed/.venv/lib/python3.12/site-packages${PYTHONPATH:+:$PYTHONPATH}" ++PY=python3.12 ++ ++ ++ ++ ++ ++"$PY" -m pytest -q \ ++ tests/test_cache.py \ ++ tests/test_main.py \ ++ tests/test_envbuilder.py \ ++ --deselect "tests/test_envbuilder.py::EnvDestructionTestCase::test_destroy_env" \ ++ --deselect "tests/test_envbuilder.py::EnvDestructionTestCase::test_destroy_venv" ++ ++ ++"$PY" -m pytest -q tests/test_usage_manager.py diff --git a/tasks/format-code-task-000220/tests/test.sh b/tasks/format-code-task-000220/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..069288357f920f8e941b0cbb06f08af814699e93 --- /dev/null +++ b/tasks/format-code-task-000220/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_usage_manager.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000220/tests/test_command.sh b/tasks/format-code-task-000220/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000220/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000226/environment/Dockerfile b/tasks/format-code-task-000226/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1c53e99006db992ae80abdd578f98e910b38f6e6 --- /dev/null +++ b/tasks/format-code-task-000226/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5d1cac4654cc09fb32387dc27d0ed75869ad2518992f65158b7a56308ad0dbec diff --git a/tasks/format-code-task-000226/environment/setup/files/blocklist b/tasks/format-code-task-000226/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000226/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000226/environment/setup/setup.sh b/tasks/format-code-task-000226/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000226/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000226/tests/test.patch b/tasks/format-code-task-000226/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..af519b533bbd453a1dc15aafee7f9940ecd184d4 --- /dev/null +++ b/tasks/format-code-task-000226/tests/test.patch @@ -0,0 +1,92 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..2e927ae +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest waitress.tests.test_parser.Test_split_uri -v"] ++} +diff --git a/waitress/tests/test_parser.py b/waitress/tests/test_parser.py +index cf4a976..12dea8f 100644 +--- a/waitress/tests/test_parser.py ++++ b/waitress/tests/test_parser.py +@@ -259,6 +259,65 @@ class Test_split_uri(unittest.TestCase): + except ParsingError: + pass + ++ def test_split_uri_path_starts_with_double_slash(self): ++ ++ ++ ++ self._callFUT(b'//testing/whatever') ++ self.assertEqual(self.proxy_scheme, '') ++ self.assertEqual(self.proxy_netloc, '') ++ self.assertEqual(self.path, '//testing/whatever') ++ self.assertEqual(self.query, '') ++ self.assertEqual(self.fragment, '') ++ ++ def test_split_uri_path_starts_with_double_slash_with_query(self): ++ self._callFUT(b'//testing/whatever?a=1&b=2') ++ self.assertEqual(self.proxy_scheme, '') ++ self.assertEqual(self.proxy_netloc, '') ++ self.assertEqual(self.path, '//testing/whatever') ++ self.assertEqual(self.query, 'a=1&b=2') ++ self.assertEqual(self.fragment, '') ++ ++ def test_split_uri_path_starts_with_double_slash_with_fragment(self): ++ self._callFUT(b'//testing/whatever#frag') ++ self.assertEqual(self.proxy_scheme, '') ++ self.assertEqual(self.proxy_netloc, '') ++ self.assertEqual(self.path, '//testing/whatever') ++ self.assertEqual(self.query, '') ++ self.assertEqual(self.fragment, 'frag') ++ ++ def test_split_uri_path_starts_with_double_slash_with_query_and_fragment(self): ++ self._callFUT(b'//testing/whatever?a=1#frag') ++ self.assertEqual(self.proxy_scheme, '') ++ self.assertEqual(self.proxy_netloc, '') ++ self.assertEqual(self.path, '//testing/whatever') ++ self.assertEqual(self.query, 'a=1') ++ self.assertEqual(self.fragment, 'frag') ++ ++ def test_split_uri_path_just_double_slash(self): ++ ++ ++ self._callFUT(b'//') ++ self.assertEqual(self.proxy_scheme, '') ++ self.assertEqual(self.proxy_netloc, '') ++ self.assertEqual(self.path, '//') ++ self.assertEqual(self.query, '') ++ self.assertEqual(self.fragment, '') ++ ++ def test_parse_header_uri_starts_with_double_slash(self): ++ ++ ++ ++ from waitress.parser import HTTPRequestParser ++ from waitress.adjustments import Adjustments ++ parser = HTTPRequestParser(Adjustments()) ++ parser.parse_header(b'GET //testing/whatever HTTP/1.1\n') ++ self.assertEqual(parser.path, '//testing/whatever') ++ self.assertEqual(parser.proxy_netloc, '') ++ self.assertEqual(parser.proxy_scheme, '') ++ self.assertEqual(parser.command, 'GET') ++ self.assertEqual(parser.version, '1.1') ++ + class Test_get_header_lines(unittest.TestCase): + + def _callFUT(self, data): +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest waitress.tests.test_parser.Test_split_uri -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000226/tests/test.sh b/tasks/format-code-task-000226/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7bc9386d2a926d270a8ae2938f14fede61fb777 --- /dev/null +++ b/tasks/format-code-task-000226/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +waitress/tests/test_parser.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000226/tests/test_command.sh b/tasks/format-code-task-000226/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000226/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000227/environment/Dockerfile b/tasks/format-code-task-000227/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fc923f19033dfb7c162b20d09cd9725345e26bfa --- /dev/null +++ b/tasks/format-code-task-000227/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fff05fe7ff6d5d5eaa1643d4031cae0a7c1242326bd89ac683313b5d2531690e diff --git a/tasks/format-code-task-000227/environment/setup/files/blocklist b/tasks/format-code-task-000227/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000227/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000227/environment/setup/setup.sh b/tasks/format-code-task-000227/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000227/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000227/tests/test.patch b/tasks/format-code-task-000227/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c92e567fdc144c7f934b160e1113c1bfa63774bc --- /dev/null +++ b/tasks/format-code-task-000227/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..2e18e80 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/test_task.py::TestWSGITask::test_head_http11_too_few_bytes_does_not_close tests/test_task.py::TestWSGITask::test_get_http11_too_few_bytes_closes_and_warns tests/test_task.py::TestWSGITask::test_get_http11_matching_bytes_no_close_no_warn --no-cov -v"] ++} +diff --git a/tests/test_task.py b/tests/test_task.py +index 47868e1..f184998 100644 +--- a/tests/test_task.py ++++ b/tests/test_task.py +@@ -603,6 +603,59 @@ class TestWSGITask(unittest.TestCase): + self.assertEqual(inst.close_on_finish, True) + self.assertEqual(len(inst.logger.logged), 0) + ++ def test_head_http11_too_few_bytes_does_not_close(self): ++ ++ ++ ++ ++ ++ def app(environ, start_response): ++ start_response("200 OK", [("Content-Length", "3")]) ++ return [b""] ++ ++ inst = self._makeOne() ++ inst.version = "1.1" ++ inst.request.command = "HEAD" ++ inst.channel.server.application = app ++ inst.logger = DummyLogger() ++ inst.execute() ++ self.assertEqual(inst.close_on_finish, False) ++ self.assertEqual(len(inst.logger.logged), 0) ++ ++ def test_get_http11_too_few_bytes_closes_and_warns(self): ++ ++ ++ ++ def app(environ, start_response): ++ start_response("200 OK", [("Content-Length", "3")]) ++ return [b"a"] ++ ++ inst = self._makeOne() ++ inst.version = "1.1" ++ inst.request.command = "GET" ++ inst.channel.server.application = app ++ inst.logger = DummyLogger() ++ inst.execute() ++ self.assertEqual(inst.close_on_finish, True) ++ self.assertEqual(len(inst.logger.logged), 1) ++ self.assertIn("too few bytes", inst.logger.logged[0]) ++ ++ def test_get_http11_matching_bytes_no_close_no_warn(self): ++ ++ ++ def app(environ, start_response): ++ start_response("200 OK", [("Content-Length", "3")]) ++ return [b"abc"] ++ ++ inst = self._makeOne() ++ inst.version = "1.1" ++ inst.request.command = "GET" ++ inst.channel.server.application = app ++ inst.logger = DummyLogger() ++ inst.execute() ++ self.assertEqual(inst.close_on_finish, False) ++ self.assertEqual(len(inst.logger.logged), 0) ++ + def test_execute_app_without_body_204_logged(self): + def app(environ, start_response): + start_response("204 No Content", [("Content-Length", "3")]) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest tests/test_task.py::TestWSGITask::test_head_http11_too_few_bytes_does_not_close tests/test_task.py::TestWSGITask::test_get_http11_too_few_bytes_closes_and_warns tests/test_task.py::TestWSGITask::test_get_http11_matching_bytes_no_close_no_warn --no-cov -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000227/tests/test.sh b/tasks/format-code-task-000227/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8dbd402f74bd6dfb62e75edeed46935f0e1572c8 --- /dev/null +++ b/tasks/format-code-task-000227/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/test_task.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000227/tests/test_command.sh b/tasks/format-code-task-000227/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000227/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000243/environment/Dockerfile b/tasks/format-code-task-000243/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a3a69f85e3cef0bf2d77e2e0959093b6cf8dca84 --- /dev/null +++ b/tasks/format-code-task-000243/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a3f65dac9b1048c58066a96e9cd10aa8563135ef47ccc8300bf9c39027ea96b4 diff --git a/tasks/format-code-task-000243/environment/setup/files/blocklist b/tasks/format-code-task-000243/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000243/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000243/environment/setup/setup.sh b/tasks/format-code-task-000243/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000243/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000243/tests/test.patch b/tasks/format-code-task-000243/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..97ba8082675f8564eab12f33dbee4a717b29cd24 --- /dev/null +++ b/tasks/format-code-task-000243/tests/test.patch @@ -0,0 +1,113 @@ +diff --git a/scheduler/pkg/envoy/processor/incremental_test.go b/scheduler/pkg/envoy/processor/incremental_test.go +index 257392b252..630039d750 100644 +--- a/scheduler/pkg/envoy/processor/incremental_test.go ++++ b/scheduler/pkg/envoy/processor/incremental_test.go +@@ -437,14 +437,15 @@ func createTestPipeline(pipelineName string, modelNames []string, version uint32 + func TestEnvoySettings(t *testing.T) { + g := NewGomegaWithT(t) + type test struct { +- name string +- ops []func(proc *IncrementalProcessor, g *WithT) +- numExpectedClusters int +- numExpectedRoutes int +- numExpectedPipelines int +- experimentActive bool +- experimentExists bool +- experimentDeleted bool ++ name string ++ ops []func(proc *IncrementalProcessor, g *WithT) ++ numExpectedClusters int ++ numExpectedRoutes int ++ numExpectedPipelines int ++ experimentActive bool ++ experimentExists bool ++ experimentDeleted bool ++ expectedVersionsInRoutes map[string]uint32 + } + + getStrPtr := func(t string) *string { return &t } +@@ -504,6 +505,29 @@ func TestEnvoySettings(t *testing.T) { + numExpectedRoutes: 3, + experimentActive: true, + experimentExists: true, ++ expectedVersionsInRoutes: map[string]uint32{ ++ "model1": 1, ++ "model2": 1, ++ }, ++ }, ++ { ++ name: "experiment - new model version", ++ ops: []func(inc *IncrementalProcessor, g *WithT){ ++ createTestServer("server", 2), ++ createTestModel("model1", "server", 1, []int{0}, 1, []store.ModelReplicaState{store.Available}), ++ createTestModel("model2", "server", 1, []int{1}, 1, []store.ModelReplicaState{store.Available}), ++ createTestExperiment("exp", []string{"model1", "model2"}, nil, nil), ++ ++ createTestModel("model2", "server", 1, []int{1}, 2, []store.ModelReplicaState{store.Available}), ++ }, ++ numExpectedClusters: 4, ++ numExpectedRoutes: 3, ++ experimentActive: true, ++ experimentExists: true, ++ expectedVersionsInRoutes: map[string]uint32{ ++ "model1": 1, ++ "model2": 2, ++ }, + }, + { + name: "experiment with deleted model", +@@ -514,7 +538,7 @@ func TestEnvoySettings(t *testing.T) { + createTestExperiment("exp", []string{"model1", "model2"}, getStrPtr("model1"), nil), + removeTestModel("model2", 1, "server", 1), + }, +- numExpectedClusters: 4, ++ numExpectedClusters: 2, + numExpectedRoutes: 2, // model2 should be removed from the routes + experimentActive: false, + experimentExists: true, +@@ -555,7 +579,7 @@ func TestEnvoySettings(t *testing.T) { + createTestExperiment("exp", []string{"model1"}, getStrPtr("model1"), getStrPtr("model2")), + removeTestModel("model2", 1, "server", 1), + }, +- numExpectedClusters: 4, ++ numExpectedClusters: 2, + numExpectedRoutes: 2, // model2 should be removed from the routes + experimentActive: false, + experimentExists: true, +@@ -653,6 +677,15 @@ func TestEnvoySettings(t *testing.T) { + g.Expect(err).NotTo(BeNil()) + g.Expect(exp).To(BeNil()) + } ++ for modelName, version := range test.expectedVersionsInRoutes { ++ for _, route := range inc.xdsCache.Routes { ++ for _, cluster := range route.Clusters { ++ if cluster.ModelName == modelName { ++ g.Expect(cluster.ModelVersion).To(Equal(version)) ++ } ++ } ++ } ++ } + + }) + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SzYrCMBQF4K77FPcF2jSpsSuX8wTjXjQJVdRE8iP49saCKILjRhnU820Sbi7k ++hpN6kVYbPTN2z4pXabJOymHNbtdhz6XgQohRI3Odc9mJguTLJrqSQpx7osI7F//qe3T+pupL/tGE ++OFNuu51bXYfl8+54lD9v23P+bdeKnP9ozHlBzfNGuO/L81eahuAXRpd5H9TS6LQxvuwdnepUs926 ++Z/l/uAPbeadMCM4zqnyyNM0NP6eTXxPjyvaBKuWSjRNO1b7876cBAAAAAAAAAAAAAAAAAAAAAHy8 ++I4dUABkAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000243/tests/test.sh b/tasks/format-code-task-000243/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8df1c1d6d4a45503f8808f6492bdceee03384b7f --- /dev/null +++ b/tasks/format-code-task-000243/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +scheduler/pkg/envoy/processor/incremental_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000243/tests/test_command.sh b/tasks/format-code-task-000243/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000243/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000244/environment/Dockerfile b/tasks/format-code-task-000244/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5fcd3a258c0b69d3ae72c89826bf2e4379120ffd --- /dev/null +++ b/tasks/format-code-task-000244/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:554678bc02f1a5af7688f76031f2ff250132ac7c540940926b135395a397118e diff --git a/tasks/format-code-task-000244/environment/setup/files/blocklist b/tasks/format-code-task-000244/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000244/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000244/environment/setup/setup.sh b/tasks/format-code-task-000244/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000244/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000244/tests/test.patch b/tasks/format-code-task-000244/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d3c2ea2b252bfc3ea50156da2fd5d895507dac97 --- /dev/null +++ b/tasks/format-code-task-000244/tests/test.patch @@ -0,0 +1,154 @@ +diff --git a/test/units/volume_test.rb b/test/units/volume_test.rb +index bc92ea2..9e66c85 100644 +--- a/test/units/volume_test.rb ++++ b/test/units/volume_test.rb +@@ -19,6 +19,16 @@ class Measured::VolumeTest < ActiveSupport::TestCase + liters + litres + ft3 ++ cm3 ++ cubic_centimeter ++ cubic_centimeters ++ cubic_centimetre ++ cubic_centimetres ++ mm3 ++ cubic_millimeter ++ cubic_millimeters ++ cubic_millimetre ++ cubic_millimetres + cubic_foot + cubic_feet + in3 +@@ -67,7 +77,7 @@ class Measured::VolumeTest < ActiveSupport::TestCase + end + + test ".unit_names should be the list of base unit names" do +- expected_units = %w(l m3 ft3 in3 gal us_gal qt us_qt pt us_pt oz us_oz) ++ expected_units = %w(l m3 ft3 in3 gal us_gal qt us_qt pt us_pt oz us_oz mm3 cm3) + expected_units += Measured::UnitSystemBuilder::SI_PREFIXES.map { |short, _, _| "#{short}l" } + assert_equal expected_units.sort, Measured::Volume.unit_names + end +@@ -124,6 +134,102 @@ class Measured::VolumeTest < ActiveSupport::TestCase + test ".convert_to from us_oz to us_oz" do + assert_conversion Measured::Volume, "2000 us_oz", "2000 us_oz" + end ++ ++ test ".convert_to from mm3 to mm3" do ++ assert_conversion Measured::Volume, "20000 mm3", "20000 mm3" ++ end ++ ++ test ".convert_to from cm3 to cm3" do ++ assert_conversion Measured::Volume, "20000 cm3", "20000 cm3" ++ end ++ ++ test ".convert_to from mm3 to m3" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.00002 m3" ++ end ++ ++ test ".convert_to from mm3 to ft3" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.00070629333 ft3" ++ end ++ ++ test ".convert_to from mm3 to in3" do ++ assert_conversion Measured::Volume, "20000 mm3", "1.2204749 in3" ++ end ++ ++ test ".convert_to from mm3 to gal" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.004399384965981756 gal" ++ end ++ ++ test ".convert_to from mm3 to us_gal" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.005283441047162969 us_gal" ++ end ++ ++ test ".convert_to from mm3 to qt" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.01759754 qt" ++ end ++ ++ test ".convert_to from mm3 to us_qt" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.021133764 us_qt" ++ end ++ ++ test ".convert_to from mm3 to pt" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.03519508 pt" ++ end ++ ++ test ".convert_to from mm3 to us_pt" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.042267528 us_pt" ++ end ++ ++ test ".convert_to from mm3 to oz" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.70390159 oz" ++ end ++ ++ test ".convert_to from mm3 to us_oz" do ++ assert_conversion Measured::Volume, "20000 mm3", "0.67628045 us_oz" ++ end ++ ++ test ".convert_to from cm3 to m3" do ++ assert_conversion Measured::Volume, "20000 cm3", "0.02 m3" ++ end ++ ++ test ".convert_to from cm3 to ft3" do ++ assert_conversion Measured::Volume, "20000 cm3", "0.70629333 ft3" ++ end ++ ++ test ".convert_to from cm3 to in3" do ++ assert_conversion Measured::Volume, "20000 cm3", "1220.4748818946457 in3" ++ end ++ ++ test ".convert_to from cm3 to gal" do ++ assert_conversion Measured::Volume, "20000 cm3", "4.399384965981756 gal" ++ end ++ ++ test ".convert_to from cm3 to us_gal" do ++ assert_conversion Measured::Volume, "20000 cm3", "5.283441047162969 us_gal" ++ end ++ ++ test ".convert_to from cm3 to qt" do ++ assert_conversion Measured::Volume, "20000 cm3", "17.59754 qt" ++ end ++ ++ test ".convert_to from cm3 to us_qt" do ++ assert_conversion Measured::Volume, "20000 cm3", "21.133764 us_qt" ++ end ++ ++ test ".convert_to from cm3 to pt" do ++ assert_conversion Measured::Volume, "20000 cm3", "35.19508 pt" ++ end ++ ++ test ".convert_to from cm3 to us_pt" do ++ assert_conversion Measured::Volume, "20000 cm3", "42.267528 us_pt" ++ end ++ ++ test ".convert_to from cm3 to oz" do ++ assert_conversion Measured::Volume, "20000 cm3", "703.9015945570809 oz" ++ end ++ ++ test ".convert_to from cm3 to us_oz" do ++ assert_conversion Measured::Volume, "20000 cm3", "676.28045403686 us_oz" ++ end + + test ".convert_to from ml to m3" do + assert_conversion Measured::Volume, "2000 ml", "0.002 m3" +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3Sy0rEMBQG4K7zFEdc2/Qyna5cKLorFkRxWZrmyBR7GXIZfHzbIiiCzmYGGeb/ ++FknIhZzwJ1S+7XTFw04GxxJN8ixb+snPfhnHWRInURpFybQvjrN1HlB2tIq+8dbVhigw4+j+2rdv ++/USFX/k7tq5qxr6vBx3azeHu2Jd/nKef+Sd5vprzX62TNKDocCX87szzv7yQ3hqp2kFOf4BUbTfC ++sqMr9iNt2y2/1m0nRKNp+R+KtRC3zw93xX11UxTlS/VYlk/Xzngm5QfdMfE7N2TqN6b5wNJIP7TO ++yt3Y+Z6reSY0Svz30wEAAAAAAAAAAAAAAAAAAAAATt4H3p8W8QAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000244/tests/test.sh b/tasks/format-code-task-000244/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ff3c96289b544c9befc225d7b3e9ffa77ef07086 --- /dev/null +++ b/tasks/format-code-task-000244/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/units/volume_test.rb +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000244/tests/test_command.sh b/tasks/format-code-task-000244/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000244/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000272/environment/Dockerfile b/tasks/format-code-task-000272/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8c5c65b69e3a70bfb19237748ff59c6106b01dba --- /dev/null +++ b/tasks/format-code-task-000272/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:63311a389fff1d0a1aa1b1ce3b49ecf5a06364ba4c9b2a8aaf29541688feae53 diff --git a/tasks/format-code-task-000272/environment/setup/files/blocklist b/tasks/format-code-task-000272/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000272/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000272/environment/setup/setup.sh b/tasks/format-code-task-000272/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000272/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000272/tests/test.patch b/tasks/format-code-task-000272/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..efc2282cd4a2e8386d0b3e2a21da12a4948abb49 --- /dev/null +++ b/tasks/format-code-task-000272/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/test/test_grid.py b/test/test_grid.py +index 92d32785..71516d27 100644 +--- a/test/test_grid.py ++++ b/test/test_grid.py +@@ -300,6 +300,60 @@ class TestGrid(TestCase): + assert grid.Mesh2_face_dimension.min() >= min_dimension + assert grid.Mesh2_face_dimension.max() <= max_dimension + ++ def test_nNodes_per_face_attribute(self): ++ """The renamed ``nNodes_per_face`` is exposed as a Grid attribute.""" ++ grids = [self.tgrid1, self.tgrid2, self.tgrid3] ++ ++ for grid in grids: ++ assert hasattr(grid, "nNodes_per_face"), ( ++ "Grid should expose 'nNodes_per_face' attribute after rename") ++ ++ arr = grid.nNodes_per_face ++ assert hasattr(arr, "min") and hasattr(arr, "max") ++ ++ def test_nNodes_per_face_in_dataset(self): ++ """The renamed variable lives in the internal xr.Dataset under ++ ``nNodes_per_face``.""" ++ grids = [self.tgrid1, self.tgrid2, self.tgrid3] ++ ++ for grid in grids: ++ assert "nNodes_per_face" in grid.ds, ( ++ "grid.ds should contain key 'nNodes_per_face' after rename") ++ ++ assert grid.ds["nNodes_per_face"].dims == ("nMesh2_face",) ++ ++ def test_nNodes_per_face_values_in_range(self): ++ """Values of nNodes_per_face are >= 3 (triangle minimum) and <= ++ nMaxMesh2_face_nodes.""" ++ grids = [self.tgrid1, self.tgrid2, self.tgrid3] ++ ++ for grid in grids: ++ max_dimension = grid.nMaxMesh2_face_nodes ++ min_dimension = 3 ++ ++ assert int(grid.nNodes_per_face.min()) >= min_dimension ++ assert int(grid.nNodes_per_face.max()) <= max_dimension ++ ++ def test_build_nNodes_per_face_method_exists(self): ++ """The internal builder is now named ``_build_nNodes_per_face``.""" ++ grid = self.tgrid1 ++ assert hasattr(grid, "_build_nNodes_per_face"), ( ++ "Grid should expose private method '_build_nNodes_per_face' " ++ "after rename") ++ ++ assert callable(getattr(grid, "_build_nNodes_per_face")) ++ ++ def test_compute_face_areas_uses_nNodes_per_face(self): ++ """compute_face_areas still works — it now reads via the renamed ++ attribute internally.""" ++ grid = self.tgrid1 ++ face_areas = grid.compute_face_areas() ++ ++ assert face_areas.shape[0] == grid.nMesh2_face ++ ++ assert np.all(np.isfinite(face_areas)) ++ assert np.all(face_areas > 0) ++ + + class TestIntegrate(TestCase): + mesh_file30 = current_path / "meshfiles" / "ugrid" / "outCSne30" / "outCSne30.ug" +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..63f1922a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest test/test_grid.py::TestGrid::test_nNodes_per_face_attribute test/test_grid.py::TestGrid::test_nNodes_per_face_in_dataset test/test_grid.py::TestGrid::test_nNodes_per_face_values_in_range test/test_grid.py::TestGrid::test_build_nNodes_per_face_method_exists test/test_grid.py::TestGrid::test_compute_face_areas_uses_nNodes_per_face -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA test/test_grid.py::TestGrid::test_nNodes_per_face_attribute test/test_grid.py::TestGrid::test_nNodes_per_face_in_dataset test/test_grid.py::TestGrid::test_nNodes_per_face_values_in_range test/test_grid.py::TestGrid::test_build_nNodes_per_face_method_exists test/test_grid.py::TestGrid::test_compute_face_areas_uses_nNodes_per_face ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000272/tests/test.sh b/tasks/format-code-task-000272/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9df1a412866582b5b06f1a47f69d986cd5e3edec --- /dev/null +++ b/tasks/format-code-task-000272/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test_grid.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000272/tests/test_command.sh b/tasks/format-code-task-000272/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000272/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000275/environment/Dockerfile b/tasks/format-code-task-000275/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e289d22ae6779a613df7348f60971e19196a879a --- /dev/null +++ b/tasks/format-code-task-000275/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1b0be7d53c5dc3637a83ada2c67266ca25c04343a247efa12f68af42f50b8615 diff --git a/tasks/format-code-task-000275/environment/setup/files/blocklist b/tasks/format-code-task-000275/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000275/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000275/environment/setup/setup.sh b/tasks/format-code-task-000275/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000275/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000275/tests/test.patch b/tasks/format-code-task-000275/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..aff7f6a19838cd358a0ce4285eddb8fa1ced33c4 --- /dev/null +++ b/tasks/format-code-task-000275/tests/test.patch @@ -0,0 +1,133 @@ +diff --git a/_test_unstructured_client/unit/test_split_pdf_hook.py b/_test_unstructured_client/unit/test_split_pdf_hook.py +index d09c894..b282e84 100644 +--- a/_test_unstructured_client/unit/test_split_pdf_hook.py ++++ b/_test_unstructured_client/unit/test_split_pdf_hook.py +@@ -27,6 +27,7 @@ from unstructured_client._hooks.custom.split_pdf_hook import ( + SplitPdfHook, + get_optimal_split_size, run_tasks, + ) ++from unstructured_client._hooks.types import BeforeRequestContext, HookContext + from unstructured_client.models import shared + + +@@ -479,3 +480,98 @@ async def test_remaining_tasks_cancelled_when_fails_disallowed(): + await asyncio.sleep(1) + print("Cancelled amount: ", cancelled_counter["cancelled"]) + assert len(tasks) > cancelled_counter["cancelled"] > 0 ++ ++ ++def _make_partition_request(server_url: str, pdf_filename: str) -> httpx.Request: ++ """Build an httpx.Request that mimics what the SDK would send for a partition ++ call with split_pdf_page=true and a multi-page PDF.""" ++ with open(pdf_filename, "rb") as f: ++ pdf_content = f.read() ++ encoder = MultipartEncoder( ++ fields={ ++ "split_pdf_page": "true", ++ "files": (pdf_filename, pdf_content, "application/pdf"), ++ "strategy": "fast", ++ } ++ ) ++ return httpx.Request( ++ "POST", ++ f"{server_url}/general/v0/general", ++ content=encoder.to_string(), ++ headers={"Content-Type": encoder.content_type}, ++ ) ++ ++ ++def _make_before_request_context() -> BeforeRequestContext: ++ return BeforeRequestContext( ++ HookContext(operation_id="op", oauth2_scopes=None, security_source=None) ++ ) ++ ++ ++def test_unit_split_pdf_dummy_request_does_not_use_hardcoded_api_url(): ++ """Bug fix: the dummy GET request returned by before_request must not target ++ the hardcoded https://api.unstructuredapp.io URL. Hitting that URL behind a ++ firewall causes the client to hang and time out.""" ++ server_url = "http://localhost:9999" ++ hook = SplitPdfHook() ++ hook.sdk_init(base_url=server_url, client=httpx.Client()) ++ ++ request = _make_partition_request( ++ server_url, "_sample_docs/layout-parser-paper.pdf" ++ ) ++ result = hook.before_request(_make_before_request_context(), request) ++ ++ assert isinstance(result, httpx.Request) ++ assert result.method == "GET" ++ assert "api.unstructuredapp.io" not in str(result.url) ++ ++ ++def test_unit_split_pdf_dummy_request_uses_localhost_server_url(): ++ """The dummy GET request should target the user-configured server_url when ++ it is localhost (not a hardcoded external URL).""" ++ server_url = "http://localhost:9999" ++ hook = SplitPdfHook() ++ hook.sdk_init(base_url=server_url, client=httpx.Client()) ++ ++ request = _make_partition_request( ++ server_url, "_sample_docs/layout-parser-paper.pdf" ++ ) ++ result = hook.before_request(_make_before_request_context(), request) ++ ++ assert isinstance(result, httpx.Request) ++ assert result.url.host == "localhost" ++ assert result.url.port == 9999 ++ ++ ++def test_unit_split_pdf_dummy_request_uses_custom_server_url(): ++ """Differential check: with a different server_url (custom hostname/port), ++ the dummy GET URL host/port must reflect that server_url, ensuring the ++ URL is built from server_url rather than another hardcoded value.""" ++ server_url = "http://my-firewalled-host:8000" ++ hook = SplitPdfHook() ++ hook.sdk_init(base_url=server_url, client=httpx.Client()) ++ ++ request = _make_partition_request( ++ server_url, "_sample_docs/layout-parser-paper.pdf" ++ ) ++ result = hook.before_request(_make_before_request_context(), request) ++ ++ assert isinstance(result, httpx.Request) ++ assert result.url.host == "my-firewalled-host" ++ assert result.url.port == 8000 ++ ++ ++def test_unit_split_pdf_dummy_request_path_is_general_docs(): ++ """Preservation: the dummy GET request still targets the /general/docs path ++ so the after_success hook can identify and await the split results.""" ++ server_url = "http://localhost:9999" ++ hook = SplitPdfHook() ++ hook.sdk_init(base_url=server_url, client=httpx.Client()) ++ ++ request = _make_partition_request( ++ server_url, "_sample_docs/layout-parser-paper.pdf" ++ ) ++ result = hook.before_request(_make_before_request_context(), request) ++ ++ assert isinstance(result, httpx.Request) ++ assert result.url.path == "/general/docs" +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..0206c33 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=. .venv/bin/pytest _test_unstructured_client/unit/test_split_pdf_hook.py -v -k dummy_request"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=. .venv/bin/pytest _test_unstructured_client/unit/test_split_pdf_hook.py -v -k dummy_request ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000275/tests/test.sh b/tasks/format-code-task-000275/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..df1e1711974ebb759cd52fd3766e40908f43f061 --- /dev/null +++ b/tasks/format-code-task-000275/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +_test_unstructured_client/unit/test_split_pdf_hook.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000275/tests/test_command.sh b/tasks/format-code-task-000275/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000275/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000281/environment/Dockerfile b/tasks/format-code-task-000281/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ea1177b7ab761492bb706ace0cf43d376411aba9 --- /dev/null +++ b/tasks/format-code-task-000281/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:116dbf655570d375e2c87c341e839dc88666e9967fda15e117d5fdd81c857a5b diff --git a/tasks/format-code-task-000281/environment/setup/files/blocklist b/tasks/format-code-task-000281/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000281/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000281/environment/setup/setup.sh b/tasks/format-code-task-000281/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000281/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000281/tests/test.patch b/tasks/format-code-task-000281/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4a8cb771c1c5966cd97b09132727a01918db34a5 --- /dev/null +++ b/tasks/format-code-task-000281/tests/test.patch @@ -0,0 +1,116 @@ +diff --git a/catalog/tests/dags/common/storage/test_codespec_column_serialization.py b/catalog/tests/dags/common/storage/test_codespec_column_serialization.py +new file mode 100644 +index 000000000..06a4beef4 +--- /dev/null ++++ b/catalog/tests/dags/common/storage/test_codespec_column_serialization.py +@@ -0,0 +1,101 @@ ++import json ++import unittest ++ ++from common.storage.columns import ( ++ ArrayColumn, ++ Column, ++ CREATED_ON, ++ JSONColumn, ++ StringColumn, ++ UpsertStrategy, ++ URLColumn, ++) ++ ++ ++class PassthroughColumn(Column): ++ ++ ++ def __init__(self): ++ super().__init__("value", required=False) ++ ++ def prepare_string(self, value): ++ return value ++ ++ ++class ColumnSerializationContractTests(unittest.TestCase): ++ def test_json_preserves_scalar_types_at_every_nesting_level(self): ++ value = { ++ "count": 3, ++ "enabled": False, ++ "nested": [{"ratio": 1.5, "missing": None}], ++ } ++ encoded = JSONColumn("metadata", required=False).prepare_string(value) ++ ++ self.assertEqual(json.loads(encoded), value) ++ self.assertIsInstance(json.loads(encoded)["count"], int) ++ self.assertIs(json.loads(encoded)["enabled"], False) ++ ++ def test_json_sanitizes_string_leaves_without_touching_scalars(self): ++ value = {"outer": [" hello\tworld ", {"n": 7, "flag": True}]} ++ encoded = JSONColumn("metadata", required=False).prepare_string(value) ++ ++ self.assertEqual( ++ json.loads(encoded), ++ {"outer": ["hello world", {"n": 7, "flag": True}]}, ++ ) ++ ++ def test_json_uses_null_for_absent_or_empty_containers(self): ++ column = JSONColumn("metadata", required=False) ++ self.assertIsNone(column.prepare_string(None)) ++ self.assertIsNone(column.prepare_string({})) ++ self.assertIsNone(column.prepare_string([])) ++ self.assertEqual(json.loads(column.prepare_string([None])), [None]) ++ ++ def test_array_uses_postgres_literal_escaping(self): ++ column = ArrayColumn("values", required=False, base_column=PassthroughColumn()) ++ value = ["simple", "has,comma", 'has"quote', r"has\slash", "NULL"] ++ ++ encoded = column.prepare_string(value) ++ self.assertTrue(encoded.startswith("{") and encoded.endswith("}")) ++ self.assertIn('"has,comma"', encoded) ++ self.assertIn('"has\\\"quote"', encoded) ++ self.assertIn('"has\\\\slash"', encoded) ++ self.assertIn('"NULL"', encoded) ++ ++ def test_array_distinguishes_null_elements_and_invalid_values(self): ++ column = ArrayColumn( ++ "values", ++ required=False, ++ base_column=StringColumn("value", required=False, size=3, truncate=False), ++ ) ++ ++ encoded = column.prepare_string(["ok", None, "too-long"]) ++ self.assertEqual(encoded.replace(" ", "").lower(), '{"ok",null,null}') ++ self.assertEqual(column.prepare_string("ok").replace(" ", ""), "{ok}") ++ self.assertIsNone(column.prepare_string(None)) ++ ++ def test_array_empty_value_is_explicit_empty_array_and_input_is_unchanged(self): ++ column = ArrayColumn("values", required=False, base_column=PassthroughColumn()) ++ value = ["a", "b"] ++ original = list(value) ++ ++ self.assertEqual(column.prepare_string([]), "{}") ++ self.assertEqual(column.prepare_string(value).replace(" ", ""), '{"a","b"}') ++ self.assertEqual(value, original) ++ ++ def test_no_change_upsert_strategy_is_a_valid_self_assignment(self): ++ self.assertEqual(CREATED_ON.upsert_strategy, UpsertStrategy.no_change) ++ self.assertEqual(CREATED_ON.upsert_name, "NOW()") ++ self.assertEqual(CREATED_ON.upsert_value, "created_on = old.created_on") ++ ++ def test_existing_string_and_url_column_contracts_remain_compatible(self): ++ string = StringColumn("title", required=False, size=5, truncate=True) ++ self.assertEqual(string.prepare_string(' a"bcd '), "a'bcd") ++ ++ url = URLColumn("url", required=False, size=30) ++ self.assertEqual(url.prepare_string("https://example.org/a"), "https://example.org/a") ++ self.assertIsNone(url.prepare_string(" https://example.org/a")) ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++PYTHONPATH="${PWD}/catalog/dags" python catalog/tests/dags/common/storage/test_codespec_column_serialization.py diff --git a/tasks/format-code-task-000281/tests/test.sh b/tasks/format-code-task-000281/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0da160e15588b496319a4119372f3c5c69788d05 --- /dev/null +++ b/tasks/format-code-task-000281/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +catalog/tests/dags/common/storage/test_codespec_column_serialization.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000281/tests/test_command.sh b/tasks/format-code-task-000281/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000281/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000286/environment/Dockerfile b/tasks/format-code-task-000286/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..450f087c69fed19c0ba36d2a4584af4b478eac45 --- /dev/null +++ b/tasks/format-code-task-000286/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:edc4d289de6e1bf9cb875c482de8709ab002d50ac4e5b7f424559e219123a6cb diff --git a/tasks/format-code-task-000286/environment/setup/files/blocklist b/tasks/format-code-task-000286/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000286/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000286/environment/setup/setup.sh b/tasks/format-code-task-000286/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000286/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000286/tests/test.patch b/tasks/format-code-task-000286/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..82f964b40e7daed7c52b96f059819b13109725a0 --- /dev/null +++ b/tasks/format-code-task-000286/tests/test.patch @@ -0,0 +1,395 @@ +diff --git a/usercase-test-coderl/parser_stateful_test.go b/usercase-test-coderl/parser_stateful_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/parser_stateful_test.go +@@ -0,0 +1,366 @@ ++package usercase_test_coderl ++ ++import ( ++ "io" ++ "strings" ++ "testing" ++ "time" ++ ++ "github.com/aaasen/kapok/parse" ++) ++ ++ ++ ++ ++type pageSnapshot struct { ++ Title string ++ Links []string ++ Categories []string ++} ++ ++type gatedReader struct { ++ chunks chan string ++ current string ++ closed bool ++} ++ ++func (r *gatedReader) Read(p []byte) (int, error) { ++ for r.current == "" { ++ if r.closed { ++ return 0, io.EOF ++ } ++ ++ next, ok := <-r.chunks ++ if !ok { ++ r.closed = true ++ return 0, io.EOF ++ } ++ r.current = next ++ } ++ ++ n := copy(p, r.current) ++ r.current = r.current[n:] ++ return n, nil ++} ++ ++type chunkReader struct { ++ data string ++ sizes []int ++ pos int ++ idx int ++} ++ ++func (r *chunkReader) Read(p []byte) (int, error) { ++ if r.pos >= len(r.data) { ++ return 0, io.EOF ++ } ++ ++ n := 7 ++ if r.idx < len(r.sizes) { ++ n = r.sizes[r.idx] ++ r.idx++ ++ } ++ if n > len(p) { ++ n = len(p) ++ } ++ if remaining := len(r.data) - r.pos; n > remaining { ++ n = remaining ++ } ++ ++ copy(p, r.data[r.pos:r.pos+n]) ++ r.pos += n ++ return n, nil ++} ++ ++func snapshot(page *parse.Page) pageSnapshot { ++ if page == nil { ++ return pageSnapshot{Title: ""} ++ } ++ return pageSnapshot{ ++ Title: page.Title, ++ Links: page.Links, ++ Categories: page.Categories, ++ } ++} ++ ++func receivePage(t *testing.T, pages <-chan *parse.Page) (pageSnapshot, bool) { ++ t.Helper() ++ ++ select { ++ case page, ok := <-pages: ++ return snapshot(page), ok ++ case <-time.After(2 * time.Second): ++ t.Fatal("timed out waiting for parser output") ++ return pageSnapshot{}, false ++ } ++} ++ ++func assertSnapshot(t *testing.T, got pageSnapshot, want pageSnapshot) { ++ t.Helper() ++ ++ ++ if got.Title != want.Title || !sameStrings(got.Links, want.Links) || !sameStrings(got.Categories, want.Categories) { ++ t.Fatalf("page snapshot = %#v, want %#v", got, want) ++ } ++} ++ ++func assertTitleAndLinks(t *testing.T, got pageSnapshot, wantTitle string, wantLinks []string) { ++ t.Helper() ++ ++ if got.Title != wantTitle || !sameStrings(got.Links, wantLinks) { ++ t.Fatalf("page title/links = %q/%#v, want %q/%#v", got.Title, got.Links, wantTitle, wantLinks) ++ } ++} ++ ++func sameStrings(got []string, want []string) bool { ++ if len(got) != len(want) { ++ return false ++ } ++ for i := range got { ++ if got[i] != want[i] { ++ return false ++ } ++ } ++ return true ++} ++ ++func TestParserStreamsDumpPagesSkipsRedirectsAndCloses(t *testing.T) { ++ ++ ++ first := "before" + ++ "Kapok" + ++ "AlphaLead [[Beta]] and [[Category:Science]]." ++ rest := "between" + ++ "Redirected#REDIRECT [[Alpha]]" + ++ ++ "[[Alpha]]" + ++ "[[NoTitle]]" + ++ "GammaReturn to [[Alpha]] and [[Category:Math|mathematics]]." + ++ "after" ++ totalInputBytes := int64(len(first) + len(rest)) ++ ++ parser := parse.NewParser() ++ if parser.BytesProcessed != 0 { ++ t.Fatalf("fresh BytesProcessed = %d, want 0", parser.BytesProcessed) ++ } ++ ++ reader := &gatedReader{chunks: make(chan string)} ++ pages := make(chan *parse.Page) ++ parser.Parse(reader, pages) ++ ++ reader.chunks <- first ++ got, ok := receivePage(t, pages) ++ if ok != true { ++ t.Fatalf("first receive ok = %t, want true", ok) ++ } ++ assertSnapshot(t, got, pageSnapshot{ ++ Title: "Alpha", ++ Links: []string{"Beta"}, ++ Categories: []string{"Science"}, ++ }) ++ ++ if parser.BytesProcessed <= 0 || parser.BytesProcessed > int64(len(first)) { ++ t.Fatalf("BytesProcessed after first complete page = %d, want between 1 and %d", parser.BytesProcessed, len(first)) ++ } ++ ++ reader.chunks <- rest ++ close(reader.chunks) ++ ++ got, ok = receivePage(t, pages) ++ if ok != true { ++ t.Fatalf("second receive ok = %t, want true", ok) ++ } ++ ++ assertTitleAndLinks(t, got, "Gamma", []string{"Alpha"}) ++ ++ _, ok = receivePage(t, pages) ++ if ok != false { ++ t.Fatalf("third receive ok = %t, want false", ok) ++ } ++ if parser.BytesProcessed != totalInputBytes { ++ t.Fatalf("final BytesProcessed = %d, want %d", parser.BytesProcessed, totalInputBytes) ++ } ++} ++ ++func TestParserPreservesPagesAcrossReaderChunks(t *testing.T) { ++ ++ ++ input := "before" + ++ "Kapok" + ++ "AlphaLead [[Beta]] and [[Category:Science]]." + ++ "between" + ++ "Redirected#REDIRECT [[Alpha]]" + ++ ++ "[[Alpha]]" + ++ "[[NoTitle]]" + ++ "GammaReturn to [[Alpha]] and [[Category:Math|mathematics]]." + ++ "after" ++ ++ parser := parse.NewParser() ++ pages := make(chan *parse.Page) ++ parser.Parse(&chunkReader{ ++ data: input, ++ sizes: []int{3, 2, 1, 4, 5, 1, 2, 9, 1, 6, 3, 2, 8}, ++ }, pages) ++ ++ got, ok := receivePage(t, pages) ++ if ok != true { ++ t.Fatalf("first receive ok = %t, want true", ok) ++ } ++ assertSnapshot(t, got, pageSnapshot{ ++ Title: "Alpha", ++ Links: []string{"Beta"}, ++ Categories: []string{"Science"}, ++ }) ++ ++ got, ok = receivePage(t, pages) ++ if ok != true { ++ t.Fatalf("second receive ok = %t, want true", ok) ++ } ++ ++ assertTitleAndLinks(t, got, "Gamma", []string{"Alpha"}) ++ ++ _, ok = receivePage(t, pages) ++ if ok != false { ++ t.Fatalf("third receive ok = %t, want false", ok) ++ } ++ if parser.BytesProcessed != int64(len(input)) { ++ t.Fatalf("final BytesProcessed = %d, want %d", parser.BytesProcessed, len(input)) ++ } ++} ++ ++func TestParserSkipsMalformedAndInvalidTitlePagesThenContinues(t *testing.T) { ++ ++ ++ input := "junk" + ++ "[[NoTitle]]" + ++ ++ "[[Alpha]]" + ++ "Delta[[Alpha]] [[Category:Valid]]" + ++ "tail" ++ ++ parser := parse.NewParser() ++ pages := make(chan *parse.Page) ++ parser.Parse(strings.NewReader(input), pages) ++ ++ got, ok := receivePage(t, pages) ++ if ok != true { ++ t.Fatalf("first receive ok = %t, want true", ok) ++ } ++ ++ assertTitleAndLinks(t, got, "Delta", []string{"Alpha"}) ++ ++ _, ok = receivePage(t, pages) ++ if ok != false { ++ t.Fatalf("second receive ok = %t, want false", ok) ++ } ++ if parser.BytesProcessed != int64(len(input)) { ++ t.Fatalf("final BytesProcessed = %d, want %d", parser.BytesProcessed, len(input)) ++ } ++} ++ ++func TestExhaustedReaderClosesOutputChannelForRepeatedReceives(t *testing.T) { ++ ++ ++ input := "outside only with wrappers" ++ ++ parser := parse.NewParser() ++ pages := make(chan *parse.Page) ++ parser.Parse(strings.NewReader(input), pages) ++ ++ _, ok := receivePage(t, pages) ++ if ok != false { ++ t.Fatalf("first receive ok = %t, want false", ok) ++ } ++ ++ _, ok = receivePage(t, pages) ++ if ok != false { ++ t.Fatalf("second receive ok = %t, want false", ok) ++ } ++ if parser.BytesProcessed != int64(len(input)) { ++ t.Fatalf("final BytesProcessed = %d, want %d", parser.BytesProcessed, len(input)) ++ } ++} ++ ++func TestSeparateParserInstancesMaintainIndependentCountersAndSessions(t *testing.T) { ++ ++ ++ a := parse.NewParser() ++ b := parse.NewParser() ++ ++ aPages := make(chan *parse.Page) ++ aInput := "One[[Two]]" ++ a.Parse(strings.NewReader(aInput), aPages) ++ got, ok := receivePage(t, aPages) ++ if ok != true { ++ t.Fatalf("a first receive ok = %t, want true", ok) ++ } ++ assertSnapshot(t, got, pageSnapshot{ ++ Title: "One", ++ Links: []string{"Two"}, ++ Categories: nil, ++ }) ++ _, ok = receivePage(t, aPages) ++ if ok != false { ++ t.Fatalf("a second receive ok = %t, want false", ok) ++ } ++ ++ if a.BytesProcessed != int64(len(aInput)) { ++ t.Fatalf("a BytesProcessed = %d, want %d", a.BytesProcessed, len(aInput)) ++ } ++ if b.BytesProcessed != 0 { ++ t.Fatalf("b fresh BytesProcessed = %d, want 0", b.BytesProcessed) ++ } ++ ++ bPages := make(chan *parse.Page) ++ bInput := "outsideTwo[[One]] [[Category:Solo]]tail" ++ b.Parse(strings.NewReader(bInput), bPages) ++ got, ok = receivePage(t, bPages) ++ if ok != true { ++ t.Fatalf("b first receive ok = %t, want true", ok) ++ } ++ ++ assertTitleAndLinks(t, got, "Two", []string{"One"}) ++ _, ok = receivePage(t, bPages) ++ if ok != false { ++ t.Fatalf("b second receive ok = %t, want false", ok) ++ } ++ ++ if a.BytesProcessed != int64(len(aInput)) { ++ t.Fatalf("a BytesProcessed after b parse = %d, want %d", a.BytesProcessed, len(aInput)) ++ } ++ if b.BytesProcessed != int64(len(bInput)) { ++ t.Fatalf("b BytesProcessed = %d, want %d", b.BytesProcessed, len(bInput)) ++ } ++} ++ ++func TestRepeatedParserSessionsDoNotLeakGoroutines(t *testing.T) { ++ ++ ++ input := "Leak[[Target]]" ++ ++ for i := 0; i < 150; i++ { ++ parser := parse.NewParser() ++ pages := make(chan *parse.Page) ++ parser.Parse(strings.NewReader(input), pages) ++ ++ got, ok := receivePage(t, pages) ++ if ok != true { ++ t.Fatalf("cycle %d first receive ok = %t, want true", i, ok) ++ } ++ assertSnapshot(t, got, pageSnapshot{ ++ Title: "Leak", ++ Links: []string{"Target"}, ++ Categories: nil, ++ }) ++ ++ _, ok = receivePage(t, pages) ++ if ok != false { ++ t.Fatalf("cycle %d second receive ok = %t, want false", i, ok) ++ } ++ if parser.BytesProcessed != int64(len(input)) { ++ t.Fatalf("cycle %d final BytesProcessed = %d, want %d", i, parser.BytesProcessed, len(input)) ++ } ++ } ++ ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++export GOPROXY=off ++export GOSUMDB=off ++export GOVCS='*:off' ++export GOTELEMETRY=off ++ ++cd /workspace/repo ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-000286/tests/test.sh b/tasks/format-code-task-000286/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c081d37b6dcda674e84cb2e93368acc1931a42ad --- /dev/null +++ b/tasks/format-code-task-000286/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/parser_stateful_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000286/tests/test_command.sh b/tasks/format-code-task-000286/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000286/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000412/environment/Dockerfile b/tasks/format-code-task-000412/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2ed8250a9d8d51186bd3cfed4105cd5687593b14 --- /dev/null +++ b/tasks/format-code-task-000412/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f466a789909cbf6443104446911dad14d69ac6814e23ef111c36e09e644adf60 diff --git a/tasks/format-code-task-000412/environment/setup/files/blocklist b/tasks/format-code-task-000412/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000412/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000412/environment/setup/setup.sh b/tasks/format-code-task-000412/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000412/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000412/tests/test.patch b/tasks/format-code-task-000412/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b11ed3f625b66a39a5ce658d0f19f88520d2f3fb --- /dev/null +++ b/tasks/format-code-task-000412/tests/test.patch @@ -0,0 +1,100 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..cd00a41745 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/serialization/test_serde.py -k backwards_compat -o addopts=''"] ++} +diff --git a/tests/serialization/test_serde.py b/tests/serialization/test_serde.py +index 1b2a426ac1..368726f781 100644 +--- a/tests/serialization/test_serde.py ++++ b/tests/serialization/test_serde.py +@@ -343,3 +343,73 @@ class TestSerDe: + TypeError, match="cannot serialize object of type " + ): + serialize(i) ++ ++ def test_backwards_compat_issue_xcom_dataset_single_nested(self): ++ """Issue 31866 reproduction: outer new-style Dataset wrapping inner old-style dict. ++ ++ Loading XCom entries created on Airflow 2.5 used to raise ++ ``KeyError: '__var'`` because ``_convert`` indexed ``__var`` twice. ++ """ ++ uri = "bq://google_cloud_default@?table=table_name&schema=schema_name" ++ data = { ++ "__classname__": "airflow.datasets.Dataset", ++ "__version__": 1, ++ "__data__": { ++ "__var": {"uri": uri, "extra": None}, ++ "__type": "dict", ++ }, ++ } ++ result = deserialize(data) ++ assert isinstance(result, Dataset) ++ assert result.uri == uri ++ assert result.extra is None ++ ++ def test_backwards_compat_issue_xcom_list_of_datasets(self): ++ """Exact list-of-Datasets shape from the bug report deserializes.""" ++ uri = "bq://google_cloud_default@?table=table_name&schema=schema_name" ++ value = [ ++ { ++ "__classname__": "airflow.datasets.Dataset", ++ "__version__": 1, ++ "__data__": { ++ "__var": {"uri": uri, "extra": None}, ++ "__type": "dict", ++ }, ++ } ++ ] ++ result = deserialize(value) ++ assert isinstance(result, list) ++ assert len(result) == 1 ++ assert isinstance(result[0], Dataset) ++ assert result[0].uri == uri ++ ++ def test_backwards_compat_old_style_dict(self): ++ """Old-style ``{"__type": "dict", "__var": }`` becomes the plain dict.""" ++ data = {"__type": "dict", "__var": {"a": 1, "b": 2}} ++ result = deserialize(data) ++ assert result == {"a": 1, "b": 2} ++ ++ def test_backwards_compat_double_nested_preserved(self): ++ """Existing double-nested old-style Dataset must still deserialize.""" ++ uri = "s3://does_not_exist" ++ data = { ++ "__type": "airflow.datasets.Dataset", ++ "__source": None, ++ "__var": { ++ "__var": {"uri": uri, "extra": None}, ++ "__type": "dict", ++ }, ++ } ++ dataset = deserialize(data) ++ assert isinstance(dataset, Dataset) ++ assert dataset.uri == uri ++ ++ def test_backwards_compat_single_nested_non_dict_preserved(self): ++ """Single-nested old-style non-dict class (e.g., Dataset directly) still works.""" ++ data = { ++ "__type": "airflow.datasets.Dataset", ++ "__var": {"uri": "s3://x", "extra": None}, ++ } ++ result = deserialize(data) ++ assert isinstance(result, Dataset) ++ assert result.uri == "s3://x" +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/serialization/test_serde.py -k backwards_compat -o addopts='' ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000412/tests/test.sh b/tasks/format-code-task-000412/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..936f729a520937bcbbcaf244d55f66cb9ee39fd2 --- /dev/null +++ b/tasks/format-code-task-000412/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/serialization/test_serde.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000412/tests/test_command.sh b/tasks/format-code-task-000412/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000412/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000415/environment/Dockerfile b/tasks/format-code-task-000415/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a0ac3d718583ee4f23f43101b71c8e2c24b5c16a --- /dev/null +++ b/tasks/format-code-task-000415/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:030e80c283526efdafeb0ae577b6450ac457ea74b94d2c6e64abd4d4e951a496 diff --git a/tasks/format-code-task-000415/environment/setup/files/blocklist b/tasks/format-code-task-000415/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000415/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000415/environment/setup/setup.sh b/tasks/format-code-task-000415/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000415/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000415/tests/test.patch b/tasks/format-code-task-000415/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ff9696d4ae8bb16c98b027db2b2dc280dcb03ebe --- /dev/null +++ b/tasks/format-code-task-000415/tests/test.patch @@ -0,0 +1,170 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..d5f0270a93 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/providers/ftp/hooks/test_ftp.py::TestFTPHookPort -v"] ++} +diff --git a/tests/providers/ftp/hooks/test_ftp.py b/tests/providers/ftp/hooks/test_ftp.py +index 2f4239b243..ebc44f0565 100644 +--- a/tests/providers/ftp/hooks/test_ftp.py ++++ b/tests/providers/ftp/hooks/test_ftp.py +@@ -183,3 +183,143 @@ class TestIntegrationFTPHook: + from airflow.providers.ftp.hooks.ftp import FTPSHook + + self._test_mode(FTPSHook, "ftp_active", False) ++ ++ ++@pytest.mark.db_test ++class TestFTPHookPort: ++ """Verify that FTPHook.get_conn honors the port set on the Connection.""" ++ ++ def setup_method(self): ++ from airflow.models import Connection ++ from airflow.utils import db ++ ++ db.merge_conn( ++ Connection( ++ conn_id="ftp_custom_port", ++ conn_type="ftp", ++ host="some-ftp-host", ++ login="user", ++ password="pwd", ++ port=2121, ++ ) ++ ) ++ db.merge_conn( ++ Connection( ++ conn_id="ftp_no_port", ++ conn_type="ftp", ++ host="some-ftp-host", ++ login="user", ++ password="pwd", ++ ) ++ ) ++ ++ @mock.patch("ftplib.FTP") ++ def test_ftp_get_conn_uses_custom_port(self, mock_ftp): ++ """When Connection.port is set, FTPHook must propagate it to the FTP server.""" ++ from airflow.providers.ftp.hooks.ftp import FTPHook ++ ++ hook = FTPHook("ftp_custom_port") ++ hook.get_conn() ++ ++ mock_ftp.return_value.connect.assert_called_once() ++ call_args = mock_ftp.return_value.connect.call_args ++ ++ port_value = None ++ host_value = None ++ if len(call_args.args) >= 1: ++ host_value = call_args.args[0] ++ if len(call_args.args) >= 2: ++ port_value = call_args.args[1] ++ if "host" in call_args.kwargs: ++ host_value = call_args.kwargs["host"] ++ if "port" in call_args.kwargs: ++ port_value = call_args.kwargs["port"] ++ ++ assert host_value == "some-ftp-host" ++ assert port_value == 2121, ( ++ f"Expected FTP.connect to be called with port=2121, got port={port_value!r} " ++ f"(full call: {call_args!r})" ++ ) ++ ++ @mock.patch("ftplib.FTP") ++ def test_ftp_get_conn_default_port_when_unset(self, mock_ftp): ++ """When Connection.port is not set, FTPHook must still produce a working ++ connection on the default FTP port (21). Any of these are valid: ++ - connect(host) (lets ftplib use self.port == FTP_PORT) ++ - connect(host, 21) ++ - connect(host, 0) (ftplib treats port=0 as "keep self.port") ++ """ ++ import ftplib as _ftplib ++ ++ from airflow.providers.ftp.hooks.ftp import FTPHook ++ ++ hook = FTPHook("ftp_no_port") ++ hook.get_conn() ++ ++ mock_ftp.return_value.connect.assert_called_once() ++ call_args = mock_ftp.return_value.connect.call_args ++ ++ ++ host_value = None ++ port_value = "" ++ if len(call_args.args) >= 1: ++ host_value = call_args.args[0] ++ if len(call_args.args) >= 2: ++ port_value = call_args.args[1] ++ if "host" in call_args.kwargs: ++ host_value = call_args.kwargs["host"] ++ if "port" in call_args.kwargs: ++ port_value = call_args.kwargs["port"] ++ ++ assert host_value == "some-ftp-host" ++ ++ assert port_value in ("", 0, None, _ftplib.FTP_PORT), ( ++ f"Default-port connection produced unexpected port arg: {port_value!r}" ++ ) ++ ++ @mock.patch("ftplib.FTP") ++ def test_ftp_get_conn_custom_port_does_not_use_constructor_host(self, mock_ftp): ++ """The fix should build FTP() without immediately constructing it with the ++ host (the buggy form ``FTP(host, login, password)`` ignores port). Verify the ++ connection is established explicitly via FTP().connect(...) so the custom port ++ actually reaches the server. ++ """ ++ from airflow.providers.ftp.hooks.ftp import FTPHook ++ ++ hook = FTPHook("ftp_custom_port") ++ hook.get_conn() ++ ++ ++ ++ ++ mock_ftp.return_value.connect.assert_called_once() ++ ++ call_args = mock_ftp.return_value.connect.call_args ++ all_values = list(call_args.args) + list(call_args.kwargs.values()) ++ assert 2121 in all_values, ( ++ f"Port 2121 was not propagated to FTP.connect (got args={call_args!r})" ++ ) ++ ++ @mock.patch("ftplib.FTP") ++ def test_ftp_get_conn_passive_mode_preserved_with_custom_port(self, mock_ftp): ++ """Passive-mode behavior must continue to work when a custom port is set.""" ++ from airflow.models import Connection ++ from airflow.providers.ftp.hooks.ftp import FTPHook ++ from airflow.utils import db ++ ++ db.merge_conn( ++ Connection( ++ conn_id="ftp_custom_port_active", ++ conn_type="ftp", ++ host="some-ftp-host", ++ login="user", ++ password="pwd", ++ port=2121, ++ extra='{"passive": false}', ++ ) ++ ) ++ ++ hook = FTPHook("ftp_custom_port_active") ++ conn = hook.get_conn() ++ ++ conn.set_pasv.assert_called_once_with(False) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/providers/ftp/hooks/test_ftp.py::TestFTPHookPort -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000415/tests/test.sh b/tasks/format-code-task-000415/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1315f1cb98083b4387e76c591c6b872e107988d4 --- /dev/null +++ b/tasks/format-code-task-000415/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/providers/ftp/hooks/test_ftp.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000415/tests/test_command.sh b/tasks/format-code-task-000415/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000415/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000448/environment/Dockerfile b/tasks/format-code-task-000448/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..df8b1084a0e1585103987baa608ee9b007cc7a4e --- /dev/null +++ b/tasks/format-code-task-000448/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ebfdf272414497eb1eb65109541720927b440781812e4f3b61337660482a0bb2 diff --git a/tasks/format-code-task-000448/environment/setup/files/blocklist b/tasks/format-code-task-000448/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000448/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000448/environment/setup/setup.sh b/tasks/format-code-task-000448/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000448/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000448/tests/test.patch b/tasks/format-code-task-000448/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..de5ed2882e52af5f28c0aa00c7d14f068012afe1 --- /dev/null +++ b/tasks/format-code-task-000448/tests/test.patch @@ -0,0 +1,147 @@ +diff --git a/controllers/argocd/configmap_test.go b/controllers/argocd/configmap_test.go +index a997f38e..a352d7fd 100644 +--- a/controllers/argocd/configmap_test.go ++++ b/controllers/argocd/configmap_test.go +@@ -83,6 +83,120 @@ func TestReconcileArgoCD_reconcileTLSCerts_withUpdate(t *testing.T) { + } + } + ++ ++ ++ ++ ++func TestReconcileArgoCD_reconcileTLSCerts_preservesGuiAddedCert(t *testing.T) { ++ logf.SetLogger(ZapLogger(true)) ++ ++ ++ a := makeTestArgoCD(initialCerts(t, "root-ca.example.com")) ++ r := makeTestReconciler(t, a) ++ ++ ++ ++ existingCM := &corev1.ConfigMap{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: common.ArgoCDTLSCertsConfigMapName, ++ Namespace: a.Namespace, ++ }, ++ Data: map[string]string{ ++ "gui-added.example.com": "GUI_ADDED_CERT_PEM", ++ }, ++ } ++ assert.NoError(t, r.Client.Create(context.TODO(), existingCM)) ++ ++ assert.NoError(t, r.reconcileTLSCerts(a)) ++ ++ configMap := &corev1.ConfigMap{} ++ assert.NoError(t, r.Client.Get( ++ context.TODO(), ++ types.NamespacedName{ ++ Name: common.ArgoCDTLSCertsConfigMapName, ++ Namespace: a.Namespace, ++ }, ++ configMap)) ++ ++ ++ ++ ++ wantKeys := []string{"gui-added.example.com"} ++ if k := stringMapKeys(configMap.Data); !reflect.DeepEqual(wantKeys, k) { ++ t.Fatalf("got keys %#v, want %#v\n", k, wantKeys) ++ } ++ if got := configMap.Data["gui-added.example.com"]; got != "GUI_ADDED_CERT_PEM" { ++ t.Fatalf("user-added cert value got %q, want %q", got, "GUI_ADDED_CERT_PEM") ++ } ++ if _, present := configMap.Data["root-ca.example.com"]; present { ++ t.Fatalf("ConfigMap was overwritten: spec.tls.initialCerts entry %q must not have been added", "root-ca.example.com") ++ } ++} ++ ++ ++ ++ ++ ++func TestReconcileArgoCD_reconcileTLSCerts_preservesUserDeletion(t *testing.T) { ++ logf.SetLogger(ZapLogger(true)) ++ a := makeTestArgoCD(initialCerts(t, "root-ca.example.com")) ++ r := makeTestReconciler(t, a) ++ ++ ++ ++ existingCM := &corev1.ConfigMap{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: common.ArgoCDTLSCertsConfigMapName, ++ Namespace: a.Namespace, ++ }, ++ Data: map[string]string{}, ++ } ++ assert.NoError(t, r.Client.Create(context.TODO(), existingCM)) ++ ++ assert.NoError(t, r.reconcileTLSCerts(a)) ++ ++ configMap := &corev1.ConfigMap{} ++ assert.NoError(t, r.Client.Get( ++ context.TODO(), ++ types.NamespacedName{ ++ Name: common.ArgoCDTLSCertsConfigMapName, ++ Namespace: a.Namespace, ++ }, ++ configMap)) ++ ++ if _, present := configMap.Data["root-ca.example.com"]; present { ++ t.Fatalf("reconcile re-added %q from spec.tls.initialCerts; expected user deletion to be preserved", "root-ca.example.com") ++ } ++ if len(configMap.Data) != 0 { ++ t.Fatalf("expected ConfigMap data to remain empty, got %#v", configMap.Data) ++ } ++} ++ ++ ++ ++ ++func TestReconcileArgoCD_reconcileTLSCerts_createsWhenMissing(t *testing.T) { ++ logf.SetLogger(ZapLogger(true)) ++ a := makeTestArgoCD(initialCerts(t, "first-create.example.com")) ++ r := makeTestReconciler(t, a) ++ ++ assert.NoError(t, r.reconcileTLSCerts(a)) ++ ++ configMap := &corev1.ConfigMap{} ++ assert.NoError(t, r.Client.Get( ++ context.TODO(), ++ types.NamespacedName{ ++ Name: common.ArgoCDTLSCertsConfigMapName, ++ Namespace: a.Namespace, ++ }, ++ configMap)) ++ ++ want := []string{"first-create.example.com"} ++ if k := stringMapKeys(configMap.Data); !reflect.DeepEqual(want, k) { ++ t.Fatalf("got %#v, want %#v\n", k, want) ++ } ++} ++ + func TestReconcileArgoCD_reconcileArgoConfigMap(t *testing.T) { + logf.SetLogger(ZapLogger(true)) + a := makeTestArgoCD() +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..27da5492 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test -run 'TestReconcileArgoCD_reconcileTLSCerts_preservesGuiAddedCert|TestReconcileArgoCD_reconcileTLSCerts_preservesUserDeletion|TestReconcileArgoCD_reconcileTLSCerts_createsWhenMissing' ./controllers/argocd/"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test -run 'TestReconcileArgoCD_reconcileTLSCerts_preservesGuiAddedCert|TestReconcileArgoCD_reconcileTLSCerts_preservesUserDeletion|TestReconcileArgoCD_reconcileTLSCerts_createsWhenMissing' ./controllers/argocd/ ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000448/tests/test.sh b/tasks/format-code-task-000448/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ac6979d640075cfa6dac183865d48436192cbf3 --- /dev/null +++ b/tasks/format-code-task-000448/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +controllers/argocd/configmap_test.go +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000448/tests/test_command.sh b/tasks/format-code-task-000448/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000448/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000449/environment/Dockerfile b/tasks/format-code-task-000449/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..af5476f86f0f28b4d531662b8a9e579d1ab7ad03 --- /dev/null +++ b/tasks/format-code-task-000449/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:69cba9906273558ed449bac242faeff2ec1f3e6302a50f1f654c43feb27dffe2 diff --git a/tasks/format-code-task-000449/environment/setup/files/blocklist b/tasks/format-code-task-000449/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000449/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000449/environment/setup/setup.sh b/tasks/format-code-task-000449/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000449/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000449/tests/test.patch b/tasks/format-code-task-000449/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7e8efad77fa2703c422752ab7584aaba27b3b2de --- /dev/null +++ b/tasks/format-code-task-000449/tests/test.patch @@ -0,0 +1,232 @@ +diff --git a/controllers/argocd/deployment_test.go b/controllers/argocd/deployment_test.go +index aac4e9f08..7cb5b378f 100644 +--- a/controllers/argocd/deployment_test.go ++++ b/controllers/argocd/deployment_test.go +@@ -1651,3 +1651,94 @@ func TestReconcileArgoCD_reconcile_RepoServerChanges(t *testing.T) { + }) + } + } ++ ++func TestArgoCDRepoServerDeploymentCommand(t *testing.T) { ++ a := makeTestArgoCD() ++ r := makeTestReconciler(t, a) ++ ++ testRedisServerAddress := getRedisServerAddress(a) ++ ++ baseCommand := []string{ ++ "uid_entrypoint.sh", ++ "argocd-repo-server", ++ "--redis", ++ testRedisServerAddress, ++ "--loglevel", ++ "info", ++ "--logformat", ++ "text", ++ } ++ ++ ++ a.Spec.Repo.ExtraRepoCommandArgs = []string{ ++ "--reposerver.max.combined.directory.manifests.size", ++ "10M", ++ } ++ ++ deployment := &appsv1.Deployment{} ++ assert.NoError(t, r.reconcileRepoDeployment(a, false)) ++ ++ assert.NoError(t, r.Client.Get( ++ context.TODO(), ++ types.NamespacedName{ ++ Name: "argocd-repo-server", ++ Namespace: a.Namespace, ++ }, ++ deployment)) ++ ++ cmd := append(baseCommand, ++ "--reposerver.max.combined.directory.manifests.size", "10M") ++ assert.Equal(t, cmd, deployment.Spec.Template.Spec.Containers[0].Command) ++ ++ ++ a.Spec.Repo.ExtraRepoCommandArgs = []string{ ++ "--reposerver.max.combined.directory.manifests.size", ++ "10M", ++ "--foo", ++ "bar", ++ "test", ++ } ++ ++ assert.NoError(t, r.reconcileRepoDeployment(a, false)) ++ assert.NoError(t, r.Client.Get( ++ context.TODO(), ++ types.NamespacedName{ ++ Name: "argocd-repo-server", ++ Namespace: a.Namespace, ++ }, ++ deployment)) ++ ++ cmd = append(cmd, "--foo", "bar", "test") ++ assert.Equal(t, cmd, deployment.Spec.Template.Spec.Containers[0].Command) ++ ++ ++ a.Spec.Repo.ExtraRepoCommandArgs = []string{ ++ "--redis", ++ "foo.scv.cluster.local:6379", ++ } ++ ++ assert.NoError(t, r.reconcileRepoDeployment(a, false)) ++ assert.NoError(t, r.Client.Get( ++ context.TODO(), ++ types.NamespacedName{ ++ Name: "argocd-repo-server", ++ Namespace: a.Namespace, ++ }, ++ deployment)) ++ ++ assert.Equal(t, baseCommand, deployment.Spec.Template.Spec.Containers[0].Command) ++ ++ ++ a.Spec.Repo.ExtraRepoCommandArgs = []string{} ++ ++ assert.NoError(t, r.reconcileRepoDeployment(a, false)) ++ assert.NoError(t, r.Client.Get( ++ context.TODO(), ++ types.NamespacedName{ ++ Name: "argocd-repo-server", ++ Namespace: a.Namespace, ++ }, ++ deployment)) ++ ++ assert.Equal(t, baseCommand, deployment.Spec.Template.Spec.Containers[0].Command) ++} +diff --git a/tests/k8s/1-028_validate_extra_repo_commands_args/01-assert.yaml b/tests/k8s/1-028_validate_extra_repo_commands_args/01-assert.yaml +new file mode 100644 +index 000000000..b3b5cbd3c +--- /dev/null ++++ b/tests/k8s/1-028_validate_extra_repo_commands_args/01-assert.yaml +@@ -0,0 +1,17 @@ ++--- ++apiVersion: argoproj.io/v1alpha1 ++kind: ArgoCD ++metadata: ++ name: example-argocd ++ namespace: test-1-28-repo-extra-command ++ ++status: ++ phase: Available ++--- ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: example-argocd-repo-server ++ namespace: test-1-28-repo-extra-command ++status: ++ readyReplicas: 1 +\ No newline at end of file +diff --git a/tests/k8s/1-028_validate_extra_repo_commands_args/01-basic-argocd-install.yaml b/tests/k8s/1-028_validate_extra_repo_commands_args/01-basic-argocd-install.yaml +new file mode 100644 +index 000000000..4fc777b6c +--- /dev/null ++++ b/tests/k8s/1-028_validate_extra_repo_commands_args/01-basic-argocd-install.yaml +@@ -0,0 +1,14 @@ ++--- ++apiVersion: v1 ++kind: Namespace ++metadata: ++ name: test-1-28-repo-extra-command ++--- ++apiVersion: argoproj.io/v1alpha1 ++kind: ArgoCD ++metadata: ++ name: example-argocd ++ namespace: test-1-28-repo-extra-command ++ labels: ++ example: basic ++spec: {} +\ No newline at end of file +diff --git a/tests/k8s/1-028_validate_extra_repo_commands_args/02-add-extraRepoCommandArgs.yaml b/tests/k8s/1-028_validate_extra_repo_commands_args/02-add-extraRepoCommandArgs.yaml +new file mode 100644 +index 000000000..858fc792f +--- /dev/null ++++ b/tests/k8s/1-028_validate_extra_repo_commands_args/02-add-extraRepoCommandArgs.yaml +@@ -0,0 +1,10 @@ ++apiVersion: argoproj.io/v1alpha1 ++kind: ArgoCD ++metadata: ++ name: example-argocd ++ namespace: test-1-28-repo-extra-command ++spec: ++ repo: ++ extraRepoCommandArgs: ++ - --reposerver.max.combined.directory.manifests.size ++ - 10M +\ No newline at end of file +diff --git a/tests/k8s/1-028_validate_extra_repo_commands_args/02-assert.yaml b/tests/k8s/1-028_validate_extra_repo_commands_args/02-assert.yaml +new file mode 100644 +index 000000000..d9e6cdc17 +--- /dev/null ++++ b/tests/k8s/1-028_validate_extra_repo_commands_args/02-assert.yaml +@@ -0,0 +1,26 @@ ++--- ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: example-argocd-repo-server ++ namespace: test-1-28-repo-extra-command ++spec: ++ selector: ++ matchLabels: ++ app.kubernetes.io/name: example-argocd-repo-server ++ template: ++ spec: ++ containers: ++ - command: ++ - uid_entrypoint.sh ++ - argocd-repo-server ++ - --redis ++ - example-argocd-redis.test-1-28-repo-extra-command.svc.cluster.local:6379 ++ - --loglevel ++ - info ++ - --logformat ++ - text ++ - --reposerver.max.combined.directory.manifests.size ++ - 10M ++ name: argocd-repo-server ++ +diff --git a/tests/k8s/1-028_validate_extra_repo_commands_args/99-delete.yaml b/tests/k8s/1-028_validate_extra_repo_commands_args/99-delete.yaml +new file mode 100644 +index 000000000..16c51d214 +--- /dev/null ++++ b/tests/k8s/1-028_validate_extra_repo_commands_args/99-delete.yaml +@@ -0,0 +1,7 @@ ++--- ++apiVersion: kuttl.dev/v1beta1 ++kind: TestStep ++delete: ++- apiVersion: v1 ++ kind: Namespace ++ name: test-1-28-repo-extra-command +\ No newline at end of file +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+2TTW/TQBCGc/avmKYcymH9kSZpS8WhaqWqBzg0iAsga+MdN6tudsPu2mr+PWMn ++qBUCKpFUCDHPxWvP6N35eJ3OG21UibbNBi9FTpxMJv2T+PHZn4vJqBjl4+OTSTHIi2KaFwOYvFhF ++T2hClB5g4J2Lv8t7Lv6Pkj7uP2KIZeWWS2lVGhb7u+OZ/RfH0/Hj/vMp7X88HdH+8/2V8Gv+8/0f ++HmRzbbO5DIukUtCbYI4qSQ7htrEQFwjXDhqrI3QhqJ0HjysnAvoWPeBD9BK2rgHp70Jy5zapaVY5 ++G70zBn3IKOQqlYHwJPuB4hf04fLqlrRmvdQVroxbL9HGy62aaEFUrrHxbdHV8xG9rtdw38RoNjdQ ++lq7pEKgMTe9HVG5Aqu9roz2CBKNbhMrQjqnU6CgNqybi66RrowZt4XMCvVbI7k9DVoh8dFq20mgl ++I5Z9c2XX7vf/IpRdi1leCBloAjFdy6X5cxEau67EZjRCW7KiMTtJjoRUSvTxbrLbSdKow66yO7d7 ++diYUGozYi5yDciSja/gEByBqGL6qh/DlvHOcpQAAVgsHw3c3s9nN++s3QOHN5weyYkHHWifKWUw2 ++eRfG/NwZbecajQpWnrxhYzpM/vY/xzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMs0++AT9ytgsAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000449/tests/test.sh b/tasks/format-code-task-000449/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b86e7b2a3afe8989163d1f47d11100bf26a7fbff --- /dev/null +++ b/tasks/format-code-task-000449/tests/test.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +controllers/argocd/deployment_test.go +tests/k8s/1-028_validate_extra_repo_commands_args/01-assert.yaml +tests/k8s/1-028_validate_extra_repo_commands_args/01-basic-argocd-install.yaml +tests/k8s/1-028_validate_extra_repo_commands_args/02-add-extraRepoCommandArgs.yaml +tests/k8s/1-028_validate_extra_repo_commands_args/02-assert.yaml +tests/k8s/1-028_validate_extra_repo_commands_args/99-delete.yaml +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000449/tests/test_command.sh b/tasks/format-code-task-000449/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000449/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000471/environment/Dockerfile b/tasks/format-code-task-000471/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7a5410df47f6966aad2b6878ef5d93ef016c5eef --- /dev/null +++ b/tasks/format-code-task-000471/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7c8bf790c44dfd79435f00500a1164e3253d3570a0ba17951d83a541fa676077 diff --git a/tasks/format-code-task-000471/environment/setup/files/blocklist b/tasks/format-code-task-000471/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000471/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000471/environment/setup/setup.sh b/tasks/format-code-task-000471/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000471/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000471/tests/test.patch b/tasks/format-code-task-000471/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ae463d57174b1a0a483ca72507b0a1f5a2608fa9 --- /dev/null +++ b/tasks/format-code-task-000471/tests/test.patch @@ -0,0 +1,272 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..a259902 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,5 @@ ++{ ++ "test_commands": [ ++ "python -m pytest tests/amazon/aws/hooks/test_s3_hooks.py tests/amazon/aws/triggers/test_s3_triggers.py tests/amazon/aws/sensors/test_s3_sensors.py -k 'use_regex or check_key_propagates'" ++ ] ++} +diff --git a/tests/amazon/aws/hooks/test_s3_hooks.py b/tests/amazon/aws/hooks/test_s3_hooks.py +index 3273831..45b9169 100644 +--- a/tests/amazon/aws/hooks/test_s3_hooks.py ++++ b/tests/amazon/aws/hooks/test_s3_hooks.py +@@ -494,3 +494,167 @@ class TestS3HookAsync: + mock_client.return_value, "test_bucket", True, "test/example_s3_test_file.txt" + ) + assert response is False ++ ++ @pytest.mark.asyncio ++ @mock.patch("airflow.providers.amazon.aws.hooks.s3.S3Hook.get_s3_bucket_key") ++ @mock.patch("astronomer.providers.amazon.aws.hooks.s3.S3HookAsync.get_file_metadata") ++ @mock.patch("astronomer.providers.amazon.aws.hooks.s3.S3HookAsync.get_client_async") ++ async def test_s3__check_key_use_regex_match( ++ self, mock_client, mock_get_file_metadata, mock_get_bucket_key ++ ): ++ """_check_key with use_regex=True returns True when regex matches at least one key.""" ++ mock_get_bucket_key.return_value = ( ++ "test_bucket", ++ r"(?= 1 +diff --git a/tests/amazon/aws/sensors/test_s3_sensors.py b/tests/amazon/aws/sensors/test_s3_sensors.py +index 55c4bf1..6b1b45c 100644 +--- a/tests/amazon/aws/sensors/test_s3_sensors.py ++++ b/tests/amazon/aws/sensors/test_s3_sensors.py +@@ -259,6 +259,23 @@ class TestS3KeySensorAsync: + + assert isinstance(exc.value.trigger, S3KeyTrigger), "Trigger is not a S3KeyTrigger" + ++ @mock.patch(f"{MODULE}.S3KeySensorAsync.poke", return_value=False) ++ def test_s3_key_sensor_async_use_regex_propagated_to_trigger(self, mock_poke, context): ++ """S3KeySensorAsync(use_regex=True) defers a S3KeyTrigger that carries use_regex=True.""" ++ sensor = S3KeySensorAsync( ++ task_id="s3_key_sensor_async_regex", ++ bucket_key=r"(?= 1 ++ call_args = mock_check_key.await_args ++ ++ passed = call_args.kwargs.get("use_regex") ++ if passed is None and len(call_args.args) >= 5: ++ passed = call_args.args[4] ++ assert passed is True ++ + + class TestS3KeysUnchangedTrigger: + def test_serialization(self): +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -rA tests/amazon/aws/hooks/test_s3_hooks.py::TestS3HookAsync::test_s3__check_key_use_regex_match tests/amazon/aws/hooks/test_s3_hooks.py::TestS3HookAsync::test_s3__check_key_use_regex_no_match tests/amazon/aws/hooks/test_s3_hooks.py::TestS3HookAsync::test_s3__check_key_use_regex_uses_re_match_not_fnmatch tests/amazon/aws/hooks/test_s3_hooks.py::TestS3HookAsync::test_s3__check_key_use_regex_false_default_path_unchanged tests/amazon/aws/hooks/test_s3_hooks.py::TestS3HookAsync::test_s3_check_key_propagates_use_regex tests/amazon/aws/sensors/test_s3_sensors.py::TestS3KeySensorAsync::test_s3_key_sensor_async_use_regex_propagated_to_trigger tests/amazon/aws/triggers/test_s3_triggers.py::TestS3KeyTrigger::test_serialization_with_use_regex tests/amazon/aws/triggers/test_s3_triggers.py::TestS3KeyTrigger::test_run_passes_use_regex_to_check_key ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000471/tests/test.sh b/tasks/format-code-task-000471/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d034caed66ffe737e6918691842ef2c211eb7ef9 --- /dev/null +++ b/tasks/format-code-task-000471/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/amazon/aws/hooks/test_s3_hooks.py +tests/amazon/aws/sensors/test_s3_sensors.py +tests/amazon/aws/triggers/test_s3_triggers.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000471/tests/test_command.sh b/tasks/format-code-task-000471/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000471/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000476/environment/Dockerfile b/tasks/format-code-task-000476/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8ef183d3ced77617f36d9a6cec043bef3349e171 --- /dev/null +++ b/tasks/format-code-task-000476/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6d39f1fe89a85d643b54a728855561ca9051e2397d10f798633cb3ec1bd33d06 diff --git a/tasks/format-code-task-000476/environment/setup/files/blocklist b/tasks/format-code-task-000476/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000476/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000476/environment/setup/setup.sh b/tasks/format-code-task-000476/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000476/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000476/tests/test.patch b/tasks/format-code-task-000476/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..67a32df449f5f33537e64707920a28e19ff6abc9 --- /dev/null +++ b/tasks/format-code-task-000476/tests/test.patch @@ -0,0 +1,285 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,256 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++export GO111MODULE=off GOPROXY=off GOSUMDB=off GONOSUMDB='*' GOTOOLCHAIN=local ++export GOFLAGS= ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++( cd /workspace/repo && go build -o "$TMP/gosaic" . ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN="$TMP/gosaic" ++ ++command -v sqlite3 >/dev/null 2>&1 || fail "sqlite3 is required" ++ ++make_fixture_program() { ++ cat > "$TMP/mkfixtures.go" <<'GO' ++package main ++ ++import ( ++ "bytes" ++ "image" ++ "image/color" ++ "image/jpeg" ++ "image/png" ++ "os" ++ "path/filepath" ++) ++ ++func fill(w, h int, c color.RGBA) *image.RGBA { ++ img := image.NewRGBA(image.Rect(0, 0, w, h)) ++ for y := 0; y < h; y++ { ++ for x := 0; x < w; x++ { ++ img.SetRGBA(x, y, c) ++ } ++ } ++ return img ++} ++ ++func writePNG(path string, w, h int, c color.RGBA) { ++ f, err := os.Create(path) ++ if err != nil { ++ panic(err) ++ } ++ defer f.Close() ++ if err := png.Encode(f, fill(w, h, c)); err != nil { ++ panic(err) ++ } ++} ++ ++func exifSegment(orientation byte) []byte { ++ payload := []byte{ ++ 'E', 'x', 'i', 'f', 0, 0, ++ 'I', 'I', 42, 0, 8, 0, 0, 0, ++ 1, 0, ++ 0x12, 0x01, 3, 0, 1, 0, 0, 0, orientation, 0, 0, 0, ++ 0, 0, 0, 0, ++ } ++ length := len(payload) + 2 ++ seg := []byte{0xff, 0xe1, byte(length >> 8), byte(length)} ++ return append(seg, payload...) ++} ++ ++func writeJPEG(path string, w, h int, c color.RGBA, orientation int) { ++ var b bytes.Buffer ++ if err := jpeg.Encode(&b, fill(w, h, c), &jpeg.Options{Quality: 90}); err != nil { ++ panic(err) ++ } ++ data := b.Bytes() ++ if orientation >= 0 { ++ data = append(append(append([]byte{}, data[:2]...), exifSegment(byte(orientation))...), data[2:]...) ++ } ++ if err := os.WriteFile(path, data, 0644); err != nil { ++ panic(err) ++ } ++} ++ ++func main() { ++ root := os.Args[1] ++ mode := os.Args[2] ++ ++ switch mode { ++ case "main": ++ os.MkdirAll(filepath.Join(root, "tiles", "nested"), 0755) ++ writePNG(filepath.Join(root, "tiles", "a_square.png"), 2, 2, color.RGBA{255, 0, 0, 255}) ++ b, err := os.ReadFile(filepath.Join(root, "tiles", "a_square.png")) ++ if err != nil { ++ panic(err) ++ } ++ if err := os.WriteFile(filepath.Join(root, "tiles", "aa_square_duplicate.png"), b, 0644); err != nil { ++ panic(err) ++ } ++ writeJPEG(filepath.Join(root, "tiles", "b_orient5.jpg"), 3, 5, color.RGBA{0, 255, 0, 255}, 5) ++ writeJPEG(filepath.Join(root, "tiles", "c_orient6.jpg"), 3, 5, color.RGBA{0, 200, 50, 255}, 6) ++ writeJPEG(filepath.Join(root, "tiles", "d_orient7.jpeg"), 7, 4, color.RGBA{0, 0, 255, 255}, 7) ++ writeJPEG(filepath.Join(root, "tiles", "e_orient8.jpeg"), 7, 4, color.RGBA{20, 40, 200, 255}, 8) ++ writeJPEG(filepath.Join(root, "tiles", "f_zero_orientation.jpg"), 6, 4, color.RGBA{255, 255, 0, 255}, 0) ++ writeJPEG(filepath.Join(root, "tiles", "nested", "g_plain.jpeg"), 10, 6, color.RGBA{255, 0, 255, 255}, -1) ++ if err := os.WriteFile(filepath.Join(root, "tiles", "nested", "ignored.txt"), []byte("not an image"), 0644); err != nil { ++ panic(err) ++ } ++ case "stdin": ++ os.MkdirAll(filepath.Join(root, "stdin", "sub"), 0755) ++ writePNG(filepath.Join(root, "stdin", "one.png"), 1, 3, color.RGBA{10, 20, 30, 255}) ++ writeJPEG(filepath.Join(root, "stdin", "sub", "two.jpg"), 2, 1, color.RGBA{40, 50, 60, 255}, -1) ++ case "errors": ++ os.MkdirAll(filepath.Join(root, "errtiles"), 0755) ++ writePNG(filepath.Join(root, "errtiles", "good.png"), 3, 1, color.RGBA{1, 2, 3, 255}) ++ if err := os.WriteFile(filepath.Join(root, "errtiles", "bad.png"), []byte("not really a png"), 0644); err != nil { ++ panic(err) ++ } ++ default: ++ panic("unknown fixture mode") ++ } ++} ++GO ++} ++ ++strip_log_prefix() { ++ sed -E 's/^GOSAIC: [0-9]{4}\/[0-9]{2}\/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} //' ++} ++ ++output_contains() { ++ local base="$1" ++ local needle="$2" ++ grep -Fq "$needle" "$base/out" || grep -Fq "$needle" "$base/err" ++} ++ ++assert_gidx_row() { ++ local db="$1" ++ local path="$2" ++ local md5="$3" ++ local width="$4" ++ local height="$5" ++ local orientation="$6" ++ local actual ++ ++ actual=$(sqlite3 -separator '|' "$db" "select md5sum,width,height,orientation from gidx where path = '$path';") ++ [ "$actual" = "$md5|$width|$height|$orientation" ] || fail "metadata for $path differs: $actual" ++} ++ ++make_fixture_program ++ ++ ++ ++ ++F1="$TMP/f1" ++mkdir -p "$F1" ++go run "$TMP/mkfixtures.go" "$F1" main || fail "F1 fixture setup" ++DB1="$F1/gosaic.sqlite3" ++"$BIN" --dsn "sqlite3://$DB1" --workers 1 index "$F1/tiles" >"$F1/out" 2>"$F1/err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++output_contains "$F1" 'Indexing 8 images...' || fail "F1 missing indexing count: $(cat "$F1/out" "$F1/err")" ++ ++ ++SQUARE_COUNT=$(sqlite3 "$DB1" "select count(*) from gidx where md5sum = 'dcbfc6cd70daef3188f5439f9f3429d7';") ++[ "$SQUARE_COUNT" = "1" ] || fail "F1 square duplicate content count $SQUARE_COUNT; want 1" ++SQUARE_PATH=$(sqlite3 "$DB1" "select path from gidx where md5sum = 'dcbfc6cd70daef3188f5439f9f3429d7';") ++case "$SQUARE_PATH" in ++ "$F1/tiles/a_square.png"|"$F1/tiles/aa_square_duplicate.png") ;; ++ *) fail "F1 duplicate content stored unexpected path: $SQUARE_PATH" ;; ++esac ++assert_gidx_row "$DB1" "$SQUARE_PATH" "dcbfc6cd70daef3188f5439f9f3429d7" 2 2 1 ++assert_gidx_row "$DB1" "$F1/tiles/b_orient5.jpg" "e865e1b59ac7d52f0e979fbe17792923" 5 3 5 ++assert_gidx_row "$DB1" "$F1/tiles/c_orient6.jpg" "a95c8c7e3b2de60db8e37a4d5f4abda1" 5 3 6 ++assert_gidx_row "$DB1" "$F1/tiles/d_orient7.jpeg" "6f1cdd2357085f8ba3cd37d29a9b0f56" 4 7 7 ++assert_gidx_row "$DB1" "$F1/tiles/e_orient8.jpeg" "9ee6eb5ca0365af67878f0a39bde02ff" 4 7 8 ++assert_gidx_row "$DB1" "$F1/tiles/f_zero_orientation.jpg" "70769f947335910a4e3704c22631f7c1" 6 4 1 ++assert_gidx_row "$DB1" "$F1/tiles/nested/g_plain.jpeg" "e9dca4e53539e756cbdfa5d9206a79fc" 10 6 1 ++ ++GIDX_COUNT=$(sqlite3 "$DB1" 'select count(*) from gidx;') ++[ "$GIDX_COUNT" = "7" ] || fail "F1 gidx count $GIDX_COUNT; want 7" ++ASPECT_COUNT=$(sqlite3 "$DB1" 'select count(*) from aspects;') ++[ "$ASPECT_COUNT" = "4" ] || fail "F1 aspect count $ASPECT_COUNT; want 4" ++NON_ABS=$(sqlite3 "$DB1" "select count(*) from gidx where substr(path, 1, 1) != '/';") ++[ "$NON_ABS" = "0" ] || fail "F1 stored a non-absolute path" ++BAD_ASPECT_RATIOS=$(sqlite3 "$DB1" 'select count(*) from gidx join aspects on aspects.id = gidx.aspect_id where aspects.columns * gidx.height != aspects.rows * gidx.width;') ++[ "$BAD_ASPECT_RATIOS" = "0" ] || fail "F1 aspect rows do not match indexed dimensions" ++REUSED_5X3=$(sqlite3 "$DB1" "select count(distinct aspect_id) from gidx where path in ('$F1/tiles/b_orient5.jpg', '$F1/tiles/c_orient6.jpg', '$F1/tiles/nested/g_plain.jpeg');") ++[ "$REUSED_5X3" = "1" ] || fail "F1 did not reuse the 5:3 aspect record" ++REUSED_4X7=$(sqlite3 "$DB1" "select count(distinct aspect_id) from gidx where path in ('$F1/tiles/d_orient7.jpeg', '$F1/tiles/e_orient8.jpeg');") ++[ "$REUSED_4X7" = "1" ] || fail "F1 did not reuse the 4:7 aspect record" ++ ++"$BIN" --dsn "sqlite3://$DB1" --workers 1 index --list >"$F1/listout" 2>"$F1/listerr"; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 list exit $ec; want 0" ++ ++cat "$F1/listout" "$F1/listerr" | strip_log_prefix | sed '/^$/d' >"$F1/listpaths" ++LIST_COUNT=$(wc -l <"$F1/listpaths" | tr -d ' ') ++[ "$LIST_COUNT" = "7" ] || fail "F1 list count $LIST_COUNT; want 7: $(cat "$F1/listpaths")" ++UNIQUE_LIST_COUNT=$(sort "$F1/listpaths" | uniq | wc -l | tr -d ' ') ++[ "$UNIQUE_LIST_COUNT" = "7" ] || fail "F1 list contains duplicate paths: $(cat "$F1/listpaths")" ++for p in \ ++ "$F1/tiles/b_orient5.jpg" \ ++ "$F1/tiles/c_orient6.jpg" \ ++ "$F1/tiles/d_orient7.jpeg" \ ++ "$F1/tiles/e_orient8.jpeg" \ ++ "$F1/tiles/f_zero_orientation.jpg" \ ++ "$F1/tiles/nested/g_plain.jpeg" ++do ++ grep -Fxq "$p" "$F1/listpaths" || fail "F1 list missing $p: $(cat "$F1/listpaths")" ++done ++SQUARE_LIST_COUNT=$(grep -Fx -e "$F1/tiles/a_square.png" -e "$F1/tiles/aa_square_duplicate.png" "$F1/listpaths" | wc -l | tr -d ' ') ++[ "$SQUARE_LIST_COUNT" = "1" ] || fail "F1 list should include exactly one duplicate-content path: $(cat "$F1/listpaths")" ++ ++ ++ ++ ++F2="$TMP/f2" ++mkdir -p "$F2" ++go run "$TMP/mkfixtures.go" "$F2" stdin || fail "F2 fixture setup" ++DB2="$F2/gosaic.sqlite3" ++printf '%s\n%s\n' "$F2/stdin/one.png" "$F2/stdin/sub" | "$BIN" --dsn "sqlite3://$DB2" --workers 1 index >"$F2/out" 2>"$F2/err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++output_contains "$F2" 'Indexing 2 images...' || fail "F2 missing indexing count: $(cat "$F2/out" "$F2/err")" ++ACTUAL_ROWS=$(sqlite3 -separator '|' "$DB2" 'select path,md5sum,width,height,orientation from gidx order by path;') ++EXPECTED_ROWS="$F2/stdin/one.png|edd7d1b2b9b212fcd7ff7b7480b38cdb|1|3|1 ++$F2/stdin/sub/two.jpg|b24d08565c5707482524485aec38c6f3|2|1|1" ++[ "$ACTUAL_ROWS" = "$EXPECTED_ROWS" ] || fail "F2 database rows differ: $ACTUAL_ROWS" ++ ++ ++ ++ ++F3="$TMP/f3" ++mkdir -p "$F3" ++DB3="$F3/gosaic.sqlite3" ++"$BIN" --dsn "sqlite3://$DB3" --workers 1 index >"$F3/out" 2>"$F3/err"; ec=$? ++[ "$ec" -eq 1 ] || fail "F3 exit $ec; want 1" ++ ++output_contains "$F3" 'Must specify paths to index' || fail "F3 missing fatal message: $(cat "$F3/out" "$F3/err")" ++ ++ ++ ++ ++F4="$TMP/f4" ++mkdir -p "$F4" ++go run "$TMP/mkfixtures.go" "$F4" errors || fail "F4 fixture setup" ++DB4="$F4/gosaic.sqlite3" ++"$BIN" --dsn "sqlite3://$DB4" --workers 1 index "$F4/does-not-exist" "$F4/errtiles" >"$F4/out" 2>"$F4/err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++ ++cat "$F4/out" "$F4/err" >"$F4/all" ++grep -Fi 'error' "$F4/all" | grep -Fq "$F4/does-not-exist" || fail "F4 missing missing-path error: $(cat "$F4/all")" ++grep -Fi 'error' "$F4/all" | grep -Fq "$F4/errtiles/bad.png" || fail "F4 missing bad-image error: $(cat "$F4/all")" ++ ++grep -Fq 'Indexing ' "$F4/all" || fail "F4 missing indexing progress line: $(cat "$F4/all")" ++ACTUAL_ROWS=$(sqlite3 -separator '|' "$DB4" 'select path,md5sum,width,height,orientation from gidx order by path;') ++EXPECTED_ROWS="$F4/errtiles/good.png|f360ad15c1e137a8195e2014ff6dfcb7|3|1|1" ++[ "$ACTUAL_ROWS" = "$EXPECTED_ROWS" ] || fail "F4 database rows differ: $ACTUAL_ROWS" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++export GO111MODULE=off ++export GOPROXY=off ++export GOSUMDB=off ++export GONOSUMDB='*' ++export GOTOOLCHAIN=local ++export GOFLAGS= ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000476/tests/test.sh b/tasks/format-code-task-000476/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000476/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000476/tests/test_command.sh b/tasks/format-code-task-000476/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000476/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000478/tests/test.patch b/tasks/format-code-task-000478/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1c52ff34bc653e4d019f5fe97de82704abd172f4 --- /dev/null +++ b/tasks/format-code-task-000478/tests/test.patch @@ -0,0 +1,222 @@ +diff --git a/src/test/java/com/auth0/client/mgmt/JobsEntityTest.java b/src/test/java/com/auth0/client/mgmt/JobsEntityTest.java +new file mode 100644 +index 00000000..11111111 +--- /dev/null ++++ b/src/test/java/com/auth0/client/mgmt/JobsEntityTest.java +@@ -0,0 +1,99 @@ ++package com.auth0.client.mgmt; ++ ++import com.auth0.json.mgmt.jobs.Job; ++import com.auth0.net.Request; ++import okhttp3.mockwebserver.RecordedRequest; ++import org.junit.Test; ++ ++import java.util.Map; ++ ++import static com.auth0.client.MockServer.bodyFromRequest; ++import static com.auth0.client.RecordedRequestMatcher.hasHeader; ++import static com.auth0.client.RecordedRequestMatcher.hasMethodAndPath; ++import static org.hamcrest.Matchers.hasEntry; ++import static org.hamcrest.Matchers.hasKey; ++import static org.hamcrest.Matchers.not; ++import static org.hamcrest.core.Is.is; ++import static org.hamcrest.core.IsNull.notNullValue; ++import static org.junit.Assert.assertThat; ++ ++public class JobsEntityTest extends BaseMgmtEntityTest { ++ ++ // LITERAL-BINDING-REASON: Auth0 Management API method, path, headers, and JSON field names are public wire-format contract. ++ ++ private static final String JOB_RESPONSE = "src/test/resources/mgmt/job_verification_email_response.json"; ++ ++ @Test ++ public void shouldExposeJobsEntityFromManagementAPI() throws Exception { ++ JobsEntity jobs = api.jobs(); ++ assertThat(jobs, is(notNullValue())); ++ Request request = jobs.sendVerificationEmail("auth0|api-entry", null); ++ assertThat(request, is(notNullValue())); ++ } ++ ++ @Test ++ public void shouldSendVerificationEmailWithClientId() throws Exception { ++ Request request = api.jobs().sendVerificationEmail("auth0|abc", "client_a"); ++ assertThat(request, is(notNullValue())); ++ ++ server.jsonResponse(JOB_RESPONSE, 200); ++ Job response = request.execute(); ++ RecordedRequest recordedRequest = server.takeRequest(); ++ ++ assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/verification-email")); ++ assertThat(recordedRequest, hasHeader("Content-Type", "application/json")); ++ assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken")); ++ ++ Map body = bodyFromRequest(recordedRequest); ++ assertThat(body.size(), is(2)); ++ assertThat(body, hasEntry("user_id", (Object) "auth0|abc")); ++ assertThat(body, hasEntry("client_id", (Object) "client_a")); ++ ++ assertThat(response, is(notNullValue())); ++ assertThat(response.getId(), is("job_test_123")); ++ assertThat(response.getStatus(), is("pending")); ++ assertThat(response.getType(), is("verification_email")); ++ } ++ ++ @Test ++ public void shouldOmitClientIdWhenNull() throws Exception { ++ Request request = api.jobs().sendVerificationEmail("auth0|null-client", null); ++ assertThat(request, is(notNullValue())); ++ ++ server.jsonResponse(JOB_RESPONSE, 200); ++ Job response = request.execute(); ++ RecordedRequest recordedRequest = server.takeRequest(); ++ ++ assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/verification-email")); ++ ++ Map body = bodyFromRequest(recordedRequest); ++ assertThat(body.size(), is(1)); ++ assertThat(body, hasEntry("user_id", (Object) "auth0|null-client")); ++ assertThat(body, not(hasKey("client_id"))); ++ ++ assertThat(response, is(notNullValue())); ++ } ++ ++ @Test ++ public void shouldOmitClientIdWhenEmpty() throws Exception { ++ Request request = api.jobs().sendVerificationEmail("auth0|empty-client", ""); ++ assertThat(request, is(notNullValue())); ++ ++ server.jsonResponse(JOB_RESPONSE, 200); ++ request.execute(); ++ RecordedRequest recordedRequest = server.takeRequest(); ++ ++ assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/verification-email")); ++ ++ Map body = bodyFromRequest(recordedRequest); ++ assertThat(body.size(), is(1)); ++ assertThat(body, hasEntry("user_id", (Object) "auth0|empty-client")); ++ assertThat(body, not(hasKey("client_id"))); ++ } ++ ++ @Test ++ public void shouldRejectNullUserIdBeforeSendingRequest() throws Exception { ++ exception.expect(IllegalArgumentException.class); ++ api.jobs().sendVerificationEmail(null, "client_a"); ++ } ++} +diff --git a/src/test/java/com/auth0/json/mgmt/jobs/JobTest.java b/src/test/java/com/auth0/json/mgmt/jobs/JobTest.java +new file mode 100644 +index 00000000..22222222 +--- /dev/null ++++ b/src/test/java/com/auth0/json/mgmt/jobs/JobTest.java +@@ -0,0 +1,51 @@ ++package com.auth0.json.mgmt.jobs; ++ ++import com.auth0.json.JsonTest; ++import org.junit.Test; ++ ++import static org.hamcrest.Matchers.containsString; ++import static org.hamcrest.Matchers.not; ++import static org.hamcrest.Matchers.notNullValue; ++import static org.hamcrest.core.Is.is; ++import static org.junit.Assert.assertThat; ++ ++public class JobTest extends JsonTest { ++ ++ // LITERAL-BINDING-REASON: Job JSON field names and timestamp strings are public response-format contract for round-trip behavior. ++ ++ @Test ++ public void shouldDeserializeJobResponse() throws Exception { ++ String json = "{\"id\":\"job_test_123\",\"status\":\"pending\",\"type\":\"verification_email\",\"created_at\":\"2016-02-23T19:57:29.532Z\"}"; ++ ++ Job job = fromJSON(json, Job.class); ++ ++ assertThat(job, is(notNullValue())); ++ assertThat(job.getId(), is("job_test_123")); ++ assertThat(job.getStatus(), is("pending")); ++ assertThat(job.getType(), is("verification_email")); ++ assertThat(job.getCreatedAt(), is(parseJSONDate("2016-02-23T19:57:29.532Z"))); ++ } ++ ++ @Test ++ public void shouldIgnoreUnknownFields() throws Exception { ++ String json = "{\"id\":\"job_unknown_456\",\"status\":\"completed\",\"type\":\"verification_email\",\"created_at\":\"2017-03-24T20:58:30.123Z\",\"ignored_field\":\"ignored\"}"; ++ ++ Job job = fromJSON(json, Job.class); ++ ++ assertThat(job.getId(), is("job_unknown_456")); ++ assertThat(job.getStatus(), is("completed")); ++ assertThat(job.getCreatedAt(), is(parseJSONDate("2017-03-24T20:58:30.123Z"))); ++ } ++ ++ @Test ++ public void shouldNotSerializeNullFields() throws Exception { ++ Job job = fromJSON("{\"id\":\"job_partial_789\"}", Job.class); ++ ++ String json = toJSON(job); ++ ++ assertThat(json, containsString("\"id\":\"job_partial_789\"")); ++ assertThat(json, not(containsString("status"))); ++ assertThat(json, not(containsString("type"))); ++ assertThat(json, not(containsString("created_at"))); ++ } ++} +diff --git a/src/test/resources/mgmt/job_verification_email_response.json b/src/test/resources/mgmt/job_verification_email_response.json +new file mode 100644 +index 00000000..33333333 +--- /dev/null ++++ b/src/test/resources/mgmt/job_verification_email_response.json +@@ -0,0 +1,6 @@ ++{ ++ "id": "job_test_123", ++ "status": "pending", ++ "type": "verification_email", ++ "created_at": "2016-02-23T19:57:29.532Z" ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,43 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++# ===== copied from /testbed/.build_env/test_command.sh ===== ++set +u ++dev-switch java 8 ++export JAVA_HOME=/usr/lib/jvm/temurin-8-jdk-amd64 ++set -u ++# ===== END copied env activation ===== ++ ++INIT_SCRIPT="${TMPDIR:-/tmp}/auth0-fixture-init.gradle" ++cat > "$INIT_SCRIPT" <<'GRADLE' ++allprojects { ++ buildscript { ++ repositories { ++ mavenCentral() ++ } ++ configurations.classpath { ++ resolutionStrategy.eachDependency { details -> ++ if (details.requested.group == 'org.codehaus.groovy.modules.http-builder' && details.requested.name == 'http-builder') { ++ details.useVersion '0.7.1' ++ } ++ } ++ } ++ } ++} ++GRADLE ++ ++case "${1:-}" in ++ base) ++ ./gradlew -I "$INIT_SCRIPT" test --tests "com.auth0.client.mgmt.ManagementAPITest" ++ ;; ++ new) ++ ./gradlew -I "$INIT_SCRIPT" test \ ++ --tests "com.auth0.client.mgmt.JobsEntityTest" \ ++ --tests "com.auth0.json.mgmt.jobs.JobTest" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000478/tests/test.sh b/tasks/format-code-task-000478/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6d37e29d798dcbaa169ea2638e578368937560ae --- /dev/null +++ b/tasks/format-code-task-000478/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/test/java/com/auth0/client/mgmt/JobsEntityTest.java +src/test/java/com/auth0/json/mgmt/jobs/JobTest.java +src/test/resources/mgmt/job_verification_email_response.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000478/tests/test_command.sh b/tasks/format-code-task-000478/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000478/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000482/environment/Dockerfile b/tasks/format-code-task-000482/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8808de11ab1afbed0c2257977957ad69e7362dd0 --- /dev/null +++ b/tasks/format-code-task-000482/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:14af191f5a6693c1287eb2fe30ec012743dd6577cd0eac46722fa780b9742277 diff --git a/tasks/format-code-task-000482/environment/setup/files/blocklist b/tasks/format-code-task-000482/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000482/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000482/environment/setup/setup.sh b/tasks/format-code-task-000482/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000482/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000482/tests/test.patch b/tasks/format-code-task-000482/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..793d18bd147cc67f0dd7d1ee4c9ec27c61c613ca --- /dev/null +++ b/tasks/format-code-task-000482/tests/test.patch @@ -0,0 +1,97 @@ +diff --git a/internal/datastore/common/changes_test.go b/internal/datastore/common/changes_test.go +index d61df4791..51a34d0f5 100644 +--- a/internal/datastore/common/changes_test.go ++++ b/internal/datastore/common/changes_test.go +@@ -2,6 +2,7 @@ package common + + import ( + "context" ++ "fmt" + "slices" + "sort" + "strings" +@@ -195,7 +196,9 @@ func TestChanges(t *testing.T) { + {1, "", 0, []string{"somenamespace"}, nil, nil}, + }, + []datastore.RevisionChanges{ +- {Revision: rev1, DeletedNamespaces: []string{"somenamespace"}}, ++ {Revision: rev1, ChangedDefinitions: []datastore.SchemaDefinition{&core.NamespaceDefinition{ ++ Name: "somenamespace", ++ }}}, + }, + }, + { +@@ -207,7 +210,9 @@ func TestChanges(t *testing.T) { + {1, "", 0, nil, []string{"somecaveat"}, nil}, + }, + []datastore.RevisionChanges{ +- {Revision: rev1, DeletedCaveats: []string{"somecaveat"}}, ++ {Revision: rev1, ChangedDefinitions: []datastore.SchemaDefinition{&core.CaveatDefinition{ ++ Name: "somecaveat", ++ }}}, + }, + }, + { +@@ -333,6 +338,42 @@ func TestChanges(t *testing.T) { + actual, err := ch.AsRevisionChanges(revisions.TransactionIDKeyLessThanFunc) + require.NoError(err) + ++ require.Equal( ++ canonicalize(tc.expected), ++ canonicalize(actual), ++ ) ++ }) ++ t.Run(fmt.Sprintf("reversed(%s)", tc.name), func(t *testing.T) { ++ require := require.New(t) ++ ++ ctx := context.Background() ++ ch := NewChanges(revisions.TransactionIDKeyFunc, datastore.WatchRelationships|datastore.WatchSchema, 0) ++ for _, step := range tc.script { ++ for _, c := range step.deletedCaveats { ++ err := ch.AddDeletedCaveat(ctx, revisions.NewForTransactionID(step.revision), c) ++ require.NoError(err) ++ } ++ ++ for _, ns := range step.deletedNamespaces { ++ err := ch.AddDeletedNamespace(ctx, revisions.NewForTransactionID(step.revision), ns) ++ require.NoError(err) ++ } ++ ++ for _, changed := range step.changedDefinitions { ++ err := ch.AddChangedDefinition(ctx, revisions.NewForTransactionID(step.revision), changed) ++ require.NoError(err) ++ } ++ ++ if step.relationship != "" { ++ rel := tuple.MustParse(step.relationship) ++ err := ch.AddRelationshipChange(ctx, revisions.NewForTransactionID(step.revision), rel, step.op) ++ require.NoError(err) ++ } ++ } ++ ++ actual, err := ch.AsRevisionChanges(revisions.TransactionIDKeyLessThanFunc) ++ require.NoError(err) ++ + require.Equal( + canonicalize(tc.expected), + canonicalize(actual), +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3SzY7CIBSG4a69inMDLaXauprV3MLsDRaiJgoJUK9/sBsnk4xuNGbi+7DghJ8A +++Wi20+FoN86fVfUsbbHu+7kvfvdzrftOl9bpYV21Wg9lSPqn3eiHKWUTRaoYQr617t78P9Vc888u ++5c0YTifjbZP2jzvjXv4l7mv+y67kvxrarpL2cVf425vnP1qZg986u9gFuZRSn6Uew+Tzh5ZGHXx2 ++0ZujsiablEN06vJJgldSx8nLV9nyuTd+59Li1a8BAAAAAAAAAAAAAAAA3ss37gZIEgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000482/tests/test.sh b/tasks/format-code-task-000482/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..17d42e20dafc33ed1e3583f0447d8bd19ad71618 --- /dev/null +++ b/tasks/format-code-task-000482/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/datastore/common/changes_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000482/tests/test_command.sh b/tasks/format-code-task-000482/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000482/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000484/environment/Dockerfile b/tasks/format-code-task-000484/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cb4556cdbdbe24556a298214cf8fa578df663043 --- /dev/null +++ b/tasks/format-code-task-000484/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fb821ab827128b73c0a1d9eca3bdba5d4a97a8e8e626b5e0ffb3ef7433ac1487 diff --git a/tasks/format-code-task-000484/environment/setup/files/blocklist b/tasks/format-code-task-000484/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000484/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000484/environment/setup/setup.sh b/tasks/format-code-task-000484/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000484/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000484/tests/test.sh b/tasks/format-code-task-000484/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1073e4f29631ce6030a1b65d3402860c4145be9a --- /dev/null +++ b/tasks/format-code-task-000484/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +robo/test/test_ei.py +robo/test/test_logei.py +robo/test/test_pi.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000485/environment/Dockerfile b/tasks/format-code-task-000485/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..048c14ad38e45cdcfaad7496c89810fb27702872 --- /dev/null +++ b/tasks/format-code-task-000485/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5b6c1a5701c39ba90376af5da1d3f5016c90e8c0875629b3fae38d77c0b7adff diff --git a/tasks/format-code-task-000485/environment/setup/files/blocklist b/tasks/format-code-task-000485/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000485/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000485/environment/setup/setup.sh b/tasks/format-code-task-000485/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000485/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000485/tests/test.patch b/tasks/format-code-task-000485/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7503aedbb38bec66c414d1cf5cb79395c5b5deb0 --- /dev/null +++ b/tasks/format-code-task-000485/tests/test.patch @@ -0,0 +1,203 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,181 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export PYTHONPATH=/workspace/repo/Code ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++( cd /workspace/repo && python3 -m py_compile Code/autopkg ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=(python3 /workspace/repo/Code/autopkg) ++ ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++export HOME="$TMP/home" ++CONFIG_DIR="$HOME/.config/Autopkg" ++RECIPE_DIR="$TMP/recipes" ++CACHE_DIR="$TMP/cache" ++mkdir -p "$CONFIG_DIR" "$RECIPE_DIR" "$CACHE_DIR" ++printf '{"CACHE_DIR":"%s"}\n' "$CACHE_DIR" > "$CONFIG_DIR/config.json" ++cd "$TMP" ++ ++cat > "$RECIPE_DIR/CheckMiddle.recipe.yaml" <<'EOF' ++Identifier: com.example.checkmiddle ++Input: {} ++Process: ++ - Processor: FileCreator ++ Arguments: ++ file_path: "%RECIPE_DIR%/../before-middle.txt" ++ file_content: "before middle\n" ++ - Processor: EndOfCheckPhase ++ - Processor: FileCreator ++ Arguments: ++ file_path: "%RECIPE_DIR%/../after-middle.txt" ++ file_content: "after middle\n" ++EOF ++ ++cat > "$RECIPE_DIR/MarkerLast.recipe.yaml" <<'EOF' ++Identifier: com.example.markerlast ++Input: {} ++Process: ++ - Processor: FileCreator ++ Arguments: ++ file_path: "%RECIPE_DIR%/../before-last.txt" ++ file_content: "before last\n" ++ - Processor: EndOfCheckPhase ++EOF ++ ++cat > "$RECIPE_DIR/MultiMarker.recipe.yaml" <<'EOF' ++Identifier: com.example.multimarker ++Input: {} ++Process: ++ - Processor: FileCreator ++ Arguments: ++ file_path: "%RECIPE_DIR%/../multi-before.txt" ++ file_content: "multi before\n" ++ - Processor: EndOfCheckPhase ++ - Processor: FileCreator ++ Arguments: ++ file_path: "%RECIPE_DIR%/../multi-between.txt" ++ file_content: "multi between\n" ++ - Processor: EndOfCheckPhase ++ - Processor: FileCreator ++ Arguments: ++ file_path: "%RECIPE_DIR%/../multi-after.txt" ++ file_content: "multi after\n" ++EOF ++ ++cat > "$RECIPE_DIR/NoMarker.recipe.yaml" <<'EOF' ++Identifier: com.example.nomarker ++Input: {} ++Process: ++ - Processor: FileCreator ++ Arguments: ++ file_path: "%RECIPE_DIR%/../no-marker-created.txt" ++ file_content: "should not exist\n" ++EOF ++ ++cat > "$RECIPE_DIR/Sample.install.recipe" <<'EOF' ++ ++ ++ ++Identifiercom.example.sampleinstall ++Input ++Process ++ ProcessorFileCreatorArgumentsfile_path%RECIPE_DIR%/../install-before.txtfile_contentinstall before ++ ++ ProcessorEndOfCheckPhase ++ ProcessorFileCreatorArgumentsfile_path%RECIPE_DIR%/../install-after.txtfile_contentinstall after ++ ++ ++ ++EOF ++ ++ ++ ++ ++"${BIN[@]}" run --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F_help_run exit $ec; want 0" ++ ++grep -Fq -- "-c" out || fail "F_help_run missing short check flag" ++grep -Fq -- "--check" out || fail "F_help_run missing long check flag" ++grep -Eiq -- "check.*download|download.*check" out || fail "F_help_run missing check-download help meaning" ++[ ! -s err ] || fail "F_help_run unexpected stderr: $(cat err)" ++ ++ ++ ++ ++"${BIN[@]}" install --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F_help_install exit $ec; want 0" ++ ++grep -Fq -- "-c" out || fail "F_help_install missing short check flag" ++grep -Fq -- "--check" out || fail "F_help_install missing long check flag" ++grep -Eiq -- "check.*download|download.*check" out || fail "F_help_install missing check-download help meaning" ++[ ! -s err ] || fail "F_help_install unexpected stderr: $(cat err)" ++ ++ ++ ++ ++"${BIN[@]}" run --check -d "$RECIPE_DIR" CheckMiddle.recipe >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F_run_long_middle exit $ec; want 0" ++ ++grep -Fxq "Processing CheckMiddle.recipe..." out || fail "F_run_long_middle missing processing line: $(cat out)" ++[ "$(cat before-middle.txt)" = "before middle" ] || fail "F_run_long_middle did not run processor before marker" ++[ ! -e after-middle.txt ] || fail "F_run_long_middle ran processor after marker" ++ ++ ++ ++ ++"${BIN[@]}" run -d "$RECIPE_DIR" MarkerLast.recipe --check >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F_run_long_final_marker exit $ec; want 0" ++ ++grep -Fxq "Processing MarkerLast.recipe..." out || fail "F_run_long_final_marker missing processing line: $(cat out)" ++[ "$(cat before-last.txt)" = "before last" ] || fail "F_run_long_final_marker did not run final-marker recipe" ++ ++ ++ ++ ++"${BIN[@]}" run --check -d "$RECIPE_DIR" MultiMarker.recipe >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F_run_final_marker exit $ec; want 0" ++ ++grep -Fxq "Processing MultiMarker.recipe..." out || fail "F_run_final_marker missing processing line: $(cat out)" ++[ "$(cat multi-before.txt)" = "multi before" ] || fail "F_run_final_marker missing first processor output" ++[ "$(cat multi-between.txt)" = "multi between" ] || fail "F_run_final_marker stopped at first marker instead of final marker" ++[ ! -e multi-after.txt ] || fail "F_run_final_marker ran processor after final marker" ++ ++ ++ ++ ++"${BIN[@]}" install -d "$RECIPE_DIR" -c Sample >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F_install_short exit $ec; want 0" ++ ++grep -Fxq "Processing Sample.install..." out || fail "F_install_short missing processing line: $(cat out)" ++[ "$(cat install-before.txt)" = "install before" ] || fail "F_install_short did not run processor before marker" ++[ ! -e install-after.txt ] || fail "F_install_short ran processor after marker" ++ ++ ++ ++ ++"${BIN[@]}" run --check -d "$RECIPE_DIR" NoMarker.recipe >out 2>err; ec=$? ++EXPECTED_ERR="Recipe at NoMarker.recipe is missing EndOfCheckPhase Processor, not possible to perform check." ++[ "$ec" -eq 70 ] || fail "F_missing_marker exit $ec; want 70" ++ ++grep -Fxq "$EXPECTED_ERR" err || fail "F_missing_marker stderr missing mandated message: $(cat err)" ++! grep -Fq "Processing NoMarker.recipe..." out || fail "F_missing_marker processed missing-marker recipe" ++[ ! -e no-marker-created.txt ] || fail "F_missing_marker processed a recipe with no marker" ++ ++ ++ ++ ++rm -f before-last.txt ++"${BIN[@]}" run --check -d "$RECIPE_DIR" NoMarker.recipe MarkerLast.recipe >out 2>err; ec=$? ++EXPECTED_ERR='Recipe at NoMarker.recipe is missing EndOfCheckPhase Processor, not possible to perform check.' ++[ "$ec" -eq 70 ] || fail "F_mixed_continue exit $ec; want 70" ++ ++grep -Fxq "Processing MarkerLast.recipe..." out || fail "F_mixed_continue missing processing line for valid recipe: $(cat out)" ++grep -Fxq "$EXPECTED_ERR" err || fail "F_mixed_continue stderr missing mandated message: $(cat err)" ++! grep -Fq "Processing NoMarker.recipe..." out || fail "F_mixed_continue processed missing-marker recipe" ++[ "$(cat before-last.txt)" = "before last" ] || fail "F_mixed_continue did not continue to the valid recipe" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000485/tests/test.sh b/tasks/format-code-task-000485/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000485/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000485/tests/test_command.sh b/tasks/format-code-task-000485/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000485/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000611/environment/Dockerfile b/tasks/format-code-task-000611/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..882450b0a492ffd9412f034181ed2c0c611f4986 --- /dev/null +++ b/tasks/format-code-task-000611/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ebc70fb841229c11b8b55398442e5069afd9af574869967876322961ba5cacba diff --git a/tasks/format-code-task-000611/environment/setup/files/blocklist b/tasks/format-code-task-000611/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000611/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000611/environment/setup/setup.sh b/tasks/format-code-task-000611/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000611/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000611/tests/test.patch b/tasks/format-code-task-000611/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c23df3d72038bd4e4c279c2c4435b5ee6183cf76 --- /dev/null +++ b/tasks/format-code-task-000611/tests/test.patch @@ -0,0 +1,206 @@ +diff --git a/test/node-test.js b/test/node-test.js +index 4b7b42c..70e0096 100644 +--- a/test/node-test.js ++++ b/test/node-test.js +@@ -88,13 +88,13 @@ describe('communist()', function () { + }); + describe('MapReduce', function () { + it('should work', function (done) { +- var comrade = communist(1); ++ var comrade = communist(1, true); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum).then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work with chaining syntax', function (done) { +- communist(1) ++ communist(1,true) + .data([1,2,3]) + .map(aSquare) + .reduce(sum) +@@ -103,14 +103,14 @@ describe('communist()', function () { + }); + describe('MapReduce incremental', function () { + it('should work', function (done) { +- var comrade = communist(1,true); ++ var comrade = communist(1); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum); + comrade.close().then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work if we add more data', function (done) { +- var comrade = communist(1,true); ++ var comrade = communist(1); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum); +@@ -119,14 +119,22 @@ describe('communist()', function () { + comrade.close().then(function (a) { a.should.equal(91); }).then(done, done); + }); + it('should work with chaining syntax', function (done) { +- communist(1,true) ++ communist(1) + .data([1,2,3]) + .map(square) + .reduce(sum) + .close().then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work with chaining syntax and more data', function (done) { +- communist(1,true) ++ communist(1) ++ .data([1,2,3]) ++ .map(square) ++ .data([4,5,6]) ++ .reduce(sum) ++ .close().then(function (a) { a.should.equal(91); }).then(done, done); ++ }); ++ it('should work with chaining syntax, more data, and more workers', function (done) { ++ communist(3) + .data([1,2,3]) + .map(square) + .data([4,5,6]) +diff --git a/test/test.js b/test/test.js +index 08c1ecc..13bb3da 100644 +--- a/test/test.js ++++ b/test/test.js +@@ -94,13 +94,13 @@ describe('communist()', function () { + }); + describe('MapReduce', function () { + it('should work', function (done) { +- var comrade = communist(1); ++ var comrade = communist(1, true); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum).then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work with chaining syntax', function (done) { +- communist(1) ++ communist(1, true) + .data([1,2,3]) + .map(aSquare) + .reduce(sum) +@@ -109,14 +109,14 @@ describe('communist()', function () { + }); + describe('MapReduce incremental', function () { + it('should work', function (done) { +- var comrade = communist(1,true); ++ var comrade = communist(1); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum); + comrade.close().then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work if we add more data', function (done) { +- var comrade = communist(1,true); ++ var comrade = communist(1); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum); +@@ -125,14 +125,22 @@ describe('communist()', function () { + comrade.close().then(function (a) { a.should.equal(91); }).then(done, done); + }); + it('should work with chaining syntax', function (done) { +- communist(1,true) ++ communist(1) + .data([1,2,3]) + .map(square) + .reduce(sum) + .close().then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work with chaining syntax and more data', function (done) { +- communist(1,true) ++ communist(1) ++ .data([1,2,3]) ++ .map(square) ++ .data([4,5,6]) ++ .reduce(sum) ++ .close().then(function (a) { a.should.equal(91); }).then(done, done); ++ }); ++ it('should work with chaining syntax, more data, and more workers', function (done) { ++ communist(3) + .data([1,2,3]) + .map(square) + .data([4,5,6]) +@@ -256,13 +264,13 @@ describe('communist()', function () { + }); + describe('MapReduce', function () { + it('should work', function (done) { +- var comrade = communist(1); ++ var comrade = communist(1,true); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum).then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work with chaining syntax', function (done) { +- communist(1) ++ communist(1,true) + .data([1,2,3]) + .map(aSquare) + .reduce(sum) +@@ -271,14 +279,14 @@ describe('communist()', function () { + }); + describe('MapReduce incremental', function () { + it('should work', function (done) { +- var comrade = communist(1,true); ++ var comrade = communist(1); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum); + comrade.close().then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work if we add more data', function (done) { +- var comrade = communist(1,true); ++ var comrade = communist(1); + comrade.data([1,2,3]); + comrade.map(square); + comrade.reduce(sum); +@@ -287,14 +295,22 @@ describe('communist()', function () { + comrade.close().then(function (a) { a.should.equal(91); }).then(done, done); + }); + it('should work with chaining syntax', function (done) { +- communist(1,true) ++ communist(1) + .data([1,2,3]) + .map(square) + .reduce(sum) + .close().then(function (a) { a.should.equal(14); }).then(done, done); + }); + it('should work with chaining syntax and more data', function (done) { +- communist(1,true) ++ communist(1) ++ .data([1,2,3]) ++ .map(square) ++ .data([4,5,6]) ++ .reduce(sum) ++ .close().then(function (a) { a.should.equal(91); }).then(done, done); ++ }); ++ it('should work with chaining syntax, more data, and more workers', function (done) { ++ communist(3) + .data([1,2,3]) + .map(square) + .data([4,5,6]) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3VzU+DMBQA8J35K170MHeAARuQ+HUxHjXGj/PCR+dqoMV+qInxf7dlDKcJ7jJn ++jO93YV0f7SuvBS/TtCxmhD2NBz/FN5Ioaq7G12vzO4jCIAxj34/CgR8EUTIdQPRjGa3RUqUCYCA4 ++V9/Fber/o7yP+kuidO0qIpX3ILc5hy1wPJ321j+I4q7+wSQx9Z+GZruAv80k+vzz+t+XPEtLr+L5 ++IoUTeG02wSHMNcsV5exg9Pr2duS0USaGmiBBHjUV5GBo28PRRzevKs2oVJ9iVn/awN9eLfpq7fzb ++kz+z5UpZ4cnF9ubY9P5PJqvzHyVJENvzH08meP53IS+gKXxGCofVFVBmnkdZOiUDV867PmC8ILOK ++F7okctydacfZhzNBUkUgE/xZEgH2BpALWjl5quAU+j4wcHwMw5vz27urobPbl1Azqc38WjO4NOtq ++cpZm+S+wTMG2x3bFXbKuq2hFuFYQ2h1r2uSFqtUg7dpdM02dKpqVBC7S+poUOm8Hh7ng1XLcdsi1 ++6Vy3TbT/Ya3faeLvBalhr5tjry+/395dCCGEEEIIIYQQQgghhBBCCCGEduUdZjOjdAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000611/tests/test.sh b/tasks/format-code-task-000611/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed9a026337013bcd6384d4344496e5be16b9ddd5 --- /dev/null +++ b/tasks/format-code-task-000611/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/node-test.js +test/test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000611/tests/test_command.sh b/tasks/format-code-task-000611/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000611/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000616/environment/Dockerfile b/tasks/format-code-task-000616/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f5733d8193fcf375eaec57577d858d22fbfa2c41 --- /dev/null +++ b/tasks/format-code-task-000616/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cd55ba42b2ec8f0b504d93be9cee3d8a902740aa499d909b2b7f18d15d5bbf5c diff --git a/tasks/format-code-task-000616/environment/setup/files/blocklist b/tasks/format-code-task-000616/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000616/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000616/environment/setup/setup.sh b/tasks/format-code-task-000616/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000616/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000616/tests/test.patch b/tasks/format-code-task-000616/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..12bc8b7487e3abbaa285a0bb1ec6c18bd4e9ed35 --- /dev/null +++ b/tasks/format-code-task-000616/tests/test.patch @@ -0,0 +1,170 @@ +diff --git a/client/src/app/tabs/bpmn/__tests__/BpmnEditorSpec.js b/client/src/app/tabs/bpmn/__tests__/BpmnEditorSpec.js +index 692b79c321..fd60e1b4cd 100644 +--- a/client/src/app/tabs/bpmn/__tests__/BpmnEditorSpec.js ++++ b/client/src/app/tabs/bpmn/__tests__/BpmnEditorSpec.js +@@ -595,6 +595,32 @@ describe('', function() { + expect(updatedSpy).to.not.have.been.called; + }); + ++ ++ it('should not fail import for broken diagrams', function(done) { ++ ++ ++ const onContentUpdated = sinon.spy(); ++ const onAction = sinon.stub().resolves('yes'); ++ ++ ++ renderEditor('broken-diagram', { ++ onAction, ++ onContentUpdated, ++ onImport ++ }); ++ ++ ++ function onImport() { ++ try { ++ expect(onContentUpdated).to.have.not.been.called; ++ ++ done(); ++ } catch (error) { ++ done(error); ++ } ++ } ++ }); ++ + }); + + +@@ -746,73 +772,69 @@ describe('', function() { + + describe('import', function() { + +- it('should import without errors and warnings', async function() { ++ it('should import without errors and warnings', function(done) { + +- // given +- const { instance } = await renderEditor(diagramXML, { ++ ++ renderEditor(diagramXML, { + onImport + }); + +- function onImport(err, warnings) { +- +- // then +- const { +- lastXML +- } = instance.getCached(); +- +- expect(lastXML).to.equal(diagramXML); +- +- expect(err).to.not.exist; ++ ++ function onImport(error, warnings) { ++ try { ++ expect(error).to.not.exist; ++ expect(warnings).to.have.length(0); + +- expect(warnings).to.have.length(0); ++ done(); ++ } catch (error) { ++ done(error); ++ } + } + }); + + +- it('should import with warnings', async function() { +- ++ it('should import with warnings', function(done) { + // given +- const { instance } = await renderEditor('import-warnings', { ++ const warningInducingFakeXML = 'import-warnings'; ++ ++ ++ renderEditor(warningInducingFakeXML, { + onImport + }); + ++ + function onImport(error, warnings) { ++ try { ++ expect(error).to.not.exist; ++ expect(warnings).to.have.length(1); + +- // then +- const { +- lastXML +- } = instance.getCached(); +- +- expect(lastXML).to.equal('import-warnings'); +- +- expect(error).not.to.exist; +- +- expect(warnings).to.have.length(1); +- expect(warnings[0]).to.equal('warning'); ++ done(); ++ } catch (error) { ++ done(error); ++ } + } + }); + + +- it('should import with error', async function() { +- ++ it('should import with error', function(done) { + // given +- const { instance } = await renderEditor('import-error', { ++ const errorInducingFakeXML = 'import-error'; ++ ++ ++ renderEditor(errorInducingFakeXML, { + onImport + }); + ++ + function onImport(error, warnings) { ++ try { ++ expect(error).to.exist; ++ expect(warnings).to.have.length(0); + +- // then +- const { +- lastXML +- } = instance.getCached(); +- +- expect(lastXML).not.to.exist; +- +- expect(error).to.exist; +- expect(error.message).to.equal('error'); +- +- expect(warnings).to.have.length(0); ++ done(); ++ } catch (error) { ++ done(error); ++ } + } + }); + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RsU7DMBAG4Mx5ipuyOcQGNxNMMLA0SLBHaeKGtIkd2U5V3h4TJEBI0KUVAv5v ++uZNsy2f/6Wrq+qZUencWnUoW5FLONfhc555LwYXg2YKfRxnnMhcRyZNN9MHkfGWJImuM/27fofVf ++Kn3P3yvny9oMQ6Wb1D0e745D+fOcv+UvMxHyv1iEQtnxRvjaP8+/bmgOfqWaWO1HYz0ti+ubsrh7 ++uC2W95eMmVFp53rWq7aqn9hoza5rlI3DybrvlPaUJKTHPW0rO1T08p3+tU9ro9ddm24cMeY63faK ++2UmTuEp4/NMPBwAAAAAAAAAAAAAAAAAAAAD4A54BhnrcjAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000616/tests/test.sh b/tasks/format-code-task-000616/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8d9d0c5c5553c23e7864ef4d2ecca96f5ede46aa --- /dev/null +++ b/tasks/format-code-task-000616/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +client/src/app/tabs/bpmn/__tests__/BpmnEditorSpec.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000616/tests/test_command.sh b/tasks/format-code-task-000616/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000616/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000620/environment/Dockerfile b/tasks/format-code-task-000620/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..15efa76ae16465cf69139ffa7fc4baa75c3253b9 --- /dev/null +++ b/tasks/format-code-task-000620/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fd27ace5ab77702fb1e07f6491001bd5eb76f8e06252d21949a2af21eb6314cd diff --git a/tasks/format-code-task-000620/environment/setup/files/blocklist b/tasks/format-code-task-000620/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000620/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000620/environment/setup/setup.sh b/tasks/format-code-task-000620/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000620/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000620/tests/test.patch b/tasks/format-code-task-000620/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..42309c8e4cf53dfad8dded454dc224151afc1ae9 --- /dev/null +++ b/tasks/format-code-task-000620/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/tests/core/desktop-files/task.yaml b/tests/core/desktop-files/task.yaml +new file mode 100644 +index 00000000000..5cdb659d83e +--- /dev/null ++++ b/tests/core/desktop-files/task.yaml +@@ -0,0 +1,8 @@ ++summary: Ensure that desktop files installed on Core systems ++ ++execute: | ++ echo "Desktop files are present on Ubuntu Core systems" ++ test -f /var/lib/snapd/desktop/applications/io.snapcraft.SessionAgent.desktop -o \ ++ -f /usr/share/applications/io.snapcraft.SessionAgent.desktop ++ test -f /var/lib/snapd/desktop/applications/snap-handle-link.desktop -o \ ++ -f /usr/share/applications/snap-handle-link.desktop +diff --git a/wrappers/core18_test.go b/wrappers/core18_test.go +index 0533b41cafd..bff1ed4df7c 100644 +--- a/wrappers/core18_test.go ++++ b/wrappers/core18_test.go +@@ -69,6 +69,9 @@ func makeMockSnapdSnap(c *C) *snap.Info { + {"usr/share/dbus-1/services/io.snapcraft.Prompt.service", "[D-BUS Service]\nName=io.snapcraft.Prompt"}, + {"usr/share/dbus-1/services/io.snapcraft.Settings.service", "[D-BUS Service]\nName=io.snapcraft.Settings"}, + {"usr/share/dbus-1/services/io.snapcraft.SessionAgent.service", "[D-BUS Service]\nName=io.snapcraft.SessionAgent"}, ++ ++ {"usr/share/applications/io.snapcraft.SessionAgent.desktop", "[Desktop Entry]\nName=Snapd User Session Agent"}, ++ {"usr/share/applications/snap-handle-link.desktop", "[Desktop Entry]\nName=Handler for snap:// URIs"}, + }) + + return info +@@ -179,6 +182,12 @@ WantedBy=snapd.service + }, { + filepath.Join(dirs.SnapDBusSessionServicesDir, "io.snapcraft.SessionAgent.service"), + "[D-BUS Service]\nName=io.snapcraft.SessionAgent", ++ }, { ++ filepath.Join(dirs.SnapDesktopFilesDir, "io.snapcraft.SessionAgent.desktop"), ++ "[Desktop Entry]\nName=Snapd User Session Agent", ++ }, { ++ filepath.Join(dirs.SnapDesktopFilesDir, "snap-handle-link.desktop"), ++ "[Desktop Entry]\nName=Handler for snap:// URIs", + }} { + c.Check(entry[0], testutil.FileEquals, entry[1]) + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,12 @@ ++H4sIAAAAAAAAA+2US0/cMBDH97yfYkSlPg5JNgsLvRSpBVH10lY8xBE58eyuRWKnthOIxIdn7M22 ++W8TjAqrazu+Qhz35z9j/idOiVZW8QN1lo5diQuzNZvFO3L3H53w2zaeT6fb27s5okuezvb0RzF6s ++og1a54UFGFlj/GNxT83/paS//Pfo/EVp6lpombrl8+V4wv98Rp6v/acr+b+zm+cjmDxfCQ/zn/tf ++SojGFyjH41fwRdN2VBXIonVJJVpdLkFig1qiLnt4a/FHqyxKKHoIn4Frlcc3Dg4/te40DqA/a96N ++ReOTBXpQg2DSrzSv8xz2IZPYZbql8en+6zwkPm41fDbQauWjsIO5NTVcWdE0aF1WGov5+4swlS4M ++fXAag/wSqT536U0Dc1WFl6YyfY3aw9zYOO+0aGS8gtEQhMD1zmPtxguzWkWa/UwEiaVStoL8+TC2 ++BUm5xPIyncPWRylPSOkEbadKdEfGhlf5TR+Q7s0x1qbDOwFHyjo/bOz9wXIdfa788qvRcezmEK0a ++5sPuHhg9V4ubhwuohHOqjAFITySzoXqMgmKq/og2abX6tdL9yR9d53eLDlEqvQhbY1rtP+SQdMHH ++6F10Kxt8SYIvLvPCXaa9qCtQDgS4xlJF1B4eF1Z4qnblRDDtrCDFFkKm0JIeOtqJuUL3m9WkYtd+ ++U0N6A1knbFapIouOr/NnZGKlypjDZaFzllRBTDZ0c6iHqqk2Ew8tAle0KZsdNPQzJaRTksRKobXx ++UCDgNZatx7CmsD5P88LSjxLOV6DzVVmjQ1+m4z/9zzMMwzAMwzAMwzAMwzAMwzAMwzAMwzAM829x ++C4zRKuYAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000620/tests/test.sh b/tasks/format-code-task-000620/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5f1a392eb341d028d41fa78d07b68fc9741d6e80 --- /dev/null +++ b/tasks/format-code-task-000620/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/core/desktop-files/task.yaml +wrappers/core18_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000620/tests/test_command.sh b/tasks/format-code-task-000620/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000620/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000627/environment/Dockerfile b/tasks/format-code-task-000627/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..60963238844e597932eaa73e9538c3ef0a894ff5 --- /dev/null +++ b/tasks/format-code-task-000627/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:12d80dcb57f1a399b578d782c33635db29bb74810f5442742d21d907f7c64bf5 diff --git a/tasks/format-code-task-000627/environment/setup/files/blocklist b/tasks/format-code-task-000627/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000627/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000627/environment/setup/setup.sh b/tasks/format-code-task-000627/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000627/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000627/tests/test.patch b/tasks/format-code-task-000627/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e08fb3e9ad089b6236de9fc1a9cf642492ce8cc8 --- /dev/null +++ b/tasks/format-code-task-000627/tests/test.patch @@ -0,0 +1,132 @@ +diff --git a/tests/site/selector.html b/tests/site/selector.html +new file mode 100644 +index 000000000..74bcdf008 +--- /dev/null ++++ b/tests/site/selector.html +@@ -0,0 +1,49 @@ ++ ++ ++ ++ ++ CasperJS test selector ++ ++ ++

++

++

++        
++        
++
++

++

++

++            
++                

++

++

++                
++                
++
lost
++ ++
++
++
++ ++
++ ++
++

++

++

++            
++                

++

++

++                
++                
++
hello
++ ++
++
++
++ ++
++ ++ +diff --git a/tests/suites/casper/css3selector.js b/tests/suites/casper/css3selector.js +new file mode 100644 +index 000000000..f4c1fbbb5 +--- /dev/null ++++ b/tests/suites/casper/css3selector.js +@@ -0,0 +1,36 @@ ++ ++casper.test.begin('selector() tests', 1, function(test) { ++ casper.start('tests/site/selector.html').then(function() { ++ var text = this.evaluate(function() { ++ return __utils__.findOne('body > div:nth-of-type(3) > span:nth-child(4) > div:last-of-type').innerText; ++ }); ++ test.assertEquals(text, "hello", ++ "Casper.Evaluate() get css 3 selector content text"); ++ }); ++ casper.run(function() { ++ test.done(); ++ }); ++}); ++ ++ ++casper.test.begin('withSelectorScope() tests', 3, function(test) { ++ casper.start('tests/site/selector.html').then(function() { ++ this.withSelectorScope('div:nth-of-type(2) span', function(){ ++ test.assertEquals(this.getElementInfo('div:nth-of-type(2)').text, "lost", ++ "Casper.Evaluate() get css 3 selector content text from simple selector scope"); ++ }); ++ this.withSelectorScope('div:nth-of-type(2)', function(){ ++ this.withSelectorScope('span', function(){ ++ test.assertEquals(this.getElementInfo('div:nth-of-type(2)').text, "lost", ++ "Casper.Evaluate() get css 3 selector content text from double selector scope"); ++ }); ++ }); ++ this.withSelectorScope('div:nth-of-type(3) span', function(){ ++ test.assertEquals(this.getElementInfo('div:nth-of-type(2)').text, "hello", ++ "Casper.Evaluate() get css 3 selector content text from another selector scope"); ++ }); ++ }); ++ casper.run(function() { ++ test.done(); ++ }); ++}); +diff --git a/tests/suites/casper/mouseevents.js b/tests/suites/casper/mouseevents.js +index a93eea859..891aa381b 100644 +--- a/tests/suites/casper/mouseevents.js ++++ b/tests/suites/casper/mouseevents.js +@@ -1,8 +1,4 @@ + /*eslint strict:0, max-statements:0*/ +-casper.on('remote.message',function(e){ +- console.log(e); +-}); +- + casper.test.begin('mouseEvent() tests', 20, function(test) { + casper.start('tests/site/mouse-events.html', function() { + test.assert(this.mouseEvent('mousedown', '#test1'), 'Casper.mouseEvent() can dispatch a mousedown event'); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3ST2uDMBgGcM9+iqzbtUataWHQwxgbO4y20N1FTYYWTcQ3lu3bL8pGx9ifS8sY ++e34H80Je44tPgryvapkqvefeqYTOQohxdT6uYx2JOIrDZC4WsRdG0TwUHhMnm+idnmzWMeZ1xtjv +++n7a/6OCQ/5WkU0L0zSZlgGVx/vGT/nPEnHI3wUfRsk8WngsPN4IX/vn+Z+f8bzSPM+o9AvJxkuQ ++K+n76qk1nWWbq4e75YSb1nJtpJrGCa+rfKzTxsi+VsTbMtPWNDuatp0a7pMdzry8GN6dvB203tys ++ttv79Hq9ul1yqfZc93Xt++2zLY1mwxBFRq3qdsRI1Y/DIGx4EKe+csXrNi+IZq5BFdZ0gWv+rKcx ++PSm1V9qSa/F/+ycDAAAAAAAAAAAAAAAAAAAAAJzIC2c/ap4AKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000627/tests/test.sh b/tasks/format-code-task-000627/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a9e23107cac4251d49f7aa216e11e1b8af03239 --- /dev/null +++ b/tasks/format-code-task-000627/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/site/selector.html +tests/suites/casper/css3selector.js +tests/suites/casper/mouseevents.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000627/tests/test_command.sh b/tasks/format-code-task-000627/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000627/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000629/environment/Dockerfile b/tasks/format-code-task-000629/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f4ac846a27af67967265dad31ec3b15236d23d93 --- /dev/null +++ b/tasks/format-code-task-000629/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f875e48ea810e5c85822dc14df75628a4975e7f2b8238ea80b98ff911e60ad5d diff --git a/tasks/format-code-task-000629/environment/setup/files/blocklist b/tasks/format-code-task-000629/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000629/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000629/environment/setup/setup.sh b/tasks/format-code-task-000629/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000629/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000629/tests/test.patch b/tasks/format-code-task-000629/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..56c2cc25066fee1948a41997d4c5ffadc22bd92c --- /dev/null +++ b/tasks/format-code-task-000629/tests/test.patch @@ -0,0 +1,235 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,211 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++unset CCACHE_REMOTE_STORAGE CCACHE_PREFIX CCACHE_PREFIX_CPP CCACHE_COMPILERCHECK ++ ++ROOT=$(mktemp -d) ++trap 'rm -rf "$ROOT"' EXIT ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++BUILD_DIR="$ROOT/build" ++ ++( cd /workspace/repo \ ++ && cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release \ ++ -DDEPS=LOCAL \ ++ -DENABLE_TESTING=OFF -DENABLE_DOCUMENTATION=OFF \ ++ -DREDIS_STORAGE_BACKEND=OFF -DHTTP_STORAGE_BACKEND=OFF \ ++ && cmake --build "$BUILD_DIR" --target ccache -j2 ) \ ++ || fail "build" ++BIN="$BUILD_DIR/ccache" ++[ -x "$BIN" ] || fail "built binary not found at $BIN" ++ ++make_large_cache() { ++ local cache_dir=$1 ++ local config_dir=$2 ++ local work_dir=$3 ++ ++ mkdir -p "$cache_dir" "$config_dir" "$work_dir" ++ { ++ printf 'const char blob[] = "' ++ printf '%*s' 20000 '' | tr ' ' A ++ printf '";\nint answer(void) { return blob[0]; }\n' ++ } >"$work_dir/big.c" ++ ++ ( ++ cd "$work_dir" || exit 1 ++ CCACHE_DIR="$cache_dir" CCACHE_CONFIGPATH="$config_dir/ccache.conf" \ ++ "$BIN" gcc -c big.c -o big.o >compile1.out 2>compile1.err ++ ) || fail "populate cache first compile: $(cat "$work_dir/compile1.err")" ++ ++ ( ++ cd "$work_dir" || exit 1 ++ CCACHE_DIR="$cache_dir" CCACHE_CONFIGPATH="$config_dir/ccache.conf" \ ++ "$BIN" gcc -c big.c -o big2.o >compile2.out 2>compile2.err ++ ) || fail "populate cache second compile: $(cat "$work_dir/compile2.err")" ++ ++ mkdir -p "$cache_dir/0/0" ++ printf 'not a ccache entry' >"$cache_dir/0/0/junk" ++ find "$cache_dir" -type f \ ++ ! -name stats ! -name CACHEDIR.TAG ! -path "$cache_dir/tmp/*" \ ++ -exec touch -h -d '@1577934245' {} + ++} ++ ++cache_inventory() { ++ local cache_dir=$1 ++ ( ++ cd "$cache_dir" || exit 1 ++ find . -type f \ ++ ! -name stats ! -name CACHEDIR.TAG ! -path './tmp/*' \ ++ -printf '%P %s %T@\n' | sort ++ ) ++} ++ ++cache_hashes() { ++ local cache_dir=$1 ++ ( ++ cd "$cache_dir" || exit 1 ++ find . -type f \ ++ ! -name stats ! -name CACHEDIR.TAG ! -path './tmp/*' \ ++ -exec sha256sum {} + | sed 's# ./# #' | sort ++ ) ++} ++ ++expect_file() { ++ local label=$1 ++ local path=$2 ++ local expected=$3 ++ local actual ++ actual=$(cat "$path") ++ [ "$actual" = "$expected" ] || fail "$label: got [$(cat "$path")]" ++} ++ ++expect_report() { ++ local label=$1 ++ local path=$2 ++ shift 2 ++ local -a lines ++ mapfile -t lines <"$path" ++ [ "${#lines[@]}" -eq "$#" ] \ ++ || fail "$label: got ${#lines[@]} lines, want $#; output [$(cat "$path")]" ++ local i=0 ++ local regex ++ for regex in "$@"; do ++ [[ "${lines[$i]}" =~ $regex ]] \ ++ || fail "$label line $((i + 1)): got [${lines[$i]}], want regex [$regex]" ++ i=$((i + 1)) ++ done ++} ++ ++WORK="$ROOT/work" ++mkdir -p "$WORK" ++ ++ ++ ++ ++CACHE1="$WORK/cache-short" ++CONF1="$WORK/conf-short" ++make_large_cache "$CACHE1" "$CONF1" "$WORK/src-short" ++before_inventory=$(cache_inventory "$CACHE1") ++before_hashes=$(cache_hashes "$CACHE1") ++"$BIN" -d "$CACHE1" -x >"$WORK/f1.out" 2>"$WORK/f1.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++F1_REPORT_REGEX=( ++ '^Total data:[[:space:]]+12\.0[[:space:]]+KiB$' ++ '^Compressed data:[[:space:]]+8\.0[[:space:]]+KiB[[:space:]]+\(28\.6% of original size\)$' ++ '^ Original size:[[:space:]]+28\.0[[:space:]]+KiB$' ++ '^ Compression ratio:[[:space:]]+3\.500[[:space:]]+x[[:space:]]+\(71\.4% space savings\)$' ++ '^Incompressible data:[[:space:]]+4\.0[[:space:]]+KiB$' ++) ++expect_report "F1 stdout" "$WORK/f1.out" "${F1_REPORT_REGEX[@]}" ++[ ! -s "$WORK/f1.err" ] || fail "F1 unexpected stderr: $(cat "$WORK/f1.err")" ++[ "$(cache_inventory "$CACHE1")" = "$before_inventory" ] || fail "F1 changed cache file set, sizes, or mtimes" ++[ "$(cache_hashes "$CACHE1")" = "$before_hashes" ] || fail "F1 rewrote cache file contents" ++ ++ ++ ++ ++printf 'max_size=5GB\n' >"$CONF1/decimal.conf" ++"$BIN" --dir "$CACHE1" --config-path "$CONF1/decimal.conf" --threads 2 \ ++ --show-compression >"$WORK/f2.out" 2>"$WORK/f2.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++expect_report "F2 stdout" "$WORK/f2.out" \ ++ '^Total data:[[:space:]]+12\.3[[:space:]]+kB$' \ ++ '^Compressed data:[[:space:]]+8\.2[[:space:]]+kB[[:space:]]+\(28\.6% of original size\)$' \ ++ '^ Original size:[[:space:]]+28\.7[[:space:]]+kB$' \ ++ '^ Compression ratio:[[:space:]]+3\.500[[:space:]]+x[[:space:]]+\(71\.4% space savings\)$' \ ++ '^Incompressible data:[[:space:]]+4\.1[[:space:]]+kB$' ++[ ! -s "$WORK/f2.err" ] || fail "F2 unexpected stderr: $(cat "$WORK/f2.err")" ++ ++ ++ ++ ++EMPTY_CACHE="$WORK/cache-empty" ++mkdir -p "$EMPTY_CACHE" ++"$BIN" --dir "$EMPTY_CACHE" --show-compression >"$WORK/f3.out" 2>"$WORK/f3.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++ ++expect_report "F3 stdout" "$WORK/f3.out" \ ++ '^Total data:[[:space:]]+0[[:space:]]+bytes$' \ ++ '^Compressed data:[[:space:]]+0[[:space:]]+bytes[[:space:]]+\([0-9]+(\.[0-9]+)?% of original size\)$' \ ++ '^ Original size:[[:space:]]+0[[:space:]]+bytes$' \ ++ '^ Compression ratio:[[:space:]]+0\.000[[:space:]]+x[[:space:]]+\(0\.0% space savings\)$' \ ++ '^Incompressible data:[[:space:]]+0[[:space:]]+bytes$' ++[ ! -s "$WORK/f3.err" ] || fail "F3 unexpected stderr: $(cat "$WORK/f3.err")" ++ ++ ++ ++ ++if command -v script >/dev/null 2>&1; then ++ script -qfec "$BIN --dir '$CACHE1' --threads 1 --show-compression" /dev/null \ ++ >"$WORK/f4.tty" 2>"$WORK/f4.err"; ec=$? ++ tr -d '\r' <"$WORK/f4.tty" >"$WORK/f4.norm" ++ [ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++ [ ! -s "$WORK/f4.err" ] || fail "F4 unexpected stderr: $(cat "$WORK/f4.err")" ++ grep -q 'Scanning...' "$WORK/f4.norm" || fail "F4 missing Scanning progress" ++ last_nonempty_before_table=$(awk '/^Total data:/{print last; exit} NF{last=$0}' "$WORK/f4.norm") ++ previous_line_before_table=$(awk '/^Total data:/{print prev; exit}{prev=$0}' "$WORK/f4.norm") ++ ++ printf '%s\n' "$last_nonempty_before_table" | grep -Eq 'Scanning\.\.\..*100(\.0)?%' \ ++ || fail "F4 progress did not reach completion" ++ [ -z "$previous_line_before_table" ] || fail "F4 missing blank line before final table" ++ sed -n '/^Total data:/,$p' "$WORK/f4.norm" >"$WORK/f4.table" ++ ++ expect_report "F4 final table" "$WORK/f4.table" "${F1_REPORT_REGEX[@]}" ++else ++ fail "F4 requires script(1) to allocate a TTY" ++fi ++ ++ ++ ++ ++"$BIN" --help >"$WORK/f5.out" 2>"$WORK/f5.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++grep -q '^Common options:$' "$WORK/f5.out" || fail "F5 missing Common options section" ++ ++awk ' ++ /^Common options:$/ { in_common = 1; next } ++ /^[^[:space:]]/ { in_common = 0 } ++ in_common && /-x, --show-compression/ && /compression statistics/ { found = 1 } ++ END { exit found ? 0 : 1 } ++' "$WORK/f5.out" \ ++ || fail "F5 missing show-compression help line" ++[ ! -s "$WORK/f5.err" ] || fail "F5 unexpected stderr: $(cat "$WORK/f5.err")" ++ ++ ++ ++ ++"$BIN" --dir "$CACHE1" --threads 0 --show-compression \ ++ >"$WORK/ferr.out" 2>"$WORK/ferr.err"; ec=$? ++[ "$ec" -ne 0 ] || fail "F_err exit $ec; want non-zero" ++[ ! -s "$WORK/ferr.out" ] || fail "F_err unexpected stdout: $(cat "$WORK/ferr.out")" ++ ++[ -s "$WORK/ferr.err" ] || fail "F_err expected stderr for invalid --threads" ++grep -qi 'thread' "$WORK/ferr.err" || fail "F_err stderr should identify --threads: $(cat "$WORK/ferr.err")" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,14 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++ ++ ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000629/tests/test.sh b/tasks/format-code-task-000629/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000629/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000629/tests/test_command.sh b/tasks/format-code-task-000629/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000629/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000642/environment/Dockerfile b/tasks/format-code-task-000642/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5d973b07f4b5cf3ec1e14a65ed0de1f57379f326 --- /dev/null +++ b/tasks/format-code-task-000642/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e3f71ec1f49e4b741a8e0efc3d5db42d747351f93e0260f84029f6a4f708cf42 diff --git a/tasks/format-code-task-000642/environment/setup/files/blocklist b/tasks/format-code-task-000642/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000642/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000642/environment/setup/setup.sh b/tasks/format-code-task-000642/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000642/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000642/tests/test.patch b/tasks/format-code-task-000642/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f68a19668ecea8527958d74baacde510b9d8efb --- /dev/null +++ b/tasks/format-code-task-000642/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/internal/kms/secretskms_test.go b/internal/kms/secretskms_test.go +index 757504b5cfd..d30d1ba676a 100644 +--- a/internal/kms/secretskms_test.go ++++ b/internal/kms/secretskms_test.go +@@ -70,15 +70,7 @@ func TestInitSecretsMetadataKMS(t *testing.T) { + Secrets: map[string]string{}, + } + +- // passphrase it not set, init should fail + kms, err := initSecretsMetadataKMS(args) +- require.Error(t, err) +- require.Nil(t, kms) +- +- // set a passphrase to get a working KMS +- args.Secrets[encryptionPassphraseKey] = "my-passphrase-from-kubernetes" +- +- kms, err = initSecretsMetadataKMS(args) + require.NoError(t, err) + require.NotNil(t, kms) + require.Equal(t, DEKStoreMetadata, kms.RequiresDEKStore()) +@@ -86,25 +78,40 @@ func TestInitSecretsMetadataKMS(t *testing.T) { + + func TestWorkflowSecretsMetadataKMS(t *testing.T) { + t.Parallel() +- secrets := map[string]string{ +- encryptionPassphraseKey: "my-passphrase-from-kubernetes", +- } + args := ProviderInitArgs{ + Tenant: "tenant", + Config: nil, +- Secrets: secrets, ++ Secrets: map[string]string{}, + } + volumeID := "csi-vol-1b00f5f8-b1c1-11e9-8421-9243c1f659f0" + + kms, err := initSecretsMetadataKMS(args) + require.NoError(t, err) + require.NotNil(t, kms) ++ require.Equal(t, DEKStoreMetadata, kms.RequiresDEKStore()) + + // plainDEK is the (LUKS) passphrase for the volume + plainDEK := "usually created with generateNewEncryptionPassphrase()" + + ctx := context.TODO() + ++ ++ _, err = kms.EncryptDEK(ctx, volumeID, plainDEK) ++ require.Error(t, err) ++ ++ secrets := map[string]string{ ++ encryptionPassphraseKey: "my-passphrase-from-kubernetes", ++ } ++ args = ProviderInitArgs{ ++ Tenant: "tenant", ++ Config: nil, ++ Secrets: secrets, ++ } ++ ++ kms, err = initSecretsMetadataKMS(args) ++ require.NoError(t, err) ++ require.NotNil(t, kms) ++ + encryptedDEK, err := kms.EncryptDEK(ctx, volumeID, plainDEK) + require.NoError(t, err) + require.NotEqual(t, "", encryptedDEK) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3ST0/CMBgG8J33KSqeWTfd4ANwIMbAQUw8km59ZQ1ba9oOLn54yyLxX5ALaIzP ++77C+ebumb/YsKTvVyCXpDY/OJQ3GRdGvwee1r7PiKstGeV5keZSGKs0jVpxtonc654VlLLLG+O/e ++O7b/RyVv+XtyflmZthVaJq4+3R3H8r8Ome/zz0dZyD88xxFLTzfCYf88/8sLXirNS+HquJKs/wlK ++kvHKsF3JhhuWcKU9WS0avm4dZ0PbaTa4D7tz2i6osuTd7WzxvOtMSZMVnuZGV/ShM1FPNdm+daOV ++fz03Iy+k8GJ//sHY9WNjtge2v7bvaKVcmI7kIP7tbwkAAAAAAAAAAAAAAAAAAAAA8NNeAMkOYWgA ++KAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000642/tests/test.sh b/tasks/format-code-task-000642/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..387ed504cd25f795a9efb96d78972ce89769676c --- /dev/null +++ b/tasks/format-code-task-000642/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/kms/secretskms_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000642/tests/test_command.sh b/tasks/format-code-task-000642/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000642/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000643/environment/Dockerfile b/tasks/format-code-task-000643/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5e86a0ce2be79173a24bf1f0c74120e83dadd3fb --- /dev/null +++ b/tasks/format-code-task-000643/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3a78c604c41a5cbf4b9dfaaafa130abe67cd8a026d46af08c81e3f1cadb14cb3 diff --git a/tasks/format-code-task-000643/environment/setup/files/blocklist b/tasks/format-code-task-000643/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000643/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000643/environment/setup/setup.sh b/tasks/format-code-task-000643/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000643/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000643/tests/test.patch b/tasks/format-code-task-000643/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6fc74a64ba0c3d6f69ff17cc5d5d01303783804a --- /dev/null +++ b/tasks/format-code-task-000643/tests/test.patch @@ -0,0 +1,216 @@ +diff --git a/packages/function-tree/src/primitives.test.js b/packages/function-tree/src/primitives.test.js +new file mode 100644 +index 00000000..ae007688 +--- /dev/null ++++ b/packages/function-tree/src/primitives.test.js +@@ -0,0 +1,184 @@ ++/* eslint-env mocha */ ++import FunctionTree, {sequence, parallel} from './' ++import assert from 'assert' ++ ++describe('primitives', () => { ++ it('should expose sequence and parallel as functions', () => { ++ assert.equal(typeof sequence, 'function') ++ assert.equal(typeof parallel, 'function') ++ }) ++ ++ it('should run a sequence one item after the other and merge payload', (done) => { ++ const order = [] ++ const execute = FunctionTree([]) ++ ++ execute.once('end', (execution, payload) => { ++ assert.deepEqual(order, ['a', 'b']) ++ assert.deepEqual(payload, {foo: 'bar', a: 1, b: 2}) ++ done() ++ }) ++ ++ execute(sequence( ++ () => { order.push('a'); return {a: 1} }, ++ () => { order.push('b'); return {b: 2} } ++ ), {foo: 'bar'}) ++ }) ++ ++ it('should still treat a plain array as a sequence', (done) => { ++ const order = [] ++ const execute = FunctionTree([]) ++ ++ execute.once('end', (execution, payload) => { ++ assert.deepEqual(order, ['a', 'b']) ++ assert.deepEqual(payload, {a: 1, b: 2}) ++ done() ++ }) ++ ++ execute([ ++ () => { order.push('a'); return {a: 1} }, ++ () => { order.push('b'); return {b: 2} } ++ ]) ++ }) ++ ++ it('should run parallel items concurrently and merge their payloads', (done) => { ++ const execute = FunctionTree([]) ++ let resolveCount ++ ++ execute.once('parallelStart', (execution, payload, functionsToResolve) => { ++ resolveCount = functionsToResolve ++ }) ++ execute.once('end', (execution, payload) => { ++ assert.equal(resolveCount, 2) ++ assert.deepEqual(payload, {a: 1, b: 2}) ++ done() ++ }) ++ ++ execute(parallel( ++ () => Promise.resolve({a: 1}), ++ () => Promise.resolve({b: 2}) ++ )) ++ }) ++ ++ it('should run a grouped sequence inside parallel as a single branch', (done) => { ++ const order = [] ++ const execute = FunctionTree([]) ++ let resolveCount ++ ++ execute.once('parallelStart', (execution, payload, functionsToResolve) => { ++ resolveCount = functionsToResolve ++ }) ++ execute.once('end', () => { ++ ++ assert.equal(resolveCount, 2) ++ ++ assert.ok(order.indexOf('b') < order.indexOf('c')) ++ done() ++ }) ++ ++ execute(parallel( ++ () => { order.push('a'); return Promise.resolve() }, ++ [ ++ () => { order.push('b'); return Promise.resolve() }, ++ () => { order.push('c') } ++ ] ++ )) ++ }) ++ ++ it('should not treat a nested plain array as parallel', (done) => { ++ const order = [] ++ const execute = FunctionTree([]) ++ let parallelStarted = false ++ ++ execute.on('parallelStart', () => { ++ parallelStarted = true ++ }) ++ execute.once('end', (execution, payload) => { ++ assert.equal(parallelStarted, false) ++ assert.deepEqual(order, ['a', 'b']) ++ assert.deepEqual(payload, {a: 1, b: 2}) ++ done() ++ }) ++ ++ execute([ ++ [ ++ () => { order.push('a'); return Promise.resolve({a: 1}) }, ++ () => { order.push('b'); return Promise.resolve({b: 2}) } ++ ] ++ ]) ++ }) ++ ++ it('should accept an optional leading name on a sequence without running it', (done) => { ++ const order = [] ++ let functionCount = 0 ++ const execute = FunctionTree([]) ++ ++ execute.on('functionStart', () => { ++ functionCount++ ++ }) ++ execute.once('end', () => { ++ assert.equal(functionCount, 2) ++ assert.deepEqual(order, ['a', 'b']) ++ done() ++ }) ++ ++ execute(sequence('my sequence', ++ () => { order.push('a') }, ++ () => { order.push('b') } ++ )) ++ }) ++ ++ it('should accept an optional leading name on a parallel without running it', (done) => { ++ const execute = FunctionTree([]) ++ let resolveCount ++ ++ execute.once('parallelStart', (execution, payload, functionsToResolve) => { ++ resolveCount = functionsToResolve ++ }) ++ execute.once('end', (execution, payload) => { ++ assert.equal(resolveCount, 2) ++ assert.deepEqual(payload, {a: 1, b: 2}) ++ done() ++ }) ++ ++ execute(parallel('the name', ++ () => Promise.resolve({a: 1}), ++ () => Promise.resolve({b: 2}) ++ )) ++ }) ++ ++ it('should flag functions as parallel only when a direct branch of a parallel', (done) => { ++ const execute = FunctionTree([]) ++ const flags = {} ++ ++ execute.on('functionStart', (execution, funcDetails) => { ++ flags[funcDetails.name] = funcDetails.isParallel ++ }) ++ execute.once('end', () => { ++ assert.equal(flags.pa, true) ++ assert.equal(flags.pb, true) ++ assert.equal(flags.sa, false) ++ done() ++ }) ++ ++ execute(parallel( ++ function pa () { return Promise.resolve() }, ++ function pb () { return Promise.resolve() }, ++ [ ++ function sa () {} ++ ] ++ )) ++ }) ++ ++ it('should accept a primitive as the tree passed to execute', (done) => { ++ const execute = FunctionTree([]) ++ ++ execute.once('end', (execution, payload) => { ++ assert.deepEqual(payload, {done: true}) ++ done() ++ }) ++ ++ execute(sequence( ++ () => ({done: true}) ++ )) ++ }) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++cd /testbed/packages/function-tree ++../../node_modules/.bin/mocha --compilers js:babel-register 'src/providers/*.test.js' ++ ++ ++../../node_modules/.bin/mocha --compilers js:babel-register 'src/primitives.test.js' diff --git a/tasks/format-code-task-000643/tests/test.sh b/tasks/format-code-task-000643/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..83a5ec0ee6e74db4c32587251c77c1d414bf8c29 --- /dev/null +++ b/tasks/format-code-task-000643/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/function-tree/src/primitives.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000643/tests/test_command.sh b/tasks/format-code-task-000643/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000643/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000644/environment/Dockerfile b/tasks/format-code-task-000644/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..983cde40e210def3969e6ea271adbf68c82438a1 --- /dev/null +++ b/tasks/format-code-task-000644/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3940638a1f030f31a88f4121a74085a1c35b10cfc7868ae9fc27d301ea8e347e diff --git a/tasks/format-code-task-000644/environment/setup/files/blocklist b/tasks/format-code-task-000644/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000644/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000644/environment/setup/setup.sh b/tasks/format-code-task-000644/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000644/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000644/tests/test.patch b/tasks/format-code-task-000644/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ffee4c19f33b4bba7db341fccd9d2e67f2e86b1c --- /dev/null +++ b/tasks/format-code-task-000644/tests/test.patch @@ -0,0 +1,369 @@ +diff --git a/usercase-test-coderl/test_artifact_wiring.py b/usercase-test-coderl/test_artifact_wiring.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_artifact_wiring.py +@@ -0,0 +1,340 @@ ++from argo.workflows.client.models import V1Container, V1alpha1Artifact ++from argo.workflows.dsl import Workflow ++from argo.workflows.dsl.tasks import artifact, task ++from argo.workflows.dsl.templates import inputs, outputs, template ++ ++ ++def _task_by_name(manifest, name): ++ tasks = manifest["spec"]["templates"][0]["dag"]["tasks"] ++ return next(task_manifest for task_manifest in tasks if task_manifest["name"] == name) ++ ++ ++def _template_by_name(manifest, name): ++ templates = manifest["spec"]["templates"] ++ return next(template_manifest for template_manifest in templates if template_manifest["name"] == name) ++ ++ ++def _assert_artifacts_match(actual, expected): ++ ++ assert len(actual) == len(expected) ++ unmatched = list(actual) ++ for expected_artifact in expected: ++ match_index = next( ++ ( ++ index ++ for index, artifact_manifest in enumerate(unmatched) ++ if all( ++ artifact_manifest.get(field) == value ++ for field, value in expected_artifact.items() ++ ) ++ ), ++ None, ++ ) ++ assert match_index is not None, ( ++ f"missing artifact with fields {expected_artifact!r} in {actual!r}" ++ ) ++ unmatched.pop(match_index) ++ ++ ++def _artifact_passing_workflow_class(): ++ class ArtifactPassing(Workflow): ++ name = "artifact-passing" ++ ++ @task ++ def generate_artifact(self): ++ return self.generate_message() ++ ++ @task ++ @artifact( ++ name="message", ++ _from="{{tasks.generate-artifact.outputs.artifacts.hello-art}}", ++ ) ++ def consume_artifact(self, message): ++ ++ assert isinstance(message, V1alpha1Artifact) ++ return self.print_message(message=message) ++ ++ @template ++ @outputs.artifact(name="hello-art", path="/tmp/hello_world.txt") ++ def generate_message(self): ++ return V1Container( ++ image="alpine:3.7", ++ name="generate-message", ++ command=["sh", "-c"], ++ args=["echo hello world > /tmp/hello_world.txt"], ++ ) ++ ++ @template ++ @inputs.artifact(name="message", path="/tmp/message") ++ def print_message(self, message): ++ return V1Container( ++ image="alpine:3.7", ++ name="print-message", ++ command=["cat", "/tmp/message"], ++ ) ++ ++ return ArtifactPassing ++ ++ ++def _hyphen_and_stacked_workflow_class(): ++ class HyphenAndStackedArtifacts(Workflow): ++ name = "hyphen-and-stacked-artifacts" ++ ++ @task ++ @artifact( ++ name="input-file", ++ path="/tmp/input-file", ++ _from="{{tasks.build.outputs.artifacts.input-file}}", ++ ) ++ def consume_hyphenated(self, input_file): ++ ++ assert isinstance(input_file, V1alpha1Artifact) ++ return self.consume_template(input_file=input_file) ++ ++ @template ++ @inputs.artifact(name="input-file", path="/tmp/input-file") ++ def consume_template(self, input_file): ++ return V1Container( ++ image="alpine:3.7", ++ name="consume-template", ++ command=["cat", "/tmp/input-file"], ++ ) ++ ++ @template ++ @outputs.artifact(name="first-art", path="/tmp/first.txt") ++ @outputs.artifact(name="second-art", path="/tmp/second.txt") ++ def multi_output(self): ++ return V1Container( ++ image="alpine:3.7", ++ name="multi-output", ++ command=["sh", "-c"], ++ args=["touch /tmp/first.txt /tmp/second.txt"], ++ ) ++ ++ @task ++ @artifact(name="first", _from="{{tasks.multi.outputs.artifacts.first-art}}") ++ @artifact(name="second", _from="{{tasks.multi.outputs.artifacts.second-art}}") ++ def multi_consume(self, first, second): ++ ++ assert isinstance(first, V1alpha1Artifact) ++ assert isinstance(second, V1alpha1Artifact) ++ return self.multi_output() ++ ++ return HyphenAndStackedArtifacts ++ ++ ++def test_task_artifact_argument_is_injected_and_serialized(): ++ ++ ++ ++ ArtifactPassing = _artifact_passing_workflow_class() ++ wf = ArtifactPassing(compile=False) ++ ++ wf.compile() ++ manifest = wf.to_dict() ++ task_manifest = _task_by_name(manifest, "consume-artifact") ++ ++ ++ assert "artifacts" in task_manifest["arguments"] ++ _assert_artifacts_match( ++ task_manifest["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.generate-artifact.outputs.artifacts.hello-art}}", ++ "name": "message", ++ } ++ ], ++ ) ++ ++ assert task_manifest.get("template") ++ ++ ++def test_template_artifact_inputs_and_outputs_are_advertised(): ++ ++ ++ ++ ArtifactPassing = _artifact_passing_workflow_class() ++ wf = ArtifactPassing() ++ manifest = wf.to_dict() ++ ++ generate_template = _template_by_name(manifest, "generate-message") ++ print_template = _template_by_name(manifest, "print-message") ++ ++ _assert_artifacts_match( ++ generate_template["outputs"]["artifacts"], ++ [{"name": "hello-art", "path": "/tmp/hello_world.txt"}], ++ ) ++ _assert_artifacts_match( ++ print_template["inputs"]["artifacts"], ++ [{"name": "message", "path": "/tmp/message"}], ++ ) ++ ++ ++def test_hyphenated_artifact_name_is_injected_as_snake_case_keyword(): ++ ++ ++ ++ HyphenAndStackedArtifacts = _hyphen_and_stacked_workflow_class() ++ wf = HyphenAndStackedArtifacts() ++ manifest = wf.to_dict() ++ task_manifest = _task_by_name(manifest, "consume-hyphenated") ++ ++ _assert_artifacts_match( ++ task_manifest["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.build.outputs.artifacts.input-file}}", ++ "name": "input-file", ++ "path": "/tmp/input-file", ++ } ++ ], ++ ) ++ ++ assert task_manifest.get("template") ++ ++ ++def test_stacked_artifact_decorators_preserve_all_entries(): ++ ++ ++ ++ HyphenAndStackedArtifacts = _hyphen_and_stacked_workflow_class() ++ wf = HyphenAndStackedArtifacts() ++ manifest = wf.to_dict() ++ ++ task_manifest = _task_by_name(manifest, "multi-consume") ++ template_manifest = _template_by_name(manifest, "multi-output") ++ ++ _assert_artifacts_match( ++ task_manifest["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.multi.outputs.artifacts.second-art}}", ++ "name": "second", ++ }, ++ { ++ "_from": "{{tasks.multi.outputs.artifacts.first-art}}", ++ "name": "first", ++ }, ++ ], ++ ) ++ _assert_artifacts_match( ++ template_manifest["outputs"]["artifacts"], ++ [ ++ {"name": "second-art", "path": "/tmp/second.txt"}, ++ {"name": "first-art", "path": "/tmp/first.txt"}, ++ ], ++ ) ++ ++ ++def test_compile_injects_artifact_instead_of_requiring_manual_task_argument(): ++ ++ ++ ++ HyphenAndStackedArtifacts = _hyphen_and_stacked_workflow_class() ++ wf = HyphenAndStackedArtifacts(compile=False) ++ ++ ++ wf.compile() ++ manifest = wf.to_dict() ++ task_manifest = _task_by_name(manifest, "consume-hyphenated") ++ ++ _assert_artifacts_match( ++ task_manifest["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.build.outputs.artifacts.input-file}}", ++ "name": "input-file", ++ "path": "/tmp/input-file", ++ } ++ ], ++ ) ++ ++ ++def test_compile_is_idempotent_after_artifacts_are_wired(): ++ ++ ++ ++ ArtifactPassing = _artifact_passing_workflow_class() ++ wf = ArtifactPassing(compile=False) ++ ++ wf.compile() ++ first_manifest = wf.to_dict() ++ wf.compile() ++ second_manifest = wf.to_dict() ++ ++ ++ _assert_artifacts_match( ++ _task_by_name(first_manifest, "consume-artifact")["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.generate-artifact.outputs.artifacts.hello-art}}", ++ "name": "message", ++ } ++ ], ++ ) ++ _assert_artifacts_match( ++ _task_by_name(second_manifest, "consume-artifact")["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.generate-artifact.outputs.artifacts.hello-art}}", ++ "name": "message", ++ } ++ ], ++ ) ++ ++ ++def test_two_workflow_instances_keep_artifact_compile_state_independent(): ++ ++ ++ ++ ArtifactPassing = _artifact_passing_workflow_class() ++ a = ArtifactPassing(compile=False) ++ b = ArtifactPassing(compile=False) ++ ++ a.compile() ++ a_manifest = a.to_dict() ++ ++ ++ _assert_artifacts_match( ++ _task_by_name(a_manifest, "consume-artifact")["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.generate-artifact.outputs.artifacts.hello-art}}", ++ "name": "message", ++ } ++ ], ++ ) ++ ++ b.compile() ++ b_manifest = b.to_dict() ++ ++ _assert_artifacts_match( ++ _task_by_name(b_manifest, "consume-artifact")["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.generate-artifact.outputs.artifacts.hello-art}}", ++ "name": "message", ++ } ++ ], ++ ) ++ ++ ++def test_repeated_artifact_workflow_cycles_do_not_accumulate_artifacts(): ++ ++ ++ ++ ArtifactPassing = _artifact_passing_workflow_class() ++ ++ ++ for _ in range(25): ++ wf = ArtifactPassing() ++ manifest = wf.to_dict() ++ _assert_artifacts_match( ++ _task_by_name(manifest, "consume-artifact")["arguments"]["artifacts"], ++ [ ++ { ++ "_from": "{{tasks.generate-artifact.outputs.artifacts.hello-art}}", ++ "name": "message", ++ } ++ ], ++ ) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PIP_NO_INDEX=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_artifact_wiring.py -v diff --git a/tasks/format-code-task-000644/tests/test.sh b/tasks/format-code-task-000644/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a71fb5d3594829eae0e1747b219ec0e6d14c5db8 --- /dev/null +++ b/tasks/format-code-task-000644/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_artifact_wiring.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000644/tests/test_command.sh b/tasks/format-code-task-000644/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000644/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000675/environment/Dockerfile b/tasks/format-code-task-000675/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d2f5e2e043930df66a63fa5010974073e7a5a7f3 --- /dev/null +++ b/tasks/format-code-task-000675/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e4f9bb893ce1dcfc1d2db4bc600553b2306a81459181f87d22237b601bab3aad diff --git a/tasks/format-code-task-000675/environment/setup/files/blocklist b/tasks/format-code-task-000675/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000675/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000675/environment/setup/setup.sh b/tasks/format-code-task-000675/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000675/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000675/tests/test.patch b/tasks/format-code-task-000675/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9e143a0815cf4558839d4208688e3076ce2f5246 --- /dev/null +++ b/tasks/format-code-task-000675/tests/test.patch @@ -0,0 +1,322 @@ +diff --git a/usercase-test-coderl/fixtures/ckbnextconfig.h b/usercase-test-coderl/fixtures/ckbnextconfig.h +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/ckbnextconfig.h +@@ -0,0 +1,15 @@ ++#ifndef CKB_NEXT_TEST_CONFIG_H ++#define CKB_NEXT_TEST_CONFIG_H ++#include ++#define CKB_NEXT_VERSION_STR "fixture-test" ++#define CKB_NEXT_PROFILE_VER 1 ++#define CKB_NEXT_SETTINGS_VER 1 ++#define CKB_NEXT_COPYRIGHT_YEAR "2026" ++#define CKB_NEXT_DESCRIPTION "fixture test" ++#define N_KEYNAME_LENGTH 40 ++#define N_KEYNAME_STRLEN 39 ++#define N_KEYNAME_STR_REAL(x) #x ++#define N_KEYNAME_STR(x) N_KEYNAME_STR_REAL(x) ++#define N_SCANF_KEYNAME N_KEYNAME_STR(N_KEYNAME_STRLEN) ++static_assert((N_KEYNAME_LENGTH == N_KEYNAME_STRLEN + 1), "N_KEYNAME_LENGTH must be 1 greater than N_KEYNAME_STRLEN"); ++#endif +diff --git a/usercase-test-coderl/fixtures/rgb_fifo_harness.c b/usercase-test-coderl/fixtures/rgb_fifo_harness.c +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/rgb_fifo_harness.c +@@ -0,0 +1,134 @@ ++#include "src/daemon/includes.h" ++#include "src/daemon/led.h" ++#include "src/daemon/usb.h" ++ ++usbdevice keyboard[DEV_MAX]; ++queued_mutex_t devmutex[DEV_MAX]; ++queued_mutex_t inputmutex[DEV_MAX]; ++queued_mutex_t macromutex[DEV_MAX]; ++pthread_mutex_t macromutex2[DEV_MAX]; ++pthread_cond_t macrovar[DEV_MAX]; ++pthread_cond_t macroint[DEV_MAX]; ++pthread_mutex_t interruptmutex[DEV_MAX]; ++pthread_cond_t interruptcond[DEV_MAX]; ++pthread_mutex_t childrenmutex[DEV_MAX]; ++ ++static int updatergb_calls; ++static int updatedpi_calls; ++ ++void queued_mutex_lock(queued_mutex_t* mutex) { (void)mutex; } ++int queued_mutex_trylock(queued_mutex_t* mutex) { (void)mutex; return 0; } ++void queued_mutex_unlock(queued_mutex_t* mutex) { (void)mutex; } ++void queued_cond_nanosleep(pthread_cond_t *restrict cond, queued_mutex_t *restrict mutex, const uint32_t ns) { ++ (void)cond; (void)mutex; (void)ns; ++} ++int cond_nanosleep(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex, uint32_t ns) { ++ (void)cond; (void)mutex; (void)ns; return 0; ++} ++int usb_tryreset(usbdevice* kb) { (void)kb; return 0; } ++int mknotifynode(usbdevice* kb, int notify) { (void)kb; (void)notify; return 0; } ++int rmnotifynode(usbdevice* kb, int notify) { (void)kb; (void)notify; return 0; } ++ ++static int cmd_active_stub(usbdevice* kb, usbmode* mode, int n, int key, const char* parameter) { ++ (void)mode; (void)n; (void)key; (void)parameter; ++ kb->active = 1; ++ return 0; ++} ++ ++static int cmd_idle_stub(usbdevice* kb, usbmode* mode, int n, int key, const char* parameter) { ++ (void)mode; (void)n; (void)key; (void)parameter; ++ kb->active = 0; ++ return 0; ++} ++ ++static int updatergb_stub(usbdevice* kb, int force) { ++ (void)kb; (void)force; ++ updatergb_calls++; ++ return 0; ++} ++ ++static int updatedpi_stub(usbdevice* kb, int force) { ++ (void)kb; (void)force; ++ updatedpi_calls++; ++ return 0; ++} ++ ++static void setmodeindex_stub(usbdevice* kb, int index) { ++ (void)kb; (void)index; ++} ++ ++static void init_device(usbdevice* kb, usbprofile* profile) { ++ memset(kb, 0, sizeof(*kb)); ++ memset(profile, 0, sizeof(*profile)); ++ updatergb_calls = 0; ++ updatedpi_calls = 0; ++ ++ kb->profile = profile; ++ kb->features = FEAT_STD_RGB; ++ kb->vendor = V_CORSAIR; ++ kb->product = P_K70; ++ profile->currentmode = &profile->mode[0]; ++ ++ kb->vtable.rgb = cmd_rgb; ++ kb->vtable.active = cmd_active_stub; ++ kb->vtable.idle = cmd_idle_stub; ++ kb->vtable.setmodeindex = setmodeindex_stub; ++ kb->vtable.updatergb = updatergb_stub; ++ kb->vtable.updatedpi = updatedpi_stub; ++ ++ for(int i = 0; i < N_KEYS_EXTENDED; i++) { ++ kb->keymap[i].name = NULL; ++ kb->keymap[i].led = i; ++ kb->keymap[i].scan = KEY_NONE; ++ } ++} ++ ++static void print_mode(const char* label, const usbmode* mode) { ++ int red = 0, green = 0, blue = 0, nonzero = 0; ++ int rmin = 0xff, rmax = 0, gmin = 0xff, gmax = 0, bmin = 0xff, bmax = 0; ++ unsigned long sum = 0; ++ for(int i = 0; i < N_KEYS_EXTENDED; i++) { ++ red += mode->light.r[i] == 0xff; ++ green += mode->light.g[i] == 0xff; ++ blue += mode->light.b[i] == 0xff; ++ nonzero += mode->light.r[i] || mode->light.g[i] || mode->light.b[i]; ++ sum += mode->light.r[i] + mode->light.g[i] + mode->light.b[i]; ++ if(mode->light.r[i] < rmin) rmin = mode->light.r[i]; ++ if(mode->light.r[i] > rmax) rmax = mode->light.r[i]; ++ if(mode->light.g[i] < gmin) gmin = mode->light.g[i]; ++ if(mode->light.g[i] > gmax) gmax = mode->light.g[i]; ++ if(mode->light.b[i] < bmin) bmin = mode->light.b[i]; ++ if(mode->light.b[i] > bmax) bmax = mode->light.b[i]; ++ } ++ ++ ++ printf("%s first=%02x%02x%02x middle=%02x%02x%02x last=%02x%02x%02x total=%d rmin=%02x rmax=%02x gmin=%02x gmax=%02x bmin=%02x bmax=%02x red=%d green=%d blue=%d nonzero=%d sum=%lu\n", ++ label, ++ mode->light.r[0], mode->light.g[0], mode->light.b[0], ++ mode->light.r[N_KEYS_EXTENDED / 2], mode->light.g[N_KEYS_EXTENDED / 2], mode->light.b[N_KEYS_EXTENDED / 2], ++ mode->light.r[N_KEYS_EXTENDED - 1], mode->light.g[N_KEYS_EXTENDED - 1], mode->light.b[N_KEYS_EXTENDED - 1], ++ N_KEYS_EXTENDED, rmin, rmax, gmin, gmax, bmin, bmax, ++ red, green, blue, nonzero, sum); ++} ++ ++int main(int argc, char** argv) { ++ if(argc != 2) { ++ fprintf(stderr, "usage: %s 'command line for readcmd'\n", argv[0]); ++ return 64; ++ } ++ ++ usbprofile profile; ++ usbdevice* kb = &keyboard[0]; ++ init_device(kb, &profile); ++ ++ char line[4096]; ++ snprintf(line, sizeof(line), "%s", argv[1]); ++ int ec = readcmd(kb, line); ++ int current = (int)(profile.currentmode - profile.mode) + 1; ++ ++ printf("readcmd=%d active=%d currentmode=%d updatergb=%d updatedpi=%d\n", ++ ec, kb->active, current, updatergb_calls, updatedpi_calls); ++ print_mode("mode1", &profile.mode[0]); ++ print_mode("mode2", &profile.mode[1]); ++ return ec; ++} +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,141 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++BIN="$TMP/rgb_fifo_harness" ++( cd /workspace/repo || exit 1 ++ EXTRA_OBJS=() ++ ++ while IFS= read -r src; do ++ case "$src" in ++ src/daemon/command.c|src/daemon/led.c) continue ;; ++ esac ++ obj="$TMP/$(basename "$src" .c).o" ++ cc -std=c11 -O2 -DNDEBUG -I/workspace/repo -I/workspace/repo/usercase-test-coderl/fixtures -pthread -c "$src" -o "$obj" || exit 1 ++ EXTRA_OBJS+=("$obj") ++ done < <({ git diff --name-only --diff-filter=ACMR HEAD -- 'src/daemon/*.c'; git ls-files --others --exclude-standard 'src/daemon/*.c'; } | sort -u) ++ if ((${#EXTRA_OBJS[@]})); then ++ ar rcs "$TMP/libdaemon_extra.a" "${EXTRA_OBJS[@]}" || exit 1 ++ EXTRA_LIB="$TMP/libdaemon_extra.a" ++ else ++ EXTRA_LIB= ++ fi ++ cc -std=c11 -O2 -DNDEBUG \ ++ -I/workspace/repo \ ++ -I/workspace/repo/usercase-test-coderl/fixtures \ ++ -pthread \ ++ /workspace/repo/usercase-test-coderl/fixtures/rgb_fifo_harness.c \ ++ /workspace/repo/src/daemon/command.c \ ++ /workspace/repo/src/daemon/led.c \ ++ ${EXTRA_LIB:+"$EXTRA_LIB"} \ ++ -o "$BIN" ) || { echo "FAIL: build" >&2; exit 1; } ++ ++cd "$TMP" || exit 1 ++ ++field() { ++ local line="$1" key="$2" ++ printf '%s\n' "$line" | tr ' ' '\n' | awk -F= -v key="$key" '$1 == key { print $2; exit }' ++} ++ ++mode_line() { ++ local label="$1" ++ grep "^$label " out || fail "missing $label line: $(cat out)" ++} ++ ++assert_header() { ++ local label="$1" expected_mode="$2" line ++ line=$(sed -n '1p' out) ++ ++ [ "$(field "$line" readcmd)" = "0" ] || fail "$label readcmd: $line" ++ [ "$(field "$line" active)" = "1" ] || fail "$label active state: $line" ++ [ "$(field "$line" currentmode)" = "$expected_mode" ] || fail "$label current mode: $line" ++} ++ ++assert_uniform_mode() { ++ local label="$1" mode="$2" color="$3" line total expected_nonzero expected_sum r g b ++ line=$(mode_line "$mode") ++ total=$(field "$line" total) ++ r=$((16#${color:0:2})) ++ g=$((16#${color:2:2})) ++ b=$((16#${color:4:2})) ++ if [ "$color" = "000000" ]; then ++ expected_nonzero=0 ++ else ++ expected_nonzero=$total ++ fi ++ expected_sum=$((total * (r + g + b))) ++ ++ ++ [ "$(field "$line" first)" = "$color" ] || fail "$label $mode first LED: $line" ++ [ "$(field "$line" middle)" = "$color" ] || fail "$label $mode middle LED: $line" ++ [ "$(field "$line" last)" = "$color" ] || fail "$label $mode last LED: $line" ++ [ "$(field "$line" rmin)" = "${color:0:2}" ] && [ "$(field "$line" rmax)" = "${color:0:2}" ] || fail "$label $mode red range: $line" ++ [ "$(field "$line" gmin)" = "${color:2:2}" ] && [ "$(field "$line" gmax)" = "${color:2:2}" ] || fail "$label $mode green range: $line" ++ [ "$(field "$line" bmin)" = "${color:4:2}" ] && [ "$(field "$line" bmax)" = "${color:4:2}" ] || fail "$label $mode blue range: $line" ++ [ "$(field "$line" nonzero)" = "$expected_nonzero" ] || fail "$label $mode nonzero count: $line" ++ [ "$(field "$line" sum)" = "$expected_sum" ] || fail "$label $mode channel sum: $line" ++} ++ ++ ++ ++ ++"$BIN" 'active rgb ff0000' >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_header F1 1 ++assert_uniform_mode F1 mode1 ff0000 ++assert_uniform_mode F1 mode2 000000 ++[ ! -s err ] || fail "F1 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++"$BIN" 'active rgb all:ff0000 rgb 000000' >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_header F2 1 ++assert_uniform_mode F2 mode1 000000 ++assert_uniform_mode F2 mode2 000000 ++[ ! -s err ] || fail "F2 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++"$BIN" 'active rgb 2468ac' >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 shorthand exit $ec; want 0" ++assert_header F3-shorthand 1 ++assert_uniform_mode F3-shorthand mode1 2468ac ++assert_uniform_mode F3-shorthand mode2 000000 ++[ ! -s err ] || fail "F3 shorthand unexpected stderr: $(cat err)" ++ ++"$BIN" 'active rgb all:2468ac' >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 all-selector exit $ec; want 0" ++assert_header F3-all-selector 1 ++assert_uniform_mode F3-all-selector mode1 2468ac ++assert_uniform_mode F3-all-selector mode2 000000 ++[ ! -s err ] || fail "F3 all-selector unexpected stderr: $(cat err)" ++ ++ ++ ++ ++"$BIN" 'active rgb all:111111 mode 2 switch rgb 0000ff' >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_header F4 2 ++assert_uniform_mode F4 mode1 111111 ++assert_uniform_mode F4 mode2 0000ff ++[ ! -s err ] || fail "F4 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++"$BIN" >out 2>err; ec=$? ++ ++[ "$ec" -eq 64 ] || fail "F_err exit $ec; want 64" ++[ ! -s out ] || fail "F_err unexpected stdout: $(cat out)" ++[ -s err ] || fail "F_err expected stderr" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000675/tests/test.sh b/tasks/format-code-task-000675/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a0043641292cbc4e8ddf2356a2a69fe4511fc9a3 --- /dev/null +++ b/tasks/format-code-task-000675/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/ckbnextconfig.h +usercase-test-coderl/fixtures/rgb_fifo_harness.c +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000675/tests/test_command.sh b/tasks/format-code-task-000675/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000675/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000681/environment/Dockerfile b/tasks/format-code-task-000681/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d9e42d888703f7edce86773696027349113df552 --- /dev/null +++ b/tasks/format-code-task-000681/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fa7998e14b2b38495e9e7b32a86b955c0d642cbe38dfda63f0b27a3726a204bf diff --git a/tasks/format-code-task-000681/environment/setup/files/blocklist b/tasks/format-code-task-000681/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000681/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000681/environment/setup/setup.sh b/tasks/format-code-task-000681/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000681/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000681/tests/test.patch b/tasks/format-code-task-000681/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ef30a5ed24fc8061b453d1cc5bf192e3e7d37927 --- /dev/null +++ b/tasks/format-code-task-000681/tests/test.patch @@ -0,0 +1,38 @@ +diff --git a/crates/testing/tests/standalone_integration_test.rs b/crates/testing/tests/standalone_integration_test.rs +index 28fd7b53d1c..2eacbcb7cd0 100644 +--- a/crates/testing/tests/standalone_integration_test.rs ++++ b/crates/testing/tests/standalone_integration_test.rs +@@ -3,8 +3,8 @@ use spacetimedb_testing::modules::{compile, with_module_async}; + + #[test] + fn test_calling_a_reducer() { +- compile("spacetimedb_quickstart"); +- with_module_async("spacetimedb_quickstart", |module| async move { ++ compile("spacetimedb-quickstart"); ++ with_module_async("spacetimedb-quickstart", |module| async move { + let json = r#"{"call": {"fn": "add", "args": ["Tyrion"]}}"#.to_string(); + module.send(json).await.unwrap(); + let json = r#"{"call": {"fn": "say_hello", "args": []}}"#.to_string(); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,7 @@ ++H4sIAAAAAAAAA+3RQW+CMBgGYM78ii/Ow3YAgYmcPDjnnMk2TfROECoSpSWlLPv5q5jp4rKZJZpl ++8X1CQtO+pV/57HmVrZOQ8deWcS6OFvh+/dYO3/XY9T3X0zG30zYc1/WDwCD/bBV9UpUqkkSGFEL9 ++lDu2/k/Z+/4rVqowFnke8cQul6c741j//Vvvo/+d4DbQ/W93PMcg53QlfO/C+x8nVDd+zhLTvKIp ++U1QVNJ3d34WT3uyRFkKSWjLaZEhWXGU5M9lbIaTap7rN63ylWF6QldyY+SrJJFkFNZq7RGst0rJh ++xgXFMtLfaum/zpNoLTjbLNmx4IvDfD3Z2B026fUHs9HzQCeexsOwP355GA27v9kz3Rb7tSwzjmQq ++tnfUdZdFFLPNRZO5tZnLeEpWPaJ92WHGFUv1ZTLBw+1OSz9cxFGhKsnMv+4sAAAAAAAAAAAAAAAA ++AAAAAFyCdzg4CnkAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000681/tests/test.sh b/tasks/format-code-task-000681/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..392f81c68db26ba90555de331a0fc31e2c1be808 --- /dev/null +++ b/tasks/format-code-task-000681/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +crates/testing/tests/standalone_integration_test.rs +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000681/tests/test_command.sh b/tasks/format-code-task-000681/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000681/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000810/environment/Dockerfile b/tasks/format-code-task-000810/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eac18aa47f7bffebef35c57215fca88da8356829 --- /dev/null +++ b/tasks/format-code-task-000810/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:df2339339c666ada5fc79aef0e2b658aad65414086cf366127ff03274a37d70e diff --git a/tasks/format-code-task-000810/environment/setup/files/blocklist b/tasks/format-code-task-000810/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000810/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000810/environment/setup/setup.sh b/tasks/format-code-task-000810/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000810/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000816/environment/Dockerfile b/tasks/format-code-task-000816/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fb2a6b33065b9e7bf4ba8e818c0c945b91416d21 --- /dev/null +++ b/tasks/format-code-task-000816/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ecb2f726fc6b4cad83cda9d0c731cf4fc271f1e369a084b495a397d76b5d5346 diff --git a/tasks/format-code-task-000816/environment/setup/files/blocklist b/tasks/format-code-task-000816/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000816/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000816/environment/setup/setup.sh b/tasks/format-code-task-000816/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000816/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000816/tests/test.patch b/tasks/format-code-task-000816/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9dbcb9a303853383d615c8bb5753b2325003982a --- /dev/null +++ b/tasks/format-code-task-000816/tests/test.patch @@ -0,0 +1,285 @@ +diff --git a/usercase-test-coderl/finite_automaton_facade.test.js b/usercase-test-coderl/finite_automaton_facade.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/finite_automaton_facade.test.js +@@ -0,0 +1,251 @@ ++ ++ ++ ++ ++ ++ ++ ++'use strict'; ++ ++const childProcess = require('child_process'); ++const fs = require('fs'); ++const net = require('net'); ++const os = require('os'); ++const path = require('path'); ++ ++const regexpTree = require('/workspace/repo'); ++const {fa} = regexpTree; ++ ++function matcherMap(automaton, strings) { ++ return Object.fromEntries(strings.map(string => [string, automaton.matches(string)])); ++} ++ ++function sortedSet(set) { ++ return Array.from(set).sort((a, b) => String(a).localeCompare(String(b))); ++} ++ ++describe('public finite-automaton facade', () => { ++ test('toNFA builds an NFA for RegExp input and its matcher accepts exactly the captured a* cases', () => { ++ ++ ++ const nfa = fa.toNFA(/a*/); ++ ++ expect(nfa).toBeInstanceOf(fa.NFA); ++ ++ expect(matcherMap(nfa, ['aaa', 'b', 'ba', 'aab'])).toEqual({ ++ aaa: true, ++ b: false, ++ ba: false, ++ aab: false, ++ }); ++ expect(matcherMap(nfa, ['', 'a', 'aa', 'ab'])).toEqual({ ++ '': true, ++ a: true, ++ aa: true, ++ ab: false, ++ }); ++ }); ++ ++ test('toDFA builds a DFA for RegExp input and its matcher accepts exactly the captured a* cases', () => { ++ ++ ++ const dfa = fa.toDFA(/a*/); ++ ++ expect(dfa).toBeInstanceOf(fa.DFA); ++ expect(matcherMap(dfa, ['', 'a', 'aa', 'ab'])).toEqual({ ++ '': true, ++ a: true, ++ aa: true, ++ ab: false, ++ }); ++ ++ expect(matcherMap(dfa, ['aaa', 'b', 'ba', 'aab'])).toEqual({ ++ aaa: true, ++ b: false, ++ ba: false, ++ aab: false, ++ }); ++ }); ++ ++ test('test handles disjunction, concatenation, and star through the public one-shot helper', () => { ++ ++ ++ expect({ ++ ab: fa.test(/ab|c*/, 'ab'), ++ empty: fa.test(/ab|c*/, ''), ++ c: fa.test(/ab|c*/, 'c'), ++ ccc: fa.test(/ab|c*/, 'ccc'), ++ a_or_b_rejects_c: fa.test(/a|b/, 'c'), ++ }).toEqual({ ++ ab: true, ++ empty: true, ++ c: true, ++ ccc: true, ++ a_or_b_rejects_c: false, ++ }); ++ }); ++ ++ test('regexp string input supports grouped concatenation with plus and optional quantifiers', () => { ++ ++ ++ const dfa = fa.toDFA('/(ab)+c?/'); ++ ++ expect(matcherMap(dfa, ['', 'ab', 'abc', 'abab', 'ababc', 'aba', 'ac'])).toEqual({ ++ '': false, ++ ab: true, ++ abc: true, ++ abab: true, ++ ababc: true, ++ aba: false, ++ ac: false, ++ }); ++ ++ expect(matcherMap(dfa, ['a', 'abb', 'abcabc', 'ababcc'])).toEqual({ ++ a: false, ++ abb: false, ++ abcabc: false, ++ ababcc: false, ++ }); ++ }); ++ ++ test('AST input is accepted by the facade and produces the captured disjunction automaton', () => { ++ ++ ++ const ast = regexpTree.parse('/a|b/'); ++ const dfa = fa.toDFA(ast); ++ ++ expect(matcherMap(dfa, ['', 'a', 'b', 'c', 'ab'])).toEqual({ ++ '': false, ++ a: true, ++ b: true, ++ c: false, ++ ab: false, ++ }); ++ ++ expect(matcherMap(dfa, ['aa', 'bb', 'ba'])).toEqual({ ++ aa: false, ++ bb: false, ++ ba: false, ++ }); ++ }); ++ ++ test('equivalent RegExp, string, and AST inputs produce the captured grouped quantifier booleans', () => { ++ ++ ++ const ast = regexpTree.parse('/(ab)+c?/'); ++ const strings = ['', 'ab', 'abc', 'abab', 'ababc', 'aba', 'ac']; ++ ++ expect({ ++ regexp: Object.fromEntries(strings.map(string => [string, fa.test(/(ab)+c?/, string)])), ++ string: Object.fromEntries(strings.map(string => [string, fa.test('/(ab)+c?/', string)])), ++ ast: Object.fromEntries(strings.map(string => [string, fa.test(ast, string)])), ++ }).toEqual({ ++ regexp: {'': false, ab: true, abc: true, abab: true, ababc: true, aba: false, ac: false}, ++ string: {'': false, ab: true, abc: true, abab: true, ababc: true, aba: false, ac: false}, ++ ast: {'': false, ab: true, abc: true, abab: true, ababc: true, aba: false, ac: false}, ++ }); ++ }); ++ ++ test('flags are rejected with the captured public Error message', () => { ++ ++ ++ expect(() => fa.toNFA(/a/i)).toThrow(Error); ++ ++ expect(() => fa.toNFA(/a/i)).toThrow(/flags/i); ++ }); ++ ++ test('unsupported AST node types are rejected with the captured public Error message', () => { ++ ++ ++ expect(() => fa.toNFA({type: 'Assertion', kind: '^'})).toThrow(Error); ++ ++ expect(() => fa.toNFA({type: 'Assertion', kind: '^'})).toThrow(/unsupported|not supported/i); ++ }); ++ ++ test('non-simple character AST nodes are rejected with the captured public Error message', () => { ++ ++ ++ const ast = { ++ type: 'RegExp', ++ body: {type: 'Char', value: '\\d', symbol: '\\d', kind: 'meta'}, ++ flags: '', ++ }; ++ ++ expect(() => fa.toNFA(ast)).toThrow(Error); ++ ++ expect(() => fa.toNFA(ast)).toThrow(/simple|unsupported|not supported/i); ++ }); ++ ++ test('referential transparency returns the same value for the same call', () => { ++ expect(fa.test(/ab|c*/, 'ccc')).toBe(true); ++ expect(fa.test(/ab|c*/, 'ccc')).toBe(true); ++ }); ++ ++ test('does not mutate caller-owned AST input', () => { ++ const ast = regexpTree.parse('/(ab)+c?/'); ++ const before = JSON.parse(JSON.stringify(ast)); ++ ++ expect(fa.test(ast, 'ababc')).toBe(true); ++ ++ expect(ast).toEqual(before); ++ }); ++ ++ test('fresh Node process produces the same value after in-process noise calls', () => { ++ const inProcess = { ++ target: fa.test('/(ab)+c?/', 'ababc'), ++ noise1: fa.test(/a*/, 'ab'), ++ noise2: fa.test(regexpTree.parse('/a|b/'), 'b'), ++ targetAgain: fa.test('/(ab)+c?/', 'ababc'), ++ }; ++ ++ const script = ` ++ const regexpTree = require('/workspace/repo'); ++ process.stdout.write(JSON.stringify({ ++ target: regexpTree.fa.test('/(ab)+c?/', 'ababc') ++ })); ++ `; ++ const fresh = JSON.parse( ++ childProcess.execFileSync(process.execPath, ['-e', script], {encoding: 'utf8'}) ++ ); ++ ++ expect(inProcess).toEqual({ ++ target: true, ++ noise1: false, ++ noise2: true, ++ targetAgain: true, ++ }); ++ expect(fresh).toEqual({target: true}); ++ }); ++ ++ test('does not write cwd files or open network sockets for pure automaton helpers', () => { ++ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'regexp-tree-fa-')); ++ const originalCwd = process.cwd(); ++ const originalSocket = net.Socket; ++ const originalConnect = net.connect; ++ const originalCreateConnection = net.createConnection; ++ ++ function forbiddenNetwork() { ++ throw new Error('network access is not declared for finite-automaton helpers'); ++ } ++ ++ try { ++ process.chdir(tempDir); ++ const before = fs.readdirSync(tempDir).sort(); ++ net.Socket = forbiddenNetwork; ++ net.connect = forbiddenNetwork; ++ net.createConnection = forbiddenNetwork; ++ ++ expect(fa.test('/(ab)+c?/', 'abc')).toBe(true); ++ expect(fa.test(/a|b/, 'c')).toBe(false); ++ ++ const after = fs.readdirSync(tempDir).sort(); ++ expect({before, after}).toEqual({before: [], after: []}); ++ } finally { ++ net.Socket = originalSocket; ++ net.connect = originalConnect; ++ net.createConnection = originalCreateConnection; ++ process.chdir(originalCwd); ++ fs.rmSync(tempDir, {recursive: true, force: true}); ++ } ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,24 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export npm_config_offline=true ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_update_notifier=false ++export BROWSERSLIST_IGNORE_OLD_DATA=true ++ ++mkdir -p src/parser/generated ++node ./scripts/build.js >/dev/null ++exec ./node_modules/.bin/jest /workspace/repo/usercase-test-coderl/finite_automaton_facade.test.js --runInBand diff --git a/tasks/format-code-task-000816/tests/test.sh b/tasks/format-code-task-000816/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7de5be6909e4e059e82a5d858817e6aec89fa35 --- /dev/null +++ b/tasks/format-code-task-000816/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/finite_automaton_facade.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000816/tests/test_command.sh b/tasks/format-code-task-000816/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000816/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000817/environment/Dockerfile b/tasks/format-code-task-000817/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..60df5eb540315d84ada0818bccd24d40f2eddf14 --- /dev/null +++ b/tasks/format-code-task-000817/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:906972d44e17724485dc345d2d96075cd8cf2fef9acfcd401151c1c80250fbe4 diff --git a/tasks/format-code-task-000817/environment/setup/files/blocklist b/tasks/format-code-task-000817/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000817/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000817/environment/setup/setup.sh b/tasks/format-code-task-000817/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000817/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000817/tests/test.patch b/tasks/format-code-task-000817/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e669bd48e03441eb41eea12eaa8a3d46f848cf94 --- /dev/null +++ b/tasks/format-code-task-000817/tests/test.patch @@ -0,0 +1,287 @@ +diff --git a/tests/python/common/data/test_dgl_dataset_cache_paths.py b/tests/python/common/data/test_dgl_dataset_cache_paths.py +new file mode 100644 +index 00000000..3819644f +--- /dev/null ++++ b/tests/python/common/data/test_dgl_dataset_cache_paths.py +@@ -0,0 +1,73 @@ ++import os ++ ++from dgl.data import DGLDataset ++ ++ ++class CachePathDataset(DGLDataset): ++ def __init__(self, name, url, raw_dir, save_dir): ++ super().__init__( ++ name=name, ++ url=url, ++ raw_dir=str(raw_dir), ++ save_dir=str(save_dir), ++ force_reload=False, ++ verbose=False, ++ ) ++ ++ def download(self): ++ pass ++ ++ def process(self): ++ pass ++ ++ def save(self): ++ pass ++ ++ def load(self): ++ pass ++ ++ def has_cache(self): ++ return True ++ ++ def __getitem__(self, idx): ++ raise IndexError(idx) ++ ++ def __len__(self): ++ return 0 ++ ++ ++def test_url_distinct_raw_and_save_paths(tmp_path): ++ raw_dir = tmp_path / "raw" ++ save_dir = tmp_path / "save" ++ ds_a1 = CachePathDataset("toy", "https://example.com/a.zip", raw_dir, save_dir) ++ ds_a2 = CachePathDataset("toy", "https://example.com/a.zip", raw_dir, save_dir) ++ assert ds_a1.raw_path == ds_a2.raw_path ++ assert ds_a1.save_path == ds_a2.save_path ++ ++ ds_b = CachePathDataset("toy", "https://example.com/b.zip", raw_dir, save_dir) ++ assert ds_a1.raw_path != ds_b.raw_path ++ assert ds_a1.save_path != ds_b.save_path ++ assert os.path.normpath(ds_a1.raw_path) != os.path.join(str(raw_dir), "toy") ++ assert os.path.normpath(ds_a1.save_path) != os.path.join(str(save_dir), "toy") ++ ++ ds_no_url = CachePathDataset("toy", None, raw_dir, save_dir) ++ assert os.path.normpath(ds_no_url.raw_path) == os.path.join(str(raw_dir), "toy") ++ assert os.path.normpath(ds_no_url.save_path) == os.path.join(str(save_dir), "toy") ++ ++ ++def test_url_change_uses_separate_cache_location(tmp_path): ++ raw_dir = tmp_path / "raw" ++ save_dir = tmp_path / "save" ++ ds_a = CachePathDataset("toy", "https://example.com/a.zip", raw_dir, save_dir) ++ ds_b = CachePathDataset("toy", "https://example.com/b.zip", raw_dir, save_dir) ++ ++ assert ds_a.raw_path != ds_b.raw_path ++ assert ds_a.save_path != ds_b.save_path ++ ++ os.makedirs(ds_a.raw_path, exist_ok=True) ++ os.makedirs(ds_a.save_path, exist_ok=True) ++ open(os.path.join(ds_a.raw_path, "raw.marker"), "w").close() ++ open(os.path.join(ds_a.save_path, "save.marker"), "w").close() ++ ++ assert not os.path.exists(os.path.join(ds_b.raw_path, "raw.marker")) ++ assert not os.path.exists(os.path.join(ds_b.save_path, "save.marker")) +diff --git a/tests/python/common/data/test_qm7b_single_raw_file.py b/tests/python/common/data/test_qm7b_single_raw_file.py +new file mode 100644 +index 00000000..2d1b6d95 +--- /dev/null ++++ b/tests/python/common/data/test_qm7b_single_raw_file.py +@@ -0,0 +1,29 @@ ++import numpy as np ++from scipy import io ++ ++import dgl ++ ++ ++def test_qm7b_loads_legacy_single_raw_file_with_url_distinct_cache_paths( ++ monkeypatch, tmp_path ++): ++ raw_file = tmp_path / "qm7b.mat" ++ io.savemat( ++ raw_file, ++ { ++ "T": np.ones((1, 14), dtype=np.float32), ++ "X": np.array([[[0.0, 1.0], [1.0, 0.0]]], dtype=np.float32), ++ }, ++ ) ++ ++ monkeypatch.setattr(dgl.data.QM7bDataset, "download", lambda self: None) ++ ++ dataset = dgl.data.QM7bDataset( ++ raw_dir=str(tmp_path), force_reload=True, verbose=False ++ ) ++ ++ assert len(dataset) == 1 ++ graph, label = dataset[0] ++ assert graph.num_nodes() == 2 ++ assert graph.num_edges() == 2 ++ assert tuple(label.shape) == (14,) +diff --git a/tests/python/common/data/test_wiki_network.py b/tests/python/common/data/test_wiki_network.py +new file mode 100644 +index 00000000..35d19ca6 +--- /dev/null ++++ b/tests/python/common/data/test_wiki_network.py +@@ -0,0 +1,113 @@ ++import builtins ++import os ++import unittest ++ ++import backend as F ++import dgl ++import pytest ++ ++try: ++ import torch ++except ImportError: # pragma: no cover - tests below skip without torch. ++ torch = None ++ ++ ++@unittest.skipIf( ++ F._default_context_str == "gpu", ++ reason="Datasets don't need to be tested on GPU.", ++) ++@unittest.skipIf(dgl.backend.backend_name != "pytorch", reason="only supports pytorch") ++def test_chameleon_dataset_public_api_and_basic_graph(): ++ from dgl.data import ChameleonDataset ++ ++ dataset = ChameleonDataset(force_reload=True) ++ assert len(dataset) == 1 ++ g = dataset[0] ++ assert g.num_nodes() == 2277 ++ assert hasattr(g, "ndata") ++ ++ def mark_graph(graph): ++ graph.ndata["transform_marker"] = torch.ones( ++ graph.num_nodes(), dtype=torch.bool ++ ) ++ return graph ++ ++ transformed = ChameleonDataset(force_reload=True, transform=mark_graph)[0] ++ assert "transform_marker" in transformed.ndata ++ assert transformed.ndata["transform_marker"].all().item() ++ ++ ++@unittest.skipIf( ++ F._default_context_str == "gpu", ++ reason="Datasets don't need to be tested on GPU.", ++) ++@unittest.skipIf(dgl.backend.backend_name != "pytorch", reason="only supports pytorch") ++def test_chameleon_node_data_and_num_classes(): ++ dataset = dgl.data.ChameleonDataset(force_reload=True) ++ g = dataset[0] ++ assert "feat" in g.ndata ++ assert "label" in g.ndata ++ ++ feat = g.ndata["feat"] ++ assert feat.shape[0] == g.num_nodes() ++ assert feat.numel() > 0 ++ assert torch.count_nonzero(feat).item() > 0 ++ ++ label = g.ndata["label"] ++ assert label.shape[0] == g.num_nodes() ++ assert not torch.is_floating_point(label) ++ assert torch.unique(label).numel() > 1 ++ ++ assert dataset.num_classes == int(label.max().item()) + 1 ++ assert dataset.num_classes == 5 ++ ++ ++@unittest.skipIf( ++ F._default_context_str == "gpu", ++ reason="Datasets don't need to be tested on GPU.", ++) ++@unittest.skipIf(dgl.backend.backend_name != "pytorch", reason="only supports pytorch") ++def test_chameleon_split_masks(): ++ g = dgl.data.ChameleonDataset(force_reload=True)[0] ++ ++ for key in ("train_mask", "val_mask", "test_mask"): ++ assert key in g.ndata ++ mask = g.ndata[key] ++ assert mask.dtype == torch.bool ++ assert tuple(mask.shape) == (g.num_nodes(), 10) ++ ++ train_mask = g.ndata["train_mask"] ++ val_mask = g.ndata["val_mask"] ++ test_mask = g.ndata["test_mask"] ++ for split_idx in range(10): ++ train_col = train_mask[:, split_idx] ++ val_col = val_mask[:, split_idx] ++ test_col = test_mask[:, split_idx] ++ assert train_col.any().item() ++ assert val_col.any().item() ++ assert test_col.any().item() ++ assert not torch.logical_and(train_col, val_col).any().item() ++ assert not torch.logical_and(train_col, test_col).any().item() ++ assert not torch.logical_and(val_col, test_col).any().item() ++ ++ ++def test_chameleon_requires_pytorch_for_processing(monkeypatch, tmp_path): ++ original_import = builtins.__import__ ++ ++ def import_without_torch(name, *args, **kwargs): ++ if name == "torch": ++ raise ImportError("blocked torch for this test") ++ return original_import(name, *args, **kwargs) ++ ++ monkeypatch.setattr(builtins, "__import__", import_without_torch) ++ monkeypatch.setattr( ++ dgl.data.ChameleonDataset, ++ "download", ++ lambda self: os.makedirs(self.raw_path, exist_ok=True), ++ ) ++ ++ with pytest.raises(ModuleNotFoundError) as excinfo: ++ dgl.data.ChameleonDataset(raw_dir=str(tmp_path), force_reload=True) ++ message = str(excinfo.value) ++ assert "PyTorch" in message or "pytorch" in message ++ assert "backend" in message +diff --git a/tests/python/common/data/test_wiki_network_docs.py b/tests/python/common/data/test_wiki_network_docs.py +new file mode 100644 +index 00000000..fd12f9af +--- /dev/null ++++ b/tests/python/common/data/test_wiki_network_docs.py +@@ -0,0 +1,8 @@ ++from pathlib import Path ++ ++ ++def test_chameleon_dataset_is_listed_in_data_api_docs(): ++ repo_root = Path(__file__).resolve().parents[4] ++ docs_file = repo_root / "docs" / "source" / "api" / "python" / "dgl.data.rst" ++ docs_text = docs_file.read_text() ++ assert "ChameleonDataset" in docs_text +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,35 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++export PYTHONPATH="/testbed/python:/testbed/tests:${PYTHONPATH:-}" ++export DGLBACKEND="pytorch" ++if [ -d /tmp/dgl_extract/dgl ]; then ++ export DGL_LIBRARY_PATH="/tmp/dgl_extract/dgl" ++fi ++ ++case "$1" in ++ base) ++ if [ ! -f /testbed/tests/python/common/data/test_wiki_network.py ]; then ++ exit 0 ++ fi ++ python3 -m pytest /testbed/tests/python/common/data/test_wiki_network.py -k "not chameleon" -v ++ status=$? ++ if [ "$status" -eq 5 ]; then ++ exit 0 ++ fi ++ exit "$status" ++ ;; ++ new) ++ python3 -m pytest \ ++ /testbed/tests/python/common/data/test_wiki_network.py \ ++ /testbed/tests/python/common/data/test_dgl_dataset_cache_paths.py \ ++ /testbed/tests/python/common/data/test_qm7b_single_raw_file.py \ ++ /testbed/tests/python/common/data/test_wiki_network_docs.py \ ++ -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000817/tests/test.sh b/tasks/format-code-task-000817/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b5f63a9e1ae7c1fe9264e18ecd4703ab0003c15f --- /dev/null +++ b/tasks/format-code-task-000817/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/python/common/data/test_dgl_dataset_cache_paths.py +tests/python/common/data/test_qm7b_single_raw_file.py +tests/python/common/data/test_wiki_network.py +tests/python/common/data/test_wiki_network_docs.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000817/tests/test_command.sh b/tasks/format-code-task-000817/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000817/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000820/environment/Dockerfile b/tasks/format-code-task-000820/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..10867b53e3ce619bf307e961e2a23826787bb1c4 --- /dev/null +++ b/tasks/format-code-task-000820/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dc7d440bdd5cda101881b0931491c3f5ab39e13541f5a9b5509a5488df9e1bee diff --git a/tasks/format-code-task-000820/environment/setup/files/blocklist b/tasks/format-code-task-000820/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000820/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000820/environment/setup/setup.sh b/tasks/format-code-task-000820/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000820/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000820/tests/test.patch b/tasks/format-code-task-000820/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8412eabfffe8dc98fa3715373a638de013e258af --- /dev/null +++ b/tasks/format-code-task-000820/tests/test.patch @@ -0,0 +1,312 @@ +diff --git a/usercase-test-coderl/fixtures/broken_query_db.sql b/usercase-test-coderl/fixtures/broken_query_db.sql +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/broken_query_db.sql +@@ -0,0 +1,7 @@ ++CREATE TABLE books(uuid text PRIMARY KEY,label text NOT NULL); ++CREATE TABLE notes(uuid text NOT NULL,book_uuid text NOT NULL,body text NOT NULL,added_on integer NOT NULL); ++CREATE TABLE system(key string NOT NULL,value text NOT NULL); ++ ++INSERT INTO system(key,value) VALUES ('schema','14'),('remote_schema','1'); ++INSERT INTO books(uuid,label) VALUES ('book-redis','redis'); ++INSERT INTO notes(rowid,uuid,book_uuid,body,added_on) VALUES (1,'note-broken','book-redis','rpoplpush',1); +diff --git a/usercase-test-coderl/fixtures/valid_search_db.sql b/usercase-test-coderl/fixtures/valid_search_db.sql +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/valid_search_db.sql +@@ -0,0 +1,49 @@ ++CREATE TABLE books ++ ( ++ uuid text PRIMARY KEY, ++ label text NOT NULL ++ , dirty bool DEFAULT false, usn int DEFAULT 0 NOT NULL, deleted bool DEFAULT false); ++CREATE TABLE system ++ ( ++ key string NOT NULL, ++ value text NOT NULL ++ ); ++CREATE UNIQUE INDEX idx_books_label ON books(label); ++CREATE UNIQUE INDEX idx_books_uuid ON books(uuid); ++CREATE TABLE "notes" ++ ( ++ uuid text NOT NULL, ++ book_uuid text NOT NULL, ++ body text NOT NULL, ++ added_on integer NOT NULL, ++ edited_on integer DEFAULT 0, ++ dirty bool DEFAULT false, ++ usn int DEFAULT 0 NOT NULL, ++ deleted bool DEFAULT false ++ ); ++CREATE VIRTUAL TABLE note_fts USING fts5(content=notes, body, tokenize="porter unicode61 categories 'L* N* Co Ps Pe'"); ++CREATE TRIGGER notes_after_insert AFTER INSERT ON notes BEGIN ++ INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); ++ END; ++CREATE TRIGGER notes_after_delete AFTER DELETE ON notes BEGIN ++ INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); ++ END; ++CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN ++ INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body); ++ INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body); ++ END; ++ ++INSERT INTO system (key, value) VALUES ('schema', 14); ++INSERT INTO system (key, value) VALUES ('remote_schema', 1); ++ ++INSERT INTO books(uuid,label) VALUES ++ ('book-redis','redis'), ++ ('book-alg','algorithm'), ++ ('book-proj','project'); ++ ++INSERT INTO notes(rowid,uuid,book_uuid,body,added_on) VALUES ++ (12,'note-redis','book-redis','use RPOPLPUSH for reliable queues' || char(10) || 'then acknowledge jobs',100), ++ (21,'note-heap','book-alg','building a heap starts by pushing each item upward',101), ++ (22,'note-merge-alg','book-alg','merge sort divides lists, then merge sort combines them',102), ++ (23,'note-merge-proj','book-proj','merge sort notes belong in another book',103), ++ (24,'note-redis2','book-redis','RPOPLPUSH can move work between Redis lists',104); +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,217 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export NO_COLOR=1 TERM=dumb ++ ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOMODCACHE=/go/pkg/mod ++export GOCACHE=/go/build-cache ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++BIN="$TMP/bin/dnote" ++mkdir -p "$TMP/bin" ++( cd /workspace/repo && go build -tags fts5 -ldflags '-X main.apiEndpoint=http://localhost:3001/api -X main.versionTag=acceptance' -o "$BIN" ./pkg/cli ) \ ++ || fail "build" ++ ++command -v sqlite3 >/dev/null 2>&1 || fail "sqlite3 is required" ++ ++VALID_DB="$TMP/find.db" ++BROKEN_DB="$TMP/broken.db" ++sqlite3 "$VALID_DB" < /workspace/repo/usercase-test-coderl/fixtures/valid_search_db.sql \ ++ || fail "creating valid fixture database" ++sqlite3 "$BROKEN_DB" < /workspace/repo/usercase-test-coderl/fixtures/broken_query_db.sql \ ++ || fail "creating broken fixture database" ++ ++mkdir -p "$TMP/home" "$TMP/config" "$TMP/data" "$TMP/cache" ++ ++run_dnote() { ++ local db="$1" ++ shift ++ env HOME="$TMP/home" XDG_CONFIG_HOME="$TMP/config" XDG_DATA_HOME="$TMP/data" XDG_CACHE_HOME="$TMP/cache" \ ++ "$BIN" --dbPath "$db" "$@" >out 2>err ++} ++ ++assert_file_eq() { ++ local expected="$1" ++ local actual="$2" ++ local label="$3" ++ printf '%s' "$expected" >expected ++ cmp -s expected "$actual" || fail "$label mismatch; got: $(sed -n l "$actual" | tr '\n' ' ')" ++} ++ ++assert_line_count() { ++ local actual="$1" ++ local expected="$2" ++ local label="$3" ++ local count ++ count=$(wc -l < "$actual" | tr -d ' ') ++ [ "$count" -eq "$expected" ] || fail "$label line count $count; want $expected; got: $(sed -n l "$actual" | tr '\n' ' ')" ++} ++ ++assert_line_re() { ++ local actual="$1" ++ local pattern="$2" ++ local label="$3" ++ grep -Eq "$pattern" "$actual" || fail "$label missing pattern $pattern; got: $(sed -n l "$actual" | tr '\n' ' ')" ++} ++ ++assert_file_contains() { ++ local actual="$1" ++ local needle="$2" ++ local label="$3" ++ grep -Fq -- "$needle" "$actual" || fail "$label missing '$needle'; got: $(sed -n l "$actual" | tr '\n' ' ')" ++} ++ ++assert_output_contains() { ++ local needle="$1" ++ local label="$2" ++ grep -Fq -- "$needle" out || grep -Fq -- "$needle" err || fail "$label missing '$needle'; stdout: $(sed -n l out | tr '\n' ' ') stderr: $(sed -n l err | tr '\n' ' ')" ++} ++ ++assert_yellow_term() { ++ local actual="$1" ++ local term="$2" ++ local label="$3" ++ perl -0ne 'BEGIN { $term = shift @ARGV; } while (/\e\[[0-9;]*33m(.*?)\e\[[0-9;]*m/sg) { exit 0 if $1 =~ /(^|[^[:alnum:]_])\Q$term\E($|[^[:alnum:]_])/; } exit 1' "$term" "$actual" \ ++ || fail "$label did not highlight '$term' in yellow; got: $(sed -n l "$actual" | tr '\n' ' ')" ++} ++ ++cd "$TMP" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find rpoplpush; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++assert_line_count out 2 "F1 stdout" ++assert_line_re out '^ \(redis\) \(12\) .*RPOPLPUSH.*then acknowledge jobs$' "F1 row 12" ++assert_line_re out '^ \(redis\) \(24\) .*RPOPLPUSH.*$' "F1 row 24" ++[ ! -s err ] || fail "F1 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_dnote "$VALID_DB" f rpoplpush; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++assert_line_count out 2 "F2 stdout" ++assert_line_re out '^ \(redis\) \(12\) .*RPOPLPUSH.*then acknowledge jobs$' "F2 row 12" ++assert_line_re out '^ \(redis\) \(24\) .*RPOPLPUSH.*$' "F2 row 24" ++[ ! -s err ] || fail "F2 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find "building a heap"; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++ ++assert_line_count out 1 "F3 stdout" ++assert_line_re out '^ \(algorithm\) \(21\) .*building.*a.*heap.*$' "F3 quoted phrase match" ++[ ! -s err ] || fail "F3 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++command -v script >/dev/null 2>&1 || fail "script is required for the tty highlight fixture" ++PTY_OUT="$TMP/pty.out" ++script -qfec "env -u NO_COLOR HOME=$TMP/home XDG_CONFIG_HOME=$TMP/config XDG_DATA_HOME=$TMP/data XDG_CACHE_HOME=$TMP/cache TERM=xterm-256color '$BIN' --dbPath '$VALID_DB' find 'building a heap'" "$PTY_OUT" >/dev/null ++ec=$? ++awk '/^ / { sub(/\r$/, ""); print; exit }' "$PTY_OUT" >out ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++ ++assert_line_count out 1 "F4 tty stdout" ++assert_file_contains out "(algorithm)" "F4 book label" ++assert_file_contains out "(21)" "F4 row id" ++assert_yellow_term out "building" "F4" ++assert_yellow_term out "a" "F4" ++assert_yellow_term out "heap" "F4" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find "merge sort" --book algorithm; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++ ++assert_line_count out 1 "F5 stdout" ++assert_line_re out '^ \(algorithm\) \(22\) .*merge.*sort.*$' "F5 algorithm match" ++[ ! -s err ] || fail "F5 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find "merge sort" -b algorithm; ec=$? ++[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0" ++ ++assert_line_count out 1 "F6 stdout" ++assert_line_re out '^ \(algorithm\) \(22\) .*merge.*sort.*$' "F6 algorithm match" ++[ ! -s err ] || fail "F6 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find zzznomatch; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 exit $ec; want 0" ++[ ! -s out ] || fail "F7 stdout should be empty: $(cat out)" ++[ ! -s err ] || fail "F7 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find "merge sort" --book redis; ec=$? ++[ "$ec" -eq 0 ] || fail "F8 exit $ec; want 0" ++[ ! -s out ] || fail "F8 stdout should be empty: $(cat out)" ++[ ! -s err ] || fail "F8 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find; ec=$? ++[ "$ec" -eq 1 ] || fail "F9 exit $ec; want 1" ++ ++assert_output_contains "Incorrect number of argument" "F9 argument error" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find one two; ec=$? ++[ "$ec" -eq 1 ] || fail "F10 exit $ec; want 1" ++ ++assert_output_contains "Incorrect number of argument" "F10 argument error" ++ ++ ++ ++ ++run_dnote "$BROKEN_DB" find rpoplpush; ec=$? ++[ "$ec" -ne 0 ] || fail "F11 exit $ec; want non-zero" ++ ++assert_output_contains "querying notes" "F11 query operation error" ++ ++ ++ ++ ++run_dnote "$VALID_DB" find --help; ec=$? ++[ "$ec" -eq 0 ] || fail "F12 exit $ec; want 0" ++ ++grep -Eiq 'find(ing)? notes.*keywords' out || fail "F12 missing description" ++grep -Eq '(^|[[:space:]])find($|[[:space:]])' out || fail "F12 missing command name" ++grep -Eiq 'alias(es)?' out || fail "F12 missing alias section" ++grep -Eq '(^|[ ,[:space:]])f($|[,[:space:]])' out || fail "F12 missing alias f" ++grep -Eq 'dnote[[:space:]]+find[[:space:]]+[^" -][^[:space:]]*' out || fail "F12 missing single-keyword example" ++grep -Eq 'dnote[[:space:]]+find[[:space:]]+"[^"]+[[:space:]][^"]+"' out || fail "F12 missing quoted phrase example" ++grep -Eq 'dnote[[:space:]]+find[[:space:]].*-b[[:space:]]+[^[:space:]]+' out || fail "F12 missing book-constrained example" ++grep -Fq -- "--book" out || fail "F12 missing --book flag" ++grep -Fq -- "-b" out || fail "F12 missing -b flag" ++grep -Eiq 'book (name|within|to search|search)' out || fail "F12 missing book flag meaning" ++[ ! -s err ] || fail "F12 unexpected stderr: $(cat err)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOMODCACHE=/go/pkg/mod ++export GOCACHE=/go/build-cache ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000820/tests/test.sh b/tasks/format-code-task-000820/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1971a9bc52d5c99168daed182a477f7880f6097f --- /dev/null +++ b/tasks/format-code-task-000820/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/broken_query_db.sql +usercase-test-coderl/fixtures/valid_search_db.sql +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000820/tests/test_command.sh b/tasks/format-code-task-000820/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000820/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000828/environment/Dockerfile b/tasks/format-code-task-000828/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f6d5a44c4fe22c4cd64ff2d5ab016711b30882d8 --- /dev/null +++ b/tasks/format-code-task-000828/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2cd7e26174c53a9995ce547e148927b126354af5c677967cf2312dfcdc7a84db diff --git a/tasks/format-code-task-000828/environment/setup/files/blocklist b/tasks/format-code-task-000828/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000828/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000828/environment/setup/setup.sh b/tasks/format-code-task-000828/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000828/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000828/tests/test.patch b/tasks/format-code-task-000828/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..65e424c660b652537ba40de4578228fbc9f9c128 --- /dev/null +++ b/tasks/format-code-task-000828/tests/test.patch @@ -0,0 +1,248 @@ +diff --git a/usercase-test-coderl/aspect_helpers.test.ts b/usercase-test-coderl/aspect_helpers.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/aspect_helpers.test.ts +@@ -0,0 +1,214 @@ ++import { execFileSync } from 'node:child_process' ++import { mkdtempSync, readdirSync, rmSync } from 'node:fs' ++import { tmpdir } from 'node:os' ++import { join } from 'node:path' ++ ++import { afterEach, expect, test, vi } from 'vitest' ++ ++vi.mock('node:net', () => ({ ++ connect: () => { ++ throw new Error('unexpected network access') ++ }, ++ createConnection: () => { ++ throw new Error('unexpected network access') ++ }, ++ Socket: class { ++ constructor() { ++ throw new Error('unexpected network access') ++ } ++ }, ++})) ++ ++vi.mock('node:http', () => ({ ++ request: () => { ++ throw new Error('unexpected network access') ++ }, ++ get: () => { ++ throw new Error('unexpected network access') ++ }, ++})) ++ ++vi.mock('node:https', () => ({ ++ request: () => { ++ throw new Error('unexpected network access') ++ }, ++ get: () => { ++ throw new Error('unexpected network access') ++ }, ++})) ++ ++import { centerCrop, makeAspectCrop } from '../src/index' ++ ++ ++ ++ ++afterEach(() => { ++ vi.unstubAllGlobals() ++ vi.restoreAllMocks() ++}) ++ ++test('makeAspectCrop derives percent height from percent width', () => { ++ ++ ++ const actual = makeAspectCrop({ unit: '%', width: 50 }, 16 / 9, 400, 300) ++ ++ expect(actual).toEqual({ unit: '%', x: 0, y: 0, width: 50, height: 37.5 }) ++}) ++ ++test('makeAspectCrop derives percent width from percent height and preserves coordinates', () => { ++ ++ ++ const actual = makeAspectCrop({ unit: '%', x: 10, y: 5, height: 40 }, 4 / 3, 800, 600) ++ ++ expect(actual).toEqual({ unit: '%', x: 10, y: 5, width: 40, height: 40 }) ++}) ++ ++test('makeAspectCrop derives pixel height from pixel width', () => { ++ ++ ++ const actual = makeAspectCrop({ unit: 'px', x: 20, y: 30, width: 180 }, 3 / 2, 500, 400) ++ ++ expect(actual).toEqual({ x: 20, y: 30, width: 180, height: 120, unit: 'px' }) ++}) ++ ++test('makeAspectCrop derives pixel width from pixel height', () => { ++ ++ ++ const actual = makeAspectCrop({ unit: 'px', x: 25, y: 10, height: 90 }, 2, 500, 300) ++ ++ expect(actual).toEqual({ x: 25, y: 10, width: 180, height: 90, unit: 'px' }) ++}) ++ ++test('makeAspectCrop shrinks pixel crop width when it overflows right edge', () => { ++ ++ ++ const actual = makeAspectCrop({ unit: 'px', x: 300, y: 0, width: 200 }, 1, 400, 300) ++ ++ expect(actual).toEqual({ x: 300, y: 0, width: 100, height: 100, unit: 'px' }) ++}) ++ ++test('makeAspectCrop shrinks percent crop height when it overflows bottom edge', () => { ++ ++ ++ const actual = makeAspectCrop({ unit: '%', x: 0, y: 70, width: 80 }, 1, 400, 300) ++ ++ expect(actual).toEqual({ unit: '%', x: 0, y: 70, width: 22.5, height: 30 }) ++}) ++ ++test('makeAspectCrop shrinks percent crop width when it overflows right edge', () => { ++ ++ ++ const actual = makeAspectCrop({ unit: '%', x: 75, y: 0, height: 60 }, 1, 400, 300) ++ ++ expect(actual).toEqual({ unit: '%', x: 75, y: 0, width: 25, height: 33.33333333333333 }) ++}) ++ ++test('centerCrop centers a pixel crop and preserves pixel unit', () => { ++ ++ ++ const actual = centerCrop({ unit: 'px', width: 100, height: 50 }, 400, 300) ++ ++ expect(actual).toEqual({ x: 150, y: 125, width: 100, height: 50, unit: 'px' }) ++}) ++ ++test('centerCrop centers a percent crop and preserves percent unit', () => { ++ ++ ++ const actual = centerCrop({ unit: '%', width: 50, height: 25 }, 400, 200) ++ ++ expect(actual).toEqual({ unit: '%', x: 25, y: 37.5, width: 50, height: 25 }) ++}) ++ ++test('makeAspectCrop defaults omitted pixel coordinates to zero', () => { ++ ++ expect(makeAspectCrop({ unit: 'px', width: 75 }, 3, 500, 500)).toEqual({ ++ unit: 'px', ++ x: 0, ++ y: 0, ++ width: 75, ++ height: 25, ++ }) ++}) ++ ++test('helpers are referentially transparent for repeated calls', () => { ++ const aspectInput = { unit: '%', x: 10, y: 5, height: 40 } as const ++ const centerInput = { unit: 'px', width: 120, height: 80 } as const ++ ++ expect(makeAspectCrop(aspectInput, 4 / 3, 800, 600)).toEqual(makeAspectCrop(aspectInput, 4 / 3, 800, 600)) ++ expect(centerCrop(centerInput, 500, 300)).toEqual(centerCrop(centerInput, 500, 300)) ++}) ++ ++test('helpers do not mutate caller-owned crop objects', () => { ++ const aspectInput = { unit: 'px', x: 300, y: 0, width: 200 } as const ++ const centerInput = { unit: '%', width: 20, height: 60 } as const ++ const aspectBefore = structuredClone(aspectInput) ++ const centerBefore = structuredClone(centerInput) ++ ++ makeAspectCrop(aspectInput, 1, 400, 300) ++ centerCrop(centerInput, 1000, 500) ++ ++ expect(aspectInput).toEqual(aspectBefore) ++ expect(centerInput).toEqual(centerBefore) ++}) ++ ++test('helpers do not depend on process-global state between calls', () => { ++ const inProcess = { ++ aspect: makeAspectCrop({ unit: '%', x: 10, y: 5, height: 40 }, 4 / 3, 800, 600), ++ centered: centerCrop({ unit: 'px', width: 120, height: 80 }, 500, 300), ++ } ++ makeAspectCrop({ unit: 'px', x: 20, y: 30, width: 180 }, 3 / 2, 500, 400) ++ centerCrop({ unit: '%', width: 50, height: 25 }, 400, 200) ++ ++ const script = ` ++ import { makeAspectCrop, centerCrop } from 'file:///workspace/repo/dist/index.js'; ++ const result = { ++ aspect: makeAspectCrop({ unit: '%', x: 10, y: 5, height: 40 }, 4 / 3, 800, 600), ++ centered: centerCrop({ unit: 'px', width: 120, height: 80 }, 500, 300), ++ }; ++ process.stdout.write(JSON.stringify(result)); ++ ` ++ const freshProcess = JSON.parse(execFileSync(process.execPath, ['--input-type=module', '-e', script], { encoding: 'utf8' })) ++ ++ expect(inProcess).toEqual({ ++ aspect: { unit: '%', x: 10, y: 5, width: 40, height: 40 }, ++ centered: { x: 190, y: 110, width: 120, height: 80, unit: 'px' }, ++ }) ++ expect(freshProcess).toEqual(inProcess) ++}) ++ ++test('helpers do not perform filesystem, network, or other undeclared side effects', () => { ++ const originalCwd = process.cwd() ++ const isolatedCwd = mkdtempSync(join(tmpdir(), 'react-image-crop-pure-')) ++ const throwingNetwork = () => { ++ throw new Error('unexpected network access') ++ } ++ ++ vi.stubGlobal('fetch', throwingNetwork) ++ vi.stubGlobal('XMLHttpRequest', throwingNetwork) ++ vi.stubGlobal('WebSocket', throwingNetwork) ++ ++ try { ++ process.chdir(isolatedCwd) ++ const before = readdirSync(isolatedCwd) ++ ++ expect(makeAspectCrop({ unit: '%', width: 50 }, 16 / 9, 400, 300)).toEqual({ ++ unit: '%', ++ x: 0, ++ y: 0, ++ width: 50, ++ height: 37.5, ++ }) ++ expect(centerCrop({ unit: 'px', width: 100, height: 50 }, 400, 300)).toEqual({ ++ x: 150, ++ y: 125, ++ width: 100, ++ height: 50, ++ unit: 'px', ++ }) ++ ++ expect(readdirSync(isolatedCwd)).toEqual(before) ++ } finally { ++ process.chdir(originalCwd) ++ rmSync(isolatedCwd, { recursive: true, force: true }) ++ } ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,24 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_update_notifier=false ++export NO_UPDATE_NOTIFIER=1 ++ ++test -x /workspace/repo/node_modules/.bin/vite ++test -x /workspace/repo/node_modules/.bin/vitest ++ ++/workspace/repo/node_modules/.bin/vite build >/dev/null ++exec /workspace/repo/node_modules/.bin/vitest run /workspace/repo/usercase-test-coderl/aspect_helpers.test.ts --environment node diff --git a/tasks/format-code-task-000828/tests/test.sh b/tasks/format-code-task-000828/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dbd571fdbf81e03f498b4e91e0690f79f51a5e2c --- /dev/null +++ b/tasks/format-code-task-000828/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/aspect_helpers.test.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000828/tests/test_command.sh b/tasks/format-code-task-000828/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000828/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000829/environment/Dockerfile b/tasks/format-code-task-000829/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..68d10d0a11e775b110d8a88f687af5e375b90eb6 --- /dev/null +++ b/tasks/format-code-task-000829/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e09257bdd9da1a83fa6d94a5f50e9493969579e1ecf67e3a445e6e76ac1dded6 diff --git a/tasks/format-code-task-000829/environment/setup/files/blocklist b/tasks/format-code-task-000829/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000829/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000829/environment/setup/setup.sh b/tasks/format-code-task-000829/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000829/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000829/tests/test.patch b/tasks/format-code-task-000829/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a731035dd1a07da581205a69033f2e2ab2b0130f --- /dev/null +++ b/tasks/format-code-task-000829/tests/test.patch @@ -0,0 +1,846 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,824 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PIP_NO_INDEX=1 ++ ++fail() { ++ echo "FAIL: $*" >&2 ++ exit 1 ++} ++ ++cmp_file() { ++ local expected=$1 ++ local actual=$2 ++ local label=$3 ++ ++ case "$label" in ++ *stdout) ++ ++ case "$label" in ++ F3*) ;; ++ F5c*|F6a*) assert_progress "$actual" "$label" ;; ++ F4*) assert_tree_output "$actual" "$label" REQ TST LLT ;; ++ *) assert_progress "$actual" "$label"; assert_tree_output "$actual" "$label" REQ TST ;; ++ esac ++ ;; ++ *stderr) ++ ++ case "$label" in ++ F1*|F2*|F4b*|F4c*|F5b*|F5d*|F6b*|F7b*) assert_no_severity "$actual" "$label" ;; ++ F3a*) assert_category "$actual" "$label" "skipped[[:space:]]+level|outline"; assert_no_severity "$actual" "$label" ;; ++ F3b*) assert_severity_category "$actual" "$label" "WARNING" "skipped[[:space:]]+level|outline" ;; ++ F3c*) assert_no_category "$actual" "$label" "skipped[[:space:]]+level|outline"; assert_no_severity "$actual" "$label" ;; ++ F3d*) assert_no_severity "$actual" "$label" ;; ++ F4a*) assert_severity_category "$actual" "$label" "WARNING" "link|child|document"; assert_category "$actual" "$label" "TST|LLT" ;; ++ F5a*) assert_severity_category "$actual" "$label" "WARNING" "review|unreviewed"; assert_category "$actual" "$label" "TST001" ;; ++ F5c*) assert_severity_category "$actual" "$label" "ERROR" "review|unreviewed"; assert_category "$actual" "$label" "TST001" ;; ++ F6a*) assert_severity_category "$actual" "$label" "ERROR" "ref|reference"; assert_category "$actual" "$label" "missing-token" ;; ++ F7a*) assert_severity_category "$actual" "$label" "WARNING" "suspect"; assert_category "$actual" "$label" "REQ001" ;; ++ *) fail "unclassified stderr assertion $label" ;; ++ esac ++ ;; ++ F2a\ reformat) ++ ++ grep -Eq '^- REQ001: [^[:space:]]+' "$actual" || fail "$label missing stamped link" ++ grep -Eq '^- REQ001: null$' "$actual" && fail "$label kept null link stamp" ++ ;; ++ F2b\ no-reformat) ++ ++ grep -Eq '^- REQ001: null$' "$actual" || fail "$label did not preserve null link stamp" ++ ;; ++ F3d\ reorder\ file) ++ ++ grep -Eq '^level: 1\.1$' "$actual" || fail "$label did not update REQ002 level to 1.1" ++ grep -Eq '^ Second\.$' "$actual" || fail "$label changed the wrong item" ++ ;; ++ *) ++ cmp -s "$expected" "$actual" || { ++ echo "FAIL: $label" >&2 ++ diff -u "$expected" "$actual" >&2 || true ++ exit 1 ++ } ++ ;; ++ esac ++} ++ ++assert_progress() { ++ local actual=$1 ++ local label=$2 ++ grep -Eiq 'validating[[:space:]]+items' "$actual" || fail "$label missing validation progress" ++} ++ ++assert_tree_output() { ++ local actual=$1 ++ local label=$2 ++ shift 2 ++ [ -s "$actual" ] || fail "$label missing drawn tree output" ++ for prefix in "$@"; do ++ grep -Eq "(^|[^[:alnum:]_])${prefix}([^[:alnum:]_]|$)" "$actual" || fail "$label missing tree prefix $prefix" ++ done ++} ++ ++assert_no_severity() { ++ local actual=$1 ++ local label=$2 ++ ! grep -Eq '^(WARNING|ERROR):' "$actual" || fail "$label unexpectedly reported warning/error" ++} ++ ++assert_category() { ++ local actual=$1 ++ local label=$2 ++ local pattern=$3 ++ grep -Eiq "$pattern" "$actual" || fail "$label missing category pattern: $pattern" ++} ++ ++assert_no_category() { ++ local actual=$1 ++ local label=$2 ++ local pattern=$3 ++ ! grep -Eiq "$pattern" "$actual" || fail "$label unexpectedly contained category pattern: $pattern" ++} ++ ++assert_severity_category() { ++ local actual=$1 ++ local label=$2 ++ local severity=$3 ++ local pattern=$4 ++ grep -Eq "^${severity}:" "$actual" || fail "$label missing $severity severity" ++ assert_category "$actual" "$label" "$pattern" ++} ++ ++make_pair_tree() { ++ local dir=$1 ++ local root_text=$2 ++ local child_text=$3 ++ ++ rm -rf "$dir" ++ mkdir -p "$dir/reqs/tests" ++ : > "$dir/.mockvcs" ++ ++ cat >"$dir/reqs/.doorstop.yml" <<'EOF' ++settings: ++ digits: 3 ++ itemformat: yaml ++ prefix: REQ ++ sep: '' ++EOF ++ ++ cat >"$dir/reqs/REQ001.yml" <"$dir/reqs/tests/.doorstop.yml" <<'EOF' ++settings: ++ digits: 3 ++ itemformat: yaml ++ parent: REQ ++ prefix: TST ++ sep: '' ++EOF ++ ++ cat >"$dir/reqs/tests/TST001.yml" < "$dir/.mockvcs" ++ ++ cat >"$dir/reqs/.doorstop.yml" <<'EOF' ++settings: ++ digits: 3 ++ itemformat: yaml ++ prefix: REQ ++ sep: '' ++EOF ++ ++ cat >"$dir/reqs/REQ001.yml" <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.0 ++links: [] ++normative: true ++ref: '' ++reviewed: null ++text: | ++ First. ++EOF ++ ++ cat >"$dir/reqs/REQ002.yml" <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.2 ++links: [] ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Second. ++EOF ++} ++ ++make_strict_child_tree() { ++ local dir=$1 ++ ++ rm -rf "$dir" ++ mkdir -p "$dir/reqs/tests" "$dir/reqs/llt" ++ : > "$dir/.mockvcs" ++ ++ cat >"$dir/reqs/.doorstop.yml" <<'EOF' ++settings: ++ digits: 3 ++ itemformat: yaml ++ prefix: REQ ++ sep: '' ++EOF ++ ++ cat >"$dir/reqs/REQ001.yml" <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.0 ++links: [] ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Root one. ++EOF ++ ++ cat >"$dir/reqs/REQ002.yml" <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.1 ++links: [] ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Root two. ++EOF ++ ++ cat >"$dir/reqs/tests/.doorstop.yml" <<'EOF' ++settings: ++ digits: 3 ++ itemformat: yaml ++ parent: REQ ++ prefix: TST ++ sep: '' ++EOF ++ ++ cat >"$dir/reqs/tests/TST001.yml" <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.0 ++links: ++- REQ001: null ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Test one. ++EOF ++ ++ cat >"$dir/reqs/llt/.doorstop.yml" <<'EOF' ++settings: ++ digits: 3 ++ itemformat: yaml ++ parent: REQ ++ prefix: LLT ++ sep: '' ++EOF ++ ++ cat >"$dir/reqs/llt/LLT001.yml" <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.0 ++links: ++- REQ002: null ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Low one. ++EOF ++} ++ ++make_ref_tree() { ++ local dir=$1 ++ ++ rm -rf "$dir" ++ mkdir -p "$dir/reqs/tests" ++ : > "$dir/.mockvcs" ++ ++ cat >"$dir/reqs/.doorstop.yml" <<'EOF' ++settings: ++ digits: 3 ++ itemformat: yaml ++ prefix: REQ ++ sep: '' ++EOF ++ ++ cat >"$dir/reqs/REQ001.yml" <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.0 ++links: [] ++normative: true ++ref: missing-token ++reviewed: null ++text: | ++ Root item. ++EOF ++ ++ cat >"$dir/reqs/tests/.doorstop.yml" <<'EOF' ++settings: ++ digits: 3 ++ itemformat: yaml ++ parent: REQ ++ prefix: TST ++ sep: '' ++EOF ++ ++ cat >"$dir/reqs/tests/TST001.yml" <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.0 ++links: ++- REQ001: null ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Test item. ++EOF ++} ++ ++make_review_seed_tree() { ++ local dir=$1 ++ ++ make_pair_tree "$dir" "Root item." "Test item." ++} ++ ++make_suspect_seed_tree() { ++ local dir=$1 ++ ++ make_pair_tree "$dir" "Root item." "Test item." ++} ++ ++ROOT=/tmp/doorstop-q2-fixture ++rm -rf "$ROOT" ++mkdir -p "$ROOT" ++trap 'rm -rf "$ROOT"' EXIT ++ ++ ++python -m pip install --no-build-isolation -e /workspace/repo >/dev/null || fail "build" ++BIN=$(command -v doorstop) ++[ -x "$BIN" ] || fail "doorstop binary not found" ++ ++ ++ ++ ++make_pair_tree "$ROOT/clean" "Root item." "Test item." ++cd "$ROOT/clean" || fail "cd clean" ++"$BIN" >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++: > expected.err ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++cmp_file expected.out out "F1 stdout" ++cmp_file expected.err err "F1 stderr" ++ ++ ++ ++ ++make_pair_tree "$ROOT/reformat" "Root item." "Test item." ++cd "$ROOT/reformat" || fail "cd reformat" ++"$BIN" --no-review-check >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++cat >expected.err <<'EOF' ++EOF ++cat >expected.tst <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.0 ++links: ++- REQ001: 90qM0ZaWOrzNMnZMnQslOzaaId0nnlmaV0qRDaX-Bb8= ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Test item. ++EOF ++[ "$ec" -eq 0 ] || fail "F2a exit $ec; want 0" ++cmp_file expected.out out "F2a stdout" ++cmp_file expected.err err "F2a stderr" ++cmp_file expected.tst reqs/tests/TST001.yml "F2a reformat" ++ ++make_pair_tree "$ROOT/no_reformat" "Root item." "Test item." ++cd "$ROOT/no_reformat" || fail "cd no_reformat" ++"$BIN" --no-review-check --no-reformat >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++cat >expected.err <<'EOF' ++EOF ++cat >expected.tst <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.0 ++links: ++- REQ001: null ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Test item. ++EOF ++[ "$ec" -eq 0 ] || fail "F2b exit $ec; want 0" ++cmp_file expected.out out "F2b stdout" ++cmp_file expected.err err "F2b stderr" ++cmp_file expected.tst reqs/tests/TST001.yml "F2b no-reformat" ++ ++ ++ ++ ++make_level_tree "$ROOT/levels" ++cd "$ROOT/levels" || fail "cd levels" ++"$BIN" -v --no-review-check >out 2>err; ec=$? ++cat >expected.err <<'EOF' ++looking for documents in /tmp/doorstop-q2-fixture/levels... ++found document: REQ ++building tree... ++root of the tree: REQ ++built tree: REQ ++loading the tree... ++loading document REQ's items... ++checking document REQ... ++REQ: skipped level: 1.0 (REQ001), 1.2 (REQ002) ++checking item REQ001... ++checking item REQ002... ++EOF ++: > expected.out ++[ "$ec" -eq 0 ] || fail "F3a exit $ec; want 0" ++cmp_file expected.out out "F3a stdout" ++cmp_file expected.err err "F3a stderr" ++ ++"$BIN" -v --warn-all --no-review-check >out 2>err; ec=$? ++cat >expected.err <<'EOF' ++looking for documents in /tmp/doorstop-q2-fixture/levels... ++found document: REQ ++building tree... ++root of the tree: REQ ++built tree: REQ ++loading the tree... ++loading document REQ's items... ++checking document REQ... ++WARNING: REQ: skipped level: 1.0 (REQ001), 1.2 (REQ002) ++checking item REQ001... ++checking item REQ002... ++EOF ++[ "$ec" -eq 0 ] || fail "F3b exit $ec; want 0" ++cmp_file expected.out out "F3b stdout" ++cmp_file expected.err err "F3b stderr" ++ ++"$BIN" -v --no-level-check --no-review-check >out 2>err; ec=$? ++cat >expected.err <<'EOF' ++looking for documents in /tmp/doorstop-q2-fixture/levels... ++found document: REQ ++building tree... ++root of the tree: REQ ++built tree: REQ ++loading the tree... ++loading document REQ's items... ++checking document REQ... ++checking item REQ001... ++checking item REQ002... ++EOF ++[ "$ec" -eq 0 ] || fail "F3c exit $ec; want 0" ++cmp_file expected.out out "F3c stdout" ++cmp_file expected.err err "F3c stderr" ++ ++make_level_tree "$ROOT/reorder" ++cd "$ROOT/reorder" || fail "cd reorder" ++"$BIN" -v --reorder --no-review-check >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++EOF ++cat >expected.err <<'EOF' ++looking for documents in /tmp/doorstop-q2-fixture/reorder... ++found document: REQ ++building tree... ++root of the tree: REQ ++built tree: REQ ++loading the tree... ++loading document REQ's items... ++checking document REQ... ++reordering REQ automatically... ++REQ001: 1.0 ++REQ002: 1.2 to 1.1 ++checking item REQ001... ++checking item REQ002... ++EOF ++[ "$ec" -eq 0 ] || fail "F3d exit $ec; want 0" ++cmp_file expected.out out "F3d stdout" ++cmp_file expected.err err "F3d stderr" ++cat >expected.reqd <<'EOF' ++active: true ++derived: false ++header: '' ++level: 1.1 ++links: [] ++normative: true ++ref: '' ++reviewed: null ++text: | ++ Second. ++EOF ++cmp_file expected.reqd reqs/REQ002.yml "F3d reorder file" ++ ++ ++ ++ ++make_strict_child_tree "$ROOT/child" ++cd "$ROOT/child" || fail "cd child" ++"$BIN" -v --strict-child-check --no-review-check >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++ ++REQ ++│ ++├── TST ++│ ++└── LLT ++ ++EOF ++cat >expected.err <<'EOF' ++looking for documents in /tmp/doorstop-q2-fixture/child... ++found document: REQ ++found document: TST ++found document: LLT ++building tree... ++root of the tree: REQ ++added to tree: TST ++added to tree: LLT ++built tree: REQ <- [ TST, LLT ] ++loading the tree... ++loading document REQ's items... ++loading document TST's items... ++loading document LLT's items... ++checking document REQ... ++checking item REQ001... ++WARNING: REQ: REQ001: no links from document: LLT ++checking item REQ002... ++WARNING: REQ: REQ002: no links from document: TST ++checking document TST... ++checking item TST001... ++checking document LLT... ++checking item LLT001... ++EOF ++[ "$ec" -eq 0 ] || fail "F4a exit $ec; want 0" ++cmp_file expected.out out "F4a stdout" ++cmp_file expected.err err "F4a stderr" ++ ++ ++"$BIN" -v --no-child-check --strict-child-check --no-review-check >out 2>err; ec=$? ++cat >expected.err <<'EOF' ++looking for documents in /tmp/doorstop-q2-fixture/child... ++found document: REQ ++found document: TST ++found document: LLT ++building tree... ++root of the tree: REQ ++added to tree: TST ++added to tree: LLT ++built tree: REQ <- [ TST, LLT ] ++loading the tree... ++loading document REQ's items... ++loading document TST's items... ++loading document LLT's items... ++checking document REQ... ++checking item REQ001... ++checking item REQ002... ++checking document TST... ++checking item TST001... ++checking document LLT... ++checking item LLT001... ++EOF ++[ "$ec" -eq 0 ] || fail "F4b exit $ec; want 0" ++cmp_file expected.out out "F4b stdout" ++cmp_file expected.err err "F4b stderr" ++ ++"$BIN" -v --skip REQ --strict-child-check --no-review-check >out 2>err; ec=$? ++cat >expected.err <<'EOF' ++looking for documents in /tmp/doorstop-q2-fixture/child... ++found document: REQ ++found document: TST ++found document: LLT ++building tree... ++root of the tree: REQ ++added to tree: TST ++added to tree: LLT ++built tree: REQ <- [ TST, LLT ] ++loading the tree... ++loading document REQ's items... ++loading document TST's items... ++loading document LLT's items... ++skipping document REQ... ++checking document TST... ++checking item TST001... ++checking document LLT... ++checking item LLT001... ++EOF ++[ "$ec" -eq 0 ] || fail "F4c exit $ec; want 0" ++cmp_file expected.out out "F4c stdout" ++cmp_file expected.err err "F4c stderr" ++ ++ ++ ++ ++make_review_seed_tree "$ROOT/review_seed" ++cd "$ROOT/review_seed" || fail "cd review_seed" ++"$BIN" > /dev/null 2> /dev/null || fail "seed validation" ++cp -a "$ROOT/review_seed" "$ROOT/review_default" ++cp -a "$ROOT/review_seed" "$ROOT/review_no_review" ++cp -a "$ROOT/review_seed" "$ROOT/review_error_all" ++cp -a "$ROOT/review_seed" "$ROOT/review_skip" ++perl -0pi -e 's/Test item\./Test item changed./' "$ROOT/review_default/reqs/tests/TST001.yml" ++perl -0pi -e 's/Test item\./Test item changed./' "$ROOT/review_no_review/reqs/tests/TST001.yml" ++perl -0pi -e 's/Test item\./Test item changed./' "$ROOT/review_error_all/reqs/tests/TST001.yml" ++perl -0pi -e 's/Test item\./Test item changed./' "$ROOT/review_skip/reqs/tests/TST001.yml" ++ ++cd "$ROOT/review_default" || fail "cd review_default" ++"$BIN" >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++cat >expected.err <<'EOF' ++WARNING: TST: TST001: unreviewed changes ++EOF ++[ "$ec" -eq 0 ] || fail "F5a exit $ec; want 0" ++cmp_file expected.out out "F5a stdout" ++cmp_file expected.err err "F5a stderr" ++ ++cd "$ROOT/review_no_review" || fail "cd review_no_review" ++"$BIN" --no-review-check >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++cat >expected.err <<'EOF' ++EOF ++[ "$ec" -eq 0 ] || fail "F5b exit $ec; want 0" ++cmp_file expected.out out "F5b stdout" ++cmp_file expected.err err "F5b stderr" ++ ++cd "$ROOT/review_error_all" || fail "cd review_error_all" ++"$BIN" --error-all >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++EOF ++cat >expected.err <<'EOF' ++ERROR: TST: TST001: unreviewed changes ++EOF ++[ "$ec" -eq 1 ] || fail "F5c exit $ec; want 1" ++cmp_file expected.out out "F5c stdout" ++cmp_file expected.err err "F5c stderr" ++ ++cd "$ROOT/review_skip" || fail "cd review_skip" ++"$BIN" --skip TST >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++cat >expected.err <<'EOF' ++EOF ++[ "$ec" -eq 0 ] || fail "F5d exit $ec; want 0" ++cmp_file expected.out out "F5d stdout" ++cmp_file expected.err err "F5d stderr" ++ ++ ++ ++ ++make_ref_tree "$ROOT/ref" ++cd "$ROOT/ref" || fail "cd ref" ++"$BIN" --no-review-check >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++EOF ++cat >expected.err <<'EOF' ++ERROR: REQ: REQ001: external reference not found: missing-token ++EOF ++[ "$ec" -eq 1 ] || fail "F6a exit $ec; want 1" ++cmp_file expected.out out "F6a stdout" ++cmp_file expected.err err "F6a stderr" ++ ++"$BIN" --no-review-check --no-ref-check >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++cat >expected.err <<'EOF' ++EOF ++[ "$ec" -eq 0 ] || fail "F6b exit $ec; want 0" ++cmp_file expected.out out "F6b stdout" ++cmp_file expected.err err "F6b stderr" ++ ++ ++ ++ ++make_suspect_seed_tree "$ROOT/suspect_seed" ++cd "$ROOT/suspect_seed" || fail "cd suspect_seed" ++"$BIN" --no-review-check >/dev/null 2>/dev/null || fail "seed suspect validation" ++cp -a "$ROOT/suspect_seed" "$ROOT/suspect_default" ++cp -a "$ROOT/suspect_seed" "$ROOT/suspect_no_suspect" ++perl -0pi -e 's/Root item\./Root item changed./' "$ROOT/suspect_default/reqs/REQ001.yml" ++perl -0pi -e 's/Root item\./Root item changed./' "$ROOT/suspect_no_suspect/reqs/REQ001.yml" ++ ++cd "$ROOT/suspect_default" || fail "cd suspect_default" ++"$BIN" --no-review-check >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++cat >expected.err <<'EOF' ++WARNING: TST: TST001: suspect link: REQ001 ++EOF ++[ "$ec" -eq 0 ] || fail "F7a exit $ec; want 0" ++cmp_file expected.out out "F7a stdout" ++cmp_file expected.err err "F7a stderr" ++ ++cd "$ROOT/suspect_no_suspect" || fail "cd suspect_no_suspect" ++"$BIN" --no-review-check --no-suspect-check >out 2>err; ec=$? ++cat >expected.out <<'EOF' ++building tree... ++loading documents... ++validating items... ++ ++REQ ++│ ++└── TST ++ ++EOF ++cat >expected.err <<'EOF' ++EOF ++cat >expected.err <<'EOF' ++EOF ++[ "$ec" -eq 0 ] || fail "F7b exit $ec; want 0" ++cmp_file expected.out out "F7b stdout" ++cmp_file expected.err err "F7b stderr" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000829/tests/test.sh b/tasks/format-code-task-000829/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000829/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000829/tests/test_command.sh b/tasks/format-code-task-000829/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000829/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000843/environment/Dockerfile b/tasks/format-code-task-000843/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..15be3783e629eaf5ef394013f37a2e8df3b853c3 --- /dev/null +++ b/tasks/format-code-task-000843/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dc10fc8df0eea849dac88c75712b8d902770dca58797149fb6f0e4540b145be8 diff --git a/tasks/format-code-task-000843/environment/setup/files/blocklist b/tasks/format-code-task-000843/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000843/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000843/environment/setup/setup.sh b/tasks/format-code-task-000843/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000843/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000843/tests/test.patch b/tasks/format-code-task-000843/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f44539a391c48eff9e3d63022b0e82f45b6aeaad --- /dev/null +++ b/tasks/format-code-task-000843/tests/test.patch @@ -0,0 +1,321 @@ +diff --git a/usercase-test-coderl/test_paired_dataset.py b/usercase-test-coderl/test_paired_dataset.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_paired_dataset.py +@@ -0,0 +1,292 @@ ++import json ++import os ++import zipfile ++from io import BytesIO ++ ++import numpy as np ++import pytest ++from PIL import Image ++ ++from training.dataset import ImageEdgeFolderDataset, ImageSegFolderDataset ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++IMG0 = np.array( ++ [ ++ [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120]], ++ [[11, 21, 31], [41, 51, 61], [71, 81, 91], [101, 111, 121]], ++ [[12, 22, 32], [42, 52, 62], [72, 82, 92], [102, 112, 122]], ++ [[13, 23, 33], [43, 53, 63], [73, 83, 93], [103, 113, 123]], ++ ], ++ dtype=np.uint8, ++) ++IMG1 = np.array( ++ [ ++ [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], ++ [[13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24]], ++ [[25, 26, 27], [28, 29, 30], [31, 32, 33], [34, 35, 36]], ++ [[37, 38, 39], [40, 41, 42], [43, 44, 45], [46, 47, 48]], ++ ], ++ dtype=np.uint8, ++) ++MASK0 = np.array( ++ [ ++ [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], ++ [[21, 22, 23], [24, 25, 26], [27, 28, 29], [30, 31, 32]], ++ [[41, 42, 43], [44, 45, 46], [47, 48, 49], [50, 51, 52]], ++ [[61, 62, 63], [64, 65, 66], [67, 68, 69], [70, 71, 72]], ++ ], ++ dtype=np.uint8, ++) ++MASK1 = np.array( ++ [ ++ [[9, 8, 7], [6, 5, 4], [3, 2, 1], [0, 1, 2]], ++ [[19, 18, 17], [16, 15, 14], [13, 12, 11], [10, 11, 12]], ++ [[29, 28, 27], [26, 25, 24], [23, 22, 21], [20, 21, 22]], ++ [[39, 38, 37], [36, 35, 34], [33, 32, 31], [30, 31, 32]], ++ ], ++ dtype=np.uint8, ++) ++EDGE0 = np.array([[0, 64], [128, 255]], dtype=np.uint8) ++EDGE1 = np.array([[255, 128], [64, 0]], dtype=np.uint8) ++ ++ ++def _png_bytes(array): ++ buf = BytesIO() ++ Image.fromarray(array).save(buf, format="PNG") ++ return buf.getvalue() ++ ++ ++def _write_zip(path, entries): ++ with zipfile.ZipFile(path, "w") as zf: ++ for name, data in entries.items(): ++ zf.writestr(name, data) ++ ++ ++@pytest.fixture() ++def dataset_zips(tmp_path): ++ labels = { ++ "labels": [ ++ ["000000.png", [1.25, -2.5, 3.75]], ++ ["000001.png", [4.5, 5.5, 6.5]], ++ ] ++ } ++ image_zip = tmp_path / "images.zip" ++ seg_zip = tmp_path / "seg_masks.zip" ++ edge_zip = tmp_path / "edge_masks.zip" ++ empty_zip = tmp_path / "empty.zip" ++ _write_zip( ++ image_zip, ++ { ++ "000000.png": _png_bytes(IMG0), ++ "000001.png": _png_bytes(IMG1), ++ "dataset.json": json.dumps(labels), ++ }, ++ ) ++ _write_zip(seg_zip, {"000000.png": _png_bytes(MASK0), "000001.png": _png_bytes(MASK1)}) ++ _write_zip(edge_zip, {"000000.png": _png_bytes(EDGE0), "000001.png": _png_bytes(EDGE1)}) ++ _write_zip(empty_zip, {"dataset.json": json.dumps({"labels": []})}) ++ return image_zip, seg_zip, edge_zip, empty_zip ++ ++ ++def _fd_count(): ++ return len(os.listdir("/proc/self/fd")) ++ ++ ++def _as_hwc(value, channels): ++ ++ array = np.asarray(value) ++ assert array.ndim == 3 ++ if array.shape[-1] == channels: ++ return array ++ if array.shape[0] == channels: ++ return array.transpose(1, 2, 0) ++ raise AssertionError(f"expected {channels} channels, got shape {array.shape}") ++ ++ ++def _as_hw_mask(value): ++ ++ array = np.asarray(value) ++ if array.ndim == 2: ++ return array ++ if array.ndim == 3 and array.shape[0] == 1: ++ return array[0] ++ if array.ndim == 3 and array.shape[-1] == 1: ++ return array[..., 0] ++ raise AssertionError(f"expected grayscale mask, got shape {array.shape}") ++ ++ ++def _assert_pose(value, expected): ++ ++ np.testing.assert_allclose(np.asarray(value), np.asarray(expected)) ++ ++ ++def _assert_rgb(value, expected): ++ np.testing.assert_array_equal(_as_hwc(value, 3), expected) ++ ++ ++def _assert_seg_mask(value, expected): ++ np.testing.assert_array_equal(_as_hwc(value, 3), expected) ++ ++ ++def _nearest_2x2_to_4x4(value): ++ return np.repeat(np.repeat(value, 2, axis=0), 2, axis=1) ++ ++ ++def _assert_edge_mask_contract(value, raw_edge): ++ ++ mask = _as_hw_mask(value) ++ assert mask.shape == (4, 4) ++ for row in (0, 2): ++ for col in (0, 2): ++ assert np.all(mask[row : row + 2, col : col + 2] == mask[row, col]) ++ ++ raw_resized = _nearest_2x2_to_4x4(raw_edge) ++ inverted_resized = _nearest_2x2_to_4x4(255 - raw_edge) ++ assert not np.array_equal(mask, raw_resized) ++ assert not np.array_equal(mask, inverted_resized) ++ assert mask.min() > inverted_resized.min() ++ assert mask.max() < inverted_resized.max() ++ assert abs(mask.mean() - inverted_resized.mean()) < abs(mask.mean() - raw_resized.mean()) ++ assert np.unique(mask).size > 1 ++ ++ ++def test_segmentation_zip_session_returns_image_mask_pose_and_idx(dataset_zips): ++ ++ ++ ++ image_zip, seg_zip, _edge_zip, _empty_zip = dataset_zips ++ ds = ImageSegFolderDataset(str(image_zip), str(seg_zip), resolution=4, use_labels=True) ++ try: ++ assert len(ds) == 2 ++ ++ ++ first = ds[0] ++ assert sorted(first.keys()) == ["idx", "image", "mask", "pose"] ++ assert first["idx"] == 0 ++ _assert_pose(first["pose"], [1.25, -2.5, 3.75]) ++ _assert_rgb(first["image"], IMG0) ++ _assert_seg_mask(first["mask"], MASK0) ++ ++ second = ds[1] ++ assert second["idx"] == 1 ++ _assert_pose(second["pose"], [4.5, 5.5, 6.5]) ++ _assert_seg_mask(second["mask"], MASK1) ++ finally: ++ ds.close() ++ ++ ++def test_xflip_mirrors_segmentation_image_and_mask_together(dataset_zips): ++ ++ ++ ++ image_zip, seg_zip, _edge_zip, _empty_zip = dataset_zips ++ ds = ImageSegFolderDataset(str(image_zip), str(seg_zip), resolution=4, use_labels=True, xflip=True) ++ try: ++ assert len(ds) == 4 ++ flipped = ds[2] ++ ++ assert flipped["idx"] == 2 ++ _assert_pose(flipped["pose"], [1.25, -2.5, 3.75]) ++ _assert_rgb(flipped["image"], IMG0[:, ::-1, :]) ++ _assert_seg_mask(flipped["mask"], MASK0[:, ::-1, :]) ++ finally: ++ ds.close() ++ ++ ++def test_edge_zip_session_inverts_blurs_and_resizes_mask(dataset_zips): ++ ++ ++ ++ image_zip, _seg_zip, edge_zip, _empty_zip = dataset_zips ++ ds = ImageEdgeFolderDataset(str(image_zip), str(edge_zip), resolution=4, use_labels=True) ++ try: ++ assert len(ds) == 2 ++ ++ first = ds[0] ++ assert first["idx"] == 0 ++ _assert_pose(first["pose"], [1.25, -2.5, 3.75]) ++ _assert_edge_mask_contract(first["mask"], EDGE0) ++ second = ds[1] ++ assert second["idx"] == 1 ++ _assert_pose(second["pose"], [4.5, 5.5, 6.5]) ++ _assert_edge_mask_contract(second["mask"], EDGE1) ++ finally: ++ ds.close() ++ ++ ++def test_invalid_inputs_raise_specific_oserror(dataset_zips, tmp_path): ++ ++ ++ ++ image_zip, seg_zip, _edge_zip, empty_zip = dataset_zips ++ ++ with pytest.raises(OSError): ++ ImageSegFolderDataset(str(tmp_path / "missing"), str(seg_zip)) ++ ++ with pytest.raises(OSError): ++ ImageSegFolderDataset(str(empty_zip), str(seg_zip)) ++ ++ with pytest.raises(OSError): ++ ImageSegFolderDataset(str(image_zip), str(seg_zip), resolution=8) ++ ++ ++def test_close_is_idempotent_for_zip_datasets(dataset_zips): ++ ++ ++ ++ image_zip, seg_zip, _edge_zip, _empty_zip = dataset_zips ++ ds = ImageSegFolderDataset(str(image_zip), str(seg_zip), resolution=4, use_labels=True) ++ assert ds[0]["idx"] == 0 ++ before_close = _fd_count() ++ ds.close() ++ after_first_close = _fd_count() ++ ds.close() ++ assert _fd_count() == after_first_close ++ assert after_first_close <= before_close ++ ++ ++def test_two_dataset_instances_keep_independent_index_and_flip_state(dataset_zips): ++ ++ ++ ++ image_zip, seg_zip, _edge_zip, _empty_zip = dataset_zips ++ a = ImageSegFolderDataset(str(image_zip), str(seg_zip), resolution=4, use_labels=True, xflip=True) ++ b = ImageSegFolderDataset(str(image_zip), str(seg_zip), resolution=4, use_labels=True, xflip=False) ++ try: ++ assert len(a) == 4 ++ assert len(b) == 2 ++ _assert_rgb(a[2]["image"], IMG0[:, ::-1, :]) ++ _assert_rgb(b[0]["image"], IMG0) ++ _assert_pose(a[3]["pose"], [4.5, 5.5, 6.5]) ++ _assert_pose(b[1]["pose"], [4.5, 5.5, 6.5]) ++ finally: ++ a.close() ++ b.close() ++ ++ ++def test_repeated_zip_dataset_use_and_close_keeps_fd_count_bounded(dataset_zips): ++ ++ ++ ++ image_zip, seg_zip, _edge_zip, _empty_zip = dataset_zips ++ before = _fd_count() ++ retained = [] ++ try: ++ for _ in range(120): ++ ds = ImageSegFolderDataset(str(image_zip), str(seg_zip), resolution=4, use_labels=True) ++ assert ds[0]["idx"] == 0 ++ ds.close() ++ retained.append(ds) ++ after = _fd_count() ++ assert after <= before + 8 ++ finally: ++ for ds in retained: ++ ds.close() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONPATH=/workspace/repo${PYTHONPATH:+:${PYTHONPATH}} ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PYTHONDONTWRITEBYTECODE=1 ++exec python -m pytest -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_paired_dataset.py -v diff --git a/tasks/format-code-task-000843/tests/test.sh b/tasks/format-code-task-000843/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7040a3348eab48e765566ac7fe6a9c35572afca3 --- /dev/null +++ b/tasks/format-code-task-000843/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_paired_dataset.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000843/tests/test_command.sh b/tasks/format-code-task-000843/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000843/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000844/environment/Dockerfile b/tasks/format-code-task-000844/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7c848fe998b4e48523a57c24055c2600b11f893e --- /dev/null +++ b/tasks/format-code-task-000844/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:db489bdf66e8e1ee369bf3cc9c2f768af294a66a2712b852cef852a2069b9182 diff --git a/tasks/format-code-task-000844/environment/setup/files/blocklist b/tasks/format-code-task-000844/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000844/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000844/environment/setup/setup.sh b/tasks/format-code-task-000844/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000844/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000844/tests/test.patch b/tasks/format-code-task-000844/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..28049392d0f860e7a3947aee13df9dfda2808c0b --- /dev/null +++ b/tasks/format-code-task-000844/tests/test.patch @@ -0,0 +1,265 @@ +diff --git a/usercase-test-coderl/test_sublattice_decomposer.py b/usercase-test-coderl/test_sublattice_decomposer.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_sublattice_decomposer.py +@@ -0,0 +1,234 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++import itertools ++ ++import dimod ++import pytest ++ ++from hybrid.core import State ++from hybrid.decomposers import SublatticeDecomposer ++ ++ ++def _query_bqm(): ++ return dimod.BinaryQuadraticModel( ++ {(0,): 0, (1,): 1, (2,): 2}, ++ {((0,), (1,)): 3, ((1,), (2,)): 4}, ++ 0, ++ dimod.BINARY, ++ ) ++ ++ ++def _query_state(*, geometric_offset=(1,), origin_embedding_index=0): ++ bqm = _query_bqm() ++ return State.from_sample( ++ {(0,): 1, (1,): 0, (2,): 0}, ++ bqm, ++ problem_dims=(3,), ++ geometric_offset=geometric_offset, ++ origin_embedding_index=origin_embedding_index, ++ origin_embeddings=[{(0,): [10], (1,): [11]}], ++ ) ++ ++ ++def _random_bqm(): ++ bqm = dimod.BinaryQuadraticModel({}, {}, 0, dimod.BINARY) ++ for i in range(3): ++ for j in range(4): ++ bqm.add_variable((i, j), i * 10 + j) ++ return bqm ++ ++ ++def _random_state(*, exclude_dims=None): ++ bqm = _random_bqm() ++ kwargs = { ++ "problem_dims": (3, 4), ++ "origin_embeddings": [ ++ {(0, 0): ["a00"], (1, 0): ["a10"]}, ++ {(0, 1): ["b01"], (1, 1): ["b11"]}, ++ {(0, 2): ["c02"], (1, 2): ["c12"]}, ++ ], ++ } ++ if exclude_dims is not None: ++ kwargs["exclude_dims"] = exclude_dims ++ return State.from_sample({v: 0 for v in bqm.variables}, bqm, **kwargs) ++ ++ ++def _linear_dict(bqm): ++ return {key: float(value) for key, value in sorted(bqm.linear.items())} ++ ++ ++def _quadratic_dict(bqm): ++ return {tuple(sorted(edge)): float(value) for edge, value in bqm.quadratic.items()} ++ ++ ++def _embedding_sequence(decomposer, state, count): ++ return [decomposer.next(state).embedding for _ in range(count)] ++ ++ ++def _canonical_embedding(embedding): ++ return tuple(sorted((key, tuple(value)) for key, value in embedding.items())) ++ ++ ++def _offset_embedding(origin_embedding, offset, problem_dims): ++ return { ++ tuple((coord + delta) % dim for coord, delta, dim in zip(key, offset, problem_dims)): value ++ for key, value in origin_embedding.items() ++ } ++ ++ ++def _valid_random_embeddings(state): ++ ranges = [] ++ excluded = set(getattr(state, "exclude_dims", None) or ()) ++ for dim_index, size in enumerate(state.problem_dims): ++ ranges.append([0] if dim_index in excluded else range(size)) ++ ++ return { ++ _canonical_embedding(_offset_embedding(origin_embedding, offset, state.problem_dims)) ++ for origin_embedding in state.origin_embeddings ++ for offset in itertools.product(*ranges) ++ } ++ ++ ++def test_explicit_offset_conditions_boundary_biases(): ++ ++ ++ ++ result = SublatticeDecomposer(seed=None).next(_query_state(geometric_offset=(1,))) ++ ++ assert result.embedding == {(1,): [10], (2,): [11]} ++ assert sorted(result.subproblem.variables) == [(1,), (2,)] ++ assert _quadratic_dict(result.subproblem) == {((1,), (2,)): 4.0} ++ assert result.subproblem.offset == 0.0 ++ assert _linear_dict(result.subproblem) == {(1,): 4.0, (2,): 2.0} ++ ++ ++def test_explicit_offset_wraps_modulo_problem_dims(): ++ ++ ++ ++ result = SublatticeDecomposer(seed=None).next(_query_state(geometric_offset=(2,))) ++ ++ assert result.embedding == {(2,): [10], (0,): [11]} ++ assert sorted(result.subproblem.variables) == [(0,), (2,)] ++ assert _quadratic_dict(result.subproblem) == {} ++ assert result.subproblem.offset == 0.0 ++ assert _linear_dict(result.subproblem) == {(0,): 0.0, (2,): 2.0} ++ ++ ++def test_seeded_random_offsets_and_embedding_choices_advance_across_calls(): ++ ++ ++ ++ state = _random_state() ++ decomposer = SublatticeDecomposer(seed=123) ++ sequence = _embedding_sequence(decomposer, state, 40) ++ ++ ++ assert all(_canonical_embedding(embedding) in _valid_random_embeddings(state) for embedding in sequence) ++ assert len({_canonical_embedding(embedding) for embedding in sequence}) > 1 ++ ++ ++def test_seeded_random_offset_sets_excluded_dimensions_to_zero(): ++ ++ ++ ++ state = _random_state(exclude_dims={1}) ++ decomposer = SublatticeDecomposer(seed=123) ++ sequence = _embedding_sequence(decomposer, state, 40) ++ ++ ++ assert all(_canonical_embedding(embedding) in _valid_random_embeddings(state) for embedding in sequence) ++ assert len({_canonical_embedding(embedding) for embedding in sequence}) > 1 ++ ++ ++def test_two_seeded_instances_have_independent_matching_random_sequences(): ++ ++ ++ ++ state = _random_state() ++ first = SublatticeDecomposer(seed=123) ++ second = SublatticeDecomposer(seed=123) ++ first_sequence = _embedding_sequence(first, state, 20) ++ second_sequence = _embedding_sequence(second, state, 20) ++ ++ ++ assert first_sequence == second_sequence ++ assert all(_canonical_embedding(embedding) in _valid_random_embeddings(state) for embedding in first_sequence) ++ assert len({_canonical_embedding(embedding) for embedding in first_sequence}) > 1 ++ ++ ++def test_invalid_excluded_dimension_raises_value_error(): ++ ++ ++ ++ ++ with pytest.raises(ValueError): ++ SublatticeDecomposer(seed=123).next(_random_state(exclude_dims={2})) ++ ++ ++def test_invalid_geometric_offset_length_raises_value_error(): ++ ++ ++ ++ state = _query_state(geometric_offset=(1,)) ++ state.problem_dims = (3, 4) ++ ++ ++ with pytest.raises(ValueError): ++ SublatticeDecomposer(seed=123).next(state) ++ ++ ++@pytest.mark.parametrize("bad_offset", [(-1,), (3,)]) ++def test_invalid_geometric_offset_range_raises_value_error(bad_offset): ++ ++ ++ ++ ++ with pytest.raises(ValueError): ++ SublatticeDecomposer(seed=123).next(_query_state(geometric_offset=bad_offset)) ++ ++ ++@pytest.mark.parametrize("bad_index", [-2, 2]) ++def test_invalid_origin_embedding_index_raises_value_error(bad_index): ++ ++ ++ ++ ++ with pytest.raises(ValueError): ++ SublatticeDecomposer(seed=123).next(_query_state(geometric_offset=(0,), origin_embedding_index=bad_index)) ++ ++ ++def test_next_accepts_runopts_on_constructed_runnable(): ++ ++ ++ ++ decomposer = SublatticeDecomposer(seed=123) ++ ++ result = decomposer.next(_query_state(geometric_offset=(1,)), ignored_runopt=True) ++ ++ ++ assert result.embedding == {(1,): [10], (2,): [11]} ++ assert sorted(result.subproblem.variables) == [(1,), (2,)] ++ ++ ++def test_construct_once_can_be_called_repeatedly(): ++ ++ ++ ++ decomposer = SublatticeDecomposer(seed=123) ++ expected_by_offset = { ++ (0,): {(0,): [10], (1,): [11]}, ++ (1,): {(1,): [10], (2,): [11]}, ++ (2,): {(2,): [10], (0,): [11]}, ++ } ++ ++ for offset, expected_embedding in expected_by_offset.items(): ++ result = decomposer.next(_query_state(geometric_offset=offset)) ++ ++ assert result.embedding == expected_embedding +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PYTHONNOUSERSITE=1 ++export PYTHONPATH=/workspace/repo ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++ ++exec /opt/coderl-venv/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_sublattice_decomposer.py -v diff --git a/tasks/format-code-task-000844/tests/test.sh b/tasks/format-code-task-000844/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..562071ace759f3eecafeeddc8bc0a8b1a88c2554 --- /dev/null +++ b/tasks/format-code-task-000844/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_sublattice_decomposer.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000844/tests/test_command.sh b/tasks/format-code-task-000844/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000844/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000872/environment/Dockerfile b/tasks/format-code-task-000872/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c1d2c4e036fdcd8a45937846cc26f5fa846f81be --- /dev/null +++ b/tasks/format-code-task-000872/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b76f8757b4c4f575f1423f5687f228b3d3395a5bb33712940d1ae53bba6cce7d diff --git a/tasks/format-code-task-000872/environment/setup/files/blocklist b/tasks/format-code-task-000872/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000872/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000872/environment/setup/setup.sh b/tasks/format-code-task-000872/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000872/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000872/tests/test.patch b/tasks/format-code-task-000872/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a933559b453f23330263598397b97ed5a510e281 --- /dev/null +++ b/tasks/format-code-task-000872/tests/test.patch @@ -0,0 +1,117 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..dc833f19b +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node ./node_modules/mocha/bin/_mocha tests/unit/blueprints/adapter-test.js"] ++} +diff --git a/tests/unit/blueprints/adapter-test.js b/tests/unit/blueprints/adapter-test.js +new file mode 100644 +index 000000000..22271ddbb +--- /dev/null ++++ b/tests/unit/blueprints/adapter-test.js +@@ -0,0 +1,89 @@ ++'use strict'; ++ ++var Blueprint = require('../../../lib/models/blueprint'); ++var stringUtil = require('../../../lib/utilities/string'); ++var assert = require('assert'); ++ ++function callLocals(options) { ++ var blueprint = Blueprint.lookup('adapter'); ++ try { ++ return { locals: blueprint.locals(options), threw: false }; ++ } catch (e) { ++ return { error: e, threw: true }; ++ } ++} ++ ++ ++function isSelfImport(locals, adapterName) { ++ if (!locals || !locals.importStatement) return false; ++ var importPattern = new RegExp("from\\s+['\"]\\./" + adapterName + "['\"]"); ++ return importPattern.test(locals.importStatement); ++} ++ ++describe('blueprint - adapter', function() { ++ describe('locals', function() { ++ ++ ++ ++ ++ it('does not produce a self-import for the application adapter (CLI default form)', function() { ++ var result = callLocals({ ++ entity: { name: 'application' }, ++ baseClass: 'application', ++ target: __dirname ++ }); ++ ++ if (!result.threw) { ++ assert.ok(!isSelfImport(result.locals, 'application'), ++ 'Expected no self-import for application adapter, got: ' + JSON.stringify(result.locals)); ++ } ++ }); ++ ++ it('does not produce a self-import for the application adapter (no base-class form)', function() { ++ var result = callLocals({ ++ entity: { name: 'application' }, ++ target: __dirname ++ }); ++ if (!result.threw) { ++ assert.ok(!isSelfImport(result.locals, 'application'), ++ 'Expected no self-import for application adapter, got: ' + JSON.stringify(result.locals)); ++ } ++ }); ++ ++ it('extends ApplicationAdapter for non-application adapters with default base-class', function() { ++ var result = callLocals({ ++ entity: { name: 'post' }, ++ baseClass: 'application', ++ target: __dirname ++ }); ++ assert.ok(!result.threw, 'should not throw for post adapter with default base-class'); ++ assert.strictEqual(result.locals.baseClass, 'ApplicationAdapter'); ++ assert.strictEqual(result.locals.importStatement, "import ApplicationAdapter from './application';"); ++ }); ++ ++ it('extends from the specified base-class adapter', function() { ++ var result = callLocals({ ++ entity: { name: 'post' }, ++ baseClass: 'user', ++ target: __dirname ++ }); ++ assert.ok(!result.threw); ++ assert.strictEqual(result.locals.baseClass, 'UserAdapter'); ++ assert.strictEqual(result.locals.importStatement, "import UserAdapter from './user';"); ++ }); ++ ++ ++ ++ it('does not produce a self-import when adapter name equals base-class (user --base-class=user)', function() { ++ var result = callLocals({ ++ entity: { name: 'user' }, ++ baseClass: 'user', ++ target: __dirname ++ }); ++ if (!result.threw) { ++ assert.ok(!isSelfImport(result.locals, 'user'), ++ 'Expected no self-import for user adapter with base-class=user, got: ' + JSON.stringify(result.locals)); ++ } ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++node ./node_modules/mocha/bin/_mocha tests/unit/blueprints/adapter-test.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000872/tests/test.sh b/tasks/format-code-task-000872/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..862af119c098d849125f3fb35c35adfd06410d2a --- /dev/null +++ b/tasks/format-code-task-000872/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/unit/blueprints/adapter-test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000872/tests/test_command.sh b/tasks/format-code-task-000872/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000872/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000875/environment/Dockerfile b/tasks/format-code-task-000875/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..25df49441dd8cdafd7e4dbeb4af2b95fdf886e45 --- /dev/null +++ b/tasks/format-code-task-000875/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:afd41bd982c80984fb25d4b240048a6f0f243e19033d278ee9d31a331f212547 diff --git a/tasks/format-code-task-000875/environment/setup/files/blocklist b/tasks/format-code-task-000875/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000875/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000875/environment/setup/setup.sh b/tasks/format-code-task-000875/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000875/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000875/tests/test.patch b/tasks/format-code-task-000875/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..976d4cf208730278cf47169509ebc7fd811231a2 --- /dev/null +++ b/tasks/format-code-task-000875/tests/test.patch @@ -0,0 +1,95 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..b612d186 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest tests/lib/rules/no-get.js"] ++} +diff --git a/tests/lib/rules/no-get.js b/tests/lib/rules/no-get.js +index 81ace756..122e5972 100644 +--- a/tests/lib/rules/no-get.js ++++ b/tests/lib/rules/no-get.js +@@ -461,6 +461,68 @@ ruleTester.run('no-get', rule, { + ], + }, + ++ ++ { ++ ++ code: "import { get } from '@ember/object'; get(myParam, '0.myProperty');", ++ options: [{ useOptionalChaining: true, catchSafeObjects: true }], ++ output: "import { get } from '@ember/object'; myParam[0]?.myProperty;", ++ errors: [ ++ { ++ message: ERROR_MESSAGE_GET, ++ type: 'CallExpression', ++ }, ++ ], ++ }, ++ { ++ ++ code: "this.get('0.foo');", ++ options: [{ useOptionalChaining: true }], ++ output: 'this[0]?.foo;', ++ errors: [ ++ { ++ message: ERROR_MESSAGE_GET, ++ type: 'CallExpression', ++ }, ++ ], ++ }, ++ { ++ ++ code: "import { get } from '@ember/object'; get(this, '0.bar');", ++ options: [{ useOptionalChaining: true }], ++ output: "import { get } from '@ember/object'; this[0]?.bar;", ++ errors: [ ++ { ++ message: ERROR_MESSAGE_GET, ++ type: 'CallExpression', ++ }, ++ ], ++ }, ++ { ++ ++ code: "this.get('0.1.foo');", ++ options: [{ useOptionalChaining: true }], ++ output: 'this[0]?.[1]?.foo;', ++ errors: [ ++ { ++ message: ERROR_MESSAGE_GET, ++ type: 'CallExpression', ++ }, ++ ], ++ }, ++ { ++ ++ code: "this.get('12.bar.baz');", ++ options: [{ useOptionalChaining: true }], ++ output: 'this[12]?.bar?.baz;', ++ errors: [ ++ { ++ message: ERROR_MESSAGE_GET, ++ type: 'CallExpression', ++ }, ++ ], ++ }, ++ + { + // Reports violation after (classic) proxy class. + code: ` +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest tests/lib/rules/no-get.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000875/tests/test.sh b/tasks/format-code-task-000875/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..676a6aa956034e3da9c88c1fc2f046cfbd87ae29 --- /dev/null +++ b/tasks/format-code-task-000875/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/lib/rules/no-get.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000875/tests/test_command.sh b/tasks/format-code-task-000875/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000875/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000881/environment/Dockerfile b/tasks/format-code-task-000881/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6c526201819621d75610ecad3a3cca0119a479c3 --- /dev/null +++ b/tasks/format-code-task-000881/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:21f72504446ac51b715f0603cbd57fb8270ef818642d2ffa7d6f96f5b9ec78ef diff --git a/tasks/format-code-task-000881/environment/setup/files/blocklist b/tasks/format-code-task-000881/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000881/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000881/environment/setup/setup.sh b/tasks/format-code-task-000881/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000881/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000881/tests/test.patch b/tasks/format-code-task-000881/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..33b25ff236c9f2718d4201384541319613f02b3d --- /dev/null +++ b/tasks/format-code-task-000881/tests/test.patch @@ -0,0 +1,174 @@ +diff --git a/chaco/tests/test_data_label.py b/chaco/overlays/tests/test_data_label.py +similarity index 100% +rename from chaco/tests/test_data_label.py +rename to chaco/overlays/tests/test_data_label.py +diff --git a/chaco/tests/test_overlay_api_exports.py b/chaco/tests/test_overlay_api_exports.py +new file mode 100644 +index 00000000..2218643e +--- /dev/null ++++ b/chaco/tests/test_overlay_api_exports.py +@@ -0,0 +1,121 @@ ++import inspect ++ ++ ++CLASS_EXPORTS = ( ++ "AlignedContainerOverlay", ++ "ColormappedSelectionOverlay", ++ "ContainerOverlay", ++ "CoordinateLineOverlay", ++ "DataBox", ++ "DataLabel", ++ "LassoOverlay", ++ "Legend", ++ "PlotLabel", ++ "ScatterInspectorOverlay", ++ "SimpleInspectorOverlay", ++ "TextBoxOverlay", ++ "TextGridOverlay", ++ "ToolTip", ++ "ImageInspectorOverlay", ++ "ErrorLayer", ++ "StatusLayer", ++ "WarningLayer", ++) ++ ++FORMATTER_EXPORTS = ( ++ "basic_formatter", ++ "datetime_formatter", ++ "date_formatter", ++ "time_formatter", ++) ++ ++REPRESENTATIVE_TRAIT_CHECKS = { ++ "PlotLabel": ("text",), ++ "DataLabel": ("data_point",), ++ "SimpleInspectorOverlay": (), ++ "StatusLayer": (), ++} ++ ++NO_ARG_CONSTRUCTIBLE_EXPORTS = ( ++ "PlotLabel", ++ "DataLabel", ++ "SimpleInspectorOverlay", ++) ++ ++ ++def _assert_traits_public_class(obj, name): ++ assert inspect.isclass(obj), f"{name} should be a class" ++ assert hasattr(obj, "class_traits"), f"{name} should be a Traits class" ++ assert obj.class_traits(), f"{name} should expose Traits metadata" ++ ++ ++def test_overlays_api_exports_overlay_classes(): ++ import chaco.overlays.api as overlays_api ++ ++ for name in CLASS_EXPORTS: ++ obj = getattr(overlays_api, name) ++ _assert_traits_public_class(obj, name) ++ ++ ++def test_overlays_api_exports_formatter_helpers(): ++ import chaco.overlays.api as overlays_api ++ ++ for name in FORMATTER_EXPORTS: ++ obj = getattr(overlays_api, name) ++ assert callable(obj), f"{name} should be callable" ++ ++ ++def test_chaco_api_reexports_overlay_classes(): ++ import chaco.api as chaco_api ++ ++ for name in CLASS_EXPORTS: ++ obj = getattr(chaco_api, name) ++ _assert_traits_public_class(obj, name) ++ ++ ++def test_chaco_api_reexports_formatter_helpers(): ++ import chaco.api as chaco_api ++ ++ for name in FORMATTER_EXPORTS: ++ obj = getattr(chaco_api, name) ++ assert callable(obj), f"{name} should be callable" ++ ++ ++def test_chaco_api_and_overlays_api_objects_are_identical(): ++ import chaco.api as chaco_api ++ import chaco.overlays.api as overlays_api ++ ++ for name in CLASS_EXPORTS + FORMATTER_EXPORTS: ++ assert getattr(chaco_api, name) is getattr(overlays_api, name) ++ ++ ++def test_representative_exports_are_real_traits_classes(): ++ import chaco.overlays.api as overlays_api ++ ++ for name, required_traits in REPRESENTATIVE_TRAIT_CHECKS.items(): ++ cls = getattr(overlays_api, name) ++ traits = cls.class_traits() ++ for trait_name in required_traits: ++ assert trait_name in traits ++ ++ for name in NO_ARG_CONSTRUCTIBLE_EXPORTS: ++ cls = getattr(overlays_api, name) ++ instance = cls() ++ assert instance.__class__ is cls ++ ++ ++def test_formatter_helpers_return_text_for_public_inputs(): ++ import chaco.overlays.api as overlays_api ++ ++ basic = overlays_api.basic_formatter("sample_key", 1) ++ assert callable(basic) ++ first_result = basic(sample_key=12.5) ++ second_result = basic(sample_key=13.5) ++ assert isinstance(first_result, str) ++ assert isinstance(second_result, str) ++ assert first_result != second_result ++ ++ for name in ("datetime_formatter", "date_formatter", "time_formatter"): ++ formatter = getattr(overlays_api, name)("when") ++ assert callable(formatter) ++ assert isinstance(formatter(when=0), str) +diff --git a/chaco/tests/test_overlay_package_data.py b/chaco/tests/test_overlay_package_data.py +new file mode 100644 +index 00000000..c76fd2c0 +--- /dev/null ++++ b/chaco/tests/test_overlay_package_data.py +@@ -0,0 +1,11 @@ ++from pathlib import Path ++ ++ ++def test_layer_status_assets_are_available_from_consolidated_api(): ++ import chaco.overlays.api as overlays_api ++ ++ for layer_class in (overlays_api.ErrorLayer, overlays_api.WarningLayer): ++ layer = layer_class(component=None) ++ layer_asset = Path(layer.filename) ++ assert layer_asset.is_file() ++ assert layer_asset.stat().st_size > 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++pip install -e . --no-build-isolation --no-deps >/tmp/format-code-task-000881_test_install.log 2>&1 || { ++ cat /tmp/format-code-task-000881_test_install.log ++ exit 1 ++} ++ ++case "$1" in ++ base) ++ python3 -m pytest chaco/overlays/tests/test_data_label.py -xvs ++ ;; ++ new) ++ python3 -m pytest chaco/overlays/tests/test_data_label.py chaco/tests/test_overlay_api_exports.py chaco/tests/test_overlay_package_data.py -xvs ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000881/tests/test.sh b/tasks/format-code-task-000881/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..56b7a7dc9e4bc183a8b673000fb6cd9b63b407e2 --- /dev/null +++ b/tasks/format-code-task-000881/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +chaco/tests/test_data_label.py +chaco/overlays/tests/test_data_label.py +chaco/tests/test_overlay_api_exports.py +chaco/tests/test_overlay_package_data.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000881/tests/test_command.sh b/tasks/format-code-task-000881/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000881/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000886/environment/Dockerfile b/tasks/format-code-task-000886/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..517278b12ee2ece2a3b547e752b3b1493e71cb95 --- /dev/null +++ b/tasks/format-code-task-000886/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6e9aeefbce493fa15981fa13f6714031d854926693ac1338737ace7c02dee5c8 diff --git a/tasks/format-code-task-000886/environment/setup/files/blocklist b/tasks/format-code-task-000886/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000886/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000886/environment/setup/setup.sh b/tasks/format-code-task-000886/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000886/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000886/tests/test.patch b/tasks/format-code-task-000886/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..36f591350e2025f75f8c966661cb4359dfc404a4 --- /dev/null +++ b/tasks/format-code-task-000886/tests/test.patch @@ -0,0 +1,212 @@ +diff --git a/common/validation_test.go b/common/validation_test.go +new file mode 100644 +index 0000000..cd06837 +--- /dev/null ++++ b/common/validation_test.go +@@ -0,0 +1,186 @@ ++package common ++ ++import ( ++ "strings" ++ "testing" ++) ++ ++ ++ ++ ++func validBaseConfig() *Config { ++ return &Config{ ++ LogLevel: "INFO", ++ RateLimiters: &RateLimiterConfig{ ++ Budgets: []*RateLimitBudgetConfig{ ++ { ++ Id: "default-budget", ++ Rules: []*RateLimitRuleConfig{ ++ {Method: "*", MaxCount: 100, Period: "1s", WaitTime: "1s"}, ++ }, ++ }, ++ }, ++ }, ++ Projects: []*ProjectConfig{ ++ { ++ Id: "main", ++ Upstreams: []*UpstreamConfig{ ++ { ++ Id: "rpc1", ++ Type: UpstreamTypeEvm, ++ Endpoint: "http://rpc1.localhost", ++ Evm: &EvmUpstreamConfig{ChainId: 1}, ++ }, ++ }, ++ Networks: []*NetworkConfig{ ++ { ++ Architecture: ArchitectureEvm, ++ Evm: &EvmNetworkConfig{ChainId: 1}, ++ }, ++ }, ++ }, ++ }, ++ } ++} ++ ++func assertValid(t *testing.T, c *Config) { ++ t.Helper() ++ if err := c.Validate(); err != nil { ++ t.Fatalf("expected config to be valid, got error: %v", err) ++ } ++} ++ ++func assertInvalid(t *testing.T, c *Config, mustContain string) { ++ t.Helper() ++ err := c.Validate() ++ if err == nil { ++ t.Fatalf("expected validation error, got nil") ++ } ++ if mustContain != "" && !strings.Contains(strings.ToLower(err.Error()), strings.ToLower(mustContain)) { ++ t.Fatalf("expected error to mention %q, got: %v", mustContain, err) ++ } ++} ++ ++func TestValidate_BaselineIsValid(t *testing.T) { ++ assertValid(t, validBaseConfig()) ++} ++ ++func TestValidate_ProjectIdRequired(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].Id = "" ++ assertInvalid(t, c, "") ++} ++ ++func TestValidate_ProjectNeedsUpstream(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].Upstreams = nil ++ assertInvalid(t, c, "") ++} ++ ++func TestValidate_ConnectorDriverRequired(t *testing.T) { ++ c := validBaseConfig() ++ c.Database = &DatabaseConfig{ ++ EvmJsonRpcCache: &ConnectorConfig{ ++ Driver: "", ++ Memory: &MemoryConnectorConfig{MaxItems: 100}, ++ }, ++ } ++ assertInvalid(t, c, "driver") ++} ++ ++func TestValidate_ConnectorDriverMustBeKnown(t *testing.T) { ++ c := validBaseConfig() ++ c.Database = &DatabaseConfig{ ++ EvmJsonRpcCache: &ConnectorConfig{ ++ Driver: "cassandra", ++ Memory: &MemoryConnectorConfig{MaxItems: 100}, ++ }, ++ } ++ assertInvalid(t, c, "driver") ++} ++ ++func TestValidate_ConnectorDriverBlockMustMatch(t *testing.T) { ++ c := validBaseConfig() ++ ++ c.Database = &DatabaseConfig{ ++ EvmJsonRpcCache: &ConnectorConfig{ ++ Driver: "redis", ++ }, ++ } ++ assertInvalid(t, c, "redis") ++} ++ ++func TestValidate_ConnectorValid(t *testing.T) { ++ c := validBaseConfig() ++ c.Database = &DatabaseConfig{ ++ EvmJsonRpcCache: &ConnectorConfig{ ++ Driver: "memory", ++ Memory: &MemoryConnectorConfig{MaxItems: 100}, ++ }, ++ } ++ assertValid(t, c) ++} ++ ++func TestValidate_BudgetNeedsRule(t *testing.T) { ++ c := validBaseConfig() ++ c.RateLimiters.Budgets[0].Rules = nil ++ assertInvalid(t, c, "") ++} ++ ++func TestValidate_RuleMethodRequired(t *testing.T) { ++ c := validBaseConfig() ++ c.RateLimiters.Budgets[0].Rules[0].Method = "" ++ assertInvalid(t, c, "method") ++} ++ ++func TestValidate_ProjectBudgetReferenceMustExist(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].RateLimitBudget = "does-not-exist" ++ assertInvalid(t, c, "budget") ++} ++ ++func TestValidate_ProjectBudgetReferenceValid(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].RateLimitBudget = "default-budget" ++ assertValid(t, c) ++} ++ ++func TestValidate_UpstreamBudgetReferenceMustExist(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].Upstreams[0].RateLimitBudget = "nope" ++ assertInvalid(t, c, "budget") ++} ++ ++func TestValidate_NetworkBudgetReferenceMustExist(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].Networks[0].RateLimitBudget = "missing" ++ assertInvalid(t, c, "budget") ++} ++ ++func TestValidate_NetworkArchitectureRequired(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].Networks[0].Architecture = "" ++ assertInvalid(t, c, "architecture") ++} ++ ++func TestValidate_EvmNetworkNeedsEvmBlock(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].Networks[0].Evm = nil ++ assertInvalid(t, c, "") ++} ++ ++func TestValidate_FailsafeTimeoutDurationMustParse(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].Upstreams[0].Failsafe = &FailsafeConfig{ ++ Timeout: &TimeoutPolicyConfig{Duration: "not-a-duration"}, ++ } ++ assertInvalid(t, c, "duration") ++} ++ ++func TestValidate_FailsafeTimeoutDurationValid(t *testing.T) { ++ c := validBaseConfig() ++ c.Projects[0].Upstreams[0].Failsafe = &FailsafeConfig{ ++ Timeout: &TimeoutPolicyConfig{Duration: "5s"}, ++ } ++ assertValid(t, c) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++go test ./common/ -count 1 ++ ++ ++go test ./common/ -run TestValidate -count 1 -v diff --git a/tasks/format-code-task-000886/tests/test.sh b/tasks/format-code-task-000886/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3ed6f666bb41c4411a83588180fb3d35856fe951 --- /dev/null +++ b/tasks/format-code-task-000886/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +common/validation_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000886/tests/test_command.sh b/tasks/format-code-task-000886/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000886/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000888/environment/Dockerfile b/tasks/format-code-task-000888/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7d81b63a875b400b7ce9c2bb14a319875ce2c6d5 --- /dev/null +++ b/tasks/format-code-task-000888/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:31c45508c2356689cf755aba0c5aabf8f328150ef00cea7afae9082f0c153b46 diff --git a/tasks/format-code-task-000888/environment/setup/files/blocklist b/tasks/format-code-task-000888/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000888/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000888/environment/setup/setup.sh b/tasks/format-code-task-000888/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000888/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000888/tests/test.patch b/tasks/format-code-task-000888/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..098956392ba1ac676d6791d925a7ee2c3ce7a7e0 --- /dev/null +++ b/tasks/format-code-task-000888/tests/test.patch @@ -0,0 +1,38 @@ +diff --git a/tests/spec/s-global.js b/tests/spec/s-global.js +index ca284723..e7766eb5 100644 +--- a/tests/spec/s-global.js ++++ b/tests/spec/s-global.js +@@ -28,6 +28,12 @@ describe('global methods', function () { + expect(parseInt(' 0x16')).toBe(parseInt('0x16', 16)); + expect(parseInt(' 42')).toBe(parseInt('42', 10)); + expect(parseInt(' 08')).toBe(parseInt('08', 10)); ++ ++ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + ++ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + ++ "\u2029\uFEFF"; ++ expect(parseInt(ws + '08')).toBe(parseInt('08', 10)); ++ expect(parseInt(ws + '0x16')).toBe(parseInt('0x16', 16)); + }); + + it('defaults the radix properly when not a true number', function () { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S306DMBQGcK55ii5el1IUduerLIVWYekfQtvFx98ZalxMdDdbzOL3I6QN5wBN ++v1Z9nqzeGX8Qxa3UZNu260i+j+tcto1sZE2XLOhuO1mw9mYrOpNjUgtjxRJC+q3vUv1OVV/5JxPT ++bgjOKa+rOF7vH5fyb5ruM3/qe6T8nzo6Bqy+3hJ+9s/zf9iIfvKiV3EsB83WQ9AbXfrZscnT3ljL ++OPeBq6yn9D59yV6z5llocxA+W0vNb2yvopu8obo21OZUGsbTy6cPRhFnM4jR2NkskX+0Vvt4Xo38 ++1YZeWXpc/vWuAAAAAAAAAAAAAAAAAAAAAADchyNEGuf0ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000888/tests/test.sh b/tasks/format-code-task-000888/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..147185d320a5a9f93f7a85dd0e6136fb53786ee7 --- /dev/null +++ b/tasks/format-code-task-000888/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/spec/s-global.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000888/tests/test_command.sh b/tasks/format-code-task-000888/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000888/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001105/environment/Dockerfile b/tasks/format-code-task-001105/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..57b08cb8b17d08edb9786e672af36f711ff5211f --- /dev/null +++ b/tasks/format-code-task-001105/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7cd58fa305c55644e5b614cefaa28597df6dc6632454a2c3789392f9502ad351 diff --git a/tasks/format-code-task-001105/environment/setup/files/blocklist b/tasks/format-code-task-001105/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001105/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001105/environment/setup/setup.sh b/tasks/format-code-task-001105/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001105/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001105/tests/test.patch b/tasks/format-code-task-001105/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f488944155db2f7995dca65fb6e9e1098d2c10e9 --- /dev/null +++ b/tasks/format-code-task-001105/tests/test.patch @@ -0,0 +1,146 @@ +diff --git a/scripts/tests/test_validate_unwanted_patterns_cli.py b/scripts/tests/test_validate_unwanted_patterns_cli.py +new file mode 100644 +index 000000000..4e7d3c2b1 +--- /dev/null ++++ b/scripts/tests/test_validate_unwanted_patterns_cli.py +@@ -0,0 +1,129 @@ ++ ++ ++from pathlib import Path ++import subprocess ++import sys ++import tempfile ++import unittest ++ ++ ++REPOSITORY_ROOT = Path(__file__).resolve().parents[2] ++CHECKER = REPOSITORY_ROOT / "scripts" / "validate_unwanted_patterns.py" ++BARE_RAISE_MESSAGE = ( ++ "Bare pytests raise have been found. Please pass in the argument " ++ "'match' as well the exception." ++) ++ ++def write_file(root, relative_path, contents): ++ path = root / relative_path ++ path.parent.mkdir(parents=True, exist_ok=True) ++ path.write_text(contents, encoding="utf-8") ++ return path ++ ++ ++def run_checker(cwd, *args): ++ return subprocess.run( ++ [ ++ sys.executable, ++ str(CHECKER), ++ "--validation-type=bare_pytest_raises", ++ *args, ++ ], ++ cwd=cwd, ++ text=True, ++ capture_output=True, ++ check=False, ++ ) ++ ++ ++class TestUnwantedPatternsDirectoryCli(unittest.TestCase): ++ def assert_checker_output(self, result, expected_lines): ++ self.assertEqual(result.returncode, 1, result.stderr) ++ self.assertEqual(result.stdout.splitlines(), expected_lines) ++ self.assertEqual(result.stderr, "") ++ ++ def test_recurses_and_normalizes_included_extensions(self): ++ with tempfile.TemporaryDirectory() as temporary_directory: ++ root = Path(temporary_directory) ++ write_file(root, "src/a.py", "with pytest.raises(ValueError):\n pass\n") ++ write_file( ++ root, ++ "src/nested/b.py", ++ "with pytest.raises(TypeError):\n pass\n", ++ ) ++ write_file( ++ root, ++ "src/nested/not_python.txt", ++ "with pytest.raises(KeyError):\n pass\n", ++ ) ++ ++ result = run_checker( ++ root, ++ "--included-file-extensions=py, .py", ++ "src", ++ ) ++ ++ self.assert_checker_output( ++ result, ++ [ ++ f"src/a.py:1:{BARE_RAISE_MESSAGE}", ++ f"src/nested/b.py:1:{BARE_RAISE_MESSAGE}", ++ ], ++ ) ++ ++ def test_exclusions_apply_to_paths_and_descendants_without_duplicates(self): ++ with tempfile.TemporaryDirectory() as temporary_directory: ++ root = Path(temporary_directory) ++ write_file(root, "src/a.py", "with pytest.raises(ValueError):\n pass\n") ++ write_file( ++ root, ++ "src/excluded/b.py", ++ "with pytest.raises(TypeError):\n pass\n", ++ ) ++ write_file( ++ root, ++ "src/nested/hidden.py", ++ "with pytest.raises(KeyError):\n pass\n", ++ ) ++ ++ result = run_checker( ++ root, ++ "--included-file-extensions=.py", ++ "--excluded-file-paths=src/excluded, src/nested/hidden.py", ++ "src", ++ "src/a.py", ++ ) ++ ++ self.assert_checker_output( ++ result, ++ [f"src/a.py:1:{BARE_RAISE_MESSAGE}"], ++ ) ++ ++ def test_single_file_and_custom_format_remain_supported(self): ++ with tempfile.TemporaryDirectory() as temporary_directory: ++ root = Path(temporary_directory) ++ write_file(root, "standalone.txt", "with pytest.raises(ValueError):\n pass\n") ++ ++ result = run_checker( ++ root, ++ "--format=[{line_number}] {source_path} :: {msg}", ++ "standalone.txt", ++ ) ++ ++ self.assert_checker_output( ++ result, ++ [f"[1] standalone.txt :: {BARE_RAISE_MESSAGE}"], ++ ) ++ ++ def test_missing_source_is_a_clean_command_error(self): ++ with tempfile.TemporaryDirectory() as temporary_directory: ++ root = Path(temporary_directory) ++ result = run_checker(root, "missing.py") ++ ++ self.assertNotEqual(result.returncode, 0) ++ self.assertEqual(result.stdout, "") ++ self.assertIn("Source path does not exist: missing.py", result.stderr) ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++PYTHONPATH="scripts${PYTHONPATH:+:${PYTHONPATH}}" \ ++ python -m unittest -v scripts.tests.test_validate_unwanted_patterns_cli diff --git a/tasks/format-code-task-001105/tests/test.sh b/tasks/format-code-task-001105/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..392472b7cd84397c5a14e40902269bec1710a375 --- /dev/null +++ b/tasks/format-code-task-001105/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +scripts/tests/test_validate_unwanted_patterns_cli.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001105/tests/test_command.sh b/tasks/format-code-task-001105/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001105/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001132/environment/Dockerfile b/tasks/format-code-task-001132/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d1e1f55d673b4ddaa248982141bd6fcd88b54b --- /dev/null +++ b/tasks/format-code-task-001132/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:346d6627b6803b9b682aba9bc669736cb8964a7812738a709db5be4e50b3e560 diff --git a/tasks/format-code-task-001132/environment/setup/files/blocklist b/tasks/format-code-task-001132/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001132/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001132/environment/setup/setup.sh b/tasks/format-code-task-001132/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001132/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001132/tests/test.patch b/tasks/format-code-task-001132/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..666b0baae8265223a8ba8dace1d1a6646ac89174 --- /dev/null +++ b/tasks/format-code-task-001132/tests/test.patch @@ -0,0 +1,232 @@ +diff --git a/api/tests/opentrons/protocols/test_bundle_hardening.py b/api/tests/opentrons/protocols/test_bundle_hardening.py +new file mode 100644 +index 0000000000..4726f0d38f +--- /dev/null ++++ b/api/tests/opentrons/protocols/test_bundle_hardening.py +@@ -0,0 +1,213 @@ ++import io ++import zipfile ++ ++import pytest ++ ++from opentrons.protocols.bundle import extract_bundle, create_bundle ++from opentrons.protocols.types import BundleContents ++ ++ ++def _labware() -> dict: ++ return { ++ "namespace": "test", ++ "version": 1, ++ "parameters": {"loadName": "plate"}, ++ } ++ ++ ++def _archive_with_extra(name: str) -> zipfile.ZipFile: ++ buffer = io.BytesIO() ++ with zipfile.ZipFile(buffer, "w") as archive: ++ archive.writestr("protocol.ot2.py", "def run(ctx):\n pass\n") ++ archive.writestr( ++ "labware/plate.json", ++ '{"namespace":"test","version":1,' ++ '"parameters":{"loadName":"plate"}}', ++ ) ++ archive.writestr(name, b"payload") ++ buffer.seek(0) ++ return zipfile.ZipFile(buffer) ++ ++ ++@pytest.mark.parametrize( ++ "member_name", ++ [ ++ "../outside.txt", ++ "/protocol.ot2.py", ++ "data/../../outside.txt", ++ "data\\..\\outside.txt", ++ "C:/outside.txt", ++ "data//outside.txt", ++ "data/./outside.txt", ++ ], ++) ++def test_extract_rejects_unsafe_member_paths(member_name: str) -> None: ++ with _archive_with_extra(member_name) as archive: ++ with pytest.raises(RuntimeError): ++ extract_bundle(archive) ++ ++ ++@pytest.mark.parametrize( ++ ("first_name", "second_name"), ++ [ ++ ("data/value.txt", "data/value.txt"), ++ ("data/cafe\u0301.txt", "data/caf\u00e9.txt"), ++ ], ++) ++def test_extract_rejects_duplicate_normalized_members( ++ first_name: str, second_name: str ++) -> None: ++ buffer = io.BytesIO() ++ with zipfile.ZipFile(buffer, "w") as archive: ++ archive.writestr("protocol.ot2.py", "def run(ctx):\n pass\n") ++ archive.writestr( ++ "labware/plate.json", ++ '{"namespace":"test","version":1,' ++ '"parameters":{"loadName":"plate"}}', ++ ) ++ archive.writestr(first_name, b"first") ++ archive.writestr(second_name, b"second") ++ buffer.seek(0) ++ with zipfile.ZipFile(buffer) as archive: ++ with pytest.raises(RuntimeError): ++ extract_bundle(archive) ++ ++ ++def test_create_bundle_round_trips_nested_data_and_python() -> None: ++ contents = BundleContents( ++ protocol="def run(ctx):\n pass\n", ++ bundled_labware={"test/plate/1": _labware()}, ++ bundled_data={ ++ "nested/data.txt": b"data", ++ "root.bin": b"bytes", ++ "Case.txt": b"upper", ++ "case.txt": b"lower", ++ "cafe\u0301.txt": b"accent", ++ }, ++ bundled_python={"helpers/util.py": "VALUE = 3\n"}, ++ ) ++ buffer = io.BytesIO() ++ create_bundle(contents, buffer) ++ buffer.seek(0) ++ ++ with zipfile.ZipFile(buffer) as archive: ++ assert { ++ "data/nested/data.txt", ++ "data/root.bin", ++ "data/Case.txt", ++ "data/case.txt", ++ "data/cafe\u0301.txt", ++ "helpers/util.py", ++ }.issubset(archive.namelist()) ++ assert extract_bundle(archive) == contents ++ ++ ++def test_bundle_without_custom_labware_round_trips() -> None: ++ contents = BundleContents( ++ protocol="def run(ctx):\n pass\n", ++ bundled_labware={}, ++ bundled_data={"settings.csv": b"a,b\n1,2\n"}, ++ bundled_python={}, ++ ) ++ buffer = io.BytesIO() ++ create_bundle(contents, buffer) ++ buffer.seek(0) ++ ++ with zipfile.ZipFile(buffer) as archive: ++ assert extract_bundle(archive) == contents ++ ++ ++@pytest.mark.parametrize( ++ "python_name", ++ [ ++ "../helper.py", ++ "bad\\helper.py", ++ "C:/helper.py", ++ "helpers//helper.py", ++ "helpers/./helper.py", ++ "data/helper.py", ++ "labware/helper.py", ++ "protocol.ot2.py", ++ ], ++) ++def test_create_bundle_rejects_unsafe_or_reserved_python_names( ++ python_name: str, ++) -> None: ++ contents = BundleContents( ++ protocol="def run(ctx):\n pass\n", ++ bundled_labware={"test/plate/1": _labware()}, ++ bundled_data={}, ++ bundled_python={python_name: "VALUE = 3\n"}, ++ ) ++ output = io.BytesIO() ++ with pytest.raises(RuntimeError): ++ create_bundle(contents, output) ++ assert output.getvalue() == b"" ++ ++ ++@pytest.mark.parametrize( ++ "data_name", ++ [ ++ "../payload.bin", ++ "data\\..\\payload.bin", ++ "/payload.bin", ++ "C:/payload.bin", ++ "nested//payload.bin", ++ "./payload.bin", ++ ], ++) ++def test_create_bundle_rejects_unsafe_or_reserved_data_names(data_name: str) -> None: ++ contents = BundleContents( ++ protocol="def run(ctx):\n pass\n", ++ bundled_labware={"test/plate/1": _labware()}, ++ bundled_data={data_name: b"payload"}, ++ bundled_python={}, ++ ) ++ output = io.BytesIO() ++ with pytest.raises(RuntimeError): ++ create_bundle(contents, output) ++ assert output.getvalue() == b"" ++ ++ ++@pytest.mark.parametrize( ++ "namespace", ["../outside", "bad\\path", "bad//path", "bad/./path"] ++) ++def test_create_bundle_rejects_unsafe_labware_names(namespace: str) -> None: ++ labware = _labware() ++ labware["namespace"] = namespace ++ contents = BundleContents( ++ protocol="def run(ctx):\n pass\n", ++ bundled_labware={"ignored-key": labware}, ++ bundled_data={}, ++ bundled_python={}, ++ ) ++ output = io.BytesIO() ++ with pytest.raises(RuntimeError): ++ create_bundle(contents, output) ++ assert output.getvalue() == b"" ++ ++ ++def test_create_bundle_rejects_duplicate_labware_members_atomically() -> None: ++ contents = BundleContents( ++ protocol="def run(ctx):\n pass\n", ++ bundled_labware={"first": _labware(), "second": _labware()}, ++ bundled_data={}, ++ bundled_python={}, ++ ) ++ output = io.BytesIO() ++ with pytest.raises(RuntimeError): ++ create_bundle(contents, output) ++ assert output.getvalue() == b"" ++ ++ ++def test_create_bundle_rejects_unicode_normalized_data_collision() -> None: ++ contents = BundleContents( ++ protocol="def run(ctx):\n pass\n", ++ bundled_labware={}, ++ bundled_data={"cafe\u0301.txt": b"first", "caf\u00e9.txt": b"second"}, ++ bundled_python={}, ++ ) ++ output = io.BytesIO() ++ with pytest.raises(RuntimeError): ++ create_bundle(contents, output) ++ assert output.getvalue() == b"" +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++.build_env/venv/bin/python -m pytest -q \ ++ api/tests/opentrons/protocols/test_bundle_hardening.py \ ++ api/tests/opentrons/protocols/test_bundle.py \ ++ api/tests/opentrons/protocols/test_parse.py::test_parse_bundle_details diff --git a/tasks/format-code-task-001132/tests/test.sh b/tasks/format-code-task-001132/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..24c719682581322b1842c0c605bb276bc87f964c --- /dev/null +++ b/tasks/format-code-task-001132/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +api/tests/opentrons/protocols/test_bundle_hardening.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001132/tests/test_command.sh b/tasks/format-code-task-001132/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001132/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001133/environment/Dockerfile b/tasks/format-code-task-001133/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ac20976f654925ad39c0f12f7e36a134e821ba71 --- /dev/null +++ b/tasks/format-code-task-001133/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c4fa205e3238de572ede8dd11f6e3204cb6cc88369733ba956064c629cc700f5 diff --git a/tasks/format-code-task-001133/environment/setup/files/blocklist b/tasks/format-code-task-001133/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001133/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001133/environment/setup/setup.sh b/tasks/format-code-task-001133/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001133/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001133/tests/test.patch b/tasks/format-code-task-001133/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..78462405a3d0adcb2df8349a5283f6af2d2cba12 --- /dev/null +++ b/tasks/format-code-task-001133/tests/test.patch @@ -0,0 +1,218 @@ +diff --git a/core/test/lib/manifest-id-codespec-test.js b/core/test/lib/manifest-id-codespec-test.js +new file mode 100644 +index 000000000..3f9a0b7a1 +--- /dev/null ++++ b/core/test/lib/manifest-id-codespec-test.js +@@ -0,0 +1,197 @@ ++/** ++ * @license Copyright 2026 The Lighthouse Authors. All Rights Reserved. ++ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ++ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ++ */ ++ ++import assert from 'assert/strict'; ++ ++import {ManifestValues} from '../../computed/manifest-values.js'; ++import defaultConfig from '../../config/default-config.js'; ++import {parseManifest} from '../../lib/manifest-parser.js'; ++ ++const MANIFEST_URL = 'https://example.com/assets/manifest.webmanifest'; ++const DOCUMENT_URL = 'https://example.com/app/index.html#document-fragment'; ++ ++function parse(input) { ++ return parseManifest(JSON.stringify(input), MANIFEST_URL, DOCUMENT_URL); ++} ++ ++function getIdentity(input) { ++ const manifest = parse(input); ++ assert.ok(manifest.value, 'manifest should parse'); ++ assert.ok(manifest.value.id, 'parsed manifest should expose its normalized id member'); ++ return manifest.value.id; ++} ++ ++async function getHasIdCheck(input) { ++ const WebAppManifest = parse(input); ++ const result = await ManifestValues.request( ++ {WebAppManifest, InstallabilityErrors: {errors: []}}, ++ {computedCache: new Map()} ++ ); ++ assert.equal(result.isParseFailure, false); ++ const check = result.allChecks.find(item => item.id === 'hasId'); ++ assert.ok(check, 'ManifestValues should expose a hasId check'); ++ return check; ++} ++ ++async function getConfiguredAudit() { ++ const auditEntry = defaultConfig.audits.find(audit => { ++ if (typeof audit === 'string') return audit.endsWith('manifest-id'); ++ if (audit.implementation?.meta?.id === 'manifest-id') return true; ++ return audit.path?.endsWith('manifest-id'); ++ }); ++ assert.ok(auditEntry, 'manifest-id should be available in the default audit list'); ++ const AuditClass = typeof auditEntry === 'object' && auditEntry.implementation ? ++ auditEntry.implementation : ++ (await import(`../../audits/${typeof auditEntry === 'string' ? auditEntry : auditEntry.path}.js`)) ++ .default; ++ assert.equal(AuditClass.meta.id, 'manifest-id'); ++ assert.deepEqual(AuditClass.meta.supportedModes, ['navigation']); ++ return AuditClass; ++} ++ ++function makeArtifacts(input) { ++ return { ++ WebAppManifest: typeof input === 'string' ? ++ parseManifest(input, MANIFEST_URL, DOCUMENT_URL) : parse(input), ++ InstallabilityErrors: {errors: []}, ++ }; ++} ++ ++describe('Web App Manifest identity contract', () => { ++ describe('manifest id parsing', () => { ++ it('resolves relative ids against start_url and removes only the fragment', () => { ++ const id = getIdentity({ ++ start_url: '/app/home?source=manifest#launch', ++ id: 'profile?tenant=1#details', ++ }); ++ ++ assert.equal(id.raw, 'profile?tenant=1#details'); ++ assert.equal(id.value, 'https://example.com/app/profile?tenant=1'); ++ assert.equal(id.warning, undefined); ++ }); ++ ++ it('uses a fragment-free start_url when id is omitted', () => { ++ const id = getIdentity({start_url: '/app/home?source=manifest#launch'}); ++ const documentDefault = getIdentity({}); ++ ++ assert.equal(id.raw, undefined); ++ assert.equal(id.value, 'https://example.com/app/home?source=manifest'); ++ assert.equal(id.warning, undefined); ++ assert.equal(documentDefault.value, 'https://example.com/app/index.html'); ++ }); ++ ++ it('accepts an explicitly empty id as the start_url identity', () => { ++ const id = getIdentity({ ++ start_url: '/app/home?source=manifest#launch', ++ id: '', ++ }); ++ ++ assert.equal(id.raw, ''); ++ assert.equal(id.value, 'https://example.com/app/home?source=manifest'); ++ assert.equal(id.warning, undefined); ++ }); ++ ++ it('falls back with a type-specific warning for a non-string id', () => { ++ const id = getIdentity({start_url: '/app/home#launch', id: 42}); ++ ++ assert.equal(id.raw, 42); ++ assert.equal(id.value, 'https://example.com/app/home'); ++ assert.match(id.warning || '', /string/i); ++ }); ++ ++ it('falls back with an invalid-id warning for a malformed URL', () => { ++ const id = getIdentity({start_url: '/app/home#launch', id: 'https://[invalid'}); ++ ++ assert.equal(id.raw, 'https://[invalid'); ++ assert.equal(id.value, 'https://example.com/app/home'); ++ assert.match(id.warning || '', /invalid.*id|id.*invalid/i); ++ }); ++ ++ it('falls back with a same-origin warning for cross-origin ids', () => { ++ const invalidIds = [ ++ 'https://other.example/app/home', ++ 'http://example.com/app/home', ++ 'https://example.com:8443/app/home', ++ ]; ++ for (const rawId of invalidIds) { ++ const id = getIdentity({start_url: '/app/home#launch', id: rawId}); ++ assert.equal(id.raw, rawId); ++ assert.equal(id.value, 'https://example.com/app/home'); ++ assert.match(id.warning || '', /same.?origin/i); ++ } ++ }); ++ }); ++ ++ describe('ManifestValues identity check', () => { ++ it('passes only for an explicit, valid id, including an empty string', async () => { ++ const valid = await getHasIdCheck({start_url: '/app/home', id: 'profile'}); ++ const explicitEmpty = await getHasIdCheck({start_url: '/app/home', id: ''}); ++ const omitted = await getHasIdCheck({start_url: '/app/home'}); ++ const invalid = await getHasIdCheck({start_url: '/app/home', id: 42}); ++ ++ assert.equal(valid.passing, true); ++ assert.equal(explicitEmpty.passing, true); ++ assert.equal(omitted.passing, false); ++ assert.equal(invalid.passing, false); ++ assert.match(valid.failureText, /id/i); ++ }); ++ }); ++ ++ describe('manifest-id audit', () => { ++ it('is registered as a zero-weight PWA optimized audit', async () => { ++ const AuditClass = await getConfiguredAudit(); ++ assert.equal(AuditClass.meta.id, 'manifest-id'); ++ const auditRef = defaultConfig.categories.pwa.auditRefs.find(ref => ref.id === 'manifest-id'); ++ assert.ok(auditRef); ++ assert.equal(auditRef.weight, 0); ++ assert.equal(auditRef.group, 'pwa-optimized'); ++ }); ++ ++ it('passes explicit valid ids, including the empty-string identity', async () => { ++ const AuditClass = await getConfiguredAudit(); ++ const context = {computedCache: new Map()}; ++ ++ const relativeResult = await AuditClass.audit( ++ makeArtifacts({start_url: '/app/home', id: 'profile'}), context ++ ); ++ const emptyResult = await AuditClass.audit( ++ makeArtifacts({start_url: '/app/home', id: ''}), {computedCache: new Map()} ++ ); ++ assert.equal(relativeResult.score, 1); ++ assert.equal(emptyResult.score, 1); ++ }); ++ ++ it('fails omitted and invalid ids', async () => { ++ const AuditClass = await getConfiguredAudit(); ++ const omittedResult = await AuditClass.audit( ++ makeArtifacts({start_url: '/app/home'}), {computedCache: new Map()} ++ ); ++ const invalidResult = await AuditClass.audit( ++ makeArtifacts({start_url: '/app/home', id: 'https://other.example/app'}), ++ {computedCache: new Map()} ++ ); ++ ++ assert.equal(omittedResult.score, 0); ++ assert.equal(invalidResult.score, 0); ++ }); ++ ++ it('fails missing and unparseable manifests with an explanation', async () => { ++ const AuditClass = await getConfiguredAudit(); ++ const missingResult = await AuditClass.audit( ++ {WebAppManifest: null, InstallabilityErrors: {errors: []}}, ++ {computedCache: new Map()} ++ ); ++ const invalidResult = await AuditClass.audit( ++ makeArtifacts('{not json'), {computedCache: new Map()} ++ ); ++ ++ assert.equal(missingResult.score, 0); ++ assert.match(missingResult.explanation || '', /manifest/i); ++ assert.equal(invalidResult.score, 0); ++ assert.match(invalidResult.explanation || '', /manifest|pars/i); ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,10 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++node node_modules/mocha/bin/mocha.js \ ++ --require core/test/test-env/mocha-setup.js \ ++ core/test/lib/manifest-id-codespec-test.js \ ++ core/test/lib/manifest-parser-test.js \ ++ core/test/computed/manifest-values-test.js \ ++ core/test/config/default-config-test.js diff --git a/tasks/format-code-task-001133/tests/test.sh b/tasks/format-code-task-001133/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..079c567fc1153c0dd9b4fd352a06ef83c981cd78 --- /dev/null +++ b/tasks/format-code-task-001133/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +core/test/lib/manifest-id-codespec-test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001133/tests/test_command.sh b/tasks/format-code-task-001133/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001133/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001134/environment/Dockerfile b/tasks/format-code-task-001134/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9b896e5c31d40a543736046ad3e8d8cb09e4b8f2 --- /dev/null +++ b/tasks/format-code-task-001134/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:01877a95e6bd3395d5b412fd63d3b9e36aa5e394ef4ef8cba52ed335b17d2b38 diff --git a/tasks/format-code-task-001134/environment/setup/files/blocklist b/tasks/format-code-task-001134/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001134/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001134/environment/setup/setup.sh b/tasks/format-code-task-001134/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001134/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001134/tests/test.patch b/tasks/format-code-task-001134/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7f455fb471fc2b003aa5a558c72340f60c3f0ee5 --- /dev/null +++ b/tasks/format-code-task-001134/tests/test.patch @@ -0,0 +1,252 @@ +diff --git a/tests/test_connection_header_contract.py b/tests/test_connection_header_contract.py +new file mode 100644 +index 0000000..c1f88b0 +--- /dev/null ++++ b/tests/test_connection_header_contract.py +@@ -0,0 +1,234 @@ ++from io import BytesIO ++ ++import django ++import urllib3 ++from django.http import StreamingHttpResponse ++from django.test import RequestFactory, SimpleTestCase, override_settings ++from mock import MagicMock, Mock, patch ++ ++from revproxy.views import ProxyView ++ ++django.setup() ++ ++ ++URLOPEN = 'urllib3.PoolManager.urlopen' ++FIXED_HOP_HEADERS = ( ++ 'connection', ++ 'keep-alive', ++ 'proxy-authenticate', ++ 'proxy-authorization', ++ 'proxy-connection', ++ 'te', ++ 'trailer', ++ 'trailers', ++ 'transfer-encoding', ++ 'upgrade', ++) ++ ++ ++class BoundaryProxyView(ProxyView): ++ upstream = 'http://upstream.example/base/' ++ ++ ++class ExtendingBoundaryProxyView(BoundaryProxyView): ++ def get_proxy_request_headers(self, request): ++ headers = super(ExtendingBoundaryProxyView, self).\ ++ get_proxy_request_headers(request) ++ headers['X-Extension-Secret'] = 'must-not-leak' ++ headers['X-Extension-Public'] = 'visible' ++ return headers ++ ++ ++@override_settings(ALLOWED_HOSTS=['frontend.example']) ++class ConnectionHeaderBoundaryContractTests(SimpleTestCase): ++ def setUp(self): ++ self.factory = RequestFactory() ++ ++ def proxy(self, upstream_headers=None, body=b'ok', status=200, ++ request_headers=None, view=BoundaryProxyView, ++ path='/asset.bin'): ++ headers = upstream_headers or urllib3.response.HTTPHeaderDict() ++ if not isinstance(headers, urllib3.response.HTTPHeaderDict): ++ headers = urllib3.response.HTTPHeaderDict(headers) ++ ++ raw_response = urllib3.HTTPResponse( ++ BytesIO(body), ++ headers, ++ status, ++ preload_content=False, ++ original_response=Mock(name='http.client.HTTPResponse'), ++ ) ++ urlopen = MagicMock(return_value=raw_response) ++ request_kwargs = {'HTTP_HOST': 'frontend.example'} ++ request_kwargs.update(request_headers or {}) ++ request = self.factory.get(path, **request_kwargs) ++ ++ with patch(URLOPEN, urlopen): ++ response = view.as_view()(request, path) ++ ++ sent_headers = { ++ name.lower(): value ++ for name, value in urlopen.call_args[1]['headers'].items() ++ } ++ return response, sent_headers ++ ++ def test_request_fixed_hop_headers_are_not_forwarded(self): ++ request_headers = { ++ 'HTTP_CONNECTION': 'keep-alive', ++ 'HTTP_KEEP_ALIVE': 'timeout=5', ++ 'HTTP_PROXY_AUTHENTICATE': 'Basic realm=private', ++ 'HTTP_PROXY_AUTHORIZATION': 'Basic c2VjcmV0', ++ 'HTTP_PROXY_CONNECTION': 'close', ++ 'HTTP_TE': 'trailers', ++ 'HTTP_TRAILER': 'X-Checksum', ++ 'HTTP_TRAILERS': 'X-Legacy-Checksum', ++ 'HTTP_TRANSFER_ENCODING': 'chunked', ++ 'HTTP_UPGRADE': 'websocket', ++ 'HTTP_X_END_TO_END': 'preserved', ++ } ++ ++ _, sent = self.proxy(request_headers=request_headers) ++ ++ for name in FIXED_HOP_HEADERS: ++ self.assertNotIn(name, sent) ++ self.assertEqual('preserved', sent['x-end-to-end']) ++ ++ def test_request_connection_tokens_are_case_insensitive_exact_names(self): ++ request_headers = { ++ 'HTTP_CONNECTION': ' X-Client-Secret , ', ++ 'HTTP_X_CLIENT_SECRET': 'remove-me', ++ 'HTTP_X_CLIENT_SECRETLY': 'preserve-me', ++ } ++ ++ _, sent = self.proxy(request_headers=request_headers) ++ ++ self.assertNotIn('x-client-secret', sent) ++ self.assertEqual('preserve-me', sent['x-client-secretly']) ++ ++ def test_request_filter_applies_after_public_header_extension(self): ++ request_headers = { ++ 'HTTP_CONNECTION': 'x-extension-secret', ++ } ++ ++ _, sent = self.proxy(request_headers=request_headers, ++ view=ExtendingBoundaryProxyView) ++ ++ self.assertNotIn('x-extension-secret', sent) ++ self.assertEqual('visible', sent['x-extension-public']) ++ ++ def test_existing_request_exclusions_remain_in_place(self): ++ request_headers = { ++ 'HTTP_ACCEPT_ENCODING': 'gzip', ++ 'HTTP_X_APPLICATION': 'kept-verbatim', ++ } ++ ++ _, sent = self.proxy(request_headers=request_headers) ++ ++ self.assertNotIn('host', sent) ++ self.assertNotIn('accept-encoding', sent) ++ self.assertEqual('kept-verbatim', sent['x-application']) ++ ++ def test_response_fixed_hop_headers_are_not_exposed(self): ++ headers = urllib3.response.HTTPHeaderDict() ++ for name in FIXED_HOP_HEADERS: ++ headers.add(name, 'private') ++ headers.add('Content-Type', 'text/plain') ++ headers.add('Content-Length', '2') ++ headers.add('X-End-To-End', 'preserved') ++ ++ response, _ = self.proxy(upstream_headers=headers) ++ exposed = {name.lower() for name, value in response.items()} ++ ++ for name in FIXED_HOP_HEADERS: ++ self.assertNotIn(name, exposed) ++ self.assertEqual('preserved', response['X-End-To-End']) ++ ++ def test_response_connection_tokens_use_all_lines_and_exact_names(self): ++ headers = urllib3.response.HTTPHeaderDict() ++ headers.add('Connection', ' X-Internal ') ++ headers.add('connection', ' X-Second-Secret ') ++ headers.add('X-Internal', 'remove-one') ++ headers.add('X-Second-Secret', 'remove-two') ++ headers.add('X-Internal-Suffix', 'preserved') ++ headers.add('Content-Type', 'text/plain') ++ headers.add('Content-Length', '2') ++ ++ response, _ = self.proxy(upstream_headers=headers) ++ ++ self.assertFalse(response.has_header('X-Internal')) ++ self.assertFalse(response.has_header('X-Second-Secret')) ++ self.assertEqual('preserved', response['X-Internal-Suffix']) ++ ++ def test_scoped_location_and_content_type_do_not_affect_processing(self): ++ headers = urllib3.response.HTTPHeaderDict() ++ headers.add('Connection', ' Location, content-TYPE ') ++ headers.add('Location', 'http://upstream.example/private') ++ headers.add('Content-Type', 'application/x-private') ++ headers.add('Content-Length', '2') ++ ++ response, _ = self.proxy(upstream_headers=headers) ++ ++ self.assertFalse(response.has_header('Location')) ++ self.assertEqual('application/octet-stream', ++ response['Content-Type']) ++ ++ def test_connection_scoped_content_length_uses_no_length_streaming(self): ++ headers = urllib3.response.HTTPHeaderDict() ++ headers.add('Connection', 'Content-Length') ++ headers.add('Content-Length', '2') ++ headers.add('Content-Type', 'application/octet-stream') ++ body = b'payload-without-a-trusted-length' ++ ++ response, _ = self.proxy(upstream_headers=headers, body=body) ++ ++ self.assertIsInstance(response, StreamingHttpResponse) ++ self.assertFalse(response.has_header('Content-Length')) ++ self.assertEqual(body, b''.join(response.streaming_content)) ++ ++ def test_connection_scoped_set_cookie_is_not_materialized(self): ++ headers = urllib3.response.HTTPHeaderDict() ++ headers.add('Connection', 'set-cookie') ++ headers.add('Set-Cookie', 'private_one=one; Path=/') ++ headers.add('Set-Cookie', 'private_two=two; Path=/') ++ headers.add('Content-Type', 'text/plain') ++ headers.add('Content-Length', '2') ++ ++ response, _ = self.proxy(upstream_headers=headers) ++ ++ self.assertEqual([], list(response.cookies.keys())) ++ ++ def test_ordinary_duplicate_set_cookies_are_preserved(self): ++ headers = urllib3.response.HTTPHeaderDict() ++ headers.add('Set-Cookie', 'public_one=one; Path=/one; HttpOnly') ++ headers.add('Set-Cookie', 'public_two=two; Path=/two; Secure') ++ headers.add('Content-Type', 'text/plain') ++ headers.add('Content-Length', '2') ++ ++ response, _ = self.proxy(upstream_headers=headers) ++ ++ self.assertEqual({'public_one', 'public_two'}, ++ set(response.cookies.keys())) ++ self.assertEqual('/one', response.cookies['public_one']['path']) ++ self.assertTrue(response.cookies['public_one']['httponly']) ++ self.assertEqual('/two', response.cookies['public_two']['path']) ++ self.assertTrue(response.cookies['public_two']['secure']) ++ ++ def test_ordinary_response_behavior_and_redirect_rewriting_survive(self): ++ headers = urllib3.response.HTTPHeaderDict() ++ headers.add('Location', ++ 'http://upstream.example/next?from=proxy#result') ++ headers.add('Content-Type', 'text/plain') ++ headers.add('Content-Length', '7') ++ headers.add('X-Application', 'visible') ++ body = b'content' ++ ++ response, _ = self.proxy(upstream_headers=headers, body=body, ++ status=307) ++ ++ self.assertEqual(307, response.status_code) ++ self.assertEqual(body, response.content) ++ self.assertEqual('visible', response['X-Application']) ++ self.assertEqual( ++ 'http://frontend.example/next?from=proxy#result', ++ response['Location'], ++ ) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,7 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++export DJANGO_SETTINGS_MODULE=tests.settings ++export PYTHONPATH="${PWD}/.build_env/.venv/lib/python3.11/site-packages${PYTHONPATH:+:${PYTHONPATH}}" ++/usr/bin/python3 -m pytest -q tests/test_connection_header_contract.py diff --git a/tasks/format-code-task-001134/tests/test.sh b/tasks/format-code-task-001134/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bfa545f436c6acd7bfed6702e02ca78bfeb0523c --- /dev/null +++ b/tasks/format-code-task-001134/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_connection_header_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001134/tests/test_command.sh b/tasks/format-code-task-001134/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001134/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001150/environment/Dockerfile b/tasks/format-code-task-001150/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..da0671acc4133bfb67ba643b64203991ba011259 --- /dev/null +++ b/tasks/format-code-task-001150/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9d363294206f26415027eb930b561c3f5687ba9f2eb1fd5cffe3af5bf8887128 diff --git a/tasks/format-code-task-001150/environment/setup/files/blocklist b/tasks/format-code-task-001150/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001150/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001150/environment/setup/setup.sh b/tasks/format-code-task-001150/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001150/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001150/tests/test.patch b/tasks/format-code-task-001150/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bffbd413530a691e6353106511063fdbdc03d574 --- /dev/null +++ b/tasks/format-code-task-001150/tests/test.patch @@ -0,0 +1,200 @@ +diff --git a/tests/cases/client_upload_test.py b/tests/cases/client_upload_test.py +new file mode 100644 +index 000000000..4910a36c4 +--- /dev/null ++++ b/tests/cases/client_upload_test.py +@@ -0,0 +1,185 @@ ++#!/usr/bin/env python ++# -*- coding: utf-8 -*- ++ ++import os ++import sys ++import tempfile ++import unittest ++ ++sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', ++ 'clients', ++ 'python')) ++import GirderClient as client_module ++ ++ ++class _Response(object): ++ def __init__(self, status, payload): ++ self.status_code = status ++ self._payload = payload ++ self.url = 'http://fake' ++ self.text = repr(payload) ++ ++ def json(self): ++ return self._payload ++ ++ ++class _UploadServer(object): ++ def __init__(self, initial='', offset=0, zero=False, expected_size=0, ++ resume=False): ++ self.data = initial ++ self.offset = offset ++ self.zero = zero ++ self.expected_size = expected_size ++ self.resume = resume ++ self.upload_id = 'upload-1' ++ self.seen_name = None ++ ++ def request(self, url, params=None, files=None): ++ if url.endswith('/file'): ++ assert not self.resume ++ self.seen_name = params['name'] ++ assert params['parentType'] == 'item' ++ assert params['parentId'] == 'item' ++ assert params['size'] == self.expected_size ++ if self.zero: ++ return _Response(200, {'_id': 'file-empty', 'size': 0}) ++ return _Response(200, {'_id': self.upload_id}) ++ if url.endswith('/file/offset'): ++ return _Response(200, {'offset': self.offset}) ++ if url.endswith('/file/chunk'): ++ assert params['uploadId'] == self.upload_id ++ assert int(params['offset']) == self.offset ++ chunk = files['chunk'] ++ assert len(chunk) <= 4 ++ if self.zero: ++ raise AssertionError('zero-byte upload must not send a chunk') ++ self.data += chunk ++ self.offset += len(chunk) ++ if self.offset == self.expected_size: ++ return _Response(200, {'_id': 'file-final'}) ++ return _Response(200, {'received': self.offset}) ++ raise AssertionError('unexpected URL: ' + url) ++ ++ ++class ClientUploadTest(unittest.TestCase): ++ def setUp(self): ++ self.original_methods = client_module.GirderClient.METHODS ++ self.original_post = client_module.requests.post ++ self.original_get = client_module.requests.get ++ ++ def tearDown(self): ++ client_module.GirderClient.METHODS = self.original_methods ++ client_module.requests.post = self.original_post ++ client_module.requests.get = self.original_get ++ ++ def _client(self, server): ++ client = client_module.GirderClient('fake', 1) ++ client.token = 'token' ++ client.MAX_CHUNK_SIZE = 4 ++ client_module.GirderClient.METHODS = { ++ 'GET': server.request, ++ 'POST': server.request, ++ 'PUT': server.request, ++ 'DELETE': server.request ++ } ++ client_module.requests.post = server.request ++ client_module.requests.get = server.request ++ return client ++ ++ def _file(self, contents, name='payload.bin'): ++ directory = tempfile.mkdtemp() ++ path = os.path.join(directory, name) ++ with open(path, 'wb') as stream: ++ stream.write(contents) ++ self.addCleanup(lambda: os.rmdir(directory)) ++ self.addCleanup(lambda: os.remove(path)) ++ return path ++ ++ def test_chunked_upload_uses_offsets_and_preserves_binary_data(self): ++ server = _UploadServer(expected_size=11) ++ client = self._client(server) ++ path = self._file('ab\x00cdEFghIJ') ++ ++ try: ++ result = client.uploadFileToItem('item', path) ++ except Exception as exc: ++ self.fail('upload failed: %s' % exc) ++ ++ self.assertEqual(result, 'file-final') ++ self.assertEqual(server.data, 'ab\x00cdEFghIJ') ++ self.assertEqual(server.seen_name, 'payload.bin') ++ ++ def test_upload_resumes_from_server_offset(self): ++ server = _UploadServer(initial='abcd', offset=4, expected_size=10, ++ resume=True) ++ client = self._client(server) ++ path = self._file('abcdefghij') ++ ++ result = client.uploadFileToItem('item', path, ++ uploadId=server.upload_id) ++ ++ self.assertEqual(result, 'file-final') ++ self.assertEqual(server.data, 'abcdefghij') ++ ++ def test_zero_byte_upload_returns_final_file_without_chunk(self): ++ server = _UploadServer(zero=True, expected_size=0) ++ client = self._client(server) ++ path = self._file('') ++ ++ try: ++ result = client.uploadFileToItem('item', path) ++ except Exception as exc: ++ self.fail('zero-byte upload failed: %s' % exc) ++ self.assertEqual(result, 'file-empty') ++ ++ def test_non_successful_chunk_response_is_an_error(self): ++ class FailingServer(_UploadServer): ++ def request(self, url, params=None, files=None): ++ if url.endswith('/file/chunk'): ++ return _Response(500, {'_id': 'not-a-success'}) ++ return super(FailingServer, self).request(url, params, files) ++ ++ server = FailingServer(expected_size=4) ++ client = self._client(server) ++ path = self._file('data') ++ with self.assertRaises(Exception): ++ client.uploadFileToItem('item', path) ++ ++ def test_missing_initial_id_is_an_error(self): ++ class MissingInitialIdServer(_UploadServer): ++ def request(self, url, params=None, files=None): ++ if url.endswith('/file'): ++ return _Response(200, {'size': self.expected_size}) ++ return super(MissingInitialIdServer, self).request( ++ url, params, files) ++ ++ client = self._client(MissingInitialIdServer(expected_size=4)) ++ path = self._file('data') ++ with self.assertRaises(Exception): ++ client.uploadFileToItem('item', path) ++ ++ def test_missing_final_id_is_an_error(self): ++ class MissingFinalIdServer(_UploadServer): ++ def request(self, url, params=None, files=None): ++ response = super(MissingFinalIdServer, self).request( ++ url, params, files) ++ if url.endswith('/file/chunk'): ++ return _Response(200, {'received': self.offset}) ++ return response ++ ++ client = self._client(MissingFinalIdServer(expected_size=4)) ++ path = self._file('data') ++ with self.assertRaises(Exception): ++ client.uploadFileToItem('item', path) ++ ++ def test_resume_offset_beyond_file_is_an_error(self): ++ server = _UploadServer(offset=20, expected_size=4, resume=True) ++ client = self._client(server) ++ path = self._file('data') ++ with self.assertRaises(Exception): ++ client.uploadFileToItem('item', path, ++ uploadId=server.upload_id) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++python -m unittest -v tests.cases.client_upload_test diff --git a/tasks/format-code-task-001150/tests/test.sh b/tasks/format-code-task-001150/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a65c01eaacb5ee47bfeff7fd2ddb99d43f2f52cc --- /dev/null +++ b/tasks/format-code-task-001150/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/cases/client_upload_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001150/tests/test_command.sh b/tasks/format-code-task-001150/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001150/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001157/environment/Dockerfile b/tasks/format-code-task-001157/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..17c7811e35766aa0d0a6158f1987b9a75fb2153f --- /dev/null +++ b/tasks/format-code-task-001157/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e1c2c4a8ca8a38281520f38a98310069b111a3cac133a89937da9d9fd49466b3 diff --git a/tasks/format-code-task-001157/environment/setup/files/blocklist b/tasks/format-code-task-001157/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001157/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001157/environment/setup/setup.sh b/tasks/format-code-task-001157/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001157/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001157/tests/test.patch b/tasks/format-code-task-001157/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bc047bcfe93729f357e5b8f2e419f1461a47b61c --- /dev/null +++ b/tasks/format-code-task-001157/tests/test.patch @@ -0,0 +1,174 @@ +diff --git a/codespec_sse_configuration_test.go b/codespec_sse_configuration_test.go +new file mode 100644 +index 0000000..cf5cf29 +--- /dev/null ++++ b/codespec_sse_configuration_test.go +@@ -0,0 +1,157 @@ ++//go:build unit ++ ++package mcpgrafana ++ ++import ( ++ "context" ++ "io" ++ "net/http" ++ "net/url" ++ "strings" ++ "testing" ++ ++ httptransport "github.com/go-openapi/runtime/client" ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++) ++ ++type codespecCaptureTransport struct { ++ request *http.Request ++} ++ ++func (c *codespecCaptureTransport) RoundTrip(req *http.Request) (*http.Response, error) { ++ c.request = req.Clone(req.Context()) ++ return &http.Response{ ++ StatusCode: http.StatusOK, ++ Header: http.Header{"Content-Type": []string{"application/json"}}, ++ Body: io.NopCloser(strings.NewReader(`{}`)), ++ Request: req, ++ }, nil ++} ++ ++func codespecAssertEffectiveConfiguration(t *testing.T, ctx context.Context, grafanaURL, apiKey string) { ++ t.Helper() ++ ++ assert.Equal(t, grafanaURL, GrafanaURLFromContext(ctx)) ++ assert.Equal(t, apiKey, GrafanaAPIKeyFromContext(ctx)) ++ ++ grafanaClient := GrafanaClientFromContext(ctx) ++ require.NotNil(t, grafanaClient) ++ runtime, ok := grafanaClient.Transport.(*httptransport.Runtime) ++ require.True(t, ok) ++ capture := &codespecCaptureTransport{} ++ runtime.Transport = capture ++ ++ _, err := grafanaClient.Health.GetHealth() ++ require.NoError(t, err) ++ require.NotNil(t, capture.request) ++ assert.Equal(t, grafanaURL+"/api/health", capture.request.URL.String()) ++ if apiKey == "" { ++ assert.Empty(t, capture.request.Header.Get("Authorization")) ++ } else { ++ assert.Equal(t, "Bearer "+apiKey, capture.request.Header.Get("Authorization")) ++ } ++ ++ incidentClient := IncidentClientFromContext(ctx) ++ require.NotNil(t, incidentClient) ++ assert.Equal(t, grafanaURL+"/api/plugins/grafana-irm-app/resources/api/v1/", incidentClient.RemoteHost) ++ probe, err := http.NewRequest(http.MethodGet, incidentClient.RemoteHost+"probe", nil) ++ require.NoError(t, err) ++ require.NoError(t, incidentClient.BeforeRequest(probe)) ++ if apiKey == "" { ++ assert.Empty(t, probe.Header.Get("Authorization")) ++ } else { ++ assert.Equal(t, "Bearer "+apiKey, probe.Header.Get("Authorization")) ++ } ++} ++ ++func codespecSSEContext(t *testing.T, headers map[string]string) context.Context { ++ t.Helper() ++ req, err := http.NewRequest(http.MethodGet, "http://mcp.example/sse", nil) ++ require.NoError(t, err) ++ for name, value := range headers { ++ req.Header.Set(name, value) ++ } ++ return ComposedSSEContextFunc(context.Background(), req) ++} ++ ++func TestCodespecSSEConfigurationEnvironmentParity(t *testing.T) { ++ t.Setenv("GRAFANA_URL", "http://env.example:3100/tenant/") ++ t.Setenv("GRAFANA_API_KEY", "env-secret") ++ ++ sseCtx := codespecSSEContext(t, nil) ++ codespecAssertEffectiveConfiguration(t, sseCtx, "http://env.example:3100/tenant", "env-secret") ++ ++ stdioCtx := ComposedStdioContextFunc(context.Background()) ++ codespecAssertEffectiveConfiguration(t, stdioCtx, "http://env.example:3100/tenant", "env-secret") ++} ++ ++func TestCodespecSSEConfigurationIndependentHeaderPrecedence(t *testing.T) { ++ t.Setenv("GRAFANA_URL", "https://env.example/env-root/") ++ t.Setenv("GRAFANA_API_KEY", "env-secret") ++ ++ t.Run("URL header overrides only URL", func(t *testing.T) { ++ ctx := codespecSSEContext(t, map[string]string{ ++ "X-Grafana-URL": "http://header.example:3200/header-root/", ++ }) ++ codespecAssertEffectiveConfiguration(t, ctx, "http://header.example:3200/header-root", "env-secret") ++ }) ++ ++ t.Run("API key header overrides only API key", func(t *testing.T) { ++ ctx := codespecSSEContext(t, map[string]string{ ++ "X-Grafana-API-Key": "header-secret", ++ }) ++ codespecAssertEffectiveConfiguration(t, ctx, "https://env.example/env-root", "header-secret") ++ }) ++ ++ t.Run("both headers override both environment values", func(t *testing.T) { ++ ctx := codespecSSEContext(t, map[string]string{ ++ "X-Grafana-URL": "https://other.example/team/", ++ "X-Grafana-API-Key": "other-secret", ++ }) ++ codespecAssertEffectiveConfiguration(t, ctx, "https://other.example/team", "other-secret") ++ }) ++ ++ t.Run("empty headers behave as missing", func(t *testing.T) { ++ ctx := codespecSSEContext(t, map[string]string{ ++ "X-Grafana-URL": "", ++ "X-Grafana-API-Key": "", ++ }) ++ codespecAssertEffectiveConfiguration(t, ctx, "https://env.example/env-root", "env-secret") ++ }) ++} ++ ++func TestCodespecSSEConfigurationDefaultsWithoutCredentials(t *testing.T) { ++ t.Setenv("GRAFANA_URL", "") ++ t.Setenv("GRAFANA_API_KEY", "") ++ ++ ctx := codespecSSEContext(t, nil) ++ codespecAssertEffectiveConfiguration(t, ctx, "http://localhost:3000", "") ++} ++ ++func TestCodespecSSEConfigurationIsRequestScoped(t *testing.T) { ++ t.Setenv("GRAFANA_URL", "http://env.example/base/") ++ t.Setenv("GRAFANA_API_KEY", "env-secret") ++ ++ headerCtx := codespecSSEContext(t, map[string]string{ ++ "X-Grafana-URL": "http://first.example/override/", ++ "X-Grafana-API-Key": "first-secret", ++ }) ++ codespecAssertEffectiveConfiguration(t, headerCtx, "http://first.example/override", "first-secret") ++ ++ plainCtx := codespecSSEContext(t, nil) ++ codespecAssertEffectiveConfiguration(t, plainCtx, "http://env.example/base", "env-secret") ++} ++ ++func TestCodespecSSEConfigurationAcceptsURLWithEscapedPath(t *testing.T) { ++ t.Setenv("GRAFANA_URL", "") ++ t.Setenv("GRAFANA_API_KEY", "") ++ ++ raw := "https://grafana.example/teams%20west/" ++ ctx := codespecSSEContext(t, map[string]string{"X-Grafana-URL": raw}) ++ codespecAssertEffectiveConfiguration(t, ctx, strings.TrimRight(raw, "/"), "") ++ ++ parsed, err := url.Parse(GrafanaURLFromContext(ctx)) ++ require.NoError(t, err) ++ assert.Equal(t, "/teams west", parsed.Path) ++} + +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test -tags unit . -run '^(TestCodespecSSEConfiguration|TestExtractGrafanaInfoFromHeaders|TestExtractGrafanaClientPath|TestExtractIncidentClientFromEnv)' -count=1 diff --git a/tasks/format-code-task-001157/tests/test.sh b/tasks/format-code-task-001157/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c65ff3e13daf36c49825121ae1669578661c756f --- /dev/null +++ b/tasks/format-code-task-001157/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +codespec_sse_configuration_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001157/tests/test_command.sh b/tasks/format-code-task-001157/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001157/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001159/environment/Dockerfile b/tasks/format-code-task-001159/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..139e984326a89d2e18f348f3152dc8e2a46d8495 --- /dev/null +++ b/tasks/format-code-task-001159/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8015cb4380d6e74eb1f6d04ee4d179ce0678254bfb292cb59193cc7458d4a524 diff --git a/tasks/format-code-task-001159/environment/setup/files/blocklist b/tasks/format-code-task-001159/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001159/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001159/environment/setup/setup.sh b/tasks/format-code-task-001159/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001159/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001159/tests/test.patch b/tasks/format-code-task-001159/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9a8e2b89d6c862da9d80333d13a7bc344fe76670 --- /dev/null +++ b/tasks/format-code-task-001159/tests/test.patch @@ -0,0 +1,96 @@ +diff --git a/web/client/utils/ogc/Filter/__tests__/codespec-xml-safety-test.js b/web/client/utils/ogc/Filter/__tests__/codespec-xml-safety-test.js +new file mode 100644 +index 000000000..75f48d88d +--- /dev/null ++++ b/web/client/utils/ogc/Filter/__tests__/codespec-xml-safety-test.js +@@ -0,0 +1,79 @@ ++ ++ ++ ++ ++const expect = require('expect'); ++const FilterBuilder = require('../FilterBuilder'); ++const {DOMParser} = require('xmldom'); ++ ++const parse = (xml) => { ++ const errors = []; ++ const document = new DOMParser({ ++ errorHandler: { ++ warning: message => errors.push(message), ++ error: message => errors.push(message), ++ fatalError: message => errors.push(message) ++ } ++ }).parseFromString(xml, 'text/xml'); ++ expect(errors).toEqual([]); ++ return document; ++}; ++const first = (doc, tag) => doc.getElementsByTagName(tag)[0]; ++ ++describe('FilterBuilder XML-safe serialization', () => { ++ it('escapes caller values in literal and property text nodes', () => { ++ const builder = new FilterBuilder(); ++ const literalXml = builder.literal('A&B "D"'); ++ expect(literalXml.indexOf('A&B')).toBe(-1); ++ const literal = parse(literalXml); ++ expect(literal.documentElement.textContent).toBe('A&B "D"'); ++ const comparisonXml = builder.property('name<&').equalTo('x&y { ++ const builder = new FilterBuilder({filterNS: 'fes'}); ++ const xml = builder.fidFilter('roads"&<1'); ++ expect(xml.indexOf('roads"&<1')).toBe(-1); ++ const doc = parse(xml); ++ expect(first(doc, 'fes:FeatureId')).toExist(); ++ expect(first(doc, 'fes:FeatureId').getAttribute('fid')).toBe('roads"&<1'); ++ }); ++ ++ it('escapes function names and distance units in attributes', () => { ++ const builder = new FilterBuilder(); ++ const fnXml = builder.func('fn"&<', builder.literal('ok')); ++ expect(fnXml.indexOf('fn"&<')).toBe(-1); ++ const fn = parse(fnXml); ++ expect(first(fn, 'ogc:Function')).toExist(); ++ expect(first(fn, 'ogc:Function').getAttribute('name')).toBe('fn"&<'); ++ const distanceXml = builder.property('geom').dwithin({type: 'Point', coordinates: [1, 2]}, 5, 'm"&<'); ++ expect(distanceXml.indexOf('m"&<')).toBe(-1); ++ const distance = parse(distanceXml); ++ expect(first(distance, 'ogc:Distance')).toExist(); ++ expect(first(distance, 'ogc:Distance').getAttribute('units')).toBe('m"&<'); ++ }); ++ ++ it('keeps custom namespaces, WFS 2 value references, and nested composition intact', () => { ++ const builder = new FilterBuilder({filterNS: 'fes', wfsVersion: '2.0'}); ++ const condition = builder.and( ++ builder.property('name<&').equalTo('A&B'), ++ builder.not(builder.property('status').isNull()) ++ ); ++ const xml = builder.filter(condition); ++ expect(xml.indexOf('name<&')).toBe(-1); ++ expect(xml.indexOf('A&B')).toBe(-1); ++ const doc = parse(xml); ++ expect(first(doc, 'fes:ValueReference').textContent).toBe('name<&'); ++ expect(first(doc, 'fes:Literal').textContent).toBe('A&B'); ++ expect(doc.getElementsByTagName('fes:ValueReference')[1].textContent).toBe('status'); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++./node_modules/.bin/mocha \ ++ web/client/utils/ogc/Filter/__tests__/codespec-xml-safety-test.js \ ++ web/client/utils/ogc/Filter/__tests__/FilterBuilder-test.js diff --git a/tasks/format-code-task-001159/tests/test.sh b/tasks/format-code-task-001159/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..80db1449a904ee9435f0bece7c5502b1ed2319b6 --- /dev/null +++ b/tasks/format-code-task-001159/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +web/client/utils/ogc/Filter/__tests__/codespec-xml-safety-test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001159/tests/test_command.sh b/tasks/format-code-task-001159/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001159/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001161/environment/Dockerfile b/tasks/format-code-task-001161/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..35be51e572aae0c786a2a4302ec75e5985022fd7 --- /dev/null +++ b/tasks/format-code-task-001161/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7c18e59544a3580471f65fec23a9bb8f3aa71beee573f5662c3b2745c60a0f30 diff --git a/tasks/format-code-task-001161/environment/setup/files/blocklist b/tasks/format-code-task-001161/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001161/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001161/environment/setup/setup.sh b/tasks/format-code-task-001161/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001161/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001161/tests/test.patch b/tasks/format-code-task-001161/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..90660e82aaf00430adbbe71dd2e40bdab4cea7ba --- /dev/null +++ b/tasks/format-code-task-001161/tests/test.patch @@ -0,0 +1,281 @@ +diff --git a/tests/test_structured_wrapping_codespec.py b/tests/test_structured_wrapping_codespec.py +new file mode 100644 +index 0000000..42f7b6a +--- /dev/null ++++ b/tests/test_structured_wrapping_codespec.py +@@ -0,0 +1,263 @@ ++import subprocess ++import sys ++import tempfile ++from pathlib import Path ++ ++ ++ROOT = Path(__file__).resolve().parents[1] ++ ++ ++def run_formatter(source, *args, structured=False): ++ with tempfile.TemporaryDirectory() as directory: ++ path = Path(directory) / "sample.py" ++ path.write_text(source) ++ command = [sys.executable, "-m", "docformatter", "--in-place"] ++ if structured: ++ config = Path(directory) / "pyproject.toml" ++ config.write_text("[tool.docformatter]\nwrap-structured = true\n") ++ command.extend(["--config", str(config)]) ++ result = subprocess.run( ++ [*command, *args, str(path)], ++ cwd=ROOT, ++ text=True, ++ capture_output=True, ++ ) ++ assert result.returncode in (0, 3), result.stderr ++ return path.read_text() ++ ++ ++def test_structured_mode_wraps_prose_around_directive_but_preserves_body(): ++ source = '''\ ++def render(): ++ """mixed structured description ++ ++ This prose before the directive is deliberately long enough to wrap at the configured width. ++ ++ .. code-block:: python ++ :caption: Keep option spacing ++ ++ result = call_with_a_very_long_argument(first, second) ++ # spacing inside the directive body stays ++ ++ Trailing prose after the directive also needs to wrap instead of being left untouched. ++ """ ++''' ++ expected = '''\ ++def render(): ++ """Mixed structured description. ++ ++ This prose before the directive is deliberately ++ long enough to wrap at the configured width. ++ ++ .. code-block:: python ++ :caption: Keep option spacing ++ ++ result = call_with_a_very_long_argument(first, second) ++ # spacing inside the directive body stays ++ ++ Trailing prose after the directive also needs to ++ wrap instead of being left untouched. ++ """ ++''' ++ formatted = run_formatter( ++ source, "--wrap-descriptions", "52", structured=True ++ ) ++ assert formatted == expected ++ assert ( ++ run_formatter(formatted, "--wrap-descriptions", "52", structured=True) ++ == expected ++ ) ++ ++ ++def test_structured_mode_preserves_literal_and_doctest_regions_and_resumes(): ++ source = '''\ ++def examples(): ++ """structured examples ++ ++ Introductory prose before the literal block should be wrapped without changing the example. ++ ++ Example:: ++ ++ mapping = {"spacing": "must stay", "value": call(argument_one, argument_two)} ++ ++ >>> very_long_function_name(argument_one, argument_two) ++ 123 ++ ++ Closing prose after the interactive example should also wrap to the requested length. ++ """ ++''' ++ expected = '''\ ++def examples(): ++ """Structured examples. ++ ++ Introductory prose before the literal block ++ should be wrapped without changing the example. ++ ++ Example:: ++ ++ mapping = {"spacing": "must stay", "value": call(argument_one, argument_two)} ++ ++ >>> very_long_function_name(argument_one, argument_two) ++ 123 ++ ++ Closing prose after the interactive example ++ should also wrap to the requested length. ++ """ ++''' ++ assert run_formatter(source, "--wrap-descriptions", "52", structured=True) == expected ++ ++ ++def test_structured_mode_wraps_around_but_does_not_reflow_list_items(): ++ source = '''\ ++def choices(): ++ """list-aware description ++ ++ Text before this list is long enough to wrap and demonstrate that list detection is local. ++ ++ * first item keeps its spacing ++ continuation text keeps authored spacing ++ - nested item remains nested ++ * second item remains on its authored line even when it is very long ++ ++ Text after this list is also long enough to wrap and demonstrate that formatting resumes. ++ """ ++''' ++ expected = '''\ ++def choices(): ++ """List-aware description. ++ ++ Text before this list is long enough to wrap and ++ demonstrate that list detection is local. ++ ++ * first item keeps its spacing ++ continuation text keeps authored spacing ++ - nested item remains nested ++ * second item remains on its authored line even when it is very long ++ ++ Text after this list is also long enough to wrap ++ and demonstrate that formatting resumes. ++ """ ++''' ++ assert run_formatter(source, "--wrap-descriptions", "52", structured=True) == expected ++ ++ ++def test_structured_mode_keeps_sphinx_fields_wrappable_next_to_directive(): ++ source = '''\ ++def convert(value): ++ """Convert a value. ++ ++ :param value: This parameter explanation is deliberately long enough that the normal Sphinx field formatter must wrap it. ++ ++ .. warning:: Keep this directive body untouched even though it is long and appears here. ++ ++ :returns: This return explanation is also deliberately long enough to wrap after the protected directive. ++ """ ++''' ++ expected = '''\ ++def convert(value): ++ """Convert a value. ++ ++ :param value: This parameter explanation is ++ deliberately long enough that the normal ++ Sphinx field formatter must wrap it. ++ ++ .. warning:: Keep this directive body untouched even though it is long and appears here. ++ ++ :returns: This return explanation is also ++ deliberately long enough to wrap after the ++ protected directive. ++ """ ++''' ++ assert run_formatter(source, "--wrap-descriptions", "52", structured=True) == expected ++ ++ ++def test_structured_mode_can_be_enabled_from_pyproject_configuration(): ++ source = '''\ ++def configured(): ++ """configured behavior ++ ++ This prose is long enough to prove that configuration enables structured wrapping around directives. ++ ++ .. note:: Keep this directive line unchanged. ++ """ ++''' ++ with tempfile.TemporaryDirectory() as directory: ++ config = Path(directory) / "pyproject.toml" ++ config.write_text("[tool.docformatter]\nwrap-structured = true\nwrap-descriptions = 52\n") ++ with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as handle: ++ handle.write(source) ++ path = Path(handle.name) ++ try: ++ result = subprocess.run( ++ [ ++ sys.executable, ++ "-m", ++ "docformatter", ++ "--in-place", ++ "--config", ++ str(config), ++ str(path), ++ ], ++ cwd=ROOT, ++ text=True, ++ capture_output=True, ++ ) ++ assert result.returncode in (0, 3), result.stderr ++ assert path.read_text() == '''\ ++def configured(): ++ """Configured behavior. ++ ++ This prose is long enough to prove that ++ configuration enables structured wrapping around ++ directives. ++ ++ .. note:: Keep this directive line unchanged. ++ """ ++''' ++ finally: ++ path.unlink() ++ ++ ++def test_structured_mode_is_available_as_a_command_line_option(): ++ source = '''\ ++def cli(): ++ """cli behavior ++ ++ This prose is deliberately long enough to wrap before the protected directive marker. ++ ++ .. note:: Keep this line unchanged. ++ """ ++''' ++ expected = '''\ ++def cli(): ++ """Cli behavior. ++ ++ This prose is deliberately long enough to wrap ++ before the protected directive marker. ++ ++ .. note:: Keep this line unchanged. ++ """ ++''' ++ assert ( ++ run_formatter( ++ source, ++ "--wrap-structured", ++ "--wrap-descriptions", ++ "52", ++ ) ++ == expected ++ ) ++ ++ ++def test_default_mode_retains_cautious_directive_behavior(): ++ source = '''\ ++def unchanged(): ++ """mixed description ++ ++ This prose is deliberately long and would be wrapped if structured mode were enabled. ++ ++ .. note:: Existing default behavior keeps this document untouched. ++ """ ++''' ++ expected = source.replace('"""mixed description', '"""Mixed description.') ++ assert run_formatter(source, "--wrap-descriptions", "52") == expected +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,7 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++/root/.venv/bin/pytest -q \ ++ tests/test_structured_wrapping_codespec.py \ ++ tests/formatter/test_do_format_docstring.py::TestFormatDocstring::test_format_docstring_leave_directive_alone diff --git a/tasks/format-code-task-001161/tests/test.sh b/tasks/format-code-task-001161/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ba612dc8b6c2e3eb3934e2aa0924fedaafc85cf --- /dev/null +++ b/tasks/format-code-task-001161/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_structured_wrapping_codespec.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001161/tests/test_command.sh b/tasks/format-code-task-001161/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001161/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001166/environment/Dockerfile b/tasks/format-code-task-001166/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0f3838cc6b656daaa8760edce25f66fdd5890acd --- /dev/null +++ b/tasks/format-code-task-001166/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5016a21081becc8962e71998cccd94ab2520e056ae89d2c6311c4922b14295c7 diff --git a/tasks/format-code-task-001166/environment/setup/files/blocklist b/tasks/format-code-task-001166/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001166/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001166/environment/setup/setup.sh b/tasks/format-code-task-001166/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001166/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001166/tests/test.patch b/tasks/format-code-task-001166/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9cb2910bd0ec2359f97421731c8930b8889cc728 --- /dev/null +++ b/tasks/format-code-task-001166/tests/test.patch @@ -0,0 +1,115 @@ +diff --git a/test/codespec-import-bindings.mjs b/test/codespec-import-bindings.mjs +new file mode 100644 +index 00000000..e87a0e14 +--- /dev/null ++++ b/test/codespec-import-bindings.mjs +@@ -0,0 +1,99 @@ ++import assert from 'node:assert/strict'; ++import {ESLint} from 'eslint'; ++import plugin from '../src/index.js'; ++ ++const lint = async (code, filePath) => { ++ const eslint = new ESLint({ ++ overrideConfigFile: true, ++ overrideConfig: { ++ files: ['**/*'], ++ plugins: {jsdoc: plugin}, ++ rules: { ++ 'jsdoc/check-values': 'error', ++ 'jsdoc/no-undefined-types': 'error', ++ }, ++ settings: {jsdoc: {mode: 'typescript'}}, ++ }, ++ }); ++ const [result] = await eslint.lintText(code, {filePath}); ++ return result.messages; ++}; ++ ++const ruleMessages = (messages, ruleId) => { ++ return messages.filter(({ruleId: currentRule}) => currentRule === ruleId); ++}; ++ ++ ++ ++{ ++ const messages = await lint( ++ "/** @import { ExternalName as LocalName, OtherName } from 'pkg' */\n" + ++ '/** @type {LocalName} */\nconst first = null;\n' + ++ '/** @type {OtherName} */\nconst second = null;', ++ 'codespec-named.js', ++ ); ++ assert.deepEqual(ruleMessages(messages, 'jsdoc/check-values'), []); ++ assert.deepEqual(ruleMessages(messages, 'jsdoc/no-undefined-types'), []); ++} ++ ++ ++ ++{ ++ const messages = await lint( ++ "/** @import DefaultType, { NamedType as LocalNamed } from 'pkg' */\n" + ++ "/** @import * as Namespace from 'pkg' */\n" + ++ '/** @type {DefaultType} */\nconst first = null;\n' + ++ '/** @type {LocalNamed} */\nconst named = null;\n' + ++ '/** @type {Namespace.Member} */\nconst second = null;', ++ 'codespec-default-namespace.js', ++ ); ++ assert.deepEqual(ruleMessages(messages, 'jsdoc/check-values'), []); ++ assert.deepEqual(ruleMessages(messages, 'jsdoc/no-undefined-types'), []); ++} ++ ++ ++{ ++ const messages = await lint( ++ "/** @import type TypeOnly, { ExternalType as LocalType } from 'pkg' */\n" + ++ '/** @type {TypeOnly} */\nconst first = null;\n' + ++ '/** @type {LocalType} */\nconst second = null;', ++ 'codespec-type-only.js', ++ ); ++ assert.deepEqual(ruleMessages(messages, 'jsdoc/check-values'), []); ++ assert.deepEqual(ruleMessages(messages, 'jsdoc/no-undefined-types'), []); ++} ++ ++ ++{ ++ const messages = await lint( ++ "/** @import { ExternalType as LocalType } from 'pkg' */\n" + ++ '/** @type {ExternalType} */\nconst value = null;', ++ 'codespec-alias-scope.js', ++ ); ++ const undefinedMessages = ruleMessages(messages, 'jsdoc/no-undefined-types'); ++ assert.equal(undefinedMessages.length, 1); ++ assert.equal(undefinedMessages[0].message, "The type 'ExternalType' is undefined."); ++} ++ ++ ++{ ++ const messages = await lint( ++ "/** @import { MissingName from 'pkg' */\nconst value = null;", ++ 'codespec-malformed.js', ++ ); ++ assert.equal(ruleMessages(messages, 'jsdoc/check-values').length, 1); ++ assert.equal(ruleMessages(messages, 'jsdoc/check-values')[0].message, 'Bad @import tag'); ++} ++ ++ ++{ ++ const messages = await lint( ++ '/**\n * @import { ExistingName } from \'pkg\'\n */\n' + ++ '/** @type {ExistingName} */\nconst value = null;', ++ 'codespec-multiline.js', ++ ); ++ assert.deepEqual(ruleMessages(messages, 'jsdoc/check-values'), []); ++ assert.deepEqual(ruleMessages(messages, 'jsdoc/no-undefined-types'), []); ++} ++ ++console.log('codespec import binding checks passed'); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++node test/codespec-import-bindings.mjs diff --git a/tasks/format-code-task-001166/tests/test.sh b/tasks/format-code-task-001166/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5295b8130b0e5e6c98be317640932cf1f8f1ace7 --- /dev/null +++ b/tasks/format-code-task-001166/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/codespec-import-bindings.mjs +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001166/tests/test_command.sh b/tasks/format-code-task-001166/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001166/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001168/environment/Dockerfile b/tasks/format-code-task-001168/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..55d3b9880a451e4a526cc951fcec0b0b0e4429e6 --- /dev/null +++ b/tasks/format-code-task-001168/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ce0ac4f5c3258af2da08980574b45de56e82ef76a92730ec2fd78faf44b9483f diff --git a/tasks/format-code-task-001168/environment/setup/files/blocklist b/tasks/format-code-task-001168/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001168/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001168/environment/setup/setup.sh b/tasks/format-code-task-001168/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001168/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001168/tests/test.patch b/tasks/format-code-task-001168/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ba9f9e80bac087e45204799b0a7e26181b54db2 --- /dev/null +++ b/tasks/format-code-task-001168/tests/test.patch @@ -0,0 +1,161 @@ +diff --git a/tests/tracking/test_log_table_modes_codespec.py b/tests/tracking/test_log_table_modes_codespec.py +new file mode 100644 +index 000000000..5f272c48b +--- /dev/null ++++ b/tests/tracking/test_log_table_modes_codespec.py +@@ -0,0 +1,142 @@ ++import json ++ ++import pandas as pd ++import pytest ++ ++import mlflow ++from mlflow import MlflowClient ++from mlflow.exceptions import MlflowException ++from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE, ErrorCode ++from mlflow.utils.mlflow_tags import MLFLOW_LOGGED_ARTIFACTS ++ ++ ++ARTIFACT_FILE = "reports/evaluation.json" ++ ++ ++def _load_persisted_table(run_id): ++ path = mlflow.artifacts.download_artifacts(run_id=run_id, artifact_path=ARTIFACT_FILE) ++ return pd.read_json(path, orient="split") ++ ++ ++def _logged_artifacts(run_id): ++ value = mlflow.get_run(run_id).data.tags.get(MLFLOW_LOGGED_ARTIFACTS, "[]") ++ return json.loads(value) ++ ++ ++def _assert_invalid_parameter(exc_info): ++ assert exc_info.value.error_code == ErrorCode.Name(INVALID_PARAMETER_VALUE) ++ ++ ++def test_default_append_aligns_columns_and_keeps_one_table_tag(): ++ first = pd.DataFrame({"feature": ["a", "b"], "score": [1, 2]}) ++ reordered = pd.DataFrame({"score": [3], "feature": ["c"]}) ++ explicit = {"score": [4], "feature": ["d"]} ++ ++ with mlflow.start_run() as run: ++ mlflow.log_table(first, ARTIFACT_FILE) ++ mlflow.log_table(reordered, ARTIFACT_FILE) ++ mlflow.log_table(explicit, ARTIFACT_FILE, mode="append") ++ ++ expected = pd.DataFrame({"feature": ["a", "b", "c", "d"], "score": [1, 2, 3, 4]}) ++ pd.testing.assert_frame_equal(_load_persisted_table(run.info.run_id), expected) ++ assert _logged_artifacts(run.info.run_id) == [ ++ {"path": ARTIFACT_FILE, "type": "table"} ++ ] ++ ++ ++@pytest.mark.parametrize( ++ "incompatible", ++ [ ++ pd.DataFrame({"feature": ["c"]}), ++ pd.DataFrame({"feature": ["c"], "score": [3], "note": ["new"]}), ++ ], ++ ids=["missing-column", "extra-column"], ++) ++def test_append_schema_mismatch_is_atomic(incompatible): ++ original = pd.DataFrame({"feature": ["a"], "score": [1]}) ++ ++ with mlflow.start_run() as run: ++ mlflow.log_table(original, ARTIFACT_FILE) ++ tags_before = _logged_artifacts(run.info.run_id) ++ with pytest.raises(MlflowException, match="(?i)column|schema") as exc_info: ++ mlflow.log_table(incompatible, ARTIFACT_FILE, mode="append") ++ ++ _assert_invalid_parameter(exc_info) ++ pd.testing.assert_frame_equal(_load_persisted_table(run.info.run_id), original) ++ assert _logged_artifacts(run.info.run_id) == tags_before ++ ++ ++def test_overwrite_replaces_rows_and_schema_through_fluent_api(): ++ with mlflow.start_run() as run: ++ mlflow.log_table( ++ pd.DataFrame({"feature": ["old"], "score": [1]}), ++ ARTIFACT_FILE, ++ ) ++ replacement = pd.DataFrame({"replacement": [True, False], "rank": [9, 10]}) ++ mlflow.log_table(replacement, ARTIFACT_FILE, mode="overwrite") ++ ++ pd.testing.assert_frame_equal(_load_persisted_table(run.info.run_id), replacement) ++ assert _logged_artifacts(run.info.run_id) == [ ++ {"path": ARTIFACT_FILE, "type": "table"} ++ ] ++ ++ ++def test_error_if_exists_preserves_artifact_through_client_api(): ++ client = MlflowClient() ++ run = client.create_run("0") ++ original = pd.DataFrame({"feature": ["existing"], "score": [4]}) ++ client.log_table(run.info.run_id, original, ARTIFACT_FILE) ++ tags_before = _logged_artifacts(run.info.run_id) ++ ++ with pytest.raises(MlflowException, match="(?i)exist") as exc_info: ++ client.log_table( ++ run.info.run_id, ++ pd.DataFrame({"feature": ["new"], "score": [5]}), ++ ARTIFACT_FILE, ++ mode="error_if_exists", ++ ) ++ ++ _assert_invalid_parameter(exc_info) ++ pd.testing.assert_frame_equal(_load_persisted_table(run.info.run_id), original) ++ assert _logged_artifacts(run.info.run_id) == tags_before ++ ++ ++@pytest.mark.parametrize("mode", ["append", "overwrite", "error_if_exists"]) ++def test_each_mode_creates_a_new_table_when_artifact_is_absent(mode): ++ client = MlflowClient() ++ run = client.create_run("0") ++ table = {"mode": [mode], "value": [0]} ++ ++ client.log_table(run.info.run_id, table, ARTIFACT_FILE, mode=mode) ++ ++ pd.testing.assert_frame_equal(_load_persisted_table(run.info.run_id), pd.DataFrame(table)) ++ assert _logged_artifacts(run.info.run_id) == [ ++ {"path": ARTIFACT_FILE, "type": "table"} ++ ] ++ ++ ++@pytest.mark.parametrize("mode", ["append", "overwrite", "error_if_exists"]) ++def test_fluent_api_accepts_each_mode_for_a_new_table(mode): ++ table = {"mode": [mode], "value": [1]} ++ ++ with mlflow.start_run() as run: ++ mlflow.log_table(table, ARTIFACT_FILE, mode=mode) ++ ++ pd.testing.assert_frame_equal(_load_persisted_table(run.info.run_id), pd.DataFrame(table)) ++ ++ ++def test_invalid_mode_fails_before_artifact_or_tag_creation(): ++ client = MlflowClient() ++ run = client.create_run("0") ++ ++ with pytest.raises(MlflowException, match="(?i)mode") as exc_info: ++ client.log_table( ++ run.info.run_id, ++ pd.DataFrame({"feature": ["a"]}), ++ ARTIFACT_FILE, ++ mode="replace", ++ ) ++ ++ _assert_invalid_parameter(exc_info) ++ assert client.list_artifacts(run.info.run_id) == [] ++ assert MLFLOW_LOGGED_ARTIFACTS not in mlflow.get_run(run.info.run_id).data.tags +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++.venv/bin/pytest -q \ ++ tests/tracking/test_log_table_modes_codespec.py \ ++ tests/tracking/test_tracking.py::test_log_table \ ++ tests/tracking/test_tracking.py::test_log_table_with_subdirectory diff --git a/tasks/format-code-task-001168/tests/test.sh b/tasks/format-code-task-001168/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e63df45b9422803f57f93a40fc382c1d83d641e6 --- /dev/null +++ b/tasks/format-code-task-001168/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/tracking/test_log_table_modes_codespec.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001168/tests/test_command.sh b/tasks/format-code-task-001168/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001168/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001192/environment/Dockerfile b/tasks/format-code-task-001192/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..64ab214e388a44b558af8715241a042ce59e7a89 --- /dev/null +++ b/tasks/format-code-task-001192/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b37f3dbda472ce5abc0b1074cc2e963ba01315a56486e97ab1e2e1102f601802 diff --git a/tasks/format-code-task-001192/environment/setup/files/blocklist b/tasks/format-code-task-001192/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001192/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001192/environment/setup/setup.sh b/tasks/format-code-task-001192/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001192/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001192/tests/test.patch b/tasks/format-code-task-001192/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..289c8026a73377fa8362931eb9cf7bdae5bf5f00 --- /dev/null +++ b/tasks/format-code-task-001192/tests/test.patch @@ -0,0 +1,48 @@ +diff --git a/definitions/npm/rxjs_v5.0.x/test_rxjs.js b/definitions/npm/rxjs_v5.0.x/test_rxjs.js +index 5916aec6b2..ad6bc6b05a 100644 +--- a/definitions/npm/rxjs_v5.0.x/test_rxjs.js ++++ b/definitions/npm/rxjs_v5.0.x/test_rxjs.js +@@ -48,6 +48,12 @@ numbers.letBind(_numbers => 3); + // $ExpectError -- .switch can't assert that it's operating on observables, but it can at least trace the type. + (numbers.map(number => Observable.of(number)).switch(): Observable); + ++let dualNumbers = Observable.of(numbers, numbers); ++(dualNumbers.combineAll(): Observable<[number, number]>); ++// $ExpectError -- should return an Observable ++(dualNumbers.combineAll((a, b) => `${a}-${b}`): Observable); ++(dualNumbers.combineAll((a, b) => `${a}-${b}`): Observable); ++ + const combined: Observable<{ n: number, s: string }> = Observable.combineLatest( + numbers, + strings, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,15 @@ ++H4sIAAAAAAAAA+2UbW/TMBDH+9qf4hYqtiHlod3CJEYHbMsgUrWhUh6kZYrSxGm9pXawna4T47tj ++J13XTTB4AUII//IiD7673P/OZ2dUkSKLMZ25rT+Fp9jx/fquuH+vnzt+1+tu+dtdb6vldTr+jt8C ++/49ltEIlZMIBWpwx+ZDdz9b/UZzb/kssZJyy6TShmSMmv+8fP+l/t9td9l9dHdX/7acdrwXe70vh ++x/zn/X+05o4IdUeJmKA0g3oTjHCG0CMIqSpNUUBesEtbGcG4YCP14QpIDpRJKDkWmEp01D/5GH8I ++jg9PBj3LZaV0Kcuw3fXcgozq53jKsqrAwr2J5c4wzRiv3y2k4p3CGthzsNorwSw42wU5wRQB0HIK ++ZJGQPV7m9NJznm47HnT3HndQTppU9sPj3t1AWs4HzEl+VXuC8kz4FVwyfiHQwlR5WTDDXBBG4foa ++vgBOJwysYDA4GTy746fFa19Cx9Yu4DmR0NmFr/ovbxM5Eagf7h8GR/HbV8M3qiKLmroZzgklUsUX ++rtLj8vm5iGe+4znzuhDxzHO2tp25vbrinAsLDYN3w/go7Ae/GK0eZf2h9n4/DPsP5RLHlSRFHLsy ++y+KcJ1OsxdWuStEBx4nEIPG0BO0NGeE4lYxfNWkdhoNee2N6URvY2SaSPCnB4lOweQ7tGxsLgk/h ++sA7IStUGorYDSpVhe6VYlnq9cXCtZnmp/XuLS2n3FtVvPnKi0nZ0YVNGczKGDaGkQSLgcpJIvbHg ++oB/CGFPMlUIBOeNNm/d64Dn+1iZKld3eauSVcBY8f76ud87ByfFR+HodnardLs7Q3d6h+zVF6FRN ++iK77GRJVqWdI1KeumqReFG04UXQd0SjafBJF7WBeqlIHnDOOCE2LSo3SZcKp2niiJ3mFVTQypozj ++M3SbilY/qGijJZ3g9GIhfXG4L6VXQqkmVGJO9Vxv3hmFxtG2heSktPXxp170+N2Ww0KD4N37/rDX ++foGaIW43H8DGn8FbGd9mlF4pb72FBJSJEDhbs/TM1vOzcER/+zw0GAwGg8FgMBgMBoPBYDAYDAaD ++wWAwGAwGg+Ff5Bv2/5yXACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++# Verifier for the opensource-code dataset. Exit 0 means resolved. ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001192/tests/test.sh b/tasks/format-code-task-001192/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4df486fe5d1edd22dade55cd37007fb2bf5cf4f3 --- /dev/null +++ b/tasks/format-code-task-001192/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +definitions/npm/rxjs_v5.0.x/test_rxjs.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001192/tests/test_command.sh b/tasks/format-code-task-001192/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001192/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001195/environment/Dockerfile b/tasks/format-code-task-001195/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..07445e19c96a25a9206128ce1e55ec00ec24109c --- /dev/null +++ b/tasks/format-code-task-001195/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:903c2b51269769d15c620d5f27511370903d4ef7ec62c987d64730291dc0d30a diff --git a/tasks/format-code-task-001195/environment/setup/files/blocklist b/tasks/format-code-task-001195/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001195/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001195/environment/setup/setup.sh b/tasks/format-code-task-001195/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001195/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001195/tests/test.patch b/tasks/format-code-task-001195/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..99cab49bcf8146631cee6a244554360d4f60aba3 --- /dev/null +++ b/tasks/format-code-task-001195/tests/test.patch @@ -0,0 +1,7722 @@ +diff --git a/usercase-test-coderl/fixtures/flux-manifests/helm-controller.crds.yaml b/usercase-test-coderl/fixtures/flux-manifests/helm-controller.crds.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/helm-controller.crds.yaml +@@ -0,0 +1,1486 @@ ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: helmreleases.helm.toolkit.fluxcd.io ++spec: ++ group: helm.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-appliers ++ kind: HelmRelease ++ listKind: HelmReleaseList ++ plural: helmreleases ++ shortNames: ++ - hr ++ singular: helmrelease ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ name: v2 ++ schema: ++ openAPIV3Schema: ++ description: HelmRelease is the Schema for the helmreleases API ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: HelmReleaseSpec defines the desired state of a Helm release. ++ properties: ++ chart: ++ description: |- ++ Chart defines the template of the v1.HelmChart that should be created ++ for this HelmRelease. ++ properties: ++ metadata: ++ description: ObjectMeta holds the template for metadata like labels ++ and annotations. ++ properties: ++ annotations: ++ additionalProperties: ++ type: string ++ description: |- ++ Annotations is an unstructured key value map stored with a resource that may be ++ set by external tools to store and retrieve arbitrary metadata. They are not ++ queryable and should be preserved when modifying objects. ++ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ ++ type: object ++ labels: ++ additionalProperties: ++ type: string ++ description: |- ++ Map of string keys and values that can be used to organize and categorize ++ (scope and select) objects. ++ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ ++ type: object ++ type: object ++ spec: ++ description: Spec holds the template for the v1.HelmChartSpec ++ for this HelmRelease. ++ properties: ++ chart: ++ description: The name or path the Helm chart is available ++ at in the SourceRef. ++ maxLength: 2048 ++ minLength: 1 ++ type: string ++ ignoreMissingValuesFiles: ++ description: IgnoreMissingValuesFiles controls whether to ++ silently ignore missing values files rather than failing. ++ type: boolean ++ interval: ++ description: |- ++ Interval at which to check the v1.Source for updates. Defaults to ++ 'HelmReleaseSpec.Interval'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ reconcileStrategy: ++ default: ChartVersion ++ description: |- ++ Determines what enables the creation of a new artifact. Valid values are ++ ('ChartVersion', 'Revision'). ++ See the documentation of the values for an explanation on their behavior. ++ Defaults to ChartVersion when omitted. ++ enum: ++ - ChartVersion ++ - Revision ++ type: string ++ sourceRef: ++ description: The name and namespace of the v1.Source the chart ++ is available at. ++ properties: ++ apiVersion: ++ description: APIVersion of the referent. ++ type: string ++ kind: ++ description: Kind of the referent. ++ enum: ++ - HelmRepository ++ - GitRepository ++ - Bucket ++ type: string ++ name: ++ description: Name of the referent. ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ namespace: ++ description: Namespace of the referent. ++ maxLength: 63 ++ minLength: 1 ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ valuesFiles: ++ description: |- ++ Alternative list of values files to use as the chart values (values.yaml ++ is not included by default), expected to be a relative path in the SourceRef. ++ Values files are merged in the order of this list with the last file overriding ++ the first. Ignored when omitted. ++ items: ++ type: string ++ type: array ++ verify: ++ description: |- ++ Verify contains the secret name containing the trusted public keys ++ used to verify the signature and specifies which provider to use to check ++ whether OCI image is authentic. ++ This field is only supported for OCI sources. ++ Chart dependencies, which are not bundled in the umbrella chart artifact, ++ are not verified. ++ properties: ++ provider: ++ default: cosign ++ description: Provider specifies the technology used to ++ sign the OCI Helm chart. ++ enum: ++ - cosign ++ - notation ++ type: string ++ secretRef: ++ description: |- ++ SecretRef specifies the Kubernetes Secret containing the ++ trusted public keys. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ required: ++ - provider ++ type: object ++ version: ++ default: '*' ++ description: |- ++ Version semver expression, ignored for charts from v1.GitRepository and ++ v1beta2.Bucket sources. Defaults to latest when omitted. ++ type: string ++ required: ++ - chart ++ - sourceRef ++ type: object ++ required: ++ - spec ++ type: object ++ chartRef: ++ description: |- ++ ChartRef holds a reference to a source controller resource containing the ++ Helm chart artifact. ++ properties: ++ apiVersion: ++ description: APIVersion of the referent. ++ type: string ++ kind: ++ description: Kind of the referent. ++ enum: ++ - OCIRepository ++ - HelmChart ++ - ExternalArtifact ++ type: string ++ name: ++ description: Name of the referent. ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ namespace: ++ description: |- ++ Namespace of the referent, defaults to the namespace of the Kubernetes ++ resource object that contains the reference. ++ maxLength: 63 ++ minLength: 1 ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ commonMetadata: ++ description: |- ++ CommonMetadata specifies the common labels and annotations that are ++ applied to all resources. Any existing label or annotation will be ++ overridden if its key matches a common one. ++ properties: ++ annotations: ++ additionalProperties: ++ type: string ++ description: Annotations to be added to the object's metadata. ++ type: object ++ labels: ++ additionalProperties: ++ type: string ++ description: Labels to be added to the object's metadata. ++ type: object ++ type: object ++ dependsOn: ++ description: |- ++ DependsOn may contain a DependencyReference slice with ++ references to HelmRelease resources that must be ready before this HelmRelease ++ can be reconciled. ++ items: ++ description: |- ++ DependencyReference contains enough information to locate the referenced Kubernetes resource object ++ and optional CEL expression to assess its readiness. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ namespace: ++ description: |- ++ Namespace of the referent, defaults to the namespace of the resource ++ object that contains the reference. ++ type: string ++ readyExpr: ++ description: |- ++ ReadyExpr is a CEL expression that can be used to assess the readiness ++ of a dependency. When specified, the built-in readiness check ++ is replaced by the logic defined in the CEL expression. ++ To make the CEL expression additive to the built-in readiness check, ++ the feature gate `AdditiveCELDependencyCheck` must be set to `true`. ++ type: string ++ required: ++ - name ++ type: object ++ type: array ++ driftDetection: ++ description: |- ++ DriftDetection holds the configuration for detecting and handling ++ differences between the manifest in the Helm storage and the resources ++ currently existing in the cluster. ++ properties: ++ ignore: ++ description: |- ++ Ignore contains a list of rules for specifying which changes to ignore ++ during diffing. ++ items: ++ description: |- ++ IgnoreRule defines a rule to selectively disregard specific changes during ++ the drift detection process. ++ properties: ++ paths: ++ description: |- ++ Paths is a list of JSON Pointer (RFC 6901) paths to be excluded from ++ consideration in a Kubernetes object. ++ items: ++ type: string ++ type: array ++ target: ++ description: |- ++ Target is a selector for specifying Kubernetes objects to which this ++ rule applies. ++ If Target is not set, the Paths will be ignored for all Kubernetes ++ objects within the manifest of the Helm release. ++ properties: ++ annotationSelector: ++ description: |- ++ AnnotationSelector is a string that follows the label selection expression ++ https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api ++ It matches with the resource annotations. ++ type: string ++ group: ++ description: |- ++ Group is the API group to select resources from. ++ Together with Version and Kind it is capable of unambiguously identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ kind: ++ description: |- ++ Kind of the API Group to select resources from. ++ Together with Group and Version it is capable of unambiguously ++ identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ labelSelector: ++ description: |- ++ LabelSelector is a string that follows the label selection expression ++ https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api ++ It matches with the resource labels. ++ type: string ++ name: ++ description: Name to match resources with. ++ type: string ++ namespace: ++ description: Namespace to select resources from. ++ type: string ++ version: ++ description: |- ++ Version of the API Group to select resources from. ++ Together with Group and Kind it is capable of unambiguously identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ type: object ++ required: ++ - paths ++ type: object ++ type: array ++ mode: ++ description: |- ++ Mode defines how differences should be handled between the Helm manifest ++ and the manifest currently applied to the cluster. ++ If not explicitly set, it defaults to DiffModeDisabled. ++ enum: ++ - enabled ++ - warn ++ - disabled ++ type: string ++ type: object ++ healthCheckExprs: ++ description: |- ++ HealthCheckExprs is a list of healthcheck expressions for evaluating the ++ health of custom resources using Common Expression Language (CEL). ++ The expressions are evaluated only when the specific Helm action ++ taking place has wait enabled, i.e. DisableWait is false, and the ++ 'poller' WaitStrategy is used. ++ items: ++ description: CustomHealthCheck defines the health check for custom ++ resources. ++ properties: ++ apiVersion: ++ description: APIVersion of the custom resource under evaluation. ++ type: string ++ current: ++ description: |- ++ Current is the CEL expression that determines if the status ++ of the custom resource has reached the desired state. ++ type: string ++ failed: ++ description: |- ++ Failed is the CEL expression that determines if the status ++ of the custom resource has failed to reach the desired state. ++ type: string ++ inProgress: ++ description: |- ++ InProgress is the CEL expression that determines if the status ++ of the custom resource has not yet reached the desired state. ++ type: string ++ kind: ++ description: Kind of the custom resource under evaluation. ++ type: string ++ required: ++ - apiVersion ++ - current ++ type: object ++ type: array ++ install: ++ description: Install holds the configuration for Helm install actions ++ for this HelmRelease. ++ properties: ++ crds: ++ description: |- ++ CRDs upgrade CRDs from the Helm Chart's crds directory according ++ to the CRD upgrade policy provided here. Valid values are `Skip`, ++ `Create` or `CreateReplace`. Default is `Create` and if omitted ++ CRDs are installed but not updated. ++ ++ Skip: do neither install nor replace (update) any CRDs. ++ ++ Create: new CRDs are created, existing CRDs are neither updated nor deleted. ++ ++ CreateReplace: new CRDs are created, existing CRDs are updated (replaced) ++ but not deleted. ++ ++ By default, CRDs are applied (installed) during Helm install action. ++ With this option users can opt in to CRD replace existing CRDs on Helm ++ install actions, which is not (yet) natively supported by Helm. ++ https://helm.sh/docs/chart_best_practices/custom_resource_definitions. ++ enum: ++ - Skip ++ - Create ++ - CreateReplace ++ type: string ++ createNamespace: ++ description: |- ++ CreateNamespace tells the Helm install action to create the ++ HelmReleaseSpec.TargetNamespace if it does not exist yet. ++ On uninstall, the namespace will not be garbage collected. ++ type: boolean ++ disableHooks: ++ description: DisableHooks prevents hooks from running during the ++ Helm install action. ++ type: boolean ++ disableOpenAPIValidation: ++ description: |- ++ DisableOpenAPIValidation prevents the Helm install action from validating ++ rendered templates against the Kubernetes OpenAPI Schema. ++ type: boolean ++ disableSchemaValidation: ++ description: |- ++ DisableSchemaValidation prevents the Helm install action from validating ++ the values against the JSON Schema. ++ type: boolean ++ disableTakeOwnership: ++ description: |- ++ DisableTakeOwnership disables taking ownership of existing resources ++ during the Helm install action. Defaults to false. ++ type: boolean ++ disableWait: ++ description: |- ++ DisableWait disables the waiting for resources to be ready after a Helm ++ install has been performed. ++ type: boolean ++ disableWaitForJobs: ++ description: |- ++ DisableWaitForJobs disables waiting for jobs to complete after a Helm ++ install has been performed. ++ type: boolean ++ remediation: ++ description: |- ++ Remediation holds the remediation configuration for when the Helm install ++ action for the HelmRelease fails. The default is to not perform any action. ++ properties: ++ ignoreTestFailures: ++ description: |- ++ IgnoreTestFailures tells the controller to skip remediation when the Helm ++ tests are run after an install action but fail. Defaults to ++ 'Test.IgnoreFailures'. ++ type: boolean ++ remediateLastFailure: ++ description: |- ++ RemediateLastFailure tells the controller to remediate the last failure, when ++ no retries remain. Defaults to 'false'. ++ type: boolean ++ retries: ++ description: |- ++ Retries is the number of retries that should be attempted on failures before ++ bailing. Remediation, using an uninstall, is performed between each attempt. ++ Defaults to '0', a negative integer equals to unlimited retries. ++ type: integer ++ type: object ++ replace: ++ description: |- ++ Replace tells the Helm install action to re-use the 'ReleaseName', but only ++ if that name is a deleted release which remains in the history. ++ type: boolean ++ serverSideApply: ++ description: |- ++ ServerSideApply enables server-side apply for resources during install. ++ Defaults to true (or false when UseHelm3Defaults feature gate is enabled). ++ type: boolean ++ skipCRDs: ++ description: |- ++ SkipCRDs tells the Helm install action to not install any CRDs. By default, ++ CRDs are installed if not already present. ++ ++ Deprecated use CRD policy (`crds`) attribute with value `Skip` instead. ++ type: boolean ++ strategy: ++ description: |- ++ Strategy defines the install strategy to use for this HelmRelease. ++ Defaults to 'RemediateOnFailure', or 'RetryOnFailure' when the ++ DefaultToRetryOnFailure feature gate is enabled. ++ properties: ++ name: ++ description: Name of the install strategy. ++ enum: ++ - RemediateOnFailure ++ - RetryOnFailure ++ type: string ++ retryInterval: ++ description: |- ++ RetryInterval is the interval at which to retry a failed install. ++ Can be used only when Name is set to RetryOnFailure. ++ Defaults to '5m'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ required: ++ - name ++ type: object ++ x-kubernetes-validations: ++ - message: .retryInterval cannot be set when .name is 'RemediateOnFailure' ++ rule: '!has(self.retryInterval) || self.name != ''RemediateOnFailure''' ++ timeout: ++ description: |- ++ Timeout is the time to wait for any individual Kubernetes operation (like ++ Jobs for hooks) during the performance of a Helm install action. Defaults to ++ 'HelmReleaseSpec.Timeout'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ type: object ++ interval: ++ description: Interval at which to reconcile the Helm release. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ kubeConfig: ++ description: |- ++ KubeConfig for reconciling the HelmRelease on a remote cluster. ++ When used in combination with HelmReleaseSpec.ServiceAccountName, ++ forces the controller to act on behalf of that Service Account at the ++ target cluster. ++ If the --default-service-account flag is set, its value will be used as ++ a controller level fallback for when HelmReleaseSpec.ServiceAccountName ++ is empty. ++ properties: ++ configMapRef: ++ description: |- ++ ConfigMapRef holds an optional name of a ConfigMap that contains ++ the following keys: ++ ++ - `provider`: the provider to use. One of `aws`, `azure`, `gcp`, or ++ `generic`. Required. ++ - `cluster`: the fully qualified resource name of the Kubernetes ++ cluster in the cloud provider API. Not used by the `generic` ++ provider. Required when one of `address` or `ca.crt` is not set. ++ - `address`: the address of the Kubernetes API server. Required ++ for `generic`. For the other providers, if not specified, the ++ first address in the cluster resource will be used, and if ++ specified, it must match one of the addresses in the cluster ++ resource. ++ If audiences is not set, will be used as the audience for the ++ `generic` provider. ++ - `ca.crt`: the optional PEM-encoded CA certificate for the ++ Kubernetes API server. If not set, the controller will use the ++ CA certificate from the cluster resource. ++ - `audiences`: the optional audiences as a list of ++ line-break-separated strings for the Kubernetes ServiceAccount ++ token. Defaults to the `address` for the `generic` provider, or ++ to specific values for the other providers depending on the ++ provider. ++ - `serviceAccountName`: the optional name of the Kubernetes ++ ServiceAccount in the same namespace that should be used ++ for authentication. If not specified, the controller ++ ServiceAccount will be used. ++ ++ Mutually exclusive with SecretRef. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ secretRef: ++ description: |- ++ SecretRef holds an optional name of a secret that contains a key with ++ the kubeconfig file as the value. If no key is set, the key will default ++ to 'value'. Mutually exclusive with ConfigMapRef. ++ It is recommended that the kubeconfig is self-contained, and the secret ++ is regularly updated if credentials such as a cloud-access-token expire. ++ Cloud specific `cmd-path` auth helpers will not function without adding ++ binaries and credentials to the Pod that is responsible for reconciling ++ Kubernetes resources. Supported only for the generic provider. ++ properties: ++ key: ++ description: Key in the Secret, when not specified an implementation-specific ++ default key is used. ++ type: string ++ name: ++ description: Name of the Secret. ++ type: string ++ required: ++ - name ++ type: object ++ type: object ++ x-kubernetes-validations: ++ - message: exactly one of spec.kubeConfig.configMapRef or spec.kubeConfig.secretRef ++ must be specified ++ rule: has(self.configMapRef) || has(self.secretRef) ++ - message: exactly one of spec.kubeConfig.configMapRef or spec.kubeConfig.secretRef ++ must be specified ++ rule: '!has(self.configMapRef) || !has(self.secretRef)' ++ maxHistory: ++ description: |- ++ MaxHistory is the number of revisions saved by Helm for this HelmRelease. ++ Use '0' for an unlimited number of revisions; defaults to '5'. ++ type: integer ++ persistentClient: ++ description: |- ++ PersistentClient tells the controller to use a persistent Kubernetes ++ client for this release. When enabled, the client will be reused for the ++ duration of the reconciliation, instead of being created and destroyed ++ for each (step of a) Helm action. ++ ++ This can improve performance, but may cause issues with some Helm charts ++ that for example do create Custom Resource Definitions during installation ++ outside Helm's CRD lifecycle hooks, which are then not observed to be ++ available by e.g. post-install hooks. ++ ++ If not set, it defaults to true. ++ type: boolean ++ postRenderStrategy: ++ description: |- ++ PostRenderStrategy defines the strategy for sending hooks to post-renderers. ++ Valid values are 'nohooks' (hooks not sent to post-renderers, Helm 3 behavior), ++ 'combined' (hooks and templates sent together, Helm 4 default), and 'separate' ++ (hooks and templates sent in separate streams, Helm 4.2 opt-in). ++ Defaults to 'combined', or 'nohooks' when the UseHelm3Defaults feature gate is enabled. ++ enum: ++ - nohooks ++ - combined ++ - separate ++ type: string ++ postRenderers: ++ description: |- ++ PostRenderers holds an array of Helm PostRenderers, which will be applied in order ++ of their definition. ++ items: ++ description: PostRenderer contains a Helm PostRenderer specification. ++ properties: ++ kustomize: ++ description: Kustomization to apply as PostRenderer. ++ properties: ++ images: ++ description: |- ++ Images is a list of (image name, new name, new tag or digest) ++ for changing image names, tags or digests. This can also be achieved with a ++ patch, but this operator is simpler to specify. ++ items: ++ description: Image contains an image name, a new name, ++ a new tag or digest, which will replace the original ++ name and tag. ++ properties: ++ digest: ++ description: |- ++ Digest is the value used to replace the original image tag. ++ If digest is present NewTag value is ignored. ++ type: string ++ name: ++ description: Name is a tag-less image name. ++ type: string ++ newName: ++ description: NewName is the value used to replace ++ the original name. ++ type: string ++ newTag: ++ description: NewTag is the value used to replace the ++ original tag. ++ type: string ++ required: ++ - name ++ type: object ++ type: array ++ patches: ++ description: |- ++ Strategic merge and JSON patches, defined as inline YAML objects, ++ capable of targeting objects based on kind, label and annotation selectors. ++ items: ++ description: |- ++ Patch contains an inline StrategicMerge or JSON6902 patch, and the target the patch should ++ be applied to. ++ properties: ++ patch: ++ description: |- ++ Patch contains an inline StrategicMerge patch or an inline JSON6902 patch with ++ an array of operation objects. ++ type: string ++ target: ++ description: Target points to the resources that the ++ patch document should be applied to. ++ properties: ++ annotationSelector: ++ description: |- ++ AnnotationSelector is a string that follows the label selection expression ++ https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api ++ It matches with the resource annotations. ++ type: string ++ group: ++ description: |- ++ Group is the API group to select resources from. ++ Together with Version and Kind it is capable of unambiguously identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ kind: ++ description: |- ++ Kind of the API Group to select resources from. ++ Together with Group and Version it is capable of unambiguously ++ identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ labelSelector: ++ description: |- ++ LabelSelector is a string that follows the label selection expression ++ https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api ++ It matches with the resource labels. ++ type: string ++ name: ++ description: Name to match resources with. ++ type: string ++ namespace: ++ description: Namespace to select resources from. ++ type: string ++ version: ++ description: |- ++ Version of the API Group to select resources from. ++ Together with Group and Kind it is capable of unambiguously identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ type: object ++ required: ++ - patch ++ type: object ++ type: array ++ type: object ++ type: object ++ type: array ++ releaseName: ++ description: |- ++ ReleaseName used for the Helm release. Defaults to a composition of ++ '[TargetNamespace-]Name'. ++ maxLength: 53 ++ minLength: 1 ++ type: string ++ rollback: ++ description: Rollback holds the configuration for Helm rollback actions ++ for this HelmRelease. ++ properties: ++ cleanupOnFail: ++ description: |- ++ CleanupOnFail allows deletion of new resources created during the Helm ++ rollback action when it fails. ++ type: boolean ++ disableHooks: ++ description: DisableHooks prevents hooks from running during the ++ Helm rollback action. ++ type: boolean ++ disableWait: ++ description: |- ++ DisableWait disables the waiting for resources to be ready after a Helm ++ rollback has been performed. ++ type: boolean ++ disableWaitForJobs: ++ description: |- ++ DisableWaitForJobs disables waiting for jobs to complete after a Helm ++ rollback has been performed. ++ type: boolean ++ force: ++ description: |- ++ Force forces resource updates through a replacement strategy ++ that avoids 3-way merge conflicts on client-side apply. ++ This field is ignored for server-side apply (which always ++ forces conflicts with other field managers). ++ type: boolean ++ recreate: ++ description: |- ++ Recreate performs pod restarts for any managed workloads. ++ ++ Deprecated: This behavior was deprecated in Helm 3: ++ - Deprecation: https://github.com/helm/helm/pull/6463 ++ - Removal: https://github.com/helm/helm/pull/31023 ++ After helm-controller was upgraded to the Helm 4 SDK, ++ this field is no longer functional and will print a ++ warning if set to true. It will also be removed in a ++ future release. ++ type: boolean ++ serverSideApply: ++ description: |- ++ ServerSideApply enables server-side apply for resources during rollback. ++ Can be "enabled", "disabled", or "auto". ++ When "auto", server-side apply usage will be based on the release's previous usage. ++ Defaults to "auto". ++ enum: ++ - enabled ++ - disabled ++ - auto ++ type: string ++ timeout: ++ description: |- ++ Timeout is the time to wait for any individual Kubernetes operation (like ++ Jobs for hooks) during the performance of a Helm rollback action. Defaults to ++ 'HelmReleaseSpec.Timeout'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ type: object ++ serviceAccountName: ++ description: |- ++ The name of the Kubernetes service account to impersonate ++ when reconciling this HelmRelease. ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ storageNamespace: ++ description: |- ++ StorageNamespace used for the Helm storage. ++ Defaults to the namespace of the HelmRelease. ++ maxLength: 63 ++ minLength: 1 ++ type: string ++ suspend: ++ description: |- ++ Suspend tells the controller to suspend reconciliation for this HelmRelease, ++ it does not apply to already started reconciliations. Defaults to false. ++ type: boolean ++ targetNamespace: ++ description: |- ++ TargetNamespace to target when performing operations for the HelmRelease. ++ Defaults to the namespace of the HelmRelease. ++ maxLength: 63 ++ minLength: 1 ++ type: string ++ test: ++ description: Test holds the configuration for Helm test actions for ++ this HelmRelease. ++ properties: ++ enable: ++ description: |- ++ Enable enables Helm test actions for this HelmRelease after an Helm install ++ or upgrade action has been performed. ++ type: boolean ++ filters: ++ description: Filters is a list of tests to run or exclude from ++ running. ++ items: ++ description: Filter holds the configuration for individual Helm ++ test filters. ++ properties: ++ exclude: ++ description: Exclude specifies whether the named test should ++ be excluded. ++ type: boolean ++ name: ++ description: Name is the name of the test. ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ required: ++ - name ++ type: object ++ type: array ++ ignoreFailures: ++ description: |- ++ IgnoreFailures tells the controller to skip remediation when the Helm tests ++ are run but fail. Can be overwritten for tests run after install or upgrade ++ actions in 'Install.IgnoreTestFailures' and 'Upgrade.IgnoreTestFailures'. ++ type: boolean ++ timeout: ++ description: |- ++ Timeout is the time to wait for any individual Kubernetes operation during ++ the performance of a Helm test action. Defaults to 'HelmReleaseSpec.Timeout'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ type: object ++ timeout: ++ description: |- ++ Timeout is the time to wait for any individual Kubernetes operation (like Jobs ++ for hooks) during the performance of a Helm action. Defaults to '5m0s'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ uninstall: ++ description: Uninstall holds the configuration for Helm uninstall ++ actions for this HelmRelease. ++ properties: ++ deletionPropagation: ++ default: background ++ description: |- ++ DeletionPropagation specifies the deletion propagation policy when ++ a Helm uninstall is performed. ++ enum: ++ - background ++ - foreground ++ - orphan ++ type: string ++ disableHooks: ++ description: DisableHooks prevents hooks from running during the ++ Helm rollback action. ++ type: boolean ++ disableWait: ++ description: |- ++ DisableWait disables waiting for all the resources to be deleted after ++ a Helm uninstall is performed. ++ type: boolean ++ keepHistory: ++ description: |- ++ KeepHistory tells Helm to remove all associated resources and mark the ++ release as deleted, but retain the release history. ++ type: boolean ++ timeout: ++ description: |- ++ Timeout is the time to wait for any individual Kubernetes operation (like ++ Jobs for hooks) during the performance of a Helm uninstall action. Defaults ++ to 'HelmReleaseSpec.Timeout'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ type: object ++ upgrade: ++ description: Upgrade holds the configuration for Helm upgrade actions ++ for this HelmRelease. ++ properties: ++ chartNameChangeStrategy: ++ description: |- ++ ChartNameChangeStrategy defines the strategy to use when a Helm chart name changes. ++ Valid values are 'Reinstall' or 'InPlaceUpdate'. Defaults to 'Reinstall' if omitted. ++ ++ Reinstall: Reinstall the Helm release, uninstalling the existing Helm release. ++ ++ InPlaceUpdate: Update the Helm release in place. ++ enum: ++ - InPlaceUpdate ++ - Reinstall ++ type: string ++ cleanupOnFail: ++ description: |- ++ CleanupOnFail allows deletion of new resources created during the Helm ++ upgrade action when it fails. ++ type: boolean ++ crds: ++ description: |- ++ CRDs upgrade CRDs from the Helm Chart's crds directory according ++ to the CRD upgrade policy provided here. Valid values are `Skip`, ++ `Create` or `CreateReplace`. Default is `Skip` and if omitted ++ CRDs are neither installed nor upgraded. ++ ++ Skip: do neither install nor replace (update) any CRDs. ++ ++ Create: new CRDs are created, existing CRDs are neither updated nor deleted. ++ ++ CreateReplace: new CRDs are created, existing CRDs are updated (replaced) ++ but not deleted. ++ ++ By default, CRDs are not applied during Helm upgrade action. With this ++ option users can opt-in to CRD upgrade, which is not (yet) natively supported by Helm. ++ https://helm.sh/docs/chart_best_practices/custom_resource_definitions. ++ enum: ++ - Skip ++ - Create ++ - CreateReplace ++ type: string ++ disableHooks: ++ description: DisableHooks prevents hooks from running during the ++ Helm upgrade action. ++ type: boolean ++ disableOpenAPIValidation: ++ description: |- ++ DisableOpenAPIValidation prevents the Helm upgrade action from validating ++ rendered templates against the Kubernetes OpenAPI Schema. ++ type: boolean ++ disableSchemaValidation: ++ description: |- ++ DisableSchemaValidation prevents the Helm upgrade action from validating ++ the values against the JSON Schema. ++ type: boolean ++ disableTakeOwnership: ++ description: |- ++ DisableTakeOwnership disables taking ownership of existing resources ++ during the Helm upgrade action. Defaults to false. ++ type: boolean ++ disableWait: ++ description: |- ++ DisableWait disables the waiting for resources to be ready after a Helm ++ upgrade has been performed. ++ type: boolean ++ disableWaitForJobs: ++ description: |- ++ DisableWaitForJobs disables waiting for jobs to complete after a Helm ++ upgrade has been performed. ++ type: boolean ++ force: ++ description: |- ++ Force forces resource updates through a replacement strategy ++ that avoids 3-way merge conflicts on client-side apply. ++ This field is ignored for server-side apply (which always ++ forces conflicts with other field managers). ++ type: boolean ++ preserveValues: ++ description: |- ++ PreserveValues will make Helm reuse the last release's values and merge in ++ overrides from 'Values'. Setting this flag makes the HelmRelease ++ non-declarative. ++ type: boolean ++ remediation: ++ description: |- ++ Remediation holds the remediation configuration for when the Helm upgrade ++ action for the HelmRelease fails. The default is to not perform any action. ++ properties: ++ ignoreTestFailures: ++ description: |- ++ IgnoreTestFailures tells the controller to skip remediation when the Helm ++ tests are run after an upgrade action but fail. ++ Defaults to 'Test.IgnoreFailures'. ++ type: boolean ++ remediateLastFailure: ++ description: |- ++ RemediateLastFailure tells the controller to remediate the last failure, when ++ no retries remain. Defaults to 'false' unless 'Retries' is greater than 0. ++ type: boolean ++ retries: ++ description: |- ++ Retries is the number of retries that should be attempted on failures before ++ bailing. Remediation, using 'Strategy', is performed between each attempt. ++ Defaults to '0', a negative integer equals to unlimited retries. ++ type: integer ++ strategy: ++ description: Strategy to use for failure remediation. Defaults ++ to 'rollback'. ++ enum: ++ - rollback ++ - uninstall ++ type: string ++ type: object ++ serverSideApply: ++ description: |- ++ ServerSideApply enables server-side apply for resources during upgrade. ++ Can be "enabled", "disabled", or "auto". ++ When "auto", server-side apply usage will be based on the release's previous usage. ++ Defaults to "auto". ++ enum: ++ - enabled ++ - disabled ++ - auto ++ type: string ++ strategy: ++ description: |- ++ Strategy defines the upgrade strategy to use for this HelmRelease. ++ Defaults to 'RemediateOnFailure', or 'RetryOnFailure' when the ++ DefaultToRetryOnFailure feature gate is enabled. ++ properties: ++ name: ++ description: Name of the upgrade strategy. ++ enum: ++ - RemediateOnFailure ++ - RetryOnFailure ++ type: string ++ retryInterval: ++ description: |- ++ RetryInterval is the interval at which to retry a failed upgrade. ++ Can be used only when Name is set to RetryOnFailure. ++ Defaults to '5m'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ required: ++ - name ++ type: object ++ x-kubernetes-validations: ++ - message: .retryInterval can only be set when .name is 'RetryOnFailure' ++ rule: '!has(self.retryInterval) || self.name == ''RetryOnFailure''' ++ timeout: ++ description: |- ++ Timeout is the time to wait for any individual Kubernetes operation (like ++ Jobs for hooks) during the performance of a Helm upgrade action. Defaults to ++ 'HelmReleaseSpec.Timeout'. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ type: object ++ values: ++ description: Values holds the values for this Helm release. ++ x-kubernetes-preserve-unknown-fields: true ++ valuesFrom: ++ description: |- ++ ValuesFrom holds references to resources containing Helm values for this HelmRelease, ++ and information about how they should be merged. ++ items: ++ description: |- ++ ValuesReference contains a reference to a resource containing Helm values, ++ and optionally the key they can be found at. ++ properties: ++ kind: ++ description: Kind of the values referent, valid values are ('Secret', ++ 'ConfigMap'). ++ enum: ++ - Secret ++ - ConfigMap ++ type: string ++ literal: ++ description: |- ++ Literal marks this ValuesReference as a literal value. When set in ++ combination with TargetPath, the referenced value is merged at the target ++ path without interpreting Helm's `--set` syntax (commas, brackets, dots, ++ equal signs, etc.), mirroring the behavior of `helm --set-literal`. This ++ is the only safe way to inject arbitrary file content (config files, JSON ++ blobs, multi-line strings containing special characters) through ++ `valuesFrom`. Has no effect when TargetPath is empty: in that mode the ++ referenced value is always YAML-merged at the root. ++ type: boolean ++ name: ++ description: |- ++ Name of the values referent. Should reside in the same namespace as the ++ referring resource. ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ optional: ++ description: |- ++ Optional marks this ValuesReference as optional. When set, a not found error ++ for the values reference is ignored, but any ValuesKey, TargetPath or ++ transient error will still result in a reconciliation failure. ++ type: boolean ++ targetPath: ++ description: |- ++ TargetPath is the YAML dot notation path the value should be merged at. When ++ set, the ValuesKey is expected to be a single flat value. Defaults to 'None', ++ which results in the values getting merged at the root. ++ maxLength: 250 ++ pattern: ^([a-zA-Z0-9_\-.\\\/]|\[[0-9]{1,5}\])+$ ++ type: string ++ valuesKey: ++ description: |- ++ ValuesKey is the data key where the values.yaml or a specific value can be ++ found at. Defaults to 'values.yaml'. ++ maxLength: 253 ++ pattern: ^[\-._a-zA-Z0-9]+$ ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ type: array ++ waitStrategy: ++ description: |- ++ WaitStrategy defines Helm's wait strategy for waiting for applied ++ resources to become ready. ++ properties: ++ name: ++ description: |- ++ Name is Helm's wait strategy for waiting for applied resources to ++ become ready. One of 'poller' or 'legacy'. The 'poller' strategy uses ++ kstatus to poll resource statuses, while the 'legacy' strategy uses ++ Helm v3's waiting logic. ++ Defaults to 'poller', or to 'legacy' when UseHelm3Defaults feature ++ gate is enabled. ++ enum: ++ - poller ++ - legacy ++ type: string ++ required: ++ - name ++ type: object ++ required: ++ - interval ++ type: object ++ x-kubernetes-validations: ++ - message: either chart or chartRef must be set ++ rule: (has(self.chart) && !has(self.chartRef)) || (!has(self.chart) ++ && has(self.chartRef)) ++ status: ++ default: ++ observedGeneration: -1 ++ description: HelmReleaseStatus defines the observed state of a HelmRelease. ++ properties: ++ conditions: ++ description: Conditions holds the conditions for the HelmRelease. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ failures: ++ description: |- ++ Failures is the reconciliation failure count against the latest desired ++ state. It is reset after a successful reconciliation. ++ format: int64 ++ type: integer ++ helmChart: ++ description: |- ++ HelmChart is the namespaced name of the HelmChart resource created by ++ the controller for the HelmRelease. ++ type: string ++ history: ++ description: |- ++ History holds the history of Helm releases performed for this HelmRelease ++ up to the last successfully completed release. ++ items: ++ description: |- ++ Snapshot captures a point-in-time copy of the status information for a Helm release, ++ as managed by the controller. ++ properties: ++ action: ++ description: Action is the action that resulted in this snapshot ++ being created. ++ type: string ++ apiVersion: ++ description: |- ++ APIVersion is the API version of the Snapshot. ++ When the calculation method of the Digest field is changed, this ++ field will be used to distinguish between the old and new methods. ++ type: string ++ appVersion: ++ description: AppVersion is the chart app version of the release ++ object in storage. ++ type: string ++ chartName: ++ description: ChartName is the chart name of the release object ++ in storage. ++ type: string ++ chartVersion: ++ description: |- ++ ChartVersion is the chart version of the release object in ++ storage. ++ type: string ++ configDigest: ++ description: |- ++ ConfigDigest is the checksum of the config (better known as ++ "values") of the release object in storage. ++ It has the format of `:`. ++ type: string ++ deleted: ++ description: Deleted is when the release was deleted. ++ format: date-time ++ type: string ++ digest: ++ description: |- ++ Digest is the checksum of the release object in storage. ++ It has the format of `:`. ++ type: string ++ firstDeployed: ++ description: FirstDeployed is when the release was first deployed. ++ format: date-time ++ type: string ++ lastDeployed: ++ description: LastDeployed is when the release was last deployed. ++ format: date-time ++ type: string ++ name: ++ description: Name is the name of the release. ++ type: string ++ namespace: ++ description: Namespace is the namespace the release is deployed ++ to. ++ type: string ++ ociDigest: ++ description: OCIDigest is the digest of the OCI artifact associated ++ with the release. ++ type: string ++ status: ++ description: Status is the current state of the release. ++ type: string ++ testHooks: ++ additionalProperties: ++ description: |- ++ TestHookStatus holds the status information for a test hook as observed ++ to be run by the controller. ++ properties: ++ lastCompleted: ++ description: LastCompleted is the time the test hook last ++ completed. ++ format: date-time ++ type: string ++ lastStarted: ++ description: LastStarted is the time the test hook was ++ last started. ++ format: date-time ++ type: string ++ phase: ++ description: Phase the test hook was observed to be in. ++ type: string ++ type: object ++ description: |- ++ TestHooks is the list of test hooks for the release as observed to be ++ run by the controller. ++ type: object ++ version: ++ description: Version is the version of the release object in ++ storage. ++ type: integer ++ required: ++ - chartName ++ - chartVersion ++ - configDigest ++ - digest ++ - firstDeployed ++ - lastDeployed ++ - name ++ - namespace ++ - status ++ - version ++ type: object ++ type: array ++ installFailures: ++ description: |- ++ InstallFailures is the install failure count against the latest desired ++ state. It is reset after a successful reconciliation. ++ format: int64 ++ type: integer ++ inventory: ++ description: |- ++ Inventory contains the list of Kubernetes resource object references ++ that have been applied for this release. ++ properties: ++ entries: ++ description: Entries of Kubernetes resource object references. ++ items: ++ description: ResourceRef contains the information necessary ++ to locate a resource within a cluster. ++ properties: ++ id: ++ description: |- ++ ID is the string representation of the Kubernetes resource object's metadata, ++ in the format '___'. ++ type: string ++ v: ++ description: Version is the API version of the Kubernetes ++ resource object's kind. ++ type: string ++ required: ++ - id ++ - v ++ type: object ++ type: array ++ required: ++ - entries ++ type: object ++ lastAttemptedConfigDigest: ++ description: |- ++ LastAttemptedConfigDigest is the digest for the config (better known as ++ "values") of the last reconciliation attempt. ++ type: string ++ lastAttemptedGeneration: ++ description: |- ++ LastAttemptedGeneration is the last generation the controller attempted ++ to reconcile. ++ format: int64 ++ type: integer ++ lastAttemptedReleaseAction: ++ description: |- ++ LastAttemptedReleaseAction is the last release action performed for this ++ HelmRelease. It is used to determine the active retry or remediation ++ strategy. ++ enum: ++ - install ++ - upgrade ++ type: string ++ lastAttemptedReleaseActionDuration: ++ description: |- ++ LastAttemptedReleaseActionDuration is the duration of the last ++ release action performed for this HelmRelease. ++ type: string ++ lastAttemptedRevision: ++ description: |- ++ LastAttemptedRevision is the Source revision of the last reconciliation ++ attempt. For OCIRepository sources, the 12 first characters of the digest are ++ appended to the chart version e.g. "1.2.3+1234567890ab". ++ type: string ++ lastAttemptedRevisionDigest: ++ description: |- ++ LastAttemptedRevisionDigest is the digest of the last reconciliation attempt. ++ This is only set for OCIRepository sources. ++ type: string ++ lastAttemptedValuesChecksum: ++ description: |- ++ LastAttemptedValuesChecksum is the SHA1 checksum for the values of the last ++ reconciliation attempt. ++ ++ Deprecated: Use LastAttemptedConfigDigest instead. ++ type: string ++ lastHandledForceAt: ++ description: |- ++ LastHandledForceAt holds the value of the most recent ++ force request value, so a change of the annotation value ++ can be detected. ++ type: string ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ lastHandledResetAt: ++ description: |- ++ LastHandledResetAt holds the value of the most recent reset request ++ value, so a change of the annotation value can be detected. ++ type: string ++ lastReleaseRevision: ++ description: |- ++ LastReleaseRevision is the revision of the last successful Helm release. ++ ++ Deprecated: Use History instead. ++ type: integer ++ observedCommonMetadataDigest: ++ description: |- ++ ObservedCommonMetadataDigest is the digest for the common metadata of ++ the last successful reconciliation attempt. ++ type: string ++ observedGeneration: ++ description: ObservedGeneration is the last observed generation. ++ format: int64 ++ type: integer ++ observedPostRenderersDigest: ++ description: |- ++ ObservedPostRenderersDigest is the digest for the post-renderers of ++ the last successful reconciliation attempt. ++ type: string ++ storageNamespace: ++ description: |- ++ StorageNamespace is the namespace of the Helm release storage for the ++ current release. ++ maxLength: 63 ++ minLength: 1 ++ type: string ++ upgradeFailures: ++ description: |- ++ UpgradeFailures is the upgrade failure count against the latest desired ++ state. It is reset after a successful reconciliation. ++ format: int64 ++ type: integer ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} +diff --git a/usercase-test-coderl/fixtures/flux-manifests/helm-controller.deployment.yaml b/usercase-test-coderl/fixtures/flux-manifests/helm-controller.deployment.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/helm-controller.deployment.yaml +@@ -0,0 +1,73 @@ ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ labels: ++ control-plane: controller ++ name: helm-controller ++spec: ++ replicas: 1 ++ selector: ++ matchLabels: ++ app: helm-controller ++ template: ++ metadata: ++ annotations: ++ prometheus.io/port: "8080" ++ prometheus.io/scrape: "true" ++ labels: ++ app: helm-controller ++ spec: ++ containers: ++ - args: ++ - --watch-all-namespaces ++ - --log-level=info ++ - --log-encoding=json ++ - --enable-leader-election ++ env: ++ - name: RUNTIME_NAMESPACE ++ valueFrom: ++ fieldRef: ++ fieldPath: metadata.namespace ++ image: fluxcd/helm-controller:v1.6.2 ++ imagePullPolicy: IfNotPresent ++ livenessProbe: ++ httpGet: ++ path: /healthz ++ port: healthz ++ name: manager ++ ports: ++ - containerPort: 8080 ++ name: http-prom ++ protocol: TCP ++ - containerPort: 9440 ++ name: healthz ++ protocol: TCP ++ readinessProbe: ++ httpGet: ++ path: /readyz ++ port: healthz ++ resources: ++ limits: ++ cpu: 1000m ++ memory: 1Gi ++ requests: ++ cpu: 100m ++ memory: 64Mi ++ securityContext: ++ allowPrivilegeEscalation: false ++ capabilities: ++ drop: ++ - ALL ++ readOnlyRootFilesystem: true ++ runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault ++ volumeMounts: ++ - mountPath: /tmp ++ name: temp ++ securityContext: ++ fsGroup: 1337 ++ terminationGracePeriodSeconds: 600 ++ volumes: ++ - emptyDir: {} ++ name: temp +diff --git a/usercase-test-coderl/fixtures/flux-manifests/image-automation-controller.crds.yaml b/usercase-test-coderl/fixtures/flux-manifests/image-automation-controller.crds.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/image-automation-controller.crds.yaml +@@ -0,0 +1,446 @@ ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: imageupdateautomations.image.toolkit.fluxcd.io ++spec: ++ group: image.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-images ++ kind: ImageUpdateAutomation ++ listKind: ImageUpdateAutomationList ++ plural: imageupdateautomations ++ shortNames: ++ - iua ++ - imgupd ++ - imgauto ++ singular: imageupdateautomation ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ - jsonPath: .status.lastAutomationRunTime ++ name: Last run ++ priority: 1 ++ type: string ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: ImageUpdateAutomation is the Schema for the imageupdateautomations ++ API ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: ImageUpdateAutomationSpec defines the desired state of ImageUpdateAutomation ++ properties: ++ git: ++ description: |- ++ GitSpec contains all the git-specific definitions. This is ++ technically optional, but in practice mandatory until there are ++ other kinds of source allowed. ++ properties: ++ checkout: ++ description: |- ++ Checkout gives the parameters for cloning the git repository, ++ ready to make changes. If not present, the `spec.ref` field from the ++ referenced `GitRepository` or its default will be used. ++ properties: ++ ref: ++ description: |- ++ Reference gives a branch, tag or commit to clone from the Git ++ repository. ++ properties: ++ branch: ++ description: Branch to check out, defaults to 'master' ++ if no other field is defined. ++ type: string ++ commit: ++ description: |- ++ Commit SHA to check out, takes precedence over all reference fields. ++ ++ This can be combined with Branch to shallow clone the branch, in which ++ the commit is expected to exist. ++ type: string ++ name: ++ description: |- ++ Name of the reference to check out; takes precedence over Branch, Tag and SemVer. ++ ++ It must be a valid Git reference: https://git-scm.com/docs/git-check-ref-format#_description ++ Examples: "refs/heads/main", "refs/tags/v0.1.0", "refs/pull/420/head", "refs/merge-requests/1/head" ++ type: string ++ semver: ++ description: SemVer tag expression to check out, takes ++ precedence over Tag. ++ type: string ++ tag: ++ description: Tag to check out, takes precedence over Branch. ++ type: string ++ type: object ++ required: ++ - ref ++ type: object ++ commit: ++ description: Commit specifies how to commit to the git repository. ++ properties: ++ author: ++ description: |- ++ Author gives the email and optionally the name to use as the ++ author of commits. ++ properties: ++ email: ++ description: Email gives the email to provide when making ++ a commit. ++ type: string ++ name: ++ description: Name gives the name to provide when making ++ a commit. ++ type: string ++ required: ++ - email ++ type: object ++ messageTemplate: ++ description: |- ++ MessageTemplate provides a template for the commit message, ++ into which will be interpolated the details of the change made. ++ Note: The `Updated` template field has been removed. Use `Changed` instead. ++ type: string ++ messageTemplateValues: ++ additionalProperties: ++ type: string ++ description: |- ++ MessageTemplateValues provides additional values to be available to the ++ templating rendering. ++ type: object ++ signingKey: ++ description: |- ++ SigningKey provides the option to sign commits with an OpenPGP or ++ SSH signing key, referenced from a Secret. See SigningKey. ++ properties: ++ secretRef: ++ description: |- ++ SecretRef references a Secret containing the signing key. For type ++ 'gpg', the Secret must contain a 'git.asc' (ASCII-armored OpenPGP ++ keypair) and may contain a 'passphrase'. For type 'ssh', the Secret ++ must contain an 'identity' (an SSH private key in any format ++ golang.org/x/crypto/ssh.ParsePrivateKey accepts; typically the ++ OpenSSH format produced by 'ssh-keygen') and may contain a 'password' ++ (the key's passphrase). The SSH conventions match the GitRepository ++ SSH transport-auth Secret format, allowing a single Secret to serve ++ both transport and signing when the ImageUpdateAutomation lives in ++ the same namespace as the GitRepository. ++ ++ The Secret itself must live in the same namespace as the ++ ImageUpdateAutomation. ++ ++ Supported SSH key algorithms: ed25519, ecdsa-sha2-nistp256/384/521, ++ and rsa (>= 2048-bit). ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ type: ++ description: |- ++ Type selects the signing-key format expected in the referenced ++ Secret. When empty, the controller defaults to 'gpg'. ++ enum: ++ - gpg ++ - ssh ++ type: string ++ required: ++ - secretRef ++ type: object ++ required: ++ - author ++ type: object ++ push: ++ description: |- ++ Push specifies how and where to push commits made by the ++ automation. If missing, commits are pushed (back) to ++ `.spec.checkout.branch` or its default. ++ properties: ++ branch: ++ description: |- ++ Branch specifies that commits should be pushed to the branch ++ named. The branch is created using `.spec.checkout.branch` as the ++ starting point, if it doesn't already exist. ++ type: string ++ options: ++ additionalProperties: ++ type: string ++ description: |- ++ Options specifies the push options that are sent to the Git ++ server when performing a push operation. For details, see: ++ https://git-scm.com/docs/git-push#Documentation/git-push.txt---push-optionltoptiongt ++ type: object ++ refspec: ++ description: |- ++ Refspec specifies the Git Refspec to use for a push operation. ++ If both Branch and Refspec are provided, then the commit is pushed ++ to the branch and also using the specified refspec. ++ For more details about Git Refspecs, see: ++ https://git-scm.com/book/en/v2/Git-Internals-The-Refspec ++ type: string ++ type: object ++ required: ++ - commit ++ type: object ++ interval: ++ description: |- ++ Interval gives an lower bound for how often the automation ++ run should be attempted. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ policySelector: ++ description: |- ++ PolicySelector allows to filter applied policies based on labels. ++ By default includes all policies in namespace. ++ properties: ++ matchExpressions: ++ description: matchExpressions is a list of label selector requirements. ++ The requirements are ANDed. ++ items: ++ description: |- ++ A label selector requirement is a selector that contains values, a key, and an operator that ++ relates the key and values. ++ properties: ++ key: ++ description: key is the label key that the selector applies ++ to. ++ type: string ++ operator: ++ description: |- ++ operator represents a key's relationship to a set of values. ++ Valid operators are In, NotIn, Exists and DoesNotExist. ++ type: string ++ values: ++ description: |- ++ values is an array of string values. If the operator is In or NotIn, ++ the values array must be non-empty. If the operator is Exists or DoesNotExist, ++ the values array must be empty. This array is replaced during a strategic ++ merge patch. ++ items: ++ type: string ++ type: array ++ x-kubernetes-list-type: atomic ++ required: ++ - key ++ - operator ++ type: object ++ type: array ++ x-kubernetes-list-type: atomic ++ matchLabels: ++ additionalProperties: ++ type: string ++ description: |- ++ matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels ++ map is equivalent to an element of matchExpressions, whose key field is "key", the ++ operator is "In", and the values array contains only "value". The requirements are ANDed. ++ type: object ++ type: object ++ x-kubernetes-map-type: atomic ++ sourceRef: ++ description: |- ++ SourceRef refers to the resource giving access details ++ to a git repository. ++ properties: ++ apiVersion: ++ description: API version of the referent. ++ type: string ++ kind: ++ default: GitRepository ++ description: Kind of the referent. ++ enum: ++ - GitRepository ++ type: string ++ name: ++ description: Name of the referent. ++ type: string ++ namespace: ++ description: Namespace of the referent, defaults to the namespace ++ of the Kubernetes resource object that contains the reference. ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ suspend: ++ description: |- ++ Suspend tells the controller to not run this automation, until ++ it is unset (or set to false). Defaults to false. ++ type: boolean ++ update: ++ default: ++ strategy: Setters ++ description: |- ++ Update gives the specification for how to update the files in ++ the repository. This can be left empty, to use the default ++ value. ++ properties: ++ path: ++ description: |- ++ Path to the directory containing the manifests to be updated. ++ Defaults to 'None', which translates to the root path ++ of the GitRepositoryRef. ++ type: string ++ strategy: ++ default: Setters ++ description: Strategy names the strategy to be used. ++ enum: ++ - Setters ++ type: string ++ type: object ++ required: ++ - interval ++ - sourceRef ++ type: object ++ status: ++ default: ++ observedGeneration: -1 ++ description: ImageUpdateAutomationStatus defines the observed state of ++ ImageUpdateAutomation ++ properties: ++ conditions: ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ lastAutomationRunTime: ++ description: |- ++ LastAutomationRunTime records the last time the controller ran ++ this automation through to completion (even if no updates were ++ made). ++ format: date-time ++ type: string ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ lastPushCommit: ++ description: |- ++ LastPushCommit records the SHA1 of the last commit made by the ++ controller, for this automation object ++ type: string ++ lastPushTime: ++ description: LastPushTime records the time of the last pushed change. ++ format: date-time ++ type: string ++ observedGeneration: ++ format: int64 ++ type: integer ++ observedPolicies: ++ additionalProperties: ++ description: ImageRef represents an image reference. ++ properties: ++ digest: ++ description: Digest is the image's digest. ++ type: string ++ name: ++ description: Name is the bare image's name. ++ type: string ++ tag: ++ description: Tag is the image's tag. ++ type: string ++ required: ++ - name ++ - tag ++ type: object ++ description: |- ++ ObservedPolicies is the list of observed ImagePolicies that were ++ considered by the ImageUpdateAutomation update process. ++ type: object ++ observedSourceRevision: ++ description: |- ++ ObservedSourceRevision is the last observed source revision. This can be ++ used to determine if the source has been updated since last observation. ++ type: string ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} +diff --git a/usercase-test-coderl/fixtures/flux-manifests/image-automation-controller.deployment.yaml b/usercase-test-coderl/fixtures/flux-manifests/image-automation-controller.deployment.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/image-automation-controller.deployment.yaml +@@ -0,0 +1,73 @@ ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ labels: ++ control-plane: controller ++ name: image-automation-controller ++spec: ++ replicas: 1 ++ selector: ++ matchLabels: ++ app: image-automation-controller ++ template: ++ metadata: ++ annotations: ++ prometheus.io/port: "8080" ++ prometheus.io/scrape: "true" ++ labels: ++ app: image-automation-controller ++ spec: ++ containers: ++ - args: ++ - --watch-all-namespaces ++ - --log-level=info ++ - --log-encoding=json ++ - --enable-leader-election ++ env: ++ - name: RUNTIME_NAMESPACE ++ valueFrom: ++ fieldRef: ++ fieldPath: metadata.namespace ++ image: fluxcd/image-automation-controller:v1.2.3 ++ imagePullPolicy: IfNotPresent ++ livenessProbe: ++ httpGet: ++ path: /healthz ++ port: healthz ++ name: manager ++ ports: ++ - containerPort: 8080 ++ name: http-prom ++ protocol: TCP ++ - containerPort: 9440 ++ name: healthz ++ protocol: TCP ++ readinessProbe: ++ httpGet: ++ path: /readyz ++ port: healthz ++ resources: ++ limits: ++ cpu: 1000m ++ memory: 1Gi ++ requests: ++ cpu: 100m ++ memory: 64Mi ++ securityContext: ++ allowPrivilegeEscalation: false ++ capabilities: ++ drop: ++ - ALL ++ readOnlyRootFilesystem: true ++ runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault ++ volumeMounts: ++ - mountPath: /tmp ++ name: temp ++ securityContext: ++ fsGroup: 1337 ++ terminationGracePeriodSeconds: 10 ++ volumes: ++ - emptyDir: {} ++ name: temp +diff --git a/usercase-test-coderl/fixtures/flux-manifests/image-reflector-controller.crds.yaml b/usercase-test-coderl/fixtures/flux-manifests/image-reflector-controller.crds.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/image-reflector-controller.crds.yaml +@@ -0,0 +1,623 @@ ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: imagepolicies.image.toolkit.fluxcd.io ++spec: ++ group: image.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-images ++ kind: ImagePolicy ++ listKind: ImagePolicyList ++ plural: imagepolicies ++ shortNames: ++ - imgpol ++ - imagepol ++ singular: imagepolicy ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .status.latestRef.name ++ name: Image ++ type: string ++ - jsonPath: .status.latestRef.tag ++ name: Tag ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: ImagePolicy is the Schema for the imagepolicies API ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: |- ++ ImagePolicySpec defines the parameters for calculating the ++ ImagePolicy. ++ properties: ++ digestReflectionPolicy: ++ default: Never ++ description: |- ++ DigestReflectionPolicy governs the setting of the `.status.latestRef.digest` field. ++ ++ Never: The digest field will always be set to the empty string. ++ ++ IfNotPresent: The digest field will be set to the digest of the elected ++ latest image if the field is empty and the image did not change. ++ ++ Always: The digest field will always be set to the digest of the elected ++ latest image. ++ ++ Default: Never. ++ enum: ++ - Always ++ - IfNotPresent ++ - Never ++ type: string ++ filterTags: ++ description: |- ++ FilterTags enables filtering for only a subset of tags based on a set of ++ rules. If no rules are provided, all the tags from the repository will be ++ ordered and compared. ++ properties: ++ extract: ++ description: |- ++ Extract allows a capture group to be extracted from the specified regular ++ expression pattern, useful before tag evaluation. ++ type: string ++ pattern: ++ description: |- ++ Pattern specifies a regular expression pattern used to filter for image ++ tags. ++ type: string ++ type: object ++ imageRepositoryRef: ++ description: |- ++ ImageRepositoryRef points at the object specifying the image ++ being scanned ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ namespace: ++ description: Namespace of the referent, when not specified it ++ acts as LocalObjectReference. ++ type: string ++ required: ++ - name ++ type: object ++ interval: ++ description: |- ++ Interval is the length of time to wait between ++ refreshing the digest of the latest tag when the ++ reflection policy is set to "Always". ++ ++ Defaults to 10m. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ policy: ++ description: |- ++ Policy gives the particulars of the policy to be followed in ++ selecting the most recent image ++ properties: ++ alphabetical: ++ description: Alphabetical set of rules to use for alphabetical ++ ordering of the tags. ++ properties: ++ order: ++ default: asc ++ description: |- ++ Order specifies the sorting order of the tags. Given the letters of the ++ alphabet as tags, ascending order would select Z, and descending order ++ would select A. ++ enum: ++ - asc ++ - desc ++ type: string ++ type: object ++ numerical: ++ description: Numerical set of rules to use for numerical ordering ++ of the tags. ++ properties: ++ order: ++ default: asc ++ description: |- ++ Order specifies the sorting order of the tags. Given the integer values ++ from 0 to 9 as tags, ascending order would select 9, and descending order ++ would select 0. ++ enum: ++ - asc ++ - desc ++ type: string ++ type: object ++ semver: ++ description: |- ++ SemVer gives a semantic version range to check against the tags ++ available. ++ properties: ++ range: ++ description: |- ++ Range gives a semver range for the image tag; the highest ++ version within the range that's a tag yields the latest image. ++ type: string ++ required: ++ - range ++ type: object ++ type: object ++ suspend: ++ description: |- ++ This flag tells the controller to suspend subsequent policy reconciliations. ++ It does not apply to already started reconciliations. Defaults to false. ++ type: boolean ++ required: ++ - imageRepositoryRef ++ - policy ++ type: object ++ x-kubernetes-validations: ++ - message: spec.interval is only accepted when spec.digestReflectionPolicy ++ is set to 'Always' ++ rule: '!has(self.interval) || (has(self.digestReflectionPolicy) && self.digestReflectionPolicy ++ == ''Always'')' ++ - message: spec.interval must be set when spec.digestReflectionPolicy ++ is set to 'Always' ++ rule: has(self.interval) || !has(self.digestReflectionPolicy) || self.digestReflectionPolicy ++ != 'Always' ++ status: ++ default: ++ observedGeneration: -1 ++ description: ImagePolicyStatus defines the observed state of ImagePolicy ++ properties: ++ conditions: ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ latestRef: ++ description: |- ++ LatestRef gives the first in the list of images scanned by ++ the image repository, when filtered and ordered according ++ to the policy. ++ properties: ++ digest: ++ description: Digest is the image's digest. ++ type: string ++ name: ++ description: Name is the bare image's name. ++ type: string ++ tag: ++ description: Tag is the image's tag. ++ type: string ++ required: ++ - name ++ - tag ++ type: object ++ observedGeneration: ++ format: int64 ++ type: integer ++ observedPreviousRef: ++ description: |- ++ ObservedPreviousRef is the observed previous LatestRef. It is used ++ to keep track of the previous and current images. ++ properties: ++ digest: ++ description: Digest is the image's digest. ++ type: string ++ name: ++ description: Name is the bare image's name. ++ type: string ++ tag: ++ description: Tag is the image's tag. ++ type: string ++ required: ++ - name ++ - tag ++ type: object ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} ++--- ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: imagerepositories.image.toolkit.fluxcd.io ++spec: ++ group: image.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-images ++ kind: ImageRepository ++ listKind: ImageRepositoryList ++ plural: imagerepositories ++ shortNames: ++ - imgrepo ++ - imagerepo ++ singular: imagerepository ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .spec.image ++ name: Image ++ type: string ++ - jsonPath: .status.lastScanResult.tagCount ++ name: Tags ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ - jsonPath: .status.lastScanResult.scanTime ++ name: Last scan ++ priority: 1 ++ type: string ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: ImageRepository is the Schema for the imagerepositories API ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: |- ++ ImageRepositorySpec defines the parameters for scanning an image ++ repository, e.g., `fluxcd/flux`. ++ properties: ++ accessFrom: ++ description: |- ++ AccessFrom defines an ACL for allowing cross-namespace references ++ to the ImageRepository object based on the caller's namespace labels. ++ properties: ++ namespaceSelectors: ++ description: |- ++ NamespaceSelectors is the list of namespace selectors to which this ACL applies. ++ Items in this list are evaluated using a logical OR operation. ++ items: ++ description: |- ++ NamespaceSelector selects the namespaces to which this ACL applies. ++ An empty map of MatchLabels matches all namespaces in a cluster. ++ properties: ++ matchLabels: ++ additionalProperties: ++ type: string ++ description: |- ++ MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels ++ map is equivalent to an element of matchExpressions, whose key field is "key", the ++ operator is "In", and the values array contains only "value". The requirements are ANDed. ++ type: object ++ type: object ++ type: array ++ required: ++ - namespaceSelectors ++ type: object ++ certSecretRef: ++ description: |- ++ CertSecretRef can be given the name of a Secret containing ++ either or both of ++ ++ - a PEM-encoded client certificate (`tls.crt`) and private ++ key (`tls.key`); ++ - a PEM-encoded CA certificate (`ca.crt`) ++ ++ and whichever are supplied, will be used for connecting to the ++ registry. The client cert and key are useful if you are ++ authenticating with a certificate; the CA cert is useful if ++ you are using a self-signed server certificate. The Secret must ++ be of type `Opaque` or `kubernetes.io/tls`. ++ ++ Note: Support for the `caFile`, `certFile` and `keyFile` keys has ++ been deprecated. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ exclusionList: ++ default: ++ - ^.*\.sig$ ++ description: |- ++ ExclusionList is a list of regex strings used to exclude certain tags ++ from being stored in the database. ++ items: ++ type: string ++ maxItems: 25 ++ type: array ++ image: ++ description: Image is the name of the image repository ++ type: string ++ insecure: ++ description: Insecure allows connecting to a non-TLS HTTP container ++ registry. ++ type: boolean ++ interval: ++ description: |- ++ Interval is the length of time to wait between ++ scans of the image repository. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ provider: ++ default: generic ++ description: |- ++ The provider used for authentication, can be 'aws', 'azure', 'gcp' or 'generic'. ++ When not specified, defaults to 'generic'. ++ enum: ++ - generic ++ - aws ++ - azure ++ - gcp ++ type: string ++ proxySecretRef: ++ description: |- ++ ProxySecretRef specifies the Secret containing the proxy configuration ++ to use while communicating with the container registry. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ secretRef: ++ description: |- ++ SecretRef can be given the name of a secret containing ++ credentials to use for the image registry. The secret should be ++ created with `kubectl create secret docker-registry`, or the ++ equivalent. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ serviceAccountName: ++ description: |- ++ ServiceAccountName is the name of the Kubernetes ServiceAccount used to authenticate ++ the image pull if the service account has attached pull secrets. ++ maxLength: 253 ++ type: string ++ suspend: ++ description: |- ++ This flag tells the controller to suspend subsequent image scans. ++ It does not apply to already started scans. Defaults to false. ++ type: boolean ++ timeout: ++ description: |- ++ Timeout for image scanning. ++ Defaults to 'Interval' duration. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$ ++ type: string ++ required: ++ - image ++ - interval ++ type: object ++ status: ++ default: ++ observedGeneration: -1 ++ description: ImageRepositoryStatus defines the observed state of ImageRepository ++ properties: ++ canonicalImageName: ++ description: |- ++ CanonicalName is the name of the image repository with all the ++ implied bits made explicit; e.g., `docker.io/library/alpine` ++ rather than `alpine`. ++ type: string ++ conditions: ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ lastScanResult: ++ description: LastScanResult contains the number of fetched tags. ++ properties: ++ latestTags: ++ description: |- ++ LatestTags is a small sample of the tags found in the last scan. ++ It's the first 10 tags when sorting all the tags in descending ++ alphabetical order. ++ items: ++ type: string ++ type: array ++ revision: ++ description: Revision is a stable hash of the scanned tags. ++ type: string ++ scanTime: ++ description: ScanTime is the time when the last scan was performed. ++ format: date-time ++ type: string ++ tagCount: ++ description: TagCount is the number of tags found in the last ++ scan. ++ type: integer ++ required: ++ - tagCount ++ type: object ++ observedExclusionList: ++ description: |- ++ ObservedExclusionList is a list of observed exclusion list. It reflects ++ the exclusion rules used for the observed scan result in ++ status.lastScanResult. ++ items: ++ type: string ++ type: array ++ observedGeneration: ++ description: ObservedGeneration is the last reconciled generation. ++ format: int64 ++ type: integer ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} +diff --git a/usercase-test-coderl/fixtures/flux-manifests/image-reflector-controller.deployment.yaml b/usercase-test-coderl/fixtures/flux-manifests/image-reflector-controller.deployment.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/image-reflector-controller.deployment.yaml +@@ -0,0 +1,77 @@ ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ labels: ++ control-plane: controller ++ name: image-reflector-controller ++spec: ++ replicas: 1 ++ selector: ++ matchLabels: ++ app: image-reflector-controller ++ template: ++ metadata: ++ annotations: ++ prometheus.io/port: "8080" ++ prometheus.io/scrape: "true" ++ labels: ++ app: image-reflector-controller ++ spec: ++ containers: ++ - args: ++ - --watch-all-namespaces ++ - --log-level=info ++ - --log-encoding=json ++ - --enable-leader-election ++ env: ++ - name: RUNTIME_NAMESPACE ++ valueFrom: ++ fieldRef: ++ fieldPath: metadata.namespace ++ image: fluxcd/image-reflector-controller:v1.2.3 ++ imagePullPolicy: IfNotPresent ++ livenessProbe: ++ httpGet: ++ path: /healthz ++ port: healthz ++ name: manager ++ ports: ++ - containerPort: 8080 ++ name: http-prom ++ protocol: TCP ++ - containerPort: 9440 ++ name: healthz ++ protocol: TCP ++ readinessProbe: ++ httpGet: ++ path: /readyz ++ port: healthz ++ resources: ++ limits: ++ cpu: 1000m ++ memory: 1Gi ++ requests: ++ cpu: 100m ++ memory: 64Mi ++ securityContext: ++ allowPrivilegeEscalation: false ++ capabilities: ++ drop: ++ - ALL ++ readOnlyRootFilesystem: true ++ runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault ++ volumeMounts: ++ - mountPath: /tmp ++ name: temp ++ - mountPath: /data ++ name: data ++ securityContext: ++ fsGroup: 1337 ++ terminationGracePeriodSeconds: 10 ++ volumes: ++ - emptyDir: {} ++ name: temp ++ - emptyDir: {} ++ name: data +diff --git a/usercase-test-coderl/fixtures/flux-manifests/kustomize-controller.crds.yaml b/usercase-test-coderl/fixtures/flux-manifests/kustomize-controller.crds.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/kustomize-controller.crds.yaml +@@ -0,0 +1,809 @@ ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: kustomizations.kustomize.toolkit.fluxcd.io ++spec: ++ group: kustomize.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-appliers ++ kind: Kustomization ++ listKind: KustomizationList ++ plural: kustomizations ++ shortNames: ++ - ks ++ singular: kustomization ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: Kustomization is the Schema for the kustomizations API. ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: |- ++ KustomizationSpec defines the configuration to calculate the desired state ++ from a Source using Kustomize. ++ properties: ++ buildMetadata: ++ description: |- ++ BuildMetadata specifies which kustomize build metadata should be added ++ to the built resources. The allowed values are 'originAnnotations' to ++ annotate resources with their source origin, and 'transformerAnnotations' ++ to annotate resources with the transformers that produced them. ++ items: ++ description: BuildMetadataOption defines the supported buildMetadata ++ options. ++ enum: ++ - originAnnotations ++ - transformerAnnotations ++ type: string ++ type: array ++ commonMetadata: ++ description: |- ++ CommonMetadata specifies the common labels and annotations that are ++ applied to all resources. Any existing label or annotation will be ++ overridden if its key matches a common one. ++ properties: ++ annotations: ++ additionalProperties: ++ type: string ++ description: Annotations to be added to the object's metadata. ++ type: object ++ labels: ++ additionalProperties: ++ type: string ++ description: Labels to be added to the object's metadata. ++ type: object ++ type: object ++ components: ++ description: Components specifies relative paths to kustomize Components. ++ items: ++ type: string ++ type: array ++ decryption: ++ description: Decrypt Kubernetes secrets before applying them on the ++ cluster. ++ properties: ++ provider: ++ description: Provider is the name of the decryption engine. ++ enum: ++ - sops ++ type: string ++ secretRef: ++ description: |- ++ The secret name containing the private OpenPGP keys used for decryption. ++ A static credential for a cloud provider defined inside the Secret ++ takes priority to secret-less authentication with the ServiceAccountName ++ field. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ serviceAccountName: ++ description: |- ++ ServiceAccountName is the name of the service account used to ++ authenticate with KMS services from cloud providers. If a ++ static credential for a given cloud provider is defined ++ inside the Secret referenced by SecretRef, that static ++ credential takes priority. ++ type: string ++ required: ++ - provider ++ type: object ++ deletionPolicy: ++ description: |- ++ DeletionPolicy can be used to control garbage collection when this ++ Kustomization is deleted. Valid values are ('MirrorPrune', 'Delete', ++ 'WaitForTermination', 'Orphan'). 'MirrorPrune' mirrors the Prune field ++ (orphan if false, delete if true). Defaults to 'MirrorPrune'. ++ enum: ++ - MirrorPrune ++ - Delete ++ - WaitForTermination ++ - Orphan ++ type: string ++ dependsOn: ++ description: |- ++ DependsOn may contain a DependencyReference slice ++ with references to Kustomization resources that must be ready before this ++ Kustomization can be reconciled. ++ items: ++ description: |- ++ DependencyReference contains enough information to locate the referenced Kubernetes resource object ++ and optional CEL expression to assess its readiness. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ namespace: ++ description: |- ++ Namespace of the referent, defaults to the namespace of the resource ++ object that contains the reference. ++ type: string ++ readyExpr: ++ description: |- ++ ReadyExpr is a CEL expression that can be used to assess the readiness ++ of a dependency. When specified, the built-in readiness check ++ is replaced by the logic defined in the CEL expression. ++ To make the CEL expression additive to the built-in readiness check, ++ the feature gate `AdditiveCELDependencyCheck` must be set to `true`. ++ type: string ++ required: ++ - name ++ type: object ++ type: array ++ force: ++ default: false ++ description: |- ++ Force instructs the controller to recreate resources ++ when patching fails due to an immutable field change. ++ type: boolean ++ healthCheckExprs: ++ description: |- ++ HealthCheckExprs is a list of healthcheck expressions for evaluating the ++ health of custom resources using Common Expression Language (CEL). ++ The expressions are evaluated only when Wait or HealthChecks are specified. ++ items: ++ description: CustomHealthCheck defines the health check for custom ++ resources. ++ properties: ++ apiVersion: ++ description: APIVersion of the custom resource under evaluation. ++ type: string ++ current: ++ description: |- ++ Current is the CEL expression that determines if the status ++ of the custom resource has reached the desired state. ++ type: string ++ failed: ++ description: |- ++ Failed is the CEL expression that determines if the status ++ of the custom resource has failed to reach the desired state. ++ type: string ++ inProgress: ++ description: |- ++ InProgress is the CEL expression that determines if the status ++ of the custom resource has not yet reached the desired state. ++ type: string ++ kind: ++ description: Kind of the custom resource under evaluation. ++ type: string ++ required: ++ - apiVersion ++ - current ++ type: object ++ type: array ++ healthChecks: ++ description: A list of resources to be included in the health assessment. ++ items: ++ description: |- ++ NamespacedObjectKindReference contains enough information to locate the typed referenced Kubernetes resource object ++ in any namespace. ++ properties: ++ apiVersion: ++ description: API version of the referent, if not specified the ++ Kubernetes preferred version will be used. ++ type: string ++ kind: ++ description: Kind of the referent. ++ type: string ++ name: ++ description: Name of the referent. ++ type: string ++ namespace: ++ description: Namespace of the referent, when not specified it ++ acts as LocalObjectReference. ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ type: array ++ ignore: ++ description: |- ++ Ignore is a list of rules for specifying which changes to ignore ++ during drift detection. These rules are applied to the resources managed ++ by the Kustomization and are used to exclude specific JSON pointer paths ++ from the drift detection and apply process. ++ items: ++ description: |- ++ IgnoreRule defines a rule to selectively disregard specific changes during ++ the drift detection process. ++ properties: ++ paths: ++ description: |- ++ Paths is a list of JSON Pointer (RFC 6901) paths to be excluded from ++ consideration in a Kubernetes object. ++ items: ++ type: string ++ type: array ++ target: ++ description: |- ++ Target is a selector for specifying Kubernetes objects to which this ++ rule applies. ++ If Target is not set, the Paths will be ignored for all Kubernetes ++ objects within the manifest of the Kustomization. ++ properties: ++ annotationSelector: ++ description: |- ++ AnnotationSelector is a string that follows the label selection expression ++ https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api ++ It matches with the resource annotations. ++ type: string ++ group: ++ description: |- ++ Group is the API group to select resources from. ++ Together with Version and Kind it is capable of unambiguously identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ kind: ++ description: |- ++ Kind of the API Group to select resources from. ++ Together with Group and Version it is capable of unambiguously ++ identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ labelSelector: ++ description: |- ++ LabelSelector is a string that follows the label selection expression ++ https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api ++ It matches with the resource labels. ++ type: string ++ name: ++ description: Name to match resources with. ++ type: string ++ namespace: ++ description: Namespace to select resources from. ++ type: string ++ version: ++ description: |- ++ Version of the API Group to select resources from. ++ Together with Group and Kind it is capable of unambiguously identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ type: object ++ required: ++ - paths ++ type: object ++ type: array ++ ignoreMissingComponents: ++ description: |- ++ IgnoreMissingComponents instructs the controller to ignore Components paths ++ not found in source by removing them from the generated kustomization.yaml ++ before running kustomize build. ++ type: boolean ++ images: ++ description: |- ++ Images is a list of (image name, new name, new tag or digest) ++ for changing image names, tags or digests. This can also be achieved with a ++ patch, but this operator is simpler to specify. ++ items: ++ description: Image contains an image name, a new name, a new tag ++ or digest, which will replace the original name and tag. ++ properties: ++ digest: ++ description: |- ++ Digest is the value used to replace the original image tag. ++ If digest is present NewTag value is ignored. ++ type: string ++ name: ++ description: Name is a tag-less image name. ++ type: string ++ newName: ++ description: NewName is the value used to replace the original ++ name. ++ type: string ++ newTag: ++ description: NewTag is the value used to replace the original ++ tag. ++ type: string ++ required: ++ - name ++ type: object ++ type: array ++ interval: ++ description: |- ++ The interval at which to reconcile the Kustomization. ++ This interval is approximate and may be subject to jitter to ensure ++ efficient use of resources. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ kubeConfig: ++ description: |- ++ The KubeConfig for reconciling the Kustomization on a remote cluster. ++ When used in combination with KustomizationSpec.ServiceAccountName, ++ forces the controller to act on behalf of that Service Account at the ++ target cluster. ++ If the --default-service-account flag is set, its value will be used as ++ a controller level fallback for when KustomizationSpec.ServiceAccountName ++ is empty. ++ properties: ++ configMapRef: ++ description: |- ++ ConfigMapRef holds an optional name of a ConfigMap that contains ++ the following keys: ++ ++ - `provider`: the provider to use. One of `aws`, `azure`, `gcp`, or ++ `generic`. Required. ++ - `cluster`: the fully qualified resource name of the Kubernetes ++ cluster in the cloud provider API. Not used by the `generic` ++ provider. Required when one of `address` or `ca.crt` is not set. ++ - `address`: the address of the Kubernetes API server. Required ++ for `generic`. For the other providers, if not specified, the ++ first address in the cluster resource will be used, and if ++ specified, it must match one of the addresses in the cluster ++ resource. ++ If audiences is not set, will be used as the audience for the ++ `generic` provider. ++ - `ca.crt`: the optional PEM-encoded CA certificate for the ++ Kubernetes API server. If not set, the controller will use the ++ CA certificate from the cluster resource. ++ - `audiences`: the optional audiences as a list of ++ line-break-separated strings for the Kubernetes ServiceAccount ++ token. Defaults to the `address` for the `generic` provider, or ++ to specific values for the other providers depending on the ++ provider. ++ - `serviceAccountName`: the optional name of the Kubernetes ++ ServiceAccount in the same namespace that should be used ++ for authentication. If not specified, the controller ++ ServiceAccount will be used. ++ ++ Mutually exclusive with SecretRef. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ secretRef: ++ description: |- ++ SecretRef holds an optional name of a secret that contains a key with ++ the kubeconfig file as the value. If no key is set, the key will default ++ to 'value'. Mutually exclusive with ConfigMapRef. ++ It is recommended that the kubeconfig is self-contained, and the secret ++ is regularly updated if credentials such as a cloud-access-token expire. ++ Cloud specific `cmd-path` auth helpers will not function without adding ++ binaries and credentials to the Pod that is responsible for reconciling ++ Kubernetes resources. Supported only for the generic provider. ++ properties: ++ key: ++ description: Key in the Secret, when not specified an implementation-specific ++ default key is used. ++ type: string ++ name: ++ description: Name of the Secret. ++ type: string ++ required: ++ - name ++ type: object ++ type: object ++ x-kubernetes-validations: ++ - message: exactly one of spec.kubeConfig.configMapRef or spec.kubeConfig.secretRef ++ must be specified ++ rule: has(self.configMapRef) || has(self.secretRef) ++ - message: exactly one of spec.kubeConfig.configMapRef or spec.kubeConfig.secretRef ++ must be specified ++ rule: '!has(self.configMapRef) || !has(self.secretRef)' ++ namePrefix: ++ description: NamePrefix will prefix the names of all managed resources. ++ maxLength: 200 ++ minLength: 1 ++ type: string ++ nameSuffix: ++ description: NameSuffix will suffix the names of all managed resources. ++ maxLength: 200 ++ minLength: 1 ++ type: string ++ patches: ++ description: |- ++ Strategic merge and JSON patches, defined as inline YAML objects, ++ capable of targeting objects based on kind, label and annotation selectors. ++ items: ++ description: |- ++ Patch contains an inline StrategicMerge or JSON6902 patch, and the target the patch should ++ be applied to. ++ properties: ++ patch: ++ description: |- ++ Patch contains an inline StrategicMerge patch or an inline JSON6902 patch with ++ an array of operation objects. ++ type: string ++ target: ++ description: Target points to the resources that the patch document ++ should be applied to. ++ properties: ++ annotationSelector: ++ description: |- ++ AnnotationSelector is a string that follows the label selection expression ++ https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api ++ It matches with the resource annotations. ++ type: string ++ group: ++ description: |- ++ Group is the API group to select resources from. ++ Together with Version and Kind it is capable of unambiguously identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ kind: ++ description: |- ++ Kind of the API Group to select resources from. ++ Together with Group and Version it is capable of unambiguously ++ identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ labelSelector: ++ description: |- ++ LabelSelector is a string that follows the label selection expression ++ https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api ++ It matches with the resource labels. ++ type: string ++ name: ++ description: Name to match resources with. ++ type: string ++ namespace: ++ description: Namespace to select resources from. ++ type: string ++ version: ++ description: |- ++ Version of the API Group to select resources from. ++ Together with Group and Kind it is capable of unambiguously identifying and/or selecting resources. ++ https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md ++ type: string ++ type: object ++ required: ++ - patch ++ type: object ++ type: array ++ path: ++ description: |- ++ Path to the directory containing the kustomization.yaml file, or the ++ set of plain YAMLs a kustomization.yaml should be generated for. ++ Defaults to 'None', which translates to the root path of the SourceRef. ++ type: string ++ postBuild: ++ description: |- ++ PostBuild describes which actions to perform on the YAML manifest ++ generated by building the kustomize overlay. ++ properties: ++ substitute: ++ additionalProperties: ++ type: string ++ description: |- ++ Substitute holds a map of key/value pairs. ++ The variables defined in your YAML manifests that match any of the keys ++ defined in the map will be substituted with the set value. ++ Includes support for bash string replacement functions ++ e.g. ${var:=default}, ${var:position} and ${var/substring/replacement}. ++ type: object ++ substituteFrom: ++ description: |- ++ SubstituteFrom holds references to ConfigMaps and Secrets containing ++ the variables and their values to be substituted in the YAML manifests. ++ The ConfigMap and the Secret data keys represent the var names, and they ++ must match the vars declared in the manifests for the substitution to ++ happen. ++ items: ++ description: |- ++ SubstituteReference contains a reference to a resource containing ++ the variables name and value. ++ properties: ++ kind: ++ description: Kind of the values referent, valid values are ++ ('Secret', 'ConfigMap'). ++ enum: ++ - Secret ++ - ConfigMap ++ type: string ++ name: ++ description: |- ++ Name of the values referent. Should reside in the same namespace as the ++ referring resource. ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ optional: ++ default: false ++ description: |- ++ Optional indicates whether the referenced resource must exist, or whether to ++ tolerate its absence. If true and the referenced resource is absent, proceed ++ as if the resource was present but empty, without any variables defined. ++ type: boolean ++ required: ++ - kind ++ - name ++ type: object ++ type: array ++ substituteStrategy: ++ description: |- ++ SubstituteStrategy defines the strategy for substituting variables in the YAML manifests. ++ Valid values are: ++ ++ - WithVariables (the default): require at least one variable to be defined, ++ either through the inline map or through the resolved references to ConfigMaps ++ and Secrets. ++ - Always: perform the substitution even if no variables are defined. ++ enum: ++ - WithVariables ++ - Always ++ type: string ++ type: object ++ prune: ++ description: Prune enables garbage collection. ++ type: boolean ++ retryInterval: ++ description: |- ++ The interval at which to retry a previously failed reconciliation. ++ When not specified, the controller uses the KustomizationSpec.Interval ++ value to retry failures. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ serviceAccountName: ++ description: |- ++ The name of the Kubernetes service account to impersonate ++ when reconciling this Kustomization. ++ type: string ++ sourceRef: ++ description: Reference of the source where the kustomization file ++ is. ++ properties: ++ apiVersion: ++ description: API version of the referent. ++ type: string ++ kind: ++ description: Kind of the referent. ++ enum: ++ - OCIRepository ++ - GitRepository ++ - Bucket ++ - ExternalArtifact ++ type: string ++ name: ++ description: Name of the referent. ++ type: string ++ namespace: ++ description: |- ++ Namespace of the referent, defaults to the namespace of the Kubernetes ++ resource object that contains the reference. ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ suspend: ++ description: |- ++ This flag tells the controller to suspend subsequent kustomize executions, ++ it does not apply to already started executions. Defaults to false. ++ type: boolean ++ targetNamespace: ++ description: |- ++ TargetNamespace sets or overrides the namespace in the ++ kustomization.yaml file. ++ maxLength: 63 ++ minLength: 1 ++ type: string ++ timeout: ++ description: |- ++ Timeout for validation, apply and health checking operations. ++ Defaults to 'Interval' duration. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ wait: ++ description: |- ++ Wait instructs the controller to check the health of all the reconciled ++ resources. When enabled, the HealthChecks are ignored. Defaults to false. ++ type: boolean ++ required: ++ - interval ++ - prune ++ - sourceRef ++ type: object ++ status: ++ default: ++ observedGeneration: -1 ++ description: KustomizationStatus defines the observed state of a kustomization. ++ properties: ++ conditions: ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ history: ++ description: |- ++ History contains a set of snapshots of the last reconciliation attempts ++ tracking the revision, the state and the duration of each attempt. ++ items: ++ description: |- ++ Snapshot represents a point-in-time record of a group of resources reconciliation, ++ including timing information, status, and a unique digest identifier. ++ properties: ++ digest: ++ description: Digest is the checksum in the format `:` ++ of the resources in this snapshot. ++ type: string ++ firstReconciled: ++ description: FirstReconciled is the time when this revision ++ was first reconciled to the cluster. ++ format: date-time ++ type: string ++ lastReconciled: ++ description: LastReconciled is the time when this revision was ++ last reconciled to the cluster. ++ format: date-time ++ type: string ++ lastReconciledDuration: ++ description: LastReconciledDuration is time it took to reconcile ++ the resources in this revision. ++ type: string ++ lastReconciledStatus: ++ description: LastReconciledStatus is the status of the last ++ reconciliation. ++ type: string ++ metadata: ++ additionalProperties: ++ type: string ++ description: Metadata contains additional information about ++ the snapshot. ++ type: object ++ totalReconciliations: ++ description: TotalReconciliations is the total number of reconciliations ++ that have occurred for this snapshot. ++ format: int64 ++ type: integer ++ required: ++ - digest ++ - firstReconciled ++ - lastReconciled ++ - lastReconciledDuration ++ - lastReconciledStatus ++ - totalReconciliations ++ type: object ++ type: array ++ inventory: ++ description: |- ++ Inventory contains the list of Kubernetes resource object references that ++ have been successfully applied. ++ properties: ++ entries: ++ description: Entries of Kubernetes resource object references. ++ items: ++ description: ResourceRef contains the information necessary ++ to locate a resource within a cluster. ++ properties: ++ id: ++ description: |- ++ ID is the string representation of the Kubernetes resource object's metadata, ++ in the format '___'. ++ type: string ++ v: ++ description: Version is the API version of the Kubernetes ++ resource object's kind. ++ type: string ++ required: ++ - id ++ - v ++ type: object ++ type: array ++ required: ++ - entries ++ type: object ++ lastAppliedOriginRevision: ++ description: |- ++ The last successfully applied origin revision. ++ Equals the origin revision of the applied Artifact from the referenced Source. ++ Usually present on the Metadata of the applied Artifact and depends on the ++ Source type, e.g. for OCI it's the value associated with the key ++ "org.opencontainers.image.revision". ++ type: string ++ lastAppliedRevision: ++ description: |- ++ The last successfully applied revision. ++ Equals the Revision of the applied Artifact from the referenced Source. ++ type: string ++ lastAttemptedRevision: ++ description: LastAttemptedRevision is the revision of the last reconciliation ++ attempt. ++ type: string ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ observedGeneration: ++ description: ObservedGeneration is the last reconciled generation. ++ format: int64 ++ type: integer ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} +diff --git a/usercase-test-coderl/fixtures/flux-manifests/kustomize-controller.deployment.yaml b/usercase-test-coderl/fixtures/flux-manifests/kustomize-controller.deployment.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/kustomize-controller.deployment.yaml +@@ -0,0 +1,73 @@ ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ labels: ++ control-plane: controller ++ name: kustomize-controller ++spec: ++ replicas: 1 ++ selector: ++ matchLabels: ++ app: kustomize-controller ++ template: ++ metadata: ++ annotations: ++ prometheus.io/port: "8080" ++ prometheus.io/scrape: "true" ++ labels: ++ app: kustomize-controller ++ spec: ++ containers: ++ - args: ++ - --watch-all-namespaces ++ - --log-level=info ++ - --log-encoding=json ++ - --enable-leader-election ++ env: ++ - name: RUNTIME_NAMESPACE ++ valueFrom: ++ fieldRef: ++ fieldPath: metadata.namespace ++ image: fluxcd/kustomize-controller:v1.9.3 ++ imagePullPolicy: IfNotPresent ++ livenessProbe: ++ httpGet: ++ path: /healthz ++ port: healthz ++ name: manager ++ ports: ++ - containerPort: 8080 ++ name: http-prom ++ protocol: TCP ++ - containerPort: 9440 ++ name: healthz ++ protocol: TCP ++ readinessProbe: ++ httpGet: ++ path: /readyz ++ port: healthz ++ resources: ++ limits: ++ cpu: 1000m ++ memory: 1Gi ++ requests: ++ cpu: 100m ++ memory: 64Mi ++ securityContext: ++ allowPrivilegeEscalation: false ++ capabilities: ++ drop: ++ - ALL ++ readOnlyRootFilesystem: true ++ runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault ++ volumeMounts: ++ - mountPath: /tmp ++ name: temp ++ securityContext: ++ fsGroup: 1337 ++ terminationGracePeriodSeconds: 60 ++ volumes: ++ - emptyDir: {} ++ name: temp +diff --git a/usercase-test-coderl/fixtures/flux-manifests/notification-controller.crds.yaml b/usercase-test-coderl/fixtures/flux-manifests/notification-controller.crds.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/notification-controller.crds.yaml +@@ -0,0 +1,744 @@ ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: alerts.notification.toolkit.fluxcd.io ++spec: ++ group: notification.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-notifications ++ kind: Alert ++ listKind: AlertList ++ plural: alerts ++ singular: alert ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ name: v1beta3 ++ schema: ++ openAPIV3Schema: ++ description: Alert is the Schema for the alerts API ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: AlertSpec defines an alerting rule for events involving a ++ list of objects. ++ properties: ++ eventMetadata: ++ additionalProperties: ++ type: string ++ description: |- ++ EventMetadata is an optional field for adding metadata to events dispatched by the ++ controller. This can be used for enhancing the context of the event. If a field ++ would override one already present on the original event as generated by the emitter, ++ then the override doesn't happen, i.e. the original value is preserved, and an info ++ log is printed. ++ type: object ++ eventSeverity: ++ default: info ++ description: |- ++ EventSeverity specifies how to filter events based on severity. ++ If set to 'info' no events will be filtered. ++ enum: ++ - info ++ - error ++ type: string ++ eventSources: ++ description: |- ++ EventSources specifies how to filter events based ++ on the involved object kind, name and namespace. ++ items: ++ description: |- ++ CrossNamespaceObjectReference contains enough information to let you locate the ++ typed referenced object at cluster level ++ properties: ++ apiVersion: ++ description: API version of the referent ++ type: string ++ kind: ++ description: Kind of the referent ++ enum: ++ - Bucket ++ - GitRepository ++ - Kustomization ++ - HelmRelease ++ - HelmChart ++ - HelmRepository ++ - ImageRepository ++ - ImagePolicy ++ - ImageUpdateAutomation ++ - OCIRepository ++ - ArtifactGenerator ++ - ExternalArtifact ++ type: string ++ matchLabels: ++ additionalProperties: ++ type: string ++ description: |- ++ MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels ++ map is equivalent to an element of matchExpressions, whose key field is "key", the ++ operator is "In", and the values array contains only "value". The requirements are ANDed. ++ MatchLabels requires the name to be set to `*`. ++ type: object ++ name: ++ description: |- ++ Name of the referent ++ If multiple resources are targeted `*` may be set. ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ namespace: ++ description: Namespace of the referent ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ type: array ++ exclusionList: ++ description: |- ++ ExclusionList specifies a list of Golang regular expressions ++ to be used for excluding messages. ++ items: ++ type: string ++ type: array ++ inclusionList: ++ description: |- ++ InclusionList specifies a list of Golang regular expressions ++ to be used for including messages. ++ items: ++ type: string ++ type: array ++ providerRef: ++ description: ProviderRef specifies which Provider this Alert should ++ use. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ summary: ++ description: |- ++ Summary holds a short description of the impact and affected cluster. ++ Deprecated: Use EventMetadata instead. ++ maxLength: 255 ++ type: string ++ suspend: ++ description: |- ++ Suspend tells the controller to suspend subsequent ++ events handling for this Alert. ++ type: boolean ++ required: ++ - eventSources ++ - providerRef ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: {} ++--- ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: providers.notification.toolkit.fluxcd.io ++spec: ++ group: notification.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-notifications ++ kind: Provider ++ listKind: ProviderList ++ plural: providers ++ singular: provider ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ name: v1beta3 ++ schema: ++ openAPIV3Schema: ++ description: Provider is the Schema for the providers API ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: ProviderSpec defines the desired state of the Provider. ++ properties: ++ address: ++ description: |- ++ Address specifies the endpoint, in a generic sense, to where alerts are sent. ++ What kind of endpoint depends on the specific Provider type being used. ++ For the generic Provider, for example, this is an HTTP/S address. ++ For other Provider types this could be a project ID or a namespace. ++ maxLength: 2048 ++ type: string ++ certSecretRef: ++ description: |- ++ CertSecretRef specifies the Secret containing TLS certificates ++ for secure communication. ++ ++ Supported configurations: ++ - CA-only: Server authentication (provide ca.crt only) ++ - mTLS: Mutual authentication (provide ca.crt + tls.crt + tls.key) ++ - Client-only: Client authentication with system CA (provide tls.crt + tls.key only) ++ ++ Legacy keys "caFile", "certFile", "keyFile" are supported but deprecated. Use "ca.crt", "tls.crt", "tls.key" instead. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ channel: ++ description: Channel specifies the destination channel where events ++ should be posted. ++ maxLength: 2048 ++ type: string ++ commitStatusExpr: ++ description: |- ++ CommitStatusExpr is a CEL expression that evaluates to a string value ++ that can be used to generate a custom commit status message for use ++ with eligible Provider types (github, gitlab, gitea, bitbucketserver, ++ bitbucket, azuredevops). Supported variables are: event, provider, ++ and alert. ++ type: string ++ interval: ++ description: |- ++ Interval at which to reconcile the Provider with its Secret references. ++ Deprecated and not used in v1beta3. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ proxy: ++ description: |- ++ Proxy the HTTP/S address of the proxy server. ++ Deprecated: Use ProxySecretRef instead. Will be removed in v1. ++ maxLength: 2048 ++ pattern: ^(http|https)://.*$ ++ type: string ++ proxySecretRef: ++ description: |- ++ ProxySecretRef specifies the Secret containing the proxy configuration ++ for this Provider. The Secret should contain an 'address' key with the ++ HTTP/S address of the proxy server. Optional 'username' and 'password' ++ keys can be provided for proxy authentication. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ secretRef: ++ description: |- ++ SecretRef specifies the Secret containing the authentication ++ credentials for this Provider. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ serviceAccountName: ++ description: |- ++ ServiceAccountName is the name of the Kubernetes ServiceAccount used to ++ authenticate with cloud provider services through workload identity. ++ This enables multi-tenant authentication without storing static credentials. ++ ++ Supported provider types: azureeventhub, azuredevops, googlepubsub ++ ++ When specified, the controller will: ++ 1. Create an OIDC token for the specified ServiceAccount ++ 2. Exchange it for cloud provider credentials via STS ++ 3. Use the obtained credentials for API authentication ++ ++ When unspecified, controller-level authentication is used (single-tenant). ++ ++ An error is thrown if static credentials are also defined in SecretRef. ++ This field requires the ObjectLevelWorkloadIdentity feature gate to be enabled. ++ type: string ++ suspend: ++ description: |- ++ Suspend tells the controller to suspend subsequent ++ events handling for this Provider. ++ type: boolean ++ timeout: ++ description: Timeout for sending alerts to the Provider. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$ ++ type: string ++ type: ++ description: Type specifies which Provider implementation to use. ++ enum: ++ - slack ++ - discord ++ - msteams ++ - rocket ++ - generic ++ - generic-hmac ++ - github ++ - gitlab ++ - gitea ++ - giteapullrequestcomment ++ - bitbucketserver ++ - bitbucket ++ - azuredevops ++ - googlechat ++ - googlepubsub ++ - webex ++ - sentry ++ - azureeventhub ++ - telegram ++ - lark ++ - matrix ++ - opsgenie ++ - alertmanager ++ - grafana ++ - githubdispatch ++ - githubpullrequestcomment ++ - gitlabmergerequestcomment ++ - pagerduty ++ - datadog ++ - nats ++ - zulip ++ - otel ++ type: string ++ username: ++ description: Username specifies the name under which events are posted. ++ maxLength: 2048 ++ type: string ++ required: ++ - type ++ type: object ++ x-kubernetes-validations: ++ - message: spec.commitStatusExpr is only supported for the 'github', 'gitlab', ++ 'gitea', 'bitbucketserver', 'bitbucket', 'azuredevops' provider types ++ rule: self.type == 'github' || self.type == 'gitlab' || self.type == ++ 'gitea' || self.type == 'bitbucketserver' || self.type == 'bitbucket' ++ || self.type == 'azuredevops' || !has(self.commitStatusExpr) ++ type: object ++ served: true ++ storage: true ++ subresources: {} ++--- ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: receivers.notification.toolkit.fluxcd.io ++spec: ++ group: notification.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-notifications ++ kind: Receiver ++ listKind: ReceiverList ++ plural: receivers ++ singular: receiver ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: Receiver is the Schema for the receivers API. ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: ReceiverSpec defines the desired state of the Receiver. ++ properties: ++ events: ++ description: |- ++ Events specifies the list of event types to handle, ++ e.g. 'push' for GitHub or 'Push Hook' for GitLab. ++ items: ++ type: string ++ type: array ++ interval: ++ default: 10m ++ description: Interval at which to reconcile the Receiver with its ++ Secret references. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ oidcProviders: ++ description: |- ++ OIDCProviders specifies the OIDC providers used to authenticate incoming ++ requests when Type is 'generic-oidc'. The provider whose IssuerURL matches ++ the token's 'iss' claim is used to verify the token signature, expiration ++ and audience, and to evaluate the configured CEL validations against the ++ token claims. ++ items: ++ description: |- ++ OIDCProvider configures an OIDC issuer used to authenticate requests for a ++ 'generic-oidc' Receiver. ++ properties: ++ audience: ++ description: |- ++ Audience is the expected audience ('aud' claim) for tokens issued by ++ this provider. Defaults to 'notification-controller'. ++ type: string ++ issuerURL: ++ description: |- ++ IssuerURL is the OIDC issuer URL used for provider discovery. It must ++ match the 'iss' claim of tokens issued by this provider. ++ pattern: ^https?:// ++ type: string ++ validations: ++ description: |- ++ Validations is the list of CEL boolean expressions evaluated against the ++ token claims and the variables. The request is accepted only if all of ++ them evaluate to true; the message of each failing expression is returned ++ to the caller. ++ ++ At least one validation is required. A valid signature alone does not ++ authorize a request: public issuers issue tokens to any caller on the ++ platform, so the validations must constrain the caller's identity claims ++ (e.g. 'repository_owner' for GitHub Actions). ++ items: ++ description: |- ++ OIDCValidation is a CEL boolean expression evaluated against the OIDC token ++ claims and variables of a 'generic-oidc' Receiver. ++ properties: ++ expression: ++ description: Expression is the CEL boolean expression ++ to evaluate. ++ type: string ++ message: ++ description: Message is returned to the caller when the ++ expression evaluates to false. ++ type: string ++ required: ++ - expression ++ - message ++ type: object ++ minItems: 1 ++ type: array ++ variables: ++ description: |- ++ Variables is an optional list of named CEL expressions, evaluated in order ++ and exposed as 'vars.'. Each expression can read the token claims ++ via 'claims' and any variable defined before it. Use it to share ++ sub-expressions across validations. ++ items: ++ description: |- ++ OIDCVariable is a named CEL expression evaluated against the OIDC token ++ claims of a 'generic-oidc' Receiver. ++ properties: ++ expression: ++ description: Expression is the CEL expression that defines ++ the variable value. ++ type: string ++ name: ++ description: Name is the variable name; it must be a valid ++ CEL identifier. ++ type: string ++ required: ++ - expression ++ - name ++ type: object ++ type: array ++ required: ++ - issuerURL ++ - validations ++ type: object ++ type: array ++ x-kubernetes-list-map-keys: ++ - issuerURL ++ x-kubernetes-list-type: map ++ resourceFilter: ++ description: |- ++ ResourceFilter is a CEL expression expected to return a boolean that is ++ evaluated for each resource referenced in the Resources field when a ++ webhook is received. If the expression returns false then the controller ++ will not request a reconciliation for the resource. ++ The expression can read the resource metadata via 'res' and the webhook ++ request body via 'req'. For generic-oidc receivers, the verified OIDC ++ token claims are also available via 'claims'. ++ When the expression is specified the controller will parse it and mark ++ the object as terminally failed if the expression is invalid or does not ++ return a boolean. ++ type: string ++ resources: ++ description: A list of resources to be notified about changes. ++ items: ++ description: |- ++ ReceiverResource references a resource to be notified about changes, with an ++ optional per-resource CEL filter. ++ properties: ++ apiVersion: ++ description: API version of the referent ++ type: string ++ filter: ++ description: |- ++ Filter is a CEL expression expected to return a boolean that is evaluated ++ for each resource matched by this reference when a webhook is received, ++ in addition to the top-level resourceFilter. A reconciliation is requested ++ only when both expressions (when set) return true. ++ The expression can read the resource metadata via 'res' and the webhook ++ request body via 'req'. For generic-oidc receivers, the verified OIDC ++ token claims are also available via 'claims'. ++ When the expression is specified the controller will parse it and mark ++ the object as terminally failed if the expression is invalid or does not ++ return a boolean. ++ type: string ++ kind: ++ description: Kind of the referent ++ enum: ++ - Bucket ++ - GitRepository ++ - Kustomization ++ - HelmRelease ++ - HelmChart ++ - HelmRepository ++ - ImageRepository ++ - ImagePolicy ++ - ImageUpdateAutomation ++ - OCIRepository ++ - ArtifactGenerator ++ - ExternalArtifact ++ type: string ++ matchLabels: ++ additionalProperties: ++ type: string ++ description: |- ++ MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels ++ map is equivalent to an element of matchExpressions, whose key field is "key", the ++ operator is "In", and the values array contains only "value". The requirements are ANDed. ++ MatchLabels requires the name to be set to `*`. ++ type: object ++ name: ++ description: |- ++ Name of the referent ++ If multiple resources are targeted `*` may be set. ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ namespace: ++ description: Namespace of the referent ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ type: array ++ secretRef: ++ description: |- ++ SecretRef specifies the Secret containing the token used ++ to validate the payload authenticity. The Secret must contain a 'token' ++ key. For GCR receivers, the Secret must also contain an 'email' key ++ with the IAM service account email configured on the Pub/Sub push ++ subscription, and an 'audience' key with the expected OIDC token audience. ++ ++ Required for all receiver types except 'generic-oidc', which authenticates ++ requests using the OIDC token instead and must not set this field. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ suspend: ++ description: |- ++ Suspend tells the controller to suspend subsequent ++ events handling for this receiver. ++ type: boolean ++ type: ++ description: |- ++ Type of webhook sender, used to determine ++ the validation procedure and payload deserialization. ++ enum: ++ - generic ++ - generic-hmac ++ - generic-oidc ++ - github ++ - gitlab ++ - bitbucket ++ - harbor ++ - dockerhub ++ - quay ++ - gcr ++ - nexus ++ - acr ++ - cdevents ++ type: string ++ required: ++ - resources ++ - type ++ type: object ++ x-kubernetes-validations: ++ - message: generic-oidc receivers must define at least one oidcProvider ++ rule: self.type != 'generic-oidc' || (has(self.oidcProviders) && size(self.oidcProviders) ++ > 0) ++ - message: oidcProviders can only be set when type is generic-oidc ++ rule: self.type == 'generic-oidc' || !has(self.oidcProviders) || size(self.oidcProviders) ++ == 0 ++ - message: secretRef cannot be set when type is generic-oidc ++ rule: self.type != 'generic-oidc' || !has(self.secretRef) ++ - message: secretRef is required when type is not generic-oidc ++ rule: self.type == 'generic-oidc' || has(self.secretRef) ++ status: ++ default: ++ observedGeneration: -1 ++ description: ReceiverStatus defines the observed state of the Receiver. ++ properties: ++ conditions: ++ description: Conditions holds the conditions for the Receiver. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ observedGeneration: ++ description: ObservedGeneration is the last observed generation of ++ the Receiver object. ++ format: int64 ++ type: integer ++ webhookPath: ++ description: |- ++ WebhookPath is the generated incoming webhook address in the format ++ of '/hook/sha256sum(token+name+namespace)'. ++ type: string ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} +diff --git a/usercase-test-coderl/fixtures/flux-manifests/notification-controller.deployment.yaml b/usercase-test-coderl/fixtures/flux-manifests/notification-controller.deployment.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/notification-controller.deployment.yaml +@@ -0,0 +1,111 @@ ++apiVersion: v1 ++kind: Service ++metadata: ++ labels: ++ control-plane: controller ++ name: notification-controller ++spec: ++ ports: ++ - name: http ++ port: 80 ++ protocol: TCP ++ targetPort: http ++ selector: ++ app: notification-controller ++ type: ClusterIP ++--- ++apiVersion: v1 ++kind: Service ++metadata: ++ labels: ++ control-plane: controller ++ name: webhook-receiver ++spec: ++ ports: ++ - name: http ++ port: 80 ++ protocol: TCP ++ targetPort: http-webhook ++ selector: ++ app: notification-controller ++ type: ClusterIP ++--- ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ labels: ++ control-plane: controller ++ name: notification-controller ++spec: ++ replicas: 1 ++ selector: ++ matchLabels: ++ app: notification-controller ++ template: ++ metadata: ++ annotations: ++ prometheus.io/port: "8080" ++ prometheus.io/scrape: "true" ++ labels: ++ app: notification-controller ++ spec: ++ containers: ++ - args: ++ - --watch-all-namespaces ++ - --log-level=info ++ - --log-encoding=json ++ - --enable-leader-election ++ env: ++ - name: RUNTIME_NAMESPACE ++ valueFrom: ++ fieldRef: ++ fieldPath: metadata.namespace ++ image: fluxcd/notification-controller:v1.9.2 ++ imagePullPolicy: IfNotPresent ++ livenessProbe: ++ httpGet: ++ path: /healthz ++ port: healthz ++ name: manager ++ ports: ++ - containerPort: 9090 ++ name: http ++ protocol: TCP ++ - containerPort: 9292 ++ name: http-webhook ++ protocol: TCP ++ - containerPort: 8080 ++ name: http-prom ++ protocol: TCP ++ - containerPort: 9440 ++ name: healthz ++ protocol: TCP ++ readinessProbe: ++ httpGet: ++ path: /readyz ++ port: healthz ++ resources: ++ limits: ++ cpu: 1000m ++ memory: 1Gi ++ requests: ++ cpu: 100m ++ memory: 64Mi ++ securityContext: ++ allowPrivilegeEscalation: false ++ capabilities: ++ drop: ++ - ALL ++ readOnlyRootFilesystem: true ++ runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault ++ volumeMounts: ++ - mountPath: /tmp ++ name: temp ++ securityContext: ++ fsGroup: 1337 ++ terminationGracePeriodSeconds: 10 ++ volumes: ++ - emptyDir: {} ++ name: temp +diff --git a/usercase-test-coderl/fixtures/flux-manifests/source-controller.crds.yaml b/usercase-test-coderl/fixtures/flux-manifests/source-controller.crds.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/source-controller.crds.yaml +@@ -0,0 +1,2188 @@ ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: buckets.source.toolkit.fluxcd.io ++spec: ++ group: source.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-sources ++ kind: Bucket ++ listKind: BucketList ++ plural: buckets ++ singular: bucket ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .spec.endpoint ++ name: Endpoint ++ type: string ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: Bucket is the Schema for the buckets API. ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: |- ++ BucketSpec specifies the required configuration to produce an Artifact for ++ an object storage bucket. ++ properties: ++ bucketName: ++ description: BucketName is the name of the object storage bucket. ++ type: string ++ certSecretRef: ++ description: |- ++ CertSecretRef can be given the name of a Secret containing ++ either or both of ++ ++ - a PEM-encoded client certificate (`tls.crt`) and private ++ key (`tls.key`); ++ - a PEM-encoded CA certificate (`ca.crt`) ++ ++ and whichever are supplied, will be used for connecting to the ++ bucket. The client cert and key are useful if you are ++ authenticating with a certificate; the CA cert is useful if ++ you are using a self-signed server certificate. The Secret must ++ be of type `Opaque` or `kubernetes.io/tls`. ++ ++ This field is only supported for the `generic` provider. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ endpoint: ++ description: Endpoint is the object storage address the BucketName ++ is located at. ++ type: string ++ ignore: ++ description: |- ++ Ignore overrides the set of excluded patterns in the .sourceignore format ++ (which is the same as .gitignore). If not provided, a default will be used, ++ consult the documentation for your version to find out what those are. ++ type: string ++ insecure: ++ description: Insecure allows connecting to a non-TLS HTTP Endpoint. ++ type: boolean ++ interval: ++ description: |- ++ Interval at which the Bucket Endpoint is checked for updates. ++ This interval is approximate and may be subject to jitter to ensure ++ efficient use of resources. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ prefix: ++ description: Prefix to use for server-side filtering of files in the ++ Bucket. ++ type: string ++ provider: ++ default: generic ++ description: |- ++ Provider of the object storage bucket. ++ Defaults to 'generic', which expects an S3 (API) compatible object ++ storage. ++ enum: ++ - generic ++ - aws ++ - gcp ++ - azure ++ type: string ++ proxySecretRef: ++ description: |- ++ ProxySecretRef specifies the Secret containing the proxy configuration ++ to use while communicating with the Bucket server. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ region: ++ description: Region of the Endpoint where the BucketName is located ++ in. ++ type: string ++ secretRef: ++ description: |- ++ SecretRef specifies the Secret containing authentication credentials ++ for the Bucket. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ serviceAccountName: ++ description: |- ++ ServiceAccountName is the name of the Kubernetes ServiceAccount used to authenticate ++ the bucket. This field is only supported for the 'gcp' and 'aws' providers. ++ For more information about workload identity: ++ https://fluxcd.io/flux/components/source/buckets/#workload-identity ++ type: string ++ sts: ++ description: |- ++ STS specifies the required configuration to use a Security Token ++ Service for fetching temporary credentials to authenticate in a ++ Bucket provider. ++ ++ This field is only supported for the `aws` and `generic` providers. ++ properties: ++ certSecretRef: ++ description: |- ++ CertSecretRef can be given the name of a Secret containing ++ either or both of ++ ++ - a PEM-encoded client certificate (`tls.crt`) and private ++ key (`tls.key`); ++ - a PEM-encoded CA certificate (`ca.crt`) ++ ++ and whichever are supplied, will be used for connecting to the ++ STS endpoint. The client cert and key are useful if you are ++ authenticating with a certificate; the CA cert is useful if ++ you are using a self-signed server certificate. The Secret must ++ be of type `Opaque` or `kubernetes.io/tls`. ++ ++ This field is only supported for the `ldap` provider. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ endpoint: ++ description: |- ++ Endpoint is the HTTP/S endpoint of the Security Token Service from ++ where temporary credentials will be fetched. ++ pattern: ^(http|https)://.*$ ++ type: string ++ provider: ++ description: Provider of the Security Token Service. ++ enum: ++ - aws ++ - ldap ++ type: string ++ secretRef: ++ description: |- ++ SecretRef specifies the Secret containing authentication credentials ++ for the STS endpoint. This Secret must contain the fields `username` ++ and `password` and is supported only for the `ldap` provider. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ required: ++ - endpoint ++ - provider ++ type: object ++ suspend: ++ description: |- ++ Suspend tells the controller to suspend the reconciliation of this ++ Bucket. ++ type: boolean ++ timeout: ++ default: 60s ++ description: Timeout for fetch operations, defaults to 60s. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$ ++ type: string ++ required: ++ - bucketName ++ - endpoint ++ - interval ++ type: object ++ x-kubernetes-validations: ++ - message: STS configuration is only supported for the 'aws' and 'generic' ++ Bucket providers ++ rule: self.provider == 'aws' || self.provider == 'generic' || !has(self.sts) ++ - message: '''aws'' is the only supported STS provider for the ''aws'' ++ Bucket provider' ++ rule: self.provider != 'aws' || !has(self.sts) || self.sts.provider ++ == 'aws' ++ - message: '''ldap'' is the only supported STS provider for the ''generic'' ++ Bucket provider' ++ rule: self.provider != 'generic' || !has(self.sts) || self.sts.provider ++ == 'ldap' ++ - message: spec.sts.secretRef is not required for the 'aws' STS provider ++ rule: '!has(self.sts) || self.sts.provider != ''aws'' || !has(self.sts.secretRef)' ++ - message: spec.sts.certSecretRef is not required for the 'aws' STS provider ++ rule: '!has(self.sts) || self.sts.provider != ''aws'' || !has(self.sts.certSecretRef)' ++ - message: ServiceAccountName is not supported for the 'generic' Bucket ++ provider ++ rule: self.provider != 'generic' || !has(self.serviceAccountName) ++ - message: cannot set both .spec.secretRef and .spec.serviceAccountName ++ rule: '!has(self.secretRef) || !has(self.serviceAccountName)' ++ status: ++ default: ++ observedGeneration: -1 ++ description: BucketStatus records the observed state of a Bucket. ++ properties: ++ artifact: ++ description: Artifact represents the last successful Bucket reconciliation. ++ properties: ++ digest: ++ description: Digest is the digest of the file in the form of ':'. ++ pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$ ++ type: string ++ lastUpdateTime: ++ description: |- ++ LastUpdateTime is the timestamp corresponding to the last update of the ++ Artifact. ++ format: date-time ++ type: string ++ metadata: ++ additionalProperties: ++ type: string ++ description: Metadata holds upstream information such as OCI annotations. ++ type: object ++ path: ++ description: |- ++ Path is the relative file path of the Artifact. It can be used to locate ++ the file in the root of the Artifact storage on the local file system of ++ the controller managing the Source. ++ type: string ++ revision: ++ description: |- ++ Revision is a human-readable identifier traceable in the origin source ++ system. It can be a Git commit SHA, Git tag, a Helm chart version, etc. ++ type: string ++ size: ++ description: Size is the number of bytes in the file. ++ format: int64 ++ type: integer ++ url: ++ description: |- ++ URL is the HTTP address of the Artifact as exposed by the controller ++ managing the Source. It can be used to retrieve the Artifact for ++ consumption, e.g. by another controller applying the Artifact contents. ++ type: string ++ required: ++ - digest ++ - lastUpdateTime ++ - path ++ - revision ++ - url ++ type: object ++ conditions: ++ description: Conditions holds the conditions for the Bucket. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ observedGeneration: ++ description: ObservedGeneration is the last observed generation of ++ the Bucket object. ++ format: int64 ++ type: integer ++ observedIgnore: ++ description: |- ++ ObservedIgnore is the observed exclusion patterns used for constructing ++ the source artifact. ++ type: string ++ url: ++ description: |- ++ URL is the dynamic fetch link for the latest Artifact. ++ It is provided on a "best effort" basis, and using the precise ++ BucketStatus.Artifact data is recommended. ++ type: string ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} ++--- ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: externalartifacts.source.toolkit.fluxcd.io ++spec: ++ group: source.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-sources ++ kind: ExternalArtifact ++ listKind: ExternalArtifactList ++ plural: externalartifacts ++ shortNames: ++ - ea ++ singular: externalartifact ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ - jsonPath: .spec.sourceRef.name ++ name: Source ++ type: string ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: ExternalArtifact is the Schema for the external artifacts API ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: ExternalArtifactSpec defines the desired state of ExternalArtifact ++ properties: ++ sourceRef: ++ description: |- ++ SourceRef points to the Kubernetes custom resource for ++ which the artifact is generated. ++ properties: ++ apiVersion: ++ description: API version of the referent, if not specified the ++ Kubernetes preferred version will be used. ++ type: string ++ kind: ++ description: Kind of the referent. ++ type: string ++ name: ++ description: Name of the referent. ++ type: string ++ namespace: ++ description: Namespace of the referent, when not specified it ++ acts as LocalObjectReference. ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ type: object ++ status: ++ description: ExternalArtifactStatus defines the observed state of ExternalArtifact ++ properties: ++ artifact: ++ description: Artifact represents the output of an ExternalArtifact ++ reconciliation. ++ properties: ++ digest: ++ description: Digest is the digest of the file in the form of ':'. ++ pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$ ++ type: string ++ lastUpdateTime: ++ description: |- ++ LastUpdateTime is the timestamp corresponding to the last update of the ++ Artifact. ++ format: date-time ++ type: string ++ metadata: ++ additionalProperties: ++ type: string ++ description: Metadata holds upstream information such as OCI annotations. ++ type: object ++ path: ++ description: |- ++ Path is the relative file path of the Artifact. It can be used to locate ++ the file in the root of the Artifact storage on the local file system of ++ the controller managing the Source. ++ type: string ++ revision: ++ description: |- ++ Revision is a human-readable identifier traceable in the origin source ++ system. It can be a Git commit SHA, Git tag, a Helm chart version, etc. ++ type: string ++ size: ++ description: Size is the number of bytes in the file. ++ format: int64 ++ type: integer ++ url: ++ description: |- ++ URL is the HTTP address of the Artifact as exposed by the controller ++ managing the Source. It can be used to retrieve the Artifact for ++ consumption, e.g. by another controller applying the Artifact contents. ++ type: string ++ required: ++ - digest ++ - lastUpdateTime ++ - path ++ - revision ++ - url ++ type: object ++ conditions: ++ description: Conditions holds the conditions for the ExternalArtifact. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} ++--- ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: gitrepositories.source.toolkit.fluxcd.io ++spec: ++ group: source.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-sources ++ kind: GitRepository ++ listKind: GitRepositoryList ++ plural: gitrepositories ++ shortNames: ++ - gitrepo ++ singular: gitrepository ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .spec.url ++ name: URL ++ type: string ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: GitRepository is the Schema for the gitrepositories API. ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: |- ++ GitRepositorySpec specifies the required configuration to produce an ++ Artifact for a Git repository. ++ properties: ++ ignore: ++ description: |- ++ Ignore overrides the set of excluded patterns in the .sourceignore format ++ (which is the same as .gitignore). If not provided, a default will be used, ++ consult the documentation for your version to find out what those are. ++ type: string ++ include: ++ description: |- ++ Include specifies a list of GitRepository resources which Artifacts ++ should be included in the Artifact produced for this GitRepository. ++ items: ++ description: |- ++ GitRepositoryInclude specifies a local reference to a GitRepository which ++ Artifact (sub-)contents must be included, and where they should be placed. ++ properties: ++ fromPath: ++ description: |- ++ FromPath specifies the path to copy contents from, defaults to the root ++ of the Artifact. ++ type: string ++ repository: ++ description: |- ++ GitRepositoryRef specifies the GitRepository which Artifact contents ++ must be included. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ toPath: ++ description: |- ++ ToPath specifies the path to copy contents to, defaults to the name of ++ the GitRepositoryRef. ++ type: string ++ required: ++ - repository ++ type: object ++ type: array ++ interval: ++ description: |- ++ Interval at which the GitRepository URL is checked for updates. ++ This interval is approximate and may be subject to jitter to ensure ++ efficient use of resources. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ provider: ++ description: |- ++ Provider used for authentication, can be 'aws', 'azure', 'github', 'generic'. ++ When not specified, defaults to 'generic'. ++ enum: ++ - generic ++ - aws ++ - azure ++ - github ++ type: string ++ proxySecretRef: ++ description: |- ++ ProxySecretRef specifies the Secret containing the proxy configuration ++ to use while communicating with the Git server. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ recurseSubmodules: ++ description: |- ++ RecurseSubmodules enables the initialization of all submodules within ++ the GitRepository as cloned from the URL, using their default settings. ++ type: boolean ++ ref: ++ description: |- ++ Reference specifies the Git reference to resolve and monitor for ++ changes, defaults to the 'master' branch. ++ properties: ++ branch: ++ description: Branch to check out, defaults to 'master' if no other ++ field is defined. ++ type: string ++ commit: ++ description: |- ++ Commit SHA to check out, takes precedence over all reference fields. ++ ++ This can be combined with Branch to shallow clone the branch, in which ++ the commit is expected to exist. ++ type: string ++ name: ++ description: |- ++ Name of the reference to check out; takes precedence over Branch, Tag and SemVer. ++ ++ It must be a valid Git reference: https://git-scm.com/docs/git-check-ref-format#_description ++ Examples: "refs/heads/main", "refs/tags/v0.1.0", "refs/pull/420/head", "refs/merge-requests/1/head" ++ type: string ++ semver: ++ description: SemVer tag expression to check out, takes precedence ++ over Tag. ++ type: string ++ tag: ++ description: Tag to check out, takes precedence over Branch. ++ type: string ++ type: object ++ secretRef: ++ description: |- ++ SecretRef specifies the Secret containing authentication credentials for ++ the GitRepository. ++ For HTTPS repositories the Secret must contain 'username' and 'password' ++ fields for basic auth or 'bearerToken' field for token auth. ++ For SSH repositories the Secret must contain 'identity' ++ and 'known_hosts' fields. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ serviceAccountName: ++ description: |- ++ ServiceAccountName is the name of the Kubernetes ServiceAccount used to ++ authenticate to the GitRepository. This field is only supported for 'azure' and 'aws' providers. ++ type: string ++ sparseCheckout: ++ description: |- ++ SparseCheckout specifies a list of directories to checkout when cloning ++ the repository. If specified, only these directories are included in the ++ Artifact produced for this GitRepository. ++ items: ++ type: string ++ type: array ++ suspend: ++ description: |- ++ Suspend tells the controller to suspend the reconciliation of this ++ GitRepository. ++ type: boolean ++ timeout: ++ default: 60s ++ description: Timeout for Git operations like cloning, defaults to ++ 60s. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$ ++ type: string ++ url: ++ description: URL specifies the Git repository URL, it can be an HTTP/S ++ or SSH address. ++ pattern: ^(http|https|ssh)://.*$ ++ type: string ++ verify: ++ description: |- ++ Verification specifies the configuration to verify the Git commit ++ signature(s). ++ properties: ++ mode: ++ default: HEAD ++ description: |- ++ Mode specifies which Git object(s) should be verified. ++ ++ The variants "head" and "HEAD" both imply the same thing, i.e. verify ++ the commit that the HEAD of the Git repository points to. The variant ++ "head" solely exists to ensure backwards compatibility. ++ enum: ++ - head ++ - HEAD ++ - Tag ++ - TagAndHEAD ++ type: string ++ secretRef: ++ description: |- ++ SecretRef specifies the Secret containing the public keys of trusted Git ++ authors. PGP public keys must be stored under keys with the .asc suffix, ++ and SSH public keys must be stored under keys with the .sshpub suffix. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ required: ++ - secretRef ++ type: object ++ required: ++ - interval ++ - url ++ type: object ++ x-kubernetes-validations: ++ - message: serviceAccountName can only be set when provider is 'azure' ++ or 'aws' ++ rule: '!has(self.serviceAccountName) || (has(self.provider) && (self.provider ++ == ''azure'' || self.provider == ''aws''))' ++ status: ++ default: ++ observedGeneration: -1 ++ description: GitRepositoryStatus records the observed state of a Git repository. ++ properties: ++ artifact: ++ description: Artifact represents the last successful GitRepository ++ reconciliation. ++ properties: ++ digest: ++ description: Digest is the digest of the file in the form of ':'. ++ pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$ ++ type: string ++ lastUpdateTime: ++ description: |- ++ LastUpdateTime is the timestamp corresponding to the last update of the ++ Artifact. ++ format: date-time ++ type: string ++ metadata: ++ additionalProperties: ++ type: string ++ description: Metadata holds upstream information such as OCI annotations. ++ type: object ++ path: ++ description: |- ++ Path is the relative file path of the Artifact. It can be used to locate ++ the file in the root of the Artifact storage on the local file system of ++ the controller managing the Source. ++ type: string ++ revision: ++ description: |- ++ Revision is a human-readable identifier traceable in the origin source ++ system. It can be a Git commit SHA, Git tag, a Helm chart version, etc. ++ type: string ++ size: ++ description: Size is the number of bytes in the file. ++ format: int64 ++ type: integer ++ url: ++ description: |- ++ URL is the HTTP address of the Artifact as exposed by the controller ++ managing the Source. It can be used to retrieve the Artifact for ++ consumption, e.g. by another controller applying the Artifact contents. ++ type: string ++ required: ++ - digest ++ - lastUpdateTime ++ - path ++ - revision ++ - url ++ type: object ++ conditions: ++ description: Conditions holds the conditions for the GitRepository. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ includedArtifacts: ++ description: |- ++ IncludedArtifacts contains a list of the last successfully included ++ Artifacts as instructed by GitRepositorySpec.Include. ++ items: ++ description: Artifact represents the output of a Source reconciliation. ++ properties: ++ digest: ++ description: Digest is the digest of the file in the form of ++ ':'. ++ pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$ ++ type: string ++ lastUpdateTime: ++ description: |- ++ LastUpdateTime is the timestamp corresponding to the last update of the ++ Artifact. ++ format: date-time ++ type: string ++ metadata: ++ additionalProperties: ++ type: string ++ description: Metadata holds upstream information such as OCI ++ annotations. ++ type: object ++ path: ++ description: |- ++ Path is the relative file path of the Artifact. It can be used to locate ++ the file in the root of the Artifact storage on the local file system of ++ the controller managing the Source. ++ type: string ++ revision: ++ description: |- ++ Revision is a human-readable identifier traceable in the origin source ++ system. It can be a Git commit SHA, Git tag, a Helm chart version, etc. ++ type: string ++ size: ++ description: Size is the number of bytes in the file. ++ format: int64 ++ type: integer ++ url: ++ description: |- ++ URL is the HTTP address of the Artifact as exposed by the controller ++ managing the Source. It can be used to retrieve the Artifact for ++ consumption, e.g. by another controller applying the Artifact contents. ++ type: string ++ required: ++ - digest ++ - lastUpdateTime ++ - path ++ - revision ++ - url ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ observedGeneration: ++ description: |- ++ ObservedGeneration is the last observed generation of the GitRepository ++ object. ++ format: int64 ++ type: integer ++ observedIgnore: ++ description: |- ++ ObservedIgnore is the observed exclusion patterns used for constructing ++ the source artifact. ++ type: string ++ observedInclude: ++ description: |- ++ ObservedInclude is the observed list of GitRepository resources used to ++ produce the current Artifact. ++ items: ++ description: |- ++ GitRepositoryInclude specifies a local reference to a GitRepository which ++ Artifact (sub-)contents must be included, and where they should be placed. ++ properties: ++ fromPath: ++ description: |- ++ FromPath specifies the path to copy contents from, defaults to the root ++ of the Artifact. ++ type: string ++ repository: ++ description: |- ++ GitRepositoryRef specifies the GitRepository which Artifact contents ++ must be included. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ toPath: ++ description: |- ++ ToPath specifies the path to copy contents to, defaults to the name of ++ the GitRepositoryRef. ++ type: string ++ required: ++ - repository ++ type: object ++ type: array ++ observedRecurseSubmodules: ++ description: |- ++ ObservedRecurseSubmodules is the observed resource submodules ++ configuration used to produce the current Artifact. ++ type: boolean ++ observedSparseCheckout: ++ description: |- ++ ObservedSparseCheckout is the observed list of directories used to ++ produce the current Artifact. ++ items: ++ type: string ++ type: array ++ sourceVerificationMode: ++ description: |- ++ SourceVerificationMode is the last used verification mode indicating ++ which Git object(s) have been verified. ++ type: string ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} ++--- ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: helmcharts.source.toolkit.fluxcd.io ++spec: ++ group: source.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-sources ++ kind: HelmChart ++ listKind: HelmChartList ++ plural: helmcharts ++ shortNames: ++ - hc ++ singular: helmchart ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .spec.chart ++ name: Chart ++ type: string ++ - jsonPath: .spec.version ++ name: Version ++ type: string ++ - jsonPath: .spec.sourceRef.kind ++ name: Source Kind ++ type: string ++ - jsonPath: .spec.sourceRef.name ++ name: Source Name ++ type: string ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: HelmChart is the Schema for the helmcharts API. ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: HelmChartSpec specifies the desired state of a Helm chart. ++ properties: ++ chart: ++ description: |- ++ Chart is the name or path the Helm chart is available at in the ++ SourceRef. ++ type: string ++ ignoreMissingValuesFiles: ++ description: |- ++ IgnoreMissingValuesFiles controls whether to silently ignore missing values ++ files rather than failing. ++ type: boolean ++ interval: ++ description: |- ++ Interval at which the HelmChart SourceRef is checked for updates. ++ This interval is approximate and may be subject to jitter to ensure ++ efficient use of resources. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ reconcileStrategy: ++ default: ChartVersion ++ description: |- ++ ReconcileStrategy determines what enables the creation of a new artifact. ++ Valid values are ('ChartVersion', 'Revision'). ++ See the documentation of the values for an explanation on their behavior. ++ Defaults to ChartVersion when omitted. ++ enum: ++ - ChartVersion ++ - Revision ++ type: string ++ sourceRef: ++ description: SourceRef is the reference to the Source the chart is ++ available at. ++ properties: ++ apiVersion: ++ description: APIVersion of the referent. ++ type: string ++ kind: ++ description: |- ++ Kind of the referent, valid values are ('HelmRepository', 'GitRepository', ++ 'Bucket'). ++ enum: ++ - HelmRepository ++ - GitRepository ++ - Bucket ++ type: string ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - kind ++ - name ++ type: object ++ suspend: ++ description: |- ++ Suspend tells the controller to suspend the reconciliation of this ++ source. ++ type: boolean ++ valuesFiles: ++ description: |- ++ ValuesFiles is an alternative list of values files to use as the chart ++ values (values.yaml is not included by default), expected to be a ++ relative path in the SourceRef. ++ Values files are merged in the order of this list with the last file ++ overriding the first. Ignored when omitted. ++ items: ++ type: string ++ type: array ++ verify: ++ description: |- ++ Verify contains the secret name containing the trusted public keys ++ used to verify the signature and specifies which provider to use to check ++ whether OCI image is authentic. ++ This field is only supported when using HelmRepository source with spec.type 'oci'. ++ Chart dependencies, which are not bundled in the umbrella chart artifact, are not verified. ++ properties: ++ matchOIDCIdentity: ++ description: |- ++ MatchOIDCIdentity specifies the identity matching criteria to use ++ while verifying an OCI artifact which was signed using Cosign keyless ++ signing. The artifact's identity is deemed to be verified if any of the ++ specified matchers match against the identity. ++ items: ++ description: |- ++ OIDCIdentityMatch specifies options for verifying the certificate identity, ++ i.e. the issuer and the subject of the certificate. ++ properties: ++ issuer: ++ description: |- ++ Issuer specifies the regex pattern to match against to verify ++ the OIDC issuer in the Fulcio certificate. The pattern must be a ++ valid Go regular expression. ++ type: string ++ subject: ++ description: |- ++ Subject specifies the regex pattern to match against to verify ++ the identity subject in the Fulcio certificate. The pattern must ++ be a valid Go regular expression. ++ type: string ++ required: ++ - issuer ++ - subject ++ type: object ++ type: array ++ provider: ++ default: cosign ++ description: Provider specifies the technology used to sign the ++ OCI Artifact. ++ enum: ++ - cosign ++ - notation ++ type: string ++ secretRef: ++ description: |- ++ SecretRef specifies the Kubernetes Secret containing the ++ trusted public keys. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ required: ++ - provider ++ type: object ++ version: ++ default: '*' ++ description: |- ++ Version is the chart version semver expression, ignored for charts from ++ GitRepository and Bucket sources. Defaults to latest when omitted. ++ type: string ++ required: ++ - chart ++ - interval ++ - sourceRef ++ type: object ++ x-kubernetes-validations: ++ - message: spec.verify is only supported when spec.sourceRef.kind is 'HelmRepository' ++ rule: '!has(self.verify) || self.sourceRef.kind == ''HelmRepository''' ++ status: ++ default: ++ observedGeneration: -1 ++ description: HelmChartStatus records the observed state of the HelmChart. ++ properties: ++ artifact: ++ description: Artifact represents the output of the last successful ++ reconciliation. ++ properties: ++ digest: ++ description: Digest is the digest of the file in the form of ':'. ++ pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$ ++ type: string ++ lastUpdateTime: ++ description: |- ++ LastUpdateTime is the timestamp corresponding to the last update of the ++ Artifact. ++ format: date-time ++ type: string ++ metadata: ++ additionalProperties: ++ type: string ++ description: Metadata holds upstream information such as OCI annotations. ++ type: object ++ path: ++ description: |- ++ Path is the relative file path of the Artifact. It can be used to locate ++ the file in the root of the Artifact storage on the local file system of ++ the controller managing the Source. ++ type: string ++ revision: ++ description: |- ++ Revision is a human-readable identifier traceable in the origin source ++ system. It can be a Git commit SHA, Git tag, a Helm chart version, etc. ++ type: string ++ size: ++ description: Size is the number of bytes in the file. ++ format: int64 ++ type: integer ++ url: ++ description: |- ++ URL is the HTTP address of the Artifact as exposed by the controller ++ managing the Source. It can be used to retrieve the Artifact for ++ consumption, e.g. by another controller applying the Artifact contents. ++ type: string ++ required: ++ - digest ++ - lastUpdateTime ++ - path ++ - revision ++ - url ++ type: object ++ conditions: ++ description: Conditions holds the conditions for the HelmChart. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ observedChartName: ++ description: |- ++ ObservedChartName is the last observed chart name as specified by the ++ resolved chart reference. ++ type: string ++ observedGeneration: ++ description: |- ++ ObservedGeneration is the last observed generation of the HelmChart ++ object. ++ format: int64 ++ type: integer ++ observedSourceArtifactRevision: ++ description: |- ++ ObservedSourceArtifactRevision is the last observed Artifact.Revision ++ of the HelmChartSpec.SourceRef. ++ type: string ++ observedValuesFiles: ++ description: |- ++ ObservedValuesFiles are the observed value files of the last successful ++ reconciliation. ++ It matches the chart in the last successfully reconciled artifact. ++ items: ++ type: string ++ type: array ++ url: ++ description: |- ++ URL is the dynamic fetch link for the latest Artifact. ++ It is provided on a "best effort" basis, and using the precise ++ HelmChartStatus.Artifact data is recommended. ++ type: string ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} ++--- ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: helmrepositories.source.toolkit.fluxcd.io ++spec: ++ group: source.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-sources ++ kind: HelmRepository ++ listKind: HelmRepositoryList ++ plural: helmrepositories ++ shortNames: ++ - helmrepo ++ singular: helmrepository ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .spec.url ++ name: URL ++ type: string ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: HelmRepository is the Schema for the helmrepositories API. ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: |- ++ HelmRepositorySpec specifies the required configuration to produce an ++ Artifact for a Helm repository index YAML. ++ properties: ++ accessFrom: ++ description: |- ++ AccessFrom specifies an Access Control List for allowing cross-namespace ++ references to this object. ++ NOTE: Not implemented, provisional as of https://github.com/fluxcd/flux2/pull/2092 ++ properties: ++ namespaceSelectors: ++ description: |- ++ NamespaceSelectors is the list of namespace selectors to which this ACL applies. ++ Items in this list are evaluated using a logical OR operation. ++ items: ++ description: |- ++ NamespaceSelector selects the namespaces to which this ACL applies. ++ An empty map of MatchLabels matches all namespaces in a cluster. ++ properties: ++ matchLabels: ++ additionalProperties: ++ type: string ++ description: |- ++ MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels ++ map is equivalent to an element of matchExpressions, whose key field is "key", the ++ operator is "In", and the values array contains only "value". The requirements are ANDed. ++ type: object ++ type: object ++ type: array ++ required: ++ - namespaceSelectors ++ type: object ++ certSecretRef: ++ description: |- ++ CertSecretRef can be given the name of a Secret containing ++ either or both of ++ ++ - a PEM-encoded client certificate (`tls.crt`) and private ++ key (`tls.key`); ++ - a PEM-encoded CA certificate (`ca.crt`) ++ ++ and whichever are supplied, will be used for connecting to the ++ registry. The client cert and key are useful if you are ++ authenticating with a certificate; the CA cert is useful if ++ you are using a self-signed server certificate. The Secret must ++ be of type `Opaque` or `kubernetes.io/tls`. ++ ++ It takes precedence over the values specified in the Secret referred ++ to by `.spec.secretRef`. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ insecure: ++ description: |- ++ Insecure allows connecting to a non-TLS HTTP container registry. ++ This field is only taken into account if the .spec.type field is set to 'oci'. ++ type: boolean ++ interval: ++ description: |- ++ Interval at which the HelmRepository URL is checked for updates. ++ This interval is approximate and may be subject to jitter to ensure ++ efficient use of resources. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ passCredentials: ++ description: |- ++ PassCredentials allows the credentials from the SecretRef to be passed ++ on to a host that does not match the host as defined in URL. ++ This may be required if the host of the advertised chart URLs in the ++ index differ from the defined URL. ++ Enabling this should be done with caution, as it can potentially result ++ in credentials getting stolen in a MITM-attack. ++ type: boolean ++ provider: ++ default: generic ++ description: |- ++ Provider used for authentication, can be 'aws', 'azure', 'gcp' or 'generic'. ++ This field is optional, and only taken into account if the .spec.type field is set to 'oci'. ++ When not specified, defaults to 'generic'. ++ enum: ++ - generic ++ - aws ++ - azure ++ - gcp ++ type: string ++ secretRef: ++ description: |- ++ SecretRef specifies the Secret containing authentication credentials ++ for the HelmRepository. ++ For HTTP/S basic auth the secret must contain 'username' and 'password' ++ fields. ++ Support for TLS auth using the 'certFile' and 'keyFile', and/or 'caFile' ++ keys is deprecated. Please use `.spec.certSecretRef` instead. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ suspend: ++ description: |- ++ Suspend tells the controller to suspend the reconciliation of this ++ HelmRepository. ++ type: boolean ++ timeout: ++ description: |- ++ Timeout is used for the index fetch operation for an HTTPS helm repository, ++ and for remote OCI Repository operations like pulling for an OCI helm ++ chart by the associated HelmChart. ++ Its default value is 60s. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$ ++ type: string ++ type: ++ description: |- ++ Type of the HelmRepository. ++ When this field is set to "oci", the URL field value must be prefixed with "oci://". ++ enum: ++ - default ++ - oci ++ type: string ++ url: ++ description: |- ++ URL of the Helm repository, a valid URL contains at least a protocol and ++ host. ++ pattern: ^(http|https|oci)://.*$ ++ type: string ++ required: ++ - url ++ type: object ++ status: ++ default: ++ observedGeneration: -1 ++ description: HelmRepositoryStatus records the observed state of the HelmRepository. ++ properties: ++ artifact: ++ description: Artifact represents the last successful HelmRepository ++ reconciliation. ++ properties: ++ digest: ++ description: Digest is the digest of the file in the form of ':'. ++ pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$ ++ type: string ++ lastUpdateTime: ++ description: |- ++ LastUpdateTime is the timestamp corresponding to the last update of the ++ Artifact. ++ format: date-time ++ type: string ++ metadata: ++ additionalProperties: ++ type: string ++ description: Metadata holds upstream information such as OCI annotations. ++ type: object ++ path: ++ description: |- ++ Path is the relative file path of the Artifact. It can be used to locate ++ the file in the root of the Artifact storage on the local file system of ++ the controller managing the Source. ++ type: string ++ revision: ++ description: |- ++ Revision is a human-readable identifier traceable in the origin source ++ system. It can be a Git commit SHA, Git tag, a Helm chart version, etc. ++ type: string ++ size: ++ description: Size is the number of bytes in the file. ++ format: int64 ++ type: integer ++ url: ++ description: |- ++ URL is the HTTP address of the Artifact as exposed by the controller ++ managing the Source. It can be used to retrieve the Artifact for ++ consumption, e.g. by another controller applying the Artifact contents. ++ type: string ++ required: ++ - digest ++ - lastUpdateTime ++ - path ++ - revision ++ - url ++ type: object ++ conditions: ++ description: Conditions holds the conditions for the HelmRepository. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ observedGeneration: ++ description: |- ++ ObservedGeneration is the last observed generation of the HelmRepository ++ object. ++ format: int64 ++ type: integer ++ url: ++ description: |- ++ URL is the dynamic fetch link for the latest Artifact. ++ It is provided on a "best effort" basis, and using the precise ++ HelmRepositoryStatus.Artifact data is recommended. ++ type: string ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} ++--- ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: ocirepositories.source.toolkit.fluxcd.io ++spec: ++ group: source.toolkit.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-sources ++ kind: OCIRepository ++ listKind: OCIRepositoryList ++ plural: ocirepositories ++ shortNames: ++ - ocirepo ++ singular: ocirepository ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .spec.url ++ name: URL ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ name: v1 ++ schema: ++ openAPIV3Schema: ++ description: OCIRepository is the Schema for the ocirepositories API ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: OCIRepositorySpec defines the desired state of OCIRepository ++ properties: ++ certSecretRef: ++ description: |- ++ CertSecretRef can be given the name of a Secret containing ++ either or both of ++ ++ - a PEM-encoded client certificate (`tls.crt`) and private ++ key (`tls.key`); ++ - a PEM-encoded CA certificate (`ca.crt`) ++ ++ and whichever are supplied, will be used for connecting to the ++ registry. The client cert and key are useful if you are ++ authenticating with a certificate; the CA cert is useful if ++ you are using a self-signed server certificate. The Secret must ++ be of type `Opaque` or `kubernetes.io/tls`. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ ignore: ++ description: |- ++ Ignore overrides the set of excluded patterns in the .sourceignore format ++ (which is the same as .gitignore). If not provided, a default will be used, ++ consult the documentation for your version to find out what those are. ++ type: string ++ insecure: ++ description: Insecure allows connecting to a non-TLS HTTP container ++ registry. ++ type: boolean ++ interval: ++ description: |- ++ Interval at which the OCIRepository URL is checked for updates. ++ This interval is approximate and may be subject to jitter to ensure ++ efficient use of resources. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ ++ type: string ++ layerSelector: ++ description: |- ++ LayerSelector specifies which layer should be extracted from the OCI artifact. ++ When not specified, the first layer found in the artifact is selected. ++ properties: ++ mediaType: ++ description: |- ++ MediaType specifies the OCI media type of the layer ++ which should be extracted from the OCI Artifact. The ++ first layer matching this type is selected. ++ type: string ++ operation: ++ description: |- ++ Operation specifies how the selected layer should be processed. ++ By default, the layer compressed content is extracted to storage. ++ When the operation is set to 'copy', the layer compressed content ++ is persisted to storage as it is. ++ enum: ++ - extract ++ - copy ++ type: string ++ type: object ++ provider: ++ default: generic ++ description: |- ++ The provider used for authentication, can be 'aws', 'azure', 'gcp' or 'generic'. ++ When not specified, defaults to 'generic'. ++ enum: ++ - generic ++ - aws ++ - azure ++ - gcp ++ type: string ++ proxySecretRef: ++ description: |- ++ ProxySecretRef specifies the Secret containing the proxy configuration ++ to use while communicating with the container registry. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ ref: ++ description: |- ++ The OCI reference to pull and monitor for changes, ++ defaults to the latest tag. ++ properties: ++ digest: ++ description: |- ++ Digest is the image digest to pull, takes precedence over SemVer. ++ The value should be in the format 'sha256:'. ++ type: string ++ semver: ++ description: |- ++ SemVer is the range of tags to pull selecting the latest within ++ the range, takes precedence over Tag. ++ type: string ++ semverFilter: ++ description: SemverFilter is a regex pattern to filter the tags ++ within the SemVer range. ++ type: string ++ tag: ++ description: Tag is the image tag to pull, defaults to latest. ++ type: string ++ type: object ++ secretRef: ++ description: |- ++ SecretRef contains the secret name containing the registry login ++ credentials to resolve image metadata. ++ The secret must be of type kubernetes.io/dockerconfigjson. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ serviceAccountName: ++ description: |- ++ ServiceAccountName is the name of the Kubernetes ServiceAccount used to authenticate ++ the image pull if the service account has attached pull secrets. For more information: ++ https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account ++ type: string ++ suspend: ++ description: This flag tells the controller to suspend the reconciliation ++ of this source. ++ type: boolean ++ timeout: ++ default: 60s ++ description: The timeout for remote OCI Repository operations like ++ pulling, defaults to 60s. ++ pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$ ++ type: string ++ url: ++ description: |- ++ URL is a reference to an OCI artifact repository hosted ++ on a remote container registry. ++ pattern: ^oci://.*$ ++ type: string ++ verify: ++ description: |- ++ Verify contains the secret name containing the trusted public keys ++ used to verify the signature and specifies which provider to use to check ++ whether OCI image is authentic. ++ properties: ++ matchOIDCIdentity: ++ description: |- ++ MatchOIDCIdentity specifies the identity matching criteria to use ++ while verifying an OCI artifact which was signed using Cosign keyless ++ signing. The artifact's identity is deemed to be verified if any of the ++ specified matchers match against the identity. ++ items: ++ description: |- ++ OIDCIdentityMatch specifies options for verifying the certificate identity, ++ i.e. the issuer and the subject of the certificate. ++ properties: ++ issuer: ++ description: |- ++ Issuer specifies the regex pattern to match against to verify ++ the OIDC issuer in the Fulcio certificate. The pattern must be a ++ valid Go regular expression. ++ type: string ++ subject: ++ description: |- ++ Subject specifies the regex pattern to match against to verify ++ the identity subject in the Fulcio certificate. The pattern must ++ be a valid Go regular expression. ++ type: string ++ required: ++ - issuer ++ - subject ++ type: object ++ type: array ++ provider: ++ default: cosign ++ description: Provider specifies the technology used to sign the ++ OCI Artifact. ++ enum: ++ - cosign ++ - notation ++ type: string ++ secretRef: ++ description: |- ++ SecretRef specifies the Kubernetes Secret containing the ++ trusted public keys. ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ trustedRootSecretRef: ++ description: |- ++ TrustedRootSecretRef specifies the Kubernetes Secret containing a ++ Sigstore trusted_root.json file. This enables verification against ++ self-hosted Sigstore infrastructure (custom Fulcio CA, self-hosted ++ Rekor instance). The Secret must contain a key named "trusted_root.json". ++ properties: ++ name: ++ description: Name of the referent. ++ type: string ++ required: ++ - name ++ type: object ++ required: ++ - provider ++ type: object ++ required: ++ - interval ++ - url ++ type: object ++ status: ++ default: ++ observedGeneration: -1 ++ description: OCIRepositoryStatus defines the observed state of OCIRepository ++ properties: ++ artifact: ++ description: Artifact represents the output of the last successful ++ OCI Repository sync. ++ properties: ++ digest: ++ description: Digest is the digest of the file in the form of ':'. ++ pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$ ++ type: string ++ lastUpdateTime: ++ description: |- ++ LastUpdateTime is the timestamp corresponding to the last update of the ++ Artifact. ++ format: date-time ++ type: string ++ metadata: ++ additionalProperties: ++ type: string ++ description: Metadata holds upstream information such as OCI annotations. ++ type: object ++ path: ++ description: |- ++ Path is the relative file path of the Artifact. It can be used to locate ++ the file in the root of the Artifact storage on the local file system of ++ the controller managing the Source. ++ type: string ++ revision: ++ description: |- ++ Revision is a human-readable identifier traceable in the origin source ++ system. It can be a Git commit SHA, Git tag, a Helm chart version, etc. ++ type: string ++ size: ++ description: Size is the number of bytes in the file. ++ format: int64 ++ type: integer ++ url: ++ description: |- ++ URL is the HTTP address of the Artifact as exposed by the controller ++ managing the Source. It can be used to retrieve the Artifact for ++ consumption, e.g. by another controller applying the Artifact contents. ++ type: string ++ required: ++ - digest ++ - lastUpdateTime ++ - path ++ - revision ++ - url ++ type: object ++ conditions: ++ description: Conditions holds the conditions for the OCIRepository. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ observedGeneration: ++ description: ObservedGeneration is the last observed generation. ++ format: int64 ++ type: integer ++ observedIgnore: ++ description: |- ++ ObservedIgnore is the observed exclusion patterns used for constructing ++ the source artifact. ++ type: string ++ observedLayerSelector: ++ description: |- ++ ObservedLayerSelector is the observed layer selector used for constructing ++ the source artifact. ++ properties: ++ mediaType: ++ description: |- ++ MediaType specifies the OCI media type of the layer ++ which should be extracted from the OCI Artifact. The ++ first layer matching this type is selected. ++ type: string ++ operation: ++ description: |- ++ Operation specifies how the selected layer should be processed. ++ By default, the layer compressed content is extracted to storage. ++ When the operation is set to 'copy', the layer compressed content ++ is persisted to storage as it is. ++ enum: ++ - extract ++ - copy ++ type: string ++ type: object ++ url: ++ description: URL is the download link for the artifact output of the ++ last OCI Repository sync. ++ type: string ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} +diff --git a/usercase-test-coderl/fixtures/flux-manifests/source-controller.deployment.yaml b/usercase-test-coderl/fixtures/flux-manifests/source-controller.deployment.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/source-controller.deployment.yaml +@@ -0,0 +1,102 @@ ++apiVersion: v1 ++kind: Service ++metadata: ++ labels: ++ control-plane: controller ++ name: source-controller ++spec: ++ ports: ++ - name: http ++ port: 80 ++ protocol: TCP ++ targetPort: http ++ selector: ++ app: source-controller ++ type: ClusterIP ++--- ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ labels: ++ control-plane: controller ++ name: source-controller ++spec: ++ replicas: 1 ++ selector: ++ matchLabels: ++ app: source-controller ++ strategy: ++ type: Recreate ++ template: ++ metadata: ++ annotations: ++ prometheus.io/port: "8080" ++ prometheus.io/scrape: "true" ++ labels: ++ app: source-controller ++ spec: ++ containers: ++ - args: ++ - --watch-all-namespaces ++ - --log-level=info ++ - --log-encoding=json ++ - --enable-leader-election ++ - --storage-path=/data ++ - --storage-adv-addr=source-controller.$(RUNTIME_NAMESPACE).svc.cluster.local. ++ env: ++ - name: RUNTIME_NAMESPACE ++ valueFrom: ++ fieldRef: ++ fieldPath: metadata.namespace ++ - name: TUF_ROOT ++ value: /tmp/.sigstore ++ image: fluxcd/source-controller:v1.9.3 ++ imagePullPolicy: IfNotPresent ++ livenessProbe: ++ httpGet: ++ path: /healthz ++ port: healthz ++ name: manager ++ ports: ++ - containerPort: 9090 ++ name: http ++ protocol: TCP ++ - containerPort: 8080 ++ name: http-prom ++ protocol: TCP ++ - containerPort: 9440 ++ name: healthz ++ protocol: TCP ++ readinessProbe: ++ httpGet: ++ path: / ++ port: http ++ resources: ++ limits: ++ cpu: 1000m ++ memory: 1Gi ++ requests: ++ cpu: 50m ++ memory: 64Mi ++ securityContext: ++ allowPrivilegeEscalation: false ++ capabilities: ++ drop: ++ - ALL ++ readOnlyRootFilesystem: true ++ runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault ++ volumeMounts: ++ - mountPath: /data ++ name: data ++ - mountPath: /tmp ++ name: tmp ++ securityContext: ++ fsGroup: 1337 ++ terminationGracePeriodSeconds: 10 ++ volumes: ++ - emptyDir: {} ++ name: data ++ - emptyDir: {} ++ name: tmp +diff --git a/usercase-test-coderl/fixtures/flux-manifests/source-watcher.crds.yaml b/usercase-test-coderl/fixtures/flux-manifests/source-watcher.crds.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/source-watcher.crds.yaml +@@ -0,0 +1,339 @@ ++apiVersion: apiextensions.k8s.io/v1 ++kind: CustomResourceDefinition ++metadata: ++ annotations: ++ controller-gen.kubebuilder.io/version: v0.21.0 ++ kustomize.toolkit.fluxcd.io/substitute: disabled ++ name: artifactgenerators.source.extensions.fluxcd.io ++spec: ++ group: source.extensions.fluxcd.io ++ names: ++ categories: ++ - all ++ - fluxcd ++ - fluxcd-sources ++ kind: ArtifactGenerator ++ listKind: ArtifactGeneratorList ++ plural: artifactgenerators ++ shortNames: ++ - ag ++ singular: artifactgenerator ++ scope: Namespaced ++ versions: ++ - additionalPrinterColumns: ++ - jsonPath: .metadata.creationTimestamp ++ name: Age ++ type: date ++ - jsonPath: .status.conditions[?(@.type=="Ready")].status ++ name: Ready ++ type: string ++ - jsonPath: .status.conditions[?(@.type=="Ready")].message ++ name: Status ++ type: string ++ name: v1beta1 ++ schema: ++ openAPIV3Schema: ++ description: ArtifactGenerator is the Schema for the artifactgenerators API. ++ properties: ++ apiVersion: ++ description: |- ++ APIVersion defines the versioned schema of this representation of an object. ++ Servers should convert recognized schemas to the latest internal value, and ++ may reject unrecognized values. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources ++ type: string ++ kind: ++ description: |- ++ Kind is a string value representing the REST resource this object represents. ++ Servers may infer this from the endpoint the client submits requests to. ++ Cannot be updated. ++ In CamelCase. ++ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds ++ type: string ++ metadata: ++ type: object ++ spec: ++ description: ArtifactGeneratorSpec defines the desired state of ArtifactGenerator. ++ properties: ++ artifacts: ++ description: OutputArtifacts is a list of output artifacts to be generated. ++ items: ++ description: |- ++ OutputArtifact defines the desired state of an ExternalArtifact ++ generated by the ArtifactGenerator. ++ properties: ++ copy: ++ description: |- ++ Copy defines a list of copy operations to perform from the sources to the generated artifact. ++ The copy operations are performed in the order they are listed with existing files ++ being overwritten by later copy operations. ++ items: ++ properties: ++ exclude: ++ description: |- ++ Exclude specifies a list of glob patterns to exclude ++ files and dirs matched by the 'From' field. Patterns are matched ++ against paths relative to the source alias root or to the non-glob ++ prefix of 'From'. Patterns without a separator (e.g. "*.md") match ++ the file name at any depth. ++ items: ++ type: string ++ maxItems: 100 ++ type: array ++ from: ++ description: |- ++ From specifies the source (by alias) and the glob pattern to match files. ++ The format is "@/". When pathPattern is set, ++ the path may use capture placeholders such as "{app}". ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^@([a-z0-9]([a-z0-9_-]*[a-z0-9])?)/(.*)$ ++ type: string ++ strategy: ++ description: |- ++ Strategy specifies the copy strategy to use. ++ 'Overwrite' will overwrite existing files in the destination. ++ 'Merge' is for merging YAML files using Helm values merge strategy. ++ 'Extract' is for extracting the contents of tarball archives (.tar.gz, .tgz) ++ When using glob patterns, non-tarball files are silently skipped. For single file sources, ++ the file must be a tarball or an error is returned. Directories are not supported. ++ If not specified, defaults to 'Overwrite'. ++ enum: ++ - Overwrite ++ - Merge ++ - Extract ++ type: string ++ to: ++ description: |- ++ To specifies the destination path within the artifact. ++ The format is "@artifact/path", the alias "artifact" ++ refers to the root path of the generated artifact. When pathPattern ++ is set, the path may use capture placeholders such as "{app}". ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^@(artifact)/(.*)$ ++ type: string ++ required: ++ - from ++ - to ++ type: object ++ minItems: 1 ++ type: array ++ name: ++ description: |- ++ Name is the name of the generated artifact. ++ When pathPattern is set, this field may use capture placeholders such as "{app}". ++ maxLength: 253 ++ minLength: 1 ++ type: string ++ originRevision: ++ description: |- ++ OriginRevision is used to set the 'org.opencontainers.image.revision' ++ annotation on the generated artifact metadata. ++ If specified, it must point to an existing source alias in the format "@". ++ If the referenced source has an origin revision (e.g. a Git commit SHA), ++ it will be used to set the annotation on the generated artifact. ++ If the referenced source does not have an origin revision, the field is ignored. ++ maxLength: 64 ++ pattern: ^@([a-z0-9]([a-z0-9_-]*[a-z0-9])?)$ ++ type: string ++ revision: ++ description: |- ++ Revision is the revision of the generated artifact. ++ If specified, it must point to an existing source alias in the format "@". ++ If not specified, the revision is automatically set to the digest of the artifact content. ++ maxLength: 64 ++ pattern: ^@([a-z0-9]([a-z0-9_-]*[a-z0-9])?)$ ++ type: string ++ required: ++ - copy ++ - name ++ type: object ++ maxItems: 1000 ++ minItems: 1 ++ type: array ++ commonMetadata: ++ description: |- ++ CommonMetadata specifies the common labels and annotations that are ++ applied to all resources. Any existing label or annotation will be ++ overridden if its key matches a common one. ++ properties: ++ annotations: ++ additionalProperties: ++ type: string ++ description: Annotations to be added to the object's metadata. ++ type: object ++ labels: ++ additionalProperties: ++ type: string ++ description: Labels to be added to the object's metadata. ++ type: object ++ type: object ++ pathPattern: ++ description: |- ++ PathPattern specifies a directory traversal pattern to match within the sources. ++ The format is "@/". Named captures in the pattern (e.g. "{app}") ++ can be used as placeholders in OutputArtifacts fields. ++ maxLength: 1024 ++ pattern: ^@([a-z0-9]([a-z0-9_-]*[a-z0-9])?)/(.*)$ ++ type: string ++ sources: ++ description: |- ++ Sources is a list of references to the Flux source-controller ++ resources that will be used to generate the artifact. ++ items: ++ description: SourceReference contains the reference to a Flux source-controller ++ resource. ++ properties: ++ alias: ++ description: |- ++ Alias of the source within the ArtifactGenerator context. ++ The alias must be unique per ArtifactGenerator, and must consist ++ of lower case alphanumeric characters, underscores, and hyphens. ++ It must start and end with an alphanumeric character. ++ maxLength: 63 ++ pattern: ^[a-z0-9]([a-z0-9_-]*[a-z0-9])?$ ++ type: string ++ kind: ++ description: Kind of the source. ++ enum: ++ - Bucket ++ - GitRepository ++ - OCIRepository ++ - HelmChart ++ - ExternalArtifact ++ type: string ++ name: ++ description: Name of the source. ++ maxLength: 253 ++ pattern: ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$ ++ type: string ++ namespace: ++ description: |- ++ Namespace of the source. ++ If not provided, defaults to the same namespace as the ArtifactGenerator. ++ maxLength: 63 ++ minLength: 1 ++ pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ++ type: string ++ required: ++ - alias ++ - kind ++ - name ++ type: object ++ maxItems: 1000 ++ minItems: 1 ++ type: array ++ required: ++ - artifacts ++ - sources ++ type: object ++ x-kubernetes-validations: ++ - message: artifact names must be valid Kubernetes object names when pathPattern ++ is not set ++ rule: has(self.pathPattern) && size(self.pathPattern) > 0 || self.artifacts.all(a, ++ a.name.matches('^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$')) ++ status: ++ description: ArtifactGeneratorStatus defines the observed state of ArtifactGenerator. ++ properties: ++ conditions: ++ description: Conditions holds the conditions for the ArtifactGenerator. ++ items: ++ description: Condition contains details for one aspect of the current ++ state of this API Resource. ++ properties: ++ lastTransitionTime: ++ description: |- ++ lastTransitionTime is the last time the condition transitioned from one status to another. ++ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. ++ format: date-time ++ type: string ++ message: ++ description: |- ++ message is a human readable message indicating details about the transition. ++ This may be an empty string. ++ maxLength: 32768 ++ type: string ++ observedGeneration: ++ description: |- ++ observedGeneration represents the .metadata.generation that the condition was set based upon. ++ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date ++ with respect to the current state of the instance. ++ format: int64 ++ minimum: 0 ++ type: integer ++ reason: ++ description: |- ++ reason contains a programmatic identifier indicating the reason for the condition's last transition. ++ Producers of specific condition types may define expected values and meanings for this field, ++ and whether the values are considered a guaranteed API. ++ The value should be a CamelCase string. ++ This field may not be empty. ++ maxLength: 1024 ++ minLength: 1 ++ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ ++ type: string ++ status: ++ description: status of the condition, one of True, False, Unknown. ++ enum: ++ - "True" ++ - "False" ++ - Unknown ++ type: string ++ type: ++ description: type of condition in CamelCase or in foo.example.com/CamelCase. ++ maxLength: 316 ++ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ ++ type: string ++ required: ++ - lastTransitionTime ++ - message ++ - reason ++ - status ++ - type ++ type: object ++ type: array ++ inventory: ++ description: Inventory contains the list of generated ExternalArtifact ++ references. ++ items: ++ description: |- ++ ExternalArtifactReference contains the reference to a ++ generated ExternalArtifact along with its digest. ++ properties: ++ digest: ++ description: Digest of the referent artifact. ++ type: string ++ filename: ++ description: Filename is the name of the artifact file. ++ type: string ++ name: ++ description: Name of the referent artifact. ++ type: string ++ namespace: ++ description: Namespace of the referent artifact. ++ type: string ++ required: ++ - digest ++ - filename ++ - name ++ - namespace ++ type: object ++ type: array ++ lastHandledReconcileAt: ++ description: |- ++ LastHandledReconcileAt holds the value of the most recent ++ reconcile request value, so a change of the annotation value ++ can be detected. ++ type: string ++ observedSourcesDigest: ++ description: |- ++ ObservedSourcesDigest is a hash representing the current state of ++ all the sources referenced by the ArtifactGenerator. ++ type: string ++ type: object ++ type: object ++ served: true ++ storage: true ++ subresources: ++ status: {} +diff --git a/usercase-test-coderl/fixtures/flux-manifests/source-watcher.deployment.yaml b/usercase-test-coderl/fixtures/flux-manifests/source-watcher.deployment.yaml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/flux-manifests/source-watcher.deployment.yaml +@@ -0,0 +1,100 @@ ++apiVersion: v1 ++kind: Service ++metadata: ++ labels: ++ control-plane: source-watcher ++ name: source-watcher ++spec: ++ ports: ++ - name: http ++ port: 80 ++ protocol: TCP ++ targetPort: http ++ selector: ++ app: source-watcher ++ type: ClusterIP ++--- ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ labels: ++ control-plane: controller ++ name: source-watcher ++spec: ++ replicas: 1 ++ selector: ++ matchLabels: ++ app: source-watcher ++ strategy: ++ type: Recreate ++ template: ++ metadata: ++ annotations: ++ prometheus.io/port: "8080" ++ prometheus.io/scrape: "true" ++ labels: ++ app: source-watcher ++ spec: ++ containers: ++ - args: ++ - --watch-all-namespaces ++ - --log-level=info ++ - --log-encoding=json ++ - --enable-leader-election ++ - --storage-path=/data ++ - --storage-adv-addr=source-watcher.$(RUNTIME_NAMESPACE).svc.cluster.local. ++ env: ++ - name: RUNTIME_NAMESPACE ++ valueFrom: ++ fieldRef: ++ fieldPath: metadata.namespace ++ image: fluxcd/source-watcher:v2.2.2 ++ imagePullPolicy: IfNotPresent ++ livenessProbe: ++ httpGet: ++ path: /healthz ++ port: healthz ++ name: manager ++ ports: ++ - containerPort: 9090 ++ name: http ++ protocol: TCP ++ - containerPort: 8080 ++ name: http-prom ++ protocol: TCP ++ - containerPort: 9440 ++ name: healthz ++ protocol: TCP ++ readinessProbe: ++ httpGet: ++ path: / ++ port: http ++ resources: ++ limits: ++ cpu: 1000m ++ memory: 1Gi ++ requests: ++ cpu: 50m ++ memory: 64Mi ++ securityContext: ++ allowPrivilegeEscalation: false ++ capabilities: ++ drop: ++ - ALL ++ readOnlyRootFilesystem: true ++ runAsNonRoot: true ++ seccompProfile: ++ type: RuntimeDefault ++ volumeMounts: ++ - mountPath: /data ++ name: data ++ - mountPath: /tmp ++ name: tmp ++ securityContext: ++ fsGroup: 1337 ++ terminationGracePeriodSeconds: 10 ++ volumes: ++ - emptyDir: {} ++ name: data ++ - emptyDir: {} ++ name: tmp +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,386 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GONOSUMDB=* ++ ++local_prepare_offline_kustomize() { ++ ++ local fixtures=/workspace/repo/usercase-test-coderl/fixtures/flux-manifests ++ local controller version base_dir ++ while read -r controller version; do ++ [ -n "$controller" ] || continue ++ base_dir="/workspace/repo/manifests/bases/${controller}" ++ cp "${fixtures}/${controller}.crds.yaml" "${base_dir}/${controller}.crds.local-offline.yaml" ++ cp "${fixtures}/${controller}.deployment.yaml" "${base_dir}/${controller}.deployment.local-offline.yaml" ++ sed -i \ ++ -e "s#https://github.com/fluxcd/${controller}/releases/download/${version}/${controller}.crds.yaml#${controller}.crds.local-offline.yaml#g" \ ++ -e "s#https://github.com/fluxcd/${controller}/releases/download/${version}/${controller}.deployment.yaml#${controller}.deployment.local-offline.yaml#g" \ ++ "${base_dir}/kustomization.yaml" ++ ++ cp "${fixtures}/${controller}.crds.yaml" "/workspace/repo/manifests/crds/${controller}.crds.local-offline.yaml" ++ sed -i \ ++ "s#https://github.com/fluxcd/${controller}/releases/download/${version}/${controller}.crds.yaml#${controller}.crds.local-offline.yaml#g" \ ++ /workspace/repo/manifests/crds/kustomization.yaml ++ done <<'EOF' ++helm-controller v1.6.2 ++image-automation-controller v1.2.3 ++image-reflector-controller v1.2.3 ++kustomize-controller v1.9.3 ++notification-controller v1.9.2 ++source-controller v1.9.3 ++source-watcher v2.2.2 ++EOF ++} ++ ++local_prepare_offline_kustomize ++ ++local_prepare_missing_build_package() { ++ ++ mkdir -p /workspace/repo/internal/build ++ cat > /workspace/repo/internal/build/build.go <<'GO' ++package build ++ ++import ( ++ "fmt" ++ ++ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ++) ++ ++type Builder struct{} ++type Option func(*Builder) ++ ++func NewBuilder(name, path string, opts ...Option) (*Builder, error) { ++ b := &Builder{} ++ for _, opt := range opts { ++ if opt != nil { ++ opt(b) ++ } ++ } ++ return b, nil ++} ++ ++func WithTimeout(v interface{}) Option { return func(*Builder) {} } ++func WithKustomizationFile(v string) Option { return func(*Builder) {} } ++func WithDryRun(v bool) Option { return func(*Builder) {} } ++func WithNamespace(v string) Option { return func(*Builder) {} } ++func WithIgnore(v []string) Option { return func(*Builder) {} } ++func WithStrictSubstitute(v bool) Option { return func(*Builder) {} } ++func WithRecursive(v bool) Option { return func(*Builder) {} } ++func WithLocalSources(v map[string]string) Option { return func(*Builder) {} } ++func WithInMemoryBuild(v bool) Option { return func(*Builder) {} } ++func WithClientConfig(v ...interface{}) Option { return func(*Builder) {} } ++func WithProgressBar() Option { return func(*Builder) {} } ++func WithSingleKustomization() Option { return func(*Builder) {} } ++func WithIgnoreNotFound(v bool) Option { return func(*Builder) {} } ++ ++func (b *Builder) Build() ([]*unstructured.Unstructured, error) { ++ return nil, fmt.Errorf("internal/build is unavailable in the offline test image") ++} ++ ++func (b *Builder) Diff() (string, bool, error) { ++ return "", false, fmt.Errorf("internal/build is unavailable in the offline test image") ++} ++ ++func (b *Builder) Cancel() error { ++ return nil ++} ++ ++func (b *Builder) StopSpinner() error { ++ return nil ++} ++GO ++} ++ ++local_prepare_missing_build_package ++ ++( cd /workspace/repo && make build ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=/workspace/repo/bin/flux ++ ++TMP=$(mktemp -d) ++SERVER_PID="" ++cleanup() { ++ if [ -n "$SERVER_PID" ]; then ++ kill "$SERVER_PID" 2>/dev/null || true ++ fi ++ rm -rf "$TMP" ++} ++trap cleanup EXIT ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++CATALOG="$TMP/catalog" ++PLUGIN_DIR="$TMP/plugins" ++HOME_DIR="$TMP/home" ++mkdir -p "$CATALOG" "$PLUGIN_DIR" "$HOME_DIR" ++ ++cat > "$TMP/server.py" <<'PY' ++import http.server ++import os ++import socketserver ++import sys ++ ++os.chdir(sys.argv[1]) ++ ++class Handler(http.server.SimpleHTTPRequestHandler): ++ def log_message(self, format, *args): ++ pass ++ ++with socketserver.TCPServer(("127.0.0.1", 0), Handler) as httpd: ++ print(httpd.server_address[1], flush=True) ++ httpd.serve_forever() ++PY ++ ++python3 "$TMP/server.py" "$CATALOG" > "$TMP/server.port" & ++SERVER_PID=$! ++for _ in $(seq 1 100); do ++ [ -s "$TMP/server.port" ] && break ++ sleep 0.05 ++done ++[ -s "$TMP/server.port" ] || fail "catalog server did not start" ++PORT=$(cat "$TMP/server.port") ++BASE_URL="http://127.0.0.1:${PORT}/" ++ ++export FLUXCD_PLUGIN_CATALOG="$BASE_URL" ++export FLUXCD_PLUGINS="$PLUGIN_DIR" ++export HOME="$HOME_DIR" ++ ++cat > "$CATALOG/operator-match.bin" <<'EOF' ++#!/bin/sh ++echo operator match ++EOF ++cat > "$CATALOG/operator-v2.bin" <<'EOF' ++#!/bin/sh ++echo operator v2 ++EOF ++cat > "$CATALOG/operator-v1.bin" <<'EOF' ++#!/bin/sh ++echo operator v1 ++EOF ++cat > "$CATALOG/other.bin" <<'EOF' ++#!/bin/sh ++echo other ++EOF ++ ++MATCH_DIGEST="sha256:529c9e498e8e5e6b0b5d6190f3d81a92a5ed14b52cd9b21a3081d6912bacd091" ++V2_DIGEST="sha256:802a3eda8181ac5ca309c9f6d5f530caaf084a92a0fd7ecfde70c13871322b51" ++V1_DIGEST="sha256:dd55b0f907a025965a3817865b747a9dc0db705e1bab854885ed93b3f78c7088" ++OTHER_DIGEST="sha256:7994c7881558bd72c4dfe4fedb9780b955f67b98a0fd675629e1da888bc0d783" ++MISSING_DIGEST="sha256:06e0a38db4fa6bc9f705a577c7e58dc020bfe2618e45488599e5ef7bb62e3a8a" ++ ++write_main_manifest() { ++ cat > "$CATALOG/operator.yaml" <out 2>err ++ ec=$? ++} ++ ++assert_success_line() { ++ local fixture="$1" ++ local version="$2" ++ local actual ++ actual=$(cat err) ++ ++ [[ "$actual" == *"installed operator"*"$version"* ]] || fail "$fixture stderr: $actual" ++} ++ ++assert_empty_stdout() { ++ local fixture="$1" ++ [ ! -s out ] || fail "$fixture stdout: $(cat out)" ++} ++ ++assert_installed_file() { ++ local fixture="$1" ++ local expected="$2" ++ [ -f "$PLUGIN_DIR/flux-operator" ] || fail "$fixture missing installed binary" ++ [ "$(cat "$PLUGIN_DIR/flux-operator")" = "$expected" ] \ ++ || fail "$fixture installed binary: $(cat "$PLUGIN_DIR/flux-operator")" ++} ++ ++assert_receipt_line() { ++ local fixture="$1" ++ local line="$2" ++ ++ [ -n "$line" ] || fail "$fixture empty receipt assertion" ++} ++ ++cd "$TMP" ++ ++ ++ ++ ++run_flux plugin install --help ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++grep -Eq '^ flux plugin install .*@.*(digest|sha256)' out \ ++ || fail "F1 usage missing digest form" ++ ++grep -Eiq '(pin|digest)' out \ ++ || fail "F1 missing digest example heading" ++ ++grep -Eq '^ flux plugin install [^[:space:]]+@sha256:[[:xdigit:]]+' out \ ++ || fail "F1 missing digest example command" ++[ ! -s err ] || fail "F1 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++write_main_manifest ++reset_install_dir ++run_flux plugin install "operator@${MATCH_DIGEST}" ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0; stderr: $(cat err)" ++assert_empty_stdout F2 ++assert_success_line F2 "1.5.0" ++assert_installed_file F2 "#!/bin/sh ++echo operator match" ++assert_receipt_line F2 "version: 1.5.0" ++assert_receipt_line F2 " arch: amd64" ++assert_receipt_line F2 " checksum: ${MATCH_DIGEST}" ++assert_receipt_line F2 " os: linux" ++ ++ ++ ++ ++write_main_manifest ++reset_install_dir ++run_flux plugin install operator@2.0.0 ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0; stderr: $(cat err)" ++assert_empty_stdout F3 ++assert_success_line F3 "2.0.0" ++assert_installed_file F3 "#!/bin/sh ++echo operator v2" ++assert_receipt_line F3 "version: 2.0.0" ++assert_receipt_line F3 " checksum: ${V2_DIGEST}" ++ ++ ++ ++ ++write_main_manifest ++reset_install_dir ++run_flux plugin install operator ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0; stderr: $(cat err)" ++assert_empty_stdout F4 ++assert_success_line F4 "2.0.0" ++assert_installed_file F4 "#!/bin/sh ++echo operator v2" ++assert_receipt_line F4 "version: 2.0.0" ++ ++ ++ ++ ++cat > "$CATALOG/operator.yaml" < "$CATALOG/operator.yaml" < "$CATALOG/operator.yaml" <