Add local reachability descriptor for same-host extensions (SAND-WP-0013-T04)
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s

Reachability gains pid/workspace_dir, populated by enrich_reachability
whenever a backend's wait_ready() returns a pid: endpoint (currently
just ext.bwrap). build_reachability_report() now also returns a
local_exec_hint (nsenter into the pid's namespaces) alongside the
existing ssh_one_liner, so glas-harness can branch on which is
populated instead of assuming every sandbox is SSH-reachable.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
tegwick 2026-07-26 12:58:32 +02:00
parent 76c38e758c
commit cf490220f4
6 changed files with 67 additions and 6 deletions

View file

@ -156,6 +156,11 @@ class Reachability(BaseModel):
tunnel: str | None = None
tunnel_via: str | None = None
identity: str | None = None
# Local (no-SSH-hop) descriptor — populated for same-host extensions
# like ext.bwrap. A consumer execs into the sandbox directly
# (e.g. `nsenter --target <pid> ...`) rather than over SSH.
pid: str | None = None
workspace_dir: str | None = None
class SandboxStatus(BaseModel):

View file

@ -19,6 +19,11 @@ def enrich_reachability(
enriched = dict(reach)
spec = profile.reachability
if handle.get("workspace_dir"):
enriched.setdefault("workspace_dir", handle["workspace_dir"])
if handle.get("pid") and enriched.get("endpoint", "").startswith("pid:"):
enriched.setdefault("pid", handle["pid"])
if spec.tunnel:
enriched.setdefault("tunnel_via", spec.tunnel)
if spec.identity:
@ -50,6 +55,20 @@ def ssh_one_liner(reach: Reachability) -> str | None:
return None
def local_exec_hint(reach: Reachability) -> str | None:
"""No-SSH-hop exec hint for same-host extensions (e.g. ext.bwrap).
Consumers exec directly into the sandbox's namespaces via the
placeholder process's pid, rather than opening an SSH channel.
"""
if reach.pid and reach.workspace_dir:
return (
f"nsenter --target {reach.pid} --mount --pid --net --uts --ipc "
f"-- sh -c 'cd {reach.workspace_dir} && exec $SHELL'"
)
return None
def build_reachability_report(status: SandboxStatus) -> dict[str, Any]:
"""Consumer-facing reachability report with ops-bridge pointer."""
reach = status.reachability
@ -65,4 +84,5 @@ def build_reachability_report(status: SandboxStatus) -> dict[str, Any]:
}
if reach:
payload["ssh_one_liner"] = ssh_one_liner(reach)
payload["local_exec_hint"] = local_exec_hint(reach)
return payload