Datasets:
Publish v3 seeded multi-file curriculum and verification reports
Browse files- v3/CALIBRATION.md +79 -0
- v3/Dockerfile +11 -0
- v3/calibrate.py +167 -0
- v3/calibrate_raw.py +78 -0
- v3/execution.py +154 -0
- v3/hard_tasks.py +101 -0
- v3/live-replay-results.json +176 -0
- v3/live_replay.py +37 -0
- v3/openenv.yaml +22 -0
- v3/qwen-eight-family-calibration.json +0 -0
- v3/qwen-raw-eight-family-calibration.json +0 -0
- v3/replay-results.json +324 -0
- v3/replay.py +52 -0
- v3/requirements-calibration.txt +2 -0
- v3/requirements.txt +1 -0
- v3/server.py +85 -0
- v3/tasks.jsonl +3 -0
- v3/tasks.py +309 -0
- v3/test_calibrate.py +82 -0
- v3/test_calibrate_raw.py +31 -0
- v3/test_environment.py +129 -0
- v3/test_targeted.py +25 -0
- v3/validation-runtime.json +113 -0
v3/CALIBRATION.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Real-Qwen local calibration, 2026-10-09
|
| 2 |
+
|
| 3 |
+
## Decision
|
| 4 |
+
|
| 5 |
+
Calibration-only recommendation was to keep v3 as a local draft. On 2026-10-09 the owner approved stopping further tuning and proceeding to essential validation/publication; this does not waive separate submission approval. Reward variation is more promising than v2's nearly uniform perfect training groups, but these probes do not establish an optimizer gradient, learning improvement or an Arena score. The raw-template recovery removed local inference-parser failures, but frequent action-format failures and budget cuts still confound task difficulty. At calibration time no new image or dataset was published and no second submission was made. Publication subsequently proceeds through Linux CI; no second submission is authorized yet.
|
| 6 |
+
|
| 7 |
+
## Runtime and protocol
|
| 8 |
+
|
| 9 |
+
- Ollama 0.40.2, qwen3.8:27b, model digest 47951e4a666180bc2aedfc93c169472f2de783696fe196efbf063f5730ecf163.
|
| 10 |
+
- Download: 18,174,721,847 bytes. Reported weights: nvfp4, MLX runner, 27.8B. This is not Arena's full-precision inference runtime.
|
| 11 |
+
- Untrained model; temperature 1.0; thinking false; no JSON-constrained decoding. Exact JSON action or literal finish true only; invalid replies cause grading of current source.
|
| 12 |
+
- Four attempts requested per task/reset group. Completion budget 4,096 includes model tokens and post-reset observations estimated as UTF-8 bytes/3. Context 8,192, per-reply token cap 1,600. These choices and token estimates are a local proxy, not verified equivalence with Arena. No call-rate pacing emulation.
|
| 13 |
+
- Hidden checks and reference solutions are never supplied to the model. Rewards are calculated by the same parent-side environment verifier used in correctness testing.
|
| 14 |
+
- Inference HTTP errors are ungraded attempts, not failed-repair rewards. The updated harness records their status/body and continues the sweep.
|
| 15 |
+
|
| 16 |
+
## Initial primary probe, reset seed 5000
|
| 17 |
+
|
| 18 |
+
Completed rewards, four per group:
|
| 19 |
+
|
| 20 |
+
| Task | Rewards |
|
| 21 |
+
| --- | --- |
|
| 22 |
+
| allocation-3 | 0.166667, 0.178161, 0.166667, 1 |
|
| 23 |
+
| expression-3 | 0.166667, 1, 1, 0.821839 |
|
| 24 |
+
| incident-3 | 0.5, 1, 0.333333, 0.333333 |
|
| 25 |
+
|
| 26 |
+
All three groups are mixed. Four of 12 episodes earned full reward; eight terminated with invalid actions. Full reward can still occur after an invalid reply when previously written code passes hidden checks. Mean terminal reward 0.555556 is an environment reward, not an Arena score.
|
| 27 |
+
|
| 28 |
+
Provenance: qwen-calibration.json contains the first four allocation episodes; qwen-calibration-followup.json contains four expression and three incident episodes. The original run aborted on an expression inference HTTP 500 after the allocation group; the follow-up aborted on incident repeat 3. qwen-incident-replacement.json is an explicit replacement for that ungraded incident episode, with initial sampling seed 9080 rather than the normal initial seed 9000. This replacement and inference attrition limit the strength of any group-variance inference.
|
| 29 |
+
|
| 30 |
+
One separate expression diagnostic episode (qwen-expression-diagnostic.json and full response log) earned 0.655172 and terminated on a truncated invalid reply. It is not included in the primary 12 or the broad sweep.
|
| 31 |
+
|
| 32 |
+
## Broad sweep, reset seed 5001
|
| 33 |
+
|
| 34 |
+
qwen-eight-family-calibration.json: 32 requested attempts, 25 graded, seven HTTP 500 inference errors. 13 graded episodes earned full reward; 13 ended on invalid actions, with overlap. Mean reward among graded episodes: 0.745517. Every family showed mixed rewards among its available completed outputs, but six groups have fewer than four rewards and do not constitute complete four-candidate training groups.
|
| 35 |
+
|
| 36 |
+
| Task | Graded | Full reward | Reward range |
|
| 37 |
+
| --- | ---: | ---: | --- |
|
| 38 |
+
| ledger-3 | 4 | 2 | 0.333333 to 1 |
|
| 39 |
+
| capacity-3 | 2 | 1 | 0.339080 to 1 |
|
| 40 |
+
| workflow-3 | 3 | 2 | 0.362069 to 1 |
|
| 41 |
+
| incident-3 | 3 | 2 | 0.672414 to 1 |
|
| 42 |
+
| sensor-3 | 3 | 1 | 0.333333 to 1 |
|
| 43 |
+
| reconcile-3 | 4 | 3 | 0 to 1 |
|
| 44 |
+
| allocation-3 | 3 | 2 | 0.655172 to 1 |
|
| 45 |
+
| expression-3 | 3 | 0 | 0.609195 to 0.833333 |
|
| 46 |
+
|
| 47 |
+
Six errors returned EOF; one returned an XML function-closing-tag syntax error. They are observed local API/parser failures, not evidence that an Arena rollout would fail in the same way. Invalid actions included prose instead of JSON, empty content, unknown fields, and length-truncated writes. Do not attribute all reward variance to repair reasoning.
|
| 48 |
+
|
| 49 |
+
## Raw official-template recovery, reset seed 5001
|
| 50 |
+
|
| 51 |
+
The documented /api/generate endpoint with raw=true avoids the chat API's tool-output parser. calibrate_raw.py renders the official Qwen tokenizer chat template using enable_thinking=false, no native tools, and the same system/action schema. It preserves the entire generated string, including XML/prose; no JSON grammar, stripping or action extraction is used. Template pinned to official revision 1d4bf0f2ff6012fd82039f2fa52739d0dd7c60c0, SHA256 c3cf9e34abf4f9e36c2d72165aa9c132d3e2a725b6c2586aaa3a8af9d7a81041.
|
| 52 |
+
|
| 53 |
+
qwen-raw-eight-family-calibration.json: all 32 attempts completed, zero inference errors; 15 full rewards, 12 invalid-action endings and three approximate-budget endings. Mean environment reward 0.706897. Seven of eight four-candidate groups showed mixed rewards; reconciliation was uniformly perfect.
|
| 54 |
+
|
| 55 |
+
| Task | Four rewards |
|
| 56 |
+
| --- | --- |
|
| 57 |
+
| ledger-3 | 1, 1, 0.333333, 0.333333 |
|
| 58 |
+
| capacity-3 | 1, 0.339080, 1, 1 |
|
| 59 |
+
| workflow-3 | 0.362069, 0.643678, 0.362069, 0.885057 |
|
| 60 |
+
| incident-3 | 0.672414, 0.672414, 0.333333, 1 |
|
| 61 |
+
| sensor-3 | 1, 1, 0.333333, 0.333333 |
|
| 62 |
+
| reconcile-3 | 1, 1, 1, 1 |
|
| 63 |
+
| allocation-3 | 0, 1, 0.166667, 1 |
|
| 64 |
+
| expression-3 | 1, 0.816092, 0.201149, 0.833333 |
|
| 65 |
+
|
| 66 |
+
Excluding invalid-action terminations leaves 20 episodes and only four families with mixed rewards: workflow, incident, allocation and expression. This exclusion is a diagnostic, not an unbiased replacement scoring rule. Workflow/incident/allocation variation still includes budget-ended episodes. Expression has three normally terminal, valid-format episodes with distinct rewards (1, 0.816092, 0.833333), providing the clearest reasoning-difficulty witness in this one-seed sample. Other families' variation is largely format-driven; reconciliation is probably too easy at this seed. Prioritize these four harder candidates rather than assuming all 24 IDs are useful training tasks.
|
| 67 |
+
|
| 68 |
+
Raw reproduction (public template fetch, no Hugging Face credential used):
|
| 69 |
+
|
| 70 |
+
../.venv/bin/python -m pip install -r requirements-calibration.txt
|
| 71 |
+
../.venv/bin/python calibrate_raw.py --tasks ledger-3 capacity-3 workflow-3 incident-3 sensor-3 reconcile-3 allocation-3 expression-3 --seed 5001 --repeats 4 --output qwen-raw-eight-family-calibration.json
|
| 72 |
+
|
| 73 |
+
Across episode probes: 69 primary/broad/raw graded episodes plus one separate diagnostic; nine runtime-aborted attempts. A separate one-reply raw JSON smoke test is not an environment episode. No attempts were silently scored as zero or silently omitted from the narrative.
|
| 74 |
+
|
| 75 |
+
## Verification and next gate
|
| 76 |
+
|
| 77 |
+
100 unit/integration/security/harness tests pass. Environment core source was not changed by this calibration. Previous 1,200 correctness episodes, 2,400 single-defect ablations, 24 live-network IDs and six official SDK contract checks remain applicable. Container build/admission and anonymous public image pull have not been performed for v3.
|
| 78 |
+
|
| 79 |
+
For stronger learning evidence beyond the owner's authorized publication scope, improve action-format reliability and verify it with the actual full-precision model/template and accurate token accounting if an authorized runtime is available. The local raw adapter has already removed tool-parser interference; it does not remove quantization or sampling differences. Recheck repeated groups at multiple seeds and levels with complete candidate counts. Any paid inference requires owner authorization. Any second Arena submission requires showing its request and obtaining fresh approval. Do not use the daily submission slot merely to discover whether a local transport worked.
|
v3/Dockerfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim-bookworm
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
|
| 4 |
+
COPY requirements.txt /app/requirements.txt
|
| 5 |
+
RUN pip install --no-cache-dir -r /app/requirements.txt
|
| 6 |
+
RUN useradd --create-home --uid 10001 repair
|
| 7 |
+
COPY server.py tasks.py hard_tasks.py execution.py openenv.yaml /app/
|
| 8 |
+
USER repair
|
| 9 |
+
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
| 10 |
+
EXPOSE 8000
|
| 11 |
+
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]
|
v3/calibrate.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Untrained-Qwen difficulty probe, not a training run or Arena score.
|
| 2 |
+
|
| 3 |
+
Runs four stochastic rollouts for each task/seed group. Exact single JSON actions,
|
| 4 |
+
no JSON-constrained decoding, no thinking, no extraction of fenced code. Local
|
| 5 |
+
Ollama quantization and token accounting differ from Arena: label results as a
|
| 6 |
+
proxy only. The harness must not recommend submission from reference replays.
|
| 7 |
+
"""
|
| 8 |
+
import argparse
|
| 9 |
+
import json
|
| 10 |
+
import math
|
| 11 |
+
import statistics
|
| 12 |
+
import time
|
| 13 |
+
import urllib.error
|
| 14 |
+
import urllib.parse
|
| 15 |
+
import urllib.request
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
from pydantic import ValidationError
|
| 19 |
+
from server import MAX_STEPS, RepairAction, RepairEnvironment
|
| 20 |
+
from tasks import TASK_IDS
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def decode(raw):
|
| 24 |
+
def nonfinite(value):
|
| 25 |
+
raise ValueError('nonfinite JSON')
|
| 26 |
+
result=json.loads(raw,parse_constant=nonfinite)
|
| 27 |
+
if not isinstance(result,dict):
|
| 28 |
+
raise ValueError('reply must be one JSON object')
|
| 29 |
+
if set(result)=={'action'} and isinstance(result['action'],dict):
|
| 30 |
+
result=result['action']
|
| 31 |
+
if set(result)=={'finish'} and result['finish'] is True:
|
| 32 |
+
return RepairAction(operation='submit')
|
| 33 |
+
return RepairAction.model_validate(result)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def episode(task_id,seed,generate,completion_budget=4096,context_budget=8192):
|
| 37 |
+
env=RepairEnvironment()
|
| 38 |
+
observation=env.reset(task_id=task_id,seed=seed)
|
| 39 |
+
system='Reply with exactly one JSON object and nothing else. It must match the action schema, or be {"finish":true} to end. Thinking is disabled. Action schema: '+json.dumps(RepairAction.model_json_schema())
|
| 40 |
+
messages=[{'role':'system','content':system},{'role':'user','content':observation.model_dump_json()}]
|
| 41 |
+
model_tokens=0
|
| 42 |
+
observation_estimate=0
|
| 43 |
+
reason='max_actions'
|
| 44 |
+
replies=[]
|
| 45 |
+
for turn in range(MAX_STEPS):
|
| 46 |
+
if model_tokens+observation_estimate>=completion_budget:
|
| 47 |
+
reason='approx_completion_budget'
|
| 48 |
+
break
|
| 49 |
+
response=generate(messages,min(1600,completion_budget-model_tokens-observation_estimate))
|
| 50 |
+
raw=response['message']['content']
|
| 51 |
+
model_tokens+=response.get('eval_count',0)
|
| 52 |
+
replies.append({'text':raw,'tokens':response.get('eval_count',0),'done_reason':response.get('done_reason')})
|
| 53 |
+
# Ollama's own prompt counter is used when present. No guessed tokenizer equivalence.
|
| 54 |
+
if response.get('prompt_eval_count',0)>context_budget:
|
| 55 |
+
reason='context_budget'
|
| 56 |
+
break
|
| 57 |
+
messages.append({'role':'assistant','content':raw})
|
| 58 |
+
try:
|
| 59 |
+
action=decode(raw)
|
| 60 |
+
except (ValueError,ValidationError,TypeError):
|
| 61 |
+
reason='invalid_action'
|
| 62 |
+
break
|
| 63 |
+
observation=env.step(action)
|
| 64 |
+
if observation.done:
|
| 65 |
+
reason='terminal'
|
| 66 |
+
break
|
| 67 |
+
text=observation.model_dump_json()
|
| 68 |
+
# Explicit approximation for post-reset observation tokens; report it in provenance.
|
| 69 |
+
observation_estimate+=math.ceil(len(text.encode())/3)
|
| 70 |
+
messages.append({'role':'user','content':text})
|
| 71 |
+
if not observation.done:
|
| 72 |
+
observation=env.step(RepairAction(operation='submit'))
|
| 73 |
+
return {'task_id':task_id,'seed':seed,'reward':observation.reward,'done':observation.done,
|
| 74 |
+
'steps':env.state.step_count,'termination':reason,'model_tokens':model_tokens,
|
| 75 |
+
'observation_tokens_estimated':observation_estimate,'replies':replies}
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
class Ollama:
|
| 79 |
+
def __init__(self,base,model,temperature,random_seed):
|
| 80 |
+
parsed=urllib.parse.urlparse(base)
|
| 81 |
+
if parsed.scheme!='http' or parsed.hostname not in {'localhost','127.0.0.1','::1'} or parsed.username or parsed.password or parsed.query:
|
| 82 |
+
raise ValueError('This harness is local-only; remote inference requires separate authorization')
|
| 83 |
+
self.base=base.rstrip('/')
|
| 84 |
+
self.model=model
|
| 85 |
+
self.temperature=temperature
|
| 86 |
+
self.random_seed=random_seed
|
| 87 |
+
|
| 88 |
+
def request(self,path,payload=None):
|
| 89 |
+
data=None if payload is None else json.dumps(payload).encode()
|
| 90 |
+
request=urllib.request.Request(self.base+path,data=data,headers={'Content-Type':'application/json'})
|
| 91 |
+
with urllib.request.urlopen(request,timeout=600) as response:
|
| 92 |
+
return json.load(response)
|
| 93 |
+
|
| 94 |
+
def info(self):
|
| 95 |
+
version=self.request('/api/version')
|
| 96 |
+
model=self.request('/api/show',{'model':self.model})
|
| 97 |
+
return {'runtime':version,'model':self.model,'details':model.get('details'),
|
| 98 |
+
'model_info':model.get('model_info'),'template':model.get('template')}
|
| 99 |
+
|
| 100 |
+
def generate(self,messages,budget):
|
| 101 |
+
self.random_seed+=1
|
| 102 |
+
return self.request('/api/chat',{'model':self.model,'stream':False,'think':False,
|
| 103 |
+
'messages':messages,'options':{'temperature':self.temperature,'seed':self.random_seed,
|
| 104 |
+
'num_predict':budget,'num_ctx':8192},'keep_alive':'10m'})
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def summarize(rows):
|
| 108 |
+
groups={}
|
| 109 |
+
for row in rows:
|
| 110 |
+
groups.setdefault((row['task_id'],row['seed']),[]).append(row['reward'])
|
| 111 |
+
result=[]
|
| 112 |
+
for (task_id,seed),rewards in groups.items():
|
| 113 |
+
result.append({'task_id':task_id,'seed':seed,'rewards':rewards,
|
| 114 |
+
'variance':statistics.pvariance(rewards),'mixed_rewards':len(set(rewards))>1})
|
| 115 |
+
return {'episodes':len(rows),'groups':result,'groups_with_mixed_rewards':sum(g['mixed_rewards'] for g in result),
|
| 116 |
+
'perfect_episodes':sum(r['reward']==1 for r in rows),'invalid_actions':sum(r['termination']=='invalid_action' for r in rows),
|
| 117 |
+
'mean_reward':statistics.mean(r['reward'] for r in rows) if rows else None,
|
| 118 |
+
'proves_learning_gain':False,'arena_score':None}
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def run_probes(model, task_ids, seed, repeats, temperature, output):
|
| 122 |
+
info=model.info() # Fail before creating a result if no real model is available.
|
| 123 |
+
rows=[]
|
| 124 |
+
runtime_errors=[]
|
| 125 |
+
started=time.time()
|
| 126 |
+
initial_sampling_seed=model.random_seed
|
| 127 |
+
for task_id in task_ids:
|
| 128 |
+
for repeat in range(repeats):
|
| 129 |
+
try:
|
| 130 |
+
row=episode(task_id,seed,model.generate)
|
| 131 |
+
except (urllib.error.URLError, TimeoutError) as error:
|
| 132 |
+
detail={'task_id':task_id,'seed':seed,'repeat':repeat,
|
| 133 |
+
'type':type(error).__name__,'error':str(error)}
|
| 134 |
+
if isinstance(error,urllib.error.HTTPError):
|
| 135 |
+
detail['status']=error.code
|
| 136 |
+
detail['body']=error.read(65536).decode(errors='replace')
|
| 137 |
+
runtime_errors.append(detail)
|
| 138 |
+
print(json.dumps({'runtime_error':detail}),flush=True)
|
| 139 |
+
else:
|
| 140 |
+
row['repeat']=repeat
|
| 141 |
+
rows.append(row)
|
| 142 |
+
print(json.dumps({k:row[k] for k in ('task_id','seed','repeat','reward','steps','termination')}),flush=True)
|
| 143 |
+
report={'kind':'quantized_local_proxy','model':info,'temperature':temperature,
|
| 144 |
+
'thinking':False,'json_constrained_decoding':False,
|
| 145 |
+
'observation_token_accounting':'UTF-8 bytes/3 estimate, not Arena tokenizer',
|
| 146 |
+
'completion_budget':4096,'context_budget':8192,'per_reply_token_cap':1600,
|
| 147 |
+
'initial_sampling_seed':initial_sampling_seed,
|
| 148 |
+
'requested_episodes':len(task_ids)*repeats,'runtime_errors':runtime_errors,
|
| 149 |
+
'wall_seconds':time.time()-started,'summary':summarize(rows),'episodes':rows}
|
| 150 |
+
Path(output).write_text(json.dumps(report,indent=2)+'\n')
|
| 151 |
+
return report
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
if __name__=='__main__':
|
| 155 |
+
parser=argparse.ArgumentParser()
|
| 156 |
+
parser.add_argument('--base',default='http://127.0.0.1:11434')
|
| 157 |
+
parser.add_argument('--model',default='qwen3.8:27b')
|
| 158 |
+
parser.add_argument('--tasks',nargs='+',choices=TASK_IDS,default=['allocation-3','expression-3','incident-3'])
|
| 159 |
+
parser.add_argument('--seed',type=int,default=5000)
|
| 160 |
+
parser.add_argument('--repeats',type=int,default=4)
|
| 161 |
+
parser.add_argument('--temperature',type=float,default=1.0)
|
| 162 |
+
parser.add_argument('--output',default='qwen-calibration.json')
|
| 163 |
+
args=parser.parse_args()
|
| 164 |
+
if args.repeats<2:
|
| 165 |
+
parser.error('at least two repeats required for reward spread')
|
| 166 |
+
model=Ollama(args.base,args.model,args.temperature,9000)
|
| 167 |
+
run_probes(model,args.tasks,args.seed,args.repeats,args.temperature,args.output)
|
v3/calibrate_raw.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Official-template local proxy without Ollama's chat/tool-output parser.
|
| 2 |
+
|
| 3 |
+
Raw model text is never cleaned up or constrained to JSON. The environment and
|
| 4 |
+
budgets remain those of calibrate.py. Quantized weights are still not Arena.
|
| 5 |
+
"""
|
| 6 |
+
import argparse
|
| 7 |
+
import hashlib
|
| 8 |
+
import json
|
| 9 |
+
import urllib.request
|
| 10 |
+
|
| 11 |
+
from jinja2.sandbox import ImmutableSandboxedEnvironment
|
| 12 |
+
|
| 13 |
+
from calibrate import Ollama, run_probes
|
| 14 |
+
from tasks import TASK_IDS
|
| 15 |
+
|
| 16 |
+
TEMPLATE_URL='https://huggingface.co/Qwen/Qwen3.8-27B/raw/1d4bf0f2ff6012fd82039f2fa52739d0dd7c60c0/tokenizer_config.json'
|
| 17 |
+
TEMPLATE_SHA256='c3cf9e34abf4f9e36c2d72165aa9c132d3e2a725b6c2586aaa3a8af9d7a81041'
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def load_template():
|
| 21 |
+
# Public source, no token, profile credential or implicit HF auth.
|
| 22 |
+
with urllib.request.urlopen(TEMPLATE_URL,timeout=30) as response:
|
| 23 |
+
template=json.load(response)['chat_template']
|
| 24 |
+
if hashlib.sha256(template.encode()).hexdigest()!=TEMPLATE_SHA256:
|
| 25 |
+
raise ValueError('Official template hash changed')
|
| 26 |
+
return template
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def renderer(template):
|
| 30 |
+
env=ImmutableSandboxedEnvironment(trim_blocks=True,lstrip_blocks=True)
|
| 31 |
+
def fail(message):
|
| 32 |
+
raise ValueError(message)
|
| 33 |
+
env.globals['raise_exception']=fail
|
| 34 |
+
return env.from_string(template)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class RawOllama(Ollama):
|
| 38 |
+
def __init__(self,base,model,temperature,random_seed,template):
|
| 39 |
+
super().__init__(base,model,temperature,random_seed)
|
| 40 |
+
self.template=template
|
| 41 |
+
self.render=renderer(template)
|
| 42 |
+
|
| 43 |
+
def info(self):
|
| 44 |
+
result=super().info()
|
| 45 |
+
result['inference_api']='/api/generate raw=true'
|
| 46 |
+
result['official_template_url']=TEMPLATE_URL
|
| 47 |
+
result['official_template_sha256']=hashlib.sha256(self.template.encode()).hexdigest()
|
| 48 |
+
result['enable_thinking']=False
|
| 49 |
+
return result
|
| 50 |
+
|
| 51 |
+
def generate(self,messages,budget):
|
| 52 |
+
self.random_seed+=1
|
| 53 |
+
prompt=self.render.render(messages=messages,tools=None,
|
| 54 |
+
enable_thinking=False,add_generation_prompt=True)
|
| 55 |
+
result=self.request('/api/generate',{'model':self.model,'raw':True,
|
| 56 |
+
'prompt':prompt,'stream':False,'think':False,
|
| 57 |
+
'options':{'temperature':self.temperature,'seed':self.random_seed,
|
| 58 |
+
'num_predict':budget,'num_ctx':8192},'keep_alive':'10m'})
|
| 59 |
+
# Preserve every generated character, including XML, fences and prose.
|
| 60 |
+
result['message']={'role':'assistant','content':result['response']}
|
| 61 |
+
return result
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
if __name__=='__main__':
|
| 65 |
+
parser=argparse.ArgumentParser()
|
| 66 |
+
parser.add_argument('--base',default='http://127.0.0.1:11434')
|
| 67 |
+
parser.add_argument('--model',default='qwen3.8:27b')
|
| 68 |
+
parser.add_argument('--tasks',nargs='+',choices=TASK_IDS,
|
| 69 |
+
default=['allocation-3','expression-3','incident-3'])
|
| 70 |
+
parser.add_argument('--seed',type=int,default=5001)
|
| 71 |
+
parser.add_argument('--repeats',type=int,default=4)
|
| 72 |
+
parser.add_argument('--temperature',type=float,default=1.0)
|
| 73 |
+
parser.add_argument('--output',default='qwen-raw-calibration.json')
|
| 74 |
+
args=parser.parse_args()
|
| 75 |
+
if args.repeats<2:
|
| 76 |
+
parser.error('at least two repeats required for reward spread')
|
| 77 |
+
model=RawOllama(args.base,args.model,args.temperature,9000,load_template())
|
| 78 |
+
run_probes(model,args.tasks,args.seed,args.repeats,args.temperature,args.output)
|
v3/execution.py
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Bounded restricted Python execution. Parent owns all expected answers and rewards.
|
| 2 |
+
|
| 3 |
+
Not a general sandbox. AST/builtin restrictions and a subprocess are defense in
|
| 4 |
+
depth; the container is the outer isolation boundary. Hidden tests, references
|
| 5 |
+
and grading state are never sent to the candidate interpreter.
|
| 6 |
+
"""
|
| 7 |
+
import ast
|
| 8 |
+
import json
|
| 9 |
+
import math
|
| 10 |
+
import subprocess
|
| 11 |
+
import sys
|
| 12 |
+
import tempfile
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
STDLIB = {'csv', 'io', 'fractions'}
|
| 16 |
+
EXPORTS = {'csv': {'DictReader', 'reader'}, 'io': {'StringIO'}, 'fractions': {'Fraction'}}
|
| 17 |
+
METHODS = set('append extend pop insert remove clear sort reverse count index get keys values items setdefault add discard union intersection difference split splitlines join strip lstrip rstrip replace startswith endswith lower upper casefold isdigit isalpha isalnum isspace copy fromkeys numerator denominator limit_denominator'.split()) | set().union(*EXPORTS.values())
|
| 18 |
+
MAX_SOURCE = 48000
|
| 19 |
+
RUNNER = r'''
|
| 20 |
+
import builtins, contextlib, importlib, io, json, resource, sys, types
|
| 21 |
+
resource.setrlimit(resource.RLIMIT_CPU, (2,2))
|
| 22 |
+
if sys.platform != 'darwin':
|
| 23 |
+
resource.setrlimit(resource.RLIMIT_AS,(256*1024*1024,256*1024*1024))
|
| 24 |
+
resource.setrlimit(resource.RLIMIT_FSIZE,(1048576,1048576))
|
| 25 |
+
resource.setrlimit(resource.RLIMIT_NOFILE,(16,16))
|
| 26 |
+
resource.setrlimit(resource.RLIMIT_CORE,(0,0))
|
| 27 |
+
payload=json.load(sys.stdin)
|
| 28 |
+
sources={p[:-3]:c for p,c in payload['files'].items()}
|
| 29 |
+
allowed={n:getattr(builtins,n) for n in 'abs all any bool dict enumerate filter float int isinstance len list map max min pow range reversed round set sorted str sum tuple zip Exception ValueError TypeError'.split()}
|
| 30 |
+
cache={}
|
| 31 |
+
loading=set()
|
| 32 |
+
def load(name,globals=None,locals=None,fromlist=(),level=0):
|
| 33 |
+
if level or '.' in name:
|
| 34 |
+
raise ImportError('only absolute top-level imports')
|
| 35 |
+
if name in ('csv','io','fractions'):
|
| 36 |
+
names={'csv':['DictReader','reader'],'io':['StringIO'],'fractions':['Fraction']}[name]
|
| 37 |
+
safe=types.ModuleType(name)
|
| 38 |
+
original=importlib.import_module(name)
|
| 39 |
+
for n in names:
|
| 40 |
+
setattr(safe,n,getattr(original,n))
|
| 41 |
+
return safe
|
| 42 |
+
if name not in sources:
|
| 43 |
+
raise ImportError(name)
|
| 44 |
+
if name in loading:
|
| 45 |
+
raise ImportError('circular local import')
|
| 46 |
+
if name not in cache:
|
| 47 |
+
loading.add(name)
|
| 48 |
+
module=types.ModuleType(name)
|
| 49 |
+
module.__dict__['__builtins__']=dict(allowed, __import__=load)
|
| 50 |
+
exec(sources[name],module.__dict__,module.__dict__)
|
| 51 |
+
cache[name]=module
|
| 52 |
+
loading.remove(name)
|
| 53 |
+
return cache[name]
|
| 54 |
+
results=[]
|
| 55 |
+
try:
|
| 56 |
+
with contextlib.redirect_stdout(io.StringIO()):
|
| 57 |
+
solve=load('main').solve
|
| 58 |
+
for args in payload['args']:
|
| 59 |
+
original=json.dumps(args,sort_keys=True,allow_nan=False)
|
| 60 |
+
try:
|
| 61 |
+
output=solve(*args)
|
| 62 |
+
encoded=json.dumps(output,allow_nan=False)
|
| 63 |
+
if len(encoded)>20000:
|
| 64 |
+
raise ValueError('output too large')
|
| 65 |
+
results.append({'output':json.loads(encoded),'mutated':original!=json.dumps(args,sort_keys=True,allow_nan=False)})
|
| 66 |
+
except BaseException as e:
|
| 67 |
+
results.append({'error':type(e).__name__})
|
| 68 |
+
except BaseException as e:
|
| 69 |
+
results=[{'error':type(e).__name__} for args in payload['args']]
|
| 70 |
+
print(json.dumps(results,allow_nan=False))
|
| 71 |
+
'''
|
| 72 |
+
|
| 73 |
+
def validate(files):
|
| 74 |
+
if 'main.py' not in files or sum(len(c) for c in files.values()) > MAX_SOURCE:
|
| 75 |
+
raise ValueError('Missing main.py or workspace too large')
|
| 76 |
+
locals_allowed = {p[:-3] for p in files}
|
| 77 |
+
for path, code in files.items():
|
| 78 |
+
if not path.endswith('.py') or not path[:-3].isidentifier() or path.startswith('_'):
|
| 79 |
+
raise ValueError('Only flat public Python module names')
|
| 80 |
+
tree = ast.parse(code)
|
| 81 |
+
if path == 'main.py' and not any(isinstance(n,ast.FunctionDef) and n.name=='solve' for n in tree.body):
|
| 82 |
+
raise ValueError('main.py must define solve')
|
| 83 |
+
for n in ast.walk(tree):
|
| 84 |
+
if isinstance(n,(ast.ClassDef,ast.AsyncFunctionDef,ast.Await,ast.With,ast.AsyncWith,ast.Global,ast.Nonlocal)):
|
| 85 |
+
raise ValueError('Unsupported control construct')
|
| 86 |
+
if isinstance(n,ast.Import):
|
| 87 |
+
for a in n.names:
|
| 88 |
+
if a.name not in locals_allowed | STDLIB or (a.asname or a.name).startswith('_'):
|
| 89 |
+
raise ValueError('Import unavailable')
|
| 90 |
+
if isinstance(n,ast.ImportFrom):
|
| 91 |
+
if n.level or n.module not in locals_allowed | STDLIB or any(a.name.startswith('_') or (a.asname or '').startswith('_') or a.name=='*' or (n.module in STDLIB and a.name not in EXPORTS[n.module]) for a in n.names):
|
| 92 |
+
raise ValueError('Import unavailable')
|
| 93 |
+
if isinstance(n,ast.Attribute) and n.attr not in METHODS:
|
| 94 |
+
raise ValueError('Private attributes and I/O unavailable')
|
| 95 |
+
if isinstance(n,ast.Name) and (n.id.startswith('_') or n.id in {'open','eval','exec','compile','globals','locals','vars','getattr','setattr','delattr','hasattr','type','input','print','breakpoint','help','dir','memoryview'}):
|
| 96 |
+
raise ValueError('Private/dynamic names and I/O unavailable')
|
| 97 |
+
if isinstance(n,(ast.FunctionDef,ast.arg)):
|
| 98 |
+
name=n.name if isinstance(n,ast.FunctionDef) else n.arg
|
| 99 |
+
if name.startswith('_') or (isinstance(n,ast.FunctionDef) and n.decorator_list):
|
| 100 |
+
raise ValueError('Private or decorated functions unavailable')
|
| 101 |
+
if isinstance(n,ast.ExceptHandler) and n.name and n.name.startswith('_'):
|
| 102 |
+
raise ValueError('Private exception alias unavailable')
|
| 103 |
+
return True
|
| 104 |
+
|
| 105 |
+
def equal(actual, expected):
|
| 106 |
+
if isinstance(actual,bool) or isinstance(expected,bool):
|
| 107 |
+
return type(actual) is type(expected) and actual==expected
|
| 108 |
+
if isinstance(actual,(int,float)) and isinstance(expected,(int,float)):
|
| 109 |
+
return math.isfinite(actual) and math.isclose(actual,expected,rel_tol=1e-10,abs_tol=1e-10)
|
| 110 |
+
if isinstance(actual,list) and isinstance(expected,list):
|
| 111 |
+
return len(actual)==len(expected) and all(equal(a,b) for a,b in zip(actual,expected))
|
| 112 |
+
if isinstance(actual,dict) and isinstance(expected,dict):
|
| 113 |
+
return actual.keys()==expected.keys() and all(equal(actual[k],expected[k]) for k in expected)
|
| 114 |
+
return type(actual) is type(expected) and actual==expected
|
| 115 |
+
|
| 116 |
+
def grade(files, cases, feedback=False):
|
| 117 |
+
total=len(cases)
|
| 118 |
+
outputs=[]
|
| 119 |
+
error=None
|
| 120 |
+
try:
|
| 121 |
+
validate(files)
|
| 122 |
+
# Bounded spool prevents untrusted output exhausting parent memory.
|
| 123 |
+
with tempfile.TemporaryDirectory(prefix='repair-v3-') as work:
|
| 124 |
+
output_path=Path(work)/'result'
|
| 125 |
+
with output_path.open('w+') as out:
|
| 126 |
+
process=subprocess.run([sys.executable,'-I','-S','-c',RUNNER],
|
| 127 |
+
input=json.dumps({'files':files,'args':[c['args'] for c in cases]}),
|
| 128 |
+
text=True,stdout=out,stderr=subprocess.DEVNULL,timeout=3,
|
| 129 |
+
cwd=work,env={'PATH':'/usr/bin:/bin'})
|
| 130 |
+
out.seek(0)
|
| 131 |
+
raw=out.read(1048577)
|
| 132 |
+
if process.returncode or len(raw)>1048576:
|
| 133 |
+
raise ValueError('execution/resource limit')
|
| 134 |
+
outputs=json.loads(raw)
|
| 135 |
+
if not isinstance(outputs,list) or len(outputs)!=total:
|
| 136 |
+
raise ValueError('invalid result protocol')
|
| 137 |
+
except (ValueError,SyntaxError,RecursionError,subprocess.TimeoutExpired) as e:
|
| 138 |
+
error=type(e).__name__+': '+str(e)[:150]
|
| 139 |
+
groups, failures, passed={},[],0
|
| 140 |
+
for i,c in enumerate(cases):
|
| 141 |
+
result=outputs[i] if i<len(outputs) else {'error':error or 'no output'}
|
| 142 |
+
ok=isinstance(result,dict) and 'output' in result and not result.get('mutated') and equal(result['output'],c['expected'])
|
| 143 |
+
passed+=int(ok)
|
| 144 |
+
tally=groups.setdefault(c['group'],[0,0]); tally[0]+=int(ok); tally[1]+=1
|
| 145 |
+
if feedback and not ok and len(failures)<3:
|
| 146 |
+
failures.append({'args':c['args'],'expected':c['expected'],'actual':result})
|
| 147 |
+
# Balance distinct behaviors instead of allowing random easy cases to swamp edge cases.
|
| 148 |
+
reward=sum(a/b for a,b in groups.values())/len(groups) if groups else 0.0
|
| 149 |
+
result={'passed':passed,'total':total,'reward':reward}
|
| 150 |
+
if feedback:
|
| 151 |
+
result['failures']=failures
|
| 152 |
+
if error:
|
| 153 |
+
result['error']=error
|
| 154 |
+
return result
|
v3/hard_tasks.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Harder algorithmic repair families with independent small-instance oracles."""
|
| 2 |
+
import ast
|
| 3 |
+
from fractions import Fraction
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def allocation_ref(workers,jobs,quotes):
|
| 7 |
+
cost={(w,j):c for w,j,c in quotes}
|
| 8 |
+
slots=[j for j,d in jobs for _ in range(d)]
|
| 9 |
+
remaining=dict(workers)
|
| 10 |
+
best=(0,0)
|
| 11 |
+
def search(i,filled,total):
|
| 12 |
+
nonlocal best
|
| 13 |
+
if i==len(slots):
|
| 14 |
+
if filled>best[0] or (filled==best[0] and total<best[1]):
|
| 15 |
+
best=(filled,total)
|
| 16 |
+
return
|
| 17 |
+
search(i+1,filled,total)
|
| 18 |
+
j=slots[i]
|
| 19 |
+
for w in remaining:
|
| 20 |
+
if remaining[w]>0 and (w,j) in cost:
|
| 21 |
+
remaining[w]-=1
|
| 22 |
+
search(i+1,filled+1,total+cost[w,j])
|
| 23 |
+
remaining[w]+=1
|
| 24 |
+
search(0,0,0)
|
| 25 |
+
return {'filled':best[0],'cost':best[1]}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def expression_ref(text):
|
| 29 |
+
# AST visitor is independent of the candidate's tokenizer/Pratt parser.
|
| 30 |
+
tree=ast.parse(text.strip().replace('^','**'),mode='eval')
|
| 31 |
+
def evaluate(n):
|
| 32 |
+
if isinstance(n,ast.Constant) and type(n.value) is int:
|
| 33 |
+
return Fraction(n.value)
|
| 34 |
+
if isinstance(n,ast.UnaryOp):
|
| 35 |
+
v=evaluate(n.operand)
|
| 36 |
+
return -v if isinstance(n.op,ast.USub) else v
|
| 37 |
+
a,b=evaluate(n.left),evaluate(n.right)
|
| 38 |
+
if isinstance(n.op,ast.Add): return a+b
|
| 39 |
+
if isinstance(n.op,ast.Sub): return a-b
|
| 40 |
+
if isinstance(n.op,ast.Mult): return a*b
|
| 41 |
+
if isinstance(n.op,ast.Div): return a/b
|
| 42 |
+
if isinstance(n.op,ast.Pow): return a**b
|
| 43 |
+
raise ValueError('operator')
|
| 44 |
+
return str(evaluate(tree.body))
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
HARD_SPECS={
|
| 48 |
+
'allocation': (
|
| 49 |
+
'solve(workers,jobs,quotes): workers=[[name,capacity],...], jobs=[[name,demand],...], quotes=[[worker,job,cost_per_unit],...] (unique pairs, nonnegative integer costs). Unquoted assignments are forbidden. Allocate integer units, never exceed a worker capacity or job demand. First maximize total filled demand, then minimize cost among all such allocations. Return exactly {filled:int,cost:int}. A greedy edge ordering is insufficient; reassignment may be necessary. Names in each list are unique. Empty and disconnected instances are valid; do not mutate inputs.',
|
| 50 |
+
{
|
| 51 |
+
'network.py': "def edge(graph,a,b,cap,cost):\n graph[a].append([b,len(graph[b]),cap,cost])\n graph[b].append([a,len(graph[a])-1,0,-cost])\n",
|
| 52 |
+
'paths.py': "def shortest(graph,source):\n n=len(graph)\n distance=[None]*n\n parent=[None]*n\n distance[source]=0\n for turn in range(n-1):\n changed=False\n for a in range(n):\n if distance[a] is not None:\n for idx,e in enumerate(graph[a]):\n b,rev,cap,cost=e\n if cap>0 and (distance[b] is None or distance[a]+cost<distance[b]):\n distance[b]=distance[a]+cost\n parent[b]=(a,idx)\n changed=True\n if not changed:\n break\n return distance,parent\n",
|
| 53 |
+
'augment.py': "def send(graph,parent,source,sink):\n path=[]\n v=sink\n while v!=source:\n a,idx=parent[v]\n path.append((a,idx))\n v=a\n amount=min(graph[a][idx][2] for a,idx in path)\n for a,idx in path:\n b,rev,cap,cost=graph[a][idx]\n graph[a][idx][2]-=amount\n graph[b][rev][2]+=amount\n return amount\n",
|
| 54 |
+
'main.py': "from network import edge\nfrom paths import shortest\nfrom augment import send\ndef solve(workers,jobs,quotes):\n wmap={name:i+1 for i,(name,c) in enumerate(workers)}\n jmap={name:len(workers)+i+1 for i,(name,d) in enumerate(jobs)}\n source,sink=0,len(workers)+len(jobs)+1\n graph=[[] for i in range(sink+1)]\n for name,c in workers:\n edge(graph,source,wmap[name],c,0)\n for name,d in jobs:\n edge(graph,jmap[name],sink,d,0)\n for w,j,c in quotes:\n edge(graph,wmap[w],jmap[j],sum(d for name,d in jobs),c)\n filled,total=0,0\n while True:\n distance,parent=shortest(graph,source)\n if distance[sink] is None:\n break\n amount=send(graph,parent,source,sink)\n filled+=amount\n total+=amount*distance[sink]\n return {'filled':filled,'cost':total}\n",
|
| 55 |
+
}, [('network.py','len(graph[a])-1,0,-cost','len(graph[a])-1,0,cost'),
|
| 56 |
+
('paths.py','range(n-1)','range(1)'),
|
| 57 |
+
('augment.py','amount=min(','amount=max(')]),
|
| 58 |
+
'expression': (
|
| 59 |
+
'solve(text): text is a valid arithmetic expression of nonnegative integer literals, whitespace, parentheses, unary +/- and binary + - * / ^. Use exact rational arithmetic. Power is right-associative and binds MORE tightly than unary signs; multiplication/division are left-associative and bind more tightly than addition/subtraction. Exponents evaluate to nonnegative integers; no zero divisor occurs. Return the canonical fractions.Fraction string, integer if denominator=1, else numerator/denominator. Example -2^2 is -4, 2^3^2 is 512, 8/4/2 is 1. Input unchanged.',
|
| 60 |
+
{
|
| 61 |
+
'lex.py': "def tokens(text):\n out=[]\n i=0\n while i<len(text):\n c=text[i]\n if c.isspace():\n i+=1\n elif c.isdigit():\n j=i+1\n while j<len(text) and text[j].isdigit():\n j+=1\n out.append(text[i:j])\n i=j\n else:\n out.append(c)\n i+=1\n return out\n",
|
| 62 |
+
'binding.py': "def powers(op):\n if op in ('+','-'): return (10,11)\n if op in ('*','/'): return (20,21)\n if op=='^': return (40,40)\n return (-1,-1)\n",
|
| 63 |
+
'unary.py': "def precedence():\n return 30\n",
|
| 64 |
+
'main.py': "from fractions import Fraction\nfrom lex import tokens\nfrom binding import powers\nfrom unary import precedence\ndef parse(ts,pos,minimum):\n token=ts[pos]\n if token in ('+','-'):\n value,pos=parse(ts,pos+1,precedence())\n if token=='-': value=-value\n elif token=='(':\n value,pos=parse(ts,pos+1,0)\n if ts[pos]!=')': raise ValueError('parenthesis')\n pos+=1\n else:\n value=Fraction(int(token))\n pos+=1\n while pos<len(ts):\n op=ts[pos]\n left,right=powers(op)\n if left<minimum: break\n other,pos=parse(ts,pos+1,right)\n if op=='+': value+=other\n elif op=='-': value-=other\n elif op=='*': value*=other\n elif op=='/': value/=other\n elif op=='^': value=value**other\n return value,pos\ndef solve(text):\n ts=tokens(text)\n value,pos=parse(ts,0,0)\n if pos!=len(ts): raise ValueError('trailing tokens')\n return str(value)\n",
|
| 65 |
+
}, [('lex.py','while j<len(text) and text[j].isdigit():','while False:'),
|
| 66 |
+
('binding.py',"if op=='^': return (40,40)","if op=='^': return (40,41)"),
|
| 67 |
+
('unary.py','return 30','return 50')]),
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def hard_cases(family,rng):
|
| 72 |
+
out=[]
|
| 73 |
+
def add(group,*args):
|
| 74 |
+
out.append({'group':group,'args':list(args)})
|
| 75 |
+
if family=='allocation':
|
| 76 |
+
add('empty',[],[],[])
|
| 77 |
+
add('reroute',[['a',1],['b',1]],[['x',1],['y',1]],[['a','x',1],['a','y',2],['b','x',2],['b','y',100]])
|
| 78 |
+
add('bottleneck',[['a',4]],[['x',1]],[['a','x',3]])
|
| 79 |
+
add('shortfall',[['a',2]],[['x',1],['y',3]],[['a','x',2]])
|
| 80 |
+
add('reverse_order',[['b',1],['a',1]],[['y',1],['x',1]],[['a','x',1],['a','y',2],['b','x',2],['b','y',100]])
|
| 81 |
+
for i in range(30):
|
| 82 |
+
workers=[[f'w{j}',rng.randint(1,3)] for j in range(rng.randint(2,3))]
|
| 83 |
+
jobs=[[f'j{j}',rng.randint(1,2)] for j in range(rng.randint(2,3))]
|
| 84 |
+
quotes=[[w,j,rng.randint(0,20)] for w,c in workers for j,d in jobs if rng.random()<.8]
|
| 85 |
+
rng.shuffle(workers); rng.shuffle(jobs); rng.shuffle(quotes)
|
| 86 |
+
add('random',workers,jobs,quotes)
|
| 87 |
+
else:
|
| 88 |
+
add('literal',str(rng.randint(10,99)))
|
| 89 |
+
add('unary',f'-{rng.randint(2,5)}^2')
|
| 90 |
+
add('power','2^3^2')
|
| 91 |
+
add('rational','8/4/2 + 1/3')
|
| 92 |
+
add('parentheses','-(12 + 3) * (5 - 8)')
|
| 93 |
+
def expression(depth):
|
| 94 |
+
if depth==0: return str(rng.randint(1,20))
|
| 95 |
+
op=rng.choice(['+','-','*','/','^'])
|
| 96 |
+
a=expression(depth-1)
|
| 97 |
+
b=str(rng.randint(1,5)) if op=='/' else str(rng.randint(0,3)) if op=='^' else expression(depth-1)
|
| 98 |
+
value=f'({a} {op} {b})'
|
| 99 |
+
return '-'+value if rng.random()<.25 else value
|
| 100 |
+
for i in range(30): add('random',expression(rng.randint(1,3)))
|
| 101 |
+
return out
|
v3/live-replay-results.json
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"transport": "real_network_websocket",
|
| 3 |
+
"task_ids": 24,
|
| 4 |
+
"all_passed": true,
|
| 5 |
+
"rows": [
|
| 6 |
+
{
|
| 7 |
+
"task_id": "ledger-1",
|
| 8 |
+
"seed": 1234,
|
| 9 |
+
"starter_reward": 0.5057471264367815,
|
| 10 |
+
"oracle_reward": 1.0,
|
| 11 |
+
"done": true
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"task_id": "ledger-2",
|
| 15 |
+
"seed": 1234,
|
| 16 |
+
"starter_reward": 0.5057471264367815,
|
| 17 |
+
"oracle_reward": 1.0,
|
| 18 |
+
"done": true
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"task_id": "ledger-3",
|
| 22 |
+
"seed": 1234,
|
| 23 |
+
"starter_reward": 0.3333333333333333,
|
| 24 |
+
"oracle_reward": 1.0,
|
| 25 |
+
"done": true
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"task_id": "capacity-1",
|
| 29 |
+
"seed": 1234,
|
| 30 |
+
"starter_reward": 0.5747126436781609,
|
| 31 |
+
"oracle_reward": 1.0,
|
| 32 |
+
"done": true
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"task_id": "capacity-2",
|
| 36 |
+
"seed": 1234,
|
| 37 |
+
"starter_reward": 0.3390804597701149,
|
| 38 |
+
"oracle_reward": 1.0,
|
| 39 |
+
"done": true
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"task_id": "capacity-3",
|
| 43 |
+
"seed": 1234,
|
| 44 |
+
"starter_reward": 0.3333333333333333,
|
| 45 |
+
"oracle_reward": 1.0,
|
| 46 |
+
"done": true
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"task_id": "workflow-1",
|
| 50 |
+
"seed": 1234,
|
| 51 |
+
"starter_reward": 0.8333333333333334,
|
| 52 |
+
"oracle_reward": 1.0,
|
| 53 |
+
"done": true
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"task_id": "workflow-2",
|
| 57 |
+
"seed": 1234,
|
| 58 |
+
"starter_reward": 0.4827586206896552,
|
| 59 |
+
"oracle_reward": 1.0,
|
| 60 |
+
"done": true
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"task_id": "workflow-3",
|
| 64 |
+
"seed": 1234,
|
| 65 |
+
"starter_reward": 0.37931034482758624,
|
| 66 |
+
"oracle_reward": 1.0,
|
| 67 |
+
"done": true
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"task_id": "incident-1",
|
| 71 |
+
"seed": 1234,
|
| 72 |
+
"starter_reward": 0.6666666666666666,
|
| 73 |
+
"oracle_reward": 1.0,
|
| 74 |
+
"done": true
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"task_id": "incident-2",
|
| 78 |
+
"seed": 1234,
|
| 79 |
+
"starter_reward": 0.5057471264367815,
|
| 80 |
+
"oracle_reward": 1.0,
|
| 81 |
+
"done": true
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"task_id": "incident-3",
|
| 85 |
+
"seed": 1234,
|
| 86 |
+
"starter_reward": 0.3333333333333333,
|
| 87 |
+
"oracle_reward": 1.0,
|
| 88 |
+
"done": true
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"task_id": "sensor-1",
|
| 92 |
+
"seed": 1234,
|
| 93 |
+
"starter_reward": 0.6781609195402298,
|
| 94 |
+
"oracle_reward": 1.0,
|
| 95 |
+
"done": true
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"task_id": "sensor-2",
|
| 99 |
+
"seed": 1234,
|
| 100 |
+
"starter_reward": 0.3333333333333333,
|
| 101 |
+
"oracle_reward": 1.0,
|
| 102 |
+
"done": true
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"task_id": "sensor-3",
|
| 106 |
+
"seed": 1234,
|
| 107 |
+
"starter_reward": 0.3333333333333333,
|
| 108 |
+
"oracle_reward": 1.0,
|
| 109 |
+
"done": true
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"task_id": "reconcile-1",
|
| 113 |
+
"seed": 1234,
|
| 114 |
+
"starter_reward": 0.6666666666666666,
|
| 115 |
+
"oracle_reward": 1.0,
|
| 116 |
+
"done": true
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"task_id": "reconcile-2",
|
| 120 |
+
"seed": 1234,
|
| 121 |
+
"starter_reward": 0.5,
|
| 122 |
+
"oracle_reward": 1.0,
|
| 123 |
+
"done": true
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"task_id": "reconcile-3",
|
| 127 |
+
"seed": 1234,
|
| 128 |
+
"starter_reward": 0.3333333333333333,
|
| 129 |
+
"oracle_reward": 1.0,
|
| 130 |
+
"done": true
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"task_id": "allocation-1",
|
| 134 |
+
"seed": 1234,
|
| 135 |
+
"starter_reward": 0.6436781609195402,
|
| 136 |
+
"oracle_reward": 1.0,
|
| 137 |
+
"done": true
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"task_id": "allocation-2",
|
| 141 |
+
"seed": 1234,
|
| 142 |
+
"starter_reward": 0.6436781609195402,
|
| 143 |
+
"oracle_reward": 1.0,
|
| 144 |
+
"done": true
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"task_id": "allocation-3",
|
| 148 |
+
"seed": 1234,
|
| 149 |
+
"starter_reward": 0.16666666666666666,
|
| 150 |
+
"oracle_reward": 1.0,
|
| 151 |
+
"done": true
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"task_id": "expression-1",
|
| 155 |
+
"seed": 1234,
|
| 156 |
+
"starter_reward": 0.8333333333333334,
|
| 157 |
+
"oracle_reward": 1.0,
|
| 158 |
+
"done": true
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"task_id": "expression-2",
|
| 162 |
+
"seed": 1234,
|
| 163 |
+
"starter_reward": 0.3735632183908046,
|
| 164 |
+
"oracle_reward": 1.0,
|
| 165 |
+
"done": true
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"task_id": "expression-3",
|
| 169 |
+
"seed": 1234,
|
| 170 |
+
"starter_reward": 0.18965517241379312,
|
| 171 |
+
"oracle_reward": 1.0,
|
| 172 |
+
"done": true
|
| 173 |
+
}
|
| 174 |
+
],
|
| 175 |
+
"model_rollouts": 0
|
| 176 |
+
}
|
v3/live_replay.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Replay all declared IDs through a real network WebSocket, not TestClient."""
|
| 2 |
+
import asyncio
|
| 3 |
+
import json
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from websockets.asyncio.client import connect
|
| 6 |
+
from tasks import TASK_IDS,make_task
|
| 7 |
+
|
| 8 |
+
async def send(sock,kind,data):
|
| 9 |
+
await sock.send(json.dumps({'type':kind,'data':data}))
|
| 10 |
+
response=json.loads(await asyncio.wait_for(sock.recv(),timeout=20))
|
| 11 |
+
assert response['type']=='observation',response
|
| 12 |
+
return response['data']
|
| 13 |
+
|
| 14 |
+
async def main():
|
| 15 |
+
rows=[]
|
| 16 |
+
for task_id in TASK_IDS:
|
| 17 |
+
task=make_task(task_id,1234)
|
| 18 |
+
async with connect('ws://127.0.0.1:8766/ws') as sock:
|
| 19 |
+
initial=await send(sock,'reset',{'task_id':task_id,'seed':1234})
|
| 20 |
+
assert initial['observation']['files']==task.starter
|
| 21 |
+
floor=await send(sock,'step',{'operation':'submit'})
|
| 22 |
+
assert floor['done'] and 0<=floor['reward']<1
|
| 23 |
+
await send(sock,'reset',{'task_id':task_id,'seed':1234})
|
| 24 |
+
for path in task.mutations:
|
| 25 |
+
written=await send(sock,'step',{'operation':'write','path':path,'code':task.solution[path]})
|
| 26 |
+
assert not written['done'] and written['reward']==0
|
| 27 |
+
result=await send(sock,'step',{'operation':'test'})
|
| 28 |
+
assert not result['done'] and result['reward']==0
|
| 29 |
+
terminal=await send(sock,'step',{'operation':'submit'})
|
| 30 |
+
assert terminal['done'] and terminal['reward']==1
|
| 31 |
+
rows.append({'task_id':task_id,'seed':1234,'starter_reward':floor['reward'],'oracle_reward':terminal['reward'],'done':True})
|
| 32 |
+
report={'transport':'real_network_websocket','task_ids':len(rows),'all_passed':True,'rows':rows,'model_rollouts':0}
|
| 33 |
+
Path('live-replay-results.json').write_text(json.dumps(report,indent=2)+'\n')
|
| 34 |
+
print(json.dumps({'task_ids':len(rows),'all_passed':True}))
|
| 35 |
+
|
| 36 |
+
if __name__=='__main__':
|
| 37 |
+
asyncio.run(main())
|
v3/openenv.yaml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
spec_version: 1
|
| 2 |
+
name: python_repair_lab_v3
|
| 3 |
+
version: 3.0.0
|
| 4 |
+
type: space
|
| 5 |
+
runtime: fastapi
|
| 6 |
+
app: server:app
|
| 7 |
+
port: 8000
|
| 8 |
+
validation:
|
| 9 |
+
reward:
|
| 10 |
+
range: [0.0, 1.0]
|
| 11 |
+
oracle_tolerance: 0.0
|
| 12 |
+
floor_margin: 0.1
|
| 13 |
+
resources:
|
| 14 |
+
cpu: 2.0
|
| 15 |
+
memory_mb: 1024
|
| 16 |
+
disk_mb: 512
|
| 17 |
+
episode_timeout_s: 180.0
|
| 18 |
+
capabilities:
|
| 19 |
+
verifier:
|
| 20 |
+
kind: reward_channel
|
| 21 |
+
types:
|
| 22 |
+
tags: [code-repair, python, multi-file, generated]
|
v3/qwen-eight-family-calibration.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
v3/qwen-raw-eight-family-calibration.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
v3/replay-results.json
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"seed_start": 1000,
|
| 3 |
+
"seeds_per_task": 50,
|
| 4 |
+
"task_ids": 24,
|
| 5 |
+
"episodes": 1200,
|
| 6 |
+
"all_oracles_perfect": true,
|
| 7 |
+
"all_starters_imperfect": true,
|
| 8 |
+
"all_single_defects_detected": true,
|
| 9 |
+
"model_rollouts": 0,
|
| 10 |
+
"rows": [
|
| 11 |
+
{
|
| 12 |
+
"task_id": "ledger-1",
|
| 13 |
+
"episodes": 50,
|
| 14 |
+
"oracle_reward": 1.0,
|
| 15 |
+
"starter_reward_min": 0.3333333333333333,
|
| 16 |
+
"starter_reward_max": 0.7873563218390806,
|
| 17 |
+
"starter_reward_mean": 0.5533333333333333,
|
| 18 |
+
"single_mutations_detected": 50,
|
| 19 |
+
"single_mutation_reward_min": 0.3333333333333333,
|
| 20 |
+
"single_mutation_reward_max": 0.7873563218390806,
|
| 21 |
+
"distinct_workspaces": 50,
|
| 22 |
+
"distinct_hidden_sets": 50
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"task_id": "ledger-2",
|
| 26 |
+
"episodes": 50,
|
| 27 |
+
"oracle_reward": 1.0,
|
| 28 |
+
"starter_reward_min": 0.3333333333333333,
|
| 29 |
+
"starter_reward_max": 0.5057471264367815,
|
| 30 |
+
"starter_reward_mean": 0.39,
|
| 31 |
+
"single_mutations_detected": 100,
|
| 32 |
+
"single_mutation_reward_min": 0.3333333333333333,
|
| 33 |
+
"single_mutation_reward_max": 0.7816091954022989,
|
| 34 |
+
"distinct_workspaces": 50,
|
| 35 |
+
"distinct_hidden_sets": 50
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"task_id": "ledger-3",
|
| 39 |
+
"episodes": 50,
|
| 40 |
+
"oracle_reward": 1.0,
|
| 41 |
+
"starter_reward_min": 0.3333333333333333,
|
| 42 |
+
"starter_reward_max": 0.3333333333333333,
|
| 43 |
+
"starter_reward_mean": 0.3333333333333333,
|
| 44 |
+
"single_mutations_detected": 150,
|
| 45 |
+
"single_mutation_reward_min": 0.3333333333333333,
|
| 46 |
+
"single_mutation_reward_max": 0.7873563218390806,
|
| 47 |
+
"distinct_workspaces": 50,
|
| 48 |
+
"distinct_hidden_sets": 50
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"task_id": "capacity-1",
|
| 52 |
+
"episodes": 50,
|
| 53 |
+
"oracle_reward": 1.0,
|
| 54 |
+
"starter_reward_min": 0.5,
|
| 55 |
+
"starter_reward_max": 0.7183908045977012,
|
| 56 |
+
"starter_reward_mean": 0.6114942528735632,
|
| 57 |
+
"single_mutations_detected": 50,
|
| 58 |
+
"single_mutation_reward_min": 0.5,
|
| 59 |
+
"single_mutation_reward_max": 0.7183908045977012,
|
| 60 |
+
"distinct_workspaces": 50,
|
| 61 |
+
"distinct_hidden_sets": 50
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"task_id": "capacity-2",
|
| 65 |
+
"episodes": 50,
|
| 66 |
+
"oracle_reward": 1.0,
|
| 67 |
+
"starter_reward_min": 0.3333333333333333,
|
| 68 |
+
"starter_reward_max": 0.5344827586206896,
|
| 69 |
+
"starter_reward_mean": 0.3994252873563218,
|
| 70 |
+
"single_mutations_detected": 100,
|
| 71 |
+
"single_mutation_reward_min": 0.5,
|
| 72 |
+
"single_mutation_reward_max": 0.7183908045977012,
|
| 73 |
+
"distinct_workspaces": 50,
|
| 74 |
+
"distinct_hidden_sets": 50
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"task_id": "capacity-3",
|
| 78 |
+
"episodes": 50,
|
| 79 |
+
"oracle_reward": 1.0,
|
| 80 |
+
"starter_reward_min": 0.3333333333333333,
|
| 81 |
+
"starter_reward_max": 0.3505747126436782,
|
| 82 |
+
"starter_reward_mean": 0.3410344827586207,
|
| 83 |
+
"single_mutations_detected": 150,
|
| 84 |
+
"single_mutation_reward_min": 0.5,
|
| 85 |
+
"single_mutation_reward_max": 0.7298850574712644,
|
| 86 |
+
"distinct_workspaces": 50,
|
| 87 |
+
"distinct_hidden_sets": 50
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"task_id": "workflow-1",
|
| 91 |
+
"episodes": 50,
|
| 92 |
+
"oracle_reward": 1.0,
|
| 93 |
+
"starter_reward_min": 0.6091954022988505,
|
| 94 |
+
"starter_reward_max": 0.8333333333333334,
|
| 95 |
+
"starter_reward_mean": 0.730919540229885,
|
| 96 |
+
"single_mutations_detected": 50,
|
| 97 |
+
"single_mutation_reward_min": 0.6091954022988505,
|
| 98 |
+
"single_mutation_reward_max": 0.8333333333333334,
|
| 99 |
+
"distinct_workspaces": 50,
|
| 100 |
+
"distinct_hidden_sets": 50
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"task_id": "workflow-2",
|
| 104 |
+
"episodes": 50,
|
| 105 |
+
"oracle_reward": 1.0,
|
| 106 |
+
"starter_reward_min": 0.43678160919540227,
|
| 107 |
+
"starter_reward_max": 0.5459770114942529,
|
| 108 |
+
"starter_reward_mean": 0.5117241379310344,
|
| 109 |
+
"single_mutations_detected": 100,
|
| 110 |
+
"single_mutation_reward_min": 0.5919540229885057,
|
| 111 |
+
"single_mutation_reward_max": 0.8333333333333334,
|
| 112 |
+
"distinct_workspaces": 50,
|
| 113 |
+
"distinct_hidden_sets": 50
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"task_id": "workflow-3",
|
| 117 |
+
"episodes": 50,
|
| 118 |
+
"oracle_reward": 1.0,
|
| 119 |
+
"starter_reward_min": 0.3620689655172414,
|
| 120 |
+
"starter_reward_max": 0.3850574712643678,
|
| 121 |
+
"starter_reward_mean": 0.3686206896551724,
|
| 122 |
+
"single_mutations_detected": 150,
|
| 123 |
+
"single_mutation_reward_min": 0.603448275862069,
|
| 124 |
+
"single_mutation_reward_max": 0.8333333333333334,
|
| 125 |
+
"distinct_workspaces": 50,
|
| 126 |
+
"distinct_hidden_sets": 50
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"task_id": "incident-1",
|
| 130 |
+
"episodes": 50,
|
| 131 |
+
"oracle_reward": 1.0,
|
| 132 |
+
"starter_reward_min": 0.6666666666666666,
|
| 133 |
+
"starter_reward_max": 0.7758620689655172,
|
| 134 |
+
"starter_reward_mean": 0.7088505747126437,
|
| 135 |
+
"single_mutations_detected": 50,
|
| 136 |
+
"single_mutation_reward_min": 0.6666666666666666,
|
| 137 |
+
"single_mutation_reward_max": 0.7758620689655172,
|
| 138 |
+
"distinct_workspaces": 50,
|
| 139 |
+
"distinct_hidden_sets": 50
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"task_id": "incident-2",
|
| 143 |
+
"episodes": 50,
|
| 144 |
+
"oracle_reward": 1.0,
|
| 145 |
+
"starter_reward_min": 0.5,
|
| 146 |
+
"starter_reward_max": 0.5517241379310345,
|
| 147 |
+
"starter_reward_mean": 0.5101149425287357,
|
| 148 |
+
"single_mutations_detected": 100,
|
| 149 |
+
"single_mutation_reward_min": 0.6666666666666666,
|
| 150 |
+
"single_mutation_reward_max": 0.7873563218390806,
|
| 151 |
+
"distinct_workspaces": 50,
|
| 152 |
+
"distinct_hidden_sets": 50
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"task_id": "incident-3",
|
| 156 |
+
"episodes": 50,
|
| 157 |
+
"oracle_reward": 1.0,
|
| 158 |
+
"starter_reward_min": 0.3333333333333333,
|
| 159 |
+
"starter_reward_max": 0.3448275862068966,
|
| 160 |
+
"starter_reward_mean": 0.33413793103448275,
|
| 161 |
+
"single_mutations_detected": 150,
|
| 162 |
+
"single_mutation_reward_min": 0.6666666666666666,
|
| 163 |
+
"single_mutation_reward_max": 0.7873563218390806,
|
| 164 |
+
"distinct_workspaces": 50,
|
| 165 |
+
"distinct_hidden_sets": 50
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"task_id": "sensor-1",
|
| 169 |
+
"episodes": 50,
|
| 170 |
+
"oracle_reward": 1.0,
|
| 171 |
+
"starter_reward_min": 0.5,
|
| 172 |
+
"starter_reward_max": 0.6781609195402298,
|
| 173 |
+
"starter_reward_mean": 0.5979310344827586,
|
| 174 |
+
"single_mutations_detected": 50,
|
| 175 |
+
"single_mutation_reward_min": 0.5,
|
| 176 |
+
"single_mutation_reward_max": 0.6781609195402298,
|
| 177 |
+
"distinct_workspaces": 50,
|
| 178 |
+
"distinct_hidden_sets": 50
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"task_id": "sensor-2",
|
| 182 |
+
"episodes": 50,
|
| 183 |
+
"oracle_reward": 1.0,
|
| 184 |
+
"starter_reward_min": 0.3333333333333333,
|
| 185 |
+
"starter_reward_max": 0.5,
|
| 186 |
+
"starter_reward_mean": 0.44666666666666666,
|
| 187 |
+
"single_mutations_detected": 100,
|
| 188 |
+
"single_mutation_reward_min": 0.5,
|
| 189 |
+
"single_mutation_reward_max": 0.6781609195402298,
|
| 190 |
+
"distinct_workspaces": 50,
|
| 191 |
+
"distinct_hidden_sets": 50
|
| 192 |
+
},
|
| 193 |
+
{
|
| 194 |
+
"task_id": "sensor-3",
|
| 195 |
+
"episodes": 50,
|
| 196 |
+
"oracle_reward": 1.0,
|
| 197 |
+
"starter_reward_min": 0.3333333333333333,
|
| 198 |
+
"starter_reward_max": 0.3333333333333333,
|
| 199 |
+
"starter_reward_mean": 0.3333333333333333,
|
| 200 |
+
"single_mutations_detected": 150,
|
| 201 |
+
"single_mutation_reward_min": 0.5,
|
| 202 |
+
"single_mutation_reward_max": 0.6724137931034483,
|
| 203 |
+
"distinct_workspaces": 50,
|
| 204 |
+
"distinct_hidden_sets": 50
|
| 205 |
+
},
|
| 206 |
+
{
|
| 207 |
+
"task_id": "reconcile-1",
|
| 208 |
+
"episodes": 50,
|
| 209 |
+
"oracle_reward": 1.0,
|
| 210 |
+
"starter_reward_min": 0.6666666666666666,
|
| 211 |
+
"starter_reward_max": 0.7011494252873564,
|
| 212 |
+
"starter_reward_mean": 0.6716091954022988,
|
| 213 |
+
"single_mutations_detected": 50,
|
| 214 |
+
"single_mutation_reward_min": 0.6666666666666666,
|
| 215 |
+
"single_mutation_reward_max": 0.7011494252873564,
|
| 216 |
+
"distinct_workspaces": 50,
|
| 217 |
+
"distinct_hidden_sets": 50
|
| 218 |
+
},
|
| 219 |
+
{
|
| 220 |
+
"task_id": "reconcile-2",
|
| 221 |
+
"episodes": 50,
|
| 222 |
+
"oracle_reward": 1.0,
|
| 223 |
+
"starter_reward_min": 0.5,
|
| 224 |
+
"starter_reward_max": 0.5057471264367815,
|
| 225 |
+
"starter_reward_mean": 0.5002298850574712,
|
| 226 |
+
"single_mutations_detected": 100,
|
| 227 |
+
"single_mutation_reward_min": 0.6666666666666666,
|
| 228 |
+
"single_mutation_reward_max": 0.7126436781609194,
|
| 229 |
+
"distinct_workspaces": 50,
|
| 230 |
+
"distinct_hidden_sets": 50
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"task_id": "reconcile-3",
|
| 234 |
+
"episodes": 50,
|
| 235 |
+
"oracle_reward": 1.0,
|
| 236 |
+
"starter_reward_min": 0.3333333333333333,
|
| 237 |
+
"starter_reward_max": 0.3333333333333333,
|
| 238 |
+
"starter_reward_mean": 0.3333333333333333,
|
| 239 |
+
"single_mutations_detected": 150,
|
| 240 |
+
"single_mutation_reward_min": 0.6666666666666666,
|
| 241 |
+
"single_mutation_reward_max": 0.7298850574712644,
|
| 242 |
+
"distinct_workspaces": 50,
|
| 243 |
+
"distinct_hidden_sets": 50
|
| 244 |
+
},
|
| 245 |
+
{
|
| 246 |
+
"task_id": "allocation-1",
|
| 247 |
+
"episodes": 50,
|
| 248 |
+
"oracle_reward": 1.0,
|
| 249 |
+
"starter_reward_min": 0.16666666666666666,
|
| 250 |
+
"starter_reward_max": 0.6609195402298851,
|
| 251 |
+
"starter_reward_mean": 0.46977011494252874,
|
| 252 |
+
"single_mutations_detected": 50,
|
| 253 |
+
"single_mutation_reward_min": 0.16666666666666666,
|
| 254 |
+
"single_mutation_reward_max": 0.6609195402298851,
|
| 255 |
+
"distinct_workspaces": 50,
|
| 256 |
+
"distinct_hidden_sets": 50
|
| 257 |
+
},
|
| 258 |
+
{
|
| 259 |
+
"task_id": "allocation-2",
|
| 260 |
+
"episodes": 50,
|
| 261 |
+
"oracle_reward": 1.0,
|
| 262 |
+
"starter_reward_min": 0.16666666666666666,
|
| 263 |
+
"starter_reward_max": 0.6609195402298851,
|
| 264 |
+
"starter_reward_mean": 0.34701149425287353,
|
| 265 |
+
"single_mutations_detected": 100,
|
| 266 |
+
"single_mutation_reward_min": 0.16666666666666666,
|
| 267 |
+
"single_mutation_reward_max": 0.6609195402298851,
|
| 268 |
+
"distinct_workspaces": 50,
|
| 269 |
+
"distinct_hidden_sets": 50
|
| 270 |
+
},
|
| 271 |
+
{
|
| 272 |
+
"task_id": "allocation-3",
|
| 273 |
+
"episodes": 50,
|
| 274 |
+
"oracle_reward": 1.0,
|
| 275 |
+
"starter_reward_min": 0.16666666666666666,
|
| 276 |
+
"starter_reward_max": 0.1724137931034483,
|
| 277 |
+
"starter_reward_mean": 0.16689655172413792,
|
| 278 |
+
"single_mutations_detected": 150,
|
| 279 |
+
"single_mutation_reward_min": 0.16666666666666666,
|
| 280 |
+
"single_mutation_reward_max": 0.6609195402298851,
|
| 281 |
+
"distinct_workspaces": 50,
|
| 282 |
+
"distinct_hidden_sets": 50
|
| 283 |
+
},
|
| 284 |
+
{
|
| 285 |
+
"task_id": "expression-1",
|
| 286 |
+
"episodes": 50,
|
| 287 |
+
"oracle_reward": 1.0,
|
| 288 |
+
"starter_reward_min": 0.5172413793103449,
|
| 289 |
+
"starter_reward_max": 0.8333333333333334,
|
| 290 |
+
"starter_reward_mean": 0.7055172413793104,
|
| 291 |
+
"single_mutations_detected": 50,
|
| 292 |
+
"single_mutation_reward_min": 0.5172413793103449,
|
| 293 |
+
"single_mutation_reward_max": 0.8333333333333334,
|
| 294 |
+
"distinct_workspaces": 50,
|
| 295 |
+
"distinct_hidden_sets": 50
|
| 296 |
+
},
|
| 297 |
+
{
|
| 298 |
+
"task_id": "expression-2",
|
| 299 |
+
"episodes": 50,
|
| 300 |
+
"oracle_reward": 1.0,
|
| 301 |
+
"starter_reward_min": 0.3390804597701149,
|
| 302 |
+
"starter_reward_max": 0.6666666666666666,
|
| 303 |
+
"starter_reward_mean": 0.47011494252873565,
|
| 304 |
+
"single_mutations_detected": 100,
|
| 305 |
+
"single_mutation_reward_min": 0.5057471264367815,
|
| 306 |
+
"single_mutation_reward_max": 0.8333333333333334,
|
| 307 |
+
"distinct_workspaces": 50,
|
| 308 |
+
"distinct_hidden_sets": 50
|
| 309 |
+
},
|
| 310 |
+
{
|
| 311 |
+
"task_id": "expression-3",
|
| 312 |
+
"episodes": 50,
|
| 313 |
+
"oracle_reward": 1.0,
|
| 314 |
+
"starter_reward_min": 0.1724137931034483,
|
| 315 |
+
"starter_reward_max": 0.22413793103448276,
|
| 316 |
+
"starter_reward_mean": 0.19724137931034483,
|
| 317 |
+
"single_mutations_detected": 150,
|
| 318 |
+
"single_mutation_reward_min": 0.5057471264367815,
|
| 319 |
+
"single_mutation_reward_max": 0.8333333333333334,
|
| 320 |
+
"distinct_workspaces": 50,
|
| 321 |
+
"distinct_hidden_sets": 50
|
| 322 |
+
}
|
| 323 |
+
]
|
| 324 |
+
}
|
v3/replay.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Replay oracle, starters and every single-defect ablation on fresh seeds."""
|
| 2 |
+
import argparse
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import statistics
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from execution import grade
|
| 8 |
+
from tasks import TASK_IDS, make_task
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def replay(count,start):
|
| 12 |
+
rows=[]
|
| 13 |
+
for task_id in TASK_IDS:
|
| 14 |
+
floors=[]
|
| 15 |
+
partials=[]
|
| 16 |
+
workspace_hashes=set()
|
| 17 |
+
case_hashes=set()
|
| 18 |
+
for seed in range(start,start+count):
|
| 19 |
+
task=make_task(task_id,seed)
|
| 20 |
+
oracle=grade(task.solution,task.hidden)
|
| 21 |
+
assert oracle['reward']==1,(task_id,seed,'oracle',oracle)
|
| 22 |
+
floor=grade(task.starter,task.hidden)
|
| 23 |
+
assert 0<=floor['reward']<1,(task_id,seed,'floor',floor)
|
| 24 |
+
floors.append(floor['reward'])
|
| 25 |
+
# Keep exactly one remaining defect at a time, not just the original bundle.
|
| 26 |
+
for path in task.mutations:
|
| 27 |
+
single=dict(task.solution,**{path:task.starter[path]})
|
| 28 |
+
result=grade(single,task.hidden)
|
| 29 |
+
assert result['reward']<1,(task_id,seed,'single undetected',path,result)
|
| 30 |
+
partials.append(result['reward'])
|
| 31 |
+
workspace_hashes.add(hashlib.sha256(json.dumps(task.starter,sort_keys=True).encode()).hexdigest())
|
| 32 |
+
case_hashes.add(hashlib.sha256(json.dumps(task.hidden,sort_keys=True).encode()).hexdigest())
|
| 33 |
+
row={'task_id':task_id,'episodes':count,'oracle_reward':1.0,'starter_reward_min':min(floors),
|
| 34 |
+
'starter_reward_max':max(floors),'starter_reward_mean':statistics.mean(floors),
|
| 35 |
+
'single_mutations_detected':len(partials),'single_mutation_reward_min':min(partials),
|
| 36 |
+
'single_mutation_reward_max':max(partials),'distinct_workspaces':len(workspace_hashes),
|
| 37 |
+
'distinct_hidden_sets':len(case_hashes)}
|
| 38 |
+
rows.append(row)
|
| 39 |
+
print(json.dumps(row),flush=True)
|
| 40 |
+
return {'seed_start':start,'seeds_per_task':count,'task_ids':len(TASK_IDS),
|
| 41 |
+
'episodes':count*len(TASK_IDS),'all_oracles_perfect':True,'all_starters_imperfect':True,
|
| 42 |
+
'all_single_defects_detected':True,'model_rollouts':0,'rows':rows}
|
| 43 |
+
|
| 44 |
+
if __name__=='__main__':
|
| 45 |
+
parser=argparse.ArgumentParser()
|
| 46 |
+
parser.add_argument('--seeds',type=int,default=50)
|
| 47 |
+
parser.add_argument('--start',type=int,default=1000)
|
| 48 |
+
parser.add_argument('--output',default='replay-results.json')
|
| 49 |
+
args=parser.parse_args()
|
| 50 |
+
assert args.seeds>0
|
| 51 |
+
result=replay(args.seeds,args.start)
|
| 52 |
+
Path(args.output).write_text(json.dumps(result,indent=2)+'\n')
|
v3/requirements-calibration.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-r requirements.txt
|
| 2 |
+
Jinja2>=3.1,<4
|
v3/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
openenv @ git+https://github.com/meta-pytorch/OpenEnv.git@86a180ede21e044f7929b9a7783ad83aa67d83a3
|
v3/server.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Python Repair Lab v3: generated multi-file debugging, OpenEnv pinned SDK."""
|
| 2 |
+
import json
|
| 3 |
+
from typing import Literal
|
| 4 |
+
from uuid import uuid4
|
| 5 |
+
|
| 6 |
+
from openenv.core.env_server.http_server import create_app
|
| 7 |
+
from openenv.core.env_server.interfaces import Environment
|
| 8 |
+
from openenv.core.env_server.types import Action, Observation, State
|
| 9 |
+
from pydantic import Field
|
| 10 |
+
|
| 11 |
+
from tasks import TASK_IDS, make_task
|
| 12 |
+
from execution import grade, validate
|
| 13 |
+
|
| 14 |
+
MAX_STEPS = 30
|
| 15 |
+
|
| 16 |
+
class RepairAction(Action):
|
| 17 |
+
operation: Literal['read','write','test','submit'] = Field(description='read returns a workspace file; write replaces one module; test runs visible examples; submit grades hidden cases and ends.')
|
| 18 |
+
path: str = Field(default='',max_length=80,description='Observed flat Python filename for read/write. No paths, new files or changes to settings.py.')
|
| 19 |
+
code: str = Field(default='',max_length=16000,description='Full replacement module for write. Allowed: local imports, csv.DictReader/reader, io.StringIO, fractions.Fraction and ordinary builtins/methods. No private attributes, filesystem, network, process or dynamic execution.')
|
| 20 |
+
|
| 21 |
+
class RepairObservation(Observation):
|
| 22 |
+
task_id: str = ''
|
| 23 |
+
message: str = ''
|
| 24 |
+
files: dict[str,str] = Field(default_factory=dict)
|
| 25 |
+
steps_left: int = MAX_STEPS
|
| 26 |
+
|
| 27 |
+
class RepairEnvironment(Environment):
|
| 28 |
+
SUPPORTS_CONCURRENT_SESSIONS = True
|
| 29 |
+
|
| 30 |
+
def __init__(self):
|
| 31 |
+
self._state = State(episode_id=str(uuid4()),step_count=0)
|
| 32 |
+
self.task = None
|
| 33 |
+
self.files = {}
|
| 34 |
+
self.ended = False
|
| 35 |
+
self.last_reward = 0.0
|
| 36 |
+
|
| 37 |
+
@property
|
| 38 |
+
def state(self):
|
| 39 |
+
return self._state
|
| 40 |
+
|
| 41 |
+
def reset(self, seed=None, task_id=None, **kwargs):
|
| 42 |
+
seed = 0 if seed is None else seed
|
| 43 |
+
if task_id is None:
|
| 44 |
+
task_id = TASK_IDS[seed % len(TASK_IDS)]
|
| 45 |
+
self.task = make_task(task_id,seed)
|
| 46 |
+
self.files = dict(self.task.starter)
|
| 47 |
+
self.ended = False
|
| 48 |
+
self.last_reward = 0.0
|
| 49 |
+
self._state = State(episode_id=str(uuid4()),step_count=0)
|
| 50 |
+
return RepairObservation(task_id=task_id,message=self.task.prompt+'\nPublic examples: '+json.dumps(self.task.visible),files=dict(self.files),reward=0.0,done=False)
|
| 51 |
+
|
| 52 |
+
def step(self,action,**kwargs):
|
| 53 |
+
if self.task is None:
|
| 54 |
+
self.reset()
|
| 55 |
+
if self.ended:
|
| 56 |
+
return RepairObservation(task_id=self.task.task_id,message='Episode ended.',done=True,reward=self.last_reward,steps_left=0)
|
| 57 |
+
self._state.step_count += 1
|
| 58 |
+
message, files = '', {}
|
| 59 |
+
if action.operation == 'read':
|
| 60 |
+
if action.path in self.files:
|
| 61 |
+
files[action.path] = self.files[action.path]
|
| 62 |
+
message = 'File contents.'
|
| 63 |
+
else:
|
| 64 |
+
message = 'Unknown file.'
|
| 65 |
+
elif action.operation == 'write':
|
| 66 |
+
if action.path not in self.files or action.path=='settings.py':
|
| 67 |
+
message = 'Unknown or read-only file. Source unchanged.'
|
| 68 |
+
else:
|
| 69 |
+
candidate = dict(self.files, **{action.path:action.code})
|
| 70 |
+
try:
|
| 71 |
+
validate(candidate)
|
| 72 |
+
self.files = candidate
|
| 73 |
+
message = 'Module replaced. Use test or submit.'
|
| 74 |
+
except (SyntaxError,ValueError,RecursionError) as error:
|
| 75 |
+
message = 'Rejected; source unchanged: '+str(error)[:180]
|
| 76 |
+
elif action.operation == 'test':
|
| 77 |
+
message = json.dumps(grade(self.files,self.task.visible,feedback=True))
|
| 78 |
+
self.ended = action.operation=='submit' or self._state.step_count>=MAX_STEPS
|
| 79 |
+
if self.ended:
|
| 80 |
+
result = grade(self.files,self.task.hidden)
|
| 81 |
+
self.last_reward = result['reward']
|
| 82 |
+
message = json.dumps(result)
|
| 83 |
+
return RepairObservation(task_id=self.task.task_id,message=message,files=files,done=self.ended,reward=self.last_reward if self.ended else 0.0,steps_left=max(0,MAX_STEPS-self._state.step_count))
|
| 84 |
+
|
| 85 |
+
app = create_app(RepairEnvironment,RepairAction,RepairObservation,env_name='python_repair_lab_v3',max_concurrent_envs=5)
|
v3/tasks.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9715cdabe6e67287399a3fe2bad435852510bf854982d2f6695b3d87db395c88
|
| 3 |
+
size 87084
|
v3/tasks.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Original seeded multi-module repair tasks; references never enter candidate execution."""
|
| 2 |
+
import copy
|
| 3 |
+
import csv
|
| 4 |
+
import io
|
| 5 |
+
import random
|
| 6 |
+
from dataclasses import dataclass
|
| 7 |
+
from fractions import Fraction
|
| 8 |
+
from hard_tasks import HARD_SPECS, allocation_ref, expression_ref, hard_cases
|
| 9 |
+
|
| 10 |
+
FAMILIES = ('ledger', 'capacity', 'workflow', 'incident', 'sensor', 'reconcile', 'allocation', 'expression')
|
| 11 |
+
TASK_IDS = tuple(f'{f}-{level}' for f in FAMILIES for level in (1, 2, 3))
|
| 12 |
+
|
| 13 |
+
@dataclass
|
| 14 |
+
class Task:
|
| 15 |
+
task_id: str
|
| 16 |
+
seed: int
|
| 17 |
+
prompt: str
|
| 18 |
+
starter: dict
|
| 19 |
+
solution: dict
|
| 20 |
+
visible: list
|
| 21 |
+
hidden: list
|
| 22 |
+
mutations: list
|
| 23 |
+
|
| 24 |
+
def ledger_ref(events, fee):
|
| 25 |
+
lots, pnl, missing = {}, 0, 0
|
| 26 |
+
for e in events:
|
| 27 |
+
key = (e['account'], e['asset'])
|
| 28 |
+
queue = lots.setdefault(key, [])
|
| 29 |
+
if e['side'] == 'buy':
|
| 30 |
+
queue.extend([e['price']] * e['qty'])
|
| 31 |
+
else:
|
| 32 |
+
amount = min(e['qty'], len(queue))
|
| 33 |
+
pnl += sum(e['price'] - p - fee for p in queue[:amount])
|
| 34 |
+
del queue[:amount]
|
| 35 |
+
missing += e['qty'] - amount
|
| 36 |
+
return {'pnl': pnl, 'unfilled': missing, 'positions': [
|
| 37 |
+
[a, s, len(q), sum(q)] for (a, s), q in sorted(lots.items()) if q]}
|
| 38 |
+
|
| 39 |
+
def capacity_ref(bookings, limit):
|
| 40 |
+
# Independent interval scan, not the submitted endpoint sweep.
|
| 41 |
+
boundaries = sorted({x for a, b, weight in bookings for x in (a, b) if a < b and weight > 0})
|
| 42 |
+
segments, peak, area = [], 0, 0
|
| 43 |
+
for a, b in zip(boundaries, boundaries[1:]):
|
| 44 |
+
load = sum(w for s, e, w in bookings if s <= a < e and w > 0)
|
| 45 |
+
peak = max(peak, load)
|
| 46 |
+
area += max(0, load - limit) * (b - a)
|
| 47 |
+
if load > limit:
|
| 48 |
+
if segments and segments[-1][1] == a:
|
| 49 |
+
segments[-1][1] = b
|
| 50 |
+
else:
|
| 51 |
+
segments.append([a, b])
|
| 52 |
+
return {'peak': peak, 'overload': segments, 'excess_area': area}
|
| 53 |
+
|
| 54 |
+
def workflow_ref(jobs):
|
| 55 |
+
lookup = {j['id']: j for j in jobs}
|
| 56 |
+
finish, visiting = {}, set()
|
| 57 |
+
def visit(name):
|
| 58 |
+
if name not in lookup or name in visiting:
|
| 59 |
+
raise ValueError('invalid dependencies')
|
| 60 |
+
if name not in finish:
|
| 61 |
+
visiting.add(name)
|
| 62 |
+
j = lookup[name]
|
| 63 |
+
finish[name] = j['duration'] + max([j['release']] + [visit(d) for d in j['deps']])
|
| 64 |
+
visiting.remove(name)
|
| 65 |
+
return finish[name]
|
| 66 |
+
try:
|
| 67 |
+
for j in jobs:
|
| 68 |
+
visit(j['id'])
|
| 69 |
+
return {'status': 'ok', 'finish': [[n, finish[n]] for n in sorted(finish)],
|
| 70 |
+
'late': sorted(j['id'] for j in jobs if finish[j['id']] > j['deadline'])}
|
| 71 |
+
except ValueError:
|
| 72 |
+
return {'status': 'invalid', 'finish': [], 'late': []}
|
| 73 |
+
|
| 74 |
+
def incident_ref(events, window, threshold):
|
| 75 |
+
ordered = sorted(enumerate(events), key=lambda x: (x[1]['time'], x[0]))
|
| 76 |
+
history, seen, alerts = {}, set(), []
|
| 77 |
+
for _, e in ordered:
|
| 78 |
+
if e['id'] in seen:
|
| 79 |
+
continue
|
| 80 |
+
seen.add(e['id'])
|
| 81 |
+
key = (e['user'], e['ip'])
|
| 82 |
+
if e['outcome'] == 'success':
|
| 83 |
+
history.pop(key, None)
|
| 84 |
+
continue
|
| 85 |
+
prior = [t for t in history.get(key, []) if e['time'] - window <= t]
|
| 86 |
+
history[key] = prior + [e['time']]
|
| 87 |
+
if len(prior) < threshold <= len(prior) + 1:
|
| 88 |
+
alerts.append([e['user'], e['ip'], e['time']])
|
| 89 |
+
return alerts
|
| 90 |
+
|
| 91 |
+
def sensor_ref(readings, calibrations, threshold):
|
| 92 |
+
converted = {}
|
| 93 |
+
for r in readings:
|
| 94 |
+
if r['valid']:
|
| 95 |
+
gain, offset = calibrations[r['sensor']]
|
| 96 |
+
converted[(r['sensor'], r['time'])] = gain * r['value'] + offset
|
| 97 |
+
groups = {}
|
| 98 |
+
for (_, time), value in converted.items():
|
| 99 |
+
groups.setdefault(time, []).append(value)
|
| 100 |
+
result = []
|
| 101 |
+
for time, values in sorted(groups.items()):
|
| 102 |
+
ordered = sorted(values)
|
| 103 |
+
n = len(ordered)
|
| 104 |
+
mid = Fraction(ordered[n // 2]) if n % 2 else Fraction(ordered[n//2-1] + ordered[n//2], 2)
|
| 105 |
+
result.append([time, float(mid), mid > threshold])
|
| 106 |
+
return result
|
| 107 |
+
|
| 108 |
+
def reconcile_ref(left, right):
|
| 109 |
+
totals = [{}, {}]
|
| 110 |
+
for side, text in enumerate((left, right)):
|
| 111 |
+
for row in csv.DictReader(io.StringIO(text)):
|
| 112 |
+
key = row['key'].strip().casefold()
|
| 113 |
+
value = Fraction(row['amount'])
|
| 114 |
+
if row['kind'] == 'credit':
|
| 115 |
+
value = -value
|
| 116 |
+
totals[side][key] = totals[side].get(key, Fraction(0)) + value
|
| 117 |
+
return [[key, str(totals[0].get(key, Fraction(0)) - totals[1].get(key, Fraction(0)))]
|
| 118 |
+
for key in sorted(totals[0].keys() | totals[1].keys())
|
| 119 |
+
if totals[0].get(key, Fraction(0)) != totals[1].get(key, Fraction(0))]
|
| 120 |
+
|
| 121 |
+
REFERENCES = dict(zip(FAMILIES, (ledger_ref, capacity_ref, workflow_ref, incident_ref, sensor_ref, reconcile_ref)))
|
| 122 |
+
|
| 123 |
+
# Each defect is in a distinct module and has a targeted verifier group.
|
| 124 |
+
SPECS = {
|
| 125 |
+
'ledger': (
|
| 126 |
+
'solve(events): FIFO accounting in input order. Each event has account, asset, side (buy/sell), qty (positive integer), price (integer cents). Separate lots by (account,asset). Sell only available units, do not create shorts. Deduct FEE cents per filled sold unit. Return pnl, unfilled (total requested units lacking stock), and sorted nonempty positions [account,asset,qty,cost_basis]. Do not mutate input.',
|
| 127 |
+
{
|
| 128 |
+
'identity.py': "def key(e):\n return (e['account'], e['asset'])\n",
|
| 129 |
+
'lots.py': "def consume(queue, qty):\n used = min(qty, sum(n for n, p in queue))\n remaining, cost = used, 0\n while remaining:\n n, p = queue[0]\n take = min(n, remaining)\n cost += take * p\n remaining -= take\n if take == n:\n queue.pop(0)\n else:\n queue[0] = (n - take, p)\n return used, cost\n",
|
| 130 |
+
'charges.py': "from settings import FEE\ndef profit(qty, price, cost):\n return qty * (price - FEE) - cost\n",
|
| 131 |
+
'main.py': "from identity import key\nfrom lots import consume\nfrom charges import profit\ndef solve(events):\n lots, pnl, unfilled = {}, 0, 0\n for e in events:\n k = key(e)\n q = lots.setdefault(k, [])\n if e['side'] == 'buy':\n q.append((e['qty'], e['price']))\n else:\n used, cost = consume(q, e['qty'])\n pnl += profit(used, e['price'], cost)\n unfilled += e['qty'] - used\n return {'pnl': pnl, 'unfilled': unfilled, 'positions': [[a, s, sum(n for n, p in q), sum(n*p for n,p in q)] for (a,s),q in sorted(lots.items()) if q]}\n",
|
| 132 |
+
}, [('identity.py', "(e['account'], e['asset'])", "(e['asset'], e['asset'])"),
|
| 133 |
+
('lots.py', 'queue[0]', 'queue[-1]'),
|
| 134 |
+
('charges.py', 'qty * (price - FEE) - cost', 'qty * price - FEE - cost')]),
|
| 135 |
+
'capacity': (
|
| 136 |
+
'solve(bookings): each [start,end,weight] is a half-open integer-time weighted reservation. Ignore zero-length and nonpositive-weight entries. Return peak load, merged maximal overload intervals where load > LIMIT, and integral of max(load-LIMIT,0) over time as excess_area. Touching overload intervals must merge. Input unchanged.',
|
| 137 |
+
{
|
| 138 |
+
'events.py': "def endpoints(bookings):\n delta = {}\n for a,b,w in bookings:\n if a < b and w > 0:\n delta[a] = delta.get(a, 0) + w\n delta[b] = delta.get(b, 0) - w\n return sorted(delta.items())\n",
|
| 139 |
+
'rules.py': "from settings import LIMIT\ndef overloaded(load):\n return load > LIMIT\ndef excess(load):\n return max(0, load - LIMIT)\n",
|
| 140 |
+
'merge.py': "def append_span(spans, a, b):\n if spans and spans[-1][1] == a:\n spans[-1][1] = b\n else:\n spans.append([a,b])\n",
|
| 141 |
+
'main.py': "from events import endpoints\nfrom rules import overloaded, excess\nfrom merge import append_span\ndef solve(bookings):\n points = endpoints(bookings)\n load, peak, area, spans = 0, 0, 0, []\n for i in range(len(points)-1):\n a,delta = points[i]\n b = points[i+1][0]\n load += delta\n peak = max(peak, load)\n area += excess(load) * (b-a)\n if overloaded(load):\n append_span(spans, a, b)\n return {'peak': peak, 'overload': spans, 'excess_area': area}\n",
|
| 142 |
+
}, [('events.py', 'delta.get(b, 0) - w', 'delta.get(b, 0) + w'),
|
| 143 |
+
('rules.py', 'load > LIMIT', 'load >= LIMIT'),
|
| 144 |
+
('merge.py', 'spans[-1][1] == a', 'spans[-1][1] > a')]),
|
| 145 |
+
'workflow': (
|
| 146 |
+
'solve(jobs): jobs have unique id, duration>=0, release>=0, deadline, deps (job IDs). Unlimited parallel workers. Start each job at max(release, predecessor finish times), then add duration. Return status=ok, sorted finish pairs and IDs with finish strictly greater than deadline as late. Missing dependencies or any cycle make the whole graph invalid: status=invalid, finish=[], late=[]. Jobs are arbitrarily ordered; do not mutate them.',
|
| 147 |
+
{
|
| 148 |
+
'graph.py': "def ready(job, pending, finished):\n return all(d in finished for d in job['deps'])\n",
|
| 149 |
+
'timing.py': "def end_time(job, finished):\n return max([job['release']] + [finished[d] for d in job['deps']]) + job['duration']\n",
|
| 150 |
+
'report.py': "def report(jobs, finished):\n return {'status': 'ok', 'finish': [[n,finished[n]] for n in sorted(finished)], 'late': sorted(j['id'] for j in jobs if finished[j['id']] > j['deadline'])}\n",
|
| 151 |
+
'main.py': "from graph import ready\nfrom timing import end_time\nfrom report import report\ndef solve(jobs):\n pending = {j['id']:j for j in jobs}\n finished = {}\n while pending:\n progress = False\n for name,job in list(pending.items()):\n if ready(job, pending, finished):\n finished[name] = end_time(job, finished)\n del pending[name]\n progress = True\n if not progress:\n return {'status':'invalid','finish':[],'late':[]}\n return report(jobs, finished)\n",
|
| 152 |
+
}, [('graph.py', "all(d in finished for d in job['deps'])", "all(d not in pending for d in job['deps'])"),
|
| 153 |
+
('timing.py', "max([job['release']] + [finished[d] for d in job['deps']])", "job['release'] + sum(finished[d] for d in job['deps'])"),
|
| 154 |
+
('report.py', "> j['deadline']", ">= j['deadline']")]),
|
| 155 |
+
'incident': (
|
| 156 |
+
'solve(events): process events by (time, original index), preserving ties. Global event id deduplication keeps the first in that sorted order. Group failures by (user,ip). At each failure retain times in inclusive [time-WINDOW,time]. Alert [user,ip,time] only on a crossing from fewer than THRESHOLD failures to at least THRESHOLD. A success clears that pair only. Return alerts in processing order, without mutating events.',
|
| 157 |
+
{
|
| 158 |
+
'order.py': "def ordered(events):\n return sorted(enumerate(events), key=lambda x: (x[1]['time'], x[0]))\n",
|
| 159 |
+
'window.py': "from settings import WINDOW\ndef trim(times, now):\n return [t for t in times if t >= now - WINDOW]\n",
|
| 160 |
+
'resetter.py': "def reset(history, key):\n history.pop(key, None)\n",
|
| 161 |
+
'main.py': "from settings import THRESHOLD\nfrom order import ordered\nfrom window import trim\nfrom resetter import reset\ndef solve(events):\n history, seen, alerts = {}, set(), []\n for idx,e in ordered(events):\n if e['id'] in seen:\n continue\n seen.add(e['id'])\n k = (e['user'],e['ip'])\n if e['outcome'] == 'success':\n reset(history,k)\n else:\n prior = trim(history.get(k,[]),e['time'])\n history[k] = prior + [e['time']]\n if len(prior) < THRESHOLD <= len(prior)+1:\n alerts.append([e['user'],e['ip'],e['time']])\n return alerts\n",
|
| 162 |
+
}, [('order.py', "(x[1]['time'], x[0])", "(x[1]['time'], -x[0])"),
|
| 163 |
+
('window.py', 't >= now - WINDOW', 't > now - WINDOW'),
|
| 164 |
+
('resetter.py', 'history.pop(key, None)', 'history.clear()')]),
|
| 165 |
+
'sensor': (
|
| 166 |
+
'solve(readings): readings have sensor, time, value (integer), valid (bool). Ignore invalid readings; for duplicate (sensor,time), keep the last valid occurrence in input order. Convert each retained value with CALIBRATIONS[sensor]=[gain,offset] as gain*value+offset BEFORE aggregation. Return sorted [time,median,alarm] rows; even-count median averages the middle two; alarm is median strictly > THRESHOLD. Inputs unchanged.',
|
| 167 |
+
{
|
| 168 |
+
'dedup.py': "def latest(readings):\n kept = {}\n for r in readings:\n if r['valid']:\n kept[(r['sensor'],r['time'])] = r\n return list(kept.values())\n",
|
| 169 |
+
'convert.py': "from settings import CALIBRATIONS\ndef convert(r):\n gain,offset = CALIBRATIONS[r['sensor']]\n return gain*r['value']+offset\n",
|
| 170 |
+
'stats.py': "def median(values):\n v = sorted(values)\n n = len(v)\n return v[n//2] if n%2 else (v[n//2-1]+v[n//2])/2\n",
|
| 171 |
+
'main.py': "from settings import THRESHOLD\nfrom dedup import latest\nfrom convert import convert\nfrom stats import median\ndef solve(readings):\n groups = {}\n for r in latest(readings):\n groups.setdefault(r['time'],[]).append(convert(r))\n return [[t, median(v), median(v)>THRESHOLD] for t,v in sorted(groups.items())]\n",
|
| 172 |
+
}, [('dedup.py', "kept[(r['sensor'],r['time'])] = r", "kept.setdefault((r['sensor'],r['time']), r)"),
|
| 173 |
+
('convert.py', "gain*r['value']+offset", "gain*(r['value']+offset)"),
|
| 174 |
+
('stats.py', '(v[n//2-1]+v[n//2])/2', 'v[n//2]')]),
|
| 175 |
+
'reconcile': (
|
| 176 |
+
'solve(left,right): two CSV strings with header key,amount,kind. CSV quoting follows Python csv rules. Normalize keys using strip().casefold(). Amount is a finite decimal string, kind is debit or credit; credits negate the amount. Sum duplicates separately in each file using exact arithmetic. Return sorted [key,delta] for nonzero left-minus-right differences. delta MUST be canonical Fraction string (integer if denominator=1, otherwise numerator/denominator), not decimal or float.',
|
| 177 |
+
{
|
| 178 |
+
'parse.py': "import csv\nimport io\ndef rows(text):\n return list(csv.DictReader(io.StringIO(text)))\n",
|
| 179 |
+
'keys.py': "def key(row):\n return row['key'].strip().casefold()\n",
|
| 180 |
+
'amounts.py': "from fractions import Fraction\ndef amount(row):\n value = Fraction(row['amount'])\n return -value if row['kind']=='credit' else value\n",
|
| 181 |
+
'main.py': "from fractions import Fraction\nfrom parse import rows\nfrom keys import key\nfrom amounts import amount\ndef totals(text):\n out = {}\n for row in rows(text):\n k = key(row)\n out[k] = out.get(k,Fraction(0)) + amount(row)\n return out\ndef solve(left,right):\n a,b = totals(left),totals(right)\n return [[k,str(a.get(k,Fraction(0))-b.get(k,Fraction(0)))] for k in sorted(set(a)|set(b)) if a.get(k,Fraction(0))!=b.get(k,Fraction(0))]\n",
|
| 182 |
+
}, [('parse.py', 'list(csv.DictReader(io.StringIO(text)))', "[dict(zip(['key','amount','kind'],line.split(','))) for line in text.splitlines()[1:]]"),
|
| 183 |
+
('keys.py', ".strip().casefold()", ".strip().lower()"),
|
| 184 |
+
('amounts.py', "-value if row['kind']=='credit' else value", 'value')]),
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
def csv_text(rows):
|
| 188 |
+
f = io.StringIO()
|
| 189 |
+
w = csv.writer(f)
|
| 190 |
+
w.writerow(['key','amount','kind'])
|
| 191 |
+
w.writerows(rows)
|
| 192 |
+
return f.getvalue()
|
| 193 |
+
|
| 194 |
+
def cases(family, rng, config):
|
| 195 |
+
"""Targeted edge groups plus compositional random tests; no private benchmark data."""
|
| 196 |
+
out = []
|
| 197 |
+
def add(group, *args):
|
| 198 |
+
out.append({'group': group, 'args': list(args)})
|
| 199 |
+
if family == 'ledger':
|
| 200 |
+
def event(a, s, side, n, p):
|
| 201 |
+
return dict(account=a,asset=s,side=side,qty=n,price=p)
|
| 202 |
+
add('empty', [])
|
| 203 |
+
add('identity', [event('a','x','buy',3,100),event('b','x','sell',2,150)])
|
| 204 |
+
add('fifo', [event('a','x','buy',2,10),event('a','x','buy',3,30),event('a','x','sell',3,45)])
|
| 205 |
+
add('fee', [event('a','x','buy',4,7),event('a','x','sell',4,12)])
|
| 206 |
+
add('shortfall', [event('a','x','buy',1,10),event('a','x','sell',5,30)])
|
| 207 |
+
for i in range(30):
|
| 208 |
+
add('random', [event(rng.choice('abc'),rng.choice('xyz'),rng.choice(['buy','sell']),rng.randint(1,6),rng.randint(1,250)) for _ in range(rng.randint(4,30))])
|
| 209 |
+
elif family == 'capacity':
|
| 210 |
+
limit = config['LIMIT']
|
| 211 |
+
add('empty', [])
|
| 212 |
+
add('half_open', [[0,4,limit],[4,7,limit]])
|
| 213 |
+
add('strict', [[0,5,limit]])
|
| 214 |
+
add('merge', [[0,3,limit+1],[3,6,limit+2]])
|
| 215 |
+
add('ignore', [[0,0,99],[1,5,0],[2,8,-3]])
|
| 216 |
+
for i in range(30):
|
| 217 |
+
values=[]
|
| 218 |
+
for j in range(rng.randint(2,15)):
|
| 219 |
+
a = rng.randint(-5,15)
|
| 220 |
+
values.append([a,a+rng.randint(0,10),rng.randint(-1,limit+4)])
|
| 221 |
+
add('random', values)
|
| 222 |
+
elif family == 'workflow':
|
| 223 |
+
def job(n, deps, duration=2, release=0, deadline=10):
|
| 224 |
+
return dict(id=n,deps=deps,duration=duration,release=release,deadline=deadline)
|
| 225 |
+
add('empty', [])
|
| 226 |
+
add('missing', [job('a',['absent'])])
|
| 227 |
+
add('cycle', [job('a',['b']),job('b',['a'])])
|
| 228 |
+
add('join', [job('c',['a','b'],3,4),job('b',[],5,2),job('a',[],2,1)])
|
| 229 |
+
add('deadline', [job('a',[],5,0,5)])
|
| 230 |
+
for i in range(30):
|
| 231 |
+
rows=[]
|
| 232 |
+
for j in range(rng.randint(3,12)):
|
| 233 |
+
rows.append(job(f'n{j}',[f'n{k}' for k in range(j) if rng.random()<.35],rng.randint(0,6),rng.randint(0,9),rng.randint(2,25)))
|
| 234 |
+
if i%7==0:
|
| 235 |
+
rows[0]['deps'] = [rows[-1]['id']]
|
| 236 |
+
rows[-1]['deps'].append(rows[0]['id'])
|
| 237 |
+
rng.shuffle(rows)
|
| 238 |
+
add('random', rows)
|
| 239 |
+
elif family == 'incident':
|
| 240 |
+
window, threshold = config['WINDOW'], config['THRESHOLD']
|
| 241 |
+
def event(i,t,u='u',ip='ip',outcome='failure'):
|
| 242 |
+
return dict(id=str(i),time=t,user=u,ip=ip,outcome=outcome)
|
| 243 |
+
add('empty', [])
|
| 244 |
+
add('boundary', [event(i,0 if i==0 else window) for i in range(threshold)])
|
| 245 |
+
add('ties', [event('s',0,outcome='success')]+[event(i,0) for i in range(threshold)]+[event(f'later{i}',1) for i in range(threshold)])
|
| 246 |
+
add('reset_scope', [event(i,0,'a') for i in range(threshold-1)]+[event('s',1,'b',outcome='success'),event('last',2,'a')])
|
| 247 |
+
add('dedup', [event('dup',0)]*threshold)
|
| 248 |
+
for i in range(30):
|
| 249 |
+
rows=[event(j,rng.randint(0,window*3),rng.choice('ab'),rng.choice(['ip1','ip2']),rng.choice(['failure']*5+['success'])) for j in range(45)]
|
| 250 |
+
rows.extend(copy.deepcopy(rows[:5]))
|
| 251 |
+
rng.shuffle(rows)
|
| 252 |
+
add('random', rows)
|
| 253 |
+
elif family == 'sensor':
|
| 254 |
+
names=list(config['CALIBRATIONS'])
|
| 255 |
+
def reading(s,t,v,valid=True):
|
| 256 |
+
return dict(sensor=s,time=t,value=v,valid=valid)
|
| 257 |
+
add('empty', [])
|
| 258 |
+
add('dedup', [reading(names[0],1,0),reading(names[0],1,9),reading(names[0],1,100,False)])
|
| 259 |
+
add('convert', [reading(names[1],2,3)])
|
| 260 |
+
add('median', [reading(names[0],3,0),reading(names[1],3,10)])
|
| 261 |
+
add('invalid', [reading(names[0],4,5,False)])
|
| 262 |
+
for i in range(30):
|
| 263 |
+
add('random', [reading(rng.choice(names),rng.randint(0,6),rng.randint(-10,20),rng.random()>.2) for _ in range(25)])
|
| 264 |
+
else:
|
| 265 |
+
add('empty', csv_text([]),csv_text([]))
|
| 266 |
+
add('quoting',csv_text([('a,b','1.25','debit'),('a\nline','2','debit')]),csv_text([]))
|
| 267 |
+
add('unicode',csv_text([(' Straße ','3','debit')]),csv_text([('STRASSE','3','debit')]))
|
| 268 |
+
add('sign',csv_text([('x','0.1','credit'),('x','0.2','debit')]),csv_text([('x','0.1','debit')]))
|
| 269 |
+
add('exact',csv_text([('x','0.1','debit'),('x','0.2','debit')]),csv_text([('x','0.3','debit')]))
|
| 270 |
+
keys = [' Alpha ','ALPHA','beta','Straße','STRASSE','a,b','a\nline','"quote"']
|
| 271 |
+
for i in range(30):
|
| 272 |
+
pair=[]
|
| 273 |
+
for side in range(2):
|
| 274 |
+
pair.append(csv_text([(rng.choice(keys),f'{rng.randint(-1000,1000)/100:.2f}',rng.choice(['debit','credit'])) for _ in range(rng.randint(1,20))]))
|
| 275 |
+
add('random',*pair)
|
| 276 |
+
return out
|
| 277 |
+
|
| 278 |
+
def make_task(task_id, seed=0):
|
| 279 |
+
if task_id not in TASK_IDS:
|
| 280 |
+
raise ValueError('Unknown task_id')
|
| 281 |
+
family, level_text = task_id.rsplit('-',1)
|
| 282 |
+
level = int(level_text)
|
| 283 |
+
rng = random.Random(f'v3/{task_id}/{seed}')
|
| 284 |
+
config = {'FEE':rng.randint(1,7), 'LIMIT':rng.randint(2,8), 'WINDOW':rng.randint(5,20),
|
| 285 |
+
'THRESHOLD':rng.randint(2,4), 'CALIBRATIONS':{'s0':[1,0],'s1':[rng.randint(2,4),rng.randint(1,5)],'s2':[-1,3]}}
|
| 286 |
+
instruction, modules, defects = (HARD_SPECS if family in HARD_SPECS else SPECS)[family]
|
| 287 |
+
solution = dict(modules)
|
| 288 |
+
# Rotating subsets avoid a fixed easy starter for the lower levels.
|
| 289 |
+
chosen = rng.sample(defects,level)
|
| 290 |
+
starter = dict(solution)
|
| 291 |
+
for path, before, after in chosen:
|
| 292 |
+
assert before in starter[path], (family,path,before)
|
| 293 |
+
starter[path] = starter[path].replace(before,after)
|
| 294 |
+
settings = '\n'.join(f'{k} = {v!r}' for k,v in config.items())+'\n'
|
| 295 |
+
starter['settings.py'] = solution['settings.py'] = settings
|
| 296 |
+
all_cases = hard_cases(family,rng) if family in HARD_SPECS else cases(family,rng,config)
|
| 297 |
+
if family=='ledger': extra=[config['FEE']]
|
| 298 |
+
elif family=='capacity': extra=[config['LIMIT']]
|
| 299 |
+
elif family=='incident': extra=[config['WINDOW'],config['THRESHOLD']]
|
| 300 |
+
elif family=='sensor': extra=[config['CALIBRATIONS'],config['THRESHOLD']]
|
| 301 |
+
else: extra=[]
|
| 302 |
+
for c in all_cases:
|
| 303 |
+
reference = {'allocation':allocation_ref,'expression':expression_ref}.get(family) or REFERENCES[family]
|
| 304 |
+
c['expected'] = reference(*copy.deepcopy(c['args']),*extra)
|
| 305 |
+
visible = [copy.deepcopy(all_cases[i]) for i in (0,1,len(all_cases)-1)]
|
| 306 |
+
# Disjoint random held-outs; edge groups may share semantic shapes, not random payloads.
|
| 307 |
+
hidden = all_cases[:-1]
|
| 308 |
+
prompt = instruction + '\nRuntime constants are in settings.py. There are multiple modules; main.solve is the entry point. Repair any necessary files. Imports may use these local modules or csv, io, fractions. No filesystem/network/process access. Use read/write/test/submit; test exposes only public examples; submit runs hidden checks. Maximum 30 actions. Fresh data and defect combinations depend on reset seed.'
|
| 309 |
+
return Task(task_id,seed,prompt,starter,solution,visible,hidden,[p for p,_,_ in chosen])
|
v3/test_calibrate.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
from calibrate import Ollama, decode, episode, summarize, run_probes
|
| 5 |
+
from tasks import make_task
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def test_strict_json_actions_and_wrapper():
|
| 9 |
+
assert decode('{"operation":"test"}').operation=='test'
|
| 10 |
+
assert decode('{"finish":true}').operation=='submit'
|
| 11 |
+
assert decode('{"action":{"operation":"submit"}}').operation=='submit'
|
| 12 |
+
for raw in ['```json\n{"operation":"test"}\n```','hello','[]','{}','{"operation":"unknown"}','{"finish":1}','{"finish":1,"extra":0}']:
|
| 13 |
+
with pytest.raises(ValueError): decode(raw)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def test_mock_transport_oracle_episode():
|
| 17 |
+
task=make_task('allocation-3',5000)
|
| 18 |
+
actions=[{'operation':'write','path':p,'code':task.solution[p]} for p in task.mutations]+[{'operation':'submit'}]
|
| 19 |
+
def generate(messages,budget):
|
| 20 |
+
assert 'hidden' not in messages[1]['content'] or 'hidden checks' in messages[1]['content']
|
| 21 |
+
return {'message':{'content':json.dumps(actions.pop(0))},'eval_count':50,'prompt_eval_count':1000}
|
| 22 |
+
result=episode(task.task_id,5000,generate)
|
| 23 |
+
assert result['reward']==1 and result['termination']=='terminal'
|
| 24 |
+
assert result['steps']==4 and result['model_tokens']==200
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def test_invalid_reply_still_grades_current_workspace():
|
| 28 |
+
def generate(messages,budget):
|
| 29 |
+
return {'message':{'content':'not JSON'},'eval_count':3}
|
| 30 |
+
result=episode('expression-3',3,generate)
|
| 31 |
+
assert result['done'] and result['reward']<1
|
| 32 |
+
assert result['termination']=='invalid_action'
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def test_summary_never_claims_training_improvement():
|
| 36 |
+
rows=[{'task_id':'allocation-3','seed':7,'reward':r,'termination':'terminal'} for r in (0,1,0.5,0.5)]
|
| 37 |
+
report=summarize(rows)
|
| 38 |
+
assert report['groups_with_mixed_rewards']==1
|
| 39 |
+
assert report['groups'][0]['variance']==0.125
|
| 40 |
+
assert report['proves_learning_gain'] is False and report['arena_score'] is None
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def test_runtime_failures_are_not_rewards(tmp_path, monkeypatch):
|
| 44 |
+
import io
|
| 45 |
+
import urllib.error
|
| 46 |
+
import calibrate
|
| 47 |
+
class MockModel:
|
| 48 |
+
random_seed=9000
|
| 49 |
+
def info(self): return {'model':'explicit-unit-test-mock'}
|
| 50 |
+
def generate(self, messages, budget): raise AssertionError('mocked episode should be used')
|
| 51 |
+
attempts=iter([urllib.error.HTTPError('http://localhost',500,'failure',{},io.BytesIO(b'backend failure')),
|
| 52 |
+
{'task_id':'incident-3','seed':7,'reward':1.0,'done':True,'steps':4,'termination':'terminal'}])
|
| 53 |
+
def fake_episode(*args):
|
| 54 |
+
value=next(attempts)
|
| 55 |
+
if isinstance(value,Exception): raise value
|
| 56 |
+
return value
|
| 57 |
+
monkeypatch.setattr(calibrate,'episode',fake_episode)
|
| 58 |
+
report=run_probes(MockModel(),['incident-3'],7,2,1.0,tmp_path/'report.json')
|
| 59 |
+
assert report['requested_episodes']==2 and report['summary']['episodes']==1
|
| 60 |
+
assert report['summary']['mean_reward']==1 and len(report['runtime_errors'])==1
|
| 61 |
+
assert report['runtime_errors'][0]['body']=='backend failure'
|
| 62 |
+
assert report['per_reply_token_cap']==1600
|
| 63 |
+
assert json.loads((tmp_path/'report.json').read_text())==report
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def test_all_runtime_failures_have_no_mean_reward(tmp_path, monkeypatch):
|
| 67 |
+
import urllib.error
|
| 68 |
+
import calibrate
|
| 69 |
+
class MockModel:
|
| 70 |
+
random_seed=9000
|
| 71 |
+
def info(self): return {'model':'explicit-unit-test-mock'}
|
| 72 |
+
def generate(self, messages, budget): raise AssertionError('mocked episode should be used')
|
| 73 |
+
def fake_episode(*args): raise urllib.error.URLError('local inference unavailable')
|
| 74 |
+
monkeypatch.setattr(calibrate,'episode',fake_episode)
|
| 75 |
+
report=run_probes(MockModel(),['incident-3'],7,2,1.0,tmp_path/'report.json')
|
| 76 |
+
assert report['summary']['episodes']==0 and report['summary']['mean_reward'] is None
|
| 77 |
+
assert len(report['runtime_errors'])==2 and not report['episodes']
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def test_paid_or_credentialled_endpoints_refused():
|
| 81 |
+
for url in ['https://api.example.com','http://user:secret@localhost:11434','http://localhost:11434?token=secret']:
|
| 82 |
+
with pytest.raises(ValueError): Ollama(url,'qwen3.8:27b',1,1)
|
v3/test_calibrate_raw.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from calibrate import decode
|
| 4 |
+
from calibrate_raw import RawOllama, renderer
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
MOCK_TEMPLATE='{{ messages[0].content }}:{{ enable_thinking }}:{{ add_generation_prompt }}'
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def test_raw_output_is_not_cleaned_or_json_constrained(monkeypatch):
|
| 11 |
+
model=RawOllama('http://localhost:11434','explicit-test-mock',1.0,3,MOCK_TEMPLATE)
|
| 12 |
+
raw='<tool_call>not a JSON action</tool_call>'
|
| 13 |
+
def request(path,payload):
|
| 14 |
+
assert path=='/api/generate' and payload['raw'] is True
|
| 15 |
+
assert payload['think'] is False and payload['prompt']=='spec:False:True'
|
| 16 |
+
assert 'format' not in payload and payload['options']['num_predict']==100
|
| 17 |
+
return {'response':raw,'eval_count':10}
|
| 18 |
+
monkeypatch.setattr(model,'request',request)
|
| 19 |
+
reply=model.generate([{'role':'system','content':'spec'}],100)
|
| 20 |
+
assert reply['message']['content']==raw and reply['eval_count']==10
|
| 21 |
+
with pytest.raises(ValueError): decode(reply['message']['content'])
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def test_raw_adapter_keeps_local_only_restriction():
|
| 25 |
+
with pytest.raises(ValueError):
|
| 26 |
+
RawOllama('https://remote.example','explicit-test-mock',1,3,MOCK_TEMPLATE)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def test_template_errors_are_not_suppressed():
|
| 30 |
+
with pytest.raises(ValueError,match='bad input'):
|
| 31 |
+
renderer("{{ raise_exception('bad input') }}").render()
|
v3/test_environment.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
from fastapi.testclient import TestClient
|
| 6 |
+
from execution import RUNNER, equal, grade, validate
|
| 7 |
+
from server import MAX_STEPS, RepairAction, RepairEnvironment, app
|
| 8 |
+
from tasks import TASK_IDS, make_task
|
| 9 |
+
|
| 10 |
+
@pytest.mark.parametrize('task_id',TASK_IDS)
|
| 11 |
+
def test_reference_floor_and_partial(task_id):
|
| 12 |
+
for seed in range(3):
|
| 13 |
+
task=make_task(task_id,seed)
|
| 14 |
+
assert grade(task.solution,task.hidden)['reward']==1, (task_id,seed)
|
| 15 |
+
floor=grade(task.starter,task.hidden)
|
| 16 |
+
assert floor['reward']<1, (task_id,seed,floor)
|
| 17 |
+
assert 0<=floor['reward']<=1
|
| 18 |
+
if len(task.mutations)>1:
|
| 19 |
+
fixed=dict(task.starter)
|
| 20 |
+
fixed[task.mutations[0]]=task.solution[task.mutations[0]]
|
| 21 |
+
result=grade(fixed,task.hidden)
|
| 22 |
+
assert result['reward']<1
|
| 23 |
+
|
| 24 |
+
@pytest.mark.parametrize('task_id',TASK_IDS)
|
| 25 |
+
def test_seeded_generation_and_terminal(task_id):
|
| 26 |
+
a,b=make_task(task_id,21),make_task(task_id,22)
|
| 27 |
+
assert a==make_task(task_id,21)
|
| 28 |
+
assert a.hidden!=b.hidden
|
| 29 |
+
assert len(a.starter)==5
|
| 30 |
+
assert len(a.mutations)==int(task_id[-1])
|
| 31 |
+
assert all(c not in a.hidden for c in a.visible[-1:])
|
| 32 |
+
env=RepairEnvironment()
|
| 33 |
+
initial=env.reset(task_id=task_id,seed=21)
|
| 34 |
+
assert initial.files==a.starter and not initial.done and initial.reward==0
|
| 35 |
+
assert 'mutations' not in initial.model_dump()
|
| 36 |
+
for path in a.mutations:
|
| 37 |
+
assert env.step(RepairAction(operation='write',path=path,code=a.solution[path])).reward==0
|
| 38 |
+
observation=env.step(RepairAction(operation='test'))
|
| 39 |
+
assert not observation.done
|
| 40 |
+
assert json.loads(observation.message)['reward']==1
|
| 41 |
+
result=env.step(RepairAction(operation='submit'))
|
| 42 |
+
assert result.done and result.reward==1
|
| 43 |
+
assert 'failures' not in json.loads(result.message)
|
| 44 |
+
steps=env.state.step_count
|
| 45 |
+
assert env.step(RepairAction(operation='submit')).reward==1
|
| 46 |
+
assert env.state.step_count==steps
|
| 47 |
+
|
| 48 |
+
@pytest.mark.parametrize('source',[
|
| 49 |
+
'import os\ndef solve(*args): return os.environ',
|
| 50 |
+
'from io import FileIO\ndef solve(*args): return list(FileIO("/app/tasks.py"))',
|
| 51 |
+
'import io\ndef solve(*args): return list(io.FileIO("/app/tasks.py"))',
|
| 52 |
+
'def solve(*args): return (1).__class__',
|
| 53 |
+
'def solve(*args): return globals()',
|
| 54 |
+
'def solve(*args): return eval("1")',
|
| 55 |
+
'def solve(*args): return __builtins__',
|
| 56 |
+
'def solve(*args): return open("/etc/passwd")',
|
| 57 |
+
'def solve(*args):\n g=(i for i in [1])\n return g.gi_frame.f_globals',
|
| 58 |
+
'from fractions import sys\ndef solve(*args): return sys.path',
|
| 59 |
+
'def solve(*args): return float("nan")',
|
| 60 |
+
'def solve(*args):\n while True: pass',
|
| 61 |
+
'def solve(*args): return "x" * 1000000',
|
| 62 |
+
'not python!!!',
|
| 63 |
+
])
|
| 64 |
+
def test_attack_and_resource_floor(source):
|
| 65 |
+
task=make_task('capacity-3',8)
|
| 66 |
+
files=dict(task.solution,**{'main.py':source})
|
| 67 |
+
assert grade(files,task.hidden)['reward']==0
|
| 68 |
+
|
| 69 |
+
def test_parent_owned_verifier_and_type_equality():
|
| 70 |
+
assert 'expected' not in RUNNER and 'reward' not in RUNNER
|
| 71 |
+
assert not equal(True,1)
|
| 72 |
+
assert not equal({'x':True},{'x':1})
|
| 73 |
+
assert not equal(float('inf'),1)
|
| 74 |
+
assert equal([1.0,{'x':2}],[1,{'x':2}])
|
| 75 |
+
assert not equal({'extra':0,'x':1},{'x':1})
|
| 76 |
+
task=make_task('capacity-3',3)
|
| 77 |
+
files=dict(task.solution,**{'main.py':'def solve(bookings):\n bookings.clear()\n return {"peak":0,"overload":[],"excess_area":0}\n'})
|
| 78 |
+
assert grade(files,task.hidden)['reward']<1
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def test_session_isolation_read_rejection_and_budget():
|
| 82 |
+
a,b=RepairEnvironment(),RepairEnvironment()
|
| 83 |
+
initial=a.reset(task_id='sensor-3',seed=4)
|
| 84 |
+
b.reset(task_id='sensor-3',seed=4)
|
| 85 |
+
task=make_task('sensor-3',4)
|
| 86 |
+
a.step(RepairAction(operation='write',path=task.mutations[0],code=task.solution[task.mutations[0]]))
|
| 87 |
+
assert a.files!=b.files
|
| 88 |
+
snapshot=copy.deepcopy(a.files)
|
| 89 |
+
for path,code in [('settings.py','FEE=0'),('../main.py','def solve(*args):return 1'),('main.py','invalid syntax!')]:
|
| 90 |
+
result=a.step(RepairAction(operation='write',path=path,code=code))
|
| 91 |
+
assert a.files==snapshot
|
| 92 |
+
read=a.step(RepairAction(operation='read',path='main.py'))
|
| 93 |
+
assert read.files=={'main.py':a.files['main.py']}
|
| 94 |
+
assert not a.step(RepairAction(operation='read',path='../../etc/passwd')).files
|
| 95 |
+
assert a.reset(task_id='sensor-3',seed=4).files==initial.files
|
| 96 |
+
for _ in range(MAX_STEPS):
|
| 97 |
+
result=b.step(RepairAction(operation='read',path='main.py'))
|
| 98 |
+
assert result.done and result.steps_left==0 and 0<=result.reward<1
|
| 99 |
+
assert b.state.step_count==MAX_STEPS
|
| 100 |
+
with pytest.raises(ValueError): a.reset(task_id='missing')
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def test_http_and_websocket_contract():
|
| 104 |
+
with TestClient(app) as client:
|
| 105 |
+
assert client.get('/health').status_code==200
|
| 106 |
+
schema=client.get('/schema').json()
|
| 107 |
+
assert schema['action']['properties']['operation']['enum']==['read','write','test','submit']
|
| 108 |
+
assert client.post('/reset',json={'task_id':'capacity-3','seed':8}).status_code==200
|
| 109 |
+
assert client.post('/step',json={'action':{'operation':'invalid'}}).status_code==422
|
| 110 |
+
with client.websocket_connect('/ws') as a,client.websocket_connect('/ws') as b:
|
| 111 |
+
for sock in (a,b):
|
| 112 |
+
sock.send_json({'type':'reset','data':{'task_id':'capacity-3','seed':8}})
|
| 113 |
+
result=sock.receive_json()
|
| 114 |
+
assert result['type']=='observation', result
|
| 115 |
+
task=make_task('capacity-3',8)
|
| 116 |
+
for path in task.mutations:
|
| 117 |
+
a.send_json({'type':'step','data':{'operation':'write','path':path,'code':task.solution[path]}})
|
| 118 |
+
assert a.receive_json()['type']=='observation'
|
| 119 |
+
a.send_json({'type':'step','data':{'operation':'submit'}})
|
| 120 |
+
assert a.receive_json()['data']['reward']==1
|
| 121 |
+
b.send_json({'type':'step','data':{'operation':'submit'}})
|
| 122 |
+
assert b.receive_json()['data']['reward']<1
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def test_imported_unchanged_functions_still_resolve():
|
| 126 |
+
task=make_task('reconcile-3',7)
|
| 127 |
+
assert grade(task.solution,task.visible,feedback=True)['reward']==1
|
| 128 |
+
# Modules load afresh per grade, not from previous candidate solutions.
|
| 129 |
+
assert grade(task.starter,task.visible)['reward']<1
|
v3/test_targeted.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Every designed defect must fail its intended edge group, not just random noise."""
|
| 2 |
+
import pytest
|
| 3 |
+
from execution import grade
|
| 4 |
+
from tasks import make_task
|
| 5 |
+
|
| 6 |
+
TARGETS=[
|
| 7 |
+
('ledger','identity.py','identity'),('ledger','lots.py','fifo'),('ledger','charges.py','fee'),
|
| 8 |
+
('capacity','events.py','half_open'),('capacity','rules.py','strict'),('capacity','merge.py','merge'),
|
| 9 |
+
('workflow','graph.py','missing'),('workflow','timing.py','join'),('workflow','report.py','deadline'),
|
| 10 |
+
('incident','order.py','ties'),('incident','window.py','boundary'),('incident','resetter.py','reset_scope'),
|
| 11 |
+
('sensor','dedup.py','dedup'),('sensor','convert.py','convert'),('sensor','stats.py','median'),
|
| 12 |
+
('reconcile','parse.py','quoting'),('reconcile','keys.py','unicode'),('reconcile','amounts.py','sign'),
|
| 13 |
+
('allocation','network.py','reroute'),('allocation','paths.py','reroute'),('allocation','augment.py','bottleneck'),
|
| 14 |
+
('expression','lex.py','literal'),('expression','binding.py','power'),('expression','unary.py','unary'),
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
@pytest.mark.parametrize('family,path,group',TARGETS)
|
| 18 |
+
def test_every_defect_has_deterministic_edge_witness(family,path,group):
|
| 19 |
+
for seed in range(3):
|
| 20 |
+
task=make_task(f'{family}-3',seed)
|
| 21 |
+
cases=[c for c in task.hidden if c['group']==group]
|
| 22 |
+
assert cases
|
| 23 |
+
assert grade(task.solution,cases)['reward']==1
|
| 24 |
+
single=dict(task.solution,**{path:task.starter[path]})
|
| 25 |
+
assert grade(single,cases)['reward']==0,(family,path,group,seed)
|
v3/validation-runtime.json
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"target": "http://127.0.0.1:8766",
|
| 3 |
+
"validation_type": "running_environment",
|
| 4 |
+
"standard_version": "1.0.0",
|
| 5 |
+
"standard_profile": "openenv-http/1.x",
|
| 6 |
+
"mode": "simulation",
|
| 7 |
+
"passed": true,
|
| 8 |
+
"summary": {
|
| 9 |
+
"passed_count": 6,
|
| 10 |
+
"total_count": 6,
|
| 11 |
+
"failed_criteria": [],
|
| 12 |
+
"required_passed_count": 6,
|
| 13 |
+
"required_total_count": 6
|
| 14 |
+
},
|
| 15 |
+
"criteria": [
|
| 16 |
+
{
|
| 17 |
+
"id": "openapi_version_available",
|
| 18 |
+
"description": "GET /openapi.json returns OpenAPI info.version",
|
| 19 |
+
"passed": true,
|
| 20 |
+
"required": true,
|
| 21 |
+
"expected": {
|
| 22 |
+
"status_code": 200,
|
| 23 |
+
"info.version": "string"
|
| 24 |
+
},
|
| 25 |
+
"actual": {
|
| 26 |
+
"status_code": 200,
|
| 27 |
+
"info.version": "1.0.0"
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"id": "health_endpoint",
|
| 32 |
+
"description": "GET /health returns healthy status",
|
| 33 |
+
"passed": true,
|
| 34 |
+
"required": true,
|
| 35 |
+
"expected": {
|
| 36 |
+
"status_code": 200,
|
| 37 |
+
"status": "healthy"
|
| 38 |
+
},
|
| 39 |
+
"actual": {
|
| 40 |
+
"status_code": 200,
|
| 41 |
+
"status": "healthy"
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"id": "metadata_endpoint",
|
| 46 |
+
"description": "GET /metadata returns name and description",
|
| 47 |
+
"passed": true,
|
| 48 |
+
"required": true,
|
| 49 |
+
"expected": {
|
| 50 |
+
"status_code": 200,
|
| 51 |
+
"fields": [
|
| 52 |
+
"name",
|
| 53 |
+
"description"
|
| 54 |
+
]
|
| 55 |
+
},
|
| 56 |
+
"actual": {
|
| 57 |
+
"status_code": 200,
|
| 58 |
+
"name": "RepairEnvironment",
|
| 59 |
+
"description": "RepairEnvironment environment"
|
| 60 |
+
}
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"id": "schema_endpoint",
|
| 64 |
+
"description": "GET /schema returns action, observation, and state schemas",
|
| 65 |
+
"passed": true,
|
| 66 |
+
"required": true,
|
| 67 |
+
"expected": {
|
| 68 |
+
"status_code": 200,
|
| 69 |
+
"fields": [
|
| 70 |
+
"action",
|
| 71 |
+
"observation",
|
| 72 |
+
"state"
|
| 73 |
+
]
|
| 74 |
+
},
|
| 75 |
+
"actual": {
|
| 76 |
+
"status_code": 200,
|
| 77 |
+
"has_action": true,
|
| 78 |
+
"has_observation": true,
|
| 79 |
+
"has_state": true
|
| 80 |
+
}
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"id": "mcp_endpoint",
|
| 84 |
+
"description": "POST /mcp is reachable and returns JSON-RPC payload",
|
| 85 |
+
"passed": true,
|
| 86 |
+
"required": true,
|
| 87 |
+
"expected": {
|
| 88 |
+
"status_code": 200,
|
| 89 |
+
"jsonrpc": "2.0"
|
| 90 |
+
},
|
| 91 |
+
"actual": {
|
| 92 |
+
"status_code": 200,
|
| 93 |
+
"jsonrpc": "2.0"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"id": "mode_endpoint_consistency",
|
| 98 |
+
"description": "OpenAPI endpoint set matches OpenEnv mode contract",
|
| 99 |
+
"passed": true,
|
| 100 |
+
"required": true,
|
| 101 |
+
"expected": {
|
| 102 |
+
"/reset": true,
|
| 103 |
+
"/step": true,
|
| 104 |
+
"/state": true
|
| 105 |
+
},
|
| 106 |
+
"actual": {
|
| 107 |
+
"/reset": true,
|
| 108 |
+
"/step": true,
|
| 109 |
+
"/state": true
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
]
|
| 113 |
+
}
|