Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/outerloop/syscall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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 ->
Expand Down
9 changes: 4 additions & 5 deletions src/outerloop/syscall_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("/"))
Expand Down
Loading