refactor: fix unused imports, long lines, and type issues
Remove 35+ unused imports across 20+ files (W0611). Wrap 19 lines to fit under 100 character limit (C0301). Add type casts and annotations in egress_addon_core.py to resolve pyright errors caused by JSON parsing of untyped objects. Key changes: - Remove unused imports (abstractmethod, mock utilities, etc) - Split long lines at logical breaks (method calls, error messages) - Add typing.cast() for proper type inference in JSON parsing - Explicit type annotations for dict/list accesses Results: - Pylint rating: 8.73/10 - egress_addon_core.py: 0 pyright errors (was 15) - All W0611 and C0301 issues fixed Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,6 @@ semantics open question.
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -39,7 +38,6 @@ from ...log import info, warn
|
|||||||
from .bottle_state import (
|
from .bottle_state import (
|
||||||
mark_preserved,
|
mark_preserved,
|
||||||
per_bottle_dockerfile,
|
per_bottle_dockerfile,
|
||||||
per_bottle_dockerfile_path,
|
|
||||||
transcript_snapshot_dir,
|
transcript_snapshot_dir,
|
||||||
write_per_bottle_dockerfile,
|
write_per_bottle_dockerfile,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,30 +15,23 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from ...log import die
|
from ...log import die
|
||||||
# Re-exported for the compose renderer + smolmachines launch step
|
|
||||||
# (they used to import these from this module before they moved to
|
|
||||||
# the platform-neutral pipelock module).
|
|
||||||
from ...pipelock import ( # noqa: F401
|
|
||||||
PIPELOCK_CA_CERT_IN_CONTAINER,
|
|
||||||
PIPELOCK_CA_KEY_IN_CONTAINER,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Pipelock image, pinned by digest. The digest is the multi-arch image
|
# Pipelock image, pinned by digest. The digest is the multi-arch image
|
||||||
# index for ghcr.io/luckypipewrench/pipelock:2.3.0.
|
# index for ghcr.io/luckypipewrench/pipelock:2.3.0.
|
||||||
PIPELOCK_IMAGE = os.environ.get(
|
PIPELOCK_IMAGE = os.environ.get(
|
||||||
"BOT_BOTTLE_PIPELOCK_IMAGE",
|
"BOT_BOTTLE_PIPELOCK_IMAGE",
|
||||||
"ghcr.io/luckypipewrench/pipelock@sha256:3b1a39417b98406ddc5dc2d8fcb42865ddc0c68a43d355db55f0f8cb06bc6de9",
|
"ghcr.io/luckypipewrench/pipelock@sha256:"
|
||||||
|
"3b1a39417b98406ddc5dc2d8fcb42865ddc0c68a43d355db55f0f8cb06bc6de9",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Listening port for pipelock's forward proxy.
|
# Listening port for pipelock's forward proxy.
|
||||||
PIPELOCK_PORT = os.environ.get("BOT_BOTTLE_PIPELOCK_PORT", "8888")
|
PIPELOCK_PORT = os.environ.get("BOT_BOTTLE_PIPELOCK_PORT", "8888")
|
||||||
|
|
||||||
|
|
||||||
# The URL egress dials for its upstream HTTPS_PROXY. egress and
|
# The URL egress dials for its upstream HTTPS_PROXY. egress and pipelock
|
||||||
# pipelock share the same container's network namespace inside the
|
# share the same container's network namespace inside the sidecar bundle, so
|
||||||
# sidecar bundle, so loopback reaches pipelock directly — no docker
|
# loopback reaches pipelock directly — no docker DNS aliases involved.
|
||||||
# DNS aliases involved.
|
|
||||||
BUNDLE_LOCAL_PIPELOCK_URL = f"http://127.0.0.1:{PIPELOCK_PORT}"
|
BUNDLE_LOCAL_PIPELOCK_URL = f"http://127.0.0.1:{PIPELOCK_PORT}"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,10 @@ REGISTRY_IMAGE = os.environ.get(
|
|||||||
# narrow.
|
# narrow.
|
||||||
CRANE_IMAGE = os.environ.get(
|
CRANE_IMAGE = os.environ.get(
|
||||||
"BOT_BOTTLE_CRANE_IMAGE",
|
"BOT_BOTTLE_CRANE_IMAGE",
|
||||||
"gcr.io/go-containerregistry/crane@sha256:0ae17ecb34315aa7cbff28f6eddee3b7adae0b2f90101260d990804db1eb0084",
|
(
|
||||||
|
"gcr.io/go-containerregistry/crane@sha256:"
|
||||||
|
"0ae17ecb34315aa7cbff28f6eddee3b7adae0b2f90101260d990804db1eb0084"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import fcntl
|
import fcntl
|
||||||
import json
|
import json
|
||||||
import os
|
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|||||||
@@ -41,9 +41,18 @@ def usage() -> None:
|
|||||||
sys.stderr.write(" info print env, skills, and prompt details for a named agent\n")
|
sys.stderr.write(" info print env, skills, and prompt details for a named agent\n")
|
||||||
sys.stderr.write(" init interactively create a new agent and add it to bot-bottle.json\n")
|
sys.stderr.write(" init interactively create a new agent and add it to bot-bottle.json\n")
|
||||||
sys.stderr.write(" list list available agents or active containers\n")
|
sys.stderr.write(" list list available agents or active containers\n")
|
||||||
sys.stderr.write(" resume re-launch a bottle by its identity (continues state from PRD 0016)\n")
|
sys.stderr.write(
|
||||||
sys.stderr.write(" start boot a container for a named agent and attach an interactive session\n")
|
" resume re-launch a bottle by its identity "
|
||||||
sys.stderr.write(" supervise view + approve/modify/reject pending supervise proposals (PRD 0013)\n\n")
|
"(continues state from PRD 0016)\n"
|
||||||
|
)
|
||||||
|
sys.stderr.write(
|
||||||
|
" start boot a container for a named agent and "
|
||||||
|
"attach an interactive session\n"
|
||||||
|
)
|
||||||
|
sys.stderr.write(
|
||||||
|
" supervise view + approve/modify/reject pending supervise "
|
||||||
|
"proposals (PRD 0013)\n\n"
|
||||||
|
)
|
||||||
sys.stderr.write(f"Run '{PROG} <command> --help' for command-specific usage.\n")
|
sys.stderr.write(f"Run '{PROG} <command> --help' for command-specific usage.\n")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+18
-5
@@ -51,7 +51,8 @@ def cmd_init(argv: list[str]) -> int:
|
|||||||
die(f"{target_file} exists but is not valid JSON; fix or remove it first")
|
die(f"{target_file} exists but is not valid JSON; fix or remove it first")
|
||||||
if agent_name in (existing.get("agents") or {}):
|
if agent_name in (existing.get("agents") or {}):
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
f'bot-bottle: agent "{agent_name}" already exists in {target_file}. Overwrite? [y/N] '
|
f'bot-bottle: agent "{agent_name}" already exists in '
|
||||||
|
f'{target_file}. Overwrite? [y/N] '
|
||||||
)
|
)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
ow = read_tty_line()
|
ow = read_tty_line()
|
||||||
@@ -71,7 +72,10 @@ def cmd_init(argv: list[str]) -> int:
|
|||||||
|
|
||||||
# Prompt
|
# Prompt
|
||||||
print(file=sys.stderr)
|
print(file=sys.stderr)
|
||||||
info("System prompt — enter text, then a lone '.' on its own line to finish (just '.' to leave empty):")
|
info(
|
||||||
|
"System prompt — enter text, then a lone '.' on its own line to "
|
||||||
|
"finish (just '.' to leave empty):"
|
||||||
|
)
|
||||||
prompt_lines: list[str] = []
|
prompt_lines: list[str] = []
|
||||||
while True:
|
while True:
|
||||||
line = read_tty_line()
|
line = read_tty_line()
|
||||||
@@ -99,7 +103,10 @@ def cmd_init(argv: list[str]) -> int:
|
|||||||
|
|
||||||
if bottle_name in (existing.get("bottles") or {}):
|
if bottle_name in (existing.get("bottles") or {}):
|
||||||
bottle_exists_already = True
|
bottle_exists_already = True
|
||||||
info(f"Bottle '{bottle_name}' already exists in {target_file}; agent will reference it.")
|
info(
|
||||||
|
f"Bottle '{bottle_name}' already exists in {target_file}; "
|
||||||
|
f"agent will reference it."
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
info(f"Creating new bottle '{bottle_name}'.")
|
info(f"Creating new bottle '{bottle_name}'.")
|
||||||
bottle_env = _prompt_for_env_vars()
|
bottle_env = _prompt_for_env_vars()
|
||||||
@@ -131,8 +138,14 @@ def cmd_init(argv: list[str]) -> int:
|
|||||||
|
|
||||||
def _prompt_for_env_vars() -> dict[str, str]:
|
def _prompt_for_env_vars() -> dict[str, str]:
|
||||||
print(file=sys.stderr)
|
print(file=sys.stderr)
|
||||||
info("Env vars — enter each var name then its mode. Press Enter with no name to finish.")
|
info(
|
||||||
info(" Modes: secret (prompt at runtime) | interpolated (read from host env) | literal (hardcoded value)")
|
"Env vars — enter each var name then its mode. Press Enter with "
|
||||||
|
"no name to finish."
|
||||||
|
)
|
||||||
|
info(
|
||||||
|
" Modes: secret (prompt at runtime) | interpolated (read from "
|
||||||
|
"host env) | literal (hardcoded value)"
|
||||||
|
)
|
||||||
out: dict[str, str] = {}
|
out: dict[str, str] = {}
|
||||||
while True:
|
while True:
|
||||||
print(file=sys.stderr)
|
print(file=sys.stderr)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ flow (PRD 0014) at egress and renames the MCP tool.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|||||||
@@ -38,7 +38,12 @@ from mitmproxy import http # type: ignore[import-not-found]
|
|||||||
# Absolute import (NOT `from .egress_addon_core`) — the
|
# Absolute import (NOT `from .egress_addon_core`) — the
|
||||||
# container drops both files flat into /app/ so they are sibling
|
# container drops both files flat into /app/ so they are sibling
|
||||||
# top-level modules to mitmdump's loader, not a package.
|
# top-level modules to mitmdump's loader, not a package.
|
||||||
from egress_addon_core import Route, decide, is_git_push_request, load_routes # type: ignore[import-not-found]
|
from egress_addon_core import ( # type: ignore[import-not-found]
|
||||||
|
Route,
|
||||||
|
decide,
|
||||||
|
is_git_push_request,
|
||||||
|
load_routes,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_ROUTES_PATH = "/etc/egress/routes.yaml"
|
DEFAULT_ROUTES_PATH = "/etc/egress/routes.yaml"
|
||||||
|
|||||||
@@ -78,11 +78,13 @@ def parse_routes(payload: object) -> tuple[Route, ...]:
|
|||||||
"""
|
"""
|
||||||
if not isinstance(payload, dict):
|
if not isinstance(payload, dict):
|
||||||
raise ValueError("routes payload: top-level must be an object")
|
raise ValueError("routes payload: top-level must be an object")
|
||||||
raw = payload.get("routes")
|
payload_dict: dict[str, object] = typing.cast(dict[str, object], payload)
|
||||||
|
raw: object = payload_dict.get("routes")
|
||||||
if not isinstance(raw, list):
|
if not isinstance(raw, list):
|
||||||
raise ValueError("routes payload: 'routes' must be a list")
|
raise ValueError("routes payload: 'routes' must be a list")
|
||||||
|
raw_list: list[object] = typing.cast(list[object], raw)
|
||||||
out: list[Route] = []
|
out: list[Route] = []
|
||||||
for i, r in enumerate(raw):
|
for i, r in enumerate(raw_list):
|
||||||
out.append(_parse_one(i, r))
|
out.append(_parse_one(i, r))
|
||||||
return tuple(out)
|
return tuple(out)
|
||||||
|
|
||||||
@@ -91,15 +93,17 @@ def _parse_one(idx: int, raw: object) -> Route:
|
|||||||
label = f"route[{idx}]"
|
label = f"route[{idx}]"
|
||||||
if not isinstance(raw, dict):
|
if not isinstance(raw, dict):
|
||||||
raise ValueError(f"{label}: must be an object (got {type(raw).__name__})")
|
raise ValueError(f"{label}: must be an object (got {type(raw).__name__})")
|
||||||
host = raw.get("host")
|
raw_dict: dict[str, object] = typing.cast(dict[str, object], raw)
|
||||||
|
host: object = raw_dict.get("host")
|
||||||
if not isinstance(host, str) or not host:
|
if not isinstance(host, str) or not host:
|
||||||
raise ValueError(f"{label}: 'host' must be a non-empty string")
|
raise ValueError(f"{label}: 'host' must be a non-empty string")
|
||||||
|
|
||||||
path_allow_raw = raw.get("path_allowlist", [])
|
path_allow_raw: object = raw_dict.get("path_allowlist", [])
|
||||||
if not isinstance(path_allow_raw, list):
|
if not isinstance(path_allow_raw, list):
|
||||||
raise ValueError(f"{label} ({host}): 'path_allowlist' must be a list")
|
raise ValueError(f"{label} ({host}): 'path_allowlist' must be a list")
|
||||||
|
path_allow_list: list[object] = typing.cast(list[object], path_allow_raw)
|
||||||
prefixes: list[str] = []
|
prefixes: list[str] = []
|
||||||
for j, p in enumerate(path_allow_raw):
|
for j, p in enumerate(path_allow_list):
|
||||||
if not isinstance(p, str):
|
if not isinstance(p, str):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"{label} ({host}): path_allowlist[{j}] must be a string"
|
f"{label} ({host}): path_allowlist[{j}] must be a string"
|
||||||
@@ -111,8 +115,8 @@ def _parse_one(idx: int, raw: object) -> Route:
|
|||||||
)
|
)
|
||||||
prefixes.append(p)
|
prefixes.append(p)
|
||||||
|
|
||||||
auth_scheme = raw.get("auth_scheme", "")
|
auth_scheme: object = raw_dict.get("auth_scheme", "")
|
||||||
token_env = raw.get("token_env", "")
|
token_env: object = raw_dict.get("token_env", "")
|
||||||
if not isinstance(auth_scheme, str):
|
if not isinstance(auth_scheme, str):
|
||||||
raise ValueError(f"{label} ({host}): 'auth_scheme' must be a string")
|
raise ValueError(f"{label} ({host}): 'auth_scheme' must be a string")
|
||||||
if not isinstance(token_env, str):
|
if not isinstance(token_env, str):
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from __future__ import annotations
|
|||||||
import dataclasses
|
import dataclasses
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ from .manifest_egress import (
|
|||||||
EgressConfig,
|
EgressConfig,
|
||||||
EgressRoute,
|
EgressRoute,
|
||||||
PipelockRoutePolicy,
|
PipelockRoutePolicy,
|
||||||
validate_egress_routes,
|
|
||||||
)
|
)
|
||||||
from .manifest_git import GitEntry, GitUser, parse_git_gate_config
|
from .manifest_git import GitEntry, GitUser, parse_git_gate_config
|
||||||
from .manifest_schema import BOTTLE_KEYS
|
from .manifest_schema import BOTTLE_KEYS
|
||||||
@@ -323,8 +322,11 @@ class Manifest:
|
|||||||
return
|
return
|
||||||
available = ", ".join(self.agents.keys())
|
available = ", ".join(self.agents.keys())
|
||||||
if available:
|
if available:
|
||||||
raise ManifestError(f"agent '{name}' not defined in bot-bottle.json. Available: {available}")
|
msg = f"agent '{name}' not defined in bot-bottle.json. Available: {available}"
|
||||||
raise ManifestError(f"agent '{name}' not defined in bot-bottle.json (manifest is empty).")
|
raise ManifestError(msg)
|
||||||
|
raise ManifestError(
|
||||||
|
f"agent '{name}' not defined in bot-bottle.json (manifest is empty)."
|
||||||
|
)
|
||||||
|
|
||||||
def has_bottle(self, name: str) -> bool:
|
def has_bottle(self, name: str) -> bool:
|
||||||
return name in self.bottles
|
return name in self.bottles
|
||||||
|
|||||||
@@ -114,7 +114,10 @@ class Agent:
|
|||||||
|
|
||||||
bottle = d.get("bottle")
|
bottle = d.get("bottle")
|
||||||
if not isinstance(bottle, str) or not bottle:
|
if not isinstance(bottle, str) or not bottle:
|
||||||
raise ManifestError(f"agent '{name}' must declare a 'bottle' field naming a defined bottle")
|
raise ManifestError(
|
||||||
|
f"agent '{name}' must declare a 'bottle' field naming a "
|
||||||
|
f"defined bottle"
|
||||||
|
)
|
||||||
if bottle not in bottle_names:
|
if bottle not in bottle_names:
|
||||||
available = ", ".join(sorted(bottle_names)) or "(none defined)"
|
available = ", ".join(sorted(bottle_names)) or "(none defined)"
|
||||||
raise ManifestError(
|
raise ManifestError(
|
||||||
@@ -126,7 +129,10 @@ class Agent:
|
|||||||
skills_raw = d.get("skills")
|
skills_raw = d.get("skills")
|
||||||
if skills_raw is not None:
|
if skills_raw is not None:
|
||||||
if not isinstance(skills_raw, list):
|
if not isinstance(skills_raw, list):
|
||||||
raise ManifestError(f"agent '{name}' skills must be an array (was {type(skills_raw).__name__})")
|
raise ManifestError(
|
||||||
|
f"agent '{name}' skills must be an array "
|
||||||
|
f"(was {type(skills_raw).__name__})"
|
||||||
|
)
|
||||||
collected: list[str] = []
|
collected: list[str] = []
|
||||||
skills_list = cast(list[object], skills_raw)
|
skills_list = cast(list[object], skills_raw)
|
||||||
for i, skill in enumerate(skills_list):
|
for i, skill in enumerate(skills_list):
|
||||||
@@ -144,7 +150,10 @@ class Agent:
|
|||||||
elif isinstance(prompt_raw, str):
|
elif isinstance(prompt_raw, str):
|
||||||
prompt = prompt_raw
|
prompt = prompt_raw
|
||||||
else:
|
else:
|
||||||
raise ManifestError(f"agent '{name}' prompt must be a string (was {type(prompt_raw).__name__})")
|
raise ManifestError(
|
||||||
|
f"agent '{name}' prompt must be a string "
|
||||||
|
f"(was {type(prompt_raw).__name__})"
|
||||||
|
)
|
||||||
|
|
||||||
# git-gate: agents may declare only `git-gate.user` (name/email).
|
# git-gate: agents may declare only `git-gate.user` (name/email).
|
||||||
# `git-gate.repos` is bottle-only — it carries credentials and host trust.
|
# `git-gate.repos` is bottle-only — it carries credentials and host trust.
|
||||||
|
|||||||
@@ -214,7 +214,8 @@ class EgressRoute:
|
|||||||
collected_roles: list[str] = []
|
collected_roles: list[str] = []
|
||||||
for r in role_list:
|
for r in role_list:
|
||||||
if not isinstance(r, str):
|
if not isinstance(r, str):
|
||||||
raise ManifestError(f"{label} role items must be strings (got {type(r).__name__})")
|
msg = f"{label} role items must be strings (got {type(r).__name__})"
|
||||||
|
raise ManifestError(msg)
|
||||||
collected_roles.append(r)
|
collected_roles.append(r)
|
||||||
roles = tuple(collected_roles)
|
roles = tuple(collected_roles)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -30,12 +30,18 @@ def parse_git_upstream(url: str, label: str) -> tuple[str, str, str, str]:
|
|||||||
raise ManifestError(f"{label} must be an ssh:// URL (was {url!r})")
|
raise ManifestError(f"{label} must be an ssh:// URL (was {url!r})")
|
||||||
rest = url[len("ssh://"):]
|
rest = url[len("ssh://"):]
|
||||||
if "@" not in rest:
|
if "@" not in rest:
|
||||||
raise ManifestError(f"{label} must include a user (e.g. ssh://git@host/path.git); was {url!r}")
|
raise ManifestError(
|
||||||
|
f"{label} must include a user (e.g. ssh://git@host/path.git); "
|
||||||
|
f"was {url!r}"
|
||||||
|
)
|
||||||
user, _, hostpart = rest.partition("@")
|
user, _, hostpart = rest.partition("@")
|
||||||
if not user:
|
if not user:
|
||||||
raise ManifestError(f"{label} user is empty in {url!r}")
|
raise ManifestError(f"{label} user is empty in {url!r}")
|
||||||
if "/" not in hostpart:
|
if "/" not in hostpart:
|
||||||
raise ManifestError(f"{label} must include a path (e.g. ssh://git@host/path.git); was {url!r}")
|
raise ManifestError(
|
||||||
|
f"{label} must include a path (e.g. ssh://git@host/path.git); "
|
||||||
|
f"was {url!r}"
|
||||||
|
)
|
||||||
hostport, _, path = hostpart.partition("/")
|
hostport, _, path = hostpart.partition("/")
|
||||||
if not path:
|
if not path:
|
||||||
raise ManifestError(f"{label} path is empty in {url!r}")
|
raise ManifestError(f"{label} path is empty in {url!r}")
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from __future__ import annotations
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from .egress import EGRESS_HOSTNAME, EgressRoute, egress_routes_for_bottle
|
from .egress import EgressRoute, egress_routes_for_bottle
|
||||||
from .supervise import SUPERVISE_HOSTNAME
|
from .supervise import SUPERVISE_HOSTNAME
|
||||||
from .manifest import Bottle
|
from .manifest import Bottle
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|||||||
@@ -159,7 +159,10 @@ TOOL_DEFINITIONS: list[dict[str, object]] = [
|
|||||||
"properties": {
|
"properties": {
|
||||||
"host": {
|
"host": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The hostname to allow (e.g. 'api.github.com'). Case-insensitive on match.",
|
"description": (
|
||||||
|
"The hostname to allow (e.g. 'api.github.com'). "
|
||||||
|
"Case-insensitive on match."
|
||||||
|
),
|
||||||
},
|
},
|
||||||
"path_allowlist": {
|
"path_allowlist": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ this test runs in DinD too — no act_runner skip needed.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
@@ -32,7 +31,7 @@ import unittest
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from bot_bottle import supervise
|
from bot_bottle import supervise
|
||||||
from bot_bottle.backend.docker import bottle_state, capability_apply
|
from bot_bottle.backend.docker import bottle_state
|
||||||
from bot_bottle.backend.docker.capability_apply import apply_capability_change
|
from bot_bottle.backend.docker.capability_apply import apply_capability_change
|
||||||
from bot_bottle.backend.docker.network import (
|
from bot_bottle.backend.docker.network import (
|
||||||
network_create_egress,
|
network_create_egress,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ localhost-reach / egress-port-bypass probes) lives in chunk 2d."""
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from pathlib import Path
|
|||||||
from bot_bottle.agent_provider import (
|
from bot_bottle.agent_provider import (
|
||||||
CODEX_HOST_CREDENTIAL_HOSTS,
|
CODEX_HOST_CREDENTIAL_HOSTS,
|
||||||
agent_provision_plan,
|
agent_provision_plan,
|
||||||
runtime_for,
|
|
||||||
)
|
)
|
||||||
from bot_bottle.egress import CODEX_HOST_CREDENTIAL_TOKEN_REF
|
from bot_bottle.egress import CODEX_HOST_CREDENTIAL_TOKEN_REF
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from __future__ import annotations
|
|||||||
import subprocess
|
import subprocess
|
||||||
import unittest
|
import unittest
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
from unittest.mock import MagicMock, call, patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ the operator confirms. Mocks the backends and stdin."""
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import sys
|
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import patch, MagicMock
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,8 @@ All actual launch work is stubbed so no container is created.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import types
|
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import MagicMock, patch, call
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import bot_bottle.cli.start as start_mod
|
import bot_bottle.cli.start as start_mod
|
||||||
import bot_bottle.cli.tui as tui_mod
|
import bot_bottle.cli.tui as tui_mod
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ from unittest.mock import MagicMock, patch
|
|||||||
|
|
||||||
from bot_bottle.agent_provider import (
|
from bot_bottle.agent_provider import (
|
||||||
AgentProvisionCommand,
|
AgentProvisionCommand,
|
||||||
AgentProvisionDir,
|
|
||||||
AgentProvisionFile,
|
AgentProvisionFile,
|
||||||
AgentProvisionPlan,
|
AgentProvisionPlan,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ import json
|
|||||||
import unittest
|
import unittest
|
||||||
import urllib.error
|
import urllib.error
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from pathlib import Path
|
from unittest.mock import MagicMock, patch
|
||||||
from tempfile import mkdtemp
|
|
||||||
from unittest.mock import MagicMock, call, patch
|
|
||||||
|
|
||||||
from bot_bottle.contrib.gitea.deploy_key_provisioner import (
|
from bot_bottle.contrib.gitea.deploy_key_provisioner import (
|
||||||
GiteaDeployKeyProvisioner,
|
GiteaDeployKeyProvisioner,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from bot_bottle.deploy_key_provisioner import DeployKeyProvisioner, get_provisioner
|
from bot_bottle.deploy_key_provisioner import DeployKeyProvisioner, get_provisioner
|
||||||
from bot_bottle.manifest import ManifestError
|
from bot_bottle.manifest import ManifestError
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from __future__ import annotations
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import MagicMock, call
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from bot_bottle.agent_provider import AgentProvisionPlan
|
from bot_bottle.agent_provider import AgentProvisionPlan
|
||||||
from bot_bottle.backend import Bottle, BottleSpec, ExecResult
|
from bot_bottle.backend import Bottle, BottleSpec, ExecResult
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ auth omission means unauthenticated."""
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bot_bottle.manifest import ManifestError, EgressRoute, Manifest
|
from bot_bottle.manifest import ManifestError, Manifest
|
||||||
|
|
||||||
|
|
||||||
def _bottle(routes):
|
def _bottle(routes):
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, cast
|
from typing import cast
|
||||||
|
|
||||||
from bot_bottle.manifest import Manifest
|
from bot_bottle.manifest import Manifest
|
||||||
from bot_bottle.pipelock import (
|
from bot_bottle.pipelock import (
|
||||||
|
|||||||
@@ -220,7 +220,11 @@ class TestEgressPrintParity(unittest.TestCase):
|
|||||||
indent_prefix = ln[:idx]
|
indent_prefix = ln[:idx]
|
||||||
result.append(ln)
|
result.append(ln)
|
||||||
elif collecting:
|
elif collecting:
|
||||||
if ln.startswith(indent_prefix) and "egress" not in ln and ":" not in ln.lstrip()[:20]:
|
if (
|
||||||
|
ln.startswith(indent_prefix)
|
||||||
|
and "egress" not in ln
|
||||||
|
and ":" not in ln.lstrip()[:20]
|
||||||
|
):
|
||||||
result.append(ln)
|
result.append(ln)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ class TestCleanup(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
results = iter([
|
results = iter([
|
||||||
_ok(), # stop succeeds
|
_ok(), # stop succeeds
|
||||||
subprocess.CompletedProcess(args=[], returncode=1, stdout="", stderr="boom"), # delete fails
|
subprocess.CompletedProcess(
|
||||||
|
args=[], returncode=1, stdout="", stderr="boom"
|
||||||
|
), # delete fails
|
||||||
_ok(), # bundle rm succeeds
|
_ok(), # bundle rm succeeds
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import json
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ class TestSmolmachinesResolveEnv(unittest.TestCase):
|
|||||||
patch("bot_bottle.backend.smolmachines.prepare.PipelockProxy") as mock_pl,
|
patch("bot_bottle.backend.smolmachines.prepare.PipelockProxy") as mock_pl,
|
||||||
patch("bot_bottle.backend.smolmachines.prepare.Egress") as mock_eg,
|
patch("bot_bottle.backend.smolmachines.prepare.Egress") as mock_eg,
|
||||||
patch("bot_bottle.backend.smolmachines.prepare.Supervise"),
|
patch("bot_bottle.backend.smolmachines.prepare.Supervise"),
|
||||||
patch("bot_bottle.backend.smolmachines.prepare.agent_provision_plan") as mock_app,
|
patch(
|
||||||
|
"bot_bottle.backend.smolmachines.prepare.agent_provision_plan"
|
||||||
|
) as mock_app,
|
||||||
patch("bot_bottle.backend.smolmachines.prepare.runtime_for"),
|
patch("bot_bottle.backend.smolmachines.prepare.runtime_for"),
|
||||||
):
|
):
|
||||||
mock_gg.return_value.prepare.return_value = MagicMock()
|
mock_gg.return_value.prepare.return_value = MagicMock()
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ from bot_bottle.supervise import (
|
|||||||
FIXED_TS = datetime(2026, 5, 25, 12, 0, 0, tzinfo=timezone.utc)
|
FIXED_TS = datetime(2026, 5, 25, 12, 0, 0, tzinfo=timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
def _proposal(tool: str = TOOL_EGRESS_BLOCK, proposed: str = "{}", justification: str = "need a route") -> Proposal:
|
def _proposal(
|
||||||
|
tool: str = TOOL_EGRESS_BLOCK,
|
||||||
|
proposed: str = "{}",
|
||||||
|
justification: str = "need a route",
|
||||||
|
) -> Proposal:
|
||||||
return Proposal.new(
|
return Proposal.new(
|
||||||
bottle_slug="dev",
|
bottle_slug="dev",
|
||||||
tool=tool,
|
tool=tool,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ which hostname will land in pipelock's allowlist on approval."""
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bot_bottle import supervise
|
|
||||||
from bot_bottle.cli import supervise as supervise_cli
|
from bot_bottle.cli import supervise as supervise_cli
|
||||||
from bot_bottle.supervise import (
|
from bot_bottle.supervise import (
|
||||||
Proposal,
|
Proposal,
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ from bot_bottle.supervise_server import (
|
|||||||
jsonrpc_error,
|
jsonrpc_error,
|
||||||
jsonrpc_result,
|
jsonrpc_result,
|
||||||
parse_jsonrpc,
|
parse_jsonrpc,
|
||||||
serve,
|
|
||||||
validate_proposed_file,
|
validate_proposed_file,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user