refactor(environments-terminal): delete unreached vercel helpers, CredentialRef, failed_start and exit-137 hint
Removed. A search for callers by name, attribute and string (Python, TypeScript, docs, the plugin API list and the frozen old-updater list) finds no supported path that reaches any of them: - tools/environments/vercel_sandbox.py: _exception_chain, _extract_status_code, _RETRY_BACKOFF_STEP, _MIN_SANDBOX_TIMEOUT, _MIN_RUNNING_WAIT, _RUNNING_WAIT_POLL_INTERVAL, _STOP_TIMEOUT, _STOP_POLL_INTERVAL, _SNAPSHOT_STORE_NAME - tools/environments/sandbox_scope.py: CredentialRef (docstring in agent/terminal_env_provider.py and the terminal-environment-plugin guide no longer name it) - tools/environments/streams.py: supports_streams() (the provider attribute of the same name stays) - completion_reason "failed_start": its producer left in cd818a4d054; drop the lookups in process_registry_notifications._REASON_STATUS (and its "Failed to Start" branch), cli_process_dock._STATUS_BY_REASON, ui-tui processRoster REASON_STATUS, and the field comments - tools/terminal_hints.py: _EXIT_CODE_HINTS[137] (exit 137 always carries a SIGKILL exit note, which gates annotate_failure off) - ProcessRegistry._config_value: unread `fallback` parameter
This commit is contained in:
committed by
Siddharth Balyan
parent
192cdaf266
commit
40492aca4e
@@ -78,8 +78,8 @@ class TerminalEnvironmentProvider(ProviderBase):
|
||||
sandbox. Suspending the sandbox once such a process is idle-stopped, and network isolation
|
||||
between sandboxes, are the backend's.
|
||||
|
||||
Credentials reach a hosted sandbox as broker references (``CredentialRef``), never values from
|
||||
the secret store; no broker exists yet, so core passes none.
|
||||
Credentials never reach a hosted sandbox as values from the secret store; no credential broker
|
||||
exists yet, so core passes none.
|
||||
"""
|
||||
|
||||
is_remote: bool = True
|
||||
|
||||
@@ -16,7 +16,7 @@ from agent.i18n import t
|
||||
RETAIN_SECONDS = 60
|
||||
|
||||
# Reader-thread exits report "exited"; `kill_process` / `kill_all` stamp "killed".
|
||||
_STATUS_BY_REASON = {"killed": "killed", "lost": "lost", "failed_start": "failed"}
|
||||
_STATUS_BY_REASON = {"killed": "killed", "lost": "lost"}
|
||||
|
||||
|
||||
def _last_output_line(buffer: str) -> str:
|
||||
|
||||
@@ -16,7 +16,6 @@ class TestAnnotateFailureBasics:
|
||||
|
||||
def test_empty_output_falls_to_exit_code_tier(self):
|
||||
assert "126" in annotate_failure("./run.sh", 126, "")
|
||||
assert "SIGKILL" in annotate_failure("big_job", 137, "")
|
||||
assert "timeout" in annotate_failure("sleep 999", 124, "")
|
||||
|
||||
def test_unknown_failure_returns_none(self):
|
||||
|
||||
@@ -71,14 +71,6 @@ class ProcessStream:
|
||||
poll: Callable[[], Optional[int]] = field(compare=False)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CredentialRef:
|
||||
"""A credential the sandbox resolves through a broker, by name. Hosted backends receive these,
|
||||
never secret values from the secret store; no broker exists yet, so core passes none."""
|
||||
|
||||
name: str
|
||||
|
||||
|
||||
def hosted_scope() -> Optional[Scope]:
|
||||
"""The bound scope when it is hosted, else ``None`` (no scope, or a local install)."""
|
||||
scope = current_scope()
|
||||
|
||||
@@ -76,10 +76,6 @@ def sandbox_temp_dir(env: BaseEnvironment) -> str:
|
||||
return str(get_temp_dir()) if callable(get_temp_dir) else "/tmp" # no-tmp: ok — sandbox-side temp dir
|
||||
|
||||
|
||||
def supports_streams(env: BaseEnvironment) -> bool:
|
||||
return exec_prefix(env, interactive=True) is not None
|
||||
|
||||
|
||||
def remote_argv(prefix: Sequence[str], argv: Sequence[str], *, env: Optional[dict] = None,
|
||||
shell_joined: bool = False) -> list[str]:
|
||||
"""``prefix`` + a ``bash -c`` that exports ``env`` and execs ``argv``.
|
||||
|
||||
@@ -53,34 +53,11 @@ def _ensure_vercel_sdk() -> None:
|
||||
_lazy_ensure("vercel")
|
||||
except Exception as e:
|
||||
raise ImportError(str(e))
|
||||
|
||||
|
||||
_WRITE_RETRY_ATTEMPTS = 3
|
||||
_RETRY_BACKOFF_STEP = timedelta(milliseconds=100)
|
||||
_MIN_SANDBOX_TIMEOUT = timedelta(minutes=5)
|
||||
_MIN_RUNNING_WAIT = timedelta(seconds=1)
|
||||
_RUNNING_WAIT_POLL_INTERVAL = timedelta(milliseconds=250)
|
||||
_STOP_TIMEOUT = timedelta(seconds=15)
|
||||
_STOP_POLL_INTERVAL = timedelta(milliseconds=500)
|
||||
_SNAPSHOT_STORE_NAME = "vercel_sandbox_snapshots.json"
|
||||
|
||||
|
||||
def _exception_chain(exc: BaseException) -> list[BaseException]:
|
||||
chain: list[BaseException] = []
|
||||
current: BaseException | None = exc
|
||||
seen: set[int] = set()
|
||||
while current is not None and id(current) not in seen:
|
||||
chain.append(current)
|
||||
seen.add(id(current))
|
||||
current = current.__cause__ or current.__context__
|
||||
return chain
|
||||
|
||||
|
||||
def _extract_status_code(exc: BaseException) -> int | None:
|
||||
response = getattr(exc, "response", None)
|
||||
for value in (getattr(exc, "status_code", None), getattr(response, "status_code", None)):
|
||||
if isinstance(value, int):
|
||||
return value
|
||||
return None
|
||||
|
||||
@cache
|
||||
def _transport_error_types() -> tuple[type[BaseException], ...]:
|
||||
"""Network exceptions of every HTTP stack the SDK may raise from.
|
||||
|
||||
@@ -563,8 +563,8 @@ class ProcessSession:
|
||||
exited: bool = False
|
||||
exited_at: float = 0.0 # time.time() of the FIRST move to finished (0 = unknown)
|
||||
exit_code: Optional[int] = None # None while running
|
||||
completion_reason: str = "exited" # exited|killed|lost|failed_start|already_exited
|
||||
termination_source: str = "" # process.kill|kill_all|backend_lost|env_closed|failed_start
|
||||
completion_reason: str = "exited" # exited|killed|lost|already_exited
|
||||
termination_source: str = "" # process.kill|kill_all|backend_lost|env_closed
|
||||
output_buffer: str = "" # Rolling tail (last max_output_chars)
|
||||
max_output_chars: int = MAX_OUTPUT_CHARS
|
||||
detached: bool = False # Recovered from checkpoint (no pipe)
|
||||
@@ -1066,7 +1066,7 @@ class ProcessRegistry(ProcessTerminationMixin, ProcessCheckpointMixin, ProcessOu
|
||||
and not self._is_host_pid_alive(session.pid))
|
||||
|
||||
@staticmethod
|
||||
def _config_value(section: str, key: str, fallback):
|
||||
def _config_value(section: str, key: str):
|
||||
"""``config.yaml`` value for ``section.key``, else the DEFAULT_CONFIG value.
|
||||
Raises if config is unreadable; callers wrap with their own hard fallback so
|
||||
registry code paths never crash on a broken config file."""
|
||||
@@ -1079,7 +1079,7 @@ class ProcessRegistry(ProcessTerminationMixin, ProcessCheckpointMixin, ProcessOu
|
||||
def _config_seconds(key: str, fallback: float) -> float:
|
||||
"""``terminal.<key>`` as a non-negative float (0 disables); *fallback* if unreadable."""
|
||||
try:
|
||||
return max(float(ProcessRegistry._config_value("terminal", key, fallback)), 0.0)
|
||||
return max(float(ProcessRegistry._config_value("terminal", key)), 0.0)
|
||||
except Exception:
|
||||
return fallback
|
||||
|
||||
@@ -1775,7 +1775,7 @@ class ProcessRegistry(ProcessTerminationMixin, ProcessCheckpointMixin, ProcessOu
|
||||
"""``delegation.surface_child_process_notifications``; False on any config
|
||||
error — never crash the drain loop."""
|
||||
try:
|
||||
return bool(ProcessRegistry._config_value("delegation", "surface_child_process_notifications", False))
|
||||
return bool(ProcessRegistry._config_value("delegation", "surface_child_process_notifications"))
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from dataclasses import dataclass
|
||||
from contextlib import suppress
|
||||
|
||||
_DONE = ("completed", "success")
|
||||
_REASON_STATUS = {"lost": "marked lost because the process backend disappeared", "failed_start": "failed to start"}
|
||||
_REASON_STATUS = {"lost": "marked lost because the process backend disappeared"}
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
@@ -444,7 +444,7 @@ def process_completion_display_text(events: list) -> str:
|
||||
if reason == "killed":
|
||||
outcome = "Terminated"
|
||||
elif reason in _REASON_STATUS:
|
||||
outcome = "Lost" if reason == "lost" else "Failed to Start"
|
||||
outcome = "Lost"
|
||||
else:
|
||||
outcome = "Finished" if exit_code == 0 else "Failed"
|
||||
cmd = _short_command(evt.get("command"))
|
||||
|
||||
@@ -76,7 +76,6 @@ _OUTPUT_HINTS: list[Callable[[str, str], Optional[str]]] = [
|
||||
# cover per-command. Checked after output patterns.
|
||||
_EXIT_CODE_HINTS: dict[int, str] = {
|
||||
126: "Exit 126: the file was found but is not executable — `chmod +x` it or invoke it via its interpreter (e.g. `bash script.sh`).",
|
||||
137: "Exit 137: the process was SIGKILLed — usually out-of-memory or an external kill. Reduce memory use or check `dmesg | tail` before retrying.",
|
||||
124: "Exit 124: the command hit its timeout. Raise timeout= (foreground max 600s) or run it with background=true and notify_on_complete=true.",
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export function applyProcessSnapshot(sid: string | null, processes: ProcessEntry
|
||||
}
|
||||
}
|
||||
|
||||
const REASON_STATUS: Record<string, ProcessRow['status']> = { failed_start: 'failed', killed: 'killed', lost: 'lost' }
|
||||
const REASON_STATUS: Record<string, ProcessRow['status']> = { killed: 'killed', lost: 'lost' }
|
||||
|
||||
export const processStatus = (entry: ProcessEntry): ProcessRow['status'] => {
|
||||
if (entry.status !== 'exited') {
|
||||
|
||||
@@ -351,9 +351,8 @@ local backend on this host, docker/ssh and `supports_streams` plugins through
|
||||
their exec prefix). Suspending a sandbox once its processes are idle-stopped,
|
||||
and network isolation between sandboxes, are yours.
|
||||
|
||||
**Credentials** reach a hosted sandbox as broker references
|
||||
(`sandbox_scope.CredentialRef`), never as values from the secret store. No
|
||||
broker exists yet, so Hermes passes none.
|
||||
**Credentials** never reach a hosted sandbox as values from the secret store.
|
||||
No credential broker exists yet, so Hermes passes none.
|
||||
|
||||
**Conformance.** `tools/environments/sandbox_conformance.py` holds the
|
||||
isolation checks Hermes runs against its recording stub backend
|
||||
|
||||
Reference in New Issue
Block a user