in reviewhumanPR #371Trust
Add reputation.calibrated.v1 trust layer and the overclaim scenario
A trust layer that scores an agent on how well the confidence it stated before an outcome matched what was later rated.
Description
The pitch.
## What this adds
A trust layer that scores an agent on how well the confidence it stated before an outcome matched what was later rated.
- An agent states its confidence as an attributed event before the outcome: `api.observe("confidence_stated", decision_id, {"confidence": 0.9, "to": "buyer-1"})`.
- A later rating of that agent by another agent settles its oldest open claim addressed to the rater, else its oldest addressed to no one.
- The score is out of 100, from the calibration error and Brier skill of the agent's latest 200 settled claims. Fewer than ten settled claims scores 10. The formula is in the module docstring.
- A rating with no open claim moves nothing and records `no_open_claim`. A second, different claim on the same decision is refused with a `confidence_refused` event; the first stands.
## Why
`reputation.v1` sums good and bad ratings, so a seller with many customers outranks a better seller with few. The `overclaim` scenario shows it: a busy seller says it is 99% sure and honours seven orders in ten; a steady one says 95% and does it. A shopper buys from whoever the registry lists first.
| scenario | trust layer | shopper buys from | verdict |
|---|---|---|---|
| `overclaim` | `reputation.calibrated.v1` | seller-steady, 28 of 30 honoured | passed |
| `overclaim_uncalibrated_control` | `reputation.v1` | seller-busy, 17 of 30 honoured | FAILS on purpose |
The two scenario files differ only in the trust layer, and a test pins that.
## Changes
- `layers/trust_calibrated.py`: the layer, registered as `("trust", "reputation.calibrated.v1")`.
- `sim/validators.py`: `reputation_calibrated`, a replay of the formula from the events alone with its own arithmetic, and the `overclaim` validator (five stages).
- `sim/agents.py`: roles `promising_seller`, `regular`, `shopper`.
- Two scenarios, `tests/test_lab_overclaim.py` (42 tests: hand-computed formula pins, refusal rules, tampered-trace cases, the scenario and its control), the scenario lists in `tests/test_sim.py` and `tests/test_lab_coverage.py`, and the README rows.
No existing layer, validator or scenario changes behaviour. `reputation_consistent` is untouched and, as intended, rejects calibrated scores; each formula is judged by its own check.
## What it does not claim
- The replay checks the recorded claim: that each score is what the formula gives over the claims and receipts before it. It does not check that a rating was true, that a stated confidence was sincere, or who was entitled to rate.
- The scenario needs the volume gap. A rule that simply ranked by share of good ratings would also pick the steady seller here; what calibration adds is that it also separates a seller that hedges honestly from one that is sure and wrong at the same delivery rate (34 against 10 in the pinned tests).
- An agent that never states a confidence stays at the floor of 10.
## Testing
- `python -m pytest -q`: 1905 passed, 2 skipped, 2 failed. The two failures are in `tests/test_url_credentials.py` (read-only home directory) and fail identically on `main` in the environment used, which runs as root.
- Both scenarios run across seeds 0 to 49: `overclaim` passes on all 50, the control fails on all 50.
Try it
Open PR on GitHubView diffCheckout locally
git fetch origin pull/371/head:pr-371
git checkout pr-371