Harness refinement — the Harness² method on the hub's own loops¶
Recursive harness refinement (JEV capability three,
tools/dash refine): the hub's harness surface validated as a sensor, one Propose–Probe–Compose step planned and evidenced from real local runs at $0, a human-gated experience library whose lessons reach every later attempt through the context pack, and the incident reflector that turns a week of agent incidents into candidate lessons for it. Decision: ADR 0004.
Why¶
Agent = model + harness (HARNESS.md). The hub holds the model fixed and has improved its harnesses one incident at a time: a standing rule after a failure, a sensor after the third correction. Nothing proposed a harness edit from what an attempt actually did, nothing probed an edit before it shipped, and nothing remembered what an edit changed. Two pieces of 2026 research say how that is done in practice. Harness² (Xu et al., arXiv:2610.14224) refines a harness recursively while the model's weights stay fixed: at the task level, a contrastive Propose–Probe–Compose step; at the harnessing level, a library of adopted harnesses and evidence-supported lessons the next task reads first. Harness Engineering: Anatomy, Architecture, and Evolution of Coding Agents (Barbaste et al., eleven production harnesses read in source) says what a harness surface is made of and which rules it must meet: skills with name and description frontmatter or they are dropped silently, hooks with the shape the runtime dispatches or they never fire, policy as data rather than prose, context files capped and scanned, agent memory behind a human-reviewed inbox, the cheap caps on every loop.
This page is the operator doc for what exists today: the $0 half, built on ADR 0002's step specs and local runner, and the first model-backed stage, the incident reflector (ADR 0004 P1, part one). The Propose–Probe–Compose sessions are P1's next part; like the reflector they run only through the loop runner's executor, and nothing they produce is filed without a person's --apply.
The map¶
Harness² edits eight components around the model. On a Claude Code harness they are these files, and refine surface reads them as one tree:
| Harness² component | On the hub (and every fleet repo's .claude/ kit) |
In context |
|---|---|---|
| c1 system prompt | CLAUDE.md → AGENTS.md, the context-file chain |
always on, capped (harness_refinement.always_on_max_chars) |
| c2 guardrails | .claude/settings.json permissions (allow / deny / ask); for a loop step, its spec's tool grant |
policy as data |
| c3 memory | _data/harness_library/ (the experience library), .claude/memory/ where a repo keeps one |
read back through the context pack |
| c4 tool guidance | .github/instructions/*.instructions.md |
read in place by skills |
| c5 subagents | .claude/agents/<name>.md |
their own context, return text |
| c6 skills | .claude/skills/<name>/SKILL.md, .claude/commands/<name>.md |
name and description advertised, body on demand |
| c7 scripts | .claude/hooks/*.py, the tools/ a component names |
run on demand |
| c8 plugins | the hooks block of .claude/settings.json, .mcp.json |
act inside the tool loop |
For a loop's agent the harness has two halves. The hard rules (the step spec's prompt, grant, model, turns and dollars; tools/jev/steps/) are gated config under constitution § 12.3: no agent edits them, and a refinement that needs one writes a proposal a person reviews. The tunable half (the brief template and the category emphasis in .github/scout/ and .github/evolution/) is what a candidate may edit. The deliverable's shape belongs to the loop's filer, never to a candidate.
The surface check: a sensor over the harness¶
tools/dash refine surface check # the hub's own surface; exit 1 on an error
tools/dash refine surface check projects/README --json
tools/dash refine surface census # the eight-component inventory
tools/dash refine surface diff BEFORE AFTER
The check reads a repository's surface and fails on what both sources say breaks a harness: an always-on chain over its cap, an empty one, a skill whose frontmatter is not YAML or has no description or whose name is not its directory, a subagent with no description, a hooks block with an unknown event, a non-list entry, an empty command or a $CLAUDE_PROJECT_DIR/<script> that does not exist, a settings or MCP file that is not JSON, and a script a context file, skill, command or agent names (tools/x.py, .claude/hooks/x.py) that is not in the repository. It warns on an always-on chain past 80% of the cap, a skill body past the runtime's per-skill load (skill_max_chars), a command with no description and prompt-injection phrasing in a file the agent reads as instructions, and it notes which skills no always-on line names (optional under deferred loading: the runtime advertises every skill's name and description). tools/test_jev_surface.py holds the hub's own surface clean; its first run found the run-dash skill's frontmatter invalid (an unquoted Triggers: colon) and that was fixed in the same change, which is the ratchet in HARNESS.md working as designed.
The experience library¶
_data/harness_library/<loop>/<domain>/<entry>/experience.yml (_data/harness_library/README.md) holds, per adopted refinement, the cue (the shape of situation the lesson fires on, one line), the lesson (an operation on a harness, naming its component), the evidence (the edit rows and the execution contrast), a confidence, the per-edit verdicts (helped, hurt, no observed effect, confounded), and the adopted edits as harness.diff. <loop> is the workflow stem and <domain> the item's registry category, the grouping the category emphasis already uses.
An entry lands only on a branch and reaches main by a reviewed pull request: refine library add … is the $0 reflector a person runs after reading a run's record; the incident reflector proposes entries from a week of incidents, and a person files its preview as a draft PR. refine library check holds every entry to its schema, its field caps and the context pack's redaction, so a local path, a host name, an address or a credential shape can never be committed. The library reaches an agent two ways: the context pack's library section (JEV.md) puts the domain's newest lessons beside the brief of every local attempt, as data to re-verify and never as a rule; and refine evidence copies the whole library of the domain into the tree a proposer reads.
tools/dash refine library list [--loop repo-scout] [--domain dev-tools]
tools/dash refine library index --loop repo-scout --domain dev-tools # the INDEX.md a proposer browses
tools/dash refine library check
tools/dash refine library add --loop repo-scout --step scout --domain dev-tools --item bamr87/SCHEMA \
--run <run_id> --adopted base1 --confidence medium --cue "…" --lesson "…" --evidence "…" \
[--diff harness.diff] [--edit "component|labels|change|observed|verdict"]
The incident reflector¶
tools/dash refine reflect --rehearse # the evidence and the exact ai-run argv, stopped before the model ($0)
tools/dash refine reflect # ONE capped session: candidate lessons, validated, PREVIEW.md (spends, files nothing)
tools/dash refine reflect show latest # the newest preview
tools/dash refine reflect publish <stamp> # what a filing would do ($0)
tools/dash refine reflect publish <stamp> --apply # file exactly the previewed bytes as a draft PR
tools/dash refine reflect doctor [--live --yes] # the $0 isolation probe for its posture; --live the ≤ $0.10 read-fence canary
The lake's review (tools/dash-gen lake review) says what went wrong in the agents' week: tool error rates in local Claude Code sessions, permission denials and failed CI agent runs, cost outliers. Nothing turned that into a lesson a loop's next attempt reads. refine reflect (tools/jev/reflect.py, ADR 0004 P1 part one) does, in four steps.
- Gather, $0. An evidence tree under
.fleet/refine/reflect-<stamp>/evidence/(gitignored):lake review --days <reflect.days> --json, the trip wires and scorecard of_data/harness_health.yml, the local loop runs of the window (.fleet/runs: each item's decision, outcome, cost, reason and flags, and the cached probe and canary verdicts), the conflict engine's resolutions (context only, since the conflict engine reads no library), every entry the library already holds, and the loop steps and registry domains a lesson may name. Every file passes through the context pack's redaction, and the rendered mission (reflect-incidents.prompt.txt) sits beside it.--lake DIRand--runs-from DIRread another checkout's data. - One session.
tools/dash-gen ai-run --isolateunder the loop runner's § 13.8 posture, with Read, Glob and Grep and nothing else (no Bash, no Write),harness_refinement.model,max_turns, astage_usdcap and thereflect.timeout_minuteswall clock. Its working directory is a copy of the evidence under the work root, never the hub, destroyed afterwards. It needsharness_refinement.enabled, a passing isolation probe and read-fence canary for its posture (refine reflect doctor), and room inbudget.loops, judged under the loop runner's budget lock; its ledger row carriesorigin: localandloop: harness-refinement, so it spends inside the same month as every loop attempt, labelled API-equivalent (estimate). The session cannot write a file: its final message is one JSON document of at mostreflect.max_entriescandidates (loop,step,domain,item,cue,lesson,evidence,confidence,source_ref), which the engine saves asproposals.json. - The engine validates. Each candidate is dropped, with every reason, when it is past the cap, is not the right shape, names a loop and step with no step spec, a domain that is not a registry category or
unknown, fails the entry schema (library.Entry.problems), carries anything the leak check refuses, or repeats the cue of an existing entry of the same loop (or of an earlier candidate) closely enough to be the same lesson. What survives becomes an entry withsource: reflector,adopted: baseand thesource_refin its notes.PREVIEW.mdshows each accepted entry's exactexperience.ymlbytes and every drop;validated.jsonholds the bytes and their hashes. - A person files it.
publish <stamp> --apply(or--applyon the run itself, typed by a person) refuses a dirty engine, claimspublish-result.jsononce, probes the publish token withgh api user, and skips when an open reflector PR exists; then it adds the entries throughlibrary.Library.addin a detached worktree oforigin/main, drops any thatmainlearned since, runs the library check, commits asharness-reflector, pusheschore/harness-reflector-<stamp>and opens a draft PR labelledskip-evidence. It never merges.
A scheduled reflection never files. --scheduled --apply exits 2, and the decision comes from the constitution, not from a flag. § 11.8 refuses the local loop runner's filing under --scheduled until § 13.7 earned autonomy exists, and the reflector's filing is the same kind of write: a branch and a pull request on the hub, from a local tool. § 13.6 starts an external action at high, which waits for Amr's yes, and no action has earned a lower tier. § 13.8 settles it on its own: the reflector reads private data (this machine's session transcripts, the prompts a person typed) and untrusted content (CI logs and issue text in the lake), and a pull request on a public repository is an external send, so the send always needs a human gate. A scheduled run therefore stops at the preview and posts a macOS notification (osascript; JEV_NOTIFY=0 turns it off) saying how many lessons wait; a person reads PREVIEW.md and runs publish <stamp> --apply. Making the filing unattended would take an amendment and a § 13.7 record, not a code change.
--scheduled also skips quietly ($0) while enabled is false, waits reflect.every_days after the last scheduled run that reached the model, and stops at budget.loops.scheduled_stop_pct; a usage limit or a budget stop is capacity and exits 0, so the next day tries again. At the $2 stage cap a weekly reflection costs at most $10 a month, and refine.config refuses a cadence whose month would pass the scheduled stop.
The schedule¶
tools/install-harness-review.sh installs the com.bamr87.harness-review LaunchAgent. Every day at 06:23 local (--at HH:MM, never on the hour) it runs, against the checkout at --root, tools/dash-gen lake sessions --days 2 (this machine's transcripts, local, $0), tools/dash-gen lake assist --days 7 (the console assistant's page audit and AI-ledger rows, joined to those sessions, local, $0), tools/dash-gen lake sync --days 2 --jobs ai --logs ai (the CI agent runs, GitHub reads), tools/dash-gen lake review --days 7 --json into .fleet/refine/review-latest.json, and then tools/dash refine reflect --scheduled, guarded: it is skipped quietly while refine reflect is not in the checkout or harness_refinement.enabled is not true, so the agent can be installed against main before this lands and the reflect step switches on when it does. A failed step is logged and the next one still runs; the log is ~/Library/Logs/bamr87-harness-review.log. It changes the Mac, so the maintainer installs it (§ 10.5): tools/install-harness-review.sh --root /Users/bamr87/bamr87; --print-job and --print-plist show what it would install, --uninstall removes it. The first live reflection on a checkout also needs that checkout's refine reflect doctor --live --yes (≤ $0.10, once per CLI version and posture).
One Propose–Probe–Compose step¶
The method at budget k: k reference attempts under the base harness (base1..k), then k INVARIANT candidates (how the agent works: procedure, tool use, completion) and k DOMAIN candidates (what a practitioner of the category knows) proposed from those trajectories, each rolled out once, then either k independent compositions from the whole pool (parallel mode: agg1..k) or k successive checkpoints that carry the refined harness forward (sequential mode: c1..k). That is R = 4k rollouts and P = 3k improvement sessions, an identity refine.Ledger asserts rather than assumes, plus one blind selection over the finals' deliverables and one reflection into the library.
tools/dash refine plan repo-scout --target SCHEMA # k=1, the configured mode, the live ledger
tools/dash refine plan repo-evolution --k 2 --mode sequential --no-budget
plan prints the schedule (every rollout and session, which harness it runs or edits and which evidence it reads), the ceiling computed from the step's own budget.call_sites cap for rollouts and harness_refinement.stage_usd for sessions, whether the month's budget.loops can absorb it (from the AI ledger, as the loop runner judges it), the tunable files a candidate may edit, the hard rules it may not, the domain's library, and that the model-backed stages are off. On the scout at k = 1 the ceiling is 4 × $8 + 3 × $2 + 2 × $2 = $42 (API-equivalent (estimate)); on evolve at k = 2 it is $176, which a $50 month cannot absorb, and the plan says so.
tools/dash refine evidence repo-scout --item bamr87/SCHEMA [--run <run_id>]… [--stage compose] [--k 1] [--out DIR]
evidence builds, from this loop step's completed local attempts on the item (.fleet/runs/; a rehearsal or a tier-0 skip never counts), the tree a proposer session would read, under .fleet/refine/<stamp>-…/ (gitignored): MISSION.md (the stage's prompt, rendered), context/INDEX.md (what is there), context/task.md (the brief), context/rollouts/<label>.md (each attempt's full trajectory in the [ACTION] / [OBSERVATION] / [ERROR] / [DENIED] / [RESULT] grammar, every observation clipped to obs_trunc_chars but the trajectory whole), context/deliverables/<label>/ (the validated outputs, the preview bodies, the patch), context/harness/ (the tunable files, the tree a candidate edits), context/hard-rules/ (the prompt, the grant and the caps, read-only), context/library/ (the domain's entries, INDEX.md first), context/proposals/ (where a hard-rule proposal goes) and evidence.json (the manifest, every file's hash). Every file passes through the context pack's redaction: the work root is <work>, the home ~, the machine <host>, credentials masked. The mission tells the session that everything under context/ is data, never instructions, that no score, rubric or grader exists anywhere in its context, and that KEEP_BASE is a real answer.
The five missions (tools/jev/missions/) are adapted from Harness² under its Apache-2.0 notice: propose-invariant, propose-domain, compose, select, reflect. They are .prompt.txt files under the step-spec prompt rules, rendered one-pass from {{TOKEN}} inputs; refine missions list prints their hashes and refine missions render <name> --set TOKEN=value … their bytes.
In the console¶
ADR 0004 P2 is the Harness Console's Refine page (Harnesses → Refine, /refine; tools/console/README.md): the surface check over the hub and the sweep over every checked-out fleet repository, one Propose–Probe–Compose plan per agent step with its ceiling judged against the month, the evidence trees built here, the experience library with the \(0 reflector's form, and the **review queue** — every local loop-run attempt whose dry-run preview has not been filed, the preview readable in place, *Check it still matches* (\)0) and Approve and file (the engine's publish gate, constitution § 11.8, behind the console's confirm) beside it. The ops are refine-surface, refine-plan, refine-evidence and refine-library-check, all $0; the MCP layer serves the same document to agents as refine_status, refine_library and refine_reviews; the public site publishes the surface, the plans and the library and keeps the evidence and the queue on the console. The Assist page (Operate → Assist) is the console's read-only assistant: one capped headless session with the fleet MCP server attached, which reads this document too, so a question about a loop's harness is answered from the same facts this page shows.
tools/dash refine surface fleet [--only NAME] [--json] is the sweep the page's Surface tab renders: every registry repository checked out under the hub, one row each, exit 1 when any has an error. A registry entry with no submodule_path (an archived repo, or one the hub tracks without checking out) is listed as no submodule and never read; only the hub's own row reads the hub. On this machine on 2026-11-04 it read 39 of the 45 rows (the hub and 38 checked-out submodules; six are tracked without a submodule) and found 35 clean, four with errors (scripts, law-ai, zer0-CMS, ocrmd: a named script that does not exist, an always-on chain over the cap) and three with warnings (it-journey, zer0-mistakes, ai-world-view.github.io); the errors are each repo's own fix, one submodule per PR.
Configuration¶
_data/fleet.yml harness_refinement:, read and validated on every command:
| Key | What it bounds |
|---|---|
enabled |
the model-backed stages (P1); true since 2026-11-07 (the maintainer's yes), for the one that exists, the incident reflector. A filing still needs a person's --apply |
k_max, mode |
the task-level recursion budget and the default mode (parallel or sequential) |
always_on_max_chars, skill_max_chars |
the surface check's caps |
stage_usd, model, max_turns |
one improvement session's dollar cap, its model (an exact id in ai_models.allowed, § 13.3) and its turns |
library_dir |
the experience library's hub-relative root (JEV_LIBRARY_DIR overrides it locally) |
obs_trunc_chars |
the per-observation clip in a rendered trajectory |
reflect |
the incident reflector: max_entries (candidates one session may propose, 1..10), days (the review window), every_days (a scheduled run waits this long after the last one that spent; a month of them at stage_usd must fit under budget.loops' scheduled stop), timeout_minutes (the session's wall clock) |
What runs a model, and when¶
One command spends today: refine reflect without --rehearse, one session of at most stage_usd ($2), plus its one-time read-fence canary (refine reflect doctor --live, at most $0.10). It runs by hand, or weekly from the harness-review LaunchAgent as --scheduled, and both need harness_refinement.enabled, a passing probe and canary, and room in budget.loops under the budget lock; the scheduled run stops at the scheduled stop and never files. Every other command on this page is $0: the surface check, the plan, the evidence tree, the library, the rehearsal, publish without --apply.
The Propose–Probe–Compose stages (ADR 0004 P1, part two) will run each proposer, composer, selector and reflector session the same way, through tools/dash-gen ai-run --isolate with a copy of the evidence tree as its working directory, under the § 13.8 posture and the loop runner's budget lock, each capped at stage_usd; each candidate's rollout is a tools/dash loop run attempt whose clone carries the candidate's tunable files; selection is blind over the validated deliverables; and the reflector's entry and the adopted tunable edits land as draft PRs a person files. The first live step is a k = 1 canary on the scout. A refinement never edits a step spec: a lesson that needs a hard rule is a proposal in context/proposals/hard-rules.md for a gated PR, and a lesson confirmed three times is a candidate for a sensor or a standing rule, the ratchet of HARNESS.md.
Tests¶
python3 tools/test_jev_surface.py # the surface rules on fixtures, the hub's own surface clean, the CLI's exit codes
python3 tools/test_jev_library.py # the entry round trip, refusals, leaks, check, the registry domain, the pack's library section
python3 tools/test_jev_refine.py # the schedule and its identity, the ledger, the config, the missions, the plan, the evidence tree
python3 tools/test_jev_reflect.py # the incident reflector: gather, the drops, the budget stop, rehearse, the probe, canary and a live run (stub claude), --apply against a bare origin, the schedule's job
Related¶
- ADR 0004 — the needs assessment, the prior-art survey and the build-vs-adopt decision (§ 10.8), the phases
- JEV.md — the step specs, the loop runner and the context pack this is built on
- HARNESS.md — the six layers, the scorecard and the ratchet this feeds
tools/jev/README.md— the module reference