AWS Builder Center
I let an AI read government records. Then I made it prove every sentence.

I let an AI read government records. Then I made it prove every sentence.

Building CivicProof for a hackathon: an agent that investigates public works from real government records, where a deterministic verifier throws away any claim whose quotation does not appear on the cited page. What Lambda Web Adapter, Cedar, DynamoDB conditional writes and CloudWatch EMF actually did for it, plus the three bugs that taught me the most, including 26 months of defect liability the code invented.

Last week a road near my place was dug up, patched, and broken again inside a month. The question I could not answer was the only one that mattered: was that road still under its defect liability period? If it was, the contractor has to repair it for free. If it was not, the ward has to pay again.
That fact exists. It is sitting in a government record. It is just not reachable by a person with a phone and a grievance.
So for the First Commit hackathon I built CivicProof: you file a report with a photo and a location, and an AI investigator searches real public records to identify the project, pull the contractor, the sanctioned cost and the completion date, and compute whether the maintenance window is still open.
The hard part was not getting an AI to answer. It was making sure the answer was true.

The rule the whole thing is built on

The AI proposes. Deterministic code verifies.
When the agent wants to state a fact, it cannot just say it. It has to submit a claim with a document ID, a page number and a verbatim quotation. Before that claim is ever shown to a user, plain TypeScript checks three things: that the document exists in the corpus, that the quoted string appears character for character on that exact page, and that the quotation actually contains the value being claimed.
If any check fails, the claim is thrown away. Not flagged, not shown with a confidence score. Thrown away.
That single rule changes what the product is. Every sentence on a CivicProof case page is clickable, and clicking it opens the government document with the quoted line highlighted. The user never has to trust the model. They can check.
The corpus behind it is real: 26 public documents, 853 pages, covering 790 public works projects in and around Bengaluru, and 7,677 reference facts. Every one of those facts is re-verified at build time. If a source document changes or goes missing, the build fails rather than quietly assuming the facts are still good.

Where the AWS pieces actually earned their place

I deployed on AWS SAM in ap-south-1, and four services did real work rather than decorative work.
AWS Lambda with the Lambda Web Adapter. This was the single best decision. A standard Next.js standalone build runs on Lambda unmodified, no framework specific adapter, no rewritten routes. The same server runs on my laptop and in production. Behind a Lambda Function URL in response streaming mode, the agent's reasoning trace streams to the browser as it happens, with no API Gateway and no WebSocket layer. For a product whose whole pitch is "watch it work", that mattered.
Amazon DynamoDB conditional writes. I use these for correctness, not storage. An investigation that gets interrupted, say the process dies mid run, must never sit in "running" forever with no way out. Optimistic locking on the run record is what makes an interrupted investigation recoverable instead of stuck. This is the kind of thing that looks like plumbing until the first time a judge refreshes a dead page.
Amazon CloudWatch Embedded Metric Format. Underrated. I emit a structured log line and get real metrics out of it: verifier acceptance rate, policy denials, rate limit waits, run duration. No PutMetricData calls, no extra client, no added latency. The dashboard is defined in the same SAM template as the function.
AWS Secrets Manager. The model key lives here. The Lambda role can read exactly one secret and nothing else, cached in process for fifteen minutes. The key never enters the repository, the bundle or the logs.
On the open source side, two AWS projects carried the agent itself. The Strands Agents SDK provides the loop, tool definitions and lifecycle hooks. And Cedar does something I have not seen enough of in agent demos: it authorizes every single tool call before it runs.
Concretely, the agent cannot fetch a record it never searched for. It cannot act on a case other than the one it is investigating. These are Cedar policies, evaluated in code, and when one denies a call the denial shows up in the visible trace. That is a real boundary, not a sentence in a system prompt asking the model to behave.

Three things that went wrong, and what they taught me

1. The code invented 26 months of defect liability.
An OMMAS record cell names both a physical completion date and a financial completion date. My date parser took the first date it found, positionally. The guard I had written checked whether the text mentioned "financial" without mentioning "physical", which can never fire on a cell that names both.
Result: a maintenance window computed as ending 2029-05-27 when the correct answer was 2027-03-05. The system confidently reported that a road was still under warranty for two extra years, and marked the answer "verified", because the quote was genuine. The quote was real. The interpretation was wrong.
The lesson is sharper than "test your date parsing". Verifying a quotation proves the text exists. It does not prove your code read the right field out of it. Those are two separate guarantees and I had conflated them.
2. The model manufactured conflicts out of formatting.
Gemini would extract the same fact twice from two documents, once as "12 months" and once as "1 year", and the conflict detector would flag a contradiction between two government sources. It was not a contradiction, it was two spellings of the same number. I had to normalize representations before comparing, while being careful not to swing the other way and suppress conflicts that are real. Hiding a genuine disagreement between two official records would be a much worse bug than showing a false one.
3. A private phone number went live on a public page.
A BBMP dataset appends contractors' mobile numbers to their names in the contractor column. Around 4,700 of them. They are technically public data. That does not make republishing them as a bulk greppable list acceptable. I now strip contact details at ingest, before anything is rendered, not at the display layer.
Public availability is not the same thing as consent to republish. If you are ingesting government open data, check what personal information is riding along in the columns you did not think about.

The thing I could not ship

I built a full fallback path: if the primary model hits its quota or fails, Amazon Bedrock with Amazon Nova continues the same investigation, keeping every fact already verified rather than restarting. It is implemented, it is tested against local stand-ins, and in this deployment it is switched off, because InvokeModel returns "Operation not allowed" on an account that is not yet verified for Bedrock model access.
The error message does not say that. That is my one piece of concrete feedback to the service team: an explicit error code and a visible verification status in the console would have saved me hours. I spent them debugging my own IAM policy, which was fine all along.

The part I would defend in a review

Unknown is a first class outcome. If the completion evidence is missing, the completion date is UNKNOWN, so the defect liability window is UNKNOWN, so the overall case is UNKNOWN. The UI then explains what is known, what is missing, why it matters and which document would resolve it.
That is deliberately less impressive than a confident answer. It is also the only version of this product that is safe to put in front of a citizen who might act on it. An evidence gap is not an invitation to infer. CivicProof does not accuse anyone. It establishes what the records support, and it is specific about where they stop.
Built with Next.js and TypeScript on AWS Lambda, DynamoDB, S3, Secrets Manager, Amazon Location Service and CloudWatch, deployed with AWS SAM, agent on the Strands Agents SDK with Cedar authorization.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article