fix: validate sandbox readiness before rein handoff
Some checks failed
ci / validate (push) Has been cancelled
Some checks failed
ci / validate (push) Has been cancelled
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a0726e-5232-73f2-aaca-2c05ceb62efb
This commit is contained in:
parent
31dd5aaca8
commit
c38ee08720
6 changed files with 92 additions and 29 deletions
|
|
@ -12,7 +12,7 @@ from datetime import UTC, datetime
|
|||
|
||||
from pydantic import ValidationError
|
||||
from sandboxer.core.manager import SandboxManager
|
||||
from sandboxer.models import Consumer, SandboxCreateRequest, SandboxExecRequest
|
||||
from sandboxer.models import Consumer, SandboxCreateRequest, SandboxExecRequest, SandboxState
|
||||
|
||||
from glas_harness import hub
|
||||
from glas_harness.contract import (
|
||||
|
|
@ -124,38 +124,40 @@ def run_execution(
|
|||
)
|
||||
)
|
||||
sandbox_id = status.sandbox_id
|
||||
if status.state != SandboxState.READY:
|
||||
raise RuntimeError("sandbox owner did not return a ready sandbox")
|
||||
except Exception as exc:
|
||||
failure_stage = "sandbox_create"
|
||||
error = str(exc)
|
||||
raise
|
||||
|
||||
reachability = (
|
||||
status.reachability.model_dump(mode="json", exclude_none=True)
|
||||
if status.reachability
|
||||
else {}
|
||||
)
|
||||
sandbox = SandboxHandle(
|
||||
sandbox_id=status.sandbox_id,
|
||||
host=status.host or "",
|
||||
reachability=reachability,
|
||||
)
|
||||
|
||||
def owner_execute(argv, input_text, timeout):
|
||||
return manager.execute(
|
||||
sandbox.sandbox_id,
|
||||
SandboxExecRequest(
|
||||
command=list(argv),
|
||||
consumer=consumer,
|
||||
credential_route_refs=profile.credential_route_refs,
|
||||
stdin_text=input_text,
|
||||
timeout_seconds=timeout,
|
||||
),
|
||||
try:
|
||||
reachability = (
|
||||
status.reachability.model_dump(mode="json", exclude_none=True)
|
||||
if status.reachability
|
||||
else {}
|
||||
)
|
||||
sandbox = SandboxHandle(
|
||||
sandbox_id=status.sandbox_id,
|
||||
host=status.host or "",
|
||||
reachability=reachability,
|
||||
)
|
||||
|
||||
sandbox._owner_execute = owner_execute
|
||||
sandbox._timeout_seconds = profile.limits.timeout_seconds or 600
|
||||
def owner_execute(argv, input_text, timeout):
|
||||
return manager.execute(
|
||||
sandbox.sandbox_id,
|
||||
SandboxExecRequest(
|
||||
command=list(argv),
|
||||
consumer=consumer,
|
||||
credential_route_refs=profile.credential_route_refs,
|
||||
stdin_text=input_text,
|
||||
timeout_seconds=timeout,
|
||||
),
|
||||
)
|
||||
|
||||
sandbox._owner_execute = owner_execute
|
||||
sandbox._timeout_seconds = profile.limits.timeout_seconds or 600
|
||||
|
||||
try:
|
||||
session = selected_rein.start_session(
|
||||
profile,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue