Inspiration

Every US community water system has to file a baseline service line inventory by November 1, 2027 (40 CFR 141.80(a)(3)). Each line gets one of four labels: Lead, Galvanized requiring replacement (GRR), Non-lead, or Lead status unknown.

EPA's 2025 survey estimates 4 million lead service lines in the country. A quarter of them, 1 million, are lines utilities reported as "unknown" that EPA predicts are lead (EPA 7th DWINSA fact sheet, Nov 2025). About 81% of community water systems serve 3,300 people or fewer (EPA LCRI economic analysis, Oct 2024, p. 3-15). An AWWA cost study puts records review at about $6 per line for a 100,000-line utility and $30 per line for a 5,000-line one (a trendline estimate, AWWA 2022, Appendix K).

So the small systems pay the most per line, and the work is reading tap cards from 1931, permits from 1979 and field notes from last summer, then applying rules with traps in them. A lead gooseneck does not make a line lead. A galvanized pipe behind a lead line that was swapped for copper in 2016 still has to be replaced. A house built in 1995 tells you nothing about the pipe.

What it does

LineProof takes the records for one service line and returns its inventory category, the two sides of the line, the connector, and every step that led there. Each step names the rule and its source. Each fact links to the words in the record it came from. When the records don't settle it, LineProof says what would: which record to pull, or where to dig.

The demo opens on the test cases: a made-up district of 24 service lines, 12 cases restating published EPA and state examples, and the 16 blind holdout cases. The model output on that tab is Gemma's saved reply from the test run, and the page says so; the quote checker and the rules run live. You can switch any fact off, change the state's lead ban date, or tell it the state accepts staff statements, and the category follows. Each line also shows what plain Gemma, Gemma with the rules pasted in, and a keyword reader with no model would have answered. The second tab runs Gemma 4 on your own GPU on records you type. There is also a CSV export.

How we built it

  • The model reads. Gemma 4 E2B (4-bit) runs on the visitor's own GPU through WebLLM. It reads one record at a time and returns facts only: side of the line, material, installed / present / removed, date, and a quote. A grammar holds the output to that JSON shape. It never picks the category.
  • Code checks. A fact is dropped if its quote is not in the record, if the quote doesn't name the material claimed, or if a "lead" quote says "no lead". The side named in the quote ("meter to house") overrides the model's label. A date with no material only counts if the quote says the pipe was installed then. Staff memory, customer reports and prediction models are set aside unless the state approved them.
  • Rules decide. Twelve rules from 40 CFR 141.2 and 141.84 and EPA's inventory guidance are a few lines each in rules.js, with unit tests that feed them hand-written facts for the hardest cases.

Nothing leaves the browser, there is no server and no API key, and the build cost US$0.

Test results

Same model in every row, temperature 0. "Missed lead" counts Lead or GRR lines that came back Non-lead, the mistake that leaves a lead pipe in the ground.

Correct category (Lead or GRR called Non-lead) District sample (24) EPA & state examples (12) Blind holdout (16)
Gemma 4 E2B alone 10 (1) 4 (1) 7 (1)
Gemma 4 E2B with all 11 rules in the prompt 13 (2) 4 (2) 9 (2)
No model: keyword reader + LineProof rules 15 (0) 9 (0) 11 (0)
LineProof: Gemma reads, code checks and decides 21 (0) 11 (0) 12 (0)
  • District sample (24): written by me to cover each rule. I tuned on it, so it flatters LineProof.
  • EPA & state examples (12): each case restates a worked example from EPA or a state agency (Vermont, Nevada, California, Virginia, Washington, Maine), and the expected answer is the one that document gives.
  • Blind holdout (16): written by a separate agent that saw only the labeling guide, run once after the code was frozen. The labeling guide and the rules code are both my reading of the regulation, so the holdout tests how well the records are read, not whether that reading of the rules is right. The EPA & state set is the check on that.

The code was frozen at commit e7b9bd7 before the EPA/state and holdout runs. Under that code LineProof scored 9/12 on the EPA & state examples, with one missed lead, and 13/16 on the holdout. The EPA/state run exposed two bugs: a removal record didn't retire the older lead record, and a document's date was taken as an installation date. After fixing them, the same saved model replies score as in the table: 11/12 and 12/16 (the fix cost one holdout case). Both sets of numbers are in results.json.

The keyword reader in row 3 is the honest surprise. On short, clean records it comes close, which says most of the gain over plain Gemma comes from moving the decision into code. Where the model earns its place: across all 52 test cases, the keyword reader and LineProof disagree on 12. LineProof is right on 10, the keyword reader on 1, neither on 1. Two of them:

  • "Lead inspector M. Ortiz on site. Curb stop to meter is 1 in. copper." The keyword reader sees "lead" and calls the line Lead. Gemma reads copper on both sides, and LineProof answers Non-lead, the expected answer (district sample, 400 Upland Ave).
  • "saw lead svc main to meter when we swapped the corp stop, also a lead gooseneck at the main." The keyword reader files the whole sentence under the gooseneck, which doesn't count toward the category, and answers Unknown. Gemma splits it into a lead service line and a lead gooseneck, and LineProof answers Lead (blind holdout, 1507 Marlow Ave).

Both are on the site under "Where the model matters", and test/ui.test.js checks them against the saved replies.

The "rules in the prompt" row gets the same rules as 11 written points rather than the code's 12: R06 and R07 share one point, R11 is part of the combine order, and one point spells out that a galvanized utility side is non-lead.

Challenges

The laptop GPU is shared with other work, and WebGPU kept losing the device mid-run. The eval runner now catches a lost device, reloads the model and retries the call. The 2B model also stopped early when asked to read a whole case at once, so it now reads one record at a time, with two worked examples in the prompt and a grammar that blocks runaway output.

Accomplishments

With every rule pasted into its prompt, Gemma still called 2 Lead or GRR lines Non-lead on each test set. LineProof called none on the holdout, and every answer comes with the record line and the rule behind it.

What we learned

Pasting rules into a prompt did little for a small model: 4/12 with the rules against 4/12 without. Splitting the job, model reads and code decides, did far more than prompt wording. And the test set written by EPA and the states found real bugs my own cases never hit.

What's next

  • Add an OCR step so scanned and handwritten tap cards can go in directly.
  • Let a state load its own settings: ban date, pipe-size cutoffs, which sources count.
  • Export in the column layout of a state's inventory template.

Limits and responsible use

All records, addresses and the district in the demo are made up. LineProof prepares an inventory for staff and state review; it does not replace a field check and is not legal advice. Where EPA leaves a call to the state, it uses the state setting or answers Unknown. It reads typed text only. A live run can differ from the saved replies: a 2B model is sensitive to how a record is worded and labeled. When a reply doesn't hold up, the checker drops the fact and the answer leans cautious, usually Unknown, which sends the line to a person to check.

I am also entering this same project in the Silicon Valley Buildathon (https://silicon-valley-buildathon.devpost.com/). It is one codebase and one set of test results, not a separate build.

AI disclosure: I used an AI coding assistant while writing the code and this description.

Built With

Share this project:

Updates

Submission history