AWS Builder Center

Building a civic agent that cannot be lied to: Cedar, ray casting, and 225 BBMP wards

Bengaluru's civic complaints get closed by contractors who never did the work. We built NammaFix AI for the AWS × WeMakeDevs First Commit hackathon, and the interesting part wasn't the AI - it was making resolution fail closed with Cedar, ray casting over 225 ward polygons, and a CV check that refuses to be fooled.

Bengaluru has a specific kind of heartbreak. You report a pothole on Outer Ring Road. Three weeks later the complaint is marked Resolved. You ride past it the next morning and it is still there, still deep enough to swallow an Activa, still exactly as unrepaired as the day you photographed it.
Somebody closed that ticket. Somebody attached proof. And in a depressing number of cases that "proof" is the citizen's own original photo, re-uploaded by the contractor who was supposed to fix it.
This is the ghost resolution, and it is why we built TrueFix AI during the AWS × WeMakeDevs First Commit hackathon.
It is also why the most interesting part of this project is not the AI. It's a policy file.

The problem is not that citizens can't report things

Bengaluru already has BBMP Sahaaya. Citizens report constantly. Reporting works fine.
What breaks is everything after it.
Ghost resolutions. A complaint closes because someone clicked a checkbox. The proof is unverified and frequently a duplicate of the original photo.
Jurisdictional ping-pong. Is this BBMP Roads, BWSSB, BESCOM, or Solid Waste? Ward boundaries get guessed by hand, so complaints bounce between departments for weeks while nobody owns them.
The language gap. A complaint filed in fluent commuter English lands on the desk of a ward engineer working in Kannada. A Kannada voice complaint from a resident arrives with no structured metadata at all. Both lose something in transit.
Three distinct failures, none of which are fixed by adding a chatbot. We know this because our first instinct was to add a chatbot.

The insight: resolution should be something the system refuses, not something a human asserts

Here is the decision the whole project hangs on.
In the existing flow, "Resolved" is a claim. Someone with the right login says it, and it becomes true.
In NammaFix, "Resolved" is a grant. The system evaluates whether the evidence justifies the state change, and when it cannot decide, it says no.
That inversion from assertion to authorization is exactly what Cedar exists for. Cedar being on the First Commit Build It stack was the nudge we needed to stop scattering  if (user.role === 'contractor')  across four files and start writing the rule down in one place, as data.
The anti-fraud rule lives in  policies/nammafix.cedar :
cedar
// A report cannot be resolved without genuine after-evidence
// and a known owner.
forbid (
principal,
action == Action::"resolveReport",
resource
)
unless {
resource.hasAfterPhoto &&
resource.evidenceSimilarity < 0.95 &&
resource.wardId != "UNASSIGNED"
};
Three things about that matter more than they look.
It is  forbid ... unless , not  permit ... when . In Cedar, forbid always beats permit. Written this way, the absence of evidence denies the action. Add a new code path six months from now that forgets to check the photo, and resolution still fails. The default is no, and the default survives your own future carelessness.
It is data, not code. We changed the similarity threshold four times during the hackathon by editing a text file. No rebuild, no redeploy, no chance of a stale check surviving in a branch nobody grepped.
It is testable in a way if-statements are not. Cedar is deterministic, so a policy test is a table of request-and-expected-decision rows. Eight of our 43 tests are exactly that, and they run in milliseconds.
The production mapping stays clean: locally we evaluate policies in  server/cedar.ts ; in the cloud the identical policy text goes to Amazon Verified Permissions behind an API Gateway authorizer. Same file, different evaluator. That is the part that convinced us this wasn't a weekend toy.

What actually fought back

Ray casting was easy. The polygons were not.

We map GPS coordinates to one of the 225 wards from the official 2023 BBMP delimitation GeoJSON using server-side ray-casting point-in-polygon. The algorithm is thirty lines and gets taught in every graphics course.
What nobody teaches you is that municipal GIS data is a geography, not a dataset. Wards share borders. Polygon winding order is not consistent. A point on Sarjapur Road can sit on a boundary with genuine ambiguity, and "genuinely ambiguous" is not a value your schema was designed to hold.
We ended up treating  UNASSIGNED  as a first-class state rather than an error and then, crucially, adding it to the Cedar policy above. A report that cannot be assigned to a ward cannot be resolved. If nobody knows whose problem it is, nobody gets to declare it fixed.
That rule came out of a bug. It stayed because it turned out to be correct.

"Is this the same photo?" is a much harder question than it sounds

The anti-fraud check compares before and after evidence and rejects submissions that are too similar. Straightforward in principle.
In practice, a genuinely repaired pothole photographed from the same angle in the same light is mostly the same image. Same road, same kerb, same lamp post, same auto parked in the background. Only the patch of asphalt changed maybe four percent of the pixels.
So the threshold fights itself. Too strict and you reject honest ward engineers. Too loose and the contractor crops the original by two pixels and strolls through.
We settled on a similarity ceiling that rejects near-duplicates, plus a hard reject on byte-identical files, and we deliberately priced a false rejection as far cheaper than a false accept. Asking an engineer to retake a photo is an annoyance. A ghost resolution is a pothole that survives another monsoon.
In production this comparison is Amazon Rekognition doing the job properly. Our local heuristic is a stand-in, and the README says so rather than pretending otherwise.

Duplicate detection was our favourite accident

Forty citizens report the same crater. The old system opens forty tickets.
We combine Haversine spherical distance within a 500 m radius with Dice text-overlap similarity, structured as an OpenSearch  geo_distance  filter plus a  multi_match  BM25 query. It runs locally against a Query DSL–compatible engine in  server/opensearch.ts  and maps one-to-one onto a managed Amazon OpenSearch Service cluster with  geo_point  indexing.
The pleasant surprise was this: consolidating forty reports into one does not merely reduce noise, it creates a signal. Forty citizens reporting the same crater is a far stronger urgency indicator than forty separate tickets, because forty tickets look like forty small problems instead of one large one.
We did not design that. We noticed it on the dashboard and then claimed we had meant it all along.

SAM Local is the reason we slept

Three Lambda handlers transcribe, route, verify defined in  template.yaml  and invocable with  sam local invoke . No AWS account, no card, no bill.
Deploy-to-test cycles are where hackathon hours go to die. We had none of them.

What I would do differently

Write the Cedar policies first. We wrote them on day two, after building the resolution flow, then spent real time deleting authorization logic we had already scattered around. The policy file should have been the first file in the repository.
Instrument the rejections from hour one. The single most persuasive number we have is how many resolution attempts the policy engine blocked. We started counting late and had to backfill from logs, which is a bad way to spend a Sunday morning.
Decide the name before the repo. Ours is called one thing and the product is called another, which is the sort of detail that costs you nothing until someone tries to clone it.

What I actually learned

Three things I did not know on Thursday morning.
Cedar's  forbid  beating  permit  is a design philosophy, not a detail. It lets you express safety as a rule that outlives your own attention span. I had been writing authorization backwards for two years without noticing.
Externalising authorization changes how a team argues about a feature. "Should a contractor be able to close a ticket without a photo?" stopped being a code review thread and became a one-line diff in a file a non-engineer could read out loud.
Fail-closed is a product decision before it is an engineering one. Deciding that an unassignable report cannot be resolved was technically three words in a policy. It was also the most opinionated thing in the entire project.



Try to break it

bash
git clone https://github.com/pallaviXD/TrueFix-AI.git
cd TrueFix-AI
pnpm install
pnpm dev:server
Then:
  •  /upload  - report something with a photo and a voice note
  •  /resolve  - try to close it by re-uploading the same photo, and watch it refuse
  •  /dashboard  - ward routing and duplicate consolidation
  •  pnpm test  - 43 tests, eight of which are Cedar policy assertions
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