Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-harness/patches/e508aba86e52be95 # omega-harness Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## Choose an AIEN coding swarm using bounded, auditable trials merged `e508aba86e52be95` #219 · opened 2026-11-08 12:10 UTC · closed 2026-11-08 12:54 UTC · merged 2026-11-08 12:54 UTC Imported from GitHub aien-dev/omega-harness#219, by drakestapleton Base `bd107ca15c40b6cdfef0f23afb03a884fe3c8086` · Head `0d2f1dd4b8f73cf1b27b99c65c35e8ae189ef21c` Merged on GitHub as `668e6adb3c6749e54a305a1144b09d2a11801300`; not reachable from main `f8561115745c6db7a1d7bc8bf5c0e89f228c503c` (observed 2026-11-18T16:39:27Z) drakestapleton wrote on 2026-11-08 12:10 UTC ## Evidence and outcome All 36 development trials reconciled. Independently accepted: OMP 2/12, Deep Agents 3/12, OpenHands 0/12. Neither replacement met the adoption criteria, so OMP remains the regular workflow. Five trials reached and passed independent acceptance; the other 31 stopped at conservative budget admission. Those are unfinished attempts, not measured source-code failures. The versioned report, sanitized outcomes, hashes and Wolfram arithmetic receipt are under `coder/swarm-pilot/evidence/`. ## Tracking issue DRA-498 , with execution, qualification, trial and output-hardening issues DRA-499 through DRA-502. The previous source provided ownership/matrix utilities and SDK probes, without qualified execution or a measured comparison. ## Implementation Add an experimental controller with one conductor, at most three nondelegating workers, exclusive claims, separate snapshots, isolated SDKs, offline Docker tools, durable recovery, cancellation, conservative aggregate token/deadline admission and atomic integration. Reuse OMP's authenticated gateway for existing subscription access. Provider credentials stay outside agents. Freeze six authored repository development tasks and run two repetitions across all three configured arms. Preserve raw failures and independently reconcile source/model/environment/judge/qualification identities before selecting. Candidate dependencies are isolated and locked. Export portable binary-capable patches without trusting worker Git metadata. Owned paths: `coder/swarm-pilot/` and the pointer in `coder/README.md`. Worker snapshots are exported workspaces; in-worker Git/PR lifecycles are outside this pilot. No native runtime, Atlas/Cortex, production service, account or repository-setting changes. ## Verification - `python -m unittest discover -s coder/swarm-pilot -p 'test_*.py'`: 35 focused checks pass. - `python coder/swarm-pilot/live_controls.py CONFIG OUTPUT`: seven real Docker boundaries pass. - `python coder/swarm-pilot/controls.py CONFIG FROZEN OUTPUT`: all six negative-start/positive-reference judge controls pass, including compiled/executed Omega. - `sh coder/swarm-pilot/verify-recovery.sh OUTPUT`: real abrupt-exit rollback, recovery, idempotent integration, snapshot preservation and persistent cancellation pass. - `python coder/swarm-pilot/audit.py CAMPAIGN`: all 36 runs reconcile; baseline retention confirmed. - Fresh real delegated-edit SDK smoke accepted with passing gates and no outstanding usage reservations. - Portable patch export/apply regression passes; derived patches exported for all recorded trials. - Whitespace and local Markdown links pass. Advisory source review findings addressed. No required GitHub CI checks are configured. Frozen measured implementation: `3e39569acf55cfaa7f1e2bc76f2caabd4aa1e4a3`. Later bounded-output, cleanup and portable-patch changes were qualified separately and did not alter or replace any scored run. Final source qualification is recorded at `8ad1ba6df6daa4867ca47632951a39c69dcd795d`; the current head changes receipts/documentation only. ## Limits and release These are authored development cases on a Linux AArch64 controller with hosted inference, not an unseen general benchmark or GPU qualification. Conservative request reservations can stop below the nominal 30000 actual-token ceiling; this dominated failures. Monetary subscription costs and immutable hosted weight revisions are unavailable. No general harness ranking or savings claim follows. The iMac runner was unreachable. Focused pilot checks ran on the development host. Unchanged language examples and unrelated full builds were not rerun. Agent review is advisory, not independent hardware/scientific qualification. Raw SDK/provider traces remain private; published receipts are sanitized. No migration, production deployment or Atlas/Cortex integration is included. ## Review and closure - Linked tracking issues and isolated ownership. - No direct-to-main implementation. - Claims distinguish implementation, host evidence and limits. - Complete trials, arithmetic and conservative decision recorded. - Linear closed with merge SHA `668e6adb3c6749e54a305a1144b09d2a11801300`; merged source and frozen lineage verified. - Exact Head: `0d2f1dd4b8f73cf1b27b99c65c35e8ae189ef21c` - Evidence Location: `coder/swarm-pilot/evidence/`; raw private campaign receipts retained on the development host. - Tier Labels: Authored development trials and host controls; not GPU or production qualification. - Linear: DRA-498 / DRA-499 / DRA-500 / DRA-501 / DRA-502 ### Apply it ``` git checkout -b patch-e508aba86e52be95 bd107ca15c40b6cdfef0f23afb03a884fe3c8086 curl -fsSL https://interplane.io/drakestapleton/omega-harness/patches/e508aba86e52be95.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/omega-harness 219 0d2f1dd4b8f73cf1b27b99c65c35e8ae189ef21c ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"omega-harness","number":219,"url":"https://github.com/aien-dev/omega-harness/pull/219","export_sha256":"81c8a50ec4f210545ba0c1f58b0895bf875fb250a73642ad466e88a680f2107e","imported_utc":"2026-11-18T16:39:27Z"} ``` ### Changes ``` diff --git a/coder/README.md b/coder/README.md index 3226738..5838f7a 100644 --- a/coder/README.md +++ b/coder/README.md @@ -55,3 +55,9 @@ The reference solutions are held out: they are not in this repository, the conte session directory; `tasks.json` records only their sha256. They were checked with the pinned gate (27/27 PASS, with a negative control that failed as it should). Keep `coder/eval/` out of any training corpus built from this repository, or the eval stops measuring anything. + +## Experimental coding swarm pilot + +[swarm-pilot/README.md](swarm-pilot/README.md) records an isolated comparative +pilot foundation and its remaining qualification work. It is not a replacement +for the Omega-only session above or a completed swarm evaluation. diff --git a/coder/swarm-pilot/.gitignore b/coder/swarm-pilot/.gitignore new file mode 100644 index 0000000..730964d --- /dev/null +++ b/coder/swarm-pilot/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +.venv/ +results/ diff --git a/coder/swarm-pilot/README.md b/coder/swarm-pilot/README.md new file mode 100644 index 0000000..36a1cab --- /dev/null +++ b/coder/swarm-pilot/README.md @@ -0,0 +1,124 @@ +# AIEN coding swarm pilot + +A local development pilot comparing configured OMP, Deep Agents/LangGraph and +OpenHands coding teams against the same model, source tasks and acceptance checks. +It is experimental tooling, outside AIEN's native runtime. Atlas, Cortex and +`spark-harness` retain their existing responsibilities. + +## What runs + +Each trial has one read-only conductor and at most three active workers. Workers +receive exclusive paths in separate repository snapshots and cannot delegate. These are exported workspaces, +not linked Git worktrees; in-worker Git/PR lifecycles are not part of this pilot. +`repo_command` executes offline Docker commands; only claimed paths are writable. +The controller independently inventories changed files before integrating them. +Command output is capped at 16000 bytes; excess output is refused before it can +be buffered unboundedly. Unconfirmed cleanup cancels further execution authority. +It does not trust the candidate's Git index, check claims or final prose. + +SQLite transactions persist ownership, requests, token reservations, cancellation, +worker state, events and the canonical workspace version. Integration creates a +complete new version before switching the durable pointer. Retrying a completed +worker request does not apply it twice. A single-conductor lease and per-worker +locks prevent duplicate execution. An interrupted conductor can resume from its +existing run directory; unresolved model requests keep their budget reservation. +Cancelled and completed runs are terminal. Resume does not silently free unknown +usage or replay completed integrations. + +SDK processes run in Linux bubblewrap with system libraries, their own installed +packages and only the adapter entrypoints. They cannot read the host home, +credential store, repository snapshots, judge files or reference solutions. +Their registered tools call the controller over an authenticated loopback endpoint. +OMP's existing `auth-gateway stdio` resolves provider credentials outside them. +No provider keys are copied into pilot configuration or agent environments. + +The proxy fixes the model route and low reasoning effort, caps completions at +1,024 tokens and accounts for aggregate provider-reported usage. Each run has a +30,000-token and 1,200-second limit across conductor and workers, including final +acceptance. Before each request it reserves an input-token estimate plus a +2,048-token protocol allowance and the completion cap. With tiktoken installed, +the estimate uses `o200k_base`; otherwise it conservatively uses UTF-8 bytes. +Unknown usage retains its reservation. Usage outside its reservation fails closed. +This is conservative admission control, not a guarantee about undisclosed provider +internal tokenization. In-flight requests are stopped and reconciled before a +result is finalized; already-sent remote requests cannot be unsent. + +## Reproduce + +Use a Linux AArch64 development host with Docker, bubblewrap, Python 3.12 and +OMP 18.18.1 already authenticated. Keep workloads off the interactive Mac. Install +the candidate environments separately using the matching `.lock` requirements; +their dependency trees conflict when installed together. Run the controller with +the OpenHands environment's Python so tiktoken is available. + +The trusted toolchain JSON contains these nonsecret fields: + +- `model`: the shared gateway route, such as `openai-codex/gpt-5.6-sol`. +- `image`: Docker image pinned as `repository@sha256:...`. +- `compiler`: `path` and `sha256` of the seeded AArch64 `omc`. +- `environments`: absolute paths to the `deepagents` and `openhands` environments. +- `omp`: absolute path to the OMP executable. +- `omp_version` and `package_pins`: recorded environment identities. + +Never include keys, tokens or personal data. Example commands: + +```sh +python -m unittest discover -s coder/swarm-pilot -p 'test_*.py' +python coder/swarm-pilot/campaign.py /path/to/toolchain.json /path/to/repository /path/to/new-campaign +python coder/swarm-pilot/audit.py /path/to/campaign +``` + +The campaign first runs software tests, seven actual Docker boundary checks, and +negative-start/positive-reference controls for all six independent judges. It then +freezes source, judge, qualification, configuration and code identities before any +scored model request. It uses a deterministic shuffled trial order (seed 498) and +runs one trial at a time. Repeating the campaign command resumes existing results; +changing code/configuration refuses the resume. Preserve failed preflights and +runs. Never tune prompts or judges against a running campaign. + +For a single task, `runner.py CONFIG SOURCE OUTPUT` uses a trusted config with +`id`, `task`, `repeat`, `arm`, `model`, `image`, `allowed_paths`, `prompt`, +`environments`, `omp`, optional pinned `compiler`, and qualification/source/judge +hashes. Without qualification evidence, a standalone run cannot qualify a harness +for adoption. `Session.cancel()` stops further admission; the active controller +reconciles active processes and cleans up containers bearing its session label. + +## Evidence and selection + +The six tasks are authored development tasks over foundation commit `f5aa51d`: +input validation, an ownership API addition, compiled Omega, independent edits, +atomic conflicting claims and ownership serialization/recovery. They are not an +unseen general benchmark. The repository already publishes their specifications; +the agent workspaces receive only frozen source, task instructions and a public +Omega syntax reference. Existing `coder/eval` held-out tasks are not consumed. + +Two repetitions across three arms produce 36 trials. Every run retains a portable binary-capable `patch.diff` and a complete +independently hashed workspace, raw provider trace, SDK +logs, durable events, actual usage and an independent judge verdict. The parallel +case also requires multiple integrated workers. Judge scripts mount only after +agent execution ends, in a separate offline container. This is ordinary isolated +test evaluation, not certification against arbitrary malicious Python code. + +`audit.py` reconciles all 36 configurations, model/image pins, qualifications, +judges, source identities, token records, workspace hashes and acceptance evidence. +`pilot.py select RESULTS.json` is a calculator over supplied rows; use the audit +before relying on its result. Missing/unbalanced/mixed evidence retains baseline. + +A candidate qualifies only when every run retains passing lifecycle/budget gates +and it completes at least two more trials than baseline, or matches completion +with at least 20% lower measured cost per accepted result. Rank qualifying +candidates by accepted results, cost, then elapsed time. Unknown subscription +costs remain null and cannot establish savings. Failed-run durations are not +accepted-code speedups. Provider model IDs pin the requested route; immutable +hosted model weight revisions are not exposed by this interface. + +Keep raw evidence private in the campaign directory (mode 0700). Publish only +reviewed aggregate results and hashes. LangSmith or Langfuse integration and +Atlas/Cortex execution-cell integration are separate follow-on decisions. + +## Completed pilot + +[The 8 November report](evidence/2026-11-08-report.md) records the audited outcomes +and the decision to retain OMP. The post-campaign output hardening is qualified +separately from the frozen trial implementation. For the real process-exit +control, run `sh coder/swarm-pilot/verify-recovery.sh /path/to/new-recovery-check`. diff --git a/coder/swarm-pilot/STATUS.md b/coder/swarm-pilot/STATUS.md new file mode 100644 index 0000000..a1d78e3 --- /dev/null +++ b/coder/swarm-pilot/STATUS.md @@ -0,0 +1,26 @@ +# Coding swarm pilot status + +Implemented and exercised. The complete 36-run development campaign was audited; +neither replacement qualified, so OMP remains the default. See +[evidence/2026-11-08-report.md](evidence/2026-11-08-report.md) for outcomes, +identities, methods, failure distinctions and release limits. + +Delivered: durable bounded execution, exclusive claims, separate snapshots, +isolated SDKs and offline command tools, atomic integration, conservative budget +admission, cancellation/recovery, separate pinned dependency trees, frozen tasks, +independent acceptance, raw private receipts and a conservative selection/audit. + +Final qualification: 35 software checks, seven real Docker boundaries, six judge +positive/negative pairs and a real abrupt-process-exit recovery control pass. +Source review is advisory. Host evidence is not GPU or production qualification. + +Reuse: existing Omega Harness skills/eval patterns and OMP's authenticated gateway. +Native `spark-harness`, Atlas and Cortex retain their existing responsibilities. +No new subscription, production service restart, native-runtime migration or +production deployment occurred. No private provider credentials enter the pilot +configuration, model workspaces or published receipts. + +Public receipt data is sanitized. Raw SDK/provider traces remain in the owned +private campaign directory. Failed preflights and failed trials are retained. +The post-campaign output-limit hardening is qualified separately; the report names +the exact earlier implementation used for the measured trials. diff --git a/coder/swarm-pilot/adapters.py b/coder/swarm-pilot/adapters.py new file mode 100644 index 0000000..35f15a5 --- /dev/null +++ b/coder/swarm-pilot/adapters.py @@ -0,0 +1,87 @@ +"""Isolated SDK entrypoint. All repository tools call the trusted controller.""" +import json +import os +import urllib.request + + +def remote(name, **arguments): + body = dict(owner=os.environ['PILOT_OWNER'],name=name,arguments=arguments) + request = urllib.request.Request(os.environ['PILOT_GATEWAY_URL']+'/tool', + data=json.dumps(body).encode(),headers={'Content-Type':'application/json', + 'Authorization':'Bearer '+os.environ['PILOT_GATEWAY_TOKEN']}) + with urllib.request.urlopen(request,timeout=1200) as r: return json.load(r) + + +def deepagents(prompt): + from deepagents import (create_deep_agent, HarnessProfile, register_harness_profile, + GeneralPurposeSubagentProfile) + from langchain_openai import ChatOpenAI + from langchain_core.tools import tool + register_harness_profile('openai', HarnessProfile( + general_purpose_subagent=GeneralPurposeSubagentProfile(enabled=False), + excluded_tools=['task','ls','read_file','write_file','edit_file','glob','grep'])) + @tool("repo_command") + def execute(command: str) -> str: + """Execute a shell command in the isolated repository workspace.""" + return json.dumps(remote('execute',command=command)) + @tool + def delegate(owner: str, paths: list[str], instruction: str) -> str: + """Delegate bounded work with exclusive paths to a nondelegating worker.""" + return json.dumps(remote('delegate',owner=owner,paths=paths,instruction=instruction)) + tools = [execute] + ([delegate] if os.environ['PILOT_OWNER']=='conductor' else []) + model = ChatOpenAI(model=os.environ['PILOT_MODEL'],api_key=os.environ['PILOT_GATEWAY_TOKEN'], + base_url=os.environ['PILOT_GATEWAY_URL']+'/v1',max_tokens=1024,streaming=False,max_retries=0) + agent = create_deep_agent(model=model, tools=tools, subagents=[], + system_prompt='Use repo_command for repository reads/checks. Only delegate workers may modify files. ' + 'Worker roles use repo_command to edit their claimed files. Report actual evidence only.') + result=agent.invoke({'messages':[{'role':'user','content':prompt}]},config={'recursion_limit':80}) + print(json.dumps({'final':str(result['messages'][-1].content)})) + + +def openhands(prompt): + from pydantic import SecretStr + from openhands.sdk import (LLM,Agent,Conversation,Action,Observation,TextContent,ToolDefinition) + from openhands.sdk.tool import Tool,ToolExecutor,register_tool + class ExecuteAction(Action): command: str + class DelegateAction(Action): + owner: str + paths: list[str] + instruction: str + class Result(Observation): + output: str + @property + def to_llm_content(self): return [TextContent(text=self.output)] + class Execute(ToolExecutor): + def __call__(self,action,conversation=None): + return Result(output=json.dumps(remote('execute',command=action.command))) + class Delegate(ToolExecutor): + def __call__(self,action,conversation=None): + return Result(output=json.dumps(remote('delegate',owner=action.owner, + paths=action.paths,instruction=action.instruction))) + class repo_command(ToolDefinition): + @classmethod + def create(cls,conv_state,**kwargs): + return [cls(description='Execute a command in the isolated repository. Conductor cannot write.', + action_type=ExecuteAction,observation_type=Result,executor=Execute())] + class delegate(ToolDefinition): + @classmethod + def create(cls,conv_state,**kwargs): + return [cls(description='Delegate to a nondelegating worker with exclusive paths.', + action_type=DelegateAction,observation_type=Result,executor=Delegate())] + register_tool('PilotExecute',repo_command);register_tool('PilotDelegate',delegate) + tools=[Tool(name='PilotExecute')] + if os.environ['PILOT_OWNER']=='conductor':tools.append(Tool(name='PilotDelegate')) + llm=LLM(model='openai/'+os.environ['PILOT_MODEL'], + api_key=SecretStr(os.environ['PILOT_GATEWAY_TOKEN']), + base_url=os.environ['PILOT_GATEWAY_URL']+'/v1',max_output_tokens=1024, + num_retries=0) + c=Conversation(agent=Agent(llm=llm,tools=tools),max_iteration_per_run=40,visualizer=None) + try: + c.send_message(prompt);c.run() + print(json.dumps({'final':'OpenHands turn finished; acceptance is independently checked.'})) + finally:c.close() + +if __name__=='__main__': + import sys + config=json.load(sys.stdin) + globals()[config['arm']](config['prompt']) diff --git a/coder/swarm-pilot/audit.py b/coder/swarm-pilot/audit.py new file mode 100644 index 0000000..cd9f032 --- /dev/null +++ b/coder/swarm-pilot/audit.py @@ -0,0 +1,38 @@ +"""Reconcile all recorded evidence before issuing a pilot selection.""" +import json +from pathlib import Path +import sys +from runner import digest +from runtime import snapshot,Session,Refused +from pilot import select + + +def audit(root): + root=Path(root);pin=json.loads((root/'campaign.json').read_text());rows=[] + qualification=json.loads((root/'qualification.json').read_text()) + if digest(qualification)!=pin['qualification_sha256'] or not qualification['unit_checks'] or not qualification['live']['passed'] or not all(r['passed'] for r in qualification['acceptance']): + raise Refused('qualification evidence missing') + if qualification['code_sha256']!=pin['code_sha256']:raise Refused('qualification code mismatch') + for item in pin['order']: + run=root/'runs'/item['id'] + row=json.loads((run/'result.json').read_text());config=json.loads((run/'config.json').read_text()) + if row['id']!=item['id'] or row['config_sha256']!=digest(config):raise Refused('configuration evidence mismatch') + if config['model']!=pin['toolchain']['model'] or config['image']!=pin['toolchain']['image']:raise Refused('mixed model or image') + if config['qualification_sha256']!=pin['qualification_sha256'] or config['judge_sha256']!=pin['judge_sha256']:raise Refused('mixed qualification or judge') + source=json.loads((root/'frozen'/item['task']/'task.json').read_text()) + if config['source_sha256']!=source['source_sha256']:raise Refused('mixed task source') + s=Session(run);state=s.status() + trace=[json.loads(l) for l in (run/'trace.jsonl').read_text().splitlines()] if (run/'trace.jsonl').exists() else [] + if sum(r['usage'] for r in trace)!=row['tokens'] or row['tokens']!=state['tokens']:raise Refused('usage evidence mismatch') + if row['tree_sha256']!=digest(snapshot(s.current)):raise Refused('artifact evidence mismatch') + if row['accepted']: + if row['judge_exit_code']!=0 or (run/'judge.stdout').read_text().strip()!='PASS '+item['task']: + raise Refused('acceptance evidence missing') + if row['tokens']>30000 or row['reserved_tokens'] or state['cancelled']:raise Refused('accepted run exceeds authority') + rows.append(row) + if len(rows)!=36:raise Refused('campaign incomplete') + verdict=select(rows) + print(json.dumps(dict(audited_runs=36,selection=verdict),indent=2)) + return rows,verdict + +if __name__=='__main__':audit(sys.argv[1]) diff --git a/coder/swarm-pilot/baseline.ts b/coder/swarm-pilot/baseline.ts new file mode 100644 index 0000000..9d5fd1f --- /dev/null +++ b/coder/swarm-pilot/baseline.ts @@ -0,0 +1,22 @@ +// Minimal OMP extension: native tools are disabled; repository effects stay in the controller. +export default function (pi: any) { + const z = pi.zod + async function call(name: string, args: unknown) { + const response = await fetch(process.env.PILOT_GATEWAY_URL + '/tool', { + method: 'POST', headers: { 'Content-Type': 'application/json', + Authorization: 'Bearer ' + process.env.PILOT_GATEWAY_TOKEN }, + body: JSON.stringify({ owner: process.env.PILOT_OWNER, name, arguments: args }) + }) + return { content: [{ type: 'text', text: await response.text() }] } + } + pi.registerTool({ name: 'repo_command', label: 'Execute', loadMode: 'essential', + description: 'Execute a command in the isolated repository. The conductor cannot write.', + parameters: z.object({ command: z.string() }), + execute: async (_id: string, args: unknown) => call('execute', args) }) + if (process.env.PILOT_OWNER === 'conductor') { + pi.registerTool({ name: 'delegate', label: 'Delegate', loadMode: 'essential', + description: 'Delegate to a nondelegating worker with exclusive paths.', + parameters: z.object({ owner: z.string(), paths: z.array(z.string()), instruction: z.string() }), + execute: async (_id: string, args: unknown) => call('delegate', args) }) + } +} diff --git a/coder/swarm-pilot/campaign.py b/coder/swarm-pilot/campaign.py new file mode 100644 index 0000000..47cebfb --- /dev/null +++ b/coder/swarm-pilot/campaign.py @@ -0,0 +1,57 @@ +"""Frozen, resumable 36-run development campaign. Never tune a running campaign.""" +import argparse +import hashlib +import json +from pathlib import Path +import random +import subprocess +import sys +from controls import run as acceptance_controls +from live_controls import run as live_controls +from runner import run,digest +from pilot import matrix,select +from runtime import snapshot,write_json,Refused +from suite import freeze + +HERE=Path(__file__).resolve().parent + +def code_hash(): + return hashlib.sha256(b''.join(p.name.encode()+p.read_bytes() for p in sorted(p for p in HERE.iterdir() if p.suffix in ('.py','.ts')))).hexdigest() + + +def campaign(toolchain,repository,output): + output=Path(output) + if not output.exists(): + output.mkdir(mode=0o700) + freeze(repository,output/'frozen') + order=matrix(['bug','feature','omega','parallel','conflict','recovery']) + random.Random(498).shuffle(order) + subprocess.run([sys.executable,'-m','unittest','discover','-s',str(HERE),'-p','test_*.py'],check=True) + live_controls(toolchain,output/'live-controls.json') + acceptance_controls(output/'frozen',output/'acceptance-controls',toolchain['image'],toolchain['compiler']) + qualification=dict(unit_checks=True,live=json.loads((output/'live-controls.json').read_text()), + acceptance=json.loads((output/'acceptance-controls'/'controls.json').read_text()),code_sha256=code_hash()) + write_json(output/'qualification.json',qualification) + write_json(output/'campaign.json',dict(toolchain=toolchain,code_sha256=code_hash(),order=order, + qualification_sha256=digest(qualification),judge_sha256=hashlib.sha256((HERE/'judge.py').read_bytes()).hexdigest())) + pin=json.loads((output/'campaign.json').read_text()) + if pin['toolchain']!=toolchain or pin['code_sha256']!=code_hash():raise Refused('campaign implementation/configuration changed') + (output/'runs').mkdir(exist_ok=True) + rows=[] + for item in pin['order']: + if pin['code_sha256']!=code_hash():raise Refused('implementation changed during campaign') + task_root=output/'frozen'/item['task'];task=json.loads((task_root/'task.json').read_text()) + if hashlib.sha256(json.dumps(snapshot(task_root/'source'),sort_keys=True).encode()).hexdigest()!=task['source_sha256']: + raise Refused('frozen source changed') + config={**toolchain,**item,'qualification_sha256':pin['qualification_sha256'],'judge_sha256':pin['judge_sha256'], + 'source_sha256':task['source_sha256'],'allowed_paths':task['paths'],'prompt':task['prompt']} + row=run(config,output/'runs'/item['id'],task_root/'source') + rows.append(row) + write_json(output/'results.json',rows) + print(json.dumps(dict(completed=len(rows),total=36,id=item['id'],accepted=row['accepted'],tokens=row['tokens'],error=row['error'])),flush=True) + selection=select(rows);write_json(output/'selection.json',selection) + print(json.dumps(selection),flush=True) + +if __name__=='__main__': + p=argparse.ArgumentParser();p.add_argument('toolchain',type=Path);p.add_argument('repository',type=Path);p.add_argument('output',type=Path) + a=p.parse_args();campaign(json.loads(a.toolchain.read_text()),a.repository,a.output) diff --git a/coder/swarm-pilot/controls.py b/coder/swarm-pilot/controls.py new file mode 100644 index 0000000..b217f32 --- /dev/null +++ b/coder/swarm-pilot/controls.py @@ -0,0 +1,59 @@ +"""Positive/negative acceptance controls; never mount reference solutions into agents.""" +import json +from pathlib import Path +import shutil +import sys +from sandbox import Sandbox +from runtime import write_json + +METHODS=''' +def _release_all(self): + owners=sorted(self.owners) + self.owners.clear() + return owners +Claims.release_all=_release_all + +def _acquire_many(self, entries): + trial=Claims() + trial.owners=dict(self.owners) + for owner, paths in entries.items(): trial.acquire(owner,paths) + self.owners=trial.owners +Claims.acquire_many=_acquire_many + +def _to_json(self): + return json.dumps({k:[str(p) for p in v] for k,v in self.owners.items()}) + +def _from_json(cls,text): + obj=json.loads(text) + if not isinstance(obj,dict): raise ValueError('mapping required') + c=cls() + for k,v in obj.items(): + if not isinstance(v,list): raise ValueError('paths required') + c.acquire(k,v) + return c +Claims.to_json=_to_json +Claims.from_json=classmethod(_from_json) +''' + +def run(frozen,output,image,compiler): + frozen,output=Path(frozen),Path(output);output.mkdir(mode=0o700) + results=[] + for task in json.loads((frozen/'manifest.json').read_text())['tasks']: + name=task['id'];source=frozen/name/'source' + negative=Sandbox(source,image,writable=[],compiler=compiler,judge=Path(__file__).with_name('judge.py')).execute('python /judge.py '+name+' /work') + positive=output/name;shutil.copytree(source,positive) + p=positive/'pilot.py';s=p.read_text() + s=s.replace(" if len(tasks) != 6", " import re\n if any(not isinstance(t,str) or not re.fullmatch('[A-Za-z0-9_-]+',t) for t in tasks): raise ValueError('invalid ID')\n if len(tasks) != 6") + p.write_text(s+METHODS) + with (positive/'sandbox.py').open('a') as f: + f.write("\ndef valid_image(v):\n return isinstance(v,str) and bool(re.fullmatch(r'[^\\s,@]+@sha256:[0-9a-f]{64}',v))\n") + (positive/'program.om').write_text('fn main to int\ni = int 1\ns = int 0\nwhile lt i 11 bound 10\ns = add s i\ni = add i 1\nend\nret s\nend\n') + result=Sandbox(positive,image,writable=[],compiler=compiler,judge=Path(__file__).with_name('judge.py')).execute('python /judge.py '+name+' /work') + results.append(dict(task=name,negative=negative,positive=result, + passed=negative['exit_code']!=0 and result['exit_code']==0 and result['output'].strip()=='PASS '+name)) + write_json(output/'controls.json',results) + print(json.dumps([dict(task=r['task'],passed=r['passed']) for r in results],indent=2)) + if not all(r['passed'] for r in results):raise SystemExit(1) + +if __name__=='__main__': + cfg=json.loads(Path(sys.argv[1]).read_text());run(sys.argv[2],sys.argv[3],cfg['image'],cfg['compiler']) diff --git a/coder/swarm-pilot/evidence/2026-11-08-arithmetic.json b/coder/swarm-pilot/evidence/2026-11-08-arithmetic.json new file mode 100644 index 0000000..8f03eb1 --- /dev/null +++ b/coder/swarm-pilot/evidence/2026-11-08-arithmetic.json @@ -0,0 +1,33 @@ +{ + "method": "WolframLanguageEvaluator", + "query": "data=<|\"baseline\" -> {{0,26096,63.67261862754822},{1,23285,36.907251596450806},{0,23662,40.6696457862854},{0,24719,43.26404809951782},{0,24826,38.30976676940918},{0,25136,30.757111310958862},{0,26134,69.0713438987732},{0,25949,53.217729330062866},{1,20207,33.17686057090759},{0,25801,55.799922943115234},{0,24549,37.240476846694946},{0,26321,68.73276257514954}},\"deepagents\" -> {{0,17012,70.83207511901855},{1,18440,60.29341220855713},{0,18389,52.89306282997131},{0,16789,46.96008253097534},{1,10176,35.355825424194336},{1,6190,32.91969919204712},{0,17886,55.82362365722656},{0,16053,39.339882373809814},{0,17963,67.90323567390442},{0,16761,67.1927981376648},{0,17373,48.68803834915161},{0,9575,51.31468462944031}},\"openhands\" -> {{0,18974,26.223806142807007},{0,19417,31.83185076713562},{0,19354,30.2143132686615},{0,19217,29.583195447921753},{0,19896,38.85233211517334},{0,21547,30.04243016242981},{0,21402,28.709967851638794},{0,23540,37.102256059646606},{0,19127,27.466328620910645},{0,19731,34.83427619934082},{0,23457,35.34184908866882},{0,19508,31.326399087905884}}|>; summary=Map[Function[rows,<|\"runs\"->Length[rows],\"accepted\"->Total[rows[[All,1]]],\"providerTokens\"->Total[rows[[All,2]]],\"elapsedSecondsAllOutcomes\"->Total[rows[[All,3]]]|>],data]; ExportString[<|\"summary\"->summary,\"plannedRunsVerified\"->(Total[Length/@Values[data]]==6*2*3),\"budgetAdmissionRefusals\"->Total[{1,1,0,1,0,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1}],\"independentJudgesRun\"->Total[{0,0,1,0,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0}],\"completionThresholdMet\"->AssociationMap[(summary[#][\"accepted\"]>=summary[\"baseline\"][\"accepted\"]+2)&,{\"deepagents\",\"openhands\"}]|>,\"JSON\"]", + "result": { + "summary": { + "baseline": { + "runs": 12, + "accepted": 2, + "providerTokens": 296685, + "elapsedSecondsAllOutcomes": 570.8195383548737 + }, + "deepagents": { + "runs": 12, + "accepted": 3, + "providerTokens": 182607, + "elapsedSecondsAllOutcomes": 629.5164201259613 + }, + "openhands": { + "runs": 12, + "accepted": 0, + "providerTokens": 245170, + "elapsedSecondsAllOutcomes": 381.5290048122406 + } + }, + "plannedRunsVerified": true, + "budgetAdmissionRefusals": 31, + "independentJudgesRun": 5, + "completionThresholdMet": { + "deepagents": false, + "openhands": false + } + } +} diff --git a/coder/swarm-pilot/evidence/2026-11-08-final-qualification.json b/coder/swarm-pilot/evidence/2026-11-08-final-qualification.json new file mode 100644 index 0000000..93dca4c --- /dev/null +++ b/coder/swarm-pilot/evidence/2026-11-08-final-qualification.json @@ -0,0 +1,77 @@ +{ + "source_commit": "8ad1ba6df6daa4867ca47632951a39c69dcd795d", + "code_sha256": "0a38e2a2eaf261b956370e432a1bba9a54619ee88a0e777d46d4d908919ef099", + "software_checks": 35, + "live_boundaries": { + "checks": { + "conductor_write_refused": true, + "judge_not_visible_during_generation": true, + "credential_store_not_visible": true, + "offline_command_network": true, + "timed_out_command_stopped": true, + "claimed_write_works": true, + "unclaimed_write_refused": true + }, + "passed": true, + "source_sha256": "762f197c13a7bc37244687f231cbbf375489c32491d4750253a35fbd2ea419f0" + }, + "judge_controls": [ + { + "task": "bug", + "passed": true + }, + { + "task": "feature", + "passed": true + }, + { + "task": "omega", + "passed": true + }, + { + "task": "parallel", + "passed": true + }, + { + "task": "conflict", + "passed": true + }, + { + "task": "recovery", + "passed": true + } + ], + "process_recovery": { + "abrupt_exit_before_commit": true, + "atomic_rollback": true, + "recovered_integration": true, + "idempotent_integration": true, + "original_snapshot_unchanged": true, + "cancellation_persistent": true + }, + "recovery_control_sha256": "9c88bb16fe3be57da8ad2e0a1ffb4c91904f3f9acfeba9c0e67dbfcd02d45190", + "sdk_interaction_source_commit": "cb880ccd973eb55ba905b0fd1df1e036cdf6742f", + "real_sdk_smoke": { + "id": "release-smoke-cb880cc", + "task": "smoke", + "repeat": 1, + "arm": "deepagents", + "accepted": true, + "gates_passed": true, + "seconds": 24.070388555526733, + "cost": null, + "tokens": 3529, + "reserved_tokens": 0, + "judge_exit_code": 0, + "error": null, + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "a1dae292bf7514f5301f213376a7e1d44de9d191229866a11ce5f112b0f9fae7", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "57eb6a9a27aa0cfbdf982859a30627464681570d963297508a4977514fa9527f", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "f350559713b78b534388408e1e2c70596f30ae244e3433d7db1e8b190a4050bd", + "tree_sha256": "e12b98b5230973431d93a14bed8bf0fcb72d06f4271a9c41ec21122d00af4c91" + }, + "portable_patch_apply_test_passed": true, + "exported_trial_patches": 36 +} diff --git a/coder/swarm-pilot/evidence/2026-11-08-report.md b/coder/swarm-pilot/evidence/2026-11-08-report.md new file mode 100644 index 0000000..c9f9ff3 --- /dev/null +++ b/coder/swarm-pilot/evidence/2026-11-08-report.md @@ -0,0 +1,102 @@ +# AIEN coding swarm pilot, 8 November 2026 + +Retain the existing OMP workflow. Neither configured replacement met the adoption +criteria. Deep Agents completed more trials in this small sample, but the result +does not establish a general ranking or justify replacing the current workflow. + +## MEASURED outcomes + +| Configured harness | Completed trials | Independently accepted | Provider-reported tokens, all outcomes | +| --- | ---: | ---: | ---: | +| OMP baseline | 12 | 2 | 296685 | +| Deep Agents / LangGraph | 12 | 3 | 182607 | +| OpenHands SDK | 12 | 0 | 245170 | + +All 36 trial configurations, token receipts, independent verdicts and final +workspace hashes reconciled through `audit.py`. Five attempts reached the +independent judge and passed. The other 31 stopped at conservative budget +admission, including worker refusals that surfaced as an SDK error in the +conductor. These are unfinished attempts, not measured source-code failures. + +The proxy reserves estimated input tokens, protocol allowance and completion +capacity before each request. It can refuse a request while actual usage remains +below the nominal 30000-token ceiling. This constraint was the dominant failure +mode and is a limitation of this configured comparison. A shorter failed run is +not an accepted-code speedup. Monetary subscription costs are unknown; token +counts are not dollar-cost measurements. + +A replacement needed at least two additional accepted trials relative to +baseline, or equal acceptance with a measured 20 percent cost reduction, plus +passing lifecycle/admission gates. Neither completion threshold was met, and +unknown costs cannot establish the alternative savings criterion. The frozen +selection policy also retains baseline when a candidate has failed run gates. +Baseline retention is a conservative default, not a claim that baseline passed +every gate or is the best harness generally. + +## What was compared + +Six authored development tasks over pinned repository source, repeated twice per +arm: task-ID validation, ownership API extension, compiling/running Omega, +independent multiworker edits, atomic conflicting claims and ownership recovery. +They are public development cases, not an unseen general benchmark. The original +`coder/eval` held-out task corpus was not used or exposed. + +Every arm used the same `openai-codex/gpt-5.6-sol` route, low reasoning effort, +1024-token completion cap, 30000-token aggregate admission budget and 1200-second +run deadline. Trials ran one at a time in a deterministic shuffled order, seed +498. Framework prompts and their configured tool/context behavior remained part +of the comparison. Workers could write only declared paths; the conductor could +read/check and delegate. No prompts or judges changed during the scored campaign. + +The model's immutable hosted weight revision is not exposed. This records the +requested route and observed response labels, not a checkpoint qualification. +The controller ran on Linux AArch64; inference used existing hosted subscription +access. No GPU performance or production-runtime claim follows from these runs. + +Trial implementation: `3e39569acf55cfaa7f1e2bc76f2caabd4aa1e4a3`. +Task source: `f5aa51df02f2037994f6ca31a4ee6181c4268ed2`. +Exact model, package, image, compiler, source, judge and qualification identities +are in [the sanitized trial receipt](2026-11-08-trials.json). +The aggregate arithmetic and comparison checks were independently calculated +through Wolfram; [the query and result](2026-11-08-arithmetic.json) are retained. + +## Verification and release boundaries + +Before scoring, 31 focused software checks, seven actual Docker boundary checks, +and all six negative-start/positive-reference acceptance controls passed. Failed +preflights were retained and contained no scored model requests. Each run then +retained its raw failures, provider usage, SDK logs, durable events, independently +hashed workspace and independent judge output. Raw content stays private on the +operator's development host; this directory publishes reviewed outcomes/hashes. + +After the frozen campaign, command-output capture was hardened to refuse output +above 16000 bytes without buffering it unboundedly. Unconfirmed sandbox cleanup +now cancels further authority. This hardening was developed separately and did +not alter the recorded trial implementation or replace any trial. Final source +passed 35 focused checks, the seven Docker boundaries and all six judge controls +again. A real abrupt-process-exit control verified rollback before pointer commit, +recovered integration, idempotent retry, original-snapshot preservation and +persistent cancellation. The full trial set was not rerun against the hardening; +its measurements apply to the frozen trial commit above. Portable patches were +exported from all recorded workspaces afterward and checked by applying an export +to an original snapshot; this postprocessing did not change model outcomes. The final hardened +source also passed a fresh real Deep Agents delegated-edit smoke test with an +independent judge and no outstanding usage reservations. +[Final qualification receipt](2026-11-08-final-qualification.json). + +An advisory source review identified eight important issues that were fixed and +covered by regression checks. Agent review is not independent hardware or +scientific qualification. The deterministic judges are separate from agent +execution, but do not certify resistance to arbitrary malicious Python code. +The iMac runner was unreachable. Focused checks ran on the development host; +unchanged language examples and unrelated full builds were not rerun. + +## Delivery decision + +Keep all three pilot adapters available for development experiments and retain +OMP as the regular workflow. Do not purchase LangSmith or move Atlas/Cortex based +on this pilot. Tracing-platform selection and production integration remain +separate follow-on work. This release changes experimental coding tooling only. + +Tracking: [DRA-498](https://linear.app/drake-stapleton/issue/DRA-498/complete-and-evaluate-the-aien-coding-swarm-pilot). +Source review and delivery: [PR 219](https://github.com/aien-dev/omega-harness/pull/219). diff --git a/coder/swarm-pilot/evidence/2026-11-08-trials.json b/coder/swarm-pilot/evidence/2026-11-08-trials.json new file mode 100644 index 0000000..7584694 --- /dev/null +++ b/coder/swarm-pilot/evidence/2026-11-08-trials.json @@ -0,0 +1,1090 @@ +{ + "metadata": { + "measurement_scope": "MEASURED authored development trials, not a general benchmark", + "date": "2026-11-08", + "trial_source_commit": "3e39569acf55cfaa7f1e2bc76f2caabd4aa1e4a3", + "code_sha256": "0f8d90eda49f6494791a17eda24bc8933a3bda808017f64bf67169eb17152a83", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "model": "openai-codex/gpt-5.6-sol", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "compiler_sha256": "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f", + "omp_version": "18.18.1", + "package_pins": { + "deepagents": "0.7.34", + "langchain-openai": "1.7.4", + "openhands-sdk": "1.60.2", + "openhands-tools": "1.60.2" + }, + "architecture": "aarch64", + "task_base_commit": "f5aa51df02f2037994f6ca31a4ee6181c4268ed2" + }, + "rows": [ + { + "id": "bug-2-baseline", + "task": "bug", + "repeat": 2, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 63.67261862754822, + "cost": null, + "tokens": 26096, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "c076b7df8be482b2db5028f59e46484a4fe8676bd08135a93cad5dc3920d0c20", + "tree_sha256": "baa4de765c0e1482f4eb0559243447b0c6a33047caa65704334438afef2443cc", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "3c9c8e19738302a61fe64673e367f766f3754c08a8cdd84817f6a5b77545d4fc" + }, + { + "id": "recovery-1-deepagents", + "task": "recovery", + "repeat": 1, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 70.83207511901855, + "cost": null, + "tokens": 17012, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "5c3f1244521f632ceef545c7c88f862f2f9e7cfcfe86df44635f652de17d06a8", + "tree_sha256": "91f11e1bdb58cf711731d05d4a4909b86d68119bab1b7cf65a5fa59af9a98fa0", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "efa58e0128557d3c499a6f0e02c86b78738c1a5303128c13ae8d8e0504601cd4" + }, + { + "id": "conflict-2-deepagents", + "task": "conflict", + "repeat": 2, + "arm": "deepagents", + "accepted": true, + "gates_passed": true, + "seconds": 60.29341220855713, + "cost": null, + "tokens": 18440, + "reserved_tokens": 0, + "judge_exit_code": 0, + "error": null, + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "0d3e48390bb836f3e0977f2c1b9d6b5ba46990602d664e4ef5c04ec79576696c", + "tree_sha256": "042bf8ba313920b18ea64e345d739e2d662341d64dee31a1ebcb7654fdfd4fc7", + "refusal_reason": null, + "failure_kind": "accepted", + "gateway_refusal_reasons": [], + "patch_sha256": "1e5f358273ee4ee1e7dc622093cdfb722f591ef3613cb964cc7632c2f048144d" + }, + { + "id": "feature-2-openhands", + "task": "feature", + "repeat": 2, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 26.223806142807007, + "cost": null, + "tokens": 18974, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "bcbb8747f464d39fc181f5d253cda3902dc17a5d7be3006812f16a3054312348", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "feature-2-baseline", + "task": "feature", + "repeat": 2, + "arm": "baseline", + "accepted": true, + "gates_passed": true, + "seconds": 36.907251596450806, + "cost": null, + "tokens": 23285, + "reserved_tokens": 0, + "judge_exit_code": 0, + "error": null, + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "c8a9041a1d4ff43fa2cce93900c89f3b136ce86d4d81117140b526c6edf3283f", + "tree_sha256": "5815a6cfc0893b78a6ef8e41f5e2b06f1c6f98107eea96a035b1e072dffd3030", + "refusal_reason": null, + "failure_kind": "accepted", + "gateway_refusal_reasons": [], + "patch_sha256": "88d46d18d6b6fd27e6b5d3f70d9235829baf1912195f8e526a9855b8ad7431e4" + }, + { + "id": "feature-1-deepagents", + "task": "feature", + "repeat": 1, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 52.89306282997131, + "cost": null, + "tokens": 18389, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "c3367ee77d7d23f5202b7cd8b3f22b10f984ad9f08e3b9d838d157a033994043", + "tree_sha256": "5815a6cfc0893b78a6ef8e41f5e2b06f1c6f98107eea96a035b1e072dffd3030", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "88d46d18d6b6fd27e6b5d3f70d9235829baf1912195f8e526a9855b8ad7431e4" + }, + { + "id": "feature-2-deepagents", + "task": "feature", + "repeat": 2, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 46.96008253097534, + "cost": null, + "tokens": 16789, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "a11259409ea9b87ed7d07f2444bbf6d83dba7833533bc4995d94251dd752a956", + "tree_sha256": "01e818efbfbef9e2b76d7698fd2812caa4a1ec4ebc68c1dd7f5574b4652ffea9", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "fada9a301473b4adc9ee44006fbc1f197ee8ef7c812be7eb3e4a211ba90cf09b" + }, + { + "id": "omega-1-deepagents", + "task": "omega", + "repeat": 1, + "arm": "deepagents", + "accepted": true, + "gates_passed": true, + "seconds": 35.355825424194336, + "cost": null, + "tokens": 10176, + "reserved_tokens": 0, + "judge_exit_code": 0, + "error": null, + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "fec422d3aa0bcbdae8f2f580185363d81b2a5e89f4d1f77aca8e39569b808136", + "tree_sha256": "3f676d88a89f336b86e2669493a15db6f07c6d54c747c6bb3f27a4141f6db335", + "refusal_reason": null, + "failure_kind": "accepted", + "gateway_refusal_reasons": [], + "patch_sha256": "43a0817183f07b8c95f235b8ecd6477a32ff3323326842ef3849522ab488b343" + }, + { + "id": "feature-1-baseline", + "task": "feature", + "repeat": 1, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 40.6696457862854, + "cost": null, + "tokens": 23662, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "6be78bfd9bd1a303beb876dcd2e263fcbc2c0e9960ccb0575fb116b582175d22", + "tree_sha256": "de8dc4c5d0c0dec0609fefaec774620159375e9eeea4f66829bdd808f90d39ba", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "55068fc6210d0d3149efd3c7bfd479ea2b4daddc22573cde60c4e77195ca2eb2" + }, + { + "id": "omega-2-deepagents", + "task": "omega", + "repeat": 2, + "arm": "deepagents", + "accepted": true, + "gates_passed": true, + "seconds": 32.91969919204712, + "cost": null, + "tokens": 6190, + "reserved_tokens": 0, + "judge_exit_code": 0, + "error": null, + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "911c60ba3d896ca9b0fec5624a07cd8fc9180f748536c64e96274a4e7cbb9923", + "tree_sha256": "e90ac4f2741c0199cd8ef7d8bf3a6f4480dae00d4972bca92690133a12855c68", + "refusal_reason": null, + "failure_kind": "accepted", + "gateway_refusal_reasons": [], + "patch_sha256": "cddec5c04efc2ee2448fdc26bef6875fb5b6c0b2084743db549a820f6d886449" + }, + { + "id": "bug-1-deepagents", + "task": "bug", + "repeat": 1, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 55.82362365722656, + "cost": null, + "tokens": 17886, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "72927bf7f4651202b7b4303c935eb4435f8fa3e70855c27946c83254825bfbdc", + "tree_sha256": "8f9d317a6639b71b01627df6db2db550ea54f4490e135ed86fe97df530d9e70d", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "e614c76a4910f25fafb1430180bd465722fcb0d5860c91a6312550f03dfef077" + }, + { + "id": "bug-1-openhands", + "task": "bug", + "repeat": 1, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 31.83185076713562, + "cost": null, + "tokens": 19417, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "b5a334b602d112b89c0c0be230eaf4d78a19693979d5c1ef126c24dbda11eb72", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "conflict-1-baseline", + "task": "conflict", + "repeat": 1, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 43.26404809951782, + "cost": null, + "tokens": 24719, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "aa88376aba8965cca3883ae76e133178f26b01fe7fa152eceb12fae94de34f25", + "tree_sha256": "db36f80a9e402e9f6aea857781168639eced2eb434c4a075af06859dc34d4826", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "32184cd77223265f6cbc3edcfde32fba180aede0540defe4676ec677c0ee5dd4" + }, + { + "id": "conflict-2-openhands", + "task": "conflict", + "repeat": 2, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 30.2143132686615, + "cost": null, + "tokens": 19354, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "bc3399f42bea639f092da905962be354ba256821931666b4f85e1b6a679b837b", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "bug-2-openhands", + "task": "bug", + "repeat": 2, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 29.583195447921753, + "cost": null, + "tokens": 19217, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "7a1e3e186f5afea234106c0f45380d71ba3d15c5e5059124143ac735c579ac30", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "parallel-2-deepagents", + "task": "parallel", + "repeat": 2, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 39.339882373809814, + "cost": null, + "tokens": 16053, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "0b89079880fa1ed3ec153e8774acd3f76b9330db0f72a0328b860158a74bb05d", + "tree_sha256": "ff421800dba10bd0ded360d64725c54362d7756f12a07c0422ef67402cbf2fdb", + "refusal_reason": "SDK process failed; inspect private run logs", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs" + ], + "patch_sha256": "c14bd9261d4422a8c9dc4f96c8527abeb9a098233aaf017dae82dd76fc8b3326" + }, + { + "id": "recovery-2-openhands", + "task": "recovery", + "repeat": 2, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 38.85233211517334, + "cost": null, + "tokens": 19896, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "74918b5f93a5074677cb5526716d4f3e3ba9aa912b7327f788e592f72a044cbc", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "parallel-1-baseline", + "task": "parallel", + "repeat": 1, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 38.30976676940918, + "cost": null, + "tokens": 24826, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "bf8a67915fa2a1f46075f29796774dc0621a91b98e96325a8c2b7dd8a5996d1e", + "tree_sha256": "01e818efbfbef9e2b76d7698fd2812caa4a1ec4ebc68c1dd7f5574b4652ffea9", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "fada9a301473b4adc9ee44006fbc1f197ee8ef7c812be7eb3e4a211ba90cf09b" + }, + { + "id": "omega-1-openhands", + "task": "omega", + "repeat": 1, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 30.04243016242981, + "cost": null, + "tokens": 21547, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "3e21785dd712b5c2ba158c23e041446e555db31dfebfe3eb188a7489be127f0f", + "tree_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "omega-2-openhands", + "task": "omega", + "repeat": 2, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 28.709967851638794, + "cost": null, + "tokens": 21402, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "33de37b64fc7ae2db176bae0d0eab932857101808ae146072846a4a866c78860", + "tree_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "conflict-1-deepagents", + "task": "conflict", + "repeat": 1, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 67.90323567390442, + "cost": null, + "tokens": 17963, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "d3e8336b6d9d5b9ba1921a7a21f2dc5cffda23f434d5838112de5263f275b8c4", + "tree_sha256": "e10e7d8094eab992f89eb357a5dad9ffbad03467a5964cf347dc5b46521ece22", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "3817eda2a2f281c113e8c74aee633a012845b05d84258b8de783bb1488238b6d" + }, + { + "id": "parallel-1-openhands", + "task": "parallel", + "repeat": 1, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 37.102256059646606, + "cost": null, + "tokens": 23540, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "6b4f291e06de3209c95980a0d4e891c6523d8efd4a8bc5d71082887695405dbb", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "bug-2-deepagents", + "task": "bug", + "repeat": 2, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 67.1927981376648, + "cost": null, + "tokens": 16761, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "89df61d5fed47b74be3ae2a19b086d6d615b7397d8739cea1f78c9390cc5bc97", + "tree_sha256": "49280f50675403e568f0318ccffd8e03eea66c4b097d0c3dec12159c3f0e8700", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "e0eb10c509a9f41efc0ae6ca676b4cce5b747b873c9a4ceebaa4aedc8924f9b6" + }, + { + "id": "parallel-2-baseline", + "task": "parallel", + "repeat": 2, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 30.757111310958862, + "cost": null, + "tokens": 25136, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "86f00440e3b14ba0cbae2df49530e28be12c034508070858a30e6b2c7ff04678", + "tree_sha256": "5815a6cfc0893b78a6ef8e41f5e2b06f1c6f98107eea96a035b1e072dffd3030", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "worker ID reused for a different request", + "token budget exhausted" + ], + "patch_sha256": "88d46d18d6b6fd27e6b5d3f70d9235829baf1912195f8e526a9855b8ad7431e4" + }, + { + "id": "feature-1-openhands", + "task": "feature", + "repeat": 1, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 27.466328620910645, + "cost": null, + "tokens": 19127, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "5e6371581a5f9155981c9cf2ab8992d47466022fa27c2cca242d3ee0e5d32305", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "conflict-2-baseline", + "task": "conflict", + "repeat": 2, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 69.0713438987732, + "cost": null, + "tokens": 26134, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "38064006601445609f11fb7420cc7d388664acc6730783b1ff4875103f1e34ad", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "worker ID reused for a different request", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "recovery-1-openhands", + "task": "recovery", + "repeat": 1, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 34.83427619934082, + "cost": null, + "tokens": 19731, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "b7bc052f4ac6eb8840411e0fdcab5303dcec5cb6ea5e49da40a6867c3e0c3b0f", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "parallel-1-deepagents", + "task": "parallel", + "repeat": 1, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 48.68803834915161, + "cost": null, + "tokens": 17373, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "a6dac406b466c6e0909c9a94dfa97aaaf683095ff0e263d41e73e8cdcc02f89b", + "tree_sha256": "5815a6cfc0893b78a6ef8e41f5e2b06f1c6f98107eea96a035b1e072dffd3030", + "refusal_reason": "SDK process failed; inspect private run logs", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs" + ], + "patch_sha256": "88d46d18d6b6fd27e6b5d3f70d9235829baf1912195f8e526a9855b8ad7431e4" + }, + { + "id": "bug-1-baseline", + "task": "bug", + "repeat": 1, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 53.217729330062866, + "cost": null, + "tokens": 25949, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "c4c00c7ccec06f2648d346e4cfdae5abba344fb30a2ae964143579a0127a835f", + "tree_sha256": "e09591ef27a883056d24386c71be3812aaa447c43ee802e140209cfbb24c0b22", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "8e309673e8274eed4fb067161a768ac22d66088bc7ac49c637b39aa15884c767" + }, + { + "id": "omega-1-baseline", + "task": "omega", + "repeat": 1, + "arm": "baseline", + "accepted": true, + "gates_passed": true, + "seconds": 33.17686057090759, + "cost": null, + "tokens": 20207, + "reserved_tokens": 0, + "judge_exit_code": 0, + "error": null, + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "5fd8e9441917dc51cdef997fa4e71c391be877f72fa33e9d0815addc21823e77", + "tree_sha256": "e90ac4f2741c0199cd8ef7d8bf3a6f4480dae00d4972bca92690133a12855c68", + "refusal_reason": null, + "failure_kind": "accepted", + "gateway_refusal_reasons": [], + "patch_sha256": "cddec5c04efc2ee2448fdc26bef6875fb5b6c0b2084743db549a820f6d886449" + }, + { + "id": "recovery-2-deepagents", + "task": "recovery", + "repeat": 2, + "arm": "deepagents", + "accepted": false, + "gates_passed": false, + "seconds": 51.31468462944031, + "cost": null, + "tokens": 9575, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "c19eb629ed628308030bebba13acd6a8fbbc4f1e90480b562669f43a6f1ac103", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "SDK process failed; inspect private run logs", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "parallel-2-openhands", + "task": "parallel", + "repeat": 2, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 35.34184908866882, + "cost": null, + "tokens": 23457, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "ce430d7008e430d92c8bd312c2ee6ed3c2619ac4578093c56e8d8aa6d430304d", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "recovery-2-baseline", + "task": "recovery", + "repeat": 2, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 55.799922943115234, + "cost": null, + "tokens": 25801, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "620fd2058271da2202a28366689260dd8c9dde35ba441681bdfc36c301566850", + "tree_sha256": "ba35599c1ccebe310f9cbbf2540e7196ae09ccdc7dd635be64d9e98a2a19ea13", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "9e0459e4532c5dfc80c28d7232af8778d3ff42b2bc83bb38178e76ea6b424b8c" + }, + { + "id": "omega-2-baseline", + "task": "omega", + "repeat": 2, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 37.240476846694946, + "cost": null, + "tokens": 24549, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "d64c22c08d50e8a2c5126e832891b668cb2ce833ca3ee649a7f28d432a7de2e7", + "tree_sha256": "ccb26d81a8eaa1f5b57d376a49e2baefa2e5c91e29c41dcbd880d9bcb23c5df1", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "worker ID reused for a different request", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "conflict-1-openhands", + "task": "conflict", + "repeat": 1, + "arm": "openhands", + "accepted": false, + "gates_passed": false, + "seconds": 31.326399087905884, + "cost": null, + "tokens": 19508, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "1536e71c9f6b4ff888aaaf59528d7d004c7b488cc00397792bb37cc25716a4f2", + "tree_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted", + "SDK process failed; inspect private run logs", + "token budget exhausted" + ], + "patch_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "id": "recovery-1-baseline", + "task": "recovery", + "repeat": 1, + "arm": "baseline", + "accepted": false, + "gates_passed": false, + "seconds": 68.73276257514954, + "cost": null, + "tokens": 26321, + "reserved_tokens": 0, + "judge_exit_code": null, + "error": "Refused", + "image": "python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b", + "qualification_sha256": "af5c501437fd2d68db1186dc2643cc3958cc8cbc65665bb768adcce33c1a9cdb", + "judge_sha256": "9e545fda6155e9c313c7062569fe030465936889aa7530ccdad02f8e7c90ee04", + "source_sha256": "bf5be0a66b7cadad8982efbdee799a2086094b0f823ae19eccb0dec11bcf62ea", + "model": "openai-codex/gpt-5.6-sol", + "config_sha256": "64576d1ff10324a2c7a8504fe9051087b68331d8e82e624874602145b6b2f6a1", + "tree_sha256": "0d0f06f3352027bf43801e01b44428a18adf2519b9b0599700c56375e1978ac4", + "refusal_reason": "token budget exhausted", + "failure_kind": "budget_admission_refused", + "gateway_refusal_reasons": [ + "token budget exhausted" + ], + "patch_sha256": "8c2b03e8c2f577557d73e42d4fe243402b66146fb73174ed4bda566277d88832" + } + ], + "qualification": { + "unit_checks": true, + "live": { + "conductor_write_refused": true, + "judge_not_visible_during_generation": true, + "credential_store_not_visible": true, + "offline_command_network": true, + "timed_out_command_stopped": true, + "claimed_write_works": true, + "unclaimed_write_refused": true + }, + "acceptance": [ + { + "task": "bug", + "passed": true + }, + { + "task": "feature", + "passed": true + }, + { + "task": "omega", + "passed": true + }, + { + "task": "parallel", + "passed": true + }, + { + "task": "conflict", + "passed": true + }, + { + "task": "recovery", + "passed": true + } + ] + }, + "selection": { + "winner": "baseline", + "summary": { + "baseline": { + "accepted": 2, + "cost_per_accepted": null, + "seconds": 570.8195383548737, + "gates": false + }, + "deepagents": { + "accepted": 3, + "cost_per_accepted": null, + "seconds": 629.5164201259613, + "gates": false + }, + "openhands": { + "accepted": 0, + "cost_per_accepted": null, + "seconds": 381.5290048122406, + "gates": false + } + }, + "reason": "pilot selection only; not a general performance claim" + } +} diff --git a/coder/swarm-pilot/gateway.py b/coder/swarm-pilot/gateway.py new file mode 100644 index 0000000..3031a3d --- /dev/null +++ b/coder/swarm-pilot/gateway.py @@ -0,0 +1,132 @@ +"""Budgeted loopback proxy reusing OMP's authenticated provider gateway.""" +import json +import os +import secrets +import signal +import subprocess +import threading +import time +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +from runtime import Refused + +class Gateway: + def __init__(self, session, model, tool_handler=None): + self.session, self.model, self.tool_handler = session, model, tool_handler + self.token = secrets.token_hex(24) + self.lock = threading.Lock() + self.closing=threading.Event();self.providers=set() + parent = self + class Handler(BaseHTTPRequestHandler): + def log_message(self, *args): pass + def do_POST(self): + if self.headers.get('Authorization') != 'Bearer '+parent.token: + self.send_error(401); return + try: + n = int(self.headers.get('Content-Length', '0')) + if not 0 < n <= 2_000_000: raise Refused('request size refused') + body = json.loads(self.rfile.read(n)) + if self.path == '/tool': + response = parent.tool_handler(body) + elif self.path in ('/v1/chat/completions','/v1/responses'): + stream = bool(body.get('stream')) + body['stream'] = False + response = parent.complete(body,self.path) + if stream: + self.send_response(200); self.send_header('Content-Type','text/event-stream'); self.end_headers() + choice=response['choices'][0]; delta=dict(choice['message']); delta.pop('role',None) + for i,t in enumerate(delta.get('tool_calls',[])): t['index']=i + chunk=dict(id=response.get('id','pilot'),object='chat.completion.chunk',created=int(time.time()),model=parent.model,choices=[dict(index=0,delta=delta,finish_reason=None)]) + self.wfile.write(('data: '+json.dumps(chunk)+'\n\n').encode()) + chunk['choices']=[dict(index=0,delta={},finish_reason=choice.get('finish_reason','stop'))];chunk['usage']=response.get('usage') + self.wfile.write(('data: '+json.dumps(chunk)+'\n\ndata: [DONE]\n\n').encode());return + else: raise Refused('route refused') + payload = json.dumps(response).encode() + self.send_response(200); self.send_header('Content-Type','application/json') + self.send_header('Content-Length',str(len(payload))); self.end_headers(); self.wfile.write(payload) + except Exception as e: + # No provider exception text or credentials enter agent-visible output. + reason=str(e) if isinstance(e,Refused) else type(e).__name__ + with parent.session.transaction('gateway_refusal') as state: state['last_refusal']=dict(path=self.path,reason=reason) + payload=json.dumps({'error':{'message':reason,'type':'pilot_refusal'}}).encode() + self.send_response(400); self.send_header('Content-Type','application/json'); self.end_headers(); self.wfile.write(payload) + self.server = ThreadingHTTPServer(('127.0.0.1',0), Handler) + self.server.daemon_threads = False + self.url = 'http://127.0.0.1:'+str(self.server.server_port) + self.thread = threading.Thread(target=self.server.serve_forever,daemon=True) + self.thread.start() + + def close(self): + self.closing.set() + self.server.shutdown() + with self.lock: + for p in list(self.providers): + if p.poll() is None: + try:os.killpg(p.pid,signal.SIGKILL) + except ProcessLookupError:pass + self.server.server_close();self.thread.join() + + def provider_call(self,request,timeout): + with self.lock: + if self.closing.is_set():raise Refused('gateway closing') + p=subprocess.Popen(['omp','auth-gateway','stdio'],stdin=subprocess.PIPE, + stdout=subprocess.PIPE,stderr=subprocess.PIPE,text=True,start_new_session=True) + self.providers.add(p) + start=time.time();first=True + try: + while True: + if self.closing.is_set() or self.session.status()['cancelled'] or time.time()-start>=timeout: + raise Refused('in-flight request cancelled or timed out; reservation retained') + try: + stdout,stderr=p.communicate(json.dumps(request)+'\n' if first else None,timeout=1) + return type('Reply',(),dict(returncode=p.returncode,stdout=stdout))() + except subprocess.TimeoutExpired:first=False + finally: + if p.poll() is None: + try:os.killpg(p.pid,signal.SIGKILL) + except ProcessLookupError:pass + p.communicate() + with self.lock:self.providers.discard(p) + + def complete(self, body, path="/v1/chat/completions"): + body = dict(body) + if body.get('stream'): raise Refused('pilot requires nonstreaming accounting') + if body.get('model') != self.model: raise Refused('model must match frozen pin') + body.pop('max_completion_tokens',None) + body['max_tokens'] = min(int(body.get('max_tokens',1024)),1024) + if body['max_tokens'] <= 0: raise Refused('invalid completion limit') + body['stream'] = False + if path == '/v1/responses': + body['max_output_tokens']=body.pop('max_tokens') + body['reasoning']={'effort':'low'} + else: body['reasoning_effort']='low' + # UTF-8 bytes plus protocol allowance conservatively reserve visible-input + # tokens. Provider usage is mandatory and must fit this reservation. + serialized=json.dumps(body,ensure_ascii=False) + try: + import tiktoken + count=len(tiktoken.get_encoding('o200k_base').encode(serialized)) + except ImportError: + count=len(serialized.encode()) + bound=count+2048+body.get('max_tokens',body.get('max_output_tokens',1024)) + ticket = self.session.reserve(bound) + remaining = self.session.status()['deadline']-time.time() + started = time.time() + request = dict(id=1,path=path,body=body) + proc = self.provider_call(request,max(.01,min(180,remaining))) + replies=[] + for line in proc.stdout.splitlines(): + try: + d=json.loads(line) + if d.get('id') == 1 and 'status' in d: replies.append(d) + except (ValueError,AttributeError): continue + if proc.returncode or len(replies)!=1 or replies[0]['status']!=200: + raise Refused('provider transport failed; reservation retained') + result=replies[0]['body'] + usage=result.get('usage',{}).get('total_tokens') + self.session.settle(ticket,usage) + record=dict(at=started,seconds=time.time()-started,request=body,response=result,usage=usage) + with self.lock: + with (self.session.root/'trace.jsonl').open('a') as f: + f.write(json.dumps(record)+'\n'); f.flush(); os.fsync(f.fileno()) + self.session.active(self.session.status()) + return result diff --git a/coder/swarm-pilot/judge.py b/coder/swarm-pilot/judge.py new file mode 100644 index 0000000..ed9697b --- /dev/null +++ b/coder/swarm-pilot/judge.py @@ -0,0 +1,67 @@ +"""Independent acceptance oracle. Execute only in an offline judge container.""" +import importlib.util +import json +from pathlib import Path +import subprocess +import sys + +root=Path(sys.argv[2]);task=sys.argv[1] +sys.path.insert(0,str(root)) +def load(name): + spec=importlib.util.spec_from_file_location(name,root/(name+'.py')) + m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);return m + +if task=='smoke': + assert (root/'hello.txt').read_text()=='ready\n' +elif task=='omega': + binary=subprocess.run(['omc'],input=(root/'program.om').read_bytes(),capture_output=True,check=True,timeout=20).stdout + Path('/tmp/program').write_bytes(binary);Path('/tmp/program').chmod(0o700) + p=subprocess.run(['/tmp/program'],capture_output=True,timeout=5) + assert p.returncode==55 and p.stdout==b'' +else: + m=load('pilot') + # Preserve baseline behavior as well as implementing the requested feature. + regression=m.Claims();regression.acquire('first',['src']) + try:regression.acquire('second',['src/file']) + except ValueError:pass + else:raise AssertionError('baseline overlap protection regressed') + assert set(regression.owners)=={'first'} + regression.release('first');regression.acquire('next',['src']) + rows=m.matrix(['a','b','c','d','e','f']) + expected={(t,n,a) for t in ['a','b','c','d','e','f'] for n in (1,2) for a in ('baseline','deepagents','openhands')} + assert len(rows)==36 and {(r['task'],r['repeat'],r['arm']) for r in rows}==expected + assert len({r['id'] for r in rows})==36 + + assert m.select([])['winner']=='baseline' + + if task=='bug': + for bad in ['../x','a/b','a\\b','x y','a\nb',None,3,{},'']: + try:m.matrix(['a','b','c','d','e',bad]) + except (ValueError,TypeError):pass + else:raise AssertionError('invalid task ID admitted') + elif task in ('feature','parallel'): + c=m.Claims();c.acquire('b',['src']);c.acquire('a',['docs']) + assert c.release_all()==['a','b'] and c.release_all()==[] + c.acquire('b',['src']) + if task=='parallel': + v=load('sandbox').valid_image + assert v('registry/image@sha256:'+'a'*64) + for bad in [None,1,'x','x@sha256:'+'A'*64,'x@sha256:'+'a'*63,'x,y@sha256:'+'a'*64,' x@sha256:'+'a'*64]:assert v(bad) is False + elif task=='conflict': + c=m.Claims();c.acquire('old',['keep']) + try:c.acquire_many({'a':['src'],'b':['src/main']}) + except ValueError:pass + else:raise AssertionError('overlap admitted') + assert list(c.owners)==['old'] + c.acquire_many({'a':['src'],'b':['docs']});assert set(c.owners)=={'old','a','b'} + elif task=='recovery': + c=m.Claims();c.acquire('a',['src']);c.acquire('b',['docs']) + text=c.to_json();assert set(c.owners)=={'a','b'} + d=m.Claims.from_json(text);assert set(c.owners)=={'a','b'} + assert json.loads(d.to_json())=={'a':['src'],'b':['docs']} + for bad in ['[]','null','{"a":["src"],"b":["src/x"]}','{"a":["../x"]}']: + try:m.Claims.from_json(bad) + except (ValueError,TypeError):pass + else:raise AssertionError('invalid restored claims') + else:raise AssertionError('unknown task') +print('PASS',task) diff --git a/coder/swarm-pilot/live_controls.py b/coder/swarm-pilot/live_controls.py new file mode 100644 index 0000000..349cea0 --- /dev/null +++ b/coder/swarm-pilot/live_controls.py @@ -0,0 +1,32 @@ +"""Exercise real Docker boundaries. These are qualification checks, not performance scores.""" +import argparse +import hashlib +import json +from pathlib import Path +import tempfile +import shlex +from sandbox import Sandbox +from runtime import write_json + +def run(config,output): + with tempfile.TemporaryDirectory(prefix='pilot-controls-') as directory: + root=Path(directory);(root/'owned.txt').write_text('original') + ro=Sandbox(root,config['image'],writable=[]) + checks={ + 'conductor_write_refused':ro.execute('echo bad > /work/owned.txt')['exit_code']!=0, + 'judge_not_visible_during_generation':ro.execute('test ! -e /judge.py')['exit_code']==0, + 'credential_store_not_visible':ro.execute('test ! -e '+shlex.quote(str(Path.home()/'.omp'/'agent'/'agent.db')))['exit_code']==0, + 'offline_command_network':ro.execute("python -c 'import socket; s=socket.socket(); s.settimeout(1); s.connect((\"1.1.1.1\",443))'")['exit_code']!=0, + 'timed_out_command_stopped':ro.execute('sleep 20',seconds=1)['exit_code']==124, + } + rw=Sandbox(root,config['image'],writable=['owned.txt']) + checks['claimed_write_works']=rw.execute('printf changed > owned.txt')['exit_code']==0 and (root/'owned.txt').read_text()=='changed' + checks['unclaimed_write_refused']=rw.execute('printf bad > outside.txt')['exit_code']!=0 + code_hash=hashlib.sha256(b''.join(p.read_bytes() for p in sorted(Path(__file__).parent.glob('*.py')))).hexdigest() + report=dict(checks=checks,passed=all(checks.values()),source_sha256=code_hash) + write_json(Path(output),report);print(json.dumps(report,indent=2)) + if not report['passed']:raise SystemExit(1) + +if __name__=='__main__': + p=argparse.ArgumentParser();p.add_argument('config',type=Path);p.add_argument('output',type=Path) + a=p.parse_args();run(json.loads(a.config.read_text()),a.output) diff --git a/coder/swarm-pilot/pilot.py b/coder/swarm-pilot/pilot.py new file mode 100644 index 0000000..9c999cd --- /dev/null +++ b/coder/swarm-pilot/pilot.py @@ -0,0 +1,102 @@ +"""Experimental pilot control plane. No benchmark results are synthesized.""" +import argparse +import json +import math +from pathlib import PurePosixPath, Path + +ARMS = ('baseline', 'deepagents', 'openhands') + +class Claims: + def __init__(self): + self.owners = {} + + def acquire(self, owner, paths): + if not owner or owner in self.owners or not paths: + raise ValueError('owner must be new and paths nonempty') + checked = [] + for value in paths: + p = PurePosixPath(value) + if p.is_absolute() or '..' in p.parts or str(p) == '.': + raise ValueError('claims must be relative paths without traversal') + for existing in [*checked, *(q for ps in self.owners.values() for q in ps)]: + if p == existing or p in existing.parents or existing in p.parents: + raise ValueError('overlapping ownership claim') + checked.append(p) + self.owners[owner] = checked + + def release(self, owner): + del self.owners[owner] + + +def matrix(tasks): + if len(tasks) != 6 or len(set(tasks)) != 6: + raise ValueError('six distinct frozen tasks required') + return [dict(id=f'{task}-{repeat}-{arm}', task=task, repeat=repeat, arm=arm, + seconds_limit=1200, token_limit=30000, max_workers=3) + for task in tasks for repeat in (1, 2) for arm in ARMS] + + +def select(rows): + summary = {} + ids = [r['id'] for r in rows] + if len(rows) != 36 or len(set(ids)) != 36: + return dict(winner='baseline', reason='incomplete or duplicate evidence') + if not all('task' in r and 'repeat' in r for r in rows): + return dict(winner='baseline',reason='missing task/repetition evidence') + if rows: + tasks={r.get('task') for r in rows} + expected={(t,n,a) for t in tasks for n in (1,2) for a in ARMS} + actual={(r.get('task'),r.get('repeat'),r.get('arm')) for r in rows} + if len(tasks)!=6 or actual!=expected: + return dict(winner='baseline',reason='task/repetition pairs do not match') + for key in ('model','image','qualification_sha256','judge_sha256'): + values={r.get(key) for r in rows} + if len(values)!=1 or not next(iter(values)): + return dict(winner='baseline',reason='missing or mixed '+key) + for task in tasks: + if len({r.get('source_sha256') for r in rows if r['task']==task})!=1 or any(not r.get('source_sha256') for r in rows if r['task']==task): + return dict(winner='baseline',reason='missing or mixed task source') + for arm in ARMS: + group = [r for r in rows if r['arm'] == arm] + if len(group) != 12: + return dict(winner='baseline', reason='unbalanced evidence') + for r in group: + if type(r.get('accepted')) is not bool or type(r.get('gates_passed')) is not bool: + raise ValueError('acceptance and gates require explicit booleans') + for key in ('seconds', 'cost'): + v = r.get(key) + if v is None and key == 'cost': continue + if type(v) not in (int, float) or not math.isfinite(v) or v < 0: + raise ValueError('invalid measurement') + accepted = sum(r['accepted'] for r in group) + cost = None if any(r.get('cost') is None for r in group) or not accepted else sum(r['cost'] for r in group)/accepted + summary[arm] = dict(accepted=accepted, cost_per_accepted=cost, + seconds=sum(r['seconds'] for r in group), + gates=all(r['gates_passed'] for r in group)) + base = summary['baseline'] + qualified = [] + for arm in ARMS[1:]: + s = summary[arm] + cheaper = (s['accepted'] == base['accepted'] and s['accepted'] > 0 + and s['cost_per_accepted'] is not None + and base['cost_per_accepted'] is not None + and base['cost_per_accepted'] > 0 + and s['cost_per_accepted'] <= .8 * base['cost_per_accepted']) + if s['gates'] and (s['accepted'] >= base['accepted'] + 2 or cheaper): + qualified.append(arm) + qualified.sort(key=lambda a: (-summary[a]['accepted'], + summary[a]['cost_per_accepted'] if summary[a]['cost_per_accepted'] is not None else float('inf'), + summary[a]['seconds'], a)) + return dict(winner=qualified[0] if qualified else 'baseline', summary=summary, + reason='pilot selection only; not a general performance claim') + + +def main(): + p = argparse.ArgumentParser() + p.add_argument('command', choices=['matrix', 'select']) + p.add_argument('input', type=Path) + a = p.parse_args() + data = json.loads(a.input.read_text()) + print(json.dumps(matrix(data) if a.command == 'matrix' else select(data), indent=2)) + +if __name__ == '__main__': main() diff --git a/coder/swarm-pilot/requirements-deepagents.lock b/coder/swarm-pilot/requirements-deepagents.lock new file mode 100644 index 0000000..e98fe04 --- /dev/null +++ b/coder/swarm-pilot/requirements-deepagents.lock @@ -0,0 +1,60 @@ +annotated-types==0.8.0 +anthropic==2.6.0 +anyio==4.16.0 +bracex==3.2.2 +certifi==2026.10.23 +cffi==2.1.1 +charset-normalizer==3.5.2 +cryptography==50.0.2 +deepagents==0.7.34 +distro==1.9.0 +docstring_parser==0.18.0 +filetype==1.2.0 +google-auth==2.62.1 +google-genai==3.0.0 +h11==0.16.0 +httpcore==1.0.9 +httpcore2==2.16.0 +httpx==0.28.1 +httpx2==2.16.0 +idna==3.20 +jiter==0.19.0 +jsonpatch==1.44 +jsonpointer==3.10 +langchain==1.4.9 +langchain-anthropic==1.7.10 +langchain-core==1.7.6 +langchain-google-genai==4.4.3 +langchain-openai==1.7.4 +langchain-protocol==0.0.21 +langgraph==1.2.20 +langgraph-checkpoint==4.3.1 +langgraph-prebuilt==1.1.1 +langgraph-sdk==0.4.14 +langsmith==0.14.17 +openai==3.46.0 +opentelemetry-api==1.45.2 +orjson==3.13.0 +ormsgpack==1.13.0 +packaging==26.3 +pyasn1==0.6.5 +pyasn1_modules==0.4.2 +pycparser==3.12 +pydantic==2.14.3 +pydantic_core==2.50.4 +PyYAML==6.0.3 +regex==2026.11.7 +requests==2.34.2 +requests-toolbelt==1.0.0 +sniffio==1.3.1 +tenacity==9.1.4 +tiktoken==0.14.0 +truststore==0.10.5 +typing-inspection==0.4.5 +typing_extensions==4.16.0 +urllib3==2.8.0 +uuid_utils==0.19.0 +wcmatch==12.0.1 +websockets==17.4 +xxhash==4.0.2 +zstandard==0.25.0 diff --git a/coder/swarm-pilot/requirements-deepagents.txt b/coder/swarm-pilot/requirements-deepagents.txt new file mode 100644 index 0000000..3f460f6 --- /dev/null +++ b/coder/swarm-pilot/requirements-deepagents.txt @@ -0,0 +1,2 @@ +deepagents==0.7.34 +langchain-openai==1.7.4 diff --git a/coder/swarm-pilot/requirements-openhands.lock b/coder/swarm-pilot/requirements-openhands.lock new file mode 100644 index 0000000..ead1fdd --- /dev/null +++ b/coder/swarm-pilot/requirements-openhands.lock @@ -0,0 +1,191 @@ +agent-client-protocol==0.12.1 +aiofile==3.12.3 +aiofiles==25.1.0 +aiohappyeyeballs==2.7.1 +aiohttp==3.14.3 +aiosignal==1.4.0 +annotated-doc==0.0.5 +annotated-types==0.8.0 +anthropic==0.76.0 +anyio==4.12.1 +attrs==26.1.0 +Authlib==1.9.5 +backoff==2.2.1 +beartype==0.23.1 +beautifulsoup4==4.15.0 +binaryornot==0.6.0 +blake3==1.0.11 +boto3==1.43.126 +botocore==1.43.126 +browser-harness==0.1.12 +browser-use==0.13.9 +browser-use-sdk==3.4.2 +bubus==1.5.6 +cachetools==8.0.0 +caio==0.12.10 +cdp-use==1.4.5 +certifi==2026.10.23 +cffi==2.1.1 +charset-normalizer==3.5.2 +click==8.3.3 +cloudpickle==3.1.2 +cryptography==50.0.2 +cyclopts==5.3.3 +deprecation==2.1.0 +distro==1.9.0 +dnspython==2.9.2 +docstring_parser==0.18.0 +email-validator==2.3.0 +exceptiongroup==1.3.1 +fakeredis==2.40.0 +fastmcp==3.4.11 +fastmcp-slim==3.4.11 +fastuuid==0.14.0 +fetch-use==0.4.0 +filelock==3.32.7 +frozenlist==1.8.0 +fsspec==2026.9.0 +func_timeout==4.3.5 +google-api-core==2.29.0 +google-api-python-client==2.188.0 +google-auth==2.48.0 +google-auth-httplib2==0.4.4 +google-auth-oauthlib==1.2.4 +google-genai==1.65.0 +googleapis-common-protos==1.76.0 +griffelib==2.4.1 +groq==1.0.0 +grpcio==1.85.1 +h11==0.16.0 +h2==4.4.1 +hf-xet==1.8.0 +hpack==4.2.0 +httpcore==1.0.9 +httplib2==0.32.1 +httpx==0.28.1 +httpx-sse==0.4.3 +huggingface_hub==1.16.1 +hyperframe==6.1.0 +idna==3.20 +importlib_metadata==8.9.0 +inquirerpy==0.3.4 +jaraco.classes==3.4.0 +jaraco.context==6.1.2 +jaraco.functools==4.6.0 +jeepney==0.9.0 +Jinja2==3.1.6 +jiter==0.19.0 +jmespath==1.1.0 +joserfc==1.8.0 +json_repair==0.64.6 +jsonref==1.1.0 +jsonschema==4.26.0 +jsonschema-path==0.5.0 +jsonschema-specifications==2025.9.1 +keyring==25.7.0 +libtmux==0.62.0 +litellm==1.105.7 +lmnr==0.7.67 +lmnr-claude-code-proxy==0.2.0 +lupa==2.8 +lxml==6.1.3 +markdown-it-py==4.2.0 +markdownify==1.2.2 +MarkupSafe==3.0.4 +mcp==1.28.1 +mdurl==0.1.2 +more-itertools==11.2.1 +multidict==6.9.1 +oauthlib==4.0.1 +ollama==0.6.1 +openai==2.26.0 +openapi-pydantic==0.6.0 +openhands-sdk==1.60.2 +openhands-tools==1.60.2 +opentelemetry-api==1.45.2 +opentelemetry-exporter-http-transport==0.66b2 +opentelemetry-exporter-otlp-common==0.66b2 +opentelemetry-exporter-otlp-proto-common==1.45.2 +opentelemetry-exporter-otlp-proto-grpc==1.45.2 +opentelemetry-exporter-otlp-proto-http==1.45.2 +opentelemetry-instrumentation==0.66b2 +opentelemetry-instrumentation-threading==0.66b2 +opentelemetry-proto==1.45.2 +opentelemetry-sdk==1.45.2 +opentelemetry-semantic-conventions==0.66b2 +opentelemetry-semantic-conventions-ai==0.4.13 +orjson==3.13.0 +packaging==26.3 +pathable==0.6.0 +pfzy==0.3.4 +pillow==12.3.0 +platformdirs==4.14.5 +portalocker==4.4.2 +posthog==7.7.0 +prompt_toolkit==3.0.53 +propcache==0.5.4 +proto-plus==1.29.0 +protobuf==6.33.6 +psutil==7.2.2 +py-key-value-aio==0.4.6 +pyasn1==0.6.5 +pyasn1_modules==0.4.2 +pycparser==3.12 +pydantic==2.13.5 +pydantic-settings==2.16.2 +pydantic_core==2.46.5 +Pygments==2.21.0 +PyJWT==2.15.1 +pyotp==2.9.0 +pyparsing==3.3.3 +pypdf==6.15.0 +pyperclip==1.11.0 +python-dateutil==2.9.0.post0 +python-docx==1.2.0 +python-dotenv==1.2.2 +python-frontmatter==1.3.0 +python-json-logger==4.2.0 +python-multipart==0.0.33 +PyYAML==6.0.3 +redis==8.1.0 +referencing==0.37.0 +regex==2026.11.7 +reportlab==4.4.9 +requests==2.33.0 +requests-oauthlib==2.0.0 +rich==14.3.3 +rich-rst==2.2.0 +rpds-py==2026.9.1 +rsa==4.9.1 +s3transfer==0.19.3 +screeninfo==0.8.1 +SecretStorage==3.5.0 +shellingham==1.5.4 +six==1.17.0 +sniffio==1.3.1 +socksio==1.0.0 +sortedcontainers==2.4.0 +soupsieve==4.0.1 +sse-starlette==3.7.0 +starlette==1.10.0 +tenacity==9.1.4 +tiktoken==0.14.0 +tokenizers==0.23.3 +tom-swe==1.0.3 +tqdm==4.70.1 +tree-sitter==0.26.0 +tree-sitter-bash==0.25.1 +typer==0.28.0 +typing-inspection==0.4.5 +typing_extensions==4.15.0 +uncalled-for==0.6.0 +uritemplate==4.2.0 +urllib3==2.8.0 +uuid7==0.1.0 +uvicorn==0.54.0 +watchfiles==1.3.0 +wcwidth==0.9.4 +websockets==15.0.1 +wrapt==1.17.3 +yarl==1.25.1 +zipp==4.1.2 diff --git a/coder/swarm-pilot/requirements-openhands.txt b/coder/swarm-pilot/requirements-openhands.txt new file mode 100644 index 0000000..1c96477 --- /dev/null +++ b/coder/swarm-pilot/requirements-openhands.txt @@ -0,0 +1,2 @@ +openhands-sdk==1.60.2 +openhands-tools==1.60.2 diff --git a/coder/swarm-pilot/runner.py b/coder/swarm-pilot/runner.py new file mode 100644 index 0000000..1909b46 --- /dev/null +++ b/coder/swarm-pilot/runner.py @@ -0,0 +1,207 @@ +"""Single-host bounded conductor with isolated SDK processes and independent judges.""" +import argparse +import hashlib +import json +import os +from pathlib import Path +import signal +import subprocess +import tempfile +import shlex +import fcntl +import threading +import shutil +import time +from gateway import Gateway +from runtime import Session,Refused,snapshot,write_json +from sandbox import Sandbox + +HERE=Path(__file__).resolve().parent + +def digest(value): return hashlib.sha256(json.dumps(value,sort_keys=True).encode()).hexdigest() + +def export_patch(before,after,output): + """Portable binary-capable patch, derived without trusting worker Git metadata.""" + with tempfile.TemporaryDirectory(prefix='pilot-patch-') as directory: + temp=Path(directory) + shutil.copytree(before,temp/'a');shutil.copytree(after,temp/'b') + with Path(output).open('wb') as f: + result=subprocess.run(['git','-c','color.ui=never','diff','--no-index','--binary','--no-prefix', + '--no-ext-diff','--no-textconv','--','a','b'],cwd=temp,stdout=f, + stderr=subprocess.PIPE,timeout=30) + if result.returncode not in (0,1):raise Refused('patch export failed') + +class Runner: + def __init__(self,session,config): + self.s,self.config=session,config + self.arm=config['arm'];self.processes=set() + self.worker_locks={};self.worker_locks_guard=threading.Lock() + self.gateway=Gateway(session,config['model'],self.tool) + self.label=digest(str(session.root))[:20] + + def close(self): + for p in list(self.processes): + if p.poll() is None: + try:os.killpg(p.pid,signal.SIGKILL) + except ProcessLookupError:pass + ids=subprocess.run(['docker','ps','-aq','--filter','label=aien.pilot='+self.label],capture_output=True,text=True,timeout=15).stdout.split() + if ids:subprocess.run(['docker','rm','-f',*ids],capture_output=True,timeout=30) + self.gateway.close() + + def tool(self,request): + self.s.active(self.s.status()) + owner,name,args=request['owner'],request['name'],request['arguments'] + state=self.s.status() + if owner!='conductor' and (owner not in state['workers'] or state['workers'][owner]['state']!='running'): + raise Refused('worker does not hold active authority') + if name=='execute': + tree=self.s.current if owner=='conductor' else self.s.root/'workers'/owner + writable=[] if owner=='conductor' else state['workers'][owner]['paths'] + remaining=max(1,min(120,state['deadline']-time.time())) + try: + result=Sandbox(tree,self.config['image'],writable=writable,label=self.label,compiler=self.config.get("compiler")).execute(args['command'],remaining) + except Exception as e: + self.s.cancel() + raise Refused('sandbox lifecycle failed; session cancelled') from e + with self.s.transaction('tool_result') as s: + s['last_tool']={'owner':owner,'exit_code':result['exit_code']} + return result + if name!='delegate' or owner!='conductor': raise Refused('workers cannot delegate') + worker,paths,instruction=args['owner'],args['paths'],args['instruction'] + if worker=='conductor': raise Refused('reserved actor name') + allowed=self.config['allowed_paths'] + if not paths or any(p not in allowed for p in paths): raise Refused('claim outside task allowlist') + with self.worker_locks_guard: + lock=self.worker_locks.setdefault(worker,threading.Lock()) + with lock: + state=self.s.status() + existing=state['workers'].get(worker) + key=digest([paths,instruction]) + if existing: + if existing.get('request_key')!=key: raise Refused('worker ID reused for a different request') + if existing['state']=='integrated': return {'status':'already integrated','changed':existing['changed']} + else: + self.s.spawn(worker,paths,request_key=key) + prompt='You are a worker. You cannot delegate. All commands run in /work via POSIX /bin/sh. Use one-line shell commands with semicolons; do not encode command separators as literal backslash-n. Modify only '+json.dumps(paths)+'.\n'+instruction + self.agent(worker,prompt) + self.s.integrate(worker) + return {'status':'integrated','changed':self.s.status()['workers'][worker]['changed']} + + def agent(self,owner,prompt): + # SDK processes see system libraries, their own environment and this code; + # no home directory, credential DB, repository, Docker socket or judges. + with tempfile.TemporaryDirectory(prefix='pilot-sdk-') as temporary: + temp=Path(temporary) + env={k:os.environ[k] for k in ('PATH','LANG') if k in os.environ} + env.update(HOME='/tmp/home',PILOT_OWNER=owner,PILOT_MODEL=self.config['model'], + PILOT_GATEWAY_URL=self.gateway.url,PILOT_GATEWAY_TOKEN=self.gateway.token, + OPENHANDS_SUPPRESS_BANNER='1',PYTHONUNBUFFERED='1',DO_NOT_TRACK='1', + PI_CODING_AGENT_DIR='/tmp/profile',OPENAI_API_KEY=self.gateway.token) + wrapper=['bwrap','--ro-bind','/usr','/usr','--symlink','usr/lib','/lib', + '--symlink','usr/bin','/bin','--proc','/proc','--dev','/dev','--tmpfs','/tmp', + '--dir','/tmp/home','--unshare-pid','--die-with-parent', + '--dir','/pilot','--ro-bind',str(HERE/'adapters.py'),'/pilot/adapters.py', + '--ro-bind',str(HERE/'baseline.ts'),'/pilot/baseline.ts','--ro-bind',str(temp),'/input', + '--chdir','/tmp'] + if self.arm=='baseline': + profile={'providers':{'pilot':{'baseUrl':self.gateway.url+'/v1', + 'api':'openai-completions','apiKey':'PILOT_GATEWAY_TOKEN', + 'models':[{'id':self.config['model'],'name':'Frozen pilot model', + 'reasoning':False,'input':['text'],'contextWindow':131072,'maxTokens':1024}]}}} + (temp/'models.yml').write_text(json.dumps(profile)) + (temp/'prompt.txt').write_text(prompt) + omp=Path(self.config['omp']).resolve() + wrapper+=['--ro-bind',str(omp),'/omp'] + command=['/bin/sh','-c', + 'mkdir -p /tmp/profile; cp /input/models.yml /tmp/profile/models.yml; ' + 'exec /omp --model "pilot/$PILOT_MODEL" --print --mode json --no-session ' + '--no-extensions --no-skills --no-rules --no-context-files --no-lsp --no-title ' + '--tools '+('repo_command,delegate' if owner=='conductor' else 'repo_command')+ + ' -e /pilot/baseline.ts "$(cat /input/prompt.txt)"'] + data=None + else: + venv=Path(self.config['environments'][self.arm]).resolve() + wrapper+=['--ro-bind',str(venv),str(venv)] + command=[str(venv/'bin/python'),'/pilot/adapters.py'] + data=json.dumps({'arm':self.arm,'prompt':prompt}) + timeout=max(1,self.s.status()['deadline']-time.time()) + p=subprocess.Popen(wrapper+command,stdin=subprocess.PIPE,stdout=subprocess.PIPE, + stderr=subprocess.PIPE,text=True,env=env,start_new_session=True) + self.processes.add(p) + try: + first=True + while True: + self.s.active(self.s.status()) + try: + stdout,stderr=p.communicate(data if first else None,timeout=min(1,timeout)) + break + except subprocess.TimeoutExpired: + first=False + timeout=max(0,self.s.status()['deadline']-time.time()) + if timeout<=0: raise + (self.s.root/f'{owner}.stdout').write_text(stdout) + (self.s.root/f'{owner}.stderr').write_text(stderr) + if p.returncode: raise Refused('SDK process failed; inspect private run logs') + except subprocess.TimeoutExpired: + self.s.cancel();os.killpg(p.pid,signal.SIGKILL);p.communicate();raise Refused('run deadline exhausted') + finally: + if p.poll() is None: + os.killpg(p.pid,signal.SIGKILL);p.communicate() + self.processes.discard(p) + + def run(self): + prompt=('All commands run in /work via POSIX /bin/sh. Use one-line shell commands with semicolons; do not encode command separators as literal backslash-n. You are the conductor for this repository task. Use repo_command to read/check the repository. ' + 'The conductor workspace is read-only. Use delegate(owner, paths, instruction) for all edits. ' + 'Each worker owns exact allowed paths. At most three active workers; workers cannot delegate. ' + 'Use stable worker IDs and reuse the same ID for retries. Judge results are independent. ' + 'Do not claim success without actual checks.\nAllowed paths: '+json.dumps(self.config['allowed_paths'])+ + '\nTask:\n'+self.config['prompt']+'\nPrior durable worker state:\n'+json.dumps(self.s.status()['workers'])) + self.agent('conductor',prompt) + + +def _run(config,root,source): + root=Path(root) + if root.exists(): + session=Session(root) + if json.loads((root/'config.json').read_text())!=config: raise Refused('resume configuration changed') + if (root/'result.json').exists(): return json.loads((root/'result.json').read_text()) + else: + session=Session.create(root,source) + write_json(root/'config.json',config) + runner=Runner(session,config);start=time.time();error=None + # Remove orphan command containers from an interrupted owner before resuming. + ids=subprocess.run(['docker','ps','-aq','--filter','label=aien.pilot='+runner.label],capture_output=True,text=True,timeout=15).stdout.split() + if ids:subprocess.run(['docker','rm','-f',*ids],capture_output=True,timeout=30) + try:runner.run() + except Exception as e:error=type(e).__name__ + finally:runner.close() + state=session.status() + export_patch(source,session.current,root/'patch.diff') + # Never trust candidate-reported checks. The judge is outside all agent trees. + judged=None + if error is None and not state['cancelled'] and not state['reserved']: + remaining=state['deadline']-time.time() + judged=Sandbox(session.current,config['image'],writable=[],label=runner.label, + compiler=config.get('compiler'),judge=HERE/'judge.py').execute( + 'python /judge.py '+shlex.quote(config['task'])+' /work',max(.01,min(120,remaining))) + (root/'judge.stdout').write_text(judged['output']) + within_deadline=time.time()<=state['deadline'] + parallel_ok=(config['task']!='parallel' or sum(w['state']=='integrated' for w in state['workers'].values())>=2) + result=dict(id=config['id'],task=config['task'],repeat=config['repeat'],arm=config['arm'], + accepted=within_deadline and parallel_ok and judged is not None and judged['exit_code']==0 and judged['output'].strip()=='PASS '+config['task'],gates_passed=within_deadline and bool(config.get('qualification_sha256')) and error is None and not state['reserved'], + seconds=time.time()-(state['deadline']-1200),cost=None,tokens=state['tokens'],reserved_tokens=state['reserved'], + judge_exit_code=judged['exit_code'] if judged else None,error=error,image=config['image'],qualification_sha256=config.get('qualification_sha256'), + judge_sha256=config.get('judge_sha256'),source_sha256=config.get('source_sha256'),model=config['model'],config_sha256=digest(config),tree_sha256=digest(snapshot(session.current))) + write_json(root/'result.json',result) + return result + +def run(config,root,source): + root=Path(root) + with (root.parent/('.'+root.name+'.runner.lock')).open('a') as lease: + try:fcntl.flock(lease,fcntl.LOCK_EX|fcntl.LOCK_NB) + except BlockingIOError as e:raise Refused('another conductor owns this session') from e + return _run(config,root,source) + +if __name__=='__main__': + p=argparse.ArgumentParser();p.add_argument('config',type=Path);p.add_argument('source',type=Path);p.add_argument('output',type=Path) + a=p.parse_args();print(json.dumps(run(json.loads(a.config.read_text()),a.output,a.source),indent=2)) diff --git a/coder/swarm-pilot/runtime.py b/coder/swarm-pilot/runtime.py new file mode 100644 index 0000000..2989be5 --- /dev/null +++ b/coder/swarm-pilot/runtime.py @@ -0,0 +1,165 @@ +"""Durable, single-host pilot control plane. Candidate trees never contain this DB.""" +import hashlib +import json +import os +import re +import shutil +import sqlite3 +import stat +import time +import uuid +from contextlib import contextmanager +from pathlib import Path, PurePosixPath +from pilot import Claims + +class Refused(RuntimeError): + pass + + +def snapshot(root): + """Independent inventory: never trust a candidate's Git index or diff.""" + files = {} + total = 0 + for p in sorted(root.rglob('*')): + s = p.lstat() + if stat.S_ISLNK(s.st_mode): raise Refused('symlinks are outside pilot profile') + if stat.S_ISDIR(s.st_mode): continue + if not stat.S_ISREG(s.st_mode) or s.st_nlink != 1: + raise Refused('special files or hardlinks refused') + total += s.st_size + if len(files) >= 20000 or total > 100_000_000: raise Refused('snapshot limit exceeded') + files[p.relative_to(root).as_posix()] = (hashlib.sha256(p.read_bytes()).hexdigest(), s.st_mode & 0o777) + return files + + +def write_json(path, data): + temp = path.with_suffix('.tmp') + with temp.open('w') as f: + json.dump(data, f, indent=2); f.flush(); os.fsync(f.fileno()) + os.replace(temp, path) + + +class Session: + def __init__(self, root): + self.root = Path(root).resolve() + if not (self.root/'state.db').is_file(): raise Refused('session does not exist') + + @classmethod + def create(cls, root, source, *, seconds=1200, tokens=30000): + root, source = Path(root).resolve(), Path(source).resolve() + if root == source or root.is_relative_to(source): raise Refused('session must be outside source') + root.mkdir(mode=0o700) + (root/'trees').mkdir(); (root/'workers').mkdir() + snapshot(source) + shutil.copytree(source, root/'trees'/'initial') + c = sqlite3.connect(root/'state.db') + c.execute('PRAGMA journal_mode=WAL') + c.execute('CREATE TABLE state (id INTEGER PRIMARY KEY CHECK(id=1), body TEXT NOT NULL)') + c.execute('CREATE TABLE events (id INTEGER PRIMARY KEY, at REAL, kind TEXT, body TEXT)') + state = dict(current='initial', deadline=time.time()+seconds, limit=tokens, + tokens=0, reserved=0, tickets={}, workers={}, cancelled=False) + c.execute('INSERT INTO state VALUES(1,?)', (json.dumps(state),)); c.commit(); c.close() + return cls(root) + + @contextmanager + def transaction(self, kind): + c = sqlite3.connect(self.root/'state.db', timeout=30) + c.execute('PRAGMA synchronous=FULL'); c.execute('BEGIN IMMEDIATE') + try: + state = json.loads(c.execute('SELECT body FROM state WHERE id=1').fetchone()[0]) + yield state + c.execute('UPDATE state SET body=? WHERE id=1', (json.dumps(state),)) + c.execute('INSERT INTO events(at,kind,body) VALUES(?,?,?)', (time.time(),kind,json.dumps(state))) + c.commit() + except BaseException: + c.rollback(); raise + finally: c.close() + + def status(self): + c = sqlite3.connect(self.root/'state.db') + try: return json.loads(c.execute('SELECT body FROM state WHERE id=1').fetchone()[0]) + finally: c.close() + + @property + def current(self): return self.root/'trees'/self.status()['current'] + + def active(self, state): + if state['cancelled'] or time.time() >= state['deadline']: + raise Refused('session cancelled or expired') + + def spawn(self, owner, paths, request_key=None): + if not re.fullmatch('[a-zA-Z0-9_-]{1,48}', owner): raise Refused('invalid owner') + with self.transaction('spawn') as s: + self.active(s) + if owner in s['workers']: raise Refused('owner already exists') + active = {k:v for k,v in s['workers'].items() if v['state'] == 'running'} + if len(active) >= 3: raise Refused('three workers maximum') + claims = Claims() + try: + for k,v in active.items(): claims.acquire(k, v['paths']) + claims.acquire(owner, paths) + except ValueError as e: raise Refused(str(e)) from e + tree = self.root/'workers'/owner + # A crash before DB commit may leave an unadmitted tree. Never reuse it. + if tree.exists(): shutil.rmtree(tree) + shutil.copytree(self.root/'trees'/s['current'], tree) + s['workers'][owner] = dict(paths=paths, state='running', base=s['current'], request_key=request_key) + return tree + + def integrate(self, owner): + with self.transaction('integrate') as s: + self.active(s) + w = s['workers'][owner] + if w['state'] == 'integrated': return + if w['state'] != 'running': raise Refused('worker is not running') + base, candidate = self.root/'trees'/w['base'], self.root/'workers'/owner + before, after = snapshot(base), snapshot(candidate) + changed = [p for p in before.keys() | after.keys() if before.get(p) != after.get(p)] + for p in changed: + if not any(p == claim or PurePosixPath(claim) in PurePosixPath(p).parents for claim in w['paths']): + raise Refused('undeclared write: '+p) + current = self.root/'trees'/s['current']; current_files = snapshot(current) + if any(current_files.get(p) != before.get(p) for p in changed): + raise Refused('integration base changed') + version = uuid.uuid4().hex + staged = self.root/'trees'/version + shutil.copytree(current, staged) + for p in changed: + dest = staged/p + if p not in after: + dest.unlink() + else: + dest.parent.mkdir(parents=True, exist_ok=True) + shutil.copy2(candidate/p, dest) + snapshot(staged) + # Immutable tree first, transactional pointer switch last. A crash leaves + # an unreachable tree, never a partially applied canonical workspace. + for p in staged.rglob('*'): + if p.is_file(): + with p.open('rb') as f: os.fsync(f.fileno()) + for directory in [*(p for p in staged.rglob('*') if p.is_dir()), staged, staged.parent]: + fd = os.open(directory, os.O_RDONLY) + try: os.fsync(fd) + finally: os.close(fd) + s['current'] = version + w['state'] = 'integrated' + w['changed'] = changed + + def reserve(self, upper_bound): + if type(upper_bound) is not int or upper_bound <= 0: raise Refused('invalid token reservation') + with self.transaction('reserve') as s: + self.active(s) + if s['tokens']+s['reserved']+upper_bound > s['limit']: raise Refused('token budget exhausted') + ticket = uuid.uuid4().hex + s['tickets'][ticket] = upper_bound; s['reserved'] += upper_bound + return ticket + + def settle(self, ticket, actual): + with self.transaction('usage') as s: + bound = s['tickets'][ticket] + if type(actual) is not int or actual < 0 or actual > bound: + raise Refused('usage outside reserved bound') + s['tokens'] += actual; s['reserved'] -= bound; del s['tickets'][ticket] + + def cancel(self): + with self.transaction('cancel') as s: s['cancelled'] = True diff --git a/coder/swarm-pilot/sandbox.py b/coder/swarm-pilot/sandbox.py new file mode 100644 index 0000000..4e6790d --- /dev/null +++ b/coder/swarm-pilot/sandbox.py @@ -0,0 +1,112 @@ +"""Run commands in disposable offline Docker containers, never on the host.""" +import subprocess +import re +import uuid +import os +import selectors +import time +from pathlib import Path + +MAX_OUTPUT = 16000 +OUTPUT_LIMIT_EXIT = 125 + + +def _stop_process(process): + """Stop a Docker client without allowing cleanup to hang forever.""" + if process.poll() is not None: + return + process.terminate() + try: + process.wait(timeout=5) + except subprocess.TimeoutExpired: + process.kill() + process.wait(timeout=5) + + +def _capture_process(process, seconds): + """Capture only the last MAX_OUTPUT bytes from a running process.""" + selector = selectors.DefaultSelector() + selector.register(process.stdout, selectors.EVENT_READ) + tail = bytearray() + total = 0 + deadline = time.monotonic() + seconds + timed_out = False + excessive = False + try: + while True: + if process.poll() is not None and not selector.get_map(): + break + remaining = deadline - time.monotonic() + if remaining <= 0: + timed_out = process.poll() is None + break + events = selector.select(min(remaining, 0.1)) + if not events: + if process.poll() is not None: + break + continue + for key, _ in events: + chunk = os.read(key.fileobj.fileno(), 4096) + if not chunk: + selector.unregister(key.fileobj) + continue + total += len(chunk) + tail.extend(chunk) + if len(tail) > MAX_OUTPUT: + del tail[:-MAX_OUTPUT] + if total > MAX_OUTPUT: + excessive = True + break + if timed_out or excessive: + break + finally: + selector.close() + + if timed_out or excessive: + _stop_process(process) + else: + process.wait() + process.stdout.close() + + output = bytes(tail).decode('utf-8', errors='replace') + if timed_out: + return 124, 'sandbox command timed out' + if excessive: + return OUTPUT_LIMIT_EXIT, 'sandbox refused: output exceeded 16000 bytes' + return process.returncode, output + +class Sandbox: + def __init__(self, workspace, image, writable=None, label="unscoped", compiler=None, judge=None): + self.workspace = Path(workspace).resolve(strict=True) + if not self.workspace.is_dir() or not re.fullmatch(r'[^\s,@]+@sha256:[0-9a-f]{64}', image): + raise ValueError('directory and digest-pinned image required') + self.image = image + self.writable, self.label, self.compiler, self.judge = writable, label, compiler, judge + + def execute(self, command, seconds=120): + name = 'aien-pilot-' + uuid.uuid4().hex + argv = ['docker', 'run', '--rm', '--name', name, '--network=none', + '--label', 'aien.pilot='+self.label, '--user', f'{os.getuid()}:{os.getgid()}', '--cap-drop=ALL', '--security-opt=no-new-privileges', '--read-only', + '--pids-limit=128', '--memory=2g', '--cpus=2', '--tmpfs', '/tmp:rw,exec,size=256m', + '--mount', f'type=bind,src={self.workspace},dst=/work'+(',readonly' if self.writable is not None else ''), '-w', '/work', + self.image, '/bin/sh', '-c', command] + if self.judge: + argv[argv.index(self.image):argv.index(self.image)] = ['--mount', f'type=bind,src={Path(self.judge).resolve(strict=True)},dst=/judge.py,readonly'] + if self.compiler: + import hashlib + file = Path(self.compiler['path']).resolve(strict=True) + if hashlib.sha256(file.read_bytes()).hexdigest() != self.compiler['sha256']: + raise ValueError('compiler pin mismatch') + argv[argv.index(self.image):argv.index(self.image)] = ['--mount', f'type=bind,src={file},dst=/usr/local/bin/omc,readonly'] + for path in self.writable or []: + source = self.workspace/path + if not source.resolve().is_relative_to(self.workspace): raise ValueError('write mount escapes workspace') + if not source.exists(): + source.parent.mkdir(parents=True, exist_ok=True); source.touch() + argv[argv.index(self.image):argv.index(self.image)] = ['--mount', f'type=bind,src={source},dst=/work/{path}'] + try: + process = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + exit_code, output = _capture_process(process, seconds) + return dict(exit_code=exit_code, output=output) + finally: + subprocess.run(['docker', 'rm', '-f', name], capture_output=True, timeout=15) diff --git a/coder/swarm-pilot/suite.py b/coder/swarm-pilot/suite.py new file mode 100644 index 0000000..9d635e5 --- /dev/null +++ b/coder/swarm-pilot/suite.py @@ -0,0 +1,36 @@ +"""Freeze public development tasks from an exact repository commit, outside agent trees.""" +import argparse +import hashlib +import json +from pathlib import Path +import subprocess +from runtime import write_json,snapshot + +BASE='f5aa51d' +TASKS=[ + dict(id='bug',paths=['pilot.py'],prompt='Fix matrix(tasks): refuse non-string task IDs and IDs containing slash, backslash, whitespace, or traversal. IDs must match [A-Za-z0-9_-]+. Preserve six unique tasks and existing 36-run behavior.'), + dict(id='feature',paths=['pilot.py'],prompt='Add Claims.release_all(): remove all owners atomically. Return a sorted list of released owner names. Calling on an empty Claims returns []. Existing acquire/release behavior stays unchanged.'), + dict(id='omega',paths=['program.om'],prompt='Write program.om in seeded Omega: sum integers 1 through 10 in a bounded loop and return the sum as the process exit status. No output. Use only the supplied public syntax reference. Compile with omc < program.om > /tmp/program, chmod +x /tmp/program, and run /tmp/program; expected exit is 55.'), + dict(id='parallel',paths=['pilot.py','sandbox.py'],prompt='Use distinct workers for independent changes. In pilot.py add Claims.release_all() returning a sorted list of released owners and clearing claims. In sandbox.py add a module function valid_image(value) returning True only for a nonempty repository followed by @sha256: and exactly 64 lowercase hexadecimal characters, with no whitespace or commas. It must return False for nonstrings. Preserve Sandbox constructor digest validation.'), + dict(id='conflict',paths=['pilot.py'],prompt='Add Claims.acquire_many(entries), where entries is a mapping of owner names to path lists. Acquire every entry using existing overlap rules, or leave all original ownership unchanged if any entry fails. Reject owners already claimed. Return None. Implement transactionally, including parent/child path conflicts. Use one exclusive worker for pilot.py; conflicting workers must be refused.'), + dict(id='recovery',paths=['pilot.py'],prompt='Add Claims.to_json() returning a JSON string of owner->list of relative path strings; add @classmethod Claims.from_json(text) returning a new Claims with all owners restored through acquire validation. Reject malformed roots and overlapping or invalid paths. Preserve existing claims when serialization is called. This is for durable recovery across a restarted process.')] + +def freeze(repo,out): + out=Path(out);out.mkdir(mode=0o700) + sha=subprocess.check_output(['git','-C',str(repo),'rev-parse',BASE],text=True).strip() + for task in TASKS: + root=out/task['id'];source=root/'source';source.mkdir(parents=True) + for name in ['pilot.py','sandbox.py']: + data=subprocess.check_output(['git','-C',str(repo),'show',sha+':coder/swarm-pilot/'+name]) + (source/name).write_bytes(data) + if task['id']=='omega': + # Existing public compiler guide, not the coder/eval held-out task corpus. + reference=subprocess.check_output(['git','-C',str(repo),'show',sha+':examples/hello.om']).decode() + reference+='\nLoop reference:\nfn main to int\ni = int 0\nwhile lt i 3 bound 3\ni = add i 1\nend\nret i\nend\n' + (source/'OMEGA.md').write_text(reference) + write_json(root/'task.json',{**task,'base_commit':sha,'source_sha256':hashlib.sha256(json.dumps(snapshot(source),sort_keys=True).encode()).hexdigest()}) + write_json(out/'manifest.json',{'base_commit':sha,'tasks':TASKS,'profile':'public authored development tasks; not an unseen general benchmark'}) + +if __name__=='__main__': + p=argparse.ArgumentParser();p.add_argument('repository',type=Path);p.add_argument('output',type=Path) + a=p.parse_args();freeze(a.repository,a.output) diff --git a/coder/swarm-pilot/test_gateway.py b/coder/swarm-pilot/test_gateway.py new file mode 100644 index 0000000..a07af9c --- /dev/null +++ b/coder/swarm-pilot/test_gateway.py @@ -0,0 +1,47 @@ +import tempfile +import unittest +from pathlib import Path +from unittest.mock import patch +from types import SimpleNamespace +from gateway import Gateway +from runtime import Session,Refused + +class GatewayTests(unittest.TestCase): + def setUp(self): + self.tmp=tempfile.TemporaryDirectory();self.addCleanup(self.tmp.cleanup) + root=Path(self.tmp.name);(root/'src').mkdir() + self.s=Session.create(root/'run',root/'src') + self.g=Gateway(self.s,'frozen-model');self.addCleanup(self.g.close) + def test_refuses_model_substitution_before_transport(self): + with patch('gateway.subprocess.run') as run: + with self.assertRaises(Refused):self.g.complete({'model':'other'}) + run.assert_not_called() + def test_missing_usage_keeps_reserved_budget(self): + p=SimpleNamespace(returncode=0,stdout='{"id":1,"status":200,"body":{}}\n') + with patch.object(self.g,'provider_call',return_value=p): + with self.assertRaises(Refused):self.g.complete({'model':'frozen-model'}) + self.assertGreater(self.s.status()['reserved'],0) + def test_usage_charged_and_trace_excludes_gateway_token(self): + p=SimpleNamespace(returncode=0,stdout='{"id":1,"status":200,"body":{"usage":{"total_tokens":10}}}\n') + with patch.object(self.g,'provider_call',return_value=p):self.g.complete({'model':'frozen-model'}) + self.assertEqual(self.s.status()['tokens'],10) + self.assertNotIn(self.g.token,(self.s.root/'trace.jsonl').read_text()) + + def test_cancellation_kills_and_reconciles_provider_process(self): + import subprocess,sys,time + from concurrent.futures import ThreadPoolExecutor + original=subprocess.Popen + children=[] + def fake(*args,**kwargs): + p=original([sys.executable,'-c','import time; time.sleep(20)'],**kwargs) + children.append(p);return p + with patch('gateway.subprocess.Popen',side_effect=fake): + with ThreadPoolExecutor(max_workers=1) as pool: + future=pool.submit(self.g.provider_call,{},30) + deadline=time.time()+2 + while not children and time.time()