# My AI Wrote a Bug That Would Have Let Strangers Fake Your Safety Check-In

> Source: <https://dev.to/atomiccninja/my-ai-wrote-a-bug-that-would-have-let-strangers-fake-your-safety-check-in-1g16>
> Published: 2026-11-28 10:06:34+00:00

**Recommendation:** Convert each requirement into a property test and gate the coding agent on it, since example tests passed while properties exposed duplicate timestamps, dropped offline edits, and key-swapping check-ins.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

It's 6:41 PM on Halloween. Maya is somewhere on Blackwood Ridge. Her phone shows no service.

At home, Mom's phone shows nothing either. Every app they own died the second the signal did.

That's the moment I built for. Afterlife Kit is an open-source skeleton for apps that keep living when the network dies. I built it for #Kiroween with Kiro, a spec-driven AI IDE. This is the story of the four bugs the AI wrote, and how the specs caught every one before a user ever could.

Most apps treat the server as the truth and your phone as a window onto it. Lose the window and you lose everything.

Afterlife Kit flips that: **the device is the truth.** Every change is written to an operation log on the phone (IndexedDB) the instant you tap. When *any* phone catches a bar of signal, the changes travel through a ~100-line relay and merge on every other phone.

Two very different apps run on the same skeleton:

| 🦇 **Ghost Trail** | 🕯️ **Ledger After Dark** | 
|---|---|
| Group safety check-ins for no-signal hikes | Credit ledger for corner shops | 
| Real topo map, downloaded for offline use | Photo receipts on every entry | 
| Overdue alarm on every synced phone | Reminders on SMS, WhatsApp, LINE, WeChat | 
| Every check-in signed by the phone's own key | 10 languages, Arabic and Urdu right-to-left | 

I didn't start in a chat box. I started in:

.kiro/

├── steering/   product.md · tech.md · structure.md   ← the rules every agent run follows

├── specs/

│   ├── sync-core/    requirements (EARS) · design · tasks

│   └── ghost-trail/  requirements (EARS) · design · tasks

└── hooks/      tests on save · typecheck on stop · secret guard · boundary review

Requirements are written in EARS, so they're testable sentences:

*WHEN now > the next checkpoint's ETA + 15 min grace **THE SYSTEM SHALL** mark the member overdue.

The design turns those into **correctness properties**, and each property becomes a [fast-check](https://fast-check.dev) test that throws hundreds of random histories at the code.

Then I let Kiro's agent loose, headless, on a cheap model, one spec phase per run. A hook re-ran the property tests on every file save, and another blocked the agent from finishing while the types were broken.

The agent's code passed every example test. The properties did not pass.

The hybrid logical clock (HLC) is the heartbeat of the merge. Kiro's version could hand two phones the **same timestamp**, so a merge could silently pick the wrong value.

One property, *"receive always produces a clock strictly greater than both inputs"*, failed in three steps. The fix was the textbook HLC receive rule.

This one scared me. Three replicas, one with a clock 3 ms behind:

```
replica 2 writes + pushes → replica 0 pulls (cursor jumps ahead)
replica 1 writes (older clock) + pushes → replica 0 pulls → never sees it 💀
```

The relay was paging by the *phones'* clocks. The phone that was offline the longest (the exact user this kit exists for) lost its edits. The spec said to key batches by **server arrival time**. The property made the gap impossible to miss.

```
CP0 at 11:00, CP1 at 12:00. Hiker checks in at CP0 at 11:00. On time.
now = 11:12 → "OVERDUE" 🦇🦇🦇
```

The agent measured lateness from the *last check-in*, not the *next checkpoint's ETA*. Every hiker would have triggered a bat-swarm alarm 15 minutes after every check-in. Kiro's own seven properties passed. Three more properties written straight from the requirement text failed instantly.

Requirement 5 says **"Only you can check in as you."** Kiro implemented ECDSA signatures and five properties, all green.

I added a sixth: *a check-in is valid only if the signing key belongs to that member id.* It failed immediately. Ids were random, so anyone who could edit the shared member list could swap their own public key under Maya's id and sign "I'm OK" **as her**. On a safety app.

The fix: make ids self-certifying.

```
id = base64url(SHA-256(`${crv}:${x}:${y}`)).slice(0, 22)
```

Swap the key and you're out. Every phone checks it before trusting a signature.

Because it's Kiroween:

The whole thing (sync engine, two apps, 40 tests, 29 property checks) ran on Kiro's free credits. The specs did the thinking, so the model only had to type.

*Built for #Kiroween 2026 (Skeleton Crew). Map data © OpenStreetMap contributors, OpenTopoMap.*
