Inspiration
Four hours is a short outage for the power grid. For a food truck, home baker, or neighborhood grocer, it can mean losing the refrigerated stock they planned to sell that day. The USDA says an unopened refrigerator keeps food cold for about four hours without power. That guidance gave us the name FourHour and a concrete problem to design around. USDA food safety guidance
We wanted to see whether a small food business could receive a payment automatically after a qualifying outage, without having to assemble a claim while dealing with spoiled stock and interrupted sales.
The hardest part was deciding what evidence should trigger that payment. A county-wide outage can leave an individual shop untouched. A phone that stops charging can indicate a local outage, or someone may simply have unplugged it. We built FourHour around the idea that these two signals can be more informative together, and then tested how much the second signal actually helped.
What it does
FourHour is a PayPal Sandbox prototype for automatic power-outage cover for small food sellers. It combines county outage data with a signed log from a device at the business. When the evidence meets the policy’s rules, FourHour creates a claim, sends a fixed PayPal payout, and shows the seller how the decision was made.
From quote to payout
| Step | What the seller experiences | What FourHour does |
|---|---|---|
| 1. Get a quote | Select a county and an amount of cover. See the monthly premium and how it was calculated. | Look up the county’s modeled risk and calculate the quote from the published pricing inputs. |
| 2. Approve PayPal | Approve saving a PayPal wallet and return to the policy page. | Exchange the approved setup token for a vaulted payment token and charge the first premium through PayPal Orders. |
| 3. Set up a witness | Register a phone or laptop that stays at the business. | Register its public key and verify signed log entries when they arrive. |
| 4. Evaluate the outage | Follow the county outage, the four-hour clock, and witness activity in the live replay. | Measure how long the county index stays above its thresholds and check for an overlapping witness outage. |
| 5. Follow the payout | See the rule that fired, the evidence behind it, and the payment status. | Record the decision, send an eligible payout, and update its status after PayPal confirmation. |
The county index measures the share of tracked customers without power. The witness records a local change in power or charging state. A qualifying witness outage lasts at least four hours and overlaps the qualifying county outage.
| Rule | Evidence | Outcome |
|---|---|---|
| R1 | At least 90% of county customers are out for four hours, and the witness confirms an overlapping outage of at least four hours. | Pays 60% of cover |
| R2 | The 90% threshold qualifies, and there is no witness log for the event. | Pays 30% of cover |
| R3 | The 20% threshold qualifies, the 90% threshold has yet to qualify, and the witness confirms an overlapping outage of at least four hours. | Pays 60% of cover |
| R4 | The 90% threshold qualifies and witness entries exist for the event, but they fail to show a qualifying outage. | Declined |
| R5 | The witness reports a four-hour outage with no overlapping county run at or above 20%. | Flagged for review, $0 |
The hosted demo replays the May 2024 Houston derecho using historical outage readings from Harris County. The county index peaks at about 27.5%, so the witness matters. With a qualifying witness log, rule R3 pays $30 on the simulated $50 policy. In the quiet-grid replay, a witness outage is flagged under R5 and pays $0. The outage readings are historical, the replay clock and policies are simulated, and the payments use PayPal Sandbox.
How we built it
Data, pricing, and claims
| Layer | Implementation |
|---|---|
| Outage data | We used DOE EAGLE-I data from Texas, Florida, and Illinois for 2014–2024. The Python pipeline converts 15-minute readings into county outage shares, reconstructs events, and records gaps and coverage. |
| Statistical models | We modeled event frequency and duration, tested how much county-level experience should influence pricing, searched for trigger thresholds, and simulated a portfolio of policies. |
| Model outputs | The pipeline exports versioned JSON artifacts for pricing, triggers, backtesting, solvency, basis risk, and data quality. Their provenance records the inputs and code revision behind the results. |
| Claims engine | A Go service evaluates the published rules, persists policy and claim state in SQLite, and sends updates to the browser through Server-Sent Events. |
| Witness | The browser uses WebCrypto to sign entries with an ECDSA P-256 key. Each entry includes a hash of the previous entry. The backend verifies signatures and the chain before accepting the log as evidence. |
| Frontend | React, TypeScript, and Vite power the quote flow, policy page, witness setup, live outage chart, claim view, and evidence pages. The operator view uses AG Grid for policies, claims, and the ledger. |
| Hosting | Render hosts the frontend as a static site and the Go API as a separate service. |
We fitted the US outage models on 2014–2022 and evaluated them on 2023–2024. The runtime decision is deterministic. Given the same policy, thresholds, and accepted evidence, the rules produce the same outcome. We used Codex to iterate on the frontend and test the quote, replay, and operator flows.
The monthly price combines expected qualifying events, the estimated chance the business is affected, the 60% payout share, a risk margin, and an expense load. In the prototype, $50 of cover in Harris County costs $1.36 per month, and the full four-hour payout is $30. The evidence page shows where those figures come from.
How PayPal fits into the flow
| PayPal capability | What we use it for |
|---|---|
| OAuth 2.0 | Authenticate the backend’s sandbox API requests. |
| Vault | Let a seller approve saving a wallet and give the backend a token for approved charges. |
| Orders v2 | Charge a premium against the saved wallet. The request ID is tied to the policy and billing period so a retry can reuse it. |
| Payouts | Send an approved claim payment. A stable sender batch ID identifies retries for the same policy, event, and payout tier. |
| Webhooks and payout polling | Verify incoming webhook signatures and reconcile payout status. Polling can confirm the payment before a webhook arrives. |
Money is stored in integer cents. The backend records payment intent before calling PayPal and uses database uniqueness constraints alongside PayPal request identifiers to guard against duplicate processing. The claim view keeps the decision and payment status visible. An approved claim can be awaiting confirmation, and a confirmed payout includes the PayPal batch and item identifiers.
Challenges we ran into
- County data has gaps and can briefly drop out during major storms. Our first reconstruction split Hurricane Beryl into two events. We revised the handling of gaps up to two hours and short, sharp drops followed by recovery. Beryl was in the evaluation period, so we disclose that it influenced the reconstruction rules even though its rows were excluded from model fitting.
- A signature establishes where an entry came from. A correctly signed report can still come from someone unplugging a charger. The rules require corroborating county evidence before a witness can contribute to a payout. Browsers that lack charger sensing use manual reports, which the prototype labels as self-reported and evaluates under the same rules.
- Different clocks drive the demo. A witness signs a report in real time, while the replay advances through a historical storm. We preserve the signed timestamp and map the report onto the replay clock for rule evaluation.
- An approved claim and a confirmed payout happen at different times. The hosted run confirmed the payout through polling before the webhook arrived. We kept both paths and made the distinction visible in the claim view.
- There were few qualifying events to learn from. After excluding low-coverage county-years, the frequency model had 34 qualifying training events. That limited what we could estimate reliably at county level and how much confidence we could put in the pricing.
Accomplishments that we're proud of
- We completed the payment loop in PayPal Sandbox. We demonstrated wallet approval and a premium charge, then replayed a historical storm and confirmed a $30 payout on a simulated policy. The quiet-grid case exercised the review path and produced no payment.
- We made claim decisions inspectable. A judge can open a claim and trace it back to the county readings, signed witness entries, rule, amount, and PayPal status.
- We tested consistency across the system. A parity test checks that the Go replay reproduces the Python pipeline’s outage runs for the derecho. A separate test checks that the payout schedule used for pricing matches what the claims engine pays.
- We published the model outputs and their caveats. The evidence page exposes the results, inputs, and data-quality checks, including where the statistical models showed little improvement and where the portfolio performed poorly.
What we learned
The witness can reduce basis risk, and its reliability matters
Basis risk is the gap between what happens at a particular business and what the outage index says should be paid. We measured it using Prayas Electricity Supply Monitoring Initiative data, which records power at individual premises in India. The evaluation covered 5,010 outages lasting at least four hours across eight districts.
| Payment approach | Premises outages missed | Payments made to premises that had power |
|---|---|---|
| District index alone | 70.4% | 35.3% |
| Index plus a perfect witness | 5.9% | 0.0% |
| Index plus witness, with 10% of logs missing | 10.9% | 1.7% |
| Index plus witness, with 30% of logs missing | 23.5% | 6.0% |
The miss rate uses eligible premises outages as its denominator. The wrong-payment rate uses payments made. The missing-log rows come from one simulated draw each.
The perfect witness was the premises’ own supply monitor, and that same monitor also contributed to the district index. When the audit removed each premises’ monitor from its own index, the perfect-witness miss rate rose to 17.1%. One district also accounted for about 71% of the observed outages. These results show how much witness quality and the construction of the index can affect the outcome. A field trial with US food sellers and actual witness devices would tell us how well the approach transfers. Prayas ESMI dataset
The pricing results showed where we needed more evidence
| Finding | What it means for FourHour |
|---|---|
| The negative-binomial frequency model performed essentially the same as the Poisson baseline. | The data gave us little reason to expect a more complex count model to improve predictions. |
| Every estimated county credibility weight was zero. | Offered counties use state-level rates. We withheld a quote for Cook County because its pricing group had no qualifying training event. |
| The simulated pool’s loss ratio was 0.00 in 2023 and 1.32 in 2024. | In 2024, two Harris County events drove 351 simulated claims, and the pool paid $1.32 for every $1 of premium. Two evaluation years leave substantial uncertainty. |
| The solvency simulation estimated a 12.3% chance that annual payouts would exceed available premium income, assuming zero starting capital. | Simulated losses came from one training storm year. The result is sensitive to the historical sample and starting-capital assumption. |
What's next for FourHour
- Evaluate finer-grained outage data. Test whether utility service-area or feeder-level data can capture localized outages that fall below the county trigger.
- Pilot a background witness. Measure how often a device stays connected, misses an outage, or reports one when the premises still has power. Use those measurements to revisit the rules for missing and self-reported logs.
- Validate pricing across more seasons and regions. Re-run the backtest with more storms, examine payment fees at small premium sizes, and test how capital needs change when multiple areas are affected.
- Work with a licensed carrier. Use field evidence to evaluate whether a carrier could offer the product and what changes the coverage, claims process, and operations would require.