# How to independently verify the CAIN 39 escrow lifecycle

This bundle contains a real, 7-transition escrow lifecycle
(`PROPOSED → AUTHORIZED → FUNDED → EXECUTING → AWAITING_VERIFICATION →
VERIFIED → SETTLED`) produced by one live demo this session, plus the two
independent verification layers CAIN 39 requires: cryptographic chain
integrity, and business-rule state-machine legality. These are DIFFERENT
checks -- a chain can be cryptographically untampered yet describe an
illegal state sequence (e.g. skipping straight to SETTLED). You need both.

## 1. Cryptographic integrity (reused, unmodified, from CAIN 37)

```
python3 cain_37_independent_verifier.py verify-chain cain39_escrow_chain.jsonl
python3 cain_37_independent_verifier.py verify-checkpoint cain39_escrow_chain.jsonl cain39_escrow_checkpoints.jsonl
```
Expect `"verdict": "VALID"` both times.

## 2. Business-rule replay (new this session)

```python
import json
from cain_escrow_39 import EscrowStateMachine

records = [json.loads(l) for l in open("cain39_escrow_chain.jsonl")]
print(EscrowStateMachine.replay(records, "escrow-cain39-live-demo-001"))
```
Expect `{"valid": True, "final_state": "SETTLED", ...}`.

## 3. Negative control -- an attacker who can append a cryptographically
valid entry but tries to skip lifecycle stages

```python
import time, uuid, json
from cain_evidence_fabric_37 import EvidenceChain, EvidenceObject
from cain_escrow_39 import EscrowStateMachine

chain = EvidenceChain("tampered_escrow_chain.jsonl")
for line in open("cain39_escrow_chain.jsonl"):
    pass  # (in a real test, copy the file and reopen; abbreviated here)

# Appending a SETTLED transition directly after AUTHORIZED (skipping
# FUNDED/EXECUTING/AWAITING_VERIFICATION/VERIFIED) is cryptographically
# valid (correctly hash-linked) but MUST be rejected by replay():
```
See `tests/test_cain39_agent_internet.py::TestEscrowStateMachine::test_replay_detects_reordering_business_rule_violation`
in the CAIN Studio Platform repository for the full runnable version of this
negative control.

## What this does and does not prove

- Proves: this exact 7-step escrow lifecycle happened, in this order, with
  no tampering, and the sequence itself is legal per CAIN's declared escrow
  state graph.
- Does NOT prove: that the underlying economic decision authorizing this
  escrow was itself correct (see `/proof/bundle/cain38-economic-fabric/` for
  that), or that real money moved (it did not -- `SETTLED` here reflects a
  SIMULATED settlement only).
