Keep the same Bash session so HARBOR_CONFIG and HARBOR_RUN remain set. The preparation and preflight job names have suffixes so the real run can create fresh output directories.
Check the host
Enter this checkout, confirm that uv and the Docker daemon are available, then install the benchmark project’s locked dependencies. Python 3.13 or later is required.
Bash / host
cd /mnt/ubuntu/home/omarchy_data/nanoPyCodeAgent-work-20261108
uv --version
docker info
uv sync --project benchmarks/harbor --locked
Change the cd path if your checkout is elsewhere. --locked requires an up-to-date lockfile without rewriting it. The Docker daemon must be accessible to this user; this phase does not call a model.
Set credentials and select the agent
Read the API key without putting it in the command text. Select a config and create a timestamped run name.
ANTHROPIC_BASE_URL must match the allowlisted inference host. The model comes from agents[].model_name; unsetting ANTHROPIC_MODEL prevents an inherited override.
Credentials stay in the environment. The page never asks for, stores, or sends your key.
Prepare the recorded inputs
Build and record the run inputs. For Nano, build the local wheel and compare its Python files with the recorded source snapshot. For Pi, verify and snapshot the pinned distribution and public model config.
Bash / host
uv run --project benchmarks/harbor python -m harbor_adapter run \
--config "$HARBOR_CONFIG" \
--job-name "${HARBOR_RUN}-prepare" \
--prepare-only
--prepare-only does not start containers, call the model, or execute the official verifier. This phase is optional but useful when checking adaptation work.
Check installation and isolation
Exercise setup in a task container: install the agent, run a registered dependency profile if present, and verify the positive, negative, and allowed-host network controls.
Bash / host
uv run --project benchmarks/harbor python -m harbor_adapter run \
--config "$HARBOR_CONFIG" \
--job-name "${HARBOR_RUN}-preflight" \
--install-only
--install-only performs no model work or official tests. WAL has no registered verifier dependency profile: report not_configured, not passed. A full run repeats setup in a fresh container.
Run the agent and official verifier
Create a fresh trial, install the selected agent, deliver the task, restrict model-phase networking, wait for the agent boundary, then run the official verifier.
Bash / host
uv run --project benchmarks/harbor python -m harbor_adapter run \
--config "$HARBOR_CONFIG" \
--job-name "$HARBOR_RUN"
This command calls the model. It does not resume the prepare-only or install-only trial. Only verifier timeouts may retry: at most three total attempts on the same submitted output, with the original per-attempt deadline.
Inside this phase: Harbor, the agent, and the official verifier
The full-run command starts one complete Harbor trial. The host orchestrates the run; the task container holds the inputs and agent; the official test script checks the submitted files after the agent boundary is confirmed.
Host orchestration›Agent work in the task container›Official tests and host accounting
01Host
Start Harbor with the recorded inputs
The repository wrapper sets PYTHONPATH to jobs/<name>-input/source, then starts Harbor using the normalized, recorded config. Harbor uses that config to schedule the selected task and adapter.
Start the standard workflow · Bash / host
uv run --project benchmarks/harbor python -m harbor_adapter run \
--config "$HARBOR_CONFIG" \
--job-name "$HARBOR_RUN"
Run this from the repository root after selecting the config and credentials above. The wrapper records inputs and launches Harbor; this is the supported full-run entry point and calls the model after setup passes. Use a fresh HARBOR_RUN.
The wrapper runs this only for Nano, then compares every Python file in the wheel against the recorded source snapshot. Pi instead snapshots and verifies its pinned distribution. This build is already included in the full-run command.
The wrapper supplies an absolute PYTHONPATH and the Python environment’s executable directory in PATH. This relative-path form assumes the repository root. The config has already been normalized and recorded; stdout and stderr go to harbor.log. This is the internal launch inside the full run, not another command to run afterward.
Create the environment, install the agent, and pass preflight
Harbor creates the task environment with the supplied /app/main.db and /app/main.db-wal. The adapter installs system dependencies and the selected agent, runs a registered dependency profile if one exists, and checks the network controls before model work.
Setup or isolation-preflight failure stops this path before any model call. WAL has no registered verifier dependency profile, so that field stays not_configured even when agent installation and network preflight pass.
Run this stage on its own · Bash / host
uv run --project benchmarks/harbor python -m harbor_adapter run \
--config "$HARBOR_CONFIG" \
--job-name "${HARBOR_RUN}-preflight" \
--install-only
Use the config, credentials, and run name set above, with a fresh preflight job name. This creates a separate trial, installs the selected agent, runs setup checks, then exits before model work or official tests. The full run repeats setup in a new environment.
docker compose <generated-compose-options> build
docker compose <generated-compose-options> down --remove-orphans
docker compose <generated-compose-options> up --detach --wait
Harbor 0.21.0 generates the Compose options: --project-name, --project-directory, and repeated -f paths for the task, runtime, egress sidecar, and hardening overlays. The angle-bracket text is a runtime placeholder. build runs only when a prebuilt task image is not selected; down removes stale containers before up starts the task and sidecars. Harbor also prepares the egress sidecar image. The task image supplies the database files; these commands do not replace that image or its inputs.
Nano and Pi share these dependencies. Between the index plan and download, the adapter restores only cached packages matching the current index filename, size, and SHA256, then verifies and saves newly downloaded packages before installation. These shell lines show the package commands; the cache transfers and validation remain in AptCache.install(). Other package managers use Harbor’s dependency installer.
set -euo pipefail
if ! command -v uv >/dev/null 2>&1; then
curl -LsSf https://astral.sh/uv/0.9.11/install.sh | sh
fi
export PATH="$HOME/.local/bin:$PATH"
uv tool install --force /tmp/<recorded-wheel-filename>.whl
nanoPyCodeAgent --version
For this repository workflow, the adapter uploads the wheel built from the recorded working tree to /tmp before running this command. Replace the wheel placeholder with that recorded filename when reading the invocation. Pi uses the next path instead of installing Nano.
chmod 755 /opt/harbor-pi/pi
/opt/harbor-pi/pi --version
mkdir -p /tmp/harbor-pi-agent
# The adapter uploads models.json before this command.
PI_CODING_AGENT_DIR=/tmp/harbor-pi-agent \
DEEPSEEK_API_KEY=preflight-only \
/opt/harbor-pi/pi --offline --list-models deepseek-flash
First, the host checks the pinned distribution hash and uploads it to /opt/harbor-pi. chmod runs as root; version, directory, and model-list checks run as the agent user. The adapter uploads the public models.json and runs a process-supervision probe using true. It checks the installed version and requires the requested provider/model in the listing; diagnostics or a missing model fail setup. preflight-only is a dummy key for local registration checks, with no inference request.
before = await self._probe("https://example.com/")
await self.set_network_policy(self.integrity_policy.network())
after = await self._probe("https://example.com/")
allowed = await self._probe("https://api.deepseek.com/")
await self._network_snapshot("network-preflight")
For the WAL config, the first example.com probe must be reachable, the second must be blocked after applying restricted-v1, and api.deepseek.com must remain reachable. A DNS resolution failure cannot prove HTTPS blocking. The source checks these results and records the external network policy and rules; any failure stops setup.
Each _probe() executes the embedded Python program with its URL in the task container. The placeholder represents the actual _PROBE source, which uses urllib without a proxy or redirects and returns JSON with reachable and error types. An HTTP error response still proves reachability. These probes do not invoke a model.
Translate the task into the selected agent’s native command
The adapter receives instruction, environment, and context from Harbor. Nano receives the instruction through stdin; Pi receives it as a quoted argument in print/JSON mode. The adapter forwards model settings and credentials, selects log paths, and wraps execution with process supervision under restricted-v1.
The calls below show the core interface. The real code also supplies budgets, environment variables, shell quoting, supervision, and log handling. You do not type these container commands yourself.
set -euo pipefail
export PATH="$HOME/.local/bin:$PATH"
printf "%s" "$instruction" | nanoPyCodeAgent --max-turns 50 \
--trajectory /logs/agent/trajectory.json \
2>&1 | tee /logs/agent/nanopycodeagent.txt
For the shown Nano config, --max-turns defaults to 50. The adapter forwards ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL, and ANTHROPIC_MODEL in the environment. Here $instruction simplifies the real temporary-variable transfer and already includes the shared integrity rules. Configured flags and process supervision are applied by the adapter.
The shown pinned Pi config selects --thinking high. PI_CODING_AGENT_DIR=/tmp/harbor-pi-agent and DEEPSEEK_API_KEY are supplied through the execution environment. The embedded event filter drops only message_update streaming deltas; the retained events are written to pi.txt and native sessions to pi/sessions. The adapter also checks settled/stop status after the process finishes.
The agent sends the task and accumulated observations to the model. The model selects a tool action; the agent executes it and returns the result for the next exchange. This continues until the agent finishes or reaches its execution limits.
In the recorded WAL example, those actions inspect bytes with xxd, decode the XOR-encoded WAL in Python, query SQLite, and write /app/recovered.json. The adapter contains no prewritten solution to this task.
Model selects an action›Agent executes the tool›Output returns to the model›Next exchange
Request a model reply · Python / Nano process in the task container · reduced excerpt
with client.messages.stream(
model=model,
max_tokens=max_tokens,
system=system,
tools=TOOLS,
messages=messages,
) as stream:
for event in stream:
... # Emit streaming events; see the full source.
message = stream.get_final_message()
This is an SDK call inside the agent, with no separate shell command for each model turn. The full source also enforces wall-clock limits, records streaming events and usage, and handles failures. Pi uses its own native model loop.
The first two lines of logic run for each tool_use block; the final append happens after the tool results are collected. _run_one_tool() dispatches read/write/edit/bash. It returns content, tool_use_id, and is_error for the next model exchange. The full loop validates inputs, checks budgets and stop reasons, and rejects incomplete responses before running tools.
A command selected by the model · Bash / recorded Pi task container
cd /app && xxd main.db-wal | head -80
This is the actual WAL-byte inspection from the recorded Pi run, not a fixed adapter setup command: call_01_ET_wRCY0ozJkp4bzDx92qsQ9904, 2026-11-04T15:22:21.635Z. The next exchanges decoded the WAL, queried SQLite, and wrote recovered.json. Read every original command and its output in the linked task replay; this guide does not execute them.
The supervisor records execution status in /logs/agent/process-supervision.json. Before grading, check_agent_quiescence() accepts a completed record or confirmed stopped processes after cancellation/error. A missing or invalid boundary raises an error rather than silently grading the submission.
On successful completion, the supervisor can leave an intentional background service running for tasks that require one. It does not unconditionally kill every process. Timeout and cancellation paths must confirm cleanup.
Run under supervision · Bash / task container / agent user · generated command shape
The adapter embeds _agent_runner.py through python3 -I -c rather than assuming that file exists in the container. The final argument is the single, shell-quoted Nano or Pi command from the preceding step. Nano uses /tmp/nanopy-agent-<uuid>.json; Pi uses /tmp/harbor-pi-<uuid>.json. Angle brackets stand for generated source, paths, and command text. The supervisor starts bash -c in a new session and writes the execution record.
This is the cleanup path, not the next command after a normal completion. Use the same control path as the run invocation, including Pi’s different prefix. The supervisor stops descendants on cancellation and confirms the result; the host rejects unconfirmed cleanup. A successful run may intentionally leave a service running.
After logs are collected, replace <trial> with the actual Harbor trial directory. The verifier checks this record with check_agent_quiescence(); merely printing it does not establish a valid boundary. A completed record needs an integer return_code; cancelled/error_stopped needs processes_stopped=true. Missing or invalid records raise an error.
Check the submitted files, with timeout-only recovery
RetryingVerifier.verify() checks the agent boundary, calls prepare_verification(), then delegates to Harbor’s original verification flow and the task’s original test script. For the current shared-verifier path, network evidence is recorded before the task’s native network is restored for official dependencies. Tasks already using separate verifiers retain that mode.
For WAL, the official tests inspect the recovered JSON and repaired WAL. The agent’s final chat answer does not replace those file checks. Only verifier timeouts may retry under the standard policy: at most three total attempts with the same agent submission and the original per-attempt deadline. The agent is not run again.
Check the boundary and prepare verification · Python / host · core lifecycle calls
RetryingVerifier performs these calls before delegating to Harbor. In the current shared environment, prepare_verification() records network evidence, clears stale canonical reward files, and restores the task’s original network policy for official dependencies. The full method also validates the outer timeout and installs the retry wrapper. These are lifecycle excerpts, not a standalone verifier entry point.
For this Linux WAL task, Harbor uploads the original tests to /tests and marks test.sh executable as root. The second line runs as the effective verifier user; under the standard integration it is intercepted by the timeout runner shown next. Preserve the script and test inputs. Its own dependency and pytest commands remain those supplied by the task; this page does not substitute a hand-written test.
The arguments are the embedded runner, original shell command, original per-attempt timeout in seconds, at most 3 attempts, dependency-error retry flag 0, collection-error retry flag 0, log directory, and generated control path. Only timeouts may retry under this standard config. Each attempt uses the same agent output; logs remain under attempts/ and retry-summary.json. This invocation wraps the official script rather than adding another independent verification run.
Collect raw results, then freeze and review the evidence
Harbor retains rewards, test output, trajectories, and exceptions. The wrapper writes summary.json; after a completed restricted run it freezes output hashes and creates the candidate audit.
Raw reward and integrity-reviewed effective score remain separate. Pending reviews have no effective score. Setup and verifier errors remain unscored, while a valid score of zero can still be a completed benchmark result.
summary = summarize(job_dir, install_only=config.install_only)
summary["harbor_exit_code"] = code
(record / "summary.json").write_text(json.dumps(summary, indent=2) + "\n")
# After a completed restricted run with job result.json:
audit = audit_job(job_dir, record / "audit")
These calls already run after Harbor exits. The summary is written in a finally block; automatic audit runs only for a completed restricted full run with job result.json, not prepare-only or install-only. The wrapper then adds the audit accounting to summary.json. Existing native rewards and errors are retained.
The summary reports raw rewards, setup/verifier status, and attempts. audit.json contains candidate findings and review accounting. No eligible reviewed score is published while reviews remain pending; violations stay in the denominator as effective zeroes.
The full restricted run normally does this automatically. This separate command uses the completed job as evidence and writes the audit outside that frozen directory. It does not call the model or rerun the official verifier; candidate flags still require evidence review.
First inspect the frozen evidence and create review.json with the actual trial ids and evidence paths bound to freeze.json’s SHA256. Replace /path/to/review.json with that file. The command validates the binding and retains the reviewed revision under its review hash; it does not invent a verdict or overwrite native rewards.
A score of zero can be a completed, valid result. Setup and verifier exceptions remain unscored. A candidate scan does not assign an integrity-cleared score.
Which work actually happens?
Phase
Record inputs
Container setup
Model calls
Official tests
--prepare-only
Yes
No
No
No
--install-only
Yes
Yes
No
No
Full run
Yes
Yes
Yes
Yes
Follow the command through the source
Select a node to see the real function, file, and a source excerpt. Line numbers and links are pinned to the snapshot shown below.
Entry and source captureInstall and executeVerification and review
Source inspector
The project entry point
argparse registers run, audit, --config, --job-name, --prepare-only, and --install-only. main() dispatches to run(args). The pyproject declares the harbor_adapter package.
After reading the code, use your browser’s Back button to return to your reading position; Forward reopens the source view.
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
commands = parser.add_subparsers(dest="command", required=True)
benchmark = commands.add_parser("run", help="Record the working tree and run the standard Harbor workflow")
benchmark.add_argument("--config", type=Path, required=True)
benchmark.add_argument("--job-name")
benchmark.add_argument("--cache-dir", type=Path, default=default_cache_dir())
benchmark.add_argument("--prepare-only", action="store_true", help="Build and record inputs without starting containers or calling the model")
benchmark.add_argument("--install-only", action="store_true", help="Run setup and dependency preflight without calling the model or verifier")
benchmark.add_argument("--legacy-open-network", action="store_true", help="Explicitly reproduce an earlier protocol without integrity enforcement")
audit = commands.add_parser("audit", help="Freeze completed outputs and produce evidence-bound integrity accounting")
audit.add_argument("--job-dir", type=Path, required=True)
audit.add_argument("--output-dir", type=Path, required=True)
audit.add_argument("--review", type=Path, help="Reviewed verdicts bound to this output freeze")
cache = commands.add_parser("import-apt", help="Import a manifest and its sibling packages/ directory")
cache.add_argument("manifest", type=Path)
cache.add_argument("--cache-dir", type=Path, default=default_cache_dir())
retained = commands.add_parser("verify-retained", help="Run an authorized verifier batch on an unchanged retained solution, without model calls")
The adapter methods run on the host and dispatch shell commands through environment into the task container. You do not type the command below. It simplifies the core invocation; temporary variables, supervision, quoting, and log filtering are in the linked source.
Harbor instruction → stdin → nanoPyCodeAgent → native tools in /app → artifacts and trajectory
The model proposes shell actions such as xxd or Python recovery code during the task. Those actions are produced by the agent; you do not hard-code a WAL solution into the Harbor adapter.
How the adaptation was developed
The integrations already exist. The history below shows when each layer was added; this HTML adds documentation, not a new runtime adapter.
fix(benchmarks): preserve long native events in streamed output
Collect long native event output in chunks without dropping oversized lines, with streaming regression tests.
If you extend an adapter, work in this order
Map the lifecycle
Implement the Harbor adapter contract in benchmarks/harbor/src/harbor_adapter. Reuse shared install/preflight rather than creating per-job adapter copies.
Map the native CLI
Decide how instruction text, model selection, credentials, budgets, output paths, and exit status map to the agent’s own CLI. Keep native tools intact.
Keep execution boundaries explicit
Use the common integrity decorator, environment preflight, and process supervisor. Confirm cancellation before allowing grading.
Export results honestly
Populate usage from real events/ATIF, preserve errors, and add regression tests for task forwarding, partial usage, cancellation, and verifier behavior.
Tests to run while developing the integration
This is a suggested development check for adapter changes. pytest -c selects the benchmark project’s pytest configuration; the following paths select integration regression tests. Creating this HTML did not run a model, Docker task, or benchmark. These test commands are provided for the developer to execute.
Replace <name> with HARBOR_RUN and <trial> with the trial directory actually created by Harbor. Do not assume that the task name alone is the full trial id.
Host path
What to inspect
jobs/<name>-input/config.json
Normalized Harbor config with injected adapter and protocol settings.
jobs/<name>-input/manifest.json
Working-tree source hashes, Git revision, wheel hash for Nano, or pinned Pi distribution/model-config metadata.
jobs/<name>-input/source/
Recorded Python adapter source; Nano’s source snapshot is also stored here.
jobs/<name>-input/harbor.log
Controller output from harbor run.
jobs/<name>-input/summary.json
Per-trial rewards, exception classification, bootstrap/preflight status, and verifier attempt records.
jobs/<name>/<trial>/agent/bootstrap.json
Setup progress. WAL verifier dependencies are explicitly not_configured.
jobs/<name>/<trial>/agent/
Nano: nanopycodeagent.txt and trajectory.json. Pi: pi.txt and pi/sessions/.
jobs/<name>/<trial>/verifier/
Official test output, native reward, retry summary, and retained attempt logs; CTRF when the task emits it.
jobs/<name>-input/audit/
freeze.json and candidate audit.json. Reviewed audit versions are written under their review hash.
jobs/<name>/.integrity/<trial>/
Host-only network and process evidence, including collected agent output; inspect as private run data.
A raw pass still needs an integrity review
Completed restricted runs automatically freeze and scan. To record a reviewed verdict, inspect the frozen evidence, create review.json bound to freeze.json’s SHA256 with actual trial ids and evidence paths, then use --review.
The review verdict is clear or violation. Pending reviews have no effective score; violations count as zero and remain in the denominator. Setup/verifier errors remain unscored. Only use the command below after creating that evidence-bound review file.
The benchmark workflow completed. A valid task score can still be zero. It does not mean the solution passed.
No profile for WAL
Agent setup and network preflight can pass while verifier dependencies remain not_configured. Do not call that a dependency-preflight pass.
Pi is offline
Pi’s --offline flag is not network isolation. restricted-v1 is enforced by the Docker environment and external egress control.
Replaying an old run
The Pi path selects the same task and pinned agent distribution, but current adapters, live provider aliases, and service conditions do not guarantee the historical output or score.