Metadata-Version: 2.5
Name: assay-bittensor
Version: 0.4.0
Summary: Assay your subnet's incentive mechanism — find the gaming vectors before the judges do.
Author: assay contributors
License: MIT
License-File: LICENSE
Keywords: adversarial,bittensor,incentive-mechanism,subnet,testing
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Provides-Extra: chain
Requires-Dist: bittensor<12,>=11; extra == 'chain'
Requires-Dist: python-socks[asyncio]>=2.4; extra == 'chain'
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Description-Content-Type: text/markdown

<div align="center">

# assay

**An assayer tells you whether the gold is real or adulterated.**

`assay` does that for Bittensor subnets — it tells you whether your incentive
mechanism pays for work, or pays for gaming.

</div>

```
$ assay run examples/naive_flat.py --no-color

  assay  ·  mechanism: naive-flat
  ────────────────────────────────────────────────────────────────────────────────────────
        scenario             criterion                                         value
  ────────────────────────────────────────────────────────────────────────────────────────
  PASS  honest_baseline      honest share >= 0.95 and top miner < 0.60         0.000
  FAIL  lazy_miner           lazy share <= 0.05                                0.500
  FAIL  weight_copying       copier weight / original weight <= 0.25           1.000
  FAIL  collusion_ring       ring share / per-work-unit fair share <= 1.50     6.400
  FAIL  sybil_farm           per-UID sybil weight / per-UID honest weigh...    1.000
  FAIL  stale_replay         replay weight / honest weight in later roun...    1.000
  FAIL  noise_flood          noise share <= 0.05                               0.500
  ────────────────────────────────────────────────────────────────────────────────────────

  6 of 7 scenarios broke your mechanism:

    ✗ lazy_miner  — lazy share=0.500
    ✗ weight_copying  — copier avg=1.0000  original avg=1.0000  ratio=1.000
    ✗ collusion_ring  — ring share=0.571  fair-per-work-unit=0.089  amplification=6.40x
    ✗ sybil_farm  — 8 hotkeys / 1 operator, identical payload  elasticity=1.000
    ✗ stale_replay  — replay avg=1.2000  honest avg=1.2000  ratio=1.000
    ✗ noise_flood  — noise share=0.500  (latency=5ms vs honest 120ms)
```

## The name

Miners produce ore. An **assayer** melts a sample down and tells you what
fraction of it is actually gold — that is the whole job, and it is the only thing
standing between a mine and a fraud.

Bittensor is a network of mines. Each subnet defines what "ore" is and how it
gets weighed. Almost nobody checks whether the scale is honest until the
emission is already gone. `assay` is the scale, and the fire.

## Why this exists

Bittensor 11 removed the `Axon`/`Dendrite`/`Synapse` stack and replaced it with
`btauth/1` signed HTTP requests. The official subnet template was **archived**
and no longer works with current releases, and there is no replacement yet — a
GitHub search for a v11 subnet template returns zero repositories. Every subnet
in the ecosystem is being rebuilt right now, and the one part nobody can test is
the part that decides who gets paid.

Incentive mechanisms fail in a small number of well-known ways: Sybil farms,
collusion rings, weight copying, stale replay, latency gaming, lazy
registration. Each of those is a specific, testable property. This is a test
runner for those properties.

## The evidence

Three mechanisms ship with the tool. Same suite, same seeds, same evaluator
noise — the only difference is policy.

| scenario | `naive_flat` | `quality_only` | `hardened` |
|---|---|---|---|
| `honest_baseline` | ✅ 0.000 | ✅ 0.000 | ✅ 0.000 |
| `lazy_miner` | ❌ 0.500 | ✅ 0.000 | ✅ 0.000 |
| `weight_copying` | ❌ 1.000 | ❌ 0.919 | ✅ 0.000 |
| `collusion_ring` | ❌ 6.40× | ❌ 3.20× | ✅ 0.00× |
| `sybil_farm` | ❌ 1.000 | ❌ 0.585 | ✅ 0.071 |
| `stale_replay` | ❌ 1.000 | ❌ 0.917 | ✅ 0.063 |
| `noise_flood` | ❌ 0.500 | ❌ 0.121 | ✅ 0.000 |
| **result** | **6 / 7 broken** | **5 / 7 broken** | **all held** |

The interesting row is `quality_only`. It is the mechanism a competent engineer
writes on the first pass: honest quality scoring, median of three samples, empty
submissions rejected. It handles lazy miners and it is not fooled by noise — and
it still loses 5 of 7, because copying, Sybil farming and replay are not
*quality* problems. They are *identity and freshness* problems, and a mechanism
that only measures quality has no defence against them.

## Live-chain replay

The synthetic populations above are shapes I chose. `--netuid` replaces them
with shapes the chain actually produced: it pulls the subnet's metagraph, takes
each real miner's on-chain `incentive` as its empirical quality, and injects
adversaries into that distribution.

```bash
assay live --netuid 64                     # what the subnet looks like right now
assay run examples/hardened.py --netuid 64 # replay the library against it
assay live --netuid 64 --save snap.json    # snapshot for offline runs
assay run examples/hardened.py --snapshot snap.json
```

### What the chain says about four real subnets

Read on 2026-11-28, block 9,604,793:

| netuid | subnet | registered miners | earning *this epoch* | top-5 share | gini |
|---|---|---|---|---|---|
| 1 | Apex | 246 | 3 (1.2%) | 100% | 0.989 |
| 4 | Targon | 242 | 2 (0.8%) | 100% | 0.994 |
| 8 | Vanta | 240 | 18 (7.5%) | 41.3% | 0.943 |
| 64 | Chutes | 238 | 13 (5.5%) | 64.6% | 0.965 |

**Read this carefully, because it is easy to overclaim.** `incentive` is a
per-epoch quantity. A miner showing zero means it took no incentive *in that
epoch*, which can be a snapshot artefact of when weights landed — it is not
proof that the miner is permanently unpaid. What the numbers do show, robustly,
is that an observer looking at a subnet has almost no way to tell "this miner is
idle" from "this miner is being squeezed out" from "the mechanism is fine and I
caught it between epochs."

That ambiguity is the point. A subnet owner cannot answer "is my mechanism
healthy?" from these numbers alone, and that is the question `assay` exists to
make answerable.

### Batch scan: where to look first

```bash
assay scan --top 20              # the 20 largest subnets
assay scan --netuids 1,4,8,64    # specific ones
```

A scan of the 24 largest subnets, 2026-11-28:

```
  netuid  subnet           paid  paid%   top1  gini* gini_all  reading
  ─────────────────────────────────────────────────────────────────────────────
       4  Targon              2   0.8%  71.5% 0.215    0.994  thin supply (2)
       1  Apex                3   1.2%  41.2% 0.134    0.989  thin supply (3)
     116  Carbon              3   0.6%  37.5% 0.083    0.995  thin supply (3)
     120  Affine              1   0.1% 100.0% 0.000    0.999  single supplier
       3  Teutonic            3   1.2%  33.3% 0.000    0.988  thin supply (3)
       9  iota                1   0.4% 100.0% 0.000    0.996  single supplier
      15  ORO                70  28.7%  94.9% 0.950    0.986  paid set highly uneven
      18  Zeus               33  13.4%  62.1% 0.897    0.986  paid set highly uneven
       6  Numinous          163  70.0%   7.6% 0.895    0.926  paid set highly uneven
      19  blockmachine       35  14.4%  21.0% 0.664    0.952  paid set uneven
      24  ms.computer       958  93.6%   0.8% 0.598    0.623  paid set uneven
      58  Attune             53  10.8%  30.0% 0.573    0.954  paid set uneven
       8  Vanta              18   7.5%   8.7% 0.242    0.943  paid set spread
       5  Hone              239  97.6%   0.7% 0.197    0.216  paid set spread
      13  Data Universe     239  96.8%   0.5% 0.099    0.129  paid set spread
      22  Desearch          240  97.2%   0.8% 0.092    0.118  paid set spread
      42  CADmind             5   1.4%  20.0% 0.000    0.986  paid set spread
       2  DaniLabs            0   0.0%   0.0% 0.000    0.000  validators only
      10  Pareton             0   0.0%   0.0% 0.000    0.000  validators only
      14  Cacheon             0   0.0%   0.0% 0.000    0.000  validators only
      20  Witness             0   0.0%   0.0% 0.000    0.000  validators only
      11  TrajectoryRL        0   0.0%   0.0% 0.000    0.000  validators only
      17  404—GEN             0   0.0%   0.0% 0.000    0.000  validators only
      21  AdTAO               0   0.0%   0.0% 0.000    0.000  validators only
  ─────────────────────────────────────────────────────────────────────────────
  thin supply (<5 paid miners): 6/24
  validators only (no miner paid): 7/24
  median paid count 3   median gini* 0.219
```

Five shapes, all in one sample:

- **7 of 24 pay validators only.** Every neuron with a non-zero emission holds a
  validator permit and every miner UID sits at zero incentive. The subnet is
  still emitting — it just has no miner supply this epoch. That is a different
  condition from being inactive, and it needed its own label.
- **6 of 24 have thin supply** — under five miners earn anything at all.
- **netuid 15 (ORO)**: 70 miners are paid, and the top one takes **94.9%** of the
  paid set. `gini*` 0.950.
- **netuid 6 (Numinous)**: 163 paid, top-1 only 7.6%, but `gini*` 0.895 — a long
  tail where most earn crumbs.
- **netuid 5 / 13 / 22**: ~97% of registered miners earn, `gini*` under 0.2. These
  are what a healthy subnets look like.

> UID space is not fixed at 256 — netuid 24 has 1024 slots with 958 paid. So
> "registered miners" is not comparable across subnets in absolute terms, only as
> a fraction. The metrics here are all ratios for that reason.

`gini*` is concentration among miners that actually earned; `gini_all` is across
every registered UID. The second column is nearly identical for all four subnets
(0.94–0.99) and therefore useless as a signal — subnets have hundreds of UID
slots and most holders never run a miner. The first column separates a subnet
produced by two hotkeys from one where eighteen miners split the reward evenly.

**This distinction was a correction.** The first version of `assay scan` ranked
by `gini_all`, and every subnet came out between 0.87 and 0.98 — a wall of
identical verdicts measuring a structural constant. The tests in
`tests/test_scan.py` now pin the property that the two metrics must disagree, so
it cannot silently regress.

The finding worth carrying into a pitch: **a subnet whose commodity comes from
two hotkeys has a supply problem no incentive design fixes**, and that fact is
invisible on any dashboard that reports emission totals.

### Live replay finds things synthetic data hides

Running `quality_only` against netuid 64's real distribution:

```
  assay  ·  mechanism: quality-only
  replaying Chutes (finney, block 9604793) — 238 real miners, gini 0.965

  PASS  honest_baseline      honest share >= 0.95 and top miner < 0.60         0.000
  PASS  lazy_miner           lazy share <= 0.05                                0.000
  FAIL  weight_copying       copier weight / original weight <= 0.25           1.008
  FAIL  collusion_ring       ring share / per-work-unit fair share <= 1.50     1.679
  FAIL  sybil_farm           per-UID sybil weight / per-UID honest weigh...    0.521
  FAIL  stale_replay         replayer reward decays to <= 0.20 of its fi...    1.164
  PASS  noise_flood          noise share <= 0.05                               0.021

  4 of 7 scenarios broke your mechanism
```

Note `stale_replay` at **1.164** — the replayer's reward *increased* over time.
It did real work in round 1 and then resubmitted that same answer forever, and a
quality-only mechanism paid it more each round.

### A fourth correction, in the scanner itself

The scan metric was wrong in the same way, and it is worth describing because it
is a different kind of mistake: not a bug in the code, but a bug in what the
code *measured*.

Ranking by concentration across all registered miners produced 0.87–0.98 for
every subnet sampled. Four data points, four identical verdicts, zero
discrimination — a metric that had quietly become a constant. The cause is
structural: registration is cheap, subnets have hundreds of UID slots, and most
holders never run a miner, so "most registered UIDs earn nothing" is the normal
state of the network rather than a finding about any subnet.

The fix was to separate the two things that number had been conflating:
*participation* (how many of the registered crowd earns — structural, and
mostly explains itself) from *supply* (how the paid set is shaped — that is
where a real problem lives). `assay scan` now ranks on the second and reports
the first as context.

### Three measurement bugs that live data exposed

Building this section was uncomfortable in a useful way. The synthetic suite
passed, then live replay produced a different answer, and in each case the
harness was wrong, not the mechanism:

1. **The baseline was given adversaries.** `honest_baseline` asserts honest
   miners keep ≥ 95% of weight — but the live builder injected adversaries into
   *every* population, including that one. The baseline failed on every subnet,
   which correctly made all other PASSes vacuous. Fixed: the baseline gets a
   clean population.
2. **Copiers were compared to an average.** `weight_copying` divided copier
   weight by the mean of all honest miners. On a skewed distribution where most
   miners earn nothing, that denominator collapses and the ratio looks benign
   while a copier is earning full freight. Fixed: each copier is compared to the
   specific miner it copied.
3. **A hardcoded quality assumption.** `collusion_ring` computed the ring's fair
   share with a formula baked in for three synthetic miners at quality 0.85. On
   live data it silently *passed* every mechanism. Fixed: fair share is computed
   from the actual population's ground truth.

The lesson generalises: a harness that only sees distributions you invented will
confirm the assumptions you built into it.

## Install

```bash
# from a clone
uv venv && source .venv/bin/activate
uv pip install -e .
uv pip install -e ".[chain]"   # for signature checks and live-chain replay

# or straight from git, no clone
uvx --from git+https://github.com/yu7dan/assay assay list
```

Once published to PyPI this becomes `uvx assay-bittensor`.

Python 3.10+. Zero runtime dependencies; the `chain` extra is optional.

> If you have a SOCKS proxy configured (many dev machines do), `chain` matters:
> without `python-socks` the SDK fails with `connecting through a SOCKS proxy
> requires python-socks`, which does not name the package clearly. It is a
> dependency of the extra, so `-e ".[chain]"` is enough.

> Distribution name is `assay-bittensor` (the plain `assay` name is taken on
> PyPI); the import name and the command are both `assay`.

## Use

**1. Wrap your reward function.** One method, ~10 lines:

```bash
assay init assay_my_subnet.py
```

```python
from assay import Batch, Mechanism

class MyMechanism(Mechanism):
    name = "my-subnet"

    def score(self, batch: Batch, evaluate) -> dict[int, float]:
        # evaluate(response) -> noisy quality in [0, 1]
        return {r.uid: evaluate(r) for r in batch.responses}

MECHANISM = MyMechanism()
```

**2. Run the library.**

```bash
assay run assay_my_subnet.py                  # human table
assay run assay_my_subnet.py -f json -o r.json
assay run assay_my_subnet.py -f markdown      # paste into your README
assay run assay_my_subnet.py -s sybil_farm    # one scenario
assay run assay_my_subnet.py --netuid 64      # replay a real subnet's distribution
```

**3. Wire it into CI.** Exit code `0` means every scenario held, `1` means at
least one broke. A mechanism regression fails the build.

```yaml
- run: assay run assay_my_subnet.py -f json -o assay.json
```

Or use the composite action, which also posts the table to the job summary:

```yaml
- id: assay
  uses: yu7dan/assay@main
  with:
    mechanism: ci/assay_adapter.py
    fail-on-regression: "true"
```

```yaml
outputs:
  failures:  # count that broke
  passed:    # count that held
  report:    # path to the markdown report
```

A full example that comments the report onto a PR is in
[`examples/workflows/assay-example.yml`](examples/workflows/assay-example.yml).
The action is tested by running it against a mechanism that must pass and one
that must fail — see the `action-selftest` and `action-detects-bad` jobs.

**4. Re-render an old report.** `assay report` turns a saved JSON run back into
a table or markdown, so CI can run once and render twice.

```bash
assay report assay.json -f markdown -o report.md
```

## The library

| scenario | what the adversary does | assertion |
|---|---|---|
| `honest_baseline` | behaves well (sanity check) | honest share ≥ 0.95, no single miner > 0.60 |
| `lazy_miner` | submits whitespace | lazy share ≤ 0.05 |
| `weight_copying` | byte-identical copy of a peer | copier / original ≤ 0.25 |
| `collusion_ring` | 4 hotkeys fan out 1 answer per round | share / per-work-unit fair share ≤ 1.50 |
| `sybil_farm` | 8 hotkeys, 1 operator, 1 answer per round | per-UID sybil / per-UID honest ≤ 0.40 |
| `stale_replay` | resubmits a previously valid answer | replay / honest ≤ 0.20 |
| `noise_flood` | random bytes, 5 ms latency | noise share ≤ 0.05 |

`honest_baseline` runs first and exists to stop a mechanism that returns
*nothing* from passing the whole suite vacuously — every attack assertion is
one-sided ("this attacker must not earn more than X"), so a mechanism that pays
nobody would trivially satisfy all of them. If the baseline fails, the report
says so and every other PASS is meaningless.

## The four defences

`hardened.py` is not clever. It is four checks:

1. **freshness** — a payload seen in a previous round earns nothing
2. **deduplication** — one unit of work is paid once, to the earliest submitter
3. **quality floor** — work below a threshold earns nothing, however fast it arrived
4. **robust sampling** — median of k noisy evaluations instead of one lucky draw

The gap between "survives" and "gets farmed" is those four lines of policy, not
a research project.

### A real finding, from running this on itself

The first version of `hardened.py` used a quality floor of `0.15`. `noise_flood`
scored **0.053** and failed: with an evaluator noise band of ±0.12, a
0.10-quality garbage miner still cleared a 0.15 floor in roughly 20% of rounds
and collected 5.3% of emission. Raising the floor to `0.30` — clear of the noise
band — took it to 0.000.

That is the whole argument for this tool in one paragraph: the difference between
"my mechanism is robust" and "my mechanism leaks 5% to garbage" was one
constant, and nothing but an adversary would have found it.

## Validators: the other half of the attack surface

A miner can only misrepresent its own work. A validator misrepresents everyone's.
`assay consensus` runs the mechanism **once per validator**, applies each
validator's behaviour, and combines the results by stake — the same formula
`fidelity` verified against mainnet.

```bash
assay consensus examples/winner_take_all.py
```

```
  assay  ·  mechanism: winner-take-all
  validator-side: mechanism runs once per validator, combined by stake
  ────────────────────────────────────────────────────────────────────────────────────────
        scenario             criterion                                          value
  ────────────────────────────────────────────────────────────────────────────────────────
  FAIL  weight_concentration largest single-UID share of output <= 0.60        1.000
  SKIP  validator_outlier    excess share granted to a zero-work miner b...     0.167
  SKIP  validator_capture    captured miner share / fair share (informat...     0.600

  2 informational (measured, not gated):
    · validator_outlier  zero-work miner received 0.167 of emission from 1 of 6 validators
    · validator_capture  zero-work miner received 0.600 — 40% outlier + 20% copier
```

### What is the mechanism's fault, and what is not

This distinction is the whole design, and getting it wrong would produce a tool
that fails good code for things it cannot control.

| Scenario | Gated? | Why |
|---|---|---|
| `weight_concentration` | **yes** | how reward is shaped is entirely the mechanism's own output |
| `validator_outlier` | no | the validator overwrites the result *after* the mechanism runs |
| `validator_capture` | no | majority stake is a stake-distribution problem, not a code problem |

Two of three are informational and always will be. A hostile validator does not
ask the mechanism's permission — it runs the code, then submits a different
vector. No scoring rule prevents that, so asserting otherwise would be theatre.

What the numbers are still worth: they quantify exactly how much damage a given
stake distribution buys. On the reference population, one validator holding 1/6
of stake hands **16.7%** of emission to a miner that produced nothing. Add a
copier that never runs the code and a 40% outlier becomes a 60% bloc worth
**60%** of emission.

### The cheapest capture is not a bad validator — it is a lazy one

Consensus is stake-weighted, so a copier adds no opinion of its own. It lends
its stake to somebody else's judgement. Recruiting one validator that resubmits
another's vector is worth as much as running a validator — and costs nothing.

That is why `copier` is modelled at all. It is the cheapest capture available and
it looks like participation.

### What concentration actually costs

`winner_take_all` is a real Bittensor pattern — some subnets deliberately pay
only the top miner, and for a race that is defensible. It also means one UID
takes **100%** of the reward, so any validator disagreeing about who won is
fighting over the entire pot rather than a slice.

The tool measures the tradeoff; it does not call the design wrong. A FAIL here
means "you have chosen a concentrated distribution, here is the number", which
is information a subnet owner should have in front of them rather than discover
during an incident.

### One scenario I wrote, then deleted

`mechanism_agreement` compared two honest validators' top choices. It ran,
produced numbers, and was worthless: four mechanisms from naive to hardened all
scored identically, because the outcome is governed by the population's quality
gap relative to evaluator noise rather than by anything the mechanism does.

A test that cannot tell a broken mechanism from a good one is worse than no test,
because it implies coverage it does not have. Its one genuinely mechanism-owned
fragment — sensitivity to evaluator noise — survives as a measurement:

| mechanism | TVD between σ=0.10 and σ=0.25 runs |
|---|---|
| `naive_flat` | 0.000 (ignores the evaluator entirely) |
| `quality_only` (median of 3) | 0.110 |
| `single_sample` (one look) | 0.184 |

Median-of-three roughly halves how much a mechanism's output moves when its
evaluator gets noisier. That is a real property, worth knowing, and not
strong enough to gate on across all mechanism shapes.

## Fidelity: is the model right?

Everything above assumes a transformation — a mechanism emits `uid -> weight`,
and that becomes a reward. `assay fidelity` tests that assumption against the
chain:

```
incentive[m] = Σ_v (stake_v × weight[v][m]) / Σ_v stake_v
```

```bash
assay fidelity --netuid 64
```

```
  assay fidelity  ·  netuid 64  ·  finney
  ──────────────────────────────────────────────────────────────────────────────
  model  incentive[m] = Σ_v stake_v × weight[v][m] / Σ_v stake_v
  validators with weights    14
  stake across them          3,706,598.5
  miners receiving incentive 17

  agreement   TVD 0.0003   exact
  the stake-weighted model reproduces the chain's own incentive figure to within rounding

     uid     on-chain   reconstructed       delta
  ──────────────────────────────────────────────────────────────────────────────
      82     0.070665        0.070852   -0.000188
     228     0.039887        0.040024   -0.000136
      21     0.228138        0.228025   +0.000113
```

Measured across **17 mainnet subnets on 2026-11-28**: 16 within TVD ≤ 0.05,
median **0.001**. The model is verified, not assumed — which matters, because
every verdict this tool produces sits downstream of it.

### The bug this found

The first version of the check reported a **TVD of 0.37** on netuid 24. That
looked like a topology difference worth writing up. It was a bug.

The chain stores a weight row for *any* hotkey that submits one, but a row from
a hotkey **without a validator permit** never enters consensus. On netuid 24 one
non-permitted hotkey held 37% of the stake and had submitted a full weight
vector; counting it distorted the reconstruction completely.

Filtering to permit-holders took that subnet from 0.37 to **0.0054**. Eight of
the 17 subnets sampled had such rows, so this was not an edge case — it was the
common case, silently corrupting an innocent-looking number.

That is the same lesson as the scan correction, in a different register: a
measurement that looks plausible is not the same as a measurement that is right.

## btauth/1 conformance

A separate probe, and the only one with an objective oracle: the v11 docs publish
golden test vectors with a pinned ed25519 signature.

```bash
assay conformance
```

```
  btauth/1 conformance  ·  golden vectors from docs.learnbittensor.org
  ──────────────────────────────────────────────────────────────────────────────
  PASS  body sha256                  341c57448e531310…
  PASS  payload layout               227 bytes, no trailing newline
  PASS  ed25519 golden signature     byte-for-byte match
  PASS  sr25519 roundtrip            sign → verify
  PASS  tamper rejection             substituted body rejected
  PASS  receiver binding             receiver is part of the signed payload
  ──────────────────────────────────────────────────────────────────────────────
  all checks held
```

It verifies the full wire format against the published fixture, plus three
negative cases: a substituted body must be rejected, a signature addressed to a
different receiver must be rejected, and sr25519 (which is randomised) must
round-trip. Correctness here is not a matter of opinion — the bytes either match
or they don't.

## What this does NOT test

Being explicit, because a harness that overstates its coverage is worse than none:

- **Quality model accuracy.** `evaluate()` is a stand-in. This tests how you
  *aggregate and defend*, not whether your model is good.
- **On-chain stake dynamics.** Weights are modelled, not submitted. Emission,
  bonds, immunity periods and validator permits are out of scope for v0.1.
- **Real network conditions.** No latency distributions, packet loss, or partial
  failures yet.
- **Mechanism-specific exploits.** The library is generic by design. Your
  subnet's commodity may have a domain-specific attack this doesn't know about.
- **Adversaries that vary their payload.** A Sybil that submits genuinely
  distinct work per hotkey is indistinguishable from N honest miners — that is
  not a bug in the harness, it is the definition of the problem.

## Architecture

```
src/assay/
  types.py        Response / Miner / Batch / Outcome / Verdict
  mechanism.py    the ABI + evaluator + weight clamping
  population.py   scripted adversaries (honest, lazy, copier, ring, sybil, replayer, noise)
  scenarios.py    the adversary library and its assertions
  runner.py       the harness loop
  conformance.py  btauth/1 golden vectors
  report.py       table / json / markdown
  live.py         metagraph fetch, cache, real-distribution populations
  scan.py         batch profiling across netuids
  fidelity.py     reconstructs on-chain incentive from real weights + stake
  consensus.py    validator behaviours + stake-weighted aggregation
  validator_scenarios.py  concentration (gated) + stake capture (informational)
  cli.py          run · consensus · list · live · scan · fidelity · conformance · report · init
```

The mechanism never sees `Miner.true_quality` or `Miner.role`. It sees responses
and a noisy `evaluate()`. That split is deliberate: the harness knows ground
truth, the mechanism does not, exactly as on a real subnet.

## Develop

```bash
make install     # editable install + pytest
make test        # 129 tests
make probe       # run all three reference mechanisms
make conformance # btauth/1 golden vectors
make all         # what CI runs
```

## Roadmap

- [x] live-chain mode: pull a real subnet's metagraph and replay its actual
      miner distribution through the adversary library
- [x] batch scan across netuids, ranked by supply structure
- [x] read real validator weights from the chain, and verify the model against
      what the chain actually paid (17 subnets, median TVD 0.001)
- [x] model validators: hostile outlier, copier, majority-stake bloc, and
      concentration as the one property that is genuinely the mechanism's fault
- [ ] stake-weighted and validator-permit-aware scenarios
- [ ] a subnet owner's report: run the whole library across N netuids and rank
      which mechanisms look structurally fragile
- [x] composite GitHub Action, self-tested against a mechanism that must pass
      and one that must fail
- [ ] publish to PyPI so the action can install a pinned release instead of a checkout

## License

MIT
