← ELI5 中文
ELI5

Find the hidden
state machines

For office workers who build apps with AI
No. 437How AI WorksPart 26 of 28Fact-checked Nov 8, 2026
Video2:31 · English voice (AI) · English subtitles

Can't play sound? The illustrated version is right below.

Read the transcript

The full narration of the video.

The AI-written code has no typos. So why does the app still act weird? There's one prompt made for exactly this: "Find all of the implicit state machines in my app." It sounds scary, but it's really just a traffic light.

A well-built traffic light has a single dial inside. Point it at red, red lights up; turn it to green, green lights up. The pointer can only sit on one slot, so red and green can never be on together. Now look at a lazy light. Red, yellow and green each get their own switch, and anyone can flip any of them.

Three switches can make eight different patterns. Only three of them make sense. Nobody thought about the other five, like red and green at the same time. Apps work the same way. Many never get a dial, just little switches scattered around: Is it ringing? Is it connected? Is it a group call?

Together those switches are doing a traffic light's job. Nobody ever drew it out, which is why it's called implicit. In January 2019, Apple's FaceTime ran into exactly this. You call someone, and their phone is still ringing. Then you add your own number, turning it into a group call.

Their phone keeps ringing, yet you can already hear what's going on in their room. One of the people who reported it was a high school student. Apple switched off group calls entirely, and shipped a fix ten days later. Apple's notes said only one thing: improved state management. The details were never made public.

In traffic-light terms, it's as if ringing and connected lit up at the same time. That prompt asks the AI to hunt for these lazy lights. It digs out the scattered switches one by one. It lists every state your app can be in, and which action moves it from one slot to the next.

That list is called a state machine. Drawn out, it's a few circles joined by arrows. In code, it's often a single status line that can only hold one value: ringing, in call, or ended. The circles are the light's colors, and the arrows are the pointer clicking to the next slot.

Once the list is laid out, you can spot at a glance the combinations that shouldn't happen but nothing stops. Next, have the AI swap that pile of switches for one dial. As an app grows, the switches keep piling up.

That's why this prompt works: it adds no new features, it just shows you which two lights can come on together. In something you built with AI, is there a button that acts weird when you tap it twice?

1

Red and green, both on

The AI-written code has no typos,
yet the app still acts weird.

A common cause: a few switches, each minding its own business, end up in a combination nobody planned for. One prompt is made to find exactly that.

Find all of the implicit state machines in my app.Paste it as is.

Before asking the AI to fix a weird bug, send this first.

2

A good light has one dial

It sounds scary, but it's really just a traffic light.

GOOD LIGHT
One dial inside.
Whatever slot it points to lights up.
The pointer sits on one slot at a time, so red and green can never be on together.
LAZY LIGHT
Red, yellow and green
each get a switch.
Anyone can flip any of them. Three switches make eight patterns.
3

Eight patterns, three make sense

Nobody thought about the other five.
Like red and green together.

These eight were computed, not drawn by hand: each switch is on or off, 2 × 2 × 2 = 8.

4

Switches scattered in your app

Many apps never get a dial, just little switches in different places. Take a video call:

Ringing?Tracked in one place
Connected?Tracked in another
Group call?Tracked in a third

Together these switches are doing a traffic light's job. Nobody ever drew it out, which is why it's called implicit.

In code they often look like isRinging = true and isConnected = false: one line per switch, spread across different files.

5

Apple's FaceTime
fell into it once

In January 2019, Apple's FaceTime video calls had a bug.

① Still ringingYou video-call someone
② Add yourselfThe call becomes a group call
③ You hear themThey haven't picked up, but you hear their room

One of the people who reported it was a high school student. Apple switched off group calls entirely, then shipped the fix in iOS 12.1.4 ten days later.

Apple's notes said only: improved state management. The details were never made public.

In traffic-light terms, it's as if "ringing" and "connected" lit up at the same time.

6

What the prompt
makes the AI do

① Dig out switchesFind the scattered switches one by one
② List themEvery state, and which action moves it to which slot
③ Flag the odd onesCombinations that shouldn't happen but nothing stops

That list is called a state machine. Drawn out, it's a few circles joined by arrows: the circles are the light's colors, the arrows are the pointer clicking to the next slot.

RingingIn callEnded

In code it's often a single line, status = ringing, that can hold only one value: ringing, in call, or ended. Next, have the AI swap the pile of switches for this one dial.

7

One thing it doesn't do

It adds no features It just shows you which states your app can end up in. Whether and how to change it, you decide after reading the list.
As an app grows,
the switches pile up.
This prompt works because it shows you which two lights can come on together. In something you built with AI, is there a button that acts weird when you tap it twice?
UP NEXT

ChatGPT vs Claude: Where Is the Real Gap?

The top AI models are neck and neck. The gap is the business: ChatGPT is flat-rate internet for a billion people, Claude is metered power for businesses.

No. 456 · 5 minKeep going →
← Back to ELI5