From 843b672f74259bf83db57f75756de54752a04872 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Fri, 9 Oct 2026 20:33:50 -0700 Subject: [PATCH 1/3] fix: avoid redundant Docker agent Node bootstrap Signed-off-by: Christopher Kevin --- CHANGELOG.md | 4 + src/skillevaluator/tier3/harbor/__init__.py | 8 + .../tier3/harbor/installed_agents.py | 70 +++++ .../tier3/harbor/local_agents.py | 8 +- src/skillevaluator/tier3/harbor/runner.py | 7 +- tests/test_harbor_local_mode.py | 8 +- tests/tier3/test_installed_agent_bootstrap.py | 293 ++++++++++++++++++ 7 files changed, 387 insertions(+), 11 deletions(-) create mode 100644 src/skillevaluator/tier3/harbor/installed_agents.py create mode 100644 tests/tier3/test_installed_agent_bootstrap.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b35b49e8..7b3192f9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to SkillEvaluator are documented in this file. ### Fixed +- Fixed Docker Codex and Claude Code setup wasting its timeout installing + distribution Node/npm before Harbor's own installers. Native, gateway Codex, + and NVIDIA Build agents now provision Node/npm only on the installer branches + that need them, while preserving installed-agent and version-pin checks. - Brought the published documentation in line with 0.5.0. It now covers how standard grading builds judge evidence and rebuilds trajectories from OpenCode and Codex logs, structured judge output and retries, the evidence diff --git a/src/skillevaluator/tier3/harbor/__init__.py b/src/skillevaluator/tier3/harbor/__init__.py index 96abfa7a0..26ea8f08b 100644 --- a/src/skillevaluator/tier3/harbor/__init__.py +++ b/src/skillevaluator/tier3/harbor/__init__.py @@ -32,6 +32,13 @@ "opencode": "skillevaluator.tier3.harbor.local_agents:SkillEvaluatorLocalOpenCode", } +# Docker wrappers retain Harbor's installers while avoiding redundant Node/npm +# packages on the branches that bootstrap their own runtime. +DOCKER_AGENT_IMPORT_PATHS = { + "codex": "skillevaluator.tier3.harbor.installed_agents:SkillEvaluatorCodex", + "claude-code": "skillevaluator.tier3.harbor.installed_agents:SkillEvaluatorClaudeCode", +} + HARBOR_AGENTS_SUPPORTED = frozenset( { "claude-code", @@ -61,6 +68,7 @@ def canonical_agent_name(agent: str) -> str: "AGENT_ALIASES", "DEFAULT_ENV_MODE", "DEFAULT_LLM_VERIFIER_TIMEOUT_SEC", + "DOCKER_AGENT_IMPORT_PATHS", "ENV_MODE_LOCAL", "HARBOR_AGENTS", "HARBOR_AGENTS_EXPERIMENTAL", diff --git a/src/skillevaluator/tier3/harbor/installed_agents.py b/src/skillevaluator/tier3/harbor/installed_agents.py new file mode 100644 index 000000000..9d97d1450 --- /dev/null +++ b/src/skillevaluator/tier3/harbor/installed_agents.py @@ -0,0 +1,70 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Keep Harbor's bootstrap dependencies aligned with its installer branches.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from harbor.agents.installed.claude_code import ClaudeCode +from harbor.agents.installed.codex import Codex + +if TYPE_CHECKING: + from harbor.environments.base import BaseEnvironment + + +async def _installer_dependencies( + environment: BaseEnvironment, + dependencies: tuple[str, ...], + *, + system_npm_predicate: str, +) -> tuple[str, ...]: + if not {"nodejs", "npm"}.intersection(dependencies): + return dependencies + + # Match the pinned Harbor installer's branch before removing prerequisites. + # Codex supplies Node via NVM on glibc; Claude's native installer needs no + # Node. Both still need system npm on their respective fallback branches. + result = await environment.exec( + command=f"if {system_npm_predicate}; then printf '%s' system; else printf '%s' bundled; fi", + user="root", + ) + installer = (result.stdout or "").strip() + if result.return_code != 0 or installer not in {"system", "bundled"}: + raise RuntimeError("Could not determine agent installer system dependency requirements") + if installer == "system": + return dependencies + return tuple(dependency for dependency in dependencies if dependency not in {"nodejs", "npm"}) + + +class SkillEvaluatorCodex(Codex): + """Avoid a redundant distribution Node/npm install before Harbor's NVM.""" + + async def ensure_system_dependencies( + self, + environment: BaseEnvironment, + dependencies: tuple[str, ...], + ) -> None: + dependencies = await _installer_dependencies( + environment, + dependencies, + system_npm_predicate="ldd --version 2>&1 | grep -qi musl || [ -f /etc/alpine-release ]", + ) + await super().ensure_system_dependencies(environment, dependencies) + + +class SkillEvaluatorClaudeCode(ClaudeCode): + """Avoid distribution Node/npm for Harbor's native Claude installer.""" + + async def ensure_system_dependencies( + self, + environment: BaseEnvironment, + dependencies: tuple[str, ...], + ) -> None: + dependencies = await _installer_dependencies( + environment, + dependencies, + system_npm_predicate="command -v apk >/dev/null 2>&1", + ) + await super().ensure_system_dependencies(environment, dependencies) diff --git a/src/skillevaluator/tier3/harbor/local_agents.py b/src/skillevaluator/tier3/harbor/local_agents.py index 65a1796a1..d38e92443 100644 --- a/src/skillevaluator/tier3/harbor/local_agents.py +++ b/src/skillevaluator/tier3/harbor/local_agents.py @@ -22,10 +22,10 @@ from harbor.agents.installed.base import NonZeroAgentExitCodeError from harbor.agents.installed.claude_code import ClaudeCode -from harbor.agents.installed.codex import Codex from harbor.agents.installed.opencode import OpenCode from harbor.models.trial.paths import EnvironmentPaths +from skillevaluator.tier3.harbor.installed_agents import SkillEvaluatorClaudeCode, SkillEvaluatorCodex from skillevaluator.tier3.harbor.nvidia_build_bridge import ( MAX_REQUESTS_PER_BRIDGE, RunningBridge, @@ -148,7 +148,7 @@ async def exec_as_agent( ) -class SkillEvaluatorGatewayCodex(Codex): +class SkillEvaluatorGatewayCodex(SkillEvaluatorCodex): """Use an explicit Responses gateway without truncating its catalog model ID.""" def _build_effective_config(self, openai_base_url: str | None = None) -> dict[str, Any]: @@ -668,7 +668,7 @@ async def run(self, instruction, environment: BaseEnvironment, context) -> None: raise -class SkillEvaluatorNvidiaBuildCodex(_NvidiaBuildBridgeAgent, Codex): +class SkillEvaluatorNvidiaBuildCodex(_NvidiaBuildBridgeAgent, SkillEvaluatorCodex): """Stock Codex CLI routed through the in-trial NVIDIA Build bridge.""" _BRIDGE_CLIENT_ENV_UNSET = ("NVIDIA_API_KEY", "OPENAI_BASE_URL", "OPENAI_API_BASE") @@ -714,7 +714,7 @@ def replace(match: re.Match[str]) -> str: return _rewrite_launcher_segment(command, lambda text: _CODEX_MODEL_ARG_RE.sub(replace, text)) -class SkillEvaluatorNvidiaBuildClaudeCode(_NvidiaBuildBridgeAgent, ClaudeCode): +class SkillEvaluatorNvidiaBuildClaudeCode(_NvidiaBuildBridgeAgent, SkillEvaluatorClaudeCode): """Stock Claude Code CLI routed through the in-trial NVIDIA Build bridge.""" def _bridge_client_environment(self) -> dict[str, str]: diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.py index c46d0f161..647a796f2 100644 --- a/src/skillevaluator/tier3/harbor/runner.py +++ b/src/skillevaluator/tier3/harbor/runner.py @@ -1263,10 +1263,9 @@ def build_harbor_run_command( ] ) elif env_mode == "docker": - if agent_import_path: - command.extend(["--agent", agent_import_path]) - else: - command.extend(["--agent", agent]) + from skillevaluator.tier3.harbor import DOCKER_AGENT_IMPORT_PATHS + + command.extend(["--agent", agent_import_path or DOCKER_AGENT_IMPORT_PATHS.get(agent, agent)]) command.extend(["--env", SECURE_DOCKER_ENV_IMPORT_PATH]) else: command.extend(["--agent", agent_import_path or agent, "--env", harbor_environment_type(env_mode)]) diff --git a/tests/test_harbor_local_mode.py b/tests/test_harbor_local_mode.py index d6e94b9f2..494fb80d7 100644 --- a/tests/test_harbor_local_mode.py +++ b/tests/test_harbor_local_mode.py @@ -34,6 +34,7 @@ from skillevaluator.provider_config import ProviderConfig from skillevaluator.tier3.harbor import ( + DOCKER_AGENT_IMPORT_PATHS, ENV_MODE_LOCAL, HARBOR_ENV_MODES, HARBOR_NATIVE_ENV_MODES, @@ -496,13 +497,14 @@ def test_build_command_wires_strict_read_policy(monkeypatch: pytest.MonkeyPatch) assert "strict_reads=true" in " ".join(cmd) -def test_build_command_docker_mode_uses_secure_import_path() -> None: - cmd = build_harbor_run_command(dataset_path="/tmp/ds", agent="codex", job_name="j", env_mode="docker") +@pytest.mark.parametrize("agent", ["codex", "claude-code", "opencode"]) +def test_build_command_docker_mode_uses_secure_import_path(agent: str) -> None: + cmd = build_harbor_run_command(dataset_path="/tmp/ds", agent=agent, job_name="j", env_mode="docker") assert "--agent-import-path" not in cmd assert "--environment-import-path" not in cmd assert "-a" not in cmd assert cmd.count("--agent") == 1 - assert cmd[cmd.index("--agent") + 1] == "codex" + assert cmd[cmd.index("--agent") + 1] == DOCKER_AGENT_IMPORT_PATHS.get(agent, agent) assert cmd.count("--env") == 1 assert cmd[cmd.index("--env") + 1] == SECURE_DOCKER_ENV_IMPORT_PATH diff --git a/tests/tier3/test_installed_agent_bootstrap.py b/tests/tier3/test_installed_agent_bootstrap.py new file mode 100644 index 000000000..e9ae37f75 --- /dev/null +++ b/tests/tier3/test_installed_agent_bootstrap.py @@ -0,0 +1,293 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Exercise the inherited Harbor bootstrap, including package selection.""" + +import asyncio +from pathlib import Path + +import pytest + +pytest.importorskip("harbor") + +from harbor.agents.factory import AgentFactory +from harbor.agents.installed.claude_code import ClaudeCode +from harbor.agents.installed.codex import Codex +from harbor.environments.base import ExecResult +from harbor.models.trial.config import AgentConfig + +from skillevaluator.tier3.harbor import DOCKER_AGENT_IMPORT_PATHS +from skillevaluator.tier3.harbor.installed_agents import SkillEvaluatorClaudeCode, SkillEvaluatorCodex +from skillevaluator.tier3.harbor.local_agents import ( + SkillEvaluatorGatewayCodex, + SkillEvaluatorLocalClaudeCode, + SkillEvaluatorLocalCodex, + SkillEvaluatorNvidiaBuildClaudeCode, + SkillEvaluatorNvidiaBuildCodex, +) + + +class _BootstrapEnvironment: + default_user = None + + def __init__( + self, + *, + manager: str = "apt-get", + system_node: bool = False, + missing_commands: tuple[str, ...] = ("node", "npm"), + installed: bool = False, + installed_version: str = "1.2.3", + probe_result: ExecResult | None = None, + probe_error: Exception | None = None, + ) -> None: + self.commands: list[str] = [] + self.exec_kwargs: list[dict[str, object]] = [] + self.manager = manager + self.system_node = system_node + self.missing_commands = missing_commands + self.installed = installed + self.installed_version = installed_version + self.probe_result = probe_result + self.probe_error = probe_error + + @property + def probes(self) -> list[str]: + return [command for command in self.commands if command.startswith("if ") and "printf" in command] + + @property + def package_installs(self) -> list[str]: + return [ + command + for command in self.commands + if any(text in command for text in ("apt-get install", "dnf install", "yum install", "apk add")) + ] + + async def exec(self, command: str, **_kwargs: object) -> ExecResult: + self.commands.append(command) + self.exec_kwargs.append(_kwargs) + if command in (Codex._INSTALL_CHECK_COMMAND, ClaudeCode._INSTALL_CHECK_COMMAND): + return ExecResult(return_code=0 if self.installed else 1, stdout="", stderr="") + if command in (Codex._INSTALL_VERSION_COMMAND, ClaudeCode._INSTALL_VERSION_COMMAND): + version = ( + f"codex-cli {self.installed_version}" + if command == Codex._INSTALL_VERSION_COMMAND + else f"{self.installed_version} (Claude Code)" + ) + return ExecResult(return_code=0 if self.installed else 1, stdout=version, stderr="") + if command.startswith("command -v ") and command.endswith(" >/dev/null 2>&1"): + executable = command.split()[2] + return ExecResult(return_code=1 if executable in self.missing_commands else 0, stdout="", stderr="") + if command.startswith("for manager in "): + return ExecResult(return_code=0, stdout=self.manager, stderr="") + if command.startswith("if ") and "printf" in command: + if self.probe_error is not None: + raise self.probe_error + if self.probe_result is not None: + return self.probe_result + return ExecResult(return_code=0, stdout="system" if self.system_node else "bundled", stderr="") + return ExecResult(return_code=0, stdout="", stderr="") + + +def test_gateway_codex_debian_bootstrap_does_not_install_system_node(tmp_path: Path) -> None: + environment = _BootstrapEnvironment() + agent = SkillEvaluatorGatewayCodex(logs_dir=tmp_path, model_name="openai/test-model") + + asyncio.run(agent.install(environment)) + + assert environment.package_installs == [], f"Unexpected system package install: {environment.package_installs}" + assert any("nvm install 22" in command for command in environment.commands) + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +@pytest.mark.parametrize("manager", ["apt-get", "dnf"]) +def test_native_bootstrap_avoids_system_node_and_keeps_vendor_installer( + tmp_path: Path, agent_class: type, manager: str +) -> None: + environment = _BootstrapEnvironment(manager=manager) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + asyncio.run(agent.install(environment)) + + assert environment.package_installs == [] + assert len(environment.probes) == 1 + probe_index = environment.commands.index(environment.probes[0]) + assert environment.exec_kwargs[probe_index]["user"] == "root" + if agent_class is SkillEvaluatorCodex: + assert "ldd --version 2>&1 | grep -qi musl || [ -f /etc/alpine-release ]" in environment.probes[0] + assert any("nvm install 22" in command for command in environment.commands) + assert any("ln -sf" in command for command in environment.commands) + else: + assert "command -v apk" in environment.probes[0] + assert any("https://downloads.claude.ai/claude-code-releases/bootstrap.sh" in c for c in environment.commands) + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +@pytest.mark.parametrize("manager", ["apt-get", "apk"]) +def test_system_npm_installer_still_provisions_node_and_npm(tmp_path: Path, agent_class: type, manager: str) -> None: + environment = _BootstrapEnvironment(manager=manager, system_node=True) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + asyncio.run(agent.install(environment)) + + assert len(environment.package_installs) == 1 + assert "nodejs npm" in environment.package_installs[0] + assert environment.package_installs[0].startswith( + "set -o pipefail; apt-get update" if manager == "apt-get" else "set -o pipefail; apk add" + ) + assert any("npm install -g" in command for command in environment.commands) + + +@pytest.mark.parametrize( + ("agent_class", "missing_command", "expected_package"), + [(SkillEvaluatorCodex, "rg", "ripgrep"), (SkillEvaluatorClaudeCode, "pgrep", "procps")], +) +def test_native_bootstrap_preserves_other_system_dependencies( + tmp_path: Path, agent_class: type, missing_command: str, expected_package: str +) -> None: + environment = _BootstrapEnvironment(missing_commands=("node", "npm", missing_command)) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + asyncio.run(agent.install(environment)) + + assert environment.package_installs == [f"set -o pipefail; apt-get update && apt-get install -y {expected_package}"] + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +@pytest.mark.parametrize("version", [None, "1.2.3"]) +def test_existing_matching_cli_skips_probe_and_bootstrap( + tmp_path: Path, agent_class: type, version: str | None +) -> None: + environment = _BootstrapEnvironment(installed=True) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model", version=version) + + asyncio.run(agent.install(environment)) + + assert len(environment.commands) == 1 + assert environment.probes == [] + assert environment.package_installs == [] + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +def test_mismatching_cli_version_runs_bootstrap_with_requested_version(tmp_path: Path, agent_class: type) -> None: + environment = _BootstrapEnvironment(installed=True, installed_version="1.2.2") + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model", version="1.2.3") + + asyncio.run(agent.install(environment)) + + assert environment.package_installs == [] + assert len(environment.probes) == 1 + expected = "@openai/codex@1.2.3" if agent_class is SkillEvaluatorCodex else "bash -s -- 1.2.3" + assert any(expected in command for command in environment.commands) + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +@pytest.mark.parametrize( + ("return_code", "stdout"), + [(1, "bundled"), (137, ""), (0, ""), (0, "unrecognized")], +) +def test_unknown_installer_platform_stops_without_installing( + tmp_path: Path, agent_class: type, return_code: int, stdout: str +) -> None: + environment = _BootstrapEnvironment(probe_result=ExecResult(return_code=return_code, stdout=stdout, stderr="")) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + with pytest.raises(RuntimeError, match="Could not determine"): + asyncio.run(agent.install(environment)) + + assert environment.package_installs == [] + assert not any("npm install -g" in command for command in environment.commands) + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +def test_platform_probe_transport_errors_propagate(tmp_path: Path, agent_class: type) -> None: + environment = _BootstrapEnvironment(probe_error=TimeoutError("probe transport timeout")) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + with pytest.raises(TimeoutError, match="probe transport timeout"): + asyncio.run(agent.install(environment)) + + assert environment.package_installs == [] + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +def test_non_node_dependency_requests_skip_platform_detection(tmp_path: Path, agent_class: type) -> None: + environment = _BootstrapEnvironment(missing_commands=("git",), probe_error=AssertionError("unneeded probe")) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + asyncio.run(agent.ensure_system_dependencies(environment, ("git",))) + + assert environment.package_installs == ["set -o pipefail; apt-get update && apt-get install -y git"] + assert environment.probes == [] + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +def test_native_bootstrap_preserves_unknown_dependency_validation(tmp_path: Path, agent_class: type) -> None: + environment = _BootstrapEnvironment() + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + with pytest.raises(ValueError, match="Unknown system dependencies: unknown-package"): + asyncio.run(agent.ensure_system_dependencies(environment, ("nodejs", "npm", "unknown-package"))) + + assert len(environment.probes) == 1 + assert environment.package_installs == [] + + +@pytest.mark.parametrize( + ("agent_name", "agent_class", "model_name"), + [ + ("codex", SkillEvaluatorCodex, "openai/test-model"), + ("claude-code", SkillEvaluatorClaudeCode, "anthropic/test-model"), + ], +) +@pytest.mark.parametrize("config_field", ["name", "import_path"]) +def test_docker_import_routes_resolve_and_preserve_report_identity( + tmp_path: Path, agent_name: str, agent_class: type, model_name: str, config_field: str +) -> None: + config = AgentConfig( + **{config_field: DOCKER_AGENT_IMPORT_PATHS[agent_name]}, + model_name=model_name, + kwargs={"version": "1.2.3"}, + ) + + assert AgentFactory.get_agent_class_from_config(config) is agent_class + agent = AgentFactory.create_agent_from_config(config, logs_dir=tmp_path) + + assert type(agent) is agent_class + assert agent.name() == agent_name + info = agent.to_agent_info() + assert info.name == agent_name + assert info.version == "1.2.3" + assert info.model_info is not None + assert info.model_info.name == "test-model" + assert info.model_info.provider == model_name.split("/", maxsplit=1)[0] + + +@pytest.mark.parametrize( + "agent_class", + [SkillEvaluatorGatewayCodex, SkillEvaluatorNvidiaBuildCodex, SkillEvaluatorNvidiaBuildClaudeCode], +) +def test_gateway_and_nvidia_wrappers_use_repaired_bootstrap(tmp_path: Path, agent_class: type) -> None: + environment = _BootstrapEnvironment() + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + asyncio.run(agent.install(environment)) + + assert environment.package_installs == [] + assert len(environment.probes) == 1 + assert any("npm install -g" in command for command in environment.commands) + + +@pytest.mark.parametrize("agent_class", [SkillEvaluatorLocalCodex, SkillEvaluatorLocalClaudeCode]) +def test_local_agents_keep_existing_version_check_without_install(tmp_path: Path, agent_class: type) -> None: + environment = _BootstrapEnvironment(installed=True) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + asyncio.run(agent.install(environment)) + + assert len(environment.commands) == 1 + assert environment.commands[0].endswith( + "codex --version" if agent_class is SkillEvaluatorLocalCodex else "claude --version" + ) + assert environment.package_installs == [] + assert environment.probes == [] From 3829bfedb08a31e8958ac2f9dace88dc9f46c02d Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Tue, 13 Oct 2026 19:00:50 -0700 Subject: [PATCH 2/3] fix(tier3): install a CA bundle when skipping Docker agent Node/npm On apt images the CA bundle used by the Codex NVM and Claude Code bootstrap downloads arrived only as a dependency of the npm package. With Node/npm skipped, images that already have curl but no CA bundle failed setup with curl error 77. The installer probe now also checks for a CA bundle and requests Harbor's ca_certificates dependency when none is present. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- .../tier3/harbor/installed_agents.py | 18 ++++++++++-- tests/tier3/test_installed_agent_bootstrap.py | 29 ++++++++++++++++++- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/skillevaluator/tier3/harbor/installed_agents.py b/src/skillevaluator/tier3/harbor/installed_agents.py index 9d97d1450..b6e514f4d 100644 --- a/src/skillevaluator/tier3/harbor/installed_agents.py +++ b/src/skillevaluator/tier3/harbor/installed_agents.py @@ -13,6 +13,11 @@ if TYPE_CHECKING: from harbor.environments.base import BaseEnvironment +# Harbor's installers download over HTTPS but never request a CA bundle; apt +# images used to get one only as a dependency of the skipped npm package. +_CA_BUNDLE_PREDICATE = "[ -s /etc/ssl/certs/ca-certificates.crt ] || [ -s /etc/pki/tls/certs/ca-bundle.crt ]" +_INSTALLER_BRANCHES = frozenset({"system", "bundled", "bundled-without-ca"}) + async def _installer_dependencies( environment: BaseEnvironment, @@ -27,15 +32,22 @@ async def _installer_dependencies( # Codex supplies Node via NVM on glibc; Claude's native installer needs no # Node. Both still need system npm on their respective fallback branches. result = await environment.exec( - command=f"if {system_npm_predicate}; then printf '%s' system; else printf '%s' bundled; fi", + command=( + f"if {system_npm_predicate}; then printf '%s' system; " + f"elif {_CA_BUNDLE_PREDICATE}; then printf '%s' bundled; " + "else printf '%s' bundled-without-ca; fi" + ), user="root", ) installer = (result.stdout or "").strip() - if result.return_code != 0 or installer not in {"system", "bundled"}: + if result.return_code != 0 or installer not in _INSTALLER_BRANCHES: raise RuntimeError("Could not determine agent installer system dependency requirements") if installer == "system": return dependencies - return tuple(dependency for dependency in dependencies if dependency not in {"nodejs", "npm"}) + bundled = tuple(dependency for dependency in dependencies if dependency not in {"nodejs", "npm"}) + if installer == "bundled-without-ca": + return (*bundled, "ca_certificates") + return bundled class SkillEvaluatorCodex(Codex): diff --git a/tests/tier3/test_installed_agent_bootstrap.py b/tests/tier3/test_installed_agent_bootstrap.py index e9ae37f75..337e60a9b 100644 --- a/tests/tier3/test_installed_agent_bootstrap.py +++ b/tests/tier3/test_installed_agent_bootstrap.py @@ -35,6 +35,7 @@ def __init__( *, manager: str = "apt-get", system_node: bool = False, + ca_bundle: bool = True, missing_commands: tuple[str, ...] = ("node", "npm"), installed: bool = False, installed_version: str = "1.2.3", @@ -45,6 +46,7 @@ def __init__( self.exec_kwargs: list[dict[str, object]] = [] self.manager = manager self.system_node = system_node + self.ca_bundle = ca_bundle self.missing_commands = missing_commands self.installed = installed self.installed_version = installed_version @@ -85,7 +87,9 @@ async def exec(self, command: str, **_kwargs: object) -> ExecResult: raise self.probe_error if self.probe_result is not None: return self.probe_result - return ExecResult(return_code=0, stdout="system" if self.system_node else "bundled", stderr="") + if self.system_node: + return ExecResult(return_code=0, stdout="system", stderr="") + return ExecResult(return_code=0, stdout="bundled" if self.ca_bundle else "bundled-without-ca", stderr="") return ExecResult(return_code=0, stdout="", stderr="") @@ -122,6 +126,29 @@ def test_native_bootstrap_avoids_system_node_and_keeps_vendor_installer( assert any("https://downloads.claude.ai/claude-code-releases/bootstrap.sh" in c for c in environment.commands) +@pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) +@pytest.mark.parametrize( + ("manager", "expected_install"), + [ + ("apt-get", "set -o pipefail; apt-get update && apt-get install -y ca-certificates"), + ("dnf", "set -o pipefail; dnf install -y ca-certificates"), + ], +) +def test_bundled_installer_without_ca_bundle_installs_ca_certificates( + tmp_path: Path, agent_class: type, manager: str, expected_install: str +) -> None: + # Without npm, nothing else pulls in the CA bundle the vendor downloads need. + environment = _BootstrapEnvironment(manager=manager, ca_bundle=False) + agent = agent_class(logs_dir=tmp_path, model_name="openai/test-model") + + asyncio.run(agent.install(environment)) + + assert len(environment.probes) == 1 + assert "[ -s /etc/ssl/certs/ca-certificates.crt ]" in environment.probes[0] + assert "[ -s /etc/pki/tls/certs/ca-bundle.crt ]" in environment.probes[0] + assert environment.package_installs == [expected_install] + + @pytest.mark.parametrize("agent_class", [SkillEvaluatorCodex, SkillEvaluatorClaudeCode]) @pytest.mark.parametrize("manager", ["apt-get", "apk"]) def test_system_npm_installer_still_provisions_node_and_npm(tmp_path: Path, agent_class: type, manager: str) -> None: From 8cd5285438c3b76bc02fa641e8a559db17bc5db7 Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Tue, 13 Oct 2026 19:01:46 -0700 Subject: [PATCH 3/3] docs: note that Docker agent setup no longer installs Node/npm Skipping the distribution nodejs/npm packages also removes npx and the gcc/g++/make toolchain those packages pulled in on Debian-based images, so Claude Code containers have no Node.js and neither agent has a compiler. Record the change in the CHANGELOG and show skill authors how to install these tools through scripts/apt-packages.txt or a custom Dockerfile. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- CHANGELOG.md | 11 +++++++++++ docs/eval-datasets.mdx | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 883c33aa5..562d99929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,17 @@ All notable changes to SkillEvaluator are documented in this file. without rerunning the scan. The version is shown even when the report omits its timestamp. +### Changed + +- Docker Claude Code and Codex containers no longer get the distribution + `nodejs` and `npm` packages from agent setup, except on Alpine images. On + Debian-based images, including the default eval image, those packages also + provided `npx`, `gcc`, `g++`, and `make`. Claude Code containers now have no + Node.js unless the image provides it, and Codex's own Node.js is on `PATH` + only for the Codex process. Skills whose scripts, tasks, or stdio MCP servers + need these tools must install them through `scripts/apt-packages.txt` or a + custom `evals/environment/Dockerfile`. + ### Fixed - Fixed Docker Codex and Claude Code setup wasting its timeout installing diff --git a/docs/eval-datasets.mdx b/docs/eval-datasets.mdx index a7b6d7f76..ec1a04d0d 100644 --- a/docs/eval-datasets.mdx +++ b/docs/eval-datasets.mdx @@ -309,6 +309,25 @@ command = "python /workspace/tools/server.py" transport = "stdio" ``` + + In Docker mode, Claude Code and Codex setup no longer installs the + distribution `nodejs` and `npm` packages, except on Alpine images. On + Debian-based images, including the default `python:3.12-slim` image, those + packages also brought `npx` and a C/C++ toolchain (`gcc`, `g++`, `make`). + Claude Code containers now have no Node.js unless the image provides it. + Codex installs its own Node.js, which is on `PATH` only for the Codex process + and the commands it runs. If your skill's scripts, its tasks, or a stdio MCP + server (for example `command = "npx ..."`) need these tools, install them in + the image: list the packages in `scripts/apt-packages.txt`, one per line, for + the auto-generated image, or install them in `evals/environment/Dockerfile`. + + +```text title="my-skill/scripts/apt-packages.txt" +nodejs +npm +build-essential +``` + ## Validate before you run Check the whole contract — dataset fields, case IDs, `config.yml`, Dockerfile