Repository navigation
feat(headless): make Harbor adapters loadable under Pier - #1344
Merged
Merged
Conversation
Astro-Han
added a commit
that referenced
this pull request
Jul 22, 2026
…n errors Apply the adjudicated cross-review bundle for PR #1344: - harness_compat: catch only ModuleNotFoundError naming pier itself; an ImportError raised inside pier's own __init__ (broken install, missing dependency) now re-raises instead of silently selecting the compat harbor tree, which would reproduce the TrialResult.agent_info pydantic failure. - MakaAgent.network_allowlist: an empty allowlist is only correct when the container makes no model calls; raise a RuntimeError naming the fix when backend=ai-sdk runs without host-side provider configuration, so the trial fails at environment creation instead of opaque in-container network errors. - MakaKimiCodeAgent: drop the api.kimi.com fallback and centralize proxy-URL parsing in _provider_proxy_host(), shared by network_allowlist() and _runtime_env(); unset/empty/unparsable URLs raise the existing host-proxy error at allowlist time, and IPv6 literal endpoints raise an explicit unsupported-endpoint error (pier's domain validator rejects ':'). - Tests: cover broken-pier re-raise, the maka mode-mismatch raise, and the kimi unset/IPv6 raises; count skips separately from passes; support MAKA_HARNESS_COMPAT_EXPECT=pier to fail instead of skip when expected pier coverage is unavailable. harbor-adapter.test.ts now runs the python contract under both interpreters (harbor launcher probe, pier launcher probe or MAKA_PIER_PYTHON), self-skipping visibly when one is absent. - Add -> None / Optional return annotations on install_spec and network_allowlist in both adapters.
Astro-Han
added a commit
that referenced
this pull request
Jul 22, 2026
…ilures diagnosable Apply the adjudicated fresh-eye review items for PR #1344: - MakaAgent.network_allowlist no longer rejects MAKA_HARBOR_MODE=task-run: the guard collapses into a single _container_makes_model_calls() predicate (cell mode + backend!=fake + no host-side config). task-run always runs the model on the host and only bridges tool commands into the container, so the empty allowlist is correct there; the mismatch error now also names task-run as a way out. - The in-container Node >= 22 bootstrap (reachable only for cell+fake under the new guard) runs in a child bash so first-failure semantics survive the || guard, and any failure collapses into one diagnostic naming the cause (downloads need network; Pier non-internet containers are offline) and the ways out, instead of obscure curl/apt errors. No IS_PIER branching; both trees behave identically. - test_harness_compat: scrub MAKA_* keys from os.environ per test (restored afterwards; MAKA_HARNESS_COMPAT_EXPECT stays visible as the runner's own control) so exported operator variables like MAKA_PROVIDER_PROXY_URL or MAKA_HOST_NO_AUTH cannot flip the contracts; add the task-run case locking the allowlist fix.
Astro-Han
added a commit
that referenced
this pull request
Jul 22, 2026
…rn on Squid-blocked ports Apply the second adjudicated fresh-eye bundle for PR #1344: - _runtime_env restores main's plain-Harbor contract: it only requires MAKA_PROVIDER_PROXY_URL and MAKA_PROVIDER_PROXY_TOKEN to be non-empty and forwards the URL opaquely, IPv6 included. The IPv6 rejection comes from Pier's NetworkAllowlist domain validator (rejects ':'), a Pier-only constraint, so endpoint-shape validation moves entirely behind the plain- Harbor early return in network_allowlist(); Pier still fails early because execution calls network_allowlist at environment creation. - network_allowlist now also parses the proxy port and warns on stderr when it is outside {80, 443}: Pier's Squid egress proxy for allow_internet=false tasks only allows those destination ports (Safe_ports acl in pier/environments/agent_setup.py), so a random high-port proxy is silently unreachable in offline tasks. Warn, do not raise - the adapter cannot see allow_internet, and internet tasks ignore the allowlist. Binding the provider proxy to 80/443 belongs to the pier task-runner follow-up. - Tests: the :8443 case now asserts the warning and restates the Squid constraint; the portless case asserts silence; a new gate-free case runs under both trees and locks the opaque IPv6 forward through _runtime_env.
Pier (Datacurve's Harbor fork) asks each agent for install_spec() and network_allowlist() when building a trial environment; plain Harbor 0.13.2 defines neither on its base classes, so both MakaAgent and MakaKimiCodeAgent raised AttributeError under Pier before any task could run. Add both hooks with a guarded NetworkAllowlist import so the modules still import under plain Harbor (Terminal-Bench). install_spec() returns None (both adapters install/verify at runtime, not at build time). MakaAgent uses an empty allowlist (host-side LLM, tools bridged in, container needs no egress); MakaKimiCodeAgent allowlists only the model endpoint host derived from MAKA_PROVIDER_PROXY_URL, defaulting to api.kimi.com, since its toolchain is pre-baked and verified offline. Add a self-runnable behavior test covering both the Pier-importable shapes and the pier-absent import path (meta-path poisoning).
…time The DeepSWE pilot failed at pier trial setup with a pydantic ValidationError: pier 0.3.0's TrialResult.agent_info only accepts pier.models.trial.result. AgentInfo, but the adapters subclassed the (type-incompatible, parallel) harbor tree, so to_agent_info() returned harbor's AgentInfo. Add harness_compat.py, which prefers the pier.* tree whenever `import pier` succeeds and falls back to harbor.* otherwise. The importing process is always the harness runner itself, so pier importability identifies the runner exactly: the plain-Harbor 0.13.2 uv tool venv (Terminal-Bench, and the CI Python-bridge contract in harbor-adapter.test.ts) cannot import pier, and inside pier's venv the compat harbor tree is never the right choice. Symbols resolve lazily (PEP 562) so each adapter's transitive import surface stays exactly the names it asks for, which keeps the per-adapter harness-stub smoke tests intact. API-drift audit harbor 0.13.2 vs pier 0.3.0 for every symbol the adapters use: ExecResult, BaseEnvironment.exec/upload_file/download_file, CliFlag/EnvVar, with_prompt_template, _get_env/_resolved_flags/_extra_env, EnvironmentPaths. agent_dir, trajectory models, and format_trajectory_json are shape-identical; AgentContext only gains optional fields. Pier makes install_spec() and populate_context_post_run() abstract on BaseInstalledAgent - both adapters already define both. Extend the tests to lock the pilot-failure seam (to_agent_info() is pier's AgentInfo under pier) and the harbor-tree fallback, and rename them to match the widened scope.
…n errors Apply the adjudicated cross-review bundle for PR #1344: - harness_compat: catch only ModuleNotFoundError naming pier itself; an ImportError raised inside pier's own __init__ (broken install, missing dependency) now re-raises instead of silently selecting the compat harbor tree, which would reproduce the TrialResult.agent_info pydantic failure. - MakaAgent.network_allowlist: an empty allowlist is only correct when the container makes no model calls; raise a RuntimeError naming the fix when backend=ai-sdk runs without host-side provider configuration, so the trial fails at environment creation instead of opaque in-container network errors. - MakaKimiCodeAgent: drop the api.kimi.com fallback and centralize proxy-URL parsing in _provider_proxy_host(), shared by network_allowlist() and _runtime_env(); unset/empty/unparsable URLs raise the existing host-proxy error at allowlist time, and IPv6 literal endpoints raise an explicit unsupported-endpoint error (pier's domain validator rejects ':'). - Tests: cover broken-pier re-raise, the maka mode-mismatch raise, and the kimi unset/IPv6 raises; count skips separately from passes; support MAKA_HARNESS_COMPAT_EXPECT=pier to fail instead of skip when expected pier coverage is unavailable. harbor-adapter.test.ts now runs the python contract under both interpreters (harbor launcher probe, pier launcher probe or MAKA_PIER_PYTHON), self-skipping visibly when one is absent. - Add -> None / Optional return annotations on install_spec and network_allowlist in both adapters.
…ilures diagnosable Apply the adjudicated fresh-eye review items for PR #1344: - MakaAgent.network_allowlist no longer rejects MAKA_HARBOR_MODE=task-run: the guard collapses into a single _container_makes_model_calls() predicate (cell mode + backend!=fake + no host-side config). task-run always runs the model on the host and only bridges tool commands into the container, so the empty allowlist is correct there; the mismatch error now also names task-run as a way out. - The in-container Node >= 22 bootstrap (reachable only for cell+fake under the new guard) runs in a child bash so first-failure semantics survive the || guard, and any failure collapses into one diagnostic naming the cause (downloads need network; Pier non-internet containers are offline) and the ways out, instead of obscure curl/apt errors. No IS_PIER branching; both trees behave identically. - test_harness_compat: scrub MAKA_* keys from os.environ per test (restored afterwards; MAKA_HARNESS_COMPAT_EXPECT stays visible as the runner's own control) so exported operator variables like MAKA_PROVIDER_PROXY_URL or MAKA_HOST_NO_AUTH cannot flip the contracts; add the task-run case locking the allowlist fix.
…rn on Squid-blocked ports Apply the second adjudicated fresh-eye bundle for PR #1344: - _runtime_env restores main's plain-Harbor contract: it only requires MAKA_PROVIDER_PROXY_URL and MAKA_PROVIDER_PROXY_TOKEN to be non-empty and forwards the URL opaquely, IPv6 included. The IPv6 rejection comes from Pier's NetworkAllowlist domain validator (rejects ':'), a Pier-only constraint, so endpoint-shape validation moves entirely behind the plain- Harbor early return in network_allowlist(); Pier still fails early because execution calls network_allowlist at environment creation. - network_allowlist now also parses the proxy port and warns on stderr when it is outside {80, 443}: Pier's Squid egress proxy for allow_internet=false tasks only allows those destination ports (Safe_ports acl in pier/environments/agent_setup.py), so a random high-port proxy is silently unreachable in offline tasks. Warn, do not raise - the adapter cannot see allow_internet, and internet tasks ignore the allowlist. Binding the provider proxy to 80/443 belongs to the pier task-runner follow-up. - Tests: the :8443 case now asserts the warning and restates the Squid constraint; the portless case asserts silence; a new gate-free case runs under both trees and locks the opaque IPv6 forward through _runtime_env.
Astro-Han
force-pushed
the
feat/headless-pier-network-allowlist
branch
from
July 22, 2026 14:34
fe6d05b to
9eac360
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refs #1343. Makes both Harbor agent adapters loadable and trial-functional under Pier ≥ 0.3.0 (Datacurve's Harbor fork used to run DeepSWE, where all 113 tasks set
allow_internet = false), while leaving plain-Harbor 0.13.2 Terminal-Bench runs untouched. Three commits: missing Pier hooks, harness-tree selection, and the adjudicated cross-review hardening.agent.install_spec()(evaluated first — the immediateAttributeError) andagent.network_allowlist(); Harbor's base classes define neither. Both adapters now implement both:MakaAgent:install_spec()→None(runtime install path unchanged);network_allowlist()→ empty, valid only because the container makes no model calls. A single_container_makes_model_calls()predicate owns that invariant: only a cell-modeai-sdkrun without host-side provider configuration needs in-container egress and raises aRuntimeErrornaming the fixes (host-side config,backend=fake, orMAKA_HARBOR_MODE=task-run); host-side, fake, and task-run modes all get the empty allowlist. The in-container Node ≥ 22 bootstrap (reachable only for cell+fake) now collapses any failure into one diagnostic — its downloads are the adapter's only container-side network dependency and Pier non-internet containers are offline — instead of obscure curl/apt errors.MakaKimiCodeAgent:install_spec()→None(toolchain pre-baked into the image, verified offline via sha256 + manifest fingerprint);network_allowlist()→ exactly the model-endpoint host ofMAKA_PROVIDER_PROXY_URL. No fallback domain: unset/empty/unparsable URLs raise the existing "Kimi Code requires the host provider proxy" error at allowlist time, and IPv6 literal endpoints raise an explicit unsupported-endpoint error (Pier's domain validator rejects:). This endpoint-shape validation is Pier-only — it lives behind the plain-Harbor early return innetwork_allowlist(), while_runtime_env()keeps main's contract and forwards the URL opaquely (IPv6 included), so Harbor 0.13.2's input domain is not narrowed. When the proxy port is outside {80, 443},network_allowlist()warns on stderr instead of raising: Pier's Squid egress proxy forallow_internet=falsetasks only allows those destination ports, but the adapter cannot seeallow_internetand internet tasks ignore the allowlist.ValidationError:TrialResult.agent_infoonly acceptspier.models.trial.result.AgentInfo, but the adapters subclassed the compatharbor.*tree. Newharness_compat.pyselects the whole base-class tree at import time; both adapters import their harness symbols from it.Tree-selection rule: prefer Pier whenever
import piersucceeds~/.local/share/uv/tools/harbor, harbor 0.13.2) has no pier distribution — verifiedimport pierfails — so every Terminal-Bench consumer keeps the harbor tree bit-for-bit. The only interpreter where both trees import is Pier's own venv, where the compatharbor.*tree is exactly what the pilot proved wrong.ModuleNotFoundErrornamingpieritself (genuinely absent package). Any other failure inside pier's own import — broken install, missing dependency — re-raises at the probe, and a pier tree broken below the top level fails at first symbol resolution; falling back in those cases would silently rebuild the adapters on the compat tree that Pier'sTrialResultrejects.harbor-adapter.test.tsresolves its interpreter from theharborlauncher on PATH (plain 0.13.2 venv, no pier), so prefer-pier cannot change what it tests. No env switch: it would add a knob that fails closed when forgotten on the Pier side.API-drift audit (harbor 0.13.2 vs pier 0.3.0, every symbol the adapters use)
ExecResultstdout/stderr/return_code)BaseEnvironment.exec/upload_file/download_fileCliFlag/EnvVar,with_prompt_template__init__,_get_env,_resolved_flags,_extra_env,model_name,logs_direnv_fallbackresolutionos.environonly; theextra_env-aware resolution is a harbor 0.20.0 feature)backendmust come from kwargs or process env, not--ae; tests use the kwarg pathEnvironmentPaths.agent_dirAgentContextformat_trajectory_jsonto_agent_info()AgentInfoinstall_spec()/populate_context_post_run()BaseInstalledAgentinstall()default bodyinstall_spec().stepsinstall()_execenv handlingenvironment.agent_process_envOther files in the harbor dir (
codex_agent.py,opencode_agent.py,opencode_title_harbor_agent.py,maka_verifier.py) still bindharbor.*directly: they are Terminal-Bench-only arms, and DeepSWE runs use each task's own verifier (the pilot trial config has no custom verifier import path). They would need the same treatment only if ever run under Pier.Verification
packages/headless/harbor/tests/test_harness_compat.pyunder both interpreters (each test scrubsMAKA_*fromos.environand restores it, so operator shells cannot flip the contracts):6 passed, 0 skipped, 0 failed— the pilot-failure seam (to_agent_info()ispier...AgentInfoand passesTrialResult.agent_infopydantic assignment), the maka mode-mismatch raise plus the task-run empty-allowlist case, the kimi unset/IPv6 raises plus the port-warning contracts, the gate-free_runtime_envIPv6-forward case, the harbor fallback under meta-path poisoning, and the broken-pier re-raise (injectedModuleNotFoundError(name="socksio")propagates instead of falling back). Earlier run withMAKA_PROVIDER_PROXY_URL=https://example.invalid,MAKA_HOST_NO_AUTH=true, andMAKA_BACKEND=fakeexported: all green (tests scrubMAKA_*).3 passed, 3 skipped, 0 failed(the gate-free_runtime_envcase runs for real here); withMAKA_HARNESS_COMPAT_EXPECT=pierthe missing pier coverage fails as intended (exit 1).MAKA_HARBOR_MODE=task-run+MakaAgent(logs_dir=...).network_allowlist()→NetworkAllowlist [](previously raised).MAKA_PROVIDER_PROXY_URL=http://[::1]:43210/v1through_runtime_env()→KIMI_MODEL_BASE_URL=http://[::1]:43210/v1forwarded opaquely (HEAD before this fix raised ValueError; now matches main).:8443→ host allowlisted + stderr warning naming the Squid 80/443 restriction;:443→ no warning; IPv6 → ValueError.harbor-adapter.test.tsspawn the python contract under each interpreter (harbor launcher probe; pier launcher probe orMAKA_PIER_PYTHON, withMAKA_HARNESS_COMPAT_EXPECT=pierso skips cannot masquerade as green), self-skipping visibly when an interpreter is absent. Both ran on this machine.@maka/headlesssuite in the worktree (npm run test -w @maka/headless): 1181 pass / 0 fail / 1 skip (source contracts on the install command —nvm install 22,/usr/local/nvm,NODE_MAJOR— still hold after the bootstrap wrap).npm run lintandnpm run format:checkclean.AgentFactory.create_agent_from_import_path+TrialResult.agent_infovalidation: maka (host-side) →allow.domains=[], pydantic OK; kimi (proxy URL set) →allow.domains=['api.kimi.com'], pydantic OK; maka without host-side config →RuntimeErrorat allowlist time; kimi without proxy URL →ValueErrorat allowlist time.harbor.agents.installed.base.BaseInstalledAgentandto_agent_info()returns harbor'sAgentInfo— Terminal-Bench path unchanged._prepare_egress_proxy_composereturns early and the no-network compose applies; non-empty → filtered egress proxy for exactly those domains.pier runwith a live model — that is the eval(headless): DeepSWE 1.1 discriminative-30 harness A/B — Maka vs Kimi Code and Codex CLI #1343 pilot, tracked on the issue.Known constraint / follow-up
Pier's
write_docker_proxy_compose()(pier/environments/agent_setup.py) generates a Squid egress proxy withacl Safe_ports port 80 443+http_access deny !Safe_portsforallow_internet=falsetasks, verified against Pier 0.3.0 output. Our host provider proxy currently listens on a random high port, which Squid would silently deny on the first in-container model request of an offline Kimi trial. This branch surfaces the mismatch as a stderr warning at environment creation (raising would wrongly kill internet-enabled tasks, where the allowlist is ignored). Binding the provider proxy to 80/443 (or an internet task) is the actual fix and is handed off to the pier task-runner follow-up PR.