The short version, for everyone: Kengele is a free, open-source alarm for activists. If an activist stops checking in, their trusted contacts are alerted. The hard part is that governments switch the internet off at exactly the moments abductions happen, and during a shutdown everyone goes quiet. This post walks through the Go code that tells "the activist went silent" apart from "the network went silent", with a scenario you can run on your own machine.
Kengele (Swahili for "bell") is an alarm for activists in East Africa. Ukinyamaza, kengele inalia: "if you go quiet, the bell rings." An activist sets a watch window before a protest, a court date or a border crossing ("2pm to 10pm, check in every 90 minutes"). Their check-ins go to three to five guardians. If a check-in does not arrive, each guardian's device raises the alarm on its own. There is no Kengele server to seize or switch off.
altradits / kengele
An alarm for when an activist goes missing. No servers, works through shutdowns. Swahili first.
Kengele
When an activist goes silent, the right people know within minutes, and nobody can switch the alarm off.
Ukinyamaza, kengele inalia. ("If you go quiet, the bell rings.")
Warning
Status: design stage. Not for real use. There is no working app yet. Do not rely on Kengele to protect anyone until an independent security review is complete and published here. People's lives may depend on this tool, so we will not cut corners to ship it sooner.
Why
When an activist disappears, how fast the public finds out often decides how quickly they are freed.
- In Kenya, more than 80 people were abducted or forcibly disappeared after the 2024 protests. In January 2025, abducted young men were released within hours of public outcry.
- Boniface Mwangi and Agather Atuhaire, detained in Tanzania in May 2025, were released after their disappearance became public.
- Governments switch networks off when it…
Contents
- Why ten lines is not enough
- A passive engine with no goroutines
- The watch window and seven states
- Pausing per route, not per network
- The return window
- Run it yourself: an election-day shutdown
- Mass silence, stuck probes and going dark
- Late messages, replays and testing
- What is still open
At its core that is a dead man's switch, and a dead man's switch sounds like ten lines of code:
if time.Since(lastCheckIn) > interval+grace { raiseAlarm() } This post is about why the real one is 775 lines, and why every one of those lines exists because of a specific way people get hurt.
Kengele is still in design and not for real use until an independent security review is published. Everything below is code you can read and run today, at commit e10d277.
Why ten lines is not enough
The naive version fails in four ways that matter in Kenya, Uganda and Tanzania.
1. Shutdowns make everyone silent at once. Uganda ordered the internet off on 13 January 2026, effective 6pm, two days before its election. Tanzania did the same in October 2025. With the naive code, every activist under watch misses their deadline in the same minute and every guardian gets an alarm. Hundreds of false public alarms would destroy trust in the tool on its first real day.
2. But silence during a shutdown can also be real. Abductions happen during shutdowns. If we simply ignore missed check-ins while the network is down, the alarm is useless exactly when it is needed. The alarm must fire the minute the network comes back if the activist still has not checked in, not days later when someone finally notices.
3. Shutdowns are partial. In Tanzania in 2025, mobile data went dark but SMS mostly kept working. An activist who has the encrypted SMS fallback turned on can still check in. Their clock should keep running. An activist who only uses the internet path should pause. One global "online" flag gets both wrong.
4. Messages arrive late, and the late arrival is not the activist's fault. A check-in can be carried phone to phone over Bluetooth and delivered hours later. It still carries the activist's signed original time. The deadline engine must judge a check-in by when it was signed, not when it arrived, and still tell guardians it was late so they verify.
On top of that, an attacker with the activist's phone will try to abuse every one of these exceptions to keep the alarm quiet. Every pause has to be bounded.
The design rule: a passive engine with no goroutines
The first decision shapes everything else. The engine in internal/schedule owns no clock, no timers and no goroutines. The caller feeds it three things:
| Input | Method | Meaning |
|---|---|---|
| Time passing | Tick(now) | "It is now now. What changed?" |
| Connectivity | SetTransport(now, kind, up) | "Nostr (or SMS) just went up or down for this guardian" |
| Messages | Observe(now, via, event) | "This verified event arrived over this route" |
Every call returns a slice of Notice values (started, reminder, missed, alarm, paused, resumed, and so on). The caller decides what to do with them: show a notification, start the guardian confirmation flow, write a log.
// The engine is passive and has no goroutines: the caller feeds it the // time (Tick), connectivity changes (SetTransport, SetOnline) and opened // messages (Observe), and acts on the Notices it returns. That keeps it // deterministic under a fake clock. Why this matters:
- Determinism. Given the same sequence of calls, you always get the same notices. There is no race between a timer firing and a message arriving, because there are no timers.
- Testability. A test can walk through a whole election day in microseconds by calling
Tickwith made-up times. The test suite does exactly that: dozens of scenarios run in well under a second. - Portability. The engine has no opinion about how time is delivered. The Go watcher an organisation can host (
cmd/kengele-watcher) drives it from a ticker; the Android guardian app, still being built, can drive the same rules from its own scheduler.
There is even a test that guards the rule itself, so nobody can quietly add a background goroutine later:
TestNoGoroutines (click to expand)func TestNoGoroutines(t *testing.T) { before := runtime.NumGoroutine() e := New(Config{}, t0) for i := 0; i < 50; i++ { _ = e.Watch(key(i), window()) } for m := 0; m < 600; m += 5 { e.Tick(at(m)) if m == 200 { e.SetOnline(at(m), false) } if m == 260 { e.SetOnline(at(m), true) } } if after := runtime.NumGoroutine(); after > before { t.Errorf("goroutines: %d before, %d after", before, after) } } One more small rule: time never runs backwards inside the engine. If a caller passes a now earlier than the last one (a phone clock correction, for example), Tick keeps the later time.
if now.Before(e.now) { now = e.now // time never runs backwards inside the engine } The watch window
A watch is a Window:
type Window struct { Start, End time.Time Interval time.Duration // check in every Interval Grace time.Duration // late after due + Grace Reminder time.Duration // remind this long before due } Validate refuses windows that cannot work: no start or end, end before start, a non-positive interval, negative grace, or a reminder that is not shorter than the interval.
The deadline after any accepted check-in is computed by one small function:
func (e *Engine) setDeadline(t *tracker, from time.Time) { due := from.Add(t.w.Interval) if due.After(t.w.End) { due = t.w.End } t.missAt = due.Add(t.w.Grace) t.reminded = false t.returnGranted = false } Three details are worth noticing:
-
fromis the signed time of the check-in, not the arrival time. A check-in signed at 15:20 and delivered at 15:50 still sets the next deadline from 15:20. - The last deadline is clamped to the end of the window, so the activist does not have to check in after the protest is over just because the arithmetic said so.
-
returnGrantedresets on every accepted check-in. Hold that thought; it is the defence against a flapping network.
Seven states
Each watched activist has a tracker with one of seven states:
| State | Meaning |
|---|---|
inactive | The window has not started |
waiting | The next check-in is not yet due |
reminder | The check-in is close to due or inside its grace period |
missed | A deadline passed while the network was up. Level 1: guardians are told privately |
alarm | A duress check-in or panic arrived. Top level |
paused | Every route this activist uses is down (or a mass-silence hold is in force) |
cleared | The window ended with a final check-in, or the guardians stood down |
Two transitions are deliberately missing.
A check-in cannot cancel an alarm. Once a duress check-in or panic has arrived, a normal check-in is ignored:
case t.state == StateInactive, t.state == StateAlarm, t.state == StateCleared: return nil // a check-in cannot cancel an alarm; only all clear can If captors hold the activist, they can make the activist check in. That must not undo the alarm the activist raised a minute earlier.
The activist's own all-clear cannot end a Level 1 alarm. This was the subject of my previous post:
Before Level 1, an all-clear from the activist ends the watch like a final check-in. From Level 1 up, it is recorded and shown to guardians ("the activist says they are safe") but ends nothing. Only k guardians, after a voice or video call, can stand the alarm down through StandDown.
Pausing per route, not per network
The engine tracks connectivity per transport. Today there are two, defined in internal/transport/kind.go:
const ( Unknown Kind = iota // proves nothing about any route Nostr // gift-wrapped events through public relays SMS // the encrypted two-part SMS fallback Mesh // reserved for the Bluetooth mesh (v0.2) ) Each activist's plan lists the routes they use. The default is Nostr only; SMS is opt-in because SMS exposes metadata (who texted whom) to the phone company. The engine's rule is:
An activist's clock pauses only when every route they use is down, and resumes when one of them comes back.
// reachable reports whether at least one of t's transports is up. func (e *Engine) reachable(t *tracker) bool { for _, k := range t.via { if e.up[k] { return true } } return false } When a route goes down, SetTransport first settles anything already due (so an alarm that was due a second before the outage still fires), then pauses every activist who is now unreachable:
if !up { out = e.Tick(now) // settle anything already due before pausing e.up[k] = false for _, a := range e.order { t := e.acts[a] if t.offline || e.reachable(t) { continue } t.offline, t.offlineAt, t.stillAt = true, e.now, e.now ... if t.state == StateWaiting || t.state == StateReminder { t.resume, t.state = t.state, StatePaused out = append(out, Notice{Kind: NoticePaused, ...}) } } return out } Note what is not paused: an activist already in missed or alarm. A shutdown never downgrades an alarm.
The return window: firing the minute the network is back
When a route returns, each activist who was paused resumes. Two cases:
- The deadline fell inside the outage. The activist could not have checked in. They get a return window (2 hours by default) from the moment the network came back.
- The deadline is still in the future. It moves forward by the length of the outage, so the activist gets exactly the time they lost.
if !t.missAt.After(now) && !t.returnGranted { t.missAt = now.Add(e.cfg.ReturnWindow) t.returnGranted = true } else { t.missAt = t.missAt.Add(outage) } The returnGranted flag is the important part. Without it, an attacker (or just a bad connection) could flap the network up and down, and every "up" would grant another two hours. One check-in cycle gets the return window at most once. The test for it reads like a story:
{ name: "flapping network cannot stretch one deadline again and again", steps: []step{ tick(0), offline(60), online(120), // deadline +105 in outage -> +240, return window used offline(130), online(135), // 5 min outage -> +245 offline(200), online(260), // +245 passed in outage, but window already used -> +305 tick(304), tick(305), }, want: []want{{0, StateMissed, 305}}, }, The third outage does not grant a fresh two hours. It only adds back the 60 minutes that were actually lost. At +305 minutes the alarm fires.
Run it yourself: an election-day shutdown
Here is a scenario with two activists. Amina has the SMS fallback turned on. Baraka uses Nostr only. The window runs 14:00 to 22:00 with a check-in every 90 minutes, 15 minutes of grace and a 10-minute reminder. At 15:40 the internet is switched off. SMS keeps working. At 19:00 the internet comes back.
Save this as internal/schedule/blog_example_test.go in a clone of the repo:
package schedule import ( "fmt" "time" "github.com/altradits/kengele/internal/message" "github.com/altradits/kengele/internal/transport" ) func Example_shutdown() { start := time.Date(2026, 1, 15, 14, 0, 0, 0, time.UTC) m := func(min int) time.Time { return start.Add(time.Duration(min) * time.Minute) } amina, baraka := [32]byte{1}, [32]byte{2} names := map[[32]byte]string{amina: "Amina", baraka: "Baraka"} show := func(ns []Notice) { for _, n := range ns { fmt.Printf("%s %-6s %-9s next deadline %s\n", n.At.Format("15:04"), names[n.Activist], n.Kind, n.Deadline.Format("15:04")) } } checkIn := func(who [32]byte, min int, seq uint32) message.Event { return message.Event{Kind: message.KindCheckIn, CreatedAt: m(min), Seq: seq, Signer: who} } w := Window{Start: start, End: m(480), Interval: 90 * time.Minute, Grace: 15 * time.Minute, Reminder: 10 * time.Minute} e := New(Config{}, start) _ = e.Watch(amina, w, transport.Nostr, transport.SMS) // SMS fallback on _ = e.Watch(baraka, w) // Nostr only for min := 0; min <= 420; min++ { // tick once a minute (kengele-watcher defaults to every 30s) switch min { case 80: show(e.Observe(m(min), transport.Nostr, checkIn(amina, min, 1))) case 100: show(e.SetTransport(m(min), transport.Nostr, false)) // internet switched off case 170: show(e.Observe(m(min), transport.SMS, checkIn(amina, min, 2))) // Amina checks in by SMS case 300: show(e.SetTransport(m(min), transport.Nostr, true)) // internet back default: show(e.Tick(m(min))) } } // Output: // 14:00 Amina started next deadline 15:45 // 14:00 Baraka started next deadline 15:45 // 15:20 Amina reminder next deadline 15:45 // 15:20 Baraka reminder next deadline 15:45 // 15:40 Baraka paused next deadline 15:45 // 16:40 Amina reminder next deadline 17:05 // 18:10 Amina reminder next deadline 18:35 // 18:35 Amina missed next deadline 18:35 // 19:00 Baraka resumed next deadline 21:00 // 20:35 Baraka reminder next deadline 21:00 // 21:00 Baraka missed next deadline 21:00 } Then:
git clone https://github.com/altradits/kengele cd kengele # save the file above as internal/schedule/blog_example_test.go go test -race -run Example_shutdown -v ./internal/schedule Our run (Go 1.26.5, macOS arm64):
=== RUN Example_shutdown --- PASS: Example_shutdown (0.00s) PASS ok github.com/altradits/kengele/internal/schedule 1.555s Read the output line by line, because every line is a design decision:
- 15:20. Both get a reminder (due 15:30, reminder 10 minutes before). Amina checks in over Nostr in the same minute, so her next deadline moves to 15:20 + 90 + 15 = 17:05. Baraka does not check in.
- 15:40. The internet goes off. Baraka pauses, because Nostr is his only route. His 15:45 deadline is frozen. Amina does not pause, because SMS still works for her. Her clock keeps running.
- 16:40 and 16:50. Amina gets her reminder and checks in by SMS at 16:50. That check-in proves only that SMS works; it says nothing about Nostr. Her next deadline becomes 18:35.
- 18:35. Amina missed. The internet is still off, but she had a working route and did not use it. That is a real missed check-in, and it is raised as one. This is the behaviour the single "online" flag would get wrong: it would have paused her too.
- 19:00. The internet is back. Baraka's 15:45 deadline fell inside the outage, so he gets the return window: 21:00.
- 21:00. Baraka missed. He had two full hours of working internet and did not check in. The alarm fires at a predictable, explainable time, not days later.
Mass silence: when the probe has not noticed the shutdown yet
SetTransport depends on something telling the engine that a route is down. In the watcher, that signal comes from the Nostr transport's relay reachability (a Connectivity callback reporting how many relays answered). But a shutdown can be partial in ways a probe cannot see: the guardian's relays are fine, but the activists' phones are in a region where data is off. Or the guardian is abroad, and only the country is dark.
From the guardian's side, that looks like several activists all missing at the same moment while nobody has heard from anyone. That pattern has two explanations, and both are serious: a regional shutdown, or a mass arrest.
The engine does not pretend ...
