From 1949828e9546b976431c95dc862562ac002127fa Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Fri, 9 Oct 2026 16:22:25 -0500 Subject: [PATCH 1/2] odysseus adapter: process-launch preflight (#93) Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 9 + adapters/odysseus/README.md | 44 ++++ .../interplane_adapter_odysseus/authority.py | 9 + .../interplane_adapter_odysseus/launch.py | 147 +++++++++++++ adapters/odysseus/tests/conftest.py | 8 + .../odysseus/tests/test_launch_preflight.py | 207 ++++++++++++++++++ 6 files changed, 424 insertions(+) create mode 100644 adapters/odysseus/interplane_adapter_odysseus/launch.py create mode 100644 adapters/odysseus/tests/test_launch_preflight.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ad5a83..d670ab7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -219,3 +219,12 @@ jobs: python -m interplane_adapter_odysseus.t3 --out $RUNNER_TEMP/t3-verdicts.json - name: bench runner offline test (scripted endpoint, sim-1 backends, runtime-v1 with denial/approval negative controls) run: ODYSSEUS_SRC=$GITHUB_WORKSPACE/../odysseus PYTHONDONTWRITEBYTECODE=1 python bench/tools/test_runner_offline.py + - name: launch preflight (#93) against current Odysseus (odysseus-dev/odysseus @ a8c147b; no skips allowed) + run: | + git clone -q https://github.com/odysseus-dev/odysseus.git ../odysseus-a8c147b + git -C ../odysseus-a8c147b checkout -q a8c147b + pip install -q -c $GITHUB_WORKSPACE/constraints/ci-python.txt -r ../odysseus-a8c147b/requirements.txt + cd adapters/odysseus + ODYSSEUS_SRC=$GITHUB_WORKSPACE/../odysseus-a8c147b PYTHONPATH=$GITHUB_WORKSPACE/python:. PYTHONDONTWRITEBYTECODE=1 \ + python -m pytest tests/test_launch_preflight.py -q -p no:cacheprovider -rs | tee pytest-a8c147b.log + ! grep -q "skipped" pytest-a8c147b.log diff --git a/adapters/odysseus/README.md b/adapters/odysseus/README.md index 4e6ef05..5c2015d 100644 --- a/adapters/odysseus/README.md +++ b/adapters/odysseus/README.md @@ -17,6 +17,7 @@ and needs no change (the `odysseus_text` dialect is registered adapter-locally). | `.../domains.py` | Hand-curated `TOOL_DOMAINS` (one reviewable line per tool, fixed 19-domain set), 16 `CANONICAL` aliases, `catalog_with_domains()`. | | `.../mapping.py` | `mapping_table()`: 16 alias rules + 71 passthrough rules, `catalog_digest` from the record. | | `.../authority.py` | `OdysseusAuthority(RuntimeAuthority)`: `decide`, `execute`, `catalog`. | +| `.../launch.py` | `launch_preflight()`: structural process-launch check (#93). Never authorizes, never executes. | | `.../dialect.py` | `odysseus_text` Lenshift dialect and `make_registry()`. | | `.../demo.py` | Runs turns through the real `Pipeline`. | | `.../_odysseus.py` | Optional loader for a checkout named by `ODYSSEUS_SRC`. | @@ -104,6 +105,49 @@ The recorded `catalog_digest` (`sha256:4ec0d10e...`) is `Catalog.computed_digest recorded capabilities, so anyone can recompute it from the record with Core alone. (The first extraction used an ad-hoc formula; it was recomputed on 2026-10-04 with the tools unchanged.) +## Workspace and process-launch boundaries (#93) + +Four separate questions, answered by four separate things: + +1. **Selection** is `vet_workspace` (`src/tool_execution.py:1179`, what `/api/workspace/vet` returns): is this a real, non-sensitive directory? It accepts an ancestor of `ODYSSEUS_DATA_DIR` on purpose and refuses `DATA_DIR` itself and anything nested in it. +2. **Confinement** is Odysseus's per-path deny: inside an accepted workspace, files of server state are hidden one path at a time. +3. **Launch preflight** is `launch_preflight()` here: would the launch boundary (`guard_launch_workspace`, `src/agent_runtime/process_resources.py:379`) structurally accept this workspace for bash, python, host_shell or manage_bg_jobs? Read-only; asks the real upstream code. +4. **Authorization** stays with Odysseus at launch: tool permission, admin, delegated credentials, untrusted context, approvals. A positive preflight is none of these and not a claim that anything ran. + +**Verified disagreement** (a8c147b, real run): a workspace that is an ancestor of `DATA_DIR` is accepted by selection but refused by the launch guard ("contains server control state"), so the workspace can be chosen and then every launch fails. A workspace nested inside `DATA_DIR` is the reverse: refused by selection, passed by the guard alone. The preflight asks both. Upstream: odysseus-dev/odysseus#6651 (open, unfixed at a8c147b). INTERPLANE does not bypass or weaken either gate. + +**Safe layout.** Keep `ODYSSEUS_DATA_DIR` disjoint from every agent workspace (siblings, not parent or child). The loader defaults it to a fresh temp directory only when unset; an operator value is always honoured. The adapter never moves, copies or rewrites existing state; the fix for a refused layout is the operator's. + +| Code | Stage | Meaning | Remediation | +|---|---|---|---| +| `structurally_eligible` | preflight | Passed every structural check; not an authorization | Odysseus still decides at launch | +| `runtime_unavailable` | runtime | Odysseus not importable | Set `ODYSSEUS_SRC` | +| `not_a_process_tool` | request | Tool is not bash, python, host_shell or manage_bg_jobs | Read-only tools need no launch preflight | +| `process_tool_unavailable` | runtime | Tool missing from `TOOL_TAGS` or `TOOL_HANDLERS` | Use a revision that registers it | +| `host_api_unsupported` | runtime | No launch guard API (e.g. 2992bf6) | Treat launch as not ready | +| `workspace_missing` | selection | No workspace given | Name one | +| `workspace_invalid` | selection | Not an existing directory | Check the path | +| `workspace_inaccessible` | selection | No read/search access | Fix permissions or choose another | +| `workspace_is_server_state` | selection | Workspace is `DATA_DIR` | Choose another; keep `DATA_DIR` outside workspaces | +| `workspace_within_server_state` | selection | Nested inside `DATA_DIR` | Choose another | +| `workspace_rejected_by_host` | selection | `vet_workspace` refuses it | Choose another | +| `indeterminate` | launch_boundary | Boundary could not be sealed or inspected | Fix permissions or shrink the workspace, retry | +| `workspace_contains_server_state` | launch_boundary | Contains control state (the #6651 case) | Disjoint workspace or `ODYSSEUS_DATA_DIR` outside it | +| `workspace_aliases_server_state` | launch_boundary | Symlink or hardlink to server state inside | Remove the link or choose another | + +Results carry fixed text only: no paths, no upstream exception text. + +**Qualification matrix** (`tests/test_launch_preflight.py`: 23 tests, no skips, real upstream calls): + +| Odysseus | Full suite | Preflight | +|---|---|---| +| 2992bf6 (catalog pin) | 114 passed (91 existing + 23) | every workspace case reports `host_api_unsupported` (no `process_resources.py`) | +| a8c147b (2026-10-07) | 111 passed, 3 failed | full table: sibling and lookalike eligible; equals, nested, ancestor, other-control-path, symlink, hardlink, invalid, inaccessible denied | + +The 3 failures at a8c147b are the existing drift detectors in `test_odysseus_pipeline.py`: `tail_serve_output` is now in `TOOL_TAGS`, and the untrusted-context message was reworded. Execution stays fail-closed (only `read_file`, `ls`, `glob`, `grep` run). Re-pinning the catalog to a8c147b is a separate follow-up. CI runs the preflight tests against a8c147b in addition to the full suite at 2992bf6. + +**Limitations.** The guard is pathname and inode based and not atomic (its own docstring): links can change after the check. The nested case relies on selection, not the guard. The guard walks the whole workspace tree, so very large workspaces cost time. A positive result is not an authorization. No shell, python or job execution was added to the adapter. + ## Run ``` diff --git a/adapters/odysseus/interplane_adapter_odysseus/authority.py b/adapters/odysseus/interplane_adapter_odysseus/authority.py index a3f86c5..0974598 100644 --- a/adapters/odysseus/interplane_adapter_odysseus/authority.py +++ b/adapters/odysseus/interplane_adapter_odysseus/authority.py @@ -14,6 +14,10 @@ Reused from Odysseus (commit 2992bf6), by call: * ``src.tool_execution._resolve_tool_path_in_workspace`` / ``vet_workspace`` / ``_active_workspace`` + ``src.agent_tools.TOOL_HANDLERS`` (ReadFileTool, LsTool, GlobTool, GrepTool) confinement and execution +Added for the launch preflight (commit a8c147b, see launch.py): + * ``src.agent_runtime.process_resources.guard_launch_workspace`` (:379) with + ``src.agent_runtime.resources.FilesystemRoot.seal`` / ``ResourceIdentityError``, + ``src.constants.DATA_DIR`` and ``src.tool_execution.vet_workspace`` (read-only, structural). Gate order follows ``execute_tool_block`` (tool_execution.py:915-926 then :1064-1080): the untrusted-context gate first, then the admin gates, then (in Odysseus: inside the tool) path confinement. Confinement is also run in ``decide`` so that an escape is refused BEFORE execution. @@ -34,6 +38,7 @@ from interplane.core import Catalog, CapabilityRequest, Decision, ToolResult from interplane.crossveil import RuntimeAuthority, make_result from . import _odysseus +from .launch import launch_preflight from .domains import catalog_with_domains RUNTIME_ID = "odysseus" @@ -104,6 +109,10 @@ class OdysseusAuthority(RuntimeAuthority): def available(self) -> bool: return self._ody is not None + def launch_preflight(self, workspace: Optional[str] = None, tool: str = "bash"): + """Structural process-launch check (see ``launch.py``); never authorizes or executes.""" + return launch_preflight(self._ody, self.workspace if workspace is None else workspace, tool) + # -- helpers -------------------------------------------------------------------------------- def _decision( diff --git a/adapters/odysseus/interplane_adapter_odysseus/launch.py b/adapters/odysseus/interplane_adapter_odysseus/launch.py new file mode 100644 index 0000000..7d48558 --- /dev/null +++ b/adapters/odysseus/interplane_adapter_odysseus/launch.py @@ -0,0 +1,147 @@ +"""Process-launch preflight: would Odysseus's launch boundary structurally accept this workspace? + +Odysseus gates a workspace twice. Selection (``src.tool_execution.vet_workspace``, tool_execution.py +:1179 at a8c147b) accepts any real directory that is not sensitive or app state, including an +ANCESTOR of ``ODYSSEUS_DATA_DIR`` (deliberate, see ``_is_app_state_path``). The launch guard +(``src.agent_runtime.process_resources.guard_launch_workspace``, :379 at a8c147b) refuses a root +that contains server control state or aliases it, but does NOT refuse a root nested inside +``DATA_DIR`` (selection does). Neither gate alone is the whole answer (odysseus-dev/odysseus#6651), +so this module asks both, in the real upstream code, read-only. + +A positive result is structural only. It is never an authorization and never a claim that anything +ran or will run: Odysseus still decides at launch (tool permission, admin, delegated credentials, +untrusted context, approvals). Nothing here runs a handler, writes a file or changes the +environment. No field ever carries a path or upstream exception text. +""" + +from __future__ import annotations + +import importlib +import os +from dataclasses import dataclass +from typing import Any, Optional + +PROCESS_TOOLS = frozenset({"bash", "python", "host_shell", "manage_bg_jobs"}) + +_FIX = { + "runtime_unavailable": ("runtime", "install Odysseus and set ODYSSEUS_SRC to its checkout; until then no process launch is possible"), + "not_a_process_tool": ("request", "ask about one of: bash, python, host_shell, manage_bg_jobs; read-only tools need no launch preflight"), + "process_tool_unavailable": ("runtime", "this Odysseus build does not register the requested process tool; use a revision that does"), + "host_api_unsupported": ("runtime", "this Odysseus revision has no launch-boundary guard the adapter can ask (qualified: a8c147b); treat process launch as not ready"), + "workspace_missing": ("selection", "name a workspace directory"), + "workspace_invalid": ("selection", "the workspace must be an existing directory; check the path"), + "workspace_inaccessible": ("selection", "grant the Odysseus user read and search access to the workspace, or choose another directory"), + "workspace_is_server_state": ("selection", "choose a workspace that is not Odysseus's data directory; set ODYSSEUS_DATA_DIR outside every agent workspace"), + "workspace_within_server_state": ("selection", "choose a workspace outside Odysseus's data directory; the adapter never moves existing state"), + "workspace_rejected_by_host": ("selection", "Odysseus itself refuses this directory as a workspace (sensitive, app state or filesystem root); choose another"), + "indeterminate": ("launch_boundary", "the launch boundary could not be inspected; fix the workspace permissions or choose a smaller, readable workspace, then retry"), + "workspace_contains_server_state": ("launch_boundary", "choose a workspace that does not contain Odysseus's data directory, or set ODYSSEUS_DATA_DIR outside it; the adapter never moves existing state"), + "workspace_aliases_server_state": ("launch_boundary", "remove the symlink or hardlink inside the workspace that points at Odysseus server state, or choose another workspace"), + "structurally_eligible": ("preflight", "structurally eligible only; Odysseus still decides at launch (tool permission, admin, delegated credentials, untrusted context, approvals)"), +} +REASON_CODES = frozenset(_FIX) + + +@dataclass(frozen=True) +class LaunchPreflight: + """Result of ``launch_preflight``. ``eligible`` is structural only: never an authorization, + never a claim that a process was or will be started. Fields hold fixed text, no paths.""" + + eligible: bool + code: str + stage: str + remediation: str + + +def _result(code: str) -> LaunchPreflight: + stage, fix = _FIX[code] + return LaunchPreflight(code == "structurally_eligible", code, stage, fix) + + +def launch_preflight(ody: Any, workspace: Optional[str], tool: str = "bash") -> LaunchPreflight: + """Return the first failing check, in order runtime, selection, launch boundary.""" + code = _runtime(ody, tool) + if code is not None: + return _result(code) + api = _host_api() + if api is None: + return _result("host_api_unsupported") + code = _selection(ody, workspace) + if code is not None: + return _result(code) + return _result(_boundary(api, os.path.realpath(workspace)) or "structurally_eligible") + + +def _runtime(ody: Any, tool: str) -> Optional[str]: + if ody is None: + return "runtime_unavailable" + if tool not in PROCESS_TOOLS: + return "not_a_process_tool" + try: + if tool not in ody.tool_tags or tool not in ody.tool_handlers: + return "process_tool_unavailable" + except Exception: # noqa: BLE001 - an unreadable registry is not a ready runtime + return "process_tool_unavailable" + return None + + +def _host_api() -> Optional[tuple]: + """(guard_launch_workspace, FilesystemRoot, ResourceIdentityError) or None if absent.""" + try: + pr = importlib.import_module("src.agent_runtime.process_resources") + res = importlib.import_module("src.agent_runtime.resources") + guard = pr.guard_launch_workspace + root, err = res.FilesystemRoot, res.ResourceIdentityError + root.seal + except Exception: # noqa: BLE001 - any failure means the API is not there + return None + return guard, root, err + + +def _inside(path: str, base: str) -> bool: + return os.path.commonpath([path, base]) == base + + +def _selection(ody: Any, workspace: Optional[str]) -> Optional[str]: + if not workspace or not isinstance(workspace, str): + return "workspace_missing" + real = os.path.realpath(workspace) + if not os.path.isdir(real): + return "workspace_invalid" + if not os.access(real, os.R_OK | os.X_OK): + return "workspace_inaccessible" + try: + data = os.path.realpath(importlib.import_module("src.constants").DATA_DIR) + except Exception: # noqa: BLE001 + return "host_api_unsupported" + if real == data: + return "workspace_is_server_state" + if _inside(real, data): + return "workspace_within_server_state" + try: + vetted = ody.tool_execution.vet_workspace(workspace) + except Exception: # noqa: BLE001 + vetted = None + if vetted is None or os.path.realpath(vetted) != real: + return "workspace_rejected_by_host" + return None + + +def _boundary(api: tuple, real: str) -> Optional[str]: + guard, filesystem_root, error = api + try: + root = filesystem_root.seal(real) + except Exception: # noqa: BLE001 + return "indeterminate" + try: + guard(root) + except error as exc: + text = str(exc) + if "contains" in text: + return "workspace_contains_server_state" + if "aliases" in text: + return "workspace_aliases_server_state" + return "indeterminate" + except Exception: # noqa: BLE001 - OSError and anything else + return "indeterminate" + return None diff --git a/adapters/odysseus/tests/conftest.py b/adapters/odysseus/tests/conftest.py index f83d342..928d343 100644 --- a/adapters/odysseus/tests/conftest.py +++ b/adapters/odysseus/tests/conftest.py @@ -1,8 +1,16 @@ +import os import sys +import tempfile from pathlib import Path import pytest +# A controlled layout for the launch-preflight tests: DATA_DIR is /data, so sibling directories +# of it are disjoint workspaces. Must be set before Odysseus is first imported; an operator value wins. +_home = Path(tempfile.mkdtemp(prefix="interplane-odysseus-home-")).resolve() +(_home / "data").mkdir() +os.environ.setdefault("ODYSSEUS_DATA_DIR", str(_home / "data")) + ADAPTER = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ADAPTER)) diff --git a/adapters/odysseus/tests/test_launch_preflight.py b/adapters/odysseus/tests/test_launch_preflight.py new file mode 100644 index 0000000..2d6fb4d --- /dev/null +++ b/adapters/odysseus/tests/test_launch_preflight.py @@ -0,0 +1,207 @@ +"""Launch preflight (#93) against Odysseus's real code. No skips: the expectation follows whether +the host launch guard exists (a8c147b: yes; 2992bf6: no, so every workspace case is +``host_api_unsupported``).""" + +import dataclasses +import importlib +import os +import sys +import types +import uuid +from pathlib import Path + +import pytest + +from interplane_adapter_odysseus.authority import NOT_EXECUTED, OdysseusAuthority +from interplane_adapter_odysseus.launch import PROCESS_TOOLS, REASON_CODES, LaunchPreflight, launch_preflight + + +def _has_guard(): + try: + return hasattr(importlib.import_module("src.agent_runtime.process_resources"), "guard_launch_workspace") + except Exception: # noqa: BLE001 + return False + + +@pytest.fixture +def data(ody): + return Path(importlib.import_module("src.constants").DATA_DIR).resolve() + + +@pytest.fixture +def home(data): + return data.parent + + +@pytest.fixture +def sibling(home): + d = home / f"ws-{uuid.uuid4().hex[:8]}" + d.mkdir() + (d / "f.txt").write_text("x", encoding="utf-8") + return d + + +def _check(ody, ws, expect_code, expect_stage=None, tool="bash"): + got = launch_preflight(ody, str(ws) if ws is not None else None, tool) + if not _has_guard() and expect_code not in ("runtime_unavailable", "not_a_process_tool", "process_tool_unavailable"): + expect_code, expect_stage = "host_api_unsupported", "runtime" + assert got.code == expect_code, got + if expect_stage: + assert got.stage == expect_stage + assert got.eligible is (expect_code == "structurally_eligible") + _no_leak(got, ws) + return got + + +def _no_leak(got, ws): + text = " ".join(map(str, dataclasses.astuple(got))) + assert got.code in REASON_CODES + assert got.remediation and str(importlib.import_module("src.constants").DATA_DIR) not in text + if ws: + assert str(ws) not in text and os.path.realpath(ws) not in text + + +def test_disjoint_sibling_is_eligible(ody, sibling): + got = _check(ody, sibling, "structurally_eligible", "preflight") + assert ("Odysseus still decides" in got.remediation) is got.eligible + + +def test_lookalike_name_is_not_rejected(ody, home): + d = home / "data-lookalike" + d.mkdir(exist_ok=True) + _check(ody, d, "structurally_eligible") + + +def test_equals_data_dir(ody, data): + _check(ody, data, "workspace_is_server_state", "selection") + + +def test_nested_in_data_dir(ody, data): + d = data / "sub" + d.mkdir(exist_ok=True) + _check(ody, d, "workspace_within_server_state", "selection") + + +def test_ancestor_contains_data_dir(ody, home): + _check(ody, home, "workspace_contains_server_state", "launch_boundary") + + +def test_ancestor_vet_accepts_but_guard_refuses(ody, home): + # The #6651 disagreement: selection accepts, launch boundary refuses. + assert ody.tool_execution.vet_workspace(str(home)) == str(home) + + +def test_root_containing_another_protected_location(ody, sibling, monkeypatch): + constants = importlib.import_module("src.constants") + monkeypatch.setattr(constants, "SETTINGS_FILE", str(sibling / "settings.json")) + _check(ody, sibling, "workspace_contains_server_state", "launch_boundary") + + +def test_symlink_alias_to_app_db(ody, data, sibling): + target = Path(importlib.import_module("src.constants").APP_DB) + assert target.exists() + (sibling / "link").symlink_to(target) + _check(ody, sibling, "workspace_aliases_server_state", "launch_boundary") + + +def test_hardlink_alias_to_app_db(ody, data, sibling): + target = Path(importlib.import_module("src.constants").APP_DB) + try: + os.link(target, sibling / "hard") + except OSError: + pytest.fail("test layout must allow hardlinks (same filesystem)") + _check(ody, sibling, "workspace_aliases_server_state", "launch_boundary") + + +def test_nonexistent_path(ody, home): + _check(ody, home / "nope-does-not-exist", "workspace_invalid", "selection") + + +def test_file_not_directory(ody, sibling): + _check(ody, sibling / "f.txt", "workspace_invalid", "selection") + + +def test_missing_workspace(ody): + _check(ody, None, "workspace_missing", "selection") + _check(ody, "", "workspace_missing", "selection") + + +def test_inaccessible_directory(ody, home): + d = home / f"locked-{uuid.uuid4().hex[:8]}" + d.mkdir() + d.chmod(0) + try: + assert os.geteuid() != 0, "tests must run as a non-root user" + _check(ody, d, "workspace_inaccessible", "selection") + finally: + d.chmod(0o700) + + +def test_runtime_unavailable(): + auth = OdysseusAuthority(odysseus=False) + got = auth.launch_preflight("/tmp", "bash") + assert (got.code, got.stage, got.eligible) == ("runtime_unavailable", "runtime", False) + assert launch_preflight(None, None).code == "runtime_unavailable" + + +@pytest.mark.parametrize("tool", ["read_file", "ls", "nope", "serve_start"]) +def test_not_a_process_tool(ody, sibling, tool): + got = _check(ody, sibling, "not_a_process_tool", "request", tool=tool) + assert tool not in PROCESS_TOOLS and not got.eligible + + +def test_process_tool_missing(ody, sibling): + stub = types.SimpleNamespace(TOOL_TAGS={}, TOOL_HANDLERS={}) + fake = dataclasses.replace(ody, agent_tools=stub) + for tool in PROCESS_TOOLS: + assert launch_preflight(fake, str(sibling), tool).code == "process_tool_unavailable" + only_tags = dataclasses.replace(ody, agent_tools=types.SimpleNamespace(TOOL_TAGS={"bash": 1}, TOOL_HANDLERS={})) + assert launch_preflight(only_tags, str(sibling), "bash").code == "process_tool_unavailable" + + +def test_host_api_missing(ody, sibling, monkeypatch): + stub = types.ModuleType("src.agent_runtime.process_resources") # no guard_launch_workspace + monkeypatch.setitem(sys.modules, "src.agent_runtime.process_resources", stub) + got = launch_preflight(ody, str(sibling), "bash") + assert (got.code, got.stage, got.eligible) == ("host_api_unsupported", "runtime", False) + + +def test_guard_error_text_never_leaks_and_unknown_is_indeterminate(ody, sibling, monkeypatch): + if not _has_guard(): + assert launch_preflight(ody, str(sibling), "bash").code == "host_api_unsupported" + return + pr = importlib.import_module("src.agent_runtime.process_resources") + err = importlib.import_module("src.agent_runtime.resources").ResourceIdentityError + + def boom(root): + raise err("Launch workspace cannot be inspected: " + str(root.path)) + + monkeypatch.setattr(pr, "guard_launch_workspace", boom) + got = launch_preflight(ody, str(sibling), "bash") + assert got.code == "indeterminate" and str(sibling) not in " ".join(map(str, dataclasses.astuple(got))) + + def oserr(root): + raise PermissionError("x") + + monkeypatch.setattr(pr, "guard_launch_workspace", oserr) + assert launch_preflight(ody, str(sibling), "bash").code == "indeterminate" + + +def test_preflight_does_not_change_decide_or_execute(ody, workspace, run): + before = [run("read_file", {"path": "notes.txt"}), run("bash", {"command": "echo hi"})] + auth = OdysseusAuthority(str(workspace), admin=True) + got = auth.launch_preflight() + assert isinstance(got, LaunchPreflight) and got.code in REASON_CODES + after = [run("read_file", {"path": "notes.txt"}), run("bash", {"command": "echo hi"})] + for (a0, r0, c0), (a1, r1, c1) in zip(before, after): + assert (r0.status, c0.decision, c0.execute_invoked) == (r1.status, c1.decision, c1.execute_invoked) + assert (a0.decide_calls, a0.execute_calls) == (a1.decide_calls, a1.execute_calls) + _, bash_res, _ = after[1] + assert (bash_res.status, bash_res.error.message) == ("error", NOT_EXECUTED) + + +def test_eligible_preflight_never_executes(ody, sibling): + auth = OdysseusAuthority(odysseus=ody) + assert auth.launch_preflight(str(sibling), "bash").code in REASON_CODES + assert not hasattr(auth, "execute_calls") + assert sorted(p.name for p in sibling.iterdir()) == ["f.txt"] From 4330b0d7a5d8d5110b740c8479a8c87f2adb64db Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Fri, 9 Oct 2026 16:25:09 -0500 Subject: [PATCH 2/2] odysseus preflight: review fixes (#93) - CI a8c147b step: set -o pipefail so a failing test fails the step; own venv so the 2992bf6 pins are untouched - launch_preflight: a workspace name with a NUL byte is workspace_invalid instead of raising - test name matches what it asserts; NUL-byte test; README wording and counts (24 preflight tests) Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 6 ++++-- adapters/odysseus/README.md | 8 ++++---- .../odysseus/interplane_adapter_odysseus/launch.py | 2 ++ adapters/odysseus/tests/test_launch_preflight.py | 12 +++++++++--- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d670ab7..ab0d2cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -221,10 +221,12 @@ jobs: run: ODYSSEUS_SRC=$GITHUB_WORKSPACE/../odysseus PYTHONDONTWRITEBYTECODE=1 python bench/tools/test_runner_offline.py - name: launch preflight (#93) against current Odysseus (odysseus-dev/odysseus @ a8c147b; no skips allowed) run: | + set -o pipefail git clone -q https://github.com/odysseus-dev/odysseus.git ../odysseus-a8c147b git -C ../odysseus-a8c147b checkout -q a8c147b - pip install -q -c $GITHUB_WORKSPACE/constraints/ci-python.txt -r ../odysseus-a8c147b/requirements.txt + python -m venv $RUNNER_TEMP/venv-a8c147b # own environment: never disturb the 2992bf6 pins above + $RUNNER_TEMP/venv-a8c147b/bin/pip install -q -c $GITHUB_WORKSPACE/constraints/ci-python.txt -r ../odysseus-a8c147b/requirements.txt pytest cd adapters/odysseus ODYSSEUS_SRC=$GITHUB_WORKSPACE/../odysseus-a8c147b PYTHONPATH=$GITHUB_WORKSPACE/python:. PYTHONDONTWRITEBYTECODE=1 \ - python -m pytest tests/test_launch_preflight.py -q -p no:cacheprovider -rs | tee pytest-a8c147b.log + $RUNNER_TEMP/venv-a8c147b/bin/python -m pytest tests/test_launch_preflight.py -q -p no:cacheprovider -rs | tee pytest-a8c147b.log ! grep -q "skipped" pytest-a8c147b.log diff --git a/adapters/odysseus/README.md b/adapters/odysseus/README.md index 5c2015d..1ff3177 100644 --- a/adapters/odysseus/README.md +++ b/adapters/odysseus/README.md @@ -114,7 +114,7 @@ Four separate questions, answered by four separate things: 3. **Launch preflight** is `launch_preflight()` here: would the launch boundary (`guard_launch_workspace`, `src/agent_runtime/process_resources.py:379`) structurally accept this workspace for bash, python, host_shell or manage_bg_jobs? Read-only; asks the real upstream code. 4. **Authorization** stays with Odysseus at launch: tool permission, admin, delegated credentials, untrusted context, approvals. A positive preflight is none of these and not a claim that anything ran. -**Verified disagreement** (a8c147b, real run): a workspace that is an ancestor of `DATA_DIR` is accepted by selection but refused by the launch guard ("contains server control state"), so the workspace can be chosen and then every launch fails. A workspace nested inside `DATA_DIR` is the reverse: refused by selection, passed by the guard alone. The preflight asks both. Upstream: odysseus-dev/odysseus#6651 (open, unfixed at a8c147b). INTERPLANE does not bypass or weaken either gate. +**Verified disagreement** (a8c147b, real run): a workspace that is an ancestor of `DATA_DIR` is accepted by selection but refused by the launch guard ("contains server control state"), so the workspace can be chosen and then every launch fails. A workspace nested inside `DATA_DIR` is the reverse: refused by selection, passed by the guard alone. The preflight runs both: Odysseus's own `vet_workspace` and launch guard, preceded by the adapter's equal/nested check against `DATA_DIR` (the same rule `vet_workspace` applies, repeated so the reason code can name the case). Upstream: odysseus-dev/odysseus#6651 (open, unfixed at a8c147b). INTERPLANE does not bypass or weaken either gate. **Safe layout.** Keep `ODYSSEUS_DATA_DIR` disjoint from every agent workspace (siblings, not parent or child). The loader defaults it to a fresh temp directory only when unset; an operator value is always honoured. The adapter never moves, copies or rewrites existing state; the fix for a refused layout is the operator's. @@ -137,12 +137,12 @@ Four separate questions, answered by four separate things: Results carry fixed text only: no paths, no upstream exception text. -**Qualification matrix** (`tests/test_launch_preflight.py`: 23 tests, no skips, real upstream calls): +**Qualification matrix** (`tests/test_launch_preflight.py`: 24 tests, no skips, real upstream calls): | Odysseus | Full suite | Preflight | |---|---|---| -| 2992bf6 (catalog pin) | 114 passed (91 existing + 23) | every workspace case reports `host_api_unsupported` (no `process_resources.py`) | -| a8c147b (2026-10-07) | 111 passed, 3 failed | full table: sibling and lookalike eligible; equals, nested, ancestor, other-control-path, symlink, hardlink, invalid, inaccessible denied | +| 2992bf6 (catalog pin) | 115 passed (91 existing + 24) | every workspace case reports `host_api_unsupported` (no `process_resources.py`) | +| a8c147b (2026-10-07) | 112 passed, 3 failed (known drift detectors) | full table: sibling and lookalike eligible; equals, nested, ancestor, other-control-path, symlink, hardlink, invalid, inaccessible denied | The 3 failures at a8c147b are the existing drift detectors in `test_odysseus_pipeline.py`: `tail_serve_output` is now in `TOOL_TAGS`, and the untrusted-context message was reworded. Execution stays fail-closed (only `read_file`, `ls`, `glob`, `grep` run). Re-pinning the catalog to a8c147b is a separate follow-up. CI runs the preflight tests against a8c147b in addition to the full suite at 2992bf6. diff --git a/adapters/odysseus/interplane_adapter_odysseus/launch.py b/adapters/odysseus/interplane_adapter_odysseus/launch.py index 7d48558..e8b776d 100644 --- a/adapters/odysseus/interplane_adapter_odysseus/launch.py +++ b/adapters/odysseus/interplane_adapter_odysseus/launch.py @@ -105,6 +105,8 @@ def _inside(path: str, base: str) -> bool: def _selection(ody: Any, workspace: Optional[str]) -> Optional[str]: if not workspace or not isinstance(workspace, str): return "workspace_missing" + if "\0" in workspace: # os.path raises on it; an unusable name is an invalid workspace + return "workspace_invalid" real = os.path.realpath(workspace) if not os.path.isdir(real): return "workspace_invalid" diff --git a/adapters/odysseus/tests/test_launch_preflight.py b/adapters/odysseus/tests/test_launch_preflight.py index 2d6fb4d..60df953 100644 --- a/adapters/odysseus/tests/test_launch_preflight.py +++ b/adapters/odysseus/tests/test_launch_preflight.py @@ -58,7 +58,9 @@ def _no_leak(got, ws): assert got.code in REASON_CODES assert got.remediation and str(importlib.import_module("src.constants").DATA_DIR) not in text if ws: - assert str(ws) not in text and os.path.realpath(ws) not in text + assert str(ws) not in text + if "\0" not in str(ws): + assert os.path.realpath(ws) not in text def test_disjoint_sibling_is_eligible(ody, sibling): @@ -86,8 +88,8 @@ def test_ancestor_contains_data_dir(ody, home): _check(ody, home, "workspace_contains_server_state", "launch_boundary") -def test_ancestor_vet_accepts_but_guard_refuses(ody, home): - # The #6651 disagreement: selection accepts, launch boundary refuses. +def test_ancestor_is_accepted_by_selection(ody, home): + # Selection half of the #6651 disagreement; the guard half is test_ancestor_contains_data_dir. assert ody.tool_execution.vet_workspace(str(home)) == str(home) @@ -117,6 +119,10 @@ def test_nonexistent_path(ody, home): _check(ody, home / "nope-does-not-exist", "workspace_invalid", "selection") +def test_embedded_null_byte_is_invalid_not_raised(ody, home): + _check(ody, str(home) + "/bad\0name", "workspace_invalid", "selection") + + def test_file_not_directory(ody, sibling): _check(ody, sibling / "f.txt", "workspace_invalid", "selection")