mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 02:08:18 +00:00
openultrasast.plane.memory and openultrasast.plane.budget are now
openultrasast.memory and openultrasast.budget; every importer follows. A pure move:
no behaviour changes. The two renames themselves were swept into 1aad435 by mistake
(they were staged when that spec commit was made), so the three commits between it
and this one do not import; this commit completes the move.
memory.py still reaches into the plane in two lazy imports (results_root in
open_store, the reconciler in seed); the cut of the plane has to settle both.
Checked: ruff, ruff format, mypy; 163 test files around memory, budget, plane, learn
and hunt passed across three runs by the implementing agent, and the six closest
files again before this commit. The whole suite was not run locally.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
53 lines
2.0 KiB
Python
53 lines
2.0 KiB
Python
"""Host queue transport: source and task metadata only, never analyzer code."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
import time
|
|
import uuid
|
|
|
|
from engine_worker_service import PENDING, client_from_env, pack, put, read, result_key, status
|
|
|
|
from openultrasast.memory import PRESIGNED_ARCHIVE_SUFFIX
|
|
|
|
|
|
class Dispatcher:
|
|
def __init__(self, args, client=None, *, pause=time.sleep, clock=time.monotonic):
|
|
self.client = client if client is not None else client_from_env()
|
|
self.run = uuid.uuid4().hex
|
|
self.args, self.pause, self.clock = args, pause, clock
|
|
|
|
def execute(self, checkout, output, pin, pin_id):
|
|
task_id = f"{self.run}-{pin_id}"
|
|
task = dict(
|
|
run=self.run,
|
|
id=pin_id,
|
|
task_id=task_id,
|
|
pin=pin,
|
|
input=f"engine-queue/inputs/{self.run}/{pin_id}/source{PRESIGNED_ARCHIVE_SUFFIX}",
|
|
image=self.args.image,
|
|
deadline=self.args.deadline,
|
|
question_deadline=self.args.question_deadline,
|
|
)
|
|
try:
|
|
self.client.put(task["input"], pack(checkout), {})
|
|
put(self.client, PENDING + task_id, task)
|
|
end = self.clock() + self.args.queue_timeout
|
|
while self.clock() < end:
|
|
result = read(self.client, result_key(task))
|
|
if result is not None:
|
|
(output / "result.json").write_text(json.dumps(result))
|
|
self.client.delete(task["input"])
|
|
return subprocess.CompletedProcess([], 0, "", ""), result.get("worker")
|
|
self.pause(2)
|
|
# Removing pending cancels work that has not been claimed; retain source for a live lease.
|
|
self.client.delete(PENDING + task_id)
|
|
return None, None
|
|
except Exception as exc:
|
|
# SDK errors can contain endpoint URLs or credentials. Do not persist their text.
|
|
raise OSError("queue transport failed") from exc
|
|
|
|
def status(self):
|
|
return status(self.client)
|