5 min read

I've Been Building the Same Control Loop Since Netcode


The first time I built the pattern I now use to think about AI, it had nothing to do with AI. It was multiplayer netcode, in grad school, a decade ago, and the enemy was latency.

The problem a networked game hands you is a contradiction. The network is slow and unreliable, but the player has to feel instant response, and every player has to agree on one shared world. Fast, and consistent, over a medium that is neither. The solution I ended up with had three moves, and I have been rebuilding those same three moves ever since, in domains that look nothing like a game.

The three moves

Optimism at the edge. If you wait for the server to confirm every action, the game feels like wading through syrup. So the client predicts: it shows the result of your input immediately and assumes the server will agree. The edge is fast because it’s optimistic — it acts before it’s allowed to.

Authority at the core. All that optimism would fracture into a different game on every screen if nothing were in charge. So one place — the server — owns the truth. Real state changes happen there, in one atomic location, and everyone else is downstream of it. The core is slow, singular, and authoritative.

Reconciliation between them. The optimistic edge and the authoritative core will disagree — the client guessed, the server knows. When they do, you don’t snap the client violently to the truth; you converge it, easing from the guess toward the authority over a few frames so the correction doesn’t jar. And underneath it all runs an ordered log of events, so the truth is not just current but replayable.

Fast surface, correct core, a reconciliation loop where they meet, an event log underneath. That’s the whole thing.

An optimistic edge proposes to an authoritative core; the core corrects the edge back; an ordered event log runs underneath both. The edge is a game client or an AI model; the core is a game server or deterministic code.

Optimism at the edge, authority at the core, reconciliation between them — and a replayable log underneath, whichever decade you’re in.

The same shape, wearing AI

Years later I started building systems with AI in them, and I kept reaching for a structure that felt oddly familiar. It took me embarrassingly long to notice it was the netcode loop.

The way I think AI should sit inside a serious system is move for move the same architecture:

  • AI is the optimistic edge. Let it draft, suggest, predict, autocomplete, propose. Let it be fast and feel instant. That’s what it’s good at, and — like client prediction — it’s allowed to act before it’s confirmed, precisely because it’s not the thing that commits.
  • Deterministic code is the authoritative core. Validation, execution, the actual write, the money, the irreversible action — those live in one checkable place that owns the truth. The model doesn’t get to be authoritative any more than a game client does.
  • Reconciliation is where they meet. When the optimistic AI output and the deterministic check disagree, the check wins — but gracefully. Reject with a reason, ask for a confirmation, fall back to a safe default. Converge, don’t crash.
  • And the event log is the audit trail — what the AI actually did and why, replayable after the fact, the same ordered history that let me record and replay a game.

I did not derive this from first principles about language models. I imported it, whole, from a game where the network would humiliate me the instant I trusted the wrong layer.

Why the game taught it better

Here’s the part I find genuinely useful, not just tidy.

In netcode the network is a merciless tutor. Latency and loss are present in every single frame; there is no happy path where they go away. So you cannot get away with letting the optimistic edge be authoritative — the moment you do, two players’ worlds diverge and the bug is on screen, immediately, every time. The environment forces the discipline on you.

AI is a lenient tutor, and that’s the danger. Its failures are occasional and probabilistic, not constant. So you absolutely can get away with letting the optimistic edge commit the truth — wiring the model’s output straight into the action, no authoritative core, no reconciliation — and it will look fine in the demo and fine in the next ten demos. It only bites later, rarely, expensively, in production, on the case you didn’t test. The leniency is exactly why so many AI systems end up as vibes all the way down: nothing ever forced their builders to separate the optimistic layer from the authoritative one, because unlike a network, the model doesn’t embarrass you on frame one.

Games made me learn the discipline the hard way. AI lets you skip it. Which is precisely why importing the hard-won version matters.

The most reusable shape I know

I keep finding this loop everywhere now, and I no longer think that’s a coincidence. Optimistic UI over an authoritative API. A single writer for the truth in a data system, with everything else reading. Caches reconciled against a source of record. It’s the general answer to a question that comes up in almost every system worth building: how do you feel fast while staying correct?

The answer, every time, has the same skeleton — an optimistic edge for speed, an authoritative core for truth, a reconciliation loop for the disagreement, and a log so the truth can be replayed. I didn’t learn to distrust the fast layer from AI. I learned it from a game where the network would prove me wrong within a frame if I trusted it. The domain changed. The loop didn’t.