How WebReceipt works
A self-healing consumer evidence engine. It compiles public purchase journeys into one canonical Deal Contract, seals every claim with tamper-evident evidence, and verifies extraction against deterministic semantic invariants.
Core concepts
Deal Contract
One canonical economic schema (v1.1.0) compiled from any site: advertised price, checkout breakdown (base, fee items, mandatory fees, taxes, add-ons, discounts, final total), terms, the journey, and the evidence set — sealed with a contract hash.
Evidence
Each critical field carries a record: captured text, source URL, DOM path, journey step, collector version, timestamp and a SHA-256 hash. Screenshots are references, not proof — the hash is the proof.
Contract Integrity Engine
Eleven deterministic checks that catch wrong-but-valid extraction — where every field is populated but the numbers don't reconcile. A critical failure marks the contract invalid.
Deal Anomalies
Observed, not adjudicated: journey price increases, mandatory non-tax charges and taxes are surfaced as facts with context — never as legal conclusions.
Promise Diff
git diff for commercial promises. Compares two contracts and reports money, text, list and fee changes — e.g. 'Free cancellation' → 'Non-refundable'.
Self-Healing
When a redesign breaks extraction, an AI repair is proposed. WebReceipt treats the preview as untrusted: it must compile into the same Deal Contract and pass every critical invariant before it is approved and deployed.
Integrity checks
total_arithmeticbase + mandatoryFees + taxes + optionalAddons − discounts equals finalTotalfee_breakdownSum of required fee items equals the mandatory-fee totaldiscount_boundsDiscounts never exceed gross chargescurrency_consistencyEvery money field shares one currencyjourney_monotonicityFinal price is plausible after discountscritical_evidenceAdvertised price, base price, final total and cancellation all carry provenanceevidence_hashesEach evidence record hashes to its stored SHA-256contract_hashThe whole Deal Contract hashes to its stored sealevidence_linksEvery journey step resolves to a real evidence recordsource_urlsEvidence sources are HTTP(S) URLsjourney_completeJourney has comparable start and end observationsAPI reference
All routes run on the Node.js runtime and drive the same engine that powers the Console. Bodies are JSON. In this app the collector behind them is the simulator; the Bright Data adapter is exercised by the sponsor harness and the CLI runbook.
/api/observe→ ObserveResultTraverse the journey, compile the Deal Contract, run integrity and detect anomalies.
{ targetUrl?, mutation?="healthy", autoHeal?=false }/api/heal→ ObserveResultObserve with auto-heal on: propose a repair, verify the preview, then deploy if valid.
{ targetUrl?, mutation?="wrong-valid-total" }/api/diff→ DiffResultDiff two contracts — a simulated day +3, or the two most recent stored observations.
{ simulate?=true, targetUrl? }/api/stress→ StressRunRun the Chaos Checkout suite: inject mutations and measure detection and recovery.
{ mutations?: string[] }/api/state→ StoreStateStored contracts, events and stress runs.
/api/reset→ StoreStateClear stored state and reset the simulator.
Run it locally
npm install npm run dev # Next.js console at http://localhost:3000 npm run verify # engine checks: schema + unit tests + chaos suite
Ready to see it run?
Walk the full observe → break → heal → diff loop on live engine data.
