#!/usr/bin/env python3 """Build the frozen evaluation sets. Answers are computed by code, not written by hand. Outputs (committed to git, never used for training): eval/tool_calls.jsonl request -> expected tool call (or none) eval/manifest_reasoning.jsonl cluster snapshot -> question -> computed answer eval/english_heldout.jsonl held-out English prose sampled from corpora/english-prose.jsonl eval/english_heldout_ids.txt identifiers to exclude from the training corpus Re-running with the same seed reproduces the same files. Hand-written concept questions live in eval/concepts.jsonl and are not generated. """ import argparse import json import random from pathlib import Path SEED = 20260101 NAMESPACES = ["default", "payments", "frontend", "monitoring", "batch"] APPS = ["checkout", "cart", "search", "billing", "auth", "metrics"] DEPLOYMENTS = ["checkout", "cart", "search", "billing", "auth", "metrics", "ingest", "report"] NODES_REQUEST = [ "Which nodes are in the cluster?", "List all the nodes.", "Show me the cluster nodes.", ] def tool_calls(rng): items = [] def add(request, expected): items.append({"id": f"tool-{len(items) + 1:03d}", "request": request, "expected": expected}) for _ in range(12): ns = rng.choice(NAMESPACES) add(rng.choice([f"List the pods in the {ns} namespace.", f"Show every pod running in {ns}.", f"What pods are in the {ns} namespace?"]), {"name": "kubectl_get", "arguments": {"resource": "pods", "namespace": ns}}) for _ in range(8): app, ns = rng.choice(APPS), rng.choice(NAMESPACES) add(rng.choice([f"Show pods with label app={app} in {ns}.", f"Which pods in {ns} carry the label app={app}?"]), {"name": "kubectl_get", "arguments": {"resource": "pods", "namespace": ns, "selector": f"app={app}"}}) for _ in range(10): name, ns = rng.choice(DEPLOYMENTS), rng.choice(NAMESPACES) add(rng.choice([f"Describe the deployment {name} in {ns}.", f"Give me the details of deployment {name} in the {ns} namespace."]), {"name": "kubectl_describe", "arguments": {"resource": "deployments", "name": name, "namespace": ns}}) for _ in range(10): pod, ns = f"{rng.choice(APPS)}-{rng.randint(1000, 9999)}", rng.choice(NAMESPACES) tail = rng.choice([20, 50, 100, 200]) add(f"Get the last {tail} log lines of pod {pod} in {ns}.", {"name": "kubectl_logs", "arguments": {"pod": pod, "namespace": ns, "tail": tail}}) for _ in range(10): name, ns, replicas = rng.choice(DEPLOYMENTS), rng.choice(NAMESPACES), rng.randint(0, 10) add(rng.choice([f"Scale deployment {name} to {replicas} replicas in {ns}.", f"Set the replica count of {name} in {ns} to {replicas}."]), {"name": "kubectl_scale", "arguments": {"deployment": name, "replicas": replicas, "namespace": ns}}) for request in NODES_REQUEST: add(request, {"name": "kubectl_get", "arguments": {"resource": "nodes"}}) # Requests that need no tool call: the model must answer in prose. for request in ["What is a pod in Kubernetes?", "Explain the difference between a Deployment and a StatefulSet.", "Write a haiku about containers.", "What does the replicas field control?", "Is a Service the same as an Ingress?", "Define a namespace."]: add(request, {"name": None}) rng.shuffle(items) return items def manifest_reasoning(rng, count=60): items = [] for index in range(count): ns = rng.choice(NAMESPACES) app = rng.choice(APPS) pods = [] for n in range(rng.randint(4, 7)): name = f"{app}-{rng.randint(10000, 99999):05d}-{n}" total = rng.randint(1, 3) ready = total if rng.random() < 0.7 else rng.randint(0, total - 1) restarts = rng.choice([0, 0, 1, 2, 3, 5, 8]) status = "Running" if ready == total else rng.choice(["CrashLoopBackOff", "Pending"]) pod_app = app if rng.random() < 0.8 else rng.choice(APPS) pods.append({"name": name, "ready": f"{ready}/{total}", "ready_ok": ready == total, "status": status, "restarts": restarts, "app": pod_app}) service_app = app selector = {"app": service_app} question_type = index % 3 if question_type == 0: question = "Which pods are not fully ready? List their names, sorted." answer = sorted(p["name"] for p in pods if not p["ready_ok"]) elif question_type == 1: question = "Which pods have restarted more than 2 times? List their names, sorted." answer = sorted(p["name"] for p in pods if p["restarts"] > 2) else: question = (f"Which pods does the Service named {service_app} in namespace {ns} " "route traffic to? List their names, sorted.") answer = sorted(p["name"] for p in pods if p["app"] == selector["app"]) rows = ["NAME | READY | STATUS | RESTARTS | LABEL app"] rows += [f"{p['name']} | {p['ready']} | {p['status']} | {p['restarts']} | {p['app']}" for p in pods] snapshot = (f"Namespace: {ns}\nService {service_app}: selector app={selector['app']}\n" + "\n".join(rows)) items.append({"id": f"manifest-{index + 1:03d}", "context": snapshot, "question": question, "expected": answer}) return items def english_sample(corpus, count, rng, max_words): """Reservoir-sample documents so the sample is uniform over the whole corpus.""" reservoir, seen = [], 0 with corpus.open(encoding="utf-8") as stream: for line in stream: seen += 1 if len(reservoir) < count: reservoir.append(line) else: slot = rng.randint(0, seen - 1) if slot < count: reservoir[slot] = line items = [] for line in reservoir: record = json.loads(line) words = record["text"].split()[:max_words] items.append({"identifier": record["identifier"], "license": record["license"], "collection": record["collection"], "text": " ".join(words)}) return items def write_jsonl(path, items): with path.open("w", encoding="utf-8") as stream: for item in items: stream.write(json.dumps(item, ensure_ascii=False) + "\n") def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--corpus", type=Path, default=Path("corpora/english-prose.jsonl")) parser.add_argument("--eval-dir", type=Path, default=Path("eval")) parser.add_argument("--english-count", type=int, default=200) parser.add_argument("--english-max-words", type=int, default=600) args = parser.parse_args() args.eval_dir.mkdir(parents=True, exist_ok=True) rng = random.Random(SEED) write_jsonl(args.eval_dir / "tool_calls.jsonl", tool_calls(rng)) write_jsonl(args.eval_dir / "manifest_reasoning.jsonl", manifest_reasoning(rng)) english = english_sample(args.corpus, args.english_count, rng, args.english_max_words) write_jsonl(args.eval_dir / "english_heldout.jsonl", english) (args.eval_dir / "english_heldout_ids.txt").write_text( "\n".join(item["identifier"] for item in english) + "\n", encoding="utf-8") print(f"wrote {args.eval_dir} (seed {SEED})") if __name__ == "__main__": main()