Skip to content

Add Hermes Agent as a CLI Base Agent (acting agent and hermes Evolver) - #107

Merged
haizhongzheng merged 3 commits into
Infini-AI-Lab:mainfrom
veoery:feat/hermes
Nov 16, 2026
Merged

haizhongzheng merged 3 commits into
Infini-AI-Lab:mainfrom
veoery:feat/hermes

Conversation

@veoery

@veoery veoery commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Change

Hermit could not use Nous Research's Hermes Agent (hermes, PyPI hermes-agent 0.19.0) as an acting agent or a
learner. It now can, in the same three layers as Pi (#89), OpenCode (#94) and DeepSeek Harness (#90): a Base Agent
hermes, the acting agent agent.base: hermes (agent.name: hermes), the hermes Evolver, and hermit deploy --host hermes.

The one design decision: a stream from Hermes's plugin API. hermes chat -Q prints only its final reply (no JSON
event mode). Rather than reading Hermes's internal SQLite transcript after the run, the Base Agent copies a plugin of
hermit's own (hermit/agent/base/hermes_plugin/, standard library only) into each
session's home and enables it. It writes every hook Hermes fires as one JSON line on the session's stdout, the stream
hermit keeps (agent-hermes.jsonl): requests with their text, reasoning, tool calls and usage; failed requests with
Hermes's own classification (reason, status_code, retryable); tool results; the first request's tool names and
any context file Hermes's scan blocked; the turn's end with Hermes's recorded auxiliary usage. It uses Hermes's public
plugin API, is live (a stopped session keeps what it did), and lets outcome() decide "provider unavailable" from
Hermes's classification, never from words. Readers stop at the turn's end: chat -Q prints the raw reply after it, and
a reply that reads as an event is the model's text.

  • Layer 1 (backends.py): Binding.hermes_provider() makes a <backend>/<model>
    reference Hermes's config provider hermit: api_mode chat_completions, else anthropic_messages (at the Messages
    root), else codex_responses, the first the backend serves (as Pi picks its dialect); the key by its variable's name
    (key_env), never its value; extra_body on the provider (Hermes sends it with chat-completions requests). The
    backend's context_window and max_output_tokens become the model's context_length and max_tokens. Hermes's
    cost figure is ignored: the backend's price applies.
  • Layer 2 (cli.py, class Hermes): hermes chat -Q --yolo --source tool -t <toolsets> -q <prompt> in a private home (HERMES_HOME = HOME), config.yaml rewritten every call.
    • What Hermes would reach besides the run's model is off: every auxiliary task routed to the same model, no fallback
      providers, no tirith download (46 MB), no update check (a cache of one for the installed version), no models.dev
      catalog (a fresh empty one in the home), no memory, skill-creation nudges, curator or title request. Approvals are
      never asked (Hermes's hardline blocks stay). The reply is the model's own (Hermes's verifier footer and completion
      explainer off).
    • Toolsets: terminal, file, todo, skills with a skills folder, and the call's tools as an MCP server (streamable
      HTTP, 1800 s a call, waited for up to 60 s before the first request). No web search, delegation, clarify, memory.
    • The caller's HERMES_*, TERMINAL_*, TIRITH_* variables and other providers' keys never reach a session
      (HERMES_SAFE_MODE would load no plugin, a stray key would be a fallback provider).
    • A kept home (the Evolver's) holds only Hermes's sessions (its state database), hermit's usage ledger and Hermes's
      logs between calls (HERMES_KEPT): a profile Hermes would switch its home to, a .env/.op.env it loads, its
      identity text, plugins, hooks, credentials and skills a session left are removed. A home hermit did not make (a
      marker file) is refused, never cleared.
    • context_files: false (the Evolver's): --ignore-rules, and the plugin turns off Hermes's subdirectory hints
      (which add a touched folder's AGENTS.md to a tool's result whatever --ignore-rules says) and reports whether it
      could; a session whose hints stayed on fails.
    • outcome(): served when the turn completed with a reply; unavailable only for Hermes's reasons rate_limit,
      upstream_rate_limit, overloaded, server_error, timeout (or 429/5xx) on the last failed request Hermes did not then
      serve; rejected for auth, billing, model_not_found, format_error, ... A session fails although Hermes exits 0 when
      the call's MCP tools were missing from its first request (Hermes goes on without a server it cannot reach), when
      Hermes's prompt-injection scan replaced a context file with a [BLOCKED: ...] notice (benign rules can match), or
      when it hit Hermes's turn limit (agent.hermes.max_turns, default 90: the summary Hermes then asks for is the
      reply, finish_reason length).
    • Usage (records.py parse_hermes): per request (input = input + cache reads + cache
      writes; output holds reasoning); the turn-limit summary request, which no hook reports, is an unreported call (cost
      unknown); Hermes's auxiliary calls (compression, ...) come from its state database at the turn's end, a resumed
      session counting only this call's share (_this_call ledger, as OpenCode's compactions).
    • Trajectory (trajectory.py hermes_steps): commands with exit codes, file
      changes, tool calls, the failed request the session ended with (not the ones Hermes retried).
    • Resume: a handle is resumed (--resume --no-restore-cwd) only when the home's state database, read as a private
      copy with its WAL, keeps it: Hermes fails a turn on an unknown id.
    • Refused rather than dropped: roles, a login, a container, web search, text_only, an effort Hermes has not
      (checked before the first session in isolate.validate and login.evolver_problems via hermes_problems), and a
      prompt over one argument (ARG_MAX, 120,000 bytes: chat -Q takes no prompt on stdin).
  • Layer 3:
    • Acting agent (workspace.py): Hermes reads MCP servers and skill folders only
      from its home's config, so the adapter's tools are served by the session's own tool server (as for OpenCode and
      mini-swe-agent) and the deployment's skills folder is the session's skills_dir.
    • Deployment (hosts/hermes.py): Hermes reads one project context file, the first of
      .hermes.md (searched up to the git root), AGENTS.md, CLAUDE.md, .cursorrules, so the context goes to
      .hermes.md; skills to .hermes/skills/; and .hermes/hermit.config.yaml, the part of Hermes's own config the
      tools (stdio server, 120 s) and skills need, for the user to merge (a deployment never changes ~/.hermes).
    • Evolver (methods/hermes/, AgentEvolver): signs in through its model
      reference, copies nothing of ~/.hermes, reads no context file of the evolver workspace, takes max_turns. MWM and
      RRSI already refuse a learner other than Codex, Claude Code or Pi.
    • Registries: config bases and sections, defaults.yaml, CLI_KINDS, NO_LOGIN, deploy --host, the AHE debugger's
      stream texts and a hermes hook wire (no-hooks host like Pi: hooks listed in .hermes.md), package data for the
      plugin's manifest.
  • Docs: agent-layers, adapter (deployment table column, workspace tree), commands, task, model-backends,
    config-fields, installation (uv tool install 'hermes-agent[mcp]==0.19.0'), compatibility, methods/agent, AHE, FAQ,
    CHANGELOG.

Not in this PR: evolver.base: hermes making the run's model Hermes for methods that call it (llm: {cli: ...}; only
Pi does that), a real AHE hook wire over Hermes's shell hooks, roles through Hermes's delegation, container isolation.

Validation

Hermes Agent 0.19.0 installed with uv tool install 'hermes-agent[mcp,anthropic]==0.19.0'; Linux, Python 3.12.9,
bubblewrap. No real model provider was called (no key on this machine): every Hermes run used a scripted local
chat-completions model.

  • python -m pytest tests/core/test_hermes_agent.py --integration: 34 passed (25 unit tests, ~9 s; 9 integration
    cases with the installed hermes, ~55 s: a session under isolation none and in the run's sandbox with an isolated
    network and no update check made, a resumed kept home, a timeout that leaves no command running, the acting agent
    deploying an adapter's context, skill and tools inside a git repository whose own .hermes.md stays out, no folder's
    AGENTS.md given with context_files: false (and given with true), a context file Hermes's scan blocks failing the
    session, the model's own reply after a failed patch).
  • With tests/core/test_context_tool.py, test_isolate.py, test_packaging.py, test_selection.py, test_layers.py
    and tests/methods/ahe/test_ahe_hosts.py, --integration: 164 passed.
  • python -m pytest tests/core/test_sandbox.py --integration -k "installed_cli_starts and hermes": 1 passed.
  • python -m pytest --changed: 1371 passed, 165 skipped, 6 failed. The 6 fail identically on main with this branch
    stashed (environment, not this PR): examples/clbench_database/utils/tests/test_parity_golden.py (3),
    tests/core/test_sandbox.py::test_inside_the_sandbox_the_hidden_paths_are_empty,
    tests/methods/harness2/test_harness2_on_pi.py::test_what_a_pi_session_spent_is_kept_when_it_times_out_or_is_stopped
    (2).
  • Recorded streams (tests/fixtures/hermes/, README says how): success, resume, 503
    (unavailable), 400 (rejected), turn limit, interrupted, tools down, from the real Hermes run by the Base Agent.
    Tests for cases the recordings do not hold edit one event of a recording (edited in the test file).
  • By hand: hermit deploy --host hermes --adapter docs/_examples/file_adapter, the fragment merged into a Hermes home,
    then the real hermes in the workspace: the adapter's stdio tool server answered, its skill and .hermes.md were in
    the system prompt.
  • ruff check --select F401,F841,F811 on the new and changed modules and git diff --check: clean.

Unverified: a real provider (usage, cost and Hermes's error classification on real 429/5xx); the Anthropic Messages and
Responses api_modes (only chat completions was run); a full hermit train with the hermes Evolver; Hermes releases
other than 0.19.0 (the plugin's hook payloads, the subdirectory-hint switch and the config keys are Hermes's, pinned
there; a Hermes without the hint tracker fails an Evolver session rather than give it an AGENTS.md).

Review

  • Tests and documentation cover the affected behavior, where applicable. Tests: see Validation; docs: see Change.

  • Commands, defaults, and public interfaces are consistent. hermes is added to every list that names dsh
    (config bases and sections, defaults, CLI_KINDS, NO_LOGIN, --host, the AgentEvolver's backends, stream readers
    and markers, AHE wires and texts); tests/core/test_selection.py and the sandbox CLI test enumerate it.

  • Shared logs and examples contain no credentials or private data. Fixtures use a mock key variable; workspace
    paths are written /w and the model URL 127.0.0.1:9 (README).

  • Documentation-only: not applicable.

  • Core changes. Shared code gains a new subclass and registry entries; CliAgent (the shared runner) is
    unchanged. Touched shared modules: cli.py (new class and helpers only), records.py, trajectory.py,
    backends.py, config.py, isolate.py (a settings check only), login.py, workspace.py, evolver/agent.py,
    pyproject.toml (package data).

  • Implementation correctness and failures. Failed, cut and stopped sessions are reported as such, never as
    success: exit 1 with Hermes's classification (unavailable vs rejected), the turn limit, missing tools, a blocked
    context file and hints left on although Hermes exits 0, a stop (interrupted, no orphan command), a run that wrote no
    plugin event (started: false). The audit's findings on this item are fixed (below).

  • Real execution paths and tests. Unit tests go through make("hermes").run, the acting agent's run,
    Config.load/layered and the Evolver loader, with a fake hermes that replays recorded streams; integration tests
    run the installed CLI.

  • Documentation. See Change; the claims the audit found inaccurate are corrected.

  • This description. Read back against the code at the PR's head.

  • Independent review (post-PR audit). A separate agent audited 6c76cca (before publication) against the
    general, test and sandbox checklists: it read the diff, callers, tests and Hermes 0.19.0's source, ran the suites and
    reproduced its findings with the real hermes against a scripted model. No blocker; its findings and their
    resolution:

    # Finding (audit's severity) Resolution
    1 Should-fix, reproduced: a kept home could be redirected (active_profile + profiles/), and .op.env, auth files and skills a session left survived Allowlist (HERMES_KEPT) and a marker; test plants each and checks the next call's home
    2 Should-fix, reproduced: --ignore-rules leaves Hermes's subdirectory hints on, so the Evolver was given the adapter's AGENTS.md The plugin turns them off and reports it; a session whose hints stayed on fails; unit and integration tests (both settings)
    3 Should-fix, reproduced: Hermes's prompt-injection scan can replace the whole .hermes.md silently (benign rules match) The plugin reports a blocked context file; the session fails naming it; documented for hermit deploy by hand; unit and integration tests
    4 Should-fix, reproduced: Hermes appends its verifier footer / completion explainer to the graded reply Both off in the session's config; integration test of a failed patch
    5 Should-fix: max_output_tokens on the provider is not applied; extra_body is not on every request; a models.dev fetch for known hosts model.max_tokens; docs say chat-completions requests; a fresh empty catalog in the home; docs and CHANGELOG corrected
    6 Nit: an incomplete turn with no reply was called the turn limit length and "turn limit" only with the summary as reply; test
    7 Nit, reproduced: a reply printed after the turn could be read as events (and a command can write to Hermes's stdout) Readers stop at the turn's end (hermes_events); test. Writing to /proc/<pid>/fd/1 is open to every CLI whose stdout is the stream: left as is
    8 Nit: the "failed request then served" rule was untested Test; mutation-checked
    9 Nit: an empty turn-limit summary is retried once by Hermes (2 unreported calls, counted 1) Documented in parse_hermes
    10 Nit, plausible: Hermes caps a hook's payload at 50,000 characters, which would hide the first request's tools HERMES_PLUGIN_PAYLOAD_MAX_CHARS set high in the session
    11 Nit: --resume moves to the session's old directory --no-restore-cwd
    12 Nit: context-tool and isolate tests not extended to the host Extended
    13 Nit: the caller's PYTHONPATH reaches Hermes's interpreter Documented (the Evolver needs it for its commands; no clashing names at the repository root)
    14 Nits: the plugin's database connection not closed; stale docstring Closed; docstrings corrected
    Q The bound model's key is readable by the session's commands As for every CLI Base Agent: the session needs it, the run's records are scrubbed of it

    The fixes are in the PR's second commit, which the audit did not review; they are covered by the tests above.

  • Group and selection. tests/core/test_hermes_agent.py is in core; tests/fixtures/hermes/* is in
    tests/selection.py's CORE and in tests/README.md.

  • Names / docstrings. Each test is a sentence of the behaviour; the file's docstring names the code and the
    stand-ins (a fake hermes replaying 0.19.0 recordings; the installed hermes against a scripted loopback model).

  • What it asserts. Statuses, records, files, stream fields, the config Hermes was given; error text matched only
    where it is the contract. The new behaviour has no code before this PR; the audit mutation-checked four mutations
    (one survived and now has a test).

  • Isolation. Unit tests write only to tmp_path, use no CLI, sign-in or network; integration tests are marked
    and skip without hermes, git or a working bubblewrap; the sandbox test's workspace is under
    ~/.cache/hermit-tests and removed.

  • Time and order. No fixed timestamps that expire (the update check's is in 2100 by design); no shared state.

  • Cost. Unit tests ~9 s, integration ~55 s (the stop test 18 s of it, waiting on its clock).

  • Hygiene. Lint clean (Validation); the integration tests' servers and workspaces are closed and removed, and
    the stop test asserts no command outlives the session.

  • Reuse the framework's sandbox. Hermes runs through CliAgent's isolation (none, or the run's sandbox via
    Sandbox.wrap, as Pi, OpenCode and dsh); no new process type. The audit's record of the sandbox integration run
    (agent-1.json): role agent, network isolated, probe passed (outside hosts blocked, model and tool ports forwarded),
    enforced; read-only the hermes uv-tool directory and its interpreter's base; read-write only the workspace and the
    home. No hermit train run with it exists yet (no model key).

  • Sandbox changes are core changes. The sandbox itself is unchanged (hermit/isolate.py gains only the
    hermes_problems config check, beside dsh's).

🤖 Generated with Claude Code

veoery and others added 3 commits November 14, 2026 12:36
An independent audit of 6c76cca (general, test and sandbox checklists; findings reproduced
with the real hermes 0.19.0 against a scripted model) found no blocker and these, now fixed:

- A kept home holds only Hermes's sessions, hermit's ledger and the logs between calls
  (HERMES_KEPT): a profile Hermes would switch its home to (active_profile, profiles/), a
  .env/.op.env, credentials and skills a session left are removed; a home hermit did not
  make (no marker) is refused, never cleared.
- context_files false (the Evolver's): the plugin turns off Hermes's subdirectory hints,
  which --ignore-rules leaves on (a touched folder's AGENTS.md added to a tool result), and
  reports it; a session whose hints stayed on fails.
- A context file Hermes's prompt-injection scan replaced with a [BLOCKED: ...] notice fails
  the session, naming it (benign rules match).
- The reply is the model's own: Hermes's verifier footer and completion explainer are off.
- The output limit is the model's max_tokens (Hermes ignores the provider's); a fresh empty
  models.dev catalog in the home, so no catalog request; extra_body documented as
  chat-completions only.
- Readers stop at the turn's end, so a reply printed after it is never read as events; an
  incomplete turn with no reply is no turn limit; the plugin's payload cap raised;
  --no-restore-cwd on resume; the plugin's database connection closed.
- Tests: each fix, the "failed request then served" rule, the context-tool and isolate
  checks for the host; integration tests for hints, the blocked context and the footer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Rollouts count every usage: the acting agent kept only usage[0], dropping
  Hermes's auxiliary calls from cost, tokens and model calls.
- A reply cut at its output limit, which Hermes continues before its hook
  reports the request, is counted: the plugin writes hermes.request_start
  for every attempt, and a request that neither answered nor failed is an
  unreported call (cost unknown); a 400 policy rejection is a failed one.
- A failed turn's auxiliary calls are read from the home's state.db (no
  session_end reports them).
- A request after a 503 counts as recovery: a continued reply that ended at
  the turn limit is no outage to retry.
- ANTHROPIC_AUTH_TOKEN is dropped; the bound key is kept whatever its name
  (HERMES_API_KEY).
- A context file Hermes's scan blocked is reported from the scan itself, on
  the Responses and Messages APIs too.
- Docs: hermes-agent[mcp,anthropic]; max_output_tokens on the model; Hermes
  loads its own source's .env and a managed .env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@haizhongzheng haizhongzheng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The plugin stream is a clean way to read Hermes, and the recorded fixtures made the review much easier. We reviewed e20ebf4 with two independent reviewers over four rounds, verified every finding against the code and Hermes 0.19.0's source, and ran the real hermes against a scripted model where a case could be reproduced. The fixes are pushed to your branch as f114385; each code fix has a test that fails without it.

Usage and cost

  • Auxiliary calls in rollouts. The acting agent kept only usage[0] in RunOutput, so Hermes's auxiliary calls (a compression's summary) were left out of a rollout's cost, tokens and model calls. It now sums every usage.
  • A reply cut at its output limit. Hermes asks for the continuation before its post_api_request hook reports the request. With the real hermes, 2 requests were counted as 1, with a known cost. The plugin now writes hermes.request_start for every attempt. parse_hermes counts a request that neither answered nor failed as an unreported call, so its cost is unknown. A content filter's refusal of a 200 counts the same way; a 400 safety rejection is a failed request.
  • A failed turn. A turn that failed fires no on_session_end, so its auxiliary calls were lost. adjust_usage now reads them from a copy of the home's state.db.
  • A recovered 503. A 503, then a continued request, then the turn limit was read as an outage, and the acting agent ran it again. A request started after the error now counts as recovery, in outcome() and in hermes_steps.

Environment

  • ANTHROPIC_AUTH_TOKEN now joins the dropped keys. Under isolation: none, the Anthropic SDK of a Messages-API session sends it beside the bound key, to that backend.
  • The bound key is never dropped. For a backend named hermes, the key is HERMES_API_KEY, which the HERMES_* filter removed.

Blocked context

  • On the Responses API the system prompt is instructions, which the hook never sees. On the Messages API the hook's copy of system is cut at 8,000 characters. So a context file that Hermes's scan blocked could pass unnoticed. The plugin now records what agent.prompt_builder._scan_context_content blocks, and the scan of the system prompt is kept for resumed sessions.

Docs

  • The installation line is hermes-agent[mcp,anthropic]==0.19.0: a Messages-API backend needs the SDK, and Hermes cannot install it inside the sandbox.
  • max_output_tokens goes on the model (max_tokens), not the provider (model-backends).
  • docs/framework/task.md now notes that Hermes still loads the .env beside its own source and a machine-wide managed .env, over what Hermit passes.

Noted, not changed

  • If a compression rotates the session id and the turn then fails, that compression's usage is still missed. The same happens for a preflight compression in a resumed session. Both are rare, and the fix would re-key the usage ledger by session id.
  • An auxiliary response without usage writes no row, so a relay that leaves usage out of non-streamed responses hides that call.

Tests. python -m pytest --changed --base origin/main: 1563 passed, 121 skipped, 0 failed. tests/core/test_hermes_agent.py --integration with Hermes 0.19.0: 40 passed.

🤖 Generated with Claude Code

@haizhongzheng haizhongzheng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with the fixes in f114385 (details in the review above). CI passed on f114385.

🤖 Generated with Claude Code

@haizhongzheng
haizhongzheng merged commit 616e818 into Infini-AI-Lab:main Nov 16, 2026
1 check passed
iamziyuzhao added a commit that referenced this pull request Nov 17, 2026
Main has gained Hermes Agent as a CLI Base Agent (#107, 616e818) since this PR's base, e813538. In the rebase, each
conflict keeps both sides: #107's Hermes in the docs' lists and tables of CLIs, and this PR's Harbor beside it. A
Harbor trial does not run Hermes: the runner refuses `acting_agent.cli: hermes` at startup, as it refuses any CLI
with no HermitXXX class, which a new test holds. The docs now say so (the acting agent's row in
docs/framework/task.md, the CHANGELOG entry), and FRAMEWORK_SUPPORT.md counts five other hosts that take
`serve_tools`, Hermes's among them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP
haizhongzheng added a commit that referenced this pull request Nov 18, 2026
…ing commands and configs (#105)

* Shared layers: a Harbor trial of any CLI is deployed, bound and read as Hermit's own sessions are

What the Harbor runner needs of the layers every method shares, so that a trial in a task's container is one more
session of the CLI's Base Agent:

- The hosts deploy for a caller that serves the adapter's tools itself (`--no-serve-tools` on every host; Pi's and
  dsh's `prepare(serve_tools=False)` names no server, and the acting agents' workspace now passes the flag on, so a
  container session of Hermit's own runs gets no server row it cannot start) and take one task's context
  (`--context-file`).
- Every CLI Base Agent reads a stream its caller read elsewhere: `outcome()` with no stream file reads the stream's
  text as it reads the file, the reply included; a missing or empty stream is a session not served, never a TypeError.
- A Codex session whose sign-in or key the provider refused is `login_failed` (the run stops) if its turn did not
  complete, read from its own notices: never one it recovered from, what its log quotes of the session's tool calls,
  or an event's text (U+0085, U+2028 and U+2029 end no line of a stream); `unavailable` comes from its last failure.
  Codex's records are read with span prefixes too (`RUST_LOG=codex_core=info`).
- hermit.agent.base.trajectory, the AHE Debugger, Harness²'s bench, RRSI's render and SkillOpt's Codex trace read a
  Harbor trial of any CLI (`agent/agent-<backend>.jsonl`, then Harbor's own output files, then its ATIF trajectory,
  which the Debugger takes before those files), and AHE's texts (EVOLVER.md's too) name that trial's files (the
  stream, hook audit and state under agent/; the record's instruction, as the Debugger's `task0i.md`; START.md's
  tree). Harness²'s bench takes a Claude Code trial's final message as the Base Agent reads its reply. MWM counts a
  learner session's turns and actions from the events the common reader reads (a line of the CLI's own that is no
  JSON object, or an event holding U+2028, no longer fails the step) and finds a task's record by the material's own
  file name.
- A Harbor acting agent's model is bound and checked in the acting CLI's dialect (`agent (harbor, <cli>)`, an
  endpoint's too), the whole Binding spec kept, developer_role included, and its login is a contained session's
  (logins_of) unless `claude_bin` names this machine's Claude Code, whose version is then checked; the task set's
  benchmark file counts for both, as the runner merges it (relative to `normalize_config`'s `base`, else the working
  directory). hermit.harbor.clis is the table of those CLIs.
- A client of a CLI's chat endpoint counts what a session that failed or that the provider refused used, which the
  endpoint reports in its error body (ChatClient's `count_error_usage`, set by `endpoint_spec`).

tests/selection.py counts the recorded OpenCode and dsh streams as shared: the methods' tests read them too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Core: infra runs, configs for hermit eval alone, and a multi-step task's steps in order

What a Harbor task set needs of the framework's own commands and configuration. There is no new way to run: training
is `hermit train`, testing is `hermit eval --adapter ...`, each set by the run's YAML and overrides as before.

- A run that is not the agent's result (`RunOutput.extra["unscored"]`: a Harbor trial of status infra) has status
  `infra`: never judged, its score null in steps.jsonl, left out of the Trainer's and `hermit eval`'s means and
  counted (`unscored`, in the summaries, the learning material and the card). `eval.infra_retries` and
  `eval.infra_wait_s` make `hermit eval` run such rows again, except a multi-step task's step rows, a task Harbor runs
  for none of Hermit's agents (`unsupported_task`) and any after a halt (a lost login, a usage limit).
- `hermit eval` needs only what it reads (`data.tasks`, `data.test`, the agent, the judge): a config with no
  `data.train`, such as a baseline's, needs no template or Evolver; `hermit check` checks it as `eval` runs it (its
  probe on a test row), `hermit train` refuses it, and its run name is the config file's when `trainer.run_name` gives
  none. An adapter of the run's tree (`final`, `root`, a tag, a commit) needs that tree: without one, `eval` refuses it
  before any run. The `eval` section is checked where an eval runs.
- With `eval.repeats` above 1, each repeat hands the pipeline copies of its rows that name it (`repeat`), so that a
  pipeline that keeps its trials by row (Harbor's trial cache) runs each repeat anew; results.jsonl names the repeat.
  With `trainer.epochs` above 1 each epoch's rows name the epoch (`epoch`), and the rows `run_agent` runs, and those of
  a task the epoch's order names twice, ask for a new run (`fresh`): such a pipeline runs each anew, an epoch on an
  adapter the one before left unchanged included, where it would have handed back the earlier trial.
- A multi-step Harbor task's steps run in order in its stream: `data.shuffle` moves its rows as one; a split whose
  order is kept (the train split with `data.shuffle: false`, the test split, the validation split) that lists a step
  ahead of an earlier one, or without every earlier one, is refused before any run, and `hermit check` reports it;
  `next_tasks` may name a step only after the earlier ones; `run_agent` runs no training row that is such a step, and
  an id it does not run comes back as an error result (score 0), no longer an exception; Harness² fails such a step
  before any editor session, and records an infra execution's cause beside its null score. A run runs each step of a
  stream once, in one environment: a train split with such steps trains one epoch (`hermit train` refuses more, and
  `hermit check` reports it). `hermit check` checks the test split's order for a training config too, and its probe
  runs no later step.
- The Harbor task set's tasks and jobs directories, and an eval config's tree, are run secrets. The Harbor agent is
  told what its streams are named for (`run_identity`: a training run's record directory and the id it keeps there,
  any other pipeline its own), whether they are kept for a resume (`keep_streams`: the Trainer's pipeline only, until
  the run finishes), the run its trials are kept to (`trial_scope`: the Trainer's pipeline only, that identity),
  whether the run deploys adapters, and the CLI and login of a model only a CLI reaches; `hermit check`'s probe takes
  no trial from the trial cache.
- An acting agent of Harbor's own takes no adapter: `hermit train` refuses it, `hermit eval` runs it with
  `--adapter none` only, and `hermit check` reports it for a training config.

tests/core/test_harbor_core.py covers these. What this commit hands the Harbor agent, the next commit's runner takes:
three of these tests (Harbor's `dataset prepare`, and a pipeline closing its HarborAgent with its streams) pass from
there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Harbor: every CLI in the task's container from one launch plan, with the adapter's tools, context and notes

A Harbor trial ran only Codex well (and Claude Code through code of its own); the adapter's tools, a per-task context
and an adapter's notes never reached the container, and infra trials counted as zeros. Now:

- One HermitXXX class per CLI (hermit.harbor.clis: codex, claude, pi, opencode, dsh, mini-swe-agent) over one executor
  (harborside/hermit.py). Hermit's side renders each trial's session with the CLI's own Base Agent
  (hermit.harbor.launch: the home, the command, the environment; host paths made the container's) against the adapter
  deployed as `hermit deploy` lays it out, and harborside uploads and runs it as the task's agent user: the prompt on
  stdin, the stream in agent/agent-<backend>.jsonl, the deployment record always there (so an adapter's hooks run on
  Codex too, HERMIT_HOOK_LOGS set), a session still running at Harbor's timeout killed with its process group. The
  steps after the session still run past that timeout, and keep the session's own error when the timeout lands in
  them; a copy that failed is dropped, never kept in part. A `<cli>_bin` serves only at the asked-for version and when
  the agent user may execute it. The runner reads the stream back with the same Base Agent: reply, served, the plan's
  or the provider's refusal, the usage at `agent.params.price`, else at the backend's price.
- The adapter's tools are served from this machine on the Docker bridge's gateway (hermit.harbor.tools, every call
  logged); a per-task context is computed in the adapter sandbox (hermit.harbor.context); an adapter's notes come back
  after the session (memory/ in the log).
- A key or a token reaches the container by its variable's name only (`docker compose exec -e NAME`; Claude Code's
  subscription token on a descriptor), never in a command line, a file, the plan or a log; Codex's ChatGPT sign-in is
  a file of its home there (mode 600). Codex and Claude Code run on the user's subscription
  (`login: chatgpt | claude`) in the plan's slots and holds, each trial noting the plan's usage (so `MAX_USED` holds
  trials back): a refused session again after the window, one the provider could not serve after a pause unless it
  ran out of the agent's time, a lost sign-in never, none once another trial halted the run; the trial's usage is
  every run's. Codex's refreshed sign-in comes back and becomes the shared copy. A task whose agent network is not
  public gets the model's and tools' hosts allowlisted and web search off; `web_search` must be set.
- The answer-only agent (`cli: answer`) makes one model call through an endpoint the runner serves and writes the
  answer into the container (LAB-Bench's questions); a request still in flight when the trial ends is given up, its
  cost unknown, and on a model a CLI reaches on a login the trial waits for that plan first (a request the plan held
  past the agent's time is infra, `usage_limit`). A question or attachments it cannot read fail the launch.
- The judge scores the verifier's reward whenever the verifier gave one, a timeout or an agent error included
  (Harbor's own mean), says "passed" at `pass_reward` (null for a score scale) and leaves out what `verifier_redact`
  matches. Not the agent's result, so unscored (infra): a verifier whose tools never downloaded or that hit a full
  disk, harborside's launch failing (HermitLaunchError, the CLI's install included), a session that never started or
  whose tools never came up, a lost sign-in, a Claude Code, Pi or OpenCode session or an answer request the provider
  refused for the run's configuration before serving any (its key, model, bill or a setting it does not take:
  `model_rejected`, no halt), a task Harbor runs for none of Hermit's agents (MCP servers, a skills folder, a Windows
  container: `unsupported_task`, never handed to Harbor; the set's other tasks run). A trial out of the agent's time
  is the agent's even after a provider notice, and so is a request refused for its input; the adapter's context over
  the CLI's limit beside the image's own is the adapter's 0, and so is a session the model's safeguards ended. With
  `verifier_timeout: agent` (a verifier that times the agent's solution, as AlgoTune's does) a verifier out of its
  time is the agent's result, and Continual Harness's Refiner reads it as that, not as a session past its clock.
- Startup refuses what every trial would: a login for another CLI, a login and a binding at once, a loopback model, a
  missing key or sign-in, a non-Docker environment for secrets by name, a plan the Base Agent cannot render
  (mini-swe-agent's: web search, a model class Hermit does not read), a `harbor` that is no executable file,
  mini-swe-agent without its package for a run that deploys adapters, the answer agent's attachments on a model a CLI
  reaches. Harbor's own claude-code gets a bound model's Messages API root (it was sent to /v1/v1/messages), keeps
  Harbor's per-task web rule unless `web_search` is false, and is refused the subscription (`CLAUDE_FORCE_OAUTH`, or
  the subscription's token as its only sign-in).
- `python -m hermit.harbor.dataset prepare` makes an example's data from its benchmark file's `dataset:` block (the
  registry's tasks, rows, splits, smoke rows, a patch, the images' sizes with `image_sizes: true`, a lock). A download
  is moved into place only once whole, and what is in its way is refused first; a relative `data:` is the benchmark
  file's folder's. The lock and the download record the tasks' source (a download of another source is never reused,
  and the default data directory is the source's own); the lock holds no path of this machine and hashes only a mode's
  executable bit (one written under a umask other than 022 needs writing again); an unreadable lock is refused unless
  `--force`.
- Also, from the Terminal-Bench 2.1 runs: a host failure (Docker's, the host's /tmp full) is infra and no trial starts
  while /tmp is short; the trial of a task whose name is longer than 32 characters is found; a `harbor run` past its
  wait budget is killed and its trial's compose projects, the verifier's too, taken down by name alone (no compose
  file or `COMPOSE_*` variable read). A stream's step runs its own plan, its verifier read as a trial's; each `hermit
  eval` repeat and each run gets streams of its own, stopped when the run ends unless a `hermit train` may resume
  them. The trial cache keys the launch, the whole row, the task's files, the model's price and the adapter as
  deployed (a file's executable bit, not the bits a umask sets; not the adapter's card, which no deployment copies, so
  a final adapter tested again meets its trials); a cached trial costs nothing again; a training run's trials are its
  own (only the run, resumed, meets them) and each epoch's too, a row asking for a new run (run_agent's, a task a
  split names twice) is neither taken nor kept, and `hermit check`'s probe neither takes one nor keeps one. The
  benchmark file's price applies to its own model, and a model the config gives as an endpoint mapping keeps its own
  price.
- OfficeQA's Harbor judge reads the final message from HermitCodex's stream (`agent-codex.jsonl`): a task set built
  before needs building again.
- Docs and CHANGELOG for the whole change (the framework's task, configuration and command pages; the methods' pages;
  the Breaking entries: the runner's `codex_login` is gone, `login: chatgpt`; a table CLI's trial needs `web_search`;
  secrets by name run on local Docker only).

Checked in real containers on this machine, each run a `hermit eval` of a config for it alone: Codex on the ChatGPT
login (no adapter; tasks with an open and a closed network; the adapter's MCP tool, AHE's hooks, Continual Harness's
notes, ASPIRE's template) and Claude Code on a subscription token (an instruction that begins with `/`, the MCP tool,
AHE's hooks); Pi, OpenCode, dsh and mini-swe-agent on a scripted model; the answer agent; a three-step stream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audits of 2d9401c and 3aa0cc2

The post-PR audit of this PR's 2d9401c found one high issue and six medium ones, and the audit of #106's 3aa0cc2 one
medium issue in this PR's code; each is fixed here, and so are five of the low ones.

- Claude Code on Anthropic's own API with a key (`acting_agent: {cli: claude}`, `anthropic/<model>`, no login)
  started every session without a token: the launch script exported the plan's empty ANTHROPIC_API_KEY before
  ANTHROPIC_AUTH_TOKEN read the key from it. A variable the plan passes under another name is now set first, in one
  export that reads every source as Harbor passed it; a source no entry sets is unset, and the plan's own variables
  come after.
- A Harbor halt (a lost sign-in, an API account's usage limit) ends `hermit train` unfinished at the step that met it,
  before its learner (after the learner's call when a run of `run_agent`'s met it), and a resume runs that step again:
  before, every later rollout came back infra/halted while the learner went on, and the run ended as finished.
- Whether the provider could not serve a Codex session is read from its last failure since the session last worked,
  never from a warning of Codex's (the trust it gives a deployment's hooks), and a turn that failed, or a stream that
  ended, while Codex retried its requests is one it could not serve, unless the sign-in was lost: Codex 0.164 that
  cannot reach chatgpt.com fails its turn with `workspace routing discovery failed`, which the last-failure rule had
  made the agent's empty answer. Codex 0.164's own words for a lost sign-in are matched.
- A ChatGPT sign-in a session hands back replaces the shared copy only as a later, well-formed refresh: a regular file
  of at most 64 KiB (a container's larger one is never downloaded) holding its refresh and access tokens, for the
  copy's account, stamped after the copy and at most a minute ahead of this machine's clock (an hour where the clock
  may differ). Harbor no longer gets CODEX_FORCE_AUTH_JSON or CODEX_AUTH_JSON_PATH from the user's environment.
- Only a pipeline that keeps its trials by row (a Harbor task set with `trial_cache` on, in the config or its benchmark
  file: isolate.keeps_trials) is handed rows naming their epoch or asking for a new run; no record keeps `epoch` or
  `fresh` (rollout.TRIAL_KEYS), so the learning material's `input` and every learner's text of a task are the same in
  each epoch, and the adapter's per-task context gets the task's own row.
- A Harbor trial is scored as Harbor grades it: a verifier that left no reward Harbor could read or ran out of its time
  (`verifier_timeout: agent`, now the default; `infra` the opt-in for a host whose load makes verifiers time out), and
  a request of one of Harbor's own agents that the provider refused for what it held, are the agent's result, 0
  without a reward, unless the verifier's output shows its tools never arrived or the host's disk full; a provider
  that could not serve, or refused the run's configuration, stays infra (Hermit runs it again, where Harbor grades it).
  An OSError on this machine while the adapter is staged is infra (`staging_failed`); the adapter's own deployment or
  per-task context failing stays the agent's 0, since what its child process prints could be the adapter's words. A
  verdict that quotes the verifier's output applies `verifier_redact`.
- `dataset prepare`: a patched set is its patch's own. The download record names the patch (its hook and its file's
  digest), a reuse of another source's or another patch's tasks is refused before the patch runs, the default data
  directory is named by the patch too (an unpatched set's name as before), and a download is patched in its own
  folder before it is moved into place.
- The AHE Adapter's learners' clocks (`evolve_timeout_s`, the Agent Debugger's `timeout_s`) are the Base Agent's own,
  counted from the CLI's start: a wait for the login's plan or a session slot pauses them instead of spending them (a
  hold longer than a clock made the step a no-op recorded as done, or the Debugger's analyses upstream's fallback
  text). This reverses PR #65's choice that the Debugger's clock cover the plan wait: upstream's clocks had no plan
  hold to cover. `trainer.call_timeout_min` still bounds a step, waits included.
- `hermit train`'s refusal of more than one epoch over a multi-step task's steps gives its true reason.

Tests: test_harbor_harborside.py (every CLI's launch script on every backend run by bash, the returned files' limits),
test_harbor_runner.py (grading as Harbor does, staging, redaction, the sign-in back by the environment's clock,
Harbor's environment, a Codex outage), test_harbor_core.py (the rows only a trial cache is handed, the records, a
halt), test_harbor_dataset.py (patched sets), test_cli_agent.py and test_base_agents.py (Codex's outcome and lost
sign-in words, the take-back), tests/methods/ahe (both clocks through a real login path).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audit of fe8c5b4

The post-PR audit of this PR's fe8c5b4 found two medium issues and eleven low ones; each is fixed here.

- A step of a multi-step task whose turn cannot come ends infra (stream_order) at once and starts no driver: its
  stream's driver waits for a step no rollout of the runner is running (one that ended before it reached the driver,
  or ran in an earlier training step), or the stream has no driver and no rollout of its first step is running to
  start one. Every later step of the stream ends the same way, and the last of them stops the driver. Before, each
  waited out its turn (by default its budget for each earlier step and an hour more), holding a rollout's worker, then
  ended infra, so a step that failed on this machine before it reached the driver, a halt (whose resume reran a later
  step on a new driver at step 1) or a driver gone lost the rest of the stream after hours. The runner keeps each
  stream's steps in flight; StreamClient.wait_turn takes what it asks.
- `trial_cache` with an answer agent on a model a CLI reaches (`model: {cli, model, login}`): the trial's key held the
  URL of the endpoint the run's pipeline serves the model on (its port and token, and the binding's `messages_url`
  derived from it), which no resumed run or other eval has again, so no trial was ever taken from the cache. The key
  names that model by its CLI and login.
- A new stream driver in a directory that held one sets the earlier one's trial and replies aside (`earlier/<n>/`):
  Harbor reuses a trial's step directories, so a step of a stream run again that left no output of its own was read,
  and billed, as the earlier run's.
- A stream driver that answers no stop within 15 minutes (hung in a step) is killed with its process group, and its
  trial's compose projects are taken down by name.
- An OSError on this machine while a trial's job and launch are written (its job directory, the launch plan, the
  agent's config, job.yaml), or a stream step's launch plan, is infra (`staging_failed`), as one while the adapter is
  staged is: before, it raised out of the rollout, the agent's 0.
- A rollout that never reached a container (a halted run's, the disk gate's, an unsupported task's, a staging that
  failed, a stream step its driver was never asked for) costs 0: before, its cost was unknown, which left the eval's
  total cost unknown. A stream step lost after its request was sent keeps an unknown cost.
- The ChatGPT sign-in's take-back reads the shared copy's own stamp as any accepted copy may hold it (at most an hour
  ahead of this machine's clock, as one from the user's own file), never as no stamp: an earlier file a session
  handed back replaced a copy stamped ahead of this clock.
- Codex's fall back from WebSockets to HTTPS retries nothing, so a request refused after it is the session's own
  failure; only its reconnects (`Reconnecting...`) are retries.
- `hermit eval` of a split that names a task twice keeps a row for each, as on main (the infra reruns kept the records
  by id).
- `<jobs_dir>/HALT` names the record's cause first (`login_failed`, `usage_limit`) and says that it halts every run on
  that jobs directory, as the docs now do.
- The docs: a sign-in file is checked for its size before it is downloaded (one grown after the check is refused when
  taken back); with Harbor's retry on, a failed attempt's usage is not counted; what `staging_failed` covers. The
  CHANGELOG's Harbor entry is rewrapped where earlier edits had cut its lines short.

Tests: test_harbor_runner.py (a stream's lost turns, at once and in order, a halt's resume, a rerun's outputs, a hung
driver, a stream step's launch, a lost step's cost, the CLI model's trial key, a trial's staging, a never-ran
rollout's cost, the halt file), test_harbor_core.py (a split that names a task twice), test_cli_agent.py (a copy
stamped ahead of this clock), test_base_agents.py (Codex's fall back).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audit of 3a49adc

The post-PR audit of this PR's 3a49adc found three medium issues and fifteen low ones; each is fixed here or, where
it is a limit of the design, recorded in the PR.

- `trial_cache` with a model a CLI reaches: 3a49adc named that model by its CLI and login alone, so a second eval on
  the same jobs directory whose CLI had another effort, `bin` or version met the first one's trials. The key also
  holds the CLI's identity (`hermit.agent.base.endpoint.cli_identity`: its settings as its sessions get them, less
  where they run and log and which plan they wait for, and its binary's path, size and time of change), as a digest
  that hermit.isolate.agent_pipeline hands the runner (`model_cli_identity`). Harbor's `retry`, the adapter
  sandbox's `sandbox_enforce` and `tools_host` are in the key too.
- A trial whose agent ran out of its time or exited with an error is verified by Harbor and graded: when its
  verifier's tools then never arrived (a 5xx of GitHub's release download) or met the host's full disk, it is infra
  and run again, as one whose agent finished is. Before, it was the agent's 0 and stayed in the trial cache.
- Codex's words for a refresh of the ChatGPT sign-in the provider refused ("Your access token could not be refreshed
  [because your refresh token was already used / has expired / was revoked]. Please log out and sign in again.")
  are a lost sign-in: the run halts. Before, the trial kept Harbor's verdict, scored 0 and cached. A sign-in refusal
  counts only since the session last worked: one on a side request the session worked after is none.
- `run_tasks` submits each multi-step task's steps in step order, in the places its steps had: a `run_agent` call
  that listed a later step first, with fewer workers than the gap, gave the stream up and lost the earlier step too.
- A step whose stream aborted before its turn is never asked for (`wait_turn` checks the abort first), so it costs 0;
  and a trial whose environment or agent setup failed before its agent started (Harbor records no
  `agent_execution`) costs 0. Both had an unknown cost, which left the eval's total cost unknown.
- An OSError on this machine past the guarded steps (no process left to start `harbor`, a file it cannot write or
  read) is infra (`host_failed`), its cost unknown, not the agent's error scored 0. A trial cache this machine cannot
  write leaves the trial as it ended (it stands, uncached), an entry it cannot read is no trial kept, a key whose dry
  render cannot be written runs the trial without the cache, a sign-in take-back that fails leaves the trial as it
  ended, and a HALT file it cannot write leaves the halt to the rollout's output.
- A stream step run again sets the tool-call log an earlier run of it left aside (`earlier-<n>-tool-calls.jsonl`) at
  its turn, so its curated log holds its own calls only.
- A killed stream driver's socket is removed.
- Only a Harbor task set's rows name their repeat (`repeat`, with `eval.repeats` above 1), and no record's `input`
  keeps it; a record's `input` drops only the keys its caller added (the Trainer's `epoch` and `fresh`), so a row's
  own field of those names stays. Every other pipeline gets its rows and records as on main, and a Harbor adapter's
  per-task context never reads `repeat`.
- A failed `hermit eval` removes the earlier eval's `summary.json`, as it empties `results.jsonl`.
- The overlap error of a declared path names a Harbor task set's directories as such.
- The docs: `solved_once` counts each test id once; the steps of `run_agent`'s call run in step order; the cost of a
  trial that never started an agent; `host_failed`; the Codex refresh refusal and what to do about it; a copy stamped
  ahead by another clock is replaced once this clock passes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audits of e7ace26 and b709e0c

The post-PR audit of this PR's e7ace26 found no high or medium issue and eleven groups of low ones; the audit of the
benchmarks PR stacked on it (b709e0c) found a medium issue here and a low one. Each is fixed here or, where it is a
limit of the design, recorded in the PR.

- `python -m pytest` imported the files of a run's folder beside an example's configs (`examples/*/runs`, their
  output_dir), a task container's and a learner's files among them, and ran them on this machine outside any
  sandbox: the root conftest ignores them, as it ignores a Harbor task set's.
- A pipeline that deploys adapters is refused at startup where bubblewrap is not installed and the adapter sandbox
  that renders each adapter is required (`agent.params.sandbox_enforce`): each trial ended in the sandbox's error,
  scored 0.
- A rollout that met a halt (a lost sign-in, an account's limit) and then an OSError of this machine (its curated log
  not written: a full disk) came back `host_failed` with no halt, so that nothing halted where its HALT file could
  not be written either: it keeps the halting verdict. A jobs directory this machine cannot make is `host_failed` at
  a cost of 0, not an error scored 0.
- A stream step whose turn never came curated the tool-call log an earlier run of it left as its own: it curates none.
- A verifier's words of a full disk (ENOSPC) made a trial infra even after its tests ran: now only before its tests
  wrote a report (`ctrf.json`), so that a test's own output (an agent's program, a task about a full disk) stays the
  agent's result.
- The copy-back and the collect ran as root in /logs/agent, which every user can write in, through a link the agent's
  user could put there, and made what it named readable to all: each makes a new folder of root's, enters it, checks
  that it is that folder, and works in it by relative names.
- `acting_agent.env` is written into each trial's job and onto `docker compose exec`'s command line: a variable of a
  secret's name, or a value naming one, is refused at startup.
- The `tasks` link is followed once (`tasks_dir`), so that a prepare pointing it elsewhere mid-run changes neither a
  trial's task set nor the key it is kept under; a task's link to a folder is in its digest by where it points.
- A codex, claude or pi trial of a model a CLI reaches got the loopback refusal once the pipeline served that model:
  it is refused for what it is.
- A row of its own `epoch`, `fresh` or `repeat` field is refused where the framework adds those keys (hermit train
  with the trial cache, hermit eval's repeats of a Harbor task set; hermit check says so too): they would replace it,
  and no record would keep it.
- `dataset prepare`: a data directory that is the set's own folder in another download is that download's (its
  marker is beside it), refused to a benchmark of another patch; a download is marked in its own folder before the
  set is moved into place; an image whose size cannot be read anew keeps the earlier one; split counts are whole
  numbers, and a smoke task is named once; the rows, the lock, the splits and the sizes are all made before any is
  written, so that a refusal leaves the link and every file as they were; a `data` naming a variable that is not set
  is refused; this machine's errors (an OSError, Harbor's failed download) are the command's `error:`, exit 1.
- An ATIF trajectory's tool-call id that is no string (a list, an object) reads as no id, never a TypeError in each
  learner reading the log.
- Tests: a trial-cache key this machine cannot make, a sign-in take-back that fails, MWM's name of a task's record.
- The docs: a command a CLI ran in a session of its own (Claude Code's shell tool) is outside the process group the
  kill reaches; a `timeout` or an `agent_error` scores 0 when its verifier left no reward.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audit of b9a3d61

The post-PR audit of this PR's b9a3d61 found no high or medium issue and four groups of low ones. Each is fixed
here; its questions are recorded in the PR.

- A `hermit eval` refused at its start (a row of its own reserved key, or a pipeline whose startup checks refuse it:
  no bubblewrap, a secret in its env) had already emptied the earlier eval's results.jsonl and removed its
  summary.json: the eval empties them once its pipeline and judge are built, as on `main`, and a refused start leaves
  them as they were. One that fails after its start still leaves no earlier summary.
- `acting_agent.env`'s secrets are read as Harbor fills its values: `${NAME:-default}`, which Harbor fills in from
  this process's environment, is refused like `${NAME}` (it got through), and a referenced name is a secret's by the
  rule the variable's own name is (`launch.SECRET_VAR`), so that a setting named like one
  (`${TOKENIZERS_PARALLELISM}`) is no longer refused. `$NAME`, which Harbor hands on as that text, is still refused
  where it names a secret, as it never passes the secret the config meant.
- `hermit check` refuses a test row's own `repeat` wherever `hermit eval` of the config would (a training config's
  eval too), by eval's own rule (`_harbor_rows`), and a test now covers it.
- Tests: an unused fixture, a temporary directory outside the test's own `tmp_path`, blank lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Rework: Harbor's needs in hermit/harbor, the agent layers as on main

Everything in hermit/ outside hermit/harbor/ is back at main (e813538):
the three agent layers, the Trainer, hermit eval, hermit check, the
configuration, the sandbox, the methods and the hosts, but one change.
Pi's and dsh's prepare take serve_tools, as the other four hosts
already do, so that a trial gets the adapter's tools from the runner.
hermit/harbor/FRAMEWORK_SUPPORT.md lists where each of Harbor's needs
now lives, and what could later become framework support.

What a Harbor task set now meets:
- A trial that is not the agent's result (infra) runs again in the
  runner (agent.params.infra_retries, 2; infra_wait_s, 300 s). One
  still infra is refused by the judge, so the run records a failed run
  (judge_error): hermit eval counts it among its errors and as 0 in its
  mean. python -m hermit.harbor.report gives pass@1 over the trials
  that are the agent's result.
- A lost sign-in, or an API account's usage limit, raises LoginFailed,
  which ends hermit train and hermit eval as a local session's does.
  There is no HALT file.
- There is no trial cache; agent.params.trial_cache is refused.
- A multi-step task's stream is the runner process's own and is never
  resumed; a split keeps its steps in order (data.shuffle: false).
- A Codex trial's lost sign-in and provider outage are read in
  hermit/harbor/signin.py (the outage by the session's last failure, so
  a reconnect Codex recovered from is no outage).
- The answer agent's model that only a CLI reaches is given in the
  benchmark file; a run config's own is refused at startup.
- A trial's log keeps the CLI's stream, task.md, prompt.txt,
  last_message.txt and the hook files at its top, where the methods
  read a local session's.

Fixes of the last audit (of 418a00d): a stream's step gets the sign-in
at its turn, not when its rollout began; acting_agent.env secrets are
named by Harbor's own rule; each step's allowed hosts reach the driver;
the answer agent waits for its plan's window; a long task name's
verifier containers are found as Harbor names them; a dataset's digest
takes a link as the link itself, not the file it points to.

Tests of the reverted code are back at main; the Harbor tests cover the
new code. Docs and the changelog describe the PR as it is now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: two post-PR audits of the rework

The first audit of the rework (2b2a46b) found no high issue, three medium and six low; a second audit of those fixes
found no high issue, five medium and ten low. Each is fixed here, in hermit/harbor/, its docs and its tests, or
recorded as a candidate where the fix is main's.

- An adapter whose own deployment or per-task context fails in its child process is the agent's result: agent_error
  (adapter_failed), scored 0 with its message as the feedback, which `python -m hermit.harbor.report` counts among the
  scored trials. It left the pipeline as an exception before (status error), outside pass@1.
- A stream's step that ends in any way before its driver is asked for it (its staging, its adapter, its tools, its
  launch plan, the disk gate, its turn's wait running out, its turn's sign-in or tools not readied, an exception of
  any of them) gives the stream up, so its driver is stopped once the stream's rollouts end, that step's own when it
  is the last, and the stream's next pass (an eval's next repeat, a later epoch) starts from its first step in a new
  environment. Before, the driver stayed up for a step that never came: the next pass's first steps ended
  stream_order and its last ran on the environment the pass before had left. A step the driver already ran gives
  nothing up. A later step of a stream with no driver and no rollout of its first step ends before anything is staged
  or served for it.
- A runner's unfinished streams are closed by its finalizer, when the runner is freed and at exit for one still held
  then. Before, a weak set of runners was closed at exit, and a runner freed before then (`hermit check`'s probe,
  `hermit eval` once it returned) left its drivers up for stream.idle_s.
- The docs say what a resumed `hermit train` does to a stream under way (its remaining steps in that epoch end
  stream_order, and the stream starts over at its first step's next rollout), and what an Evolver's run_agent of a
  stream's first step does once the Trainer's pass of it finished: it starts a pass the next epoch inherits.
- A request the provider refused for the run's configuration (model_rejected) is not run again (NO_RETRY), and
  NO_RETRY is tested with runs again allowed; nor is a host failure past the trial's staging (host_failed, whose
  session may have run), which the docs now say. The `halted` cause, which nothing gives any more, is gone.
- Codex: a session the provider refused for the run's configuration or bill (a 400, 402 or 404 Codex does not retry,
  an API account's quota) is model_rejected, as the other CLIs' are, never the agent's 0. Its usage limit is read
  from Codex's own notices, never from what its log quotes of the session's work, and a JSON line its log quotes no
  longer ends the record. A session that failed on its own after a reconnect Codex went on from, or whose response
  the provider's content filter ended, is no outage.
- The answer agent's model a CLI reaches: its sessions run with plan_rerun off, so that a session the plan refused
  comes back at once (infra, run again once the plan allows) instead of waiting for the window inside the agent's
  time and scoring as the agent's timeout; its sign-in is checked at startup; its CLI sessions get main's check that
  the user's own secrets are absent (HOME_SECRETS). The runner refuses a run config's own `{cli}` model for the answer
  agent as written, as `hermit check` hands it, as well as the endpoint spec `hermit eval` and `hermit train` hand it,
  whose test builds it with main's endpoint_spec.
- The docs say that `hermit check` builds the runner and reports its startup refusals, and that every run of
  Hermit's agents needs bubblewrap, a baseline's too (the runner cannot tell a run that deploys no adapter), unless
  sandbox_enforce or HA_ADAPTER_SANDBOX_ENFORCE says best_effort.
- The report says when an eval did not finish: no summary.json beside its rows, one that is not of them (its count of
  trials, of failed runs or its mean score differ), or a last row cut off, which is left out. It reads the summary,
  never the files' times, which a copy changes. The docs say that a stopped eval writes no row of the repeat it
  stopped in.
- A plan refusal's hold gets the run's stop, so that a hold that cannot be written waits no longer than the run. The
  docs record that trials racing on one ChatGPT copy for its refresh end the run: the loser's refusal reads as a lost
  sign-in.
- FRAMEWORK_SUPPORT.md names the four private helpers of main that hermit/harbor/ uses, and more candidates: a
  trial's usage when LoginFailed ends the run, the run's own secrets for the answer agent's sandbox, public names for
  those helpers, rows that say who runs them (run_agent's or the Trainer's), the `login: claude` check of `hermit
  train`, RRSI's halt file. The docs no longer say a trial a lost sign-in ended keeps its runs' usage, and
  bind_agent_params is named right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the tenth post-PR audit

The audit of e19d155 found no high issue, two medium and twelve low, and asked eleven questions. Each is fixed here,
in hermit/harbor/, its docs and its tests, or recorded as a candidate where the fix is main's.

- Pi's and dsh's trials get the backend's developer_role, as Hermit's own sessions do: the spec the config's loading
  keeps drops it (Binding.spec), so the runner takes the backends registry's for a backend it names at the same URL.
  A test compares a trial's provider settings with main's bind_agent_params on Fireworks (developer_role: system).
- `hermit check` and `hermit train` check a Harbor run's acting model as a chat client's, main's rule for an agent it
  does not know: they refuse Claude Code on Anthropic's API, which `hermit eval` runs, and do not check that Codex's
  backend serves the Responses API. The docs say so, and candidate 7 names the cause in main.
- On a login, busy_retries is one count over all of a trial's runs: infra_retries no longer multiplies it (up to 12
  runs by default, where the docs said 4). A plan refusal of the answer agent's model runs the trial again once the
  plan allows, not counted in infra_retries.
- A staging or per-task-context child that failed is the host's failure (staging_failed, run again), not the
  adapter's 0, when this process sees this machine fail any adapter's staging there: a folder it cannot write, less
  than 64 MB free, the strict adapter sandbox not starting. Startup refuses a runner whose bubblewrap cannot start
  that sandbox.
- A trial's launch plan refused for what its adapter is (its tools beside text_only, a dsh server name made of a long
  id) is adapter_failed, scored 0, for a trial and for a stream's step; with no adapter it is still the config's
  error.
- A provider that does not bill the account (a 402, its quota or credit spent) ends the run, as an API account's usage
  limit does. Before, every later trial ended model_rejected.
- acting_agent.settings.env refuses a secret's $NAME inside a value by every rule (AUTH, PASSWD, Harbor's), and a
  secret's value written as it is. `effort: off` gives no effort flag, as on main.
- The answer agent writes answer.json as a new file renamed into place, never through a link the container left
  there. Codex's auth.json is removed from the container once it has been copied back, before a verifier that shares
  the container runs.
- The curated log's top stream is the one the launch plan names. The report adds a note when results.jsonl was
  written after summary.json, as by an eval stopped beside an earlier summary. The runner's finalizer gives each
  driver 2 minutes (CLOSE_STOP_S) before it kills it.
- Tests for each fix above. They also catch four mutations no test caught before: the turn's sign-in copy, the first
  give-up reason, Codex's outage reading, and the report's errors comparison.
- Docs that did not match the code: what `hermit eval` reads of a config made for it alone, the causes never run
  again, only a first step starting a finished stream over, the CLI Evolvers' run_agent, the stream socket's path,
  split files with more than one rollout, Harbor's own usage-limit error, when the `login: claude` warning fires, a
  quoted line in Codex's own form, the relay's sandbox, the deployment record's host paths, and hermit check's probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Rebase onto main: what Hermes Agent is to a Harbor run

Main has gained Hermes Agent as a CLI Base Agent (#107, 616e818) since this PR's base, e813538. In the rebase, each
conflict keeps both sides: #107's Hermes in the docs' lists and tables of CLIs, and this PR's Harbor beside it. A
Harbor trial does not run Hermes: the runner refuses `acting_agent.cli: hermes` at startup, as it refuses any CLI
with no HermitXXX class, which a new test holds. The docs now say so (the acting agent's row in
docs/framework/task.md, the CHANGELOG entry), and FRAMEWORK_SUPPORT.md counts five other hosts that take
`serve_tools`, Hermes's among them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Round-11 audit: a trial's developer_role, a secret's name, which disk gate held

The round-11 audit of a332854 found no high or medium issue; these are its low ones and what its questions found.

- A Pi or dsh trial's developer_role is the backends registry's only for the backend the registry has at the trial's
  URL (launch._with_role): the run config's `backends:` is not the runner's to read, where Hermit's own sessions take
  it. FRAMEWORK_SUPPORT.md (candidate 14), docs/framework/task.md and the changelog said the trial got what Hermit's
  sessions get; they now say where it does not, and a test holds the URL check, on both of the spec's paths.
- acting_agent.settings.env refuses a value given as it is to a variable a word of whose name is a secret's wherever
  the word stands (HF_TOKEN_READ, OPENAI_API_KEY_2, SECRET_ID), not only at the name's end (launch.SECRET_VAR); a word
  that only holds one (GIT_AUTHOR_NAME, TOKENIZERS_PARALLELISM) is no secret. A test now holds Harbor's part of the
  rule for a `$NAME` inside other text ($OAUTH_CLIENT_ID).
- The verdict of a trial, or of a stream's first step, that a disk gate held back names the gate that held it, the
  host's /tmp or Docker's data root; it named the data root whichever held it.
- Tests for what none caught: the answer agent's relay's 402 whatever its words, the stop a runner's close gives each
  driver (CLOSE_STOP_S), a job folder this process cannot write (the host check after a failed staging child).
- docs/framework/task.md says what the questions found: a login's wait for its plan has no bound, a request the plan
  held back at any time makes its timed-out trial infra, a refused session runs again as often as the plan refuses,
  the host check comes after the staging child, and N hung drivers hold a close up N x 2 minutes. The changelog's
  Codex refusal no longer reads as every 400 or 404.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Round-12 audit: a stream's next driver, a curated log's links, refusals for good

The audit of 6a79375 found one high and four medium issues and fifteen
low ones. This fixes the high and medium ones, and fourteen of the low
ones (one is in the PR's description); the last is noted there.

- High: a stream's next pass (an eval's next repeat) could meet the
  driver of the pass before in the half second between its last answer
  and its exit, take it for a live one, and lose the whole pass. The
  driver's record now says it is ending before its last answers
  (harborside.driver._mark_ending); StreamClient.running takes neither
  such a driver nor one killed and not yet reaped, and ensure() waits up
  to 30 s for an earlier driver to exit, then kills it, before it starts
  the next.
- Medium: a step whose own folder this machine cannot make now gives its
  stream up (host_failed), so its driver is stopped and the next pass
  starts anew. Before, the driver waited for that step, and the next
  pass ran its last step on the old environment.
- Medium: a step's curated log walks the agent's folders through open
  directory handles and opens each entry with O_NOFOLLOW (curate._files,
  and open_regular for the files at its top). A link that a process the
  agent left running swaps in while the stream's environment stays up is
  never followed, and a file gone meanwhile is left out without an error.
- Medium: Codex's refusals for good are read in its own words: a
  provider's error body Codex passes on as it is, "model is not
  supported", and its plan refusals (a workspace out of credits, a spend
  cap, a plan without Codex). The plan refusals end the run, as a 402
  does.
- Medium: the answer agent's relay reads a 429 for a spent quota
  (OpenAI's insufficient_quota, as its code or its type) as the bill's
  refusal, which ends the run, not as an outage that runs again.
- Low:
  - A relayed Codex session that main's reader leaves a 502 but whose
    stream says it was refused for good is a 400 with Codex's words.
  - The disk gate's verdict names the room for the task's image and for
    other trials' pulls, and a stream's first step keeps room for its
    image until its environment is up.
  - A step waits for its turn over the earlier steps' own budgets.
  - Refused at startup: a benchmark file's {cli} model without a login,
    which the runner cannot bind, and a login in acting_agent.settings.
  - A relative mini-swe-agent settings.config is read beside the params,
    as the runner's other paths are.
  - The texts on the line reader, the secret-name rules and their
    tradeoff, the time a kill takes at exit, the answer agent's effort,
    and a Harbor Claude session's token (on a descriptor).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Dual review: OfficeQA's task builder, keyless backends, a run's spend and stop

- build_tasks.py imports task_text from utils/task.py (the module it named is gone)
- Claude Code on a backend that needs no key gets its placeholder token
- the answer agent's Codex model has web_search off unless given
- a row without an instruction gets Harbor's instruction for its context
- a benchmark's patch is loaded without writing __pycache__ beside it
- a launch's plans folder is the user's only (0700)
- curate opens a reward file and hermit-copy/memory without following links
- an answer trial whose agent sent no request costs 0, not unknown
- a spent quota ends the run even when the agent's time ran out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Haizhong Zheng <hzzheng@umich.edu>
haizhongzheng added a commit that referenced this pull request Nov 18, 2026
…hods (#106)

* Shared layers: a Harbor trial of any CLI is deployed, bound and read as Hermit's own sessions are

What the Harbor runner needs of the layers every method shares, so that a trial in a task's container is one more
session of the CLI's Base Agent:

- The hosts deploy for a caller that serves the adapter's tools itself (`--no-serve-tools` on every host; Pi's and
  dsh's `prepare(serve_tools=False)` names no server, and the acting agents' workspace now passes the flag on, so a
  container session of Hermit's own runs gets no server row it cannot start) and take one task's context
  (`--context-file`).
- Every CLI Base Agent reads a stream its caller read elsewhere: `outcome()` with no stream file reads the stream's
  text as it reads the file, the reply included; a missing or empty stream is a session not served, never a TypeError.
- A Codex session whose sign-in or key the provider refused is `login_failed` (the run stops) if its turn did not
  complete, read from its own notices: never one it recovered from, what its log quotes of the session's tool calls,
  or an event's text (U+0085, U+2028 and U+2029 end no line of a stream); `unavailable` comes from its last failure.
  Codex's records are read with span prefixes too (`RUST_LOG=codex_core=info`).
- hermit.agent.base.trajectory, the AHE Debugger, Harness²'s bench, RRSI's render and SkillOpt's Codex trace read a
  Harbor trial of any CLI (`agent/agent-<backend>.jsonl`, then Harbor's own output files, then its ATIF trajectory,
  which the Debugger takes before those files), and AHE's texts (EVOLVER.md's too) name that trial's files (the
  stream, hook audit and state under agent/; the record's instruction, as the Debugger's `task0i.md`; START.md's
  tree). Harness²'s bench takes a Claude Code trial's final message as the Base Agent reads its reply. MWM counts a
  learner session's turns and actions from the events the common reader reads (a line of the CLI's own that is no
  JSON object, or an event holding U+2028, no longer fails the step) and finds a task's record by the material's own
  file name.
- A Harbor acting agent's model is bound and checked in the acting CLI's dialect (`agent (harbor, <cli>)`, an
  endpoint's too), the whole Binding spec kept, developer_role included, and its login is a contained session's
  (logins_of) unless `claude_bin` names this machine's Claude Code, whose version is then checked; the task set's
  benchmark file counts for both, as the runner merges it (relative to `normalize_config`'s `base`, else the working
  directory). hermit.harbor.clis is the table of those CLIs.
- A client of a CLI's chat endpoint counts what a session that failed or that the provider refused used, which the
  endpoint reports in its error body (ChatClient's `count_error_usage`, set by `endpoint_spec`).

tests/selection.py counts the recorded OpenCode and dsh streams as shared: the methods' tests read them too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Core: infra runs, configs for hermit eval alone, and a multi-step task's steps in order

What a Harbor task set needs of the framework's own commands and configuration. There is no new way to run: training
is `hermit train`, testing is `hermit eval --adapter ...`, each set by the run's YAML and overrides as before.

- A run that is not the agent's result (`RunOutput.extra["unscored"]`: a Harbor trial of status infra) has status
  `infra`: never judged, its score null in steps.jsonl, left out of the Trainer's and `hermit eval`'s means and
  counted (`unscored`, in the summaries, the learning material and the card). `eval.infra_retries` and
  `eval.infra_wait_s` make `hermit eval` run such rows again, except a multi-step task's step rows, a task Harbor runs
  for none of Hermit's agents (`unsupported_task`) and any after a halt (a lost login, a usage limit).
- `hermit eval` needs only what it reads (`data.tasks`, `data.test`, the agent, the judge): a config with no
  `data.train`, such as a baseline's, needs no template or Evolver; `hermit check` checks it as `eval` runs it (its
  probe on a test row), `hermit train` refuses it, and its run name is the config file's when `trainer.run_name` gives
  none. An adapter of the run's tree (`final`, `root`, a tag, a commit) needs that tree: without one, `eval` refuses it
  before any run. The `eval` section is checked where an eval runs.
- With `eval.repeats` above 1, each repeat hands the pipeline copies of its rows that name it (`repeat`), so that a
  pipeline that keeps its trials by row (Harbor's trial cache) runs each repeat anew; results.jsonl names the repeat.
  With `trainer.epochs` above 1 each epoch's rows name the epoch (`epoch`), and the rows `run_agent` runs, and those of
  a task the epoch's order names twice, ask for a new run (`fresh`): such a pipeline runs each anew, an epoch on an
  adapter the one before left unchanged included, where it would have handed back the earlier trial.
- A multi-step Harbor task's steps run in order in its stream: `data.shuffle` moves its rows as one; a split whose
  order is kept (the train split with `data.shuffle: false`, the test split, the validation split) that lists a step
  ahead of an earlier one, or without every earlier one, is refused before any run, and `hermit check` reports it;
  `next_tasks` may name a step only after the earlier ones; `run_agent` runs no training row that is such a step, and
  an id it does not run comes back as an error result (score 0), no longer an exception; Harness² fails such a step
  before any editor session, and records an infra execution's cause beside its null score. A run runs each step of a
  stream once, in one environment: a train split with such steps trains one epoch (`hermit train` refuses more, and
  `hermit check` reports it). `hermit check` checks the test split's order for a training config too, and its probe
  runs no later step.
- The Harbor task set's tasks and jobs directories, and an eval config's tree, are run secrets. The Harbor agent is
  told what its streams are named for (`run_identity`: a training run's record directory and the id it keeps there,
  any other pipeline its own), whether they are kept for a resume (`keep_streams`: the Trainer's pipeline only, until
  the run finishes), the run its trials are kept to (`trial_scope`: the Trainer's pipeline only, that identity),
  whether the run deploys adapters, and the CLI and login of a model only a CLI reaches; `hermit check`'s probe takes
  no trial from the trial cache.
- An acting agent of Harbor's own takes no adapter: `hermit train` refuses it, `hermit eval` runs it with
  `--adapter none` only, and `hermit check` reports it for a training config.

tests/core/test_harbor_core.py covers these. What this commit hands the Harbor agent, the next commit's runner takes:
three of these tests (Harbor's `dataset prepare`, and a pipeline closing its HarborAgent with its streams) pass from
there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Harbor: every CLI in the task's container from one launch plan, with the adapter's tools, context and notes

A Harbor trial ran only Codex well (and Claude Code through code of its own); the adapter's tools, a per-task context
and an adapter's notes never reached the container, and infra trials counted as zeros. Now:

- One HermitXXX class per CLI (hermit.harbor.clis: codex, claude, pi, opencode, dsh, mini-swe-agent) over one executor
  (harborside/hermit.py). Hermit's side renders each trial's session with the CLI's own Base Agent
  (hermit.harbor.launch: the home, the command, the environment; host paths made the container's) against the adapter
  deployed as `hermit deploy` lays it out, and harborside uploads and runs it as the task's agent user: the prompt on
  stdin, the stream in agent/agent-<backend>.jsonl, the deployment record always there (so an adapter's hooks run on
  Codex too, HERMIT_HOOK_LOGS set), a session still running at Harbor's timeout killed with its process group. The
  steps after the session still run past that timeout, and keep the session's own error when the timeout lands in
  them; a copy that failed is dropped, never kept in part. A `<cli>_bin` serves only at the asked-for version and when
  the agent user may execute it. The runner reads the stream back with the same Base Agent: reply, served, the plan's
  or the provider's refusal, the usage at `agent.params.price`, else at the backend's price.
- The adapter's tools are served from this machine on the Docker bridge's gateway (hermit.harbor.tools, every call
  logged); a per-task context is computed in the adapter sandbox (hermit.harbor.context); an adapter's notes come back
  after the session (memory/ in the log).
- A key or a token reaches the container by its variable's name only (`docker compose exec -e NAME`; Claude Code's
  subscription token on a descriptor), never in a command line, a file, the plan or a log; Codex's ChatGPT sign-in is
  a file of its home there (mode 600). Codex and Claude Code run on the user's subscription
  (`login: chatgpt | claude`) in the plan's slots and holds, each trial noting the plan's usage (so `MAX_USED` holds
  trials back): a refused session again after the window, one the provider could not serve after a pause unless it
  ran out of the agent's time, a lost sign-in never, none once another trial halted the run; the trial's usage is
  every run's. Codex's refreshed sign-in comes back and becomes the shared copy. A task whose agent network is not
  public gets the model's and tools' hosts allowlisted and web search off; `web_search` must be set.
- The answer-only agent (`cli: answer`) makes one model call through an endpoint the runner serves and writes the
  answer into the container (LAB-Bench's questions); a request still in flight when the trial ends is given up, its
  cost unknown, and on a model a CLI reaches on a login the trial waits for that plan first (a request the plan held
  past the agent's time is infra, `usage_limit`). A question or attachments it cannot read fail the launch.
- The judge scores the verifier's reward whenever the verifier gave one, a timeout or an agent error included
  (Harbor's own mean), says "passed" at `pass_reward` (null for a score scale) and leaves out what `verifier_redact`
  matches. Not the agent's result, so unscored (infra): a verifier whose tools never downloaded or that hit a full
  disk, harborside's launch failing (HermitLaunchError, the CLI's install included), a session that never started or
  whose tools never came up, a lost sign-in, a Claude Code, Pi or OpenCode session or an answer request the provider
  refused for the run's configuration before serving any (its key, model, bill or a setting it does not take:
  `model_rejected`, no halt), a task Harbor runs for none of Hermit's agents (MCP servers, a skills folder, a Windows
  container: `unsupported_task`, never handed to Harbor; the set's other tasks run). A trial out of the agent's time
  is the agent's even after a provider notice, and so is a request refused for its input; the adapter's context over
  the CLI's limit beside the image's own is the adapter's 0, and so is a session the model's safeguards ended. With
  `verifier_timeout: agent` (a verifier that times the agent's solution, as AlgoTune's does) a verifier out of its
  time is the agent's result, and Continual Harness's Refiner reads it as that, not as a session past its clock.
- Startup refuses what every trial would: a login for another CLI, a login and a binding at once, a loopback model, a
  missing key or sign-in, a non-Docker environment for secrets by name, a plan the Base Agent cannot render
  (mini-swe-agent's: web search, a model class Hermit does not read), a `harbor` that is no executable file,
  mini-swe-agent without its package for a run that deploys adapters, the answer agent's attachments on a model a CLI
  reaches. Harbor's own claude-code gets a bound model's Messages API root (it was sent to /v1/v1/messages), keeps
  Harbor's per-task web rule unless `web_search` is false, and is refused the subscription (`CLAUDE_FORCE_OAUTH`, or
  the subscription's token as its only sign-in).
- `python -m hermit.harbor.dataset prepare` makes an example's data from its benchmark file's `dataset:` block (the
  registry's tasks, rows, splits, smoke rows, a patch, the images' sizes with `image_sizes: true`, a lock). A download
  is moved into place only once whole, and what is in its way is refused first; a relative `data:` is the benchmark
  file's folder's. The lock and the download record the tasks' source (a download of another source is never reused,
  and the default data directory is the source's own); the lock holds no path of this machine and hashes only a mode's
  executable bit (one written under a umask other than 022 needs writing again); an unreadable lock is refused unless
  `--force`.
- Also, from the Terminal-Bench 2.1 runs: a host failure (Docker's, the host's /tmp full) is infra and no trial starts
  while /tmp is short; the trial of a task whose name is longer than 32 characters is found; a `harbor run` past its
  wait budget is killed and its trial's compose projects, the verifier's too, taken down by name alone (no compose
  file or `COMPOSE_*` variable read). A stream's step runs its own plan, its verifier read as a trial's; each `hermit
  eval` repeat and each run gets streams of its own, stopped when the run ends unless a `hermit train` may resume
  them. The trial cache keys the launch, the whole row, the task's files, the model's price and the adapter as
  deployed (a file's executable bit, not the bits a umask sets; not the adapter's card, which no deployment copies, so
  a final adapter tested again meets its trials); a cached trial costs nothing again; a training run's trials are its
  own (only the run, resumed, meets them) and each epoch's too, a row asking for a new run (run_agent's, a task a
  split names twice) is neither taken nor kept, and `hermit check`'s probe neither takes one nor keeps one. The
  benchmark file's price applies to its own model, and a model the config gives as an endpoint mapping keeps its own
  price.
- OfficeQA's Harbor judge reads the final message from HermitCodex's stream (`agent-codex.jsonl`): a task set built
  before needs building again.
- Docs and CHANGELOG for the whole change (the framework's task, configuration and command pages; the methods' pages;
  the Breaking entries: the runner's `codex_login` is gone, `login: chatgpt`; a table CLI's trial needs `web_search`;
  secrets by name run on local Docker only).

Checked in real containers on this machine, each run a `hermit eval` of a config for it alone: Codex on the ChatGPT
login (no adapter; tasks with an open and a closed network; the adapter's MCP tool, AHE's hooks, Continual Harness's
notes, ASPIRE's template) and Claude Code on a subscription token (an instruction that begins with `/`, the MCP tool,
AHE's hooks); Pi, OpenCode, dsh and mini-swe-agent on a scripted model; the answer agent; a three-step stream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audits of 2d9401c and 3aa0cc2

The post-PR audit of this PR's 2d9401c found one high issue and six medium ones, and the audit of #106's 3aa0cc2 one
medium issue in this PR's code; each is fixed here, and so are five of the low ones.

- Claude Code on Anthropic's own API with a key (`acting_agent: {cli: claude}`, `anthropic/<model>`, no login)
  started every session without a token: the launch script exported the plan's empty ANTHROPIC_API_KEY before
  ANTHROPIC_AUTH_TOKEN read the key from it. A variable the plan passes under another name is now set first, in one
  export that reads every source as Harbor passed it; a source no entry sets is unset, and the plan's own variables
  come after.
- A Harbor halt (a lost sign-in, an API account's usage limit) ends `hermit train` unfinished at the step that met it,
  before its learner (after the learner's call when a run of `run_agent`'s met it), and a resume runs that step again:
  before, every later rollout came back infra/halted while the learner went on, and the run ended as finished.
- Whether the provider could not serve a Codex session is read from its last failure since the session last worked,
  never from a warning of Codex's (the trust it gives a deployment's hooks), and a turn that failed, or a stream that
  ended, while Codex retried its requests is one it could not serve, unless the sign-in was lost: Codex 0.164 that
  cannot reach chatgpt.com fails its turn with `workspace routing discovery failed`, which the last-failure rule had
  made the agent's empty answer. Codex 0.164's own words for a lost sign-in are matched.
- A ChatGPT sign-in a session hands back replaces the shared copy only as a later, well-formed refresh: a regular file
  of at most 64 KiB (a container's larger one is never downloaded) holding its refresh and access tokens, for the
  copy's account, stamped after the copy and at most a minute ahead of this machine's clock (an hour where the clock
  may differ). Harbor no longer gets CODEX_FORCE_AUTH_JSON or CODEX_AUTH_JSON_PATH from the user's environment.
- Only a pipeline that keeps its trials by row (a Harbor task set with `trial_cache` on, in the config or its benchmark
  file: isolate.keeps_trials) is handed rows naming their epoch or asking for a new run; no record keeps `epoch` or
  `fresh` (rollout.TRIAL_KEYS), so the learning material's `input` and every learner's text of a task are the same in
  each epoch, and the adapter's per-task context gets the task's own row.
- A Harbor trial is scored as Harbor grades it: a verifier that left no reward Harbor could read or ran out of its time
  (`verifier_timeout: agent`, now the default; `infra` the opt-in for a host whose load makes verifiers time out), and
  a request of one of Harbor's own agents that the provider refused for what it held, are the agent's result, 0
  without a reward, unless the verifier's output shows its tools never arrived or the host's disk full; a provider
  that could not serve, or refused the run's configuration, stays infra (Hermit runs it again, where Harbor grades it).
  An OSError on this machine while the adapter is staged is infra (`staging_failed`); the adapter's own deployment or
  per-task context failing stays the agent's 0, since what its child process prints could be the adapter's words. A
  verdict that quotes the verifier's output applies `verifier_redact`.
- `dataset prepare`: a patched set is its patch's own. The download record names the patch (its hook and its file's
  digest), a reuse of another source's or another patch's tasks is refused before the patch runs, the default data
  directory is named by the patch too (an unpatched set's name as before), and a download is patched in its own
  folder before it is moved into place.
- The AHE Adapter's learners' clocks (`evolve_timeout_s`, the Agent Debugger's `timeout_s`) are the Base Agent's own,
  counted from the CLI's start: a wait for the login's plan or a session slot pauses them instead of spending them (a
  hold longer than a clock made the step a no-op recorded as done, or the Debugger's analyses upstream's fallback
  text). This reverses PR #65's choice that the Debugger's clock cover the plan wait: upstream's clocks had no plan
  hold to cover. `trainer.call_timeout_min` still bounds a step, waits included.
- `hermit train`'s refusal of more than one epoch over a multi-step task's steps gives its true reason.

Tests: test_harbor_harborside.py (every CLI's launch script on every backend run by bash, the returned files' limits),
test_harbor_runner.py (grading as Harbor does, staging, redaction, the sign-in back by the environment's clock,
Harbor's environment, a Codex outage), test_harbor_core.py (the rows only a trial cache is handed, the records, a
halt), test_harbor_dataset.py (patched sets), test_cli_agent.py and test_base_agents.py (Codex's outcome and lost
sign-in words, the take-back), tests/methods/ahe (both clocks through a real login path).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audit of fe8c5b4

The post-PR audit of this PR's fe8c5b4 found two medium issues and eleven low ones; each is fixed here.

- A step of a multi-step task whose turn cannot come ends infra (stream_order) at once and starts no driver: its
  stream's driver waits for a step no rollout of the runner is running (one that ended before it reached the driver,
  or ran in an earlier training step), or the stream has no driver and no rollout of its first step is running to
  start one. Every later step of the stream ends the same way, and the last of them stops the driver. Before, each
  waited out its turn (by default its budget for each earlier step and an hour more), holding a rollout's worker, then
  ended infra, so a step that failed on this machine before it reached the driver, a halt (whose resume reran a later
  step on a new driver at step 1) or a driver gone lost the rest of the stream after hours. The runner keeps each
  stream's steps in flight; StreamClient.wait_turn takes what it asks.
- `trial_cache` with an answer agent on a model a CLI reaches (`model: {cli, model, login}`): the trial's key held the
  URL of the endpoint the run's pipeline serves the model on (its port and token, and the binding's `messages_url`
  derived from it), which no resumed run or other eval has again, so no trial was ever taken from the cache. The key
  names that model by its CLI and login.
- A new stream driver in a directory that held one sets the earlier one's trial and replies aside (`earlier/<n>/`):
  Harbor reuses a trial's step directories, so a step of a stream run again that left no output of its own was read,
  and billed, as the earlier run's.
- A stream driver that answers no stop within 15 minutes (hung in a step) is killed with its process group, and its
  trial's compose projects are taken down by name.
- An OSError on this machine while a trial's job and launch are written (its job directory, the launch plan, the
  agent's config, job.yaml), or a stream step's launch plan, is infra (`staging_failed`), as one while the adapter is
  staged is: before, it raised out of the rollout, the agent's 0.
- A rollout that never reached a container (a halted run's, the disk gate's, an unsupported task's, a staging that
  failed, a stream step its driver was never asked for) costs 0: before, its cost was unknown, which left the eval's
  total cost unknown. A stream step lost after its request was sent keeps an unknown cost.
- The ChatGPT sign-in's take-back reads the shared copy's own stamp as any accepted copy may hold it (at most an hour
  ahead of this machine's clock, as one from the user's own file), never as no stamp: an earlier file a session
  handed back replaced a copy stamped ahead of this clock.
- Codex's fall back from WebSockets to HTTPS retries nothing, so a request refused after it is the session's own
  failure; only its reconnects (`Reconnecting...`) are retries.
- `hermit eval` of a split that names a task twice keeps a row for each, as on main (the infra reruns kept the records
  by id).
- `<jobs_dir>/HALT` names the record's cause first (`login_failed`, `usage_limit`) and says that it halts every run on
  that jobs directory, as the docs now do.
- The docs: a sign-in file is checked for its size before it is downloaded (one grown after the check is refused when
  taken back); with Harbor's retry on, a failed attempt's usage is not counted; what `staging_failed` covers. The
  CHANGELOG's Harbor entry is rewrapped where earlier edits had cut its lines short.

Tests: test_harbor_runner.py (a stream's lost turns, at once and in order, a halt's resume, a rerun's outputs, a hung
driver, a stream step's launch, a lost step's cost, the CLI model's trial key, a trial's staging, a never-ran
rollout's cost, the halt file), test_harbor_core.py (a split that names a task twice), test_cli_agent.py (a copy
stamped ahead of this clock), test_base_agents.py (Codex's fall back).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audit of 3a49adc

The post-PR audit of this PR's 3a49adc found three medium issues and fifteen low ones; each is fixed here or, where
it is a limit of the design, recorded in the PR.

- `trial_cache` with a model a CLI reaches: 3a49adc named that model by its CLI and login alone, so a second eval on
  the same jobs directory whose CLI had another effort, `bin` or version met the first one's trials. The key also
  holds the CLI's identity (`hermit.agent.base.endpoint.cli_identity`: its settings as its sessions get them, less
  where they run and log and which plan they wait for, and its binary's path, size and time of change), as a digest
  that hermit.isolate.agent_pipeline hands the runner (`model_cli_identity`). Harbor's `retry`, the adapter
  sandbox's `sandbox_enforce` and `tools_host` are in the key too.
- A trial whose agent ran out of its time or exited with an error is verified by Harbor and graded: when its
  verifier's tools then never arrived (a 5xx of GitHub's release download) or met the host's full disk, it is infra
  and run again, as one whose agent finished is. Before, it was the agent's 0 and stayed in the trial cache.
- Codex's words for a refresh of the ChatGPT sign-in the provider refused ("Your access token could not be refreshed
  [because your refresh token was already used / has expired / was revoked]. Please log out and sign in again.")
  are a lost sign-in: the run halts. Before, the trial kept Harbor's verdict, scored 0 and cached. A sign-in refusal
  counts only since the session last worked: one on a side request the session worked after is none.
- `run_tasks` submits each multi-step task's steps in step order, in the places its steps had: a `run_agent` call
  that listed a later step first, with fewer workers than the gap, gave the stream up and lost the earlier step too.
- A step whose stream aborted before its turn is never asked for (`wait_turn` checks the abort first), so it costs 0;
  and a trial whose environment or agent setup failed before its agent started (Harbor records no
  `agent_execution`) costs 0. Both had an unknown cost, which left the eval's total cost unknown.
- An OSError on this machine past the guarded steps (no process left to start `harbor`, a file it cannot write or
  read) is infra (`host_failed`), its cost unknown, not the agent's error scored 0. A trial cache this machine cannot
  write leaves the trial as it ended (it stands, uncached), an entry it cannot read is no trial kept, a key whose dry
  render cannot be written runs the trial without the cache, a sign-in take-back that fails leaves the trial as it
  ended, and a HALT file it cannot write leaves the halt to the rollout's output.
- A stream step run again sets the tool-call log an earlier run of it left aside (`earlier-<n>-tool-calls.jsonl`) at
  its turn, so its curated log holds its own calls only.
- A killed stream driver's socket is removed.
- Only a Harbor task set's rows name their repeat (`repeat`, with `eval.repeats` above 1), and no record's `input`
  keeps it; a record's `input` drops only the keys its caller added (the Trainer's `epoch` and `fresh`), so a row's
  own field of those names stays. Every other pipeline gets its rows and records as on main, and a Harbor adapter's
  per-task context never reads `repeat`.
- A failed `hermit eval` removes the earlier eval's `summary.json`, as it empties `results.jsonl`.
- The overlap error of a declared path names a Harbor task set's directories as such.
- The docs: `solved_once` counts each test id once; the steps of `run_agent`'s call run in step order; the cost of a
  trial that never started an agent; `host_failed`; the Codex refresh refusal and what to do about it; a copy stamped
  ahead by another clock is replaced once this clock passes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audits of e7ace26 and b709e0c

The post-PR audit of this PR's e7ace26 found no high or medium issue and eleven groups of low ones; the audit of the
benchmarks PR stacked on it (b709e0c) found a medium issue here and a low one. Each is fixed here or, where it is a
limit of the design, recorded in the PR.

- `python -m pytest` imported the files of a run's folder beside an example's configs (`examples/*/runs`, their
  output_dir), a task container's and a learner's files among them, and ran them on this machine outside any
  sandbox: the root conftest ignores them, as it ignores a Harbor task set's.
- A pipeline that deploys adapters is refused at startup where bubblewrap is not installed and the adapter sandbox
  that renders each adapter is required (`agent.params.sandbox_enforce`): each trial ended in the sandbox's error,
  scored 0.
- A rollout that met a halt (a lost sign-in, an account's limit) and then an OSError of this machine (its curated log
  not written: a full disk) came back `host_failed` with no halt, so that nothing halted where its HALT file could
  not be written either: it keeps the halting verdict. A jobs directory this machine cannot make is `host_failed` at
  a cost of 0, not an error scored 0.
- A stream step whose turn never came curated the tool-call log an earlier run of it left as its own: it curates none.
- A verifier's words of a full disk (ENOSPC) made a trial infra even after its tests ran: now only before its tests
  wrote a report (`ctrf.json`), so that a test's own output (an agent's program, a task about a full disk) stays the
  agent's result.
- The copy-back and the collect ran as root in /logs/agent, which every user can write in, through a link the agent's
  user could put there, and made what it named readable to all: each makes a new folder of root's, enters it, checks
  that it is that folder, and works in it by relative names.
- `acting_agent.env` is written into each trial's job and onto `docker compose exec`'s command line: a variable of a
  secret's name, or a value naming one, is refused at startup.
- The `tasks` link is followed once (`tasks_dir`), so that a prepare pointing it elsewhere mid-run changes neither a
  trial's task set nor the key it is kept under; a task's link to a folder is in its digest by where it points.
- A codex, claude or pi trial of a model a CLI reaches got the loopback refusal once the pipeline served that model:
  it is refused for what it is.
- A row of its own `epoch`, `fresh` or `repeat` field is refused where the framework adds those keys (hermit train
  with the trial cache, hermit eval's repeats of a Harbor task set; hermit check says so too): they would replace it,
  and no record would keep it.
- `dataset prepare`: a data directory that is the set's own folder in another download is that download's (its
  marker is beside it), refused to a benchmark of another patch; a download is marked in its own folder before the
  set is moved into place; an image whose size cannot be read anew keeps the earlier one; split counts are whole
  numbers, and a smoke task is named once; the rows, the lock, the splits and the sizes are all made before any is
  written, so that a refusal leaves the link and every file as they were; a `data` naming a variable that is not set
  is refused; this machine's errors (an OSError, Harbor's failed download) are the command's `error:`, exit 1.
- An ATIF trajectory's tool-call id that is no string (a list, an object) reads as no id, never a TypeError in each
  learner reading the log.
- Tests: a trial-cache key this machine cannot make, a sign-in take-back that fails, MWM's name of a task's record.
- The docs: a command a CLI ran in a session of its own (Claude Code's shell tool) is outside the process group the
  kill reaches; a `timeout` or an `agent_error` scores 0 when its verifier left no reward.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the post-PR audit of b9a3d61

The post-PR audit of this PR's b9a3d61 found no high or medium issue and four groups of low ones. Each is fixed
here; its questions are recorded in the PR.

- A `hermit eval` refused at its start (a row of its own reserved key, or a pipeline whose startup checks refuse it:
  no bubblewrap, a secret in its env) had already emptied the earlier eval's results.jsonl and removed its
  summary.json: the eval empties them once its pipeline and judge are built, as on `main`, and a refused start leaves
  them as they were. One that fails after its start still leaves no earlier summary.
- `acting_agent.env`'s secrets are read as Harbor fills its values: `${NAME:-default}`, which Harbor fills in from
  this process's environment, is refused like `${NAME}` (it got through), and a referenced name is a secret's by the
  rule the variable's own name is (`launch.SECRET_VAR`), so that a setting named like one
  (`${TOKENIZERS_PARALLELISM}`) is no longer refused. `$NAME`, which Harbor hands on as that text, is still refused
  where it names a secret, as it never passes the secret the config meant.
- `hermit check` refuses a test row's own `repeat` wherever `hermit eval` of the config would (a training config's
  eval too), by eval's own rule (`_harbor_rows`), and a test now covers it.
- Tests: an unused fixture, a temporary directory outside the test's own `tmp_path`, blank lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Rework: Harbor's needs in hermit/harbor, the agent layers as on main

Everything in hermit/ outside hermit/harbor/ is back at main (e813538):
the three agent layers, the Trainer, hermit eval, hermit check, the
configuration, the sandbox, the methods and the hosts, but one change.
Pi's and dsh's prepare take serve_tools, as the other four hosts
already do, so that a trial gets the adapter's tools from the runner.
hermit/harbor/FRAMEWORK_SUPPORT.md lists where each of Harbor's needs
now lives, and what could later become framework support.

What a Harbor task set now meets:
- A trial that is not the agent's result (infra) runs again in the
  runner (agent.params.infra_retries, 2; infra_wait_s, 300 s). One
  still infra is refused by the judge, so the run records a failed run
  (judge_error): hermit eval counts it among its errors and as 0 in its
  mean. python -m hermit.harbor.report gives pass@1 over the trials
  that are the agent's result.
- A lost sign-in, or an API account's usage limit, raises LoginFailed,
  which ends hermit train and hermit eval as a local session's does.
  There is no HALT file.
- There is no trial cache; agent.params.trial_cache is refused.
- A multi-step task's stream is the runner process's own and is never
  resumed; a split keeps its steps in order (data.shuffle: false).
- A Codex trial's lost sign-in and provider outage are read in
  hermit/harbor/signin.py (the outage by the session's last failure, so
  a reconnect Codex recovered from is no outage).
- The answer agent's model that only a CLI reaches is given in the
  benchmark file; a run config's own is refused at startup.
- A trial's log keeps the CLI's stream, task.md, prompt.txt,
  last_message.txt and the hook files at its top, where the methods
  read a local session's.

Fixes of the last audit (of 418a00d): a stream's step gets the sign-in
at its turn, not when its rollout began; acting_agent.env secrets are
named by Harbor's own rule; each step's allowed hosts reach the driver;
the answer agent waits for its plan's window; a long task name's
verifier containers are found as Harbor names them; a dataset's digest
takes a link as the link itself, not the file it points to.

Tests of the reverted code are back at main; the Harbor tests cover the
new code. Docs and the changelog describe the PR as it is now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: two post-PR audits of the rework

The first audit of the rework (2b2a46b) found no high issue, three medium and six low; a second audit of those fixes
found no high issue, five medium and ten low. Each is fixed here, in hermit/harbor/, its docs and its tests, or
recorded as a candidate where the fix is main's.

- An adapter whose own deployment or per-task context fails in its child process is the agent's result: agent_error
  (adapter_failed), scored 0 with its message as the feedback, which `python -m hermit.harbor.report` counts among the
  scored trials. It left the pipeline as an exception before (status error), outside pass@1.
- A stream's step that ends in any way before its driver is asked for it (its staging, its adapter, its tools, its
  launch plan, the disk gate, its turn's wait running out, its turn's sign-in or tools not readied, an exception of
  any of them) gives the stream up, so its driver is stopped once the stream's rollouts end, that step's own when it
  is the last, and the stream's next pass (an eval's next repeat, a later epoch) starts from its first step in a new
  environment. Before, the driver stayed up for a step that never came: the next pass's first steps ended
  stream_order and its last ran on the environment the pass before had left. A step the driver already ran gives
  nothing up. A later step of a stream with no driver and no rollout of its first step ends before anything is staged
  or served for it.
- A runner's unfinished streams are closed by its finalizer, when the runner is freed and at exit for one still held
  then. Before, a weak set of runners was closed at exit, and a runner freed before then (`hermit check`'s probe,
  `hermit eval` once it returned) left its drivers up for stream.idle_s.
- The docs say what a resumed `hermit train` does to a stream under way (its remaining steps in that epoch end
  stream_order, and the stream starts over at its first step's next rollout), and what an Evolver's run_agent of a
  stream's first step does once the Trainer's pass of it finished: it starts a pass the next epoch inherits.
- A request the provider refused for the run's configuration (model_rejected) is not run again (NO_RETRY), and
  NO_RETRY is tested with runs again allowed; nor is a host failure past the trial's staging (host_failed, whose
  session may have run), which the docs now say. The `halted` cause, which nothing gives any more, is gone.
- Codex: a session the provider refused for the run's configuration or bill (a 400, 402 or 404 Codex does not retry,
  an API account's quota) is model_rejected, as the other CLIs' are, never the agent's 0. Its usage limit is read
  from Codex's own notices, never from what its log quotes of the session's work, and a JSON line its log quotes no
  longer ends the record. A session that failed on its own after a reconnect Codex went on from, or whose response
  the provider's content filter ended, is no outage.
- The answer agent's model a CLI reaches: its sessions run with plan_rerun off, so that a session the plan refused
  comes back at once (infra, run again once the plan allows) instead of waiting for the window inside the agent's
  time and scoring as the agent's timeout; its sign-in is checked at startup; its CLI sessions get main's check that
  the user's own secrets are absent (HOME_SECRETS). The runner refuses a run config's own `{cli}` model for the answer
  agent as written, as `hermit check` hands it, as well as the endpoint spec `hermit eval` and `hermit train` hand it,
  whose test builds it with main's endpoint_spec.
- The docs say that `hermit check` builds the runner and reports its startup refusals, and that every run of
  Hermit's agents needs bubblewrap, a baseline's too (the runner cannot tell a run that deploys no adapter), unless
  sandbox_enforce or HA_ADAPTER_SANDBOX_ENFORCE says best_effort.
- The report says when an eval did not finish: no summary.json beside its rows, one that is not of them (its count of
  trials, of failed runs or its mean score differ), or a last row cut off, which is left out. It reads the summary,
  never the files' times, which a copy changes. The docs say that a stopped eval writes no row of the repeat it
  stopped in.
- A plan refusal's hold gets the run's stop, so that a hold that cannot be written waits no longer than the run. The
  docs record that trials racing on one ChatGPT copy for its refresh end the run: the loser's refusal reads as a lost
  sign-in.
- FRAMEWORK_SUPPORT.md names the four private helpers of main that hermit/harbor/ uses, and more candidates: a
  trial's usage when LoginFailed ends the run, the run's own secrets for the answer agent's sandbox, public names for
  those helpers, rows that say who runs them (run_agent's or the Trainer's), the `login: claude` check of `hermit
  train`, RRSI's halt file. The docs no longer say a trial a lost sign-in ended keeps its runs' usage, and
  bind_agent_params is named right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Review fixes: the tenth post-PR audit

The audit of e19d155 found no high issue, two medium and twelve low, and asked eleven questions. Each is fixed here,
in hermit/harbor/, its docs and its tests, or recorded as a candidate where the fix is main's.

- Pi's and dsh's trials get the backend's developer_role, as Hermit's own sessions do: the spec the config's loading
  keeps drops it (Binding.spec), so the runner takes the backends registry's for a backend it names at the same URL.
  A test compares a trial's provider settings with main's bind_agent_params on Fireworks (developer_role: system).
- `hermit check` and `hermit train` check a Harbor run's acting model as a chat client's, main's rule for an agent it
  does not know: they refuse Claude Code on Anthropic's API, which `hermit eval` runs, and do not check that Codex's
  backend serves the Responses API. The docs say so, and candidate 7 names the cause in main.
- On a login, busy_retries is one count over all of a trial's runs: infra_retries no longer multiplies it (up to 12
  runs by default, where the docs said 4). A plan refusal of the answer agent's model runs the trial again once the
  plan allows, not counted in infra_retries.
- A staging or per-task-context child that failed is the host's failure (staging_failed, run again), not the
  adapter's 0, when this process sees this machine fail any adapter's staging there: a folder it cannot write, less
  than 64 MB free, the strict adapter sandbox not starting. Startup refuses a runner whose bubblewrap cannot start
  that sandbox.
- A trial's launch plan refused for what its adapter is (its tools beside text_only, a dsh server name made of a long
  id) is adapter_failed, scored 0, for a trial and for a stream's step; with no adapter it is still the config's
  error.
- A provider that does not bill the account (a 402, its quota or credit spent) ends the run, as an API account's usage
  limit does. Before, every later trial ended model_rejected.
- acting_agent.settings.env refuses a secret's $NAME inside a value by every rule (AUTH, PASSWD, Harbor's), and a
  secret's value written as it is. `effort: off` gives no effort flag, as on main.
- The answer agent writes answer.json as a new file renamed into place, never through a link the container left
  there. Codex's auth.json is removed from the container once it has been copied back, before a verifier that shares
  the container runs.
- The curated log's top stream is the one the launch plan names. The report adds a note when results.jsonl was
  written after summary.json, as by an eval stopped beside an earlier summary. The runner's finalizer gives each
  driver 2 minutes (CLOSE_STOP_S) before it kills it.
- Tests for each fix above. They also catch four mutations no test caught before: the turn's sign-in copy, the first
  give-up reason, Codex's outage reading, and the report's errors comparison.
- Docs that did not match the code: what `hermit eval` reads of a config made for it alone, the causes never run
  again, only a first step starting a finished stream over, the CLI Evolvers' run_agent, the stream socket's path,
  split files with more than one rollout, Harbor's own usage-limit error, when the `login: claude` warning fires, a
  quoted line in Codex's own form, the relay's sandbox, the deployment record's host paths, and hermit check's probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Rebase onto main: what Hermes Agent is to a Harbor run

Main has gained Hermes Agent as a CLI Base Agent (#107, 616e818) since this PR's base, e813538. In the rebase, each
conflict keeps both sides: #107's Hermes in the docs' lists and tables of CLIs, and this PR's Harbor beside it. A
Harbor trial does not run Hermes: the runner refuses `acting_agent.cli: hermes` at startup, as it refuses any CLI
with no HermitXXX class, which a new test holds. The docs now say so (the acting agent's row in
docs/framework/task.md, the CHANGELOG entry), and FRAMEWORK_SUPPORT.md counts five other hosts that take
`serve_tools`, Hermes's among them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Round-11 audit: a trial's developer_role, a secret's name, which disk gate held

The round-11 audit of a332854 found no high or medium issue; these are its low ones and what its questions found.

- A Pi or dsh trial's developer_role is the backends registry's only for the backend the registry has at the trial's
  URL (launch._with_role): the run config's `backends:` is not the runner's to read, where Hermit's own sessions take
  it. FRAMEWORK_SUPPORT.md (candidate 14), docs/framework/task.md and the changelog said the trial got what Hermit's
  sessions get; they now say where it does not, and a test holds the URL check, on both of the spec's paths.
- acting_agent.settings.env refuses a value given as it is to a variable a word of whose name is a secret's wherever
  the word stands (HF_TOKEN_READ, OPENAI_API_KEY_2, SECRET_ID), not only at the name's end (launch.SECRET_VAR); a word
  that only holds one (GIT_AUTHOR_NAME, TOKENIZERS_PARALLELISM) is no secret. A test now holds Harbor's part of the
  rule for a `$NAME` inside other text ($OAUTH_CLIENT_ID).
- The verdict of a trial, or of a stream's first step, that a disk gate held back names the gate that held it, the
  host's /tmp or Docker's data root; it named the data root whichever held it.
- Tests for what none caught: the answer agent's relay's 402 whatever its words, the stop a runner's close gives each
  driver (CLOSE_STOP_S), a job folder this process cannot write (the host check after a failed staging child).
- docs/framework/task.md says what the questions found: a login's wait for its plan has no bound, a request the plan
  held back at any time makes its timed-out trial infra, a refused session runs again as often as the plan refuses,
  the host check comes after the staging child, and N hung drivers hold a close up N x 2 minutes. The changelog's
  Codex refusal no longer reads as every 400 or 404.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Round-12 audit: a stream's next driver, a curated log's links, refusals for good

The audit of 6a79375 found one high and four medium issues and fifteen
low ones. This fixes the high and medium ones, and fourteen of the low
ones (one is in the PR's description); the last is noted there.

- High: a stream's next pass (an eval's next repeat) could meet the
  driver of the pass before in the half second between its last answer
  and its exit, take it for a live one, and lose the whole pass. The
  driver's record now says it is ending before its last answers
  (harborside.driver._mark_ending); StreamClient.running takes neither
  such a driver nor one killed and not yet reaped, and ensure() waits up
  to 30 s for an earlier driver to exit, then kills it, before it starts
  the next.
- Medium: a step whose own folder this machine cannot make now gives its
  stream up (host_failed), so its driver is stopped and the next pass
  starts anew. Before, the driver waited for that step, and the next
  pass ran its last step on the old environment.
- Medium: a step's curated log walks the agent's folders through open
  directory handles and opens each entry with O_NOFOLLOW (curate._files,
  and open_regular for the files at its top). A link that a process the
  agent left running swaps in while the stream's environment stays up is
  never followed, and a file gone meanwhile is left out without an error.
- Medium: Codex's refusals for good are read in its own words: a
  provider's error body Codex passes on as it is, "model is not
  supported", and its plan refusals (a workspace out of credits, a spend
  cap, a plan without Codex). The plan refusals end the run, as a 402
  does.
- Medium: the answer agent's relay reads a 429 for a spent quota
  (OpenAI's insufficient_quota, as its code or its type) as the bill's
  refusal, which ends the run, not as an outage that runs again.
- Low:
  - A relayed Codex session that main's reader leaves a 502 but whose
    stream says it was refused for good is a 400 with Codex's words.
  - The disk gate's verdict names the room for the task's image and for
    other trials' pulls, and a stream's first step keeps room for its
    image until its environment is up.
  - A step waits for its turn over the earlier steps' own budgets.
  - Refused at startup: a benchmark file's {cli} model without a login,
    which the runner cannot bind, and a login in acting_agent.settings.
  - A relative mini-swe-agent settings.config is read beside the params,
    as the runner's other paths are.
  - The texts on the line reader, the secret-name rules and their
    tradeoff, the time a kill takes at exit, the answer agent's effort,
    and a Harbor Claude session's token (on a descriptor).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Examples: five Harbor benchmarks with baselines and their papers' methods

Terminal-Bench 2.0, SWE-bench Verified, AlgoTune, Terminal-Bench-Science and LAB-Bench FigQA through Harbor, each a
benchmark file (the registry's task set, locked), a baseline per profile (Codex with GPT-5.6-Luna on a ChatGPT login,
Claude Code with Claude Haiku 5.5 on a Claude subscription) and the method whose paper's protocol fits it: the AHE
Adapter on Terminal-Bench 2.0 in the AHE paper's in-sample protocol, trained on each task's rollouts #1 and #2 and
tested on #3 and #4; its final adapter, frozen, on SWE-bench Verified and Terminal-Bench-Science against AHE's seed;
SkillOpt in its paper's protocol on AlgoTune, a trial scored 1 - 1/speedup so that the mean gives AlgoTune's harmonic
mean (a success, by which SkillOpt's analysts and slow update sort the rollouts, a solver faster than the reference),
and on LAB-Bench FigQA, whose download is patched: the published tasks save the shuffle's seed where the agent reads
it, which gives the answer away, and their verifier runs a script the agent can rewrite. LAB-Bench's test questions
whose figure no training question has are listed for a second score from the same trials (utils/figures.py reads an
eval's results).

Every run is the framework's own commands on a config, as on main: a baseline is a config for `hermit eval` alone
(`--adapter none`, or an adapter directory: a transfer's, or AHE's seed as the template's directory), whose training
keys are placeholders (its Evolver, `eval-only`, one that `hermit train` does not find); a method is `hermit train`
and then `hermit eval --adapter final` (and `--adapter root` for its seed or empty skill where no baseline tests it, an
adapter of the same run's tree); a whole benchmark's test is an override of the same config
(`data.test=../utils/splits/all.txt` with its own run name). An eval's number is the pass@1 that
`python -m hermit.harbor.report` gives over the trials that are the agent's result: #105's runner runs an infra trial
again, then records a failed run, 0 in `hermit eval`'s mean. AlgoTune's harmonic mean and LAB-Bench's second score
read the rows the same way, and say when an eval did not finish. No trial is taken from an earlier run: there is no
trial cache.

SkillOpt's configs give its analysts no Codex trace summary (it describes SkillOpt's own harness). Every learner on a
login waits for the plan's window (`plan_max_wait_s: null`); AHE's learners' clocks count the wait, as on main.
examples/README.md says what a machine needs (bubblewrap for every run, a baseline's too) and lists every run with its
trials, to be handed out; examples/conftest.py keeps `python -m pytest` out of a prepared task set and a run's
`runs/`, and examples/.gitignore keeps the task sets' links out of git; tests/core/test_harbor_examples.py holds the
protocols to the committed files (every learner's wait for the plan among them), loads every config as its command
does (a baseline's refused by `hermit train`) and builds #105's runner from each config's settings, its startup checks
included (this machine's sign-in and bubblewrap stood in for).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcJCJanVqQuJyChDevJNYP

* Dual review: OfficeQA's task builder, keyless backends, a run's spend and stop

- build_tasks.py imports task_text from utils/task.py (the module it named is gone)
- Claude Code on a backend that needs no key gets its placeholder token
- the answer agent's Codex model has web_search off unless given
- a row without an instruction gets Harbor's instruction for its context
- a benchmark's patch is loaded without writing __pycache__ beside it
- a launch's plans folder is the user's only (0700)
- curate opens a reward file and hermit-copy/memory without following links
- an answer trial whose agent sent no request costs 0, not unknown
- a spent quota ends the run even when the agent's time ran out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Haizhong Zheng <hzzheng@umich.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants