# W3 — CPA Audit Pack: Attributed Synthesis + Sampling + Envelope + Universality Guard

## Hypothesis

A single provenance-carrying value (pcv) engine can simultaneously serve:

1. Full attributed synthesis of cross-ledger financial totals with zero orphan values.
2. Deterministic monetary-unit sampling with all auditor-set params attributed to pcv leaves.
3. A clean audit envelope separating VERIFIED / DERIVED / REFUSED dispositions, never crossed.
4. The same engine runs correctly on non-accounting data (sensor readings), proving domain-blindness — the engine is universal; accounting was only data + config.

## Files

- `run.py` — the runner; pure stdlib; deterministic; no external deps.
- `results.json` — the artifact produced by `run.py`; byte-identical across re-runs.
- `README.md` — this file.

## Inputs (read-only)

- `experiments/attributed_synthesis/pcv.py` — the pcv engine (imported, never modified).
- `experiments/accounting_familiar/ledger_real.json` — 200 real UK-gov transactions.
- `experiments/accounting_familiar/ledger_test_newdomain.json` — 120 additional transactions.

## Pre-registered bars (frozen in run.py before any run logic)

| Bar | Expected |
|---|---|
| part1 synthesis replay_ok | True |
| part1 synthesis n_orphans | 0 |
| part1 synthesis label | derived(trace-attached) |
| part2 deterministic | True |
| part2 params_attributed | True |
| part3 all_3_labels_correct | True |
| part3 never_crossed | True |
| part4 all_shas_unchanged | True |
| part4 nonaccounting replay_ok | True |

## Verdict

**ALL BARS PASS.**

Results from `results.json` (sha256: `83321e0f60c88e51ae187b73603c9b9aaa0f6b089ee553307bc4ddd7ded9eaaa`; byte-identical on second run):

### Part 1 — Cross-ledger synthesis

Top 5 categories by total spend (ledger_real.json, 200 txns):

| Category | Total (GBP) |
|---|---|
| OTHER ICT COSTS | 7,358,362.40 |
| TRAVEL BOOKING | 4,020,011.13 |
| TELECOMS - TELECOM RENTALS | 3,067,608.42 |
| PERSONNEL RELATED - PENSIONS PAYROLL CONTRACTOR (FIXED FEE) | 3,022,948.96 |
| OTHER PROFESSIONAL SERVICES | 2,204,563.30 |

Cross-ledger combined total (both files): replay_ok=True, 0 orphan values, label=derived(trace-attached).

### Part 2 — MUS sampling

- Materiality: 500,000 (auditor-set, pcv leaf)
- Interval: 500,000 (auditor-set, pcv leaf)
- Seed: 42 (auditor-set, pcv leaf)
- Sample size: 71 of 200 transactions
- Deterministic: True (same seed => identical selected set; confirmed by identical sha across two runs)
- All params attributed: True

### Part 3 — Audit envelope

| Disposition | Label | Query |
|---|---|---|
| VERIFIED | `verified-fact` | Amount for _transaction_ref=1037195989? → 65668.0 |
| DERIVED | `derived(trace-attached)` | Total spend for category 'OTHER ICT COSTS'? → 7,358,362.40 |
| REFUSED | `refused(unverifiable)` | Is supplier '4 NET' legitimate / was the payment fraudulent? |

Labels never crossed: confirmed by 6 cross-assertions in run.py (would raise AssertionError if violated).

### Part 4 — Universality guard

| Engine file | Expected SHA | Actual SHA | Unchanged |
|---|---|---|---|
| experiments/general_core/core.py | 7efaf4ac36129bbe | 7efaf4ac36129bbe | True |
| experiments/attributed_synthesis/pcv.py | 79b9cd915e626a5c | 79b9cd915e626a5c | True |
| experiments/dual_engine/dual_core.py | f300ca0bf16b5170 | f300ca0bf16b5170 | True |

Non-accounting domain-blind run: mean of 3 sensor/temperature readings (21.3, 19.8, 22.1 C) via pcv.combine('mean'). Result=21.066..., replay_ok=True, 0 orphans, label=derived(trace-attached). The engine operated identically on non-financial data.

## Determinism

`results.json` sha256 is identical across two independent runs:
`83321e0f60c88e51ae187b73603c9b9aaa0f6b089ee553307bc4ddd7ded9eaaa`
