# CRM-002 test evidence

Run 2026-11-30 in Claude's cloud workspace. PHP 8.3.6, SQLite 3, MariaDB 10.11.14, headless Chrome (Playwright). All data is **synthetic** (`tests/fixtures.php`); no real lead, contact or provider data was used, and no external system was called.

| Suite | Result |
|---|---|
| A: rules + metrics on **SQLite** (31) and B: real `api.php` over HTTP (13) | **44/44 pass** |
| A + B with Part A on **MariaDB 10.11** (MySQL dialect used by cPanel) | **44/44 pass** |
| U: browser test of `index.html` + `api.php` | **15/15 pass** |
| Migration re-run twice + rollback on MariaDB | Pass: only `crm_*` dropped; pre-existing `founders` table and row intact (`evidence/rollback-check.txt`) |

Reproduce: `php tests/run_tests.php` (add `CRM_TEST_DSN`, `CRM_TEST_USER`, `CRM_TEST_PASS` for MySQL), then `php tests/seed_ui.php /tmp/ui.sqlite /tmp/ui_cfg.php > /tmp/obs.json`, start `CRM_TEST_CONFIG=/tmp/ui_cfg.php CRM_TEST_TODAY=2026-11-30 php -S 127.0.0.1:8940 -t .` and run `node tests/ui_test.mjs http://127.0.0.1:8940 /tmp/ui.sqlite /tmp/obs.json tests/evidence`.

## What the CEO requirements map to

| Requirement | Test(s) |
|---|---|
| Conflicting source observations retained | A03, B07, U02 |
| Correction appends; original provenance never erased | A11, A12, A28, U06 |
| Undo via audit event, no deletes; role limits on undo | A13–A15, U07 |
| Repeat clicks not double counted; idempotent writes | A05–A07, A22, B06, U04, U05 (response lost after save → Retry → exactly 1 event) |
| No answer / no reply = inconclusive, never inaccurate | A09, A10, B08, U08 |
| Provider claim vs independent check | A17, A20 |
| Never auto-unsuppress on correction | A16 |
| Permissions (viewer/verifier/admin), CSRF, session, brute force | A08, B03–B05, B10, B12, U12, U13 |
| Visible failure state | U05 (screenshot 03) |
| Completeness, coverage, accuracy with n and 95% CI, stale/unknown | A10, A22, A23, U10 |
| Usable unique leads, duplicate rate, cost per usable lead incl. rework | A20, A24 |
| Unknown separate from zero | A10, A24, U10 |
| Pipeline, next actions, stage aging, recurring revenue, churn, renewals | A25 |
| 22-day scenario (33,000 target, Lead Carrot $212.50/25,000/18,750 @ unverified 75%) | A27 |
| Chart totals reconcile to source records (independent SQL recomputation) | A21 |
| Synthetic fixtures excluded in production | A26, B09, B13, U14 |
| Existing Leads preserved, read by field ID only | A30, B11 |
| CRM-001 acceptance = config-only mapping | A31 |
| XSS safety | U11 |

## Not verified (needs the live environment)

- Live `api.airtable.com` calls (Leads tab, CRM-001 mapping): the workspace's outbound access is restricted; adapter tested with an injected transport.
- Production PHP version, `pdo_mysql`, disk, and that cPanel Apache honors the two `.htaccess` deny files (DEPLOY step 6 checks this).
- Airtable plan tier / record count for the base.
- Any provider integration (Rosie, Apollo, Lead Carrot, Reply.io, Stripe, n8n): none are connected; all are off by design.

## Part A + B (SQLite)

| Result | Test | Detail |
|---|---|---|
| PASS | A01 schema migrates and re-runs idempotently | sqlite, crm_* tables: 11 |
| PASS | A02 synthetic fixtures load | 35 observations, 11 contacts |
| PASS | A03 conflicting sources retained side by side (con_1 email: Apollo vs Lead Carrot) | {"apollo":"dana@sla.example.org","leadcarrot":"dreyes@sla.example.org"} |
| PASS | A04 one-click "correct" writes an independent accurate event | vev_165217de74e108d89a32 |
| PASS | A05 repeat click (new key, same person, same verdict) is collapsed: no new event, not double counted |  |
| PASS | A06 replayed idempotency key returns the original event and writes nothing |  |
| PASS | A07 same key reused for a different observation is rejected (409) | Idempotency key already used for a different write. |
| PASS | A08 viewer role cannot verify (403) and the denial is audited |  |
| PASS | A09 "no answer" cannot be recorded as inaccurate (422) | No answer / no reply is inconclusive, not inaccurate. |
| PASS | A10 "no answer" recorded as inconclusive and excluded from accuracy | leadcarrot/phone accuracy = Unknown (n=0), inconclusive=1 |
| PASS | A11 correction appends a new observation; the provider original is unchanged | original "Treasurer" kept; correction obs_3199bbdcfd486e8865db |
| PASS | A12 a correction must accompany "inaccurate" and must differ from the original |  |
| PASS | A13 another verifier cannot undo my verdict (403); admin can, as a new audit event |  |
| PASS | A14 withdrawn correction drops out of reports; undo of undo and double undo rejected |  |
| PASS | A15 re-correct after undo, then verifier undoes own verdict (allowed) |  |
| PASS | A16 verifying a suppressed contact never unsuppresses it and never makes it usable |  |
| PASS | A17 "provider says verified" is a provider claim, not an independent check |  |
| PASS | A18 stale verdict overrides an earlier accurate and leaves accuracy |  |
| PASS | A19 more independent checks for a realistic mix | 8 more verdicts |
| PASS | A20 usable unique leads: gates for duplicate, suppression, opt-out and provider-only support | independent: con_1, con_4, con_5, con_8, con_p1; claimed: con_7 |
| PASS | A21 chart reconciliation: report totals equal an independent SQL recomputation | 21 provider/batch/field cells match; 37 active observations |
| PASS | A22 accuracy = accurate / conclusive with Wilson interval; repeat checks counted once | apollo/email 4/4, 95% CI 0.51–1.00 |
| PASS | A23 completeness and expected-missing fields |  |
| PASS | A24 cost per usable lead includes list, enrichment and human rework; unknown cost stays unknown | Lead Carrot: $212.50 + $0 + 16 min × $30/h = $220.50 per 1 usable lead |
| PASS | A25 pipeline: MRR, churn, renewals, failed payments, overdue and missing next actions |  |
| PASS | A26 production mode excludes every synthetic row | contacts 2, orgs 2, MRR $5,500 |
| PASS | A27 22-day scenario math |  |
| PASS | A28 append-only: no UPDATE or DELETE path exists for observations or verification events |  |
| PASS | A29 n8n stays off by default; HMAC signature is deterministic |  |
| PASS | A30 Airtable Leads adapter maps field IDs and drops Test Record rows in production |  |
| PASS | A31 CRM-001 mapping: Airtable entity rows map to contract columns via config only |  |
| PASS | B01 status before sign-in: configured, not signed in; data returns 401 |  |
| PASS | B02 GET login → 405; wrong password → 401 |  |
| PASS | B03 session cookie is HttpOnly, SameSite=Strict, scoped to /command/crm/ |  |
| PASS | B04 viewer can read every view but cannot write (403) | Your role can view but not verify. |
| PASS | B05 POST without the CSRF header is refused (403) | Session check failed. Reload the page. |
| PASS | B06 verifier write over HTTP; retry with same key is a replay (no duplicate) |  |
| PASS | B07 contact detail shows provenance, conflict flag and the event trail |  |
| PASS | B08 no-answer as inaccurate refused over HTTP with a clear message | No answer / no reply is inconclusive, not inaccurate. |
| PASS | B09 staging toggle: test=0 hides synthetic rows |  |
| PASS | B10 brute force: 10 failed logins for a username → 429 |  |
| PASS | B11 Inbound leads tab reports "not configured" instead of failing when no Airtable token |  |
| PASS | B12 logout ends the session |  |
| PASS | B13 production mode: synthetic excluded even if the client asks for test=1 |  |

## Part U (browser)

| Result | Test | Detail |
|---|---|---|
| PASS | U01 sign in as verifier; overview renders KPIs, charts and staging banner |  |
| PASS | U02 contact drawer shows each source side by side with a "sources disagree" flag |  |
| PASS | U03 one click on ✓ saves; the row shows "Saved." and the pill turns accurate | 1 event |
| PASS | U04 clicking ✓ again does not count twice | Same verdict already recorded by you; not counted twice. |
| PASS | U05 response lost after the server saved: visible failure, Retry, and still exactly one event | Not confirmed: Network error, so the server did not confirm. Retry is safe: it cannot create a duplicate. Retry → Already saved (no duplicat |
| PASS | U06 "More" → Wrong + corrected value appends a correction; original kept |  |
| PASS | U07 Undo is offered on my own verdict and records an undo event |  |
| PASS | U08 "No answer" via More is saved as inconclusive | {"verdict":"inconclusive","reason_code":"no_reply","method":"email"} |
| PASS | U09 Lead data quality, pipeline, revenue, next actions, integrations and audit tabs render |  |
| PASS | U10 Unknown is shown, not zero, where there is no data |  |
| PASS | U11 XSS probe in an organization name is rendered as text |  |
| PASS | U12 viewer sees data but no verification controls |  |
| PASS | U13 admin sees the audit trail of every write |  |
| PASS | U14 production-like toggle: hiding synthetic fixtures leaves only non-test rows |  |
| PASS | U15 no JavaScript errors during the run |  |

Screenshots: `evidence/01-overview.png` … `12-audit.png`.
