Implementation: ALPHA (server) · Exposure: PREVIEW, not in the v0.3 contract. These endpoints are served by allternit-api’s Agency API alpha (cmd/allternit-api/src/agency_api/harness/). Shapes may change.
A task type runs a graph (the steps, their order, which ones are S1 decisions, which ones call a model). Harness learning proposes changes to that graph from what runs actually did, measures every change on evals and replays, and keeps only the changes that are clearly better. Nothing goes live without an admin’s approval, and every approved change can be rolled back. No model is trained here. Candidates come from deterministic mutation operators and, optionally, one call to the planner model asked for a JSON patch. The learning is search plus selection under evals.

Who can use it

Decisions admins only (ALLTERNIT_DECISIONS_ADMINS, user ids, comma separated). Everyone else gets 403 ERR_PERMISSION_DENIED. Proposals, versions and the audit trail are server-wide: an approved version applies to every user’s new runs of that task type.

Endpoints

Propose

The server then:
  1. Gathers evidence: the last 50 finished runs of the type and their trace-monitor findings by check and node, your 5 latest eval runs (failed cases of this type), Decision Runtime metrics for the graph’s S1 decision kinds over 30 days (decisions, mean confidence, abstain share, share under min_confidence, oracle share), and the baseline evaluation’s failures and replay divergences by node.
  2. Generates candidates from the graph new runs use now (the active version), validates each through the task-type binder and the Factory graph validator plus the guardrails, and discards invalid ones with the reason (discarded). Candidates are ranked by the evidence (for example, raising an S1 node’s min_confidence ranks higher when the monitor reports low-confidence answers there), deduplicated, and the top k are kept.
  3. Evaluates the current graph (baseline) and every candidate on the same cases: the task type’s shipped eval set and your suites, walked by the scripted runner on the candidate graph (no model, no effect), and recorded-only replays of the recent runs with a graph_version inline-candidate override.
  4. Judges each candidate by the acceptance rule and stores it as a proposal: pending if it passed, failed_acceptance if not, both with their reasons.
The search runs in the request (201) unless it needs live model calls (the LLM proposer, or replays outside scripted mode); then it is accepted (202, status: running) and finishes in the background. Read it at /v1/harness/searches/{search_id}. A daily spending cap reached during the search fails it with ERR_BUDGET_CAP_REACHED.
The search (hsr_…) carries base (the version evaluated against), evidence, baseline (metrics), cases (case keys), candidates (one line per evaluated candidate: proposal_id, operator, target, status, passed, reasons, delta), discarded, not_evaluated, llm (whether it was used, tokens, cost, candidates kept) and pending (the ids of passing proposals).

Mutation operators

Each operator produces a graph that is valid by construction; it is still validated.

LLM proposer

With llm: true the planner model (through gizzi-code, tools off) gets the graph JSON and the evidence and is asked for {"candidates": [{"rationale", "patch"}]}, where patch is an RFC 6902 JSON Patch (add, remove, replace, move, copy, test; at most 32 operations). Every patch is applied all-or-nothing and validated like an operator’s candidate; a patch that fails to apply, does not bind, or breaks a guardrail is discarded with the reason. The call is metered on the usage ledger and checked against the same daily caps as replays and evals. In scripted mode (ALLTERNIT_AGENCY_COGNITION=scripted) no model is called and the LLM yields no candidates.

Guardrails

Every candidate, from an operator or the model, must keep:
  • the completion gate (ver.check_acceptance_evidence) and its edges, the completion nodes, and every POLICY and WAIT node exactly as they were;
  • for every criterion of the task type’s completion contract, a VERIFY, POLICY, WAIT or CONTROL node that produces its evidence;
  • write authority: no node gains a write set, and every writing node still runs after the POLICY nodes that guarded it;
  • at most 4 added nodes.

Acceptance rule

Baseline and candidate are compared on the cases graded on both sides. A candidate passes only if all hold:
  1. No high-stakes failure. Default high_stakes: "no_new": a high-stakes case that passed on the baseline must not fail. "none": no high-stakes case may fail at all.
  2. Better, or as good and cheaper. Pass rate ≥ baseline + min_gain (default 0.05, five points), or pass rate ≥ baseline − epsilon (default 0.02) and cost or latency improves by at least efficiency_gain (default 0.10).
  3. Not a likely regression. The lower bound of the paired percentile-bootstrap 95% interval of the pass-rate delta is above −epsilon.
Cost and latency are measured (USD, milliseconds) when the replayed runs have them, else counted in units over the visited steps (cost: S1 1, S2 10, S3 30; latency: S0 1, S1 2, S2 10, S3 20). The proposal’s acceptance gives passed, reasons (one line per rule), baseline_pass_rate, candidate_pass_rate, delta, delta_ci95, cost_change, latency_change (relative, with their basis), new_high_stakes_failures and the rule used.

Proposals

A proposal (hpr_…) is what an admin reviews: operator, target, rationale, base (version and graph id it was evaluated against), acceptance, metrics (baseline and candidate: graded, passed, pass rate, cost, latency, failing stop nodes, replay divergences by node), per-case results, the evidence, the candidate graph, the patch (LLM candidates) and a readable diff:
status is pending, failed_acceptance, approved, rejected or rolled_back; history lists every transition with who and when. Pending proposals are an admin-facing list (GET /v1/harness/proposals?status=pending), not attention requests: an attention request belongs to a run and resolves back into it, and a proposal has no run to park or resume.

Approve, reject, roll back

All take an optional {"note": "..."} (at most 2000 bytes).
  • Approve a pending proposal: the candidate is re-validated and registered as the task type’s next graph version (general.task.v2, general.task.v3, …) and becomes active. The shipped graph files are never edited; version 1 is always the shipped graph. A proposal evaluated against a version that is no longer active is refused with 409 ERR_HARNESS_STALE (propose again); one that is not pending with 409 ERR_HARNESS_NOT_PENDING.
  • Reject a pending proposal.
  • Roll back: new runs go back to the version that was active before the current one (versions form a stack; rolling back the last approved version returns to the shipped graph). The rolled-back version keeps rolled_back_at and its proposal becomes rolled_back. With nothing to roll back: 409 ERR_HARNESS_NOTHING_TO_ROLL_BACK.
The registry (GET /v1/harness/versions/{task_type}) shows active_version, the stack, and every version with its graph_id, proposal_id, parent_version, approved_by, approved_at and rolled_back_at.

Which version a run uses

A run takes the active version when it is created and keeps it: its TaskIR carries graph_version (task_type, graph_id, version, graph), and the executor, the trace monitor and replays of that run use that graph. Approving or rolling back changes new runs only; runs in flight finish on the graph they started with. Runs on the shipped graph carry no graph_version.

Audit

Every transition is recorded (hau_…): proposal.created, proposal.approved, proposal.rejected, version.rolled_back, each with the actor, time, task type, proposal id, versions involved and the note.

Errors