Metadata-Version: 2.5
Name: spoolis-receipt-verifier
Version: 0.1.0
Summary: Verify signed Spoolis Outcome Receipts offline: attestations of acceptance criteria, what passed, and what was earned.
Project-URL: Homepage, https://spoolis.com
Project-URL: Documentation, https://spoolis.com/docs/verify-receipt
License: MIT License
        
        Copyright (c) 2026 Spoolis
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: acceptance criteria,agent commerce,attestation,earned value,fulfillment verification,offline verification,outcome receipt,receipt verification,signed receipt,verify purchased work
Requires-Python: >=3.10
Requires-Dist: cryptography
Description-Content-Type: text/markdown

# Verify a Spoolis outcome receipt

An Outcome Receipt is a signed attestation of delivered work: acceptance criteria agreed before delivery, what passed, and what was earned.

```python
from spoolis_receipt_verifier import verify_outcome_receipt

result = verify_outcome_receipt(receipt, trust_set=trust_set)
print(result["valid"])
print(receipt["amounts"]["earned"])
```

## Install

```sh
pip install spoolis-receipt-verifier
```

No Spoolis account is required to verify a receipt. The package uses `cryptography` for Ed25519 signature verification and supports Python 3.10 or later.

## Require an outcome

`require_outcome` verifies the full receipt before applying the consumer's policy. This example acts only on a valid outcome with a passing result, at least 100 accepted units, and fully satisfied evidence requirements:

```python
from spoolis_receipt_verifier import require_outcome

required = require_outcome(
    receipt,
    {
        "minimum_status": "pass",
        "min_accepted_units": 100,
        "evidence_requirements": "satisfied",
    },
    trust_set=trust_set,
)

if not required["ok"]:
    raise RuntimeError(", ".join(required["reasons"]))
```

A partial batch has `result: "partial"`, not `pass`. To act on partial batches, set `minimum_status` to `partial` or omit it, then gate on `min_accepted_units`, `min_accepted_ratio`, or `min_earned`. The receipt's `amounts.earned` excludes rejected and uncertain units.

## Reading partial, unitized results

The `accepted_units`, `rejected_units`, and `uncertain_units` helpers return published unit rows for one verdict. They return `None` when per-unit rows were not published. `earned_amount` returns the decimal string or `None`.

## Trust material

Spoolis publishes receipt trust material at `https://spoolis.com/.well-known/spoolis-keys.json`. Pin the receipt entries you accept and pass the selected environment's array as `trust_set`. `fetch_trust_set(url, environment)` is an online convenience, while verification itself remains offline.

## Offline verification and online status

Signature validity is offline and permanent when the verifier has the receipt and a pinned trust set. Online correction and revocation status is optional:

```python
from spoolis_receipt_verifier import fetch_receipt_status, verify_outcome_receipt

status = fetch_receipt_status("https://spoolis.com", receipt["id"])
result = verify_outcome_receipt(receipt, trust_set=trust_set, status_source=status)
```

Without a status source, verification includes the `status_source_unavailable` advisory.

## Security model

A valid result proves that a supplied trusted key signed the receipt, the content-derived ID matches, and recognized structural and arithmetic checks pass. It does not prove that referenced evidence is true, resolve actor identities, grant payment authority, or prove payment settlement. Consumers must enforce their own authorization and consume-once rules.

See the [receipt verification documentation](https://spoolis.com/docs/verify-receipt) for integration details.
