diff --git a/src/outerloop/syscall.py b/src/outerloop/syscall.py index 4bca7b8c..70d3e121 100644 --- a/src/outerloop/syscall.py +++ b/src/outerloop/syscall.py @@ -47,6 +47,7 @@ from outerloop.compute import GONE from outerloop.contract import Benchmark, Budgets +from outerloop.syscall_cli import _rel_path_ok log = logging.getLogger(__name__) @@ -254,15 +255,6 @@ def launch_task_ids(launches: Iterable[Launch], job_ids: list[str]) -> list[str] return [] -def _rel_path_ok(path: str) -> bool: - """A declared artifact must stay inside the job's tree: repo-relative, - no traversal, no absolute paths. (Same stance as scope normalization.)""" - if not path or len(path) > 500 or path.startswith(("/", "~")) or "\\" in path: - return False - parts = path.split("/") - return all(p not in ("", ".", "..") for p in parts) - - def read_request(workspace: Path) -> SyscallRequest | None: """Read and CONSUME the author's request. None = no request (the session finished; today's path). Malformed or over per-request bounds -> diff --git a/src/outerloop/syscall_cli.py b/src/outerloop/syscall_cli.py index 2ddfafe8..08c3014a 100644 --- a/src/outerloop/syscall_cli.py +++ b/src/outerloop/syscall_cli.py @@ -76,11 +76,10 @@ class ToolError(Exception): def _rel_path_ok(path: str) -> bool: - """MUST match syscall._rel_path_ok exactly — the CLI's fast check has to - accept precisely what the kernel accepts, or the author burns a sleep on a - post-session validation error (the very thing the tool exists to prevent). - Rejects absolute/`~`, backslashes, over-long, and any empty/`.`/`..` - component (so ``, `.`, `out/./x`, `out//x` all fail here as they do there).""" + """The kernel's artifact-path rule; the CLI uses the same function for + early feedback. It rejects absolute and home paths, backslashes, paths + over 500 characters, and empty, `.` or `..` path parts. This module uses + only the standard library because it is copied into workspaces.""" if not path or len(path) > 500 or path.startswith(("/", "~")) or "\\" in path: return False return all(p not in ("", ".", "..") for p in path.split("/"))