# `speciated`: model-fitted network variants (an extension to MVP Profile 0.3)

## The problem
In the Agentic Web spec, a network's `llm_config` is only a hint: the caller's router wins (§2.1), and a peer network runs on the **caller's** model (§3.2). A network tuned on one model is run by strangers on models its author never tried. Model compatibility is listed as open (§3.2, §7).

## The extension
A site keeps its original network and may publish **variants** of it, each fitted to a model and each with its fitness evidence. It adds one block to `agent-manifest.json`:

```json
"speciated": {
  "version": 1,
  "network": "gullwing_desk",
  "suite": { "url": "./speciated/gullwing_desk.suite.json", "sha256": "<hex>" },
  "tool": "https://<speciate-site>/",
  "variants": [
    {
      "models": ["alibaba/qwen3.8-flash"],
      "hocon": "./speciated/gullwing_desk.alibaba-qwen3.8-flash.network.json",
      "sha256": "<hex of the exact file bytes>",
      "fitness": { "passed": 10, "total": 10, "tokens": 5210 },
      "original_fitness": { "passed": 5, "total": 10, "tokens": 3120 },
      "generations": 3,
      "evaluations": 14,
      "evolved_at": "2026-12-20"
    }
  ]
}
```

| Field | Meaning |
|---|---|
| `version` | Always 1. A loader ignores any other version. |
| `network` | The name of the entry in `networks` that the variants replace. |
| `suite` | The fitness tests (queries plus deterministic trace checks) and their hash. Anyone can re-run them. |
| `variants[].models` | Model ids, matched case-insensitively. A trailing `*` matches a family; the longest pattern wins and an exact id beats any pattern. |
| `variants[].hocon` | The variant network file, relative to the manifest. |
| `variants[].sha256` | sha256 of the file bytes. A loader that cannot verify it **must** use the original. |
| `fitness`, `original_fitness` | Checks passed out of the total, plus the tokens used, on that model, for the variant and for the original. |

## Loading rules
1. Read the manifest. If there is no `speciated` block, or its version is not 1, do nothing.
2. Use the model this page actually runs on: the visitor's model, else the caller's model for a peer.
3. If a variant lists that model, fetch its file and check the sha256. Serve it in place of the original network file **only on a match**.
4. Otherwise, or on any error, serve the original. Fail closed to the publisher's own original.
5. A variant is a whole network. It goes through the same `validateNetwork` gate, the same `allowed_peers` and the same consent cards as the original. It can change instructions, nothing that widens what the network may reach. (Speciate only mutates `instructions`.)

`pick-variant.js` (about 100 lines, no dependencies) implements this as a fetch wrapper, so the runtime needs no changes:

```js
import { installVariantFetch } from "./pick-variant.js";
installVariantFetch({ model: () => currentModelId() });
```

Because peers run on the caller's model, a caller page with the wrapper also gets the fitted variant of every **partner** network it calls.

## How variants are made (Speciate)
- **Fitness** is deterministic. The unmodified runtime runs each test query on the target model, and checks on the trace decide pass or fail: tools called and their order, arguments, amounts in the answer grounded in action results, confirmation asked, no origins outside `allowed_peers`, step and token caps. No LLM judges anything.
- **Variation:** an LLM proposes small rewrites of one agent's instructions, aimed at the failed checks (add a rule, tighten, add an example, reorder), plus crossover of agents between parents. Guards drop proposals that add site data such as prices.
- **Selection:** elitism, ranked by checks passed, then by Pareto front on (passed, tokens). The PRNG is seeded, so a run can be replayed.
