> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Test a rater

> Test a rater against the filing: rate generated requests, confirm each broken rule gets its refusal, and match the filed rating examples to the cent.

[Install Relativities and download the synthetic examples](/relativities/setup) before running this page.

This page tests the dwelling fire rater from [Write your first rater](/relativities/rsl/tutorial/first-rater).
`rslc check` establishes properties of the implemented calculations and input constraints.
Generated requests exercise those declared rules. Independently calculated cases test whether selected premiums agree with the intended rating algorithm.

| Test | Shows |
| - | - |
| Rate generated requests | each request that passes the rules gets a premium |
| Rate generated bad requests | each broken rule gets its refusal |
| Match filed rating examples | the premiums equal the filing's worked examples |

## Rate generated requests

Generate requests that pass every rule, and save them as JSON lines:

```bash theme={null}
rslc inputs sample rater.rsl --n 5 --representation rate --json-lines samples.jsonl
```

Rate each one. The sample download includes the bundle and the file in
`relativities-examples/rsl/dwelling-fire`:

```python theme={null}
import json

import rslc

rater = rslc.PreparedRater("relativities-examples/rsl/dwelling-fire")
with open("relativities-examples/rsl/dwelling-fire/samples.jsonl") as rows:
    for row in rows:
        payload = json.loads(row)["input"]
        result = json.loads(rater.rate(json.dumps(payload)))
        print(result["ok"], result.get("outputs", {}).get("Policy", {}).get("premium"))
# True 3793
# True 575
# True 3418
# True 7010
# True 7278
```

Each request gets a premium. The generator picks values at the edges and the middle of each range,
such as the lowest and highest Coverage A.

## Rate generated bad requests

Add `--invalid`. Each row breaks one rule and records the refusal it expects:

```bash theme={null}
rslc inputs sample rater.rsl --n 4 --representation rate --invalid --json-lines invalid.jsonl
```

```python theme={null}
with open("relativities-examples/rsl/dwelling-fire/invalid.jsonl") as rows:
    for row in rows:
        row = json.loads(row)
        result = json.loads(rater.rate(json.dumps(row["input"])))
        codes = [v["code"] for v in result["refusal"]["violations"]]
        print(row["generation"]["mutation"], result["refusal"]["error"], codes)
# child.missing@Policy.dwelling InvalidInputs ['INPUT-TYPE']
# len.above_max@Policy.items BusinessRejection ['TOO-MANY-ITEMS']
# child.missing@Policy.dwelling InvalidInputs ['INPUT-TYPE']
# len.above_max@Policy.items BusinessRejection ['TOO-MANY-ITEMS']
```

`mutation` names the change: a missing dwelling, then too many items. The generator breaks list
lengths, repeated keys, missing records and choices between record kinds. Write your own cases
for number ranges and for rules that read several inputs.

## Match the filed rating examples

A filing often prints worked examples. Rate each one and compare the premium exactly.
These expected values come from the invented manual in the tutorial; replace them with independently established expectations for your filing:

```python theme={null}
cases = [
    ({"dwelling": {"coverage_a": 250000, "protection_class": 5}, "items": [{"value": 1200}, {"value": 800}]}, 1028),
    ({"dwelling": {"coverage_a": 250000, "protection_class": 5}}, 998),
]
for policy, expected in cases:
    result = json.loads(rater.rate(json.dumps({"Policy": policy})))
    assert result["outputs"]["Policy"]["premium"] == expected, result
```

* Add one case at each band edge, such as protection classes 3 and 4.
* Add one refusal case for each rule with a code, and compare the code.
* To compare a value inside the calculation, rate with `detailed=True`.

Reconcile real quotes only after establishing their rating inputs, effective date, coverage scope, fees, and carrier-specific assignments.
Record unexplained differences and any components outside the implemented scope. [Validate a program](/relativities/how-to/validate-a-program) covers the full comparison workflow.

## Related

* [Use the rslc commands](/relativities/rsl/commands) covers each `rslc inputs` option.
* [Refusals](/relativities/rsl/reference/refusals) lists the codes a refusal carries.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.