<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-AU">
  <title>nehem.dev — Writing by Nehemiah Jacob</title>
  <subtitle>Essays on Python, Django, APIs and software design.</subtitle>
  <link rel="self" type="application/atom+xml" href="https://nehem.dev/feed.xml"/>
  <link rel="alternate" type="text/html" href="https://nehem.dev/writing/"/>
  <id>https://nehem.dev/writing/</id>
  <updated>2026-11-26T00:00:00+10:00</updated>
  <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
  <icon>https://nehem.dev/favicon-192.png</icon>
  <entry>
    <title>The Quiet Rearrangement of a Developer's Day</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/6dc072.html"/>
    <id>https://nehem.dev/6dc072.html</id>
    <published>2026-11-26T00:00:00+10:00</published>
    <updated>2026-11-26T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>How coding agents, cloud agents and Grok Bots are changing developer habits: ergonomics off the desk, sleep and family, the race to ship, and $200 plans.</summary>
    <category term="Developer Productivity"/><category term="AI"/><category term="Software Engineering"/><category term="Work-Life Balance"/>
    <content type="html">&lt;p&gt;Recently I've been noticing small changes in how my days are put together. None of them arrived with an announcement. There was no day when I decided to work differently. But when I look at a week of mine now and compare it with a week from three years ago, the shape is different.&lt;/p&gt;
&lt;p&gt;A lot has been written about what AI coding agents do to code. Whether the code is good, whether review can keep up, whether juniors still learn. I've written some of that myself. Much less has been written about what they do to the person. To the chair, the evening, the bank statement and the people at the dinner table.&lt;/p&gt;
&lt;p&gt;So this post is about that. I don't have a strong argument to make here, and I'm not trying to warn anyone off. I use coding agents, cloud agents and a handful of Grok Bots every day, and I like it. I just want to look at what has moved, and offer a few thoughts on what might help.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/6dc072/hero.svg" alt="Two drawings of a working day. On the left, labelled then: one desk with a big monitor, a good chair and a keyboard, with a solid block of work from nine to five. On the right, labelled now: the same day scattered across a phone on the train, the kitchen bench, the couch, a park bench and the bedside table, each with a small check-in dot, and a cloud above them labelled agents running." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The work didn't shrink. It spread out.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;The Desk&lt;/h2&gt;
&lt;p&gt;For most of my career, the desk was the centre of the job. I've been writing software for about eighteen years, a good chunk of it Python and Django, and for nearly all of that time being productive meant being in one place.&lt;/p&gt;
&lt;p&gt;We cared about that place. We argued about monitors. We bought the chair we couldn't really afford because we'd sit in it for ten thousand hours. We set up two screens, then one big one, then went back to two. We learned keyboard shortcuts so our hands didn't have to leave the home row.&lt;/p&gt;
&lt;p&gt;All of that made sense, because the work happened at the speed of our hands. If you were typing the code, the ergonomics of typing mattered more than anything else.&lt;/p&gt;
&lt;p&gt;That has quietly stopped being true for a lot of what I do. When an agent is writing most of the first draft, my hands are not the bottleneck. My attention is. And attention doesn't need a desk.&lt;/p&gt;
&lt;p&gt;The tools have noticed this too. When Cursor &lt;a href="https://cursor.com/blog/ios-mobile-app"&gt;launched its iOS app&lt;/a&gt; in June, the announcement said developers had been "keeping laptops half-open and caffeinated everywhere they go," and pitched launching agents "whether you're catching a flight, cooking a meal, or in between sets at the gym." It describes push notifications and lock-screen updates when an agent finishes, needs input or is ready for review, and merging the pull request from your phone.&lt;/p&gt;
&lt;p&gt;I don't say that as a complaint. It's genuinely useful. Kicking off a fix from the train while it's fresh in my head is a nice thing to be able to do. But it does mean the desk is no longer where the work lives. It's one of several places.&lt;/p&gt;
&lt;h2&gt;The New Ergonomics&lt;/h2&gt;
&lt;p&gt;So the old ergonomics questions, about chairs and monitor height, haven't gone away. They've just been joined by new ones that we haven't really thought about yet.&lt;/p&gt;
&lt;p&gt;The first is physical. I now read diffs on a phone. I review screenshots an agent took of a UI change while I'm sitting on the couch, head bent forward, thumb scrolling. We spent years telling each other to put the top of the monitor at eye level. Then we started doing a meaningful part of the job looking down at a small screen held at chest height. I'm not a physiotherapist and I won't pretend to know the numbers, but I'm fairly sure my neck has an opinion about it.&lt;/p&gt;
&lt;p&gt;The second is attention. Working with agents is less like writing and more like supervising. You start something, step away, come back, read, decide, start the next thing. Each of those returns is a small context switch.&lt;/p&gt;
&lt;p&gt;Gloria Mark and her colleagues studied this long before agents existed. In a &lt;a href="https://interruptions.net/literature/Mark-CHI05-p321-mark.pdf"&gt;2005 study of information workers&lt;/a&gt;, interrupted work that was resumed the same day took an average of 25 minutes and 26 seconds to get back to, and in between people worked on an average of 2.26 other tasks. That study was about phone calls and colleagues at the door. A day of agent check-ins can produce a lot more of those returns than a day of phone calls ever did.&lt;/p&gt;
&lt;p&gt;The third is a kind of reading fatigue. When you write code yourself, you build the understanding as you go. When an agent writes it, you have to build the understanding afterwards, by reading. Reading someone else's code all day is tiring in a different way from writing your own. I notice it as a heaviness by mid-afternoon that I didn't used to have, even on days when I've typed almost nothing.&lt;/p&gt;
&lt;p&gt;I think we need ergonomics for this too. Not just a good chair, but a good rhythm. Fewer, longer check-ins rather than many tiny ones. Reviewing on a real screen when the change matters. Treating the phone as a place to start and steer work, not a place to approve it.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/6dc072/checkins.svg" alt="A coding day drawn as a timeline from 6am to midnight. Agent notifications appear as dots. In the old pattern above, a few dots cluster inside a nine-to-five block. In the new pattern below, dots spread across the whole day: breakfast, the commute, lunch, dinner, the evening and two late dots near midnight, with the late ones circled and labelled still checking." width="960" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;When work can reach you anywhere, it tends to reach you everywhere.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;The Agents Don't Sleep&lt;/h2&gt;
&lt;p&gt;This is the part I think about most.&lt;/p&gt;
&lt;p&gt;A cloud agent doesn't get tired. A Grok Bot running an errand at 11pm doesn't mind. That's a feature. You can hand off a job at the end of the day and wake up to a result. But it also removes something that used to protect us: the work stopping because we stopped.&lt;/p&gt;
&lt;p&gt;When I wrote all the code myself, there was a natural end to the day. I'd get stuck, or tired, or my brain would simply refuse to hold one more thing. Now there's always one more small thing I could kick off. It only takes a minute. It'll be done by morning.&lt;/p&gt;
&lt;p&gt;I'm clearly not the only one who feels this. LeadDev ran a piece in April called &lt;a href="https://leaddev.com/ai/the-just-one-more-prompt-era-is-here"&gt;The "just one more prompt" era is here&lt;/a&gt;, in which Kelli Korducki spoke with nearly a dozen developers who described a "slot machine" effect, and several said they'd scrambled their sleep schedules. One founder told her, "Earlier, you'd stop because you got stuck. Now you just keep moving." Another said he'd skip sleep because he "hadn't used up my full daily limits on the tools yet, like I was leaving potential on the table."&lt;/p&gt;
&lt;p&gt;That last line stuck with me, because I recognised it. When you pay for a usage allowance that refreshes, unused capacity starts to feel like waste. It's a strange new pressure, and I don't think it's a healthy one.&lt;/p&gt;
&lt;p&gt;Quentin Rousseau wrote a very honest post called &lt;a href="https://blog.quent.in/blog/2026/03/09/one-more-prompt-the-dopamine-trap-of-agentic-coding/"&gt;One More Prompt: The Dopamine Trap of Agentic Coding&lt;/a&gt;, about lying in bed with "the prompts" still "composing themselves behind my eyelids." He tried batching agent runs instead of watching them in real time, and tracking hours instead of output. He's candid that he still breaks his own rules.&lt;/p&gt;
&lt;p&gt;What I find interesting is that the advice in both pieces is very old-fashioned. A hard stop time. Laptop closed by a certain hour. One of the founders in the LeadDev piece set a rule of "Laptop closed by 6pm, no exceptions," and said that, ironically, the work didn't suffer. It improved.&lt;/p&gt;
&lt;p&gt;None of this is new wisdom. What's new is that the tool no longer enforces it for us. The friction that used to send us to bed is gone, so we have to put it back on purpose.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/6dc072/loop.svg" alt="A loop drawn in pencil: start a small task, wait a minute, a small win, and then one more, arrowing back to the start. The loop goes round several times, getting later each time: 9pm, 10:30pm, midnight. A single exit arrow leaves the loop, labelled a stop time you chose earlier, pointing to a bed." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The loop has no natural exit. You have to draw one in advance.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;The People Around Us&lt;/h2&gt;
&lt;p&gt;Time is the obvious cost. The less obvious one is presence.&lt;/p&gt;
&lt;p&gt;Being physically at the dinner table while half-watching an agent finish a migration is not quite the same as being there. I've caught myself doing it. Nobody minds a quick glance. But a quick glance every ten minutes adds up to an evening where I wasn't really in the room.&lt;/p&gt;
&lt;p&gt;There's something a little lonely about agent work too, which I didn't expect. A lot of my day used to involve other people by necessity. You'd ask someone how a module worked, or pair on a hard bug, or wait for a colleague's review and chat while you waited. Now much of that conversation happens with a model. It's fast and patient and available at any hour. It also doesn't ask how your weekend was.&lt;/p&gt;
&lt;p&gt;I don't want to overstate this. There are new social forms emerging as well. People share their agent setups, swap prompts, show each other what they've built on a Saturday. Some of the most fun conversations I've had with other engineers this year were about how we each organise our bots. That's real connection, and it's nice.&lt;/p&gt;
&lt;p&gt;But I think it's worth noticing which human contact has been quietly replaced, and choosing to keep some of it on purpose. Ask the colleague, even when the agent could answer. Pair on the hard thing. And when you're with your family, put the phone in the other room. The agent will still be there, and so will the pull request.&lt;/p&gt;
&lt;h2&gt;Everybody Is Shipping&lt;/h2&gt;
&lt;p&gt;There's another feeling I've noticed in the last year or so, and I think many developers share it. It's the sense that everyone around you is building something.&lt;/p&gt;
&lt;p&gt;Open any feed and somebody has shipped an app over the weekend. Somebody else has three side projects live. A friend who had never made a mobile app has one in the store. It's exciting, genuinely. A lot of ideas that would never have been built are being built.&lt;/p&gt;
&lt;p&gt;The numbers back up the feeling. GitHub's &lt;a href="https://github.blog/news-insights/octoverse/octoverse-a-new-developer-joins-github-every-second-as-ai-leads-typescript-to-1/"&gt;Octoverse 2025 report&lt;/a&gt; said more than one new developer joined GitHub every second on average, over 36 million in a year, and that developers created more than 230 new repositories every minute. And as &lt;a href="https://9to5mac.com/2026/07/20/report-app-store-added-nearly-as-many-new-apps-in-h1-2026-as-in-all-of-2025/"&gt;9to5Mac reported&lt;/a&gt; in July, citing Sensor Tower estimates via The New York Times, new App Store releases grew about 30 percent in 2025 to around 600,000, and then roughly 560,000 new apps arrived in the first half of 2026 alone.&lt;/p&gt;
&lt;p&gt;The same report has a detail I keep coming back to. Downloads grew 3 percent in 2025 and 2 percent in the first half of 2026. Building has become far easier. Attention hasn't grown to match it.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/6dc072/shipping.svg" alt="A hand-drawn bar chart of new App Store apps. A bar for all of 2025 reaches about 600,000. A bar for only the first half of 2026 reaches about 560,000, nearly as tall. Beside them, a small arrow labelled downloads rises only slightly: plus 3 percent in 2025, plus 2 percent in the first half of 2026." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Everyone is building. The audience didn't double.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;I think this explains a lot of the pressure people feel. When everyone is working hard, and everyone can produce a lot, the bar for what counts as keeping up moves every month. You ship something, and the next week three similar things appear. So you reach for the next thing. And the next.&lt;/p&gt;
&lt;p&gt;Chuck, a security architect in the LeadDev piece, put it plainly. He wants to find the great idea first because "three or six months from now, somebody else will." I understand that. I've felt it. But I'm not sure it's a race anyone can win, because the finish line moves at the same speed as the runners.&lt;/p&gt;
&lt;h2&gt;What "Done" Means&lt;/h2&gt;
&lt;p&gt;This leads to a quieter question. What does it mean for something to be finished now?&lt;/p&gt;
&lt;p&gt;When building took months, finishing was a big moment. You'd launch, you'd maintain, you'd live with the thing for years. Now it's easy to build something in a weekend and move on before it has really been used. I've got a few of those myself, and I'm fond of them. But a project that's been built isn't the same as a project that's been cared for.&lt;/p&gt;
&lt;p&gt;I've started to think the scarce thing is no longer the ability to make something. It's the patience to stay with it. To answer the third bug report. To make the boring improvements. To let something be small and useful rather than chasing the next launch.&lt;/p&gt;
&lt;p&gt;That's an old Django-world lesson, really. The projects that lasted were rarely the cleverest ones. They were the ones somebody kept looking after.&lt;/p&gt;
&lt;h2&gt;The Subscription Line&lt;/h2&gt;
&lt;p&gt;Now to money, which is where the change is easiest to measure and, I think, the strangest when you look back.&lt;/p&gt;
&lt;p&gt;I remember thinking carefully about paying for an editor. In 2013, Sublime Text &lt;a href="https://www.sublimetext.com/blog/articles/sublime-text-3-beta"&gt;raised its licence price from $59 to $70&lt;/a&gt;, the first rise in its five-year history, and I remember that being a conversation. In 2015 a &lt;a href="https://mail.python.org/pipermail/omaha/2015-November/001970.html"&gt;personal PyCharm Professional licence&lt;/a&gt; was $89 for the first year. I know developers who used the free editions for years rather than spend that. I was one of them for a while.&lt;/p&gt;
&lt;p&gt;Then in February 2023 OpenAI &lt;a href="https://openai.com/index/chatgpt-plus/"&gt;launched ChatGPT Plus at $20 a month&lt;/a&gt;, and I remember people debating whether that was too much. Twenty dollars a month felt like a real decision.&lt;/p&gt;
&lt;p&gt;In December 2024 OpenAI &lt;a href="https://openai.com/index/introducing-chatgpt-pro/"&gt;introduced ChatGPT Pro&lt;/a&gt; at $200 a month. Today its &lt;a href="https://help.openai.com/en/articles/9793128-about-chatgpt-pro-tiers"&gt;Pro tiers&lt;/a&gt; run at $100, $200 and $500. Anthropic's &lt;a href="https://claude.com/pricing"&gt;Claude pricing&lt;/a&gt; lists Max at $100 and Ultra at $200 a month. &lt;a href="https://cursor.com/docs/models-and-pricing"&gt;Cursor's plans&lt;/a&gt; go up to Ultra at $200 a month. Google &lt;a href="https://blog.google/products-and-platforms/products/google-one/google-ai-subscriptions/"&gt;cut its top AI Ultra tier&lt;/a&gt; from $250 to $200 in May and added a $100 one. And xAI launched &lt;a href="https://techcrunch.com/2025/07/09/elon-musks-xai-launches-grok-4-alongside-a-300-monthly-subscription/"&gt;SuperGrok Heavy at $300 a month&lt;/a&gt; back in 2025. Those are US prices, before tax.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/6dc072/ladder.svg" alt="A hand-drawn ladder of what developers pay per year, drawn as bars on the same scale. Sublime Text licence 2013: $70, once. PyCharm Professional 2015: $89 for the first year. ChatGPT Plus 2023: $20 a month, $240 a year. A $200 a month tier: $2,400 a year. A $300 a month tier: $3,600 a year. The last two bars run off the right-hand side compared with the first three, which are short stubs." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;We used to deliberate over $70. Now $2,400 a year barely gets a second thought.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;What I find remarkable isn't that the prices are high. It's how quickly they started to feel normal. A few years ago I'd have laughed at a $200 monthly tool. Now, when I hear another developer is on one of the top tiers, it barely registers. So does everyone, it seems.&lt;/p&gt;
&lt;h2&gt;Who Gets to Pay&lt;/h2&gt;
&lt;p&gt;I don't think the normalisation is irrational. At $200 a month, one of these plans adds up to $2,400 a year. If it saves you a few hours a week, the maths is easy. A lot of people now talk about these tools the way companies talk about a salary line: not "is this expensive?" but "what does it replace?"&lt;/p&gt;
&lt;p&gt;But a few things make me a little uneasy.&lt;/p&gt;
&lt;p&gt;The first is stacking. Each subscription makes sense on its own. A coding agent plan, a chat plan, a bot plan, the usage top-ups when you hit a limit on a busy week. It's very easy to end up paying for three overlapping tools because each was the best at one thing for a month. I'd encourage anyone to sit down once a quarter and look at the whole list, the way you would with streaming services.&lt;/p&gt;
&lt;p&gt;The second is the allowance pressure I mentioned earlier. A plan with a weekly pool that refreshes nudges you to use it all, which nudges you to keep working.&lt;/p&gt;
&lt;p&gt;The third is fairness. Eighteen years ago, a student with a cheap laptop and a free editor had more or less the same tools as a senior engineer at a big company. That was one of the lovely things about this profession. A $200 a month tier is a very different amount of money depending on where you live and what you earn. I'm glad most of these companies still offer cheaper and free tiers. I hope that stays true, and I hope those of us who can afford the top plans remember that not everyone can.&lt;/p&gt;
&lt;h2&gt;Habits Worth Keeping&lt;/h2&gt;
&lt;p&gt;So what do we do with all this? I don't think the answer is to go back. I'm not going to give up the agents, and I don't think anyone should feel guilty for enjoying them. They've made a lot of my work more fun.&lt;/p&gt;
&lt;p&gt;But I think it helps to be deliberate about the habits that used to be enforced for us and now aren't.&lt;/p&gt;
&lt;p&gt;The desk used to tell us when we were working. Now we have to decide that ourselves. I've started treating it as a choice again: real work at a real screen, steering from the phone only when it's genuinely useful.&lt;/p&gt;
&lt;p&gt;Getting tired used to tell us when to stop. Now we have to choose a stop time before the evening starts, because by ten o'clock the loop will always have a good reason to continue.&lt;/p&gt;
&lt;p&gt;Colleagues used to be part of the day by necessity. Now we have to keep them in it on purpose.&lt;/p&gt;
&lt;p&gt;And money used to be scarce enough that we thought about every tool. Now it's worth thinking about them again, once in a while, all together.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/6dc072/keep.svg" alt="A drawing of four old habits on the left, each with an arrow to the deliberate version on the right. The desk told us when we were working, becomes choose where real work happens. Getting tired told us when to stop, becomes pick a stop time before the evening. Colleagues were there by necessity, becomes keep people in the loop on purpose. Money was scarce enough to think about, becomes review the whole list each quarter." width="960" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The old limits were doing a job. Now we have to do it ourselves.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;None of this is dramatic. It's just a rearrangement, the kind you only notice when you step back and look at a whole week at once. I'd be curious whether other developers see the same shape in their own days, and what habits they've found that help.&lt;/p&gt;
&lt;p&gt;I suspect we're all still working it out.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Read First, Then Act</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/cebc28.html"/>
    <id>https://nehem.dev/cebc28.html</id>
    <published>2026-11-26T00:00:00+10:00</published>
    <updated>2026-11-26T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>The best debugging skill isn't writing code, it's reading: the full error, the logs in order, the ticket, the callers and the history. Read first, then act.</summary>
    <category term="Debugging"/><category term="Software Engineering"/><category term="Developer Productivity"/><category term="Engineering Culture"/>
    <content type="html">&lt;p&gt;The best debugging skill isn't writing code.&lt;/p&gt;
&lt;p&gt;It's reading.&lt;/p&gt;
&lt;p&gt;Reading the error message. Actually reading it. Not glancing at the first line and guessing. The full stack trace. The line number. The variable it's complaining about.&lt;/p&gt;
&lt;p&gt;You'd be amazed how many production incidents I've seen where the answer was literally in the error message and somebody spent two hours looking elsewhere.&lt;/p&gt;
&lt;p&gt;I don't say that to sneer at anyone. I've been that somebody more times than I'd like to admit. The pull to start doing something is strong, especially when a thing is broken, people are watching and a channel is filling up with questions. Typing feels like progress. Reading feels like standing still.&lt;/p&gt;
&lt;p&gt;This post is about why that feeling is wrong, what "reading" actually means when you're debugging, and the habit that took me far too long to build: sit still, read first, then act.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/cebc28/hero.svg" alt="Two paths from the same error. The top path, labelled reacting: change code, add a try-catch, tweak a parameter, restart, and loop back to the start, about two hours and still guessing. The bottom path, labelled reading: about ten minutes of reading the logs, the ticket, the last three commits and Tuesday's config change, then one line changed and a tick: fixed." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Same error, two engineers. One starts typing. One starts reading.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Same error, two engineers&lt;/h2&gt;
&lt;p&gt;Here's what I mean.&lt;/p&gt;
&lt;p&gt;A junior developer sees an error and immediately starts changing code. Adding try-catch blocks. Tweaking parameters. Commenting things out. Restarting services. They're writing before they've finished reading.&lt;/p&gt;
&lt;p&gt;Every one of those moves is a guess. Some of them even make the error go away, which is worse, because now the symptom is hidden and the cause is still there. A try-catch around the failing call doesn't fix anything. It just moves the failure somewhere quieter, where it will turn up later as wrong data instead of a loud stack trace.&lt;/p&gt;
&lt;p&gt;A senior developer sees the same error and does nothing for ten minutes. Opens the logs. Reads them top to bottom. Reads the ticket description again. Reads the last three commits to that file. Reads the config that changed on Tuesday.&lt;/p&gt;
&lt;p&gt;Then they change one line and it's fixed.&lt;/p&gt;
&lt;p&gt;From the outside it looks like experience. From the inside it's just reading comprehension.&lt;/p&gt;
&lt;p&gt;That's the part I want people to sit with. When you watch someone senior fix a bug in one line, it's tempting to file it under talent, or intuition, or "they've seen this before". Sometimes they have. But much more often, they just looked at more of the evidence before they touched anything. The one line wasn't a flash of genius. It was the obvious conclusion of ten minutes nobody saw.&lt;/p&gt;
&lt;p&gt;The gap between junior and senior is not what you think it is.&lt;/p&gt;
&lt;p&gt;It's not years. It's not languages. It's not design patterns.&lt;/p&gt;
&lt;p&gt;It's the willingness to read before you react.&lt;/p&gt;
&lt;h2&gt;Read the error message. The whole thing.&lt;/h2&gt;
&lt;p&gt;Not the first line.&lt;/p&gt;
&lt;p&gt;Error messages are written by people who knew, at that exact point in the code, what had gone wrong. They're often clumsy and sometimes misleading, but they are first-hand evidence from the scene. The first line tells you the category. The rest tells you the story.&lt;/p&gt;
&lt;p&gt;A stack trace has a shape. The top is where it blew up, the bottom is where the journey started, and somewhere in the middle is the frame where your code handed something bad to someone else's code. The line number is a gift. The variable name it's complaining about is a gift. "Expected a string, got None" is telling you exactly what question to ask next: where was this supposed to be set, and why wasn't it?&lt;/p&gt;
&lt;p&gt;I've lost count of the times I've seen someone paste only the first line of an error into a chat and ask what it means. The answer was usually three lines further down, in the part they didn't copy.&lt;/p&gt;
&lt;p&gt;And if the error has a "caused by" section, read that too. The exception you're looking at is frequently a wrapper around the one that actually matters.&lt;/p&gt;
&lt;p&gt;There's a reason this is hard. An error message arrives at the worst possible moment, usually as a wall of red text, and our brains are very good at deciding we've seen it before. We recognise the shape, match it to the last time something similar happened, and stop reading. Most of the time that shortcut is harmless. When it's wrong, it sends you confidently in the wrong direction, and the more confident you are, the longer it takes to turn around.&lt;/p&gt;
&lt;h2&gt;Read the logs like a story&lt;/h2&gt;
&lt;p&gt;Read the logs. Not grep for the keyword you expect. Read what actually happened, in order.&lt;/p&gt;
&lt;p&gt;This is the one I've seen cost the most time. I've watched engineers spend an entire afternoon on a bug that the log file explained in the first three lines. They didn't read the logs. They searched the logs. For the keyword they expected. And when it wasn't there, they assumed the logs were useless.&lt;/p&gt;
&lt;p&gt;The logs weren't useless. The search was wrong.&lt;/p&gt;
&lt;p&gt;If they'd read the logs sequentially, like a story, they would have seen the real failure two lines above the one they were looking for.&lt;/p&gt;
&lt;p&gt;Searching is a fine tool when you already know what you're looking for. The trouble is that when you're debugging, you don't. If you knew, you'd have fixed it. A search for the keyword you expect can only confirm your theory or come back empty. It can never show you the thing you didn't think of, and the thing you didn't think of is usually the bug.&lt;/p&gt;
&lt;p&gt;Reading in order gives you causality. This happened, then this, then this went wrong. A warning that nobody cared about at 2:14 explains the error at 2:15. A connection pool that quietly filled up explains the timeouts that came after it. You only see that if you read the lines around the failure, not just the failure.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/cebc28/logs.svg" alt="A log file drawn as a column of lines. A magnifying glass labelled grep for the expected keyword hovers over the lower lines and finds nothing. Two lines above the line it was hunting for, a line is circled in coral: the real failure. An arrow labelled read in order runs down the left side of the file from the top." width="960" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The logs weren't useless. The search was wrong.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Read the ticket, not the title&lt;/h2&gt;
&lt;p&gt;Read the ticket. Not the title. The comments. The history. The thing the reporter said in paragraph three that everyone skipped.&lt;/p&gt;
&lt;p&gt;Ticket titles are compressed. Someone took a confusing experience and squeezed it into eight words, usually while annoyed. The title is their guess at what the problem is. The body is what they actually saw.&lt;/p&gt;
&lt;p&gt;That difference matters. A title that says "checkout is broken" might come with a description that says it only happens on the second attempt, only on mobile, only since the morning. Each of those details rules out whole areas of the system before you've opened an editor. Paragraph three is where people put the detail they weren't sure was relevant, and it is very often the most relevant thing in the whole ticket.&lt;/p&gt;
&lt;p&gt;The comments matter too. Somebody might already have tried the obvious fix. Somebody might have attached a screenshot that contradicts the title. Somebody might have said "this also happened last month", which turns a mystery into a regression with a date on it.&lt;/p&gt;
&lt;h2&gt;Read the code, and the code around it&lt;/h2&gt;
&lt;p&gt;Read the code you're about to change. Not the function. The callers. The callers of the callers. The test that covers it. The commit message that introduced it.&lt;/p&gt;
&lt;p&gt;Same with code as with logs.&lt;/p&gt;
&lt;p&gt;People read code the way they read their own code. They jump to the function, read it in isolation, and assume they understand what it does. But the function was written by someone who left two years ago, in a context that no longer exists, with assumptions that are buried in a commit message from 2018.&lt;/p&gt;
&lt;p&gt;When you read your own code, you bring the context with you. You remember why that odd check is there, what that magic number means, which edge case bit you. When you read someone else's code the same way, you fill those gaps with your own assumptions, and you don't notice you're doing it.&lt;/p&gt;
&lt;p&gt;The callers tell you what the function is actually used for, which is often different from what its name says. The callers of the callers tell you which assumptions are load-bearing. The test tells you what someone once cared enough to protect. Change the function without reading those, and your one-line fix becomes three new bugs somewhere you never looked.&lt;/p&gt;
&lt;p&gt;Each of these takes minutes. And each one eliminates an entire class of wrong guesses.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/cebc28/layers.svg" alt="Five nested rings drawn around a bug, each labelled with what to read and the wrong guess it removes. The error message, in full: guessing the cause from line one. The logs, in order: assuming the logs are useless. The ticket, beyond the title: fixing the wrong symptom. The code with its callers and tests: breaking something you never looked at. The PR and commit history: undoing a decision you didn't know was made." width="960" height="660" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Each one takes minutes. Each one removes a whole class of wrong guesses.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;The code is the final draft&lt;/h2&gt;
&lt;p&gt;Read the PR description from the last person who touched this file. That's where the "why" lives.&lt;/p&gt;
&lt;p&gt;You can't understand code by reading a function. You understand code by reading the conversation: the commit, the PR, the review, the ticket, the person who argued against it and the person who overruled them.&lt;/p&gt;
&lt;p&gt;The code is the final draft. The reasoning is in the history.&lt;/p&gt;
&lt;p&gt;This is the bit that gets skipped most, because the history is one more click away and it doesn't look like the bug. But that strange line you're itching to delete might be the fix for an incident from three years ago. That clumsy-looking retry might be there because a downstream service misbehaves on Mondays. The code can only tell you what it does. It can't tell you what it's protecting against.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git blame&lt;/code&gt; and the PR it points to are the closest thing we have to asking the original author. Often the review thread has the exact debate you're about to restart: someone proposed the simpler approach, someone else explained why it doesn't work, and the code ended up the way it is for a reason that's written down, just not in the code.&lt;/p&gt;
&lt;p&gt;That's also why I care so much about writing good commit messages and PR descriptions myself. Every one of them is a note to the person who'll be reading this code at 2am in two years. Sometimes that person is me.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/cebc28/history.svg" alt="A single sheet labelled the code, the final draft, sits in front of a stack of sheets fanned out behind it: the ticket, the commit, the PR description, the review thread, the person who argued against it, and the person who overruled them. A note under the stack: the why lives here." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The code is the final draft. The reasoning is in the history.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Reading is slow, and that's the point&lt;/h2&gt;
&lt;p&gt;Here's the uncomfortable part:&lt;/p&gt;
&lt;p&gt;Reading is slow. It doesn't feel productive. You're not typing. You're not shipping. You're just sitting there with your eyes moving across a screen.&lt;/p&gt;
&lt;p&gt;And when something is on fire, sitting still is socially hard. People want updates. Someone senior is asking for an ETA. It feels much better to say "I'm trying a fix" than "I'm reading the logs". The first sounds like action. The second sounds like you haven't started.&lt;/p&gt;
&lt;p&gt;But every minute spent reading saves ten minutes of guessing.&lt;/p&gt;
&lt;p&gt;Guessing has a hidden cost structure. Each guess needs a change, a build, a deploy or a restart, and a wait to see whether it worked. When it doesn't, you've learned almost nothing, because you changed one thing based on a theory you never checked. Worse, you've now got a modified system to debug instead of the original one. Stack up a few wrong guesses and you're debugging your own debugging.&lt;/p&gt;
&lt;p&gt;Reading compounds the other way. Each thing you read narrows the space. By the time you change something, you're not guessing anymore. You're confirming.&lt;/p&gt;
&lt;p&gt;There's a quieter benefit too. When you've read properly, you can explain the fix. You can tell the team what happened, why, and why this change stops it happening again. A fix found by guessing can only be explained as "I tried a few things and this one worked", which is another way of saying nobody knows if it's really fixed.&lt;/p&gt;
&lt;p&gt;It's also worth saying: none of this gets less true because AI can read faster than we can. An agent will happily skim a log, pattern-match the first error it sees and propose a confident fix. If you want it to do better, you have to point it at the full trace, the ticket, the history, and ask it to read before it writes. The habit transfers. The tool doesn't replace it.&lt;/p&gt;
&lt;h2&gt;The best readers read differently&lt;/h2&gt;
&lt;p&gt;One more thing.&lt;/p&gt;
&lt;p&gt;The best readers I've worked with don't just read more. They read differently.&lt;/p&gt;
&lt;p&gt;They read with suspicion. "The ticket says database issue. Does the evidence actually say that?" A ticket is a hypothesis written by someone under stress. An alert name is a guess someone configured months ago. Treat them as claims to verify, not facts to build on.&lt;/p&gt;
&lt;p&gt;They read with timestamps. "This log line is from 3am. The deploy was at 2am. What happened in between?" Time is the cheapest correlation tool there is. Lining up when things happened against when things changed rules things in and out faster than almost anything else.&lt;/p&gt;
&lt;p&gt;They read with questions. "This function catches every exception. Why? Who was afraid of what?" Strange code is rarely random. It's a fossil of some past problem. Asking who was afraid of what turns a confusing line into a clue.&lt;/p&gt;
&lt;p&gt;What these three have in common is that they slow the jump from evidence to conclusion. A suspicious reader doesn't accept the first explanation offered. A reader with timestamps checks the order before the story. A reader with questions treats every oddity as information rather than noise. None of it requires genius. It requires refusing to be satisfied too early.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/cebc28/lenses.svg" alt="Three lenses side by side. Suspicion: a ticket saying database issue, with the question does the evidence actually say that. Timestamps: a timeline with deploy at 2am and an error at 3am, and the gap between them circled with the question what happened in between. Questions: a function that catches every exception, with the question why, who was afraid of what." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Read with suspicion, with timestamps, with questions.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;A habit, not a tutorial&lt;/h2&gt;
&lt;p&gt;That's not a skill you learn from a tutorial. It's a habit you build from every bug you've ever been wrong about.&lt;/p&gt;
&lt;p&gt;Every time I jumped to a conclusion without reading properly, I got burned. Every single time. And slowly, painfully, over twenty years, I learned to sit still and read first.&lt;/p&gt;
&lt;p&gt;The lesson didn't arrive in one go. It arrived as a long series of small embarrassments. The fix that made it worse. The afternoon spent on the wrong service. The confident theory in the incident channel that the next log line disproved. Each one left a little scar, and the scars added up to a reflex: before I touch anything, I read.&lt;/p&gt;
&lt;p&gt;If you're earlier in your career, you don't have to wait twenty years for the scars. You can borrow the habit now. Next time an error appears, set yourself a rule: no code changes until you've read the full trace, the logs around it in order, the ticket body and the last few commits to the file. It will feel slow the first few times. Then you'll notice how often the answer was already sitting there.&lt;/p&gt;
&lt;h2&gt;Read first. Then act.&lt;/h2&gt;
&lt;p&gt;It's not glamorous. Nobody gives a conference talk about reading log files carefully.&lt;/p&gt;
&lt;p&gt;But it's the skill that separates the engineer who fixes things from the engineer who makes things worse while trying.&lt;/p&gt;
&lt;p&gt;Read first. Then act.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Writing code is no longer the bottleneck</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/f06970.html"/>
    <id>https://nehem.dev/f06970.html</id>
    <published>2026-11-25T00:00:00+10:00</published>
    <updated>2026-11-25T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>AI agents write a fix in an hour, then it waits days for review. Why the bottleneck moved to code review, and what helps: better PRs, smaller PRs, agent review.</summary>
    <category term="AI"/><category term="Agentic Development"/><category term="Code Review"/><category term="Software Engineering"/>
    <content type="html">&lt;p&gt;Writing code is no longer the bottleneck.&lt;/p&gt;
&lt;p&gt;That sentence would have been ridiculous two years ago. Now it's just Tuesday.&lt;/p&gt;
&lt;p&gt;AI agents can investigate a bug, write the fix, write the tests, and have a PR ready before lunch. What used to take a day takes an hour. Sometimes less.&lt;/p&gt;
&lt;p&gt;I work with agents every day, and I'm not going back. I'd happily take more of this, faster. But something has been bugging me for months, and it's not the agents. It's what happens to their work after it's done.&lt;/p&gt;
&lt;p&gt;This post is about where the work piles up now, why every tool we've built so far has made that pile worse rather than better, the maths nobody puts on a slide, and the handful of boring changes that actually move delivery speed.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/f06970/hero.svg" alt="Two horizontal pipelines, ticket to ship, where width is time. Two years ago the widest block was investigate, write and test, with review after it. Now the agent block is a sliver, about an hour, and the hatched review block stretches across most of the row: one to five days of waiting." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Same pipeline, two years apart. AI shrank the writing. The review didn't move.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;So where does the work pile up now?&lt;/h2&gt;
&lt;p&gt;In the review queue.&lt;/p&gt;
&lt;p&gt;Here's a week I've lived more than once.&lt;/p&gt;
&lt;p&gt;Three PRs waiting for review. Reviewer is in meetings until 3pm. By then there's a fourth. Tomorrow there's a conflict. Day after that someone asks a question that takes another round trip. By Friday the fix that took an hour to write has spent four days sitting in a queue.&lt;/p&gt;
&lt;p&gt;Sound familiar?&lt;/p&gt;
&lt;p&gt;Nothing in that week is anyone doing anything wrong. The reviewer went to their meetings. The fourth PR was real work from someone else. The conflict happened because main kept moving while my branch sat still. The question was a fair question. Every single step was reasonable, and the sum of them was a four-day fix.&lt;/p&gt;
&lt;p&gt;That last part is the trap. Waiting doesn't just add time, it creates more work. The longer a PR sits, the more main drifts, the more likely a conflict, the more context the reviewer has to rebuild, and the more context &lt;em&gt;I&lt;/em&gt; have to rebuild when the question finally arrives on Thursday about something I wrote on Monday. Idle PRs rot.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/f06970/week.svg" alt="A Monday to Friday timeline. On Monday morning a tiny teal block: write and test, about an hour. Then a long hatched coral bar labelled waiting runs to Friday, marked with what happens along the way: the reviewer is in meetings until 3pm, a fourth PR lands in the queue, a merge conflict, a question and another round trip, a re-review. A tick on Friday: merged. A note: productive to waiting time is roughly one to twenty." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;One hour of work, four days in a queue. Every step was reasonable. The total wasn't.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;We optimised the wrong side of the pipeline&lt;/h2&gt;
&lt;p&gt;We spent years optimising the wrong side of the pipeline.&lt;/p&gt;
&lt;p&gt;Faster editors. Better autocomplete. AI pair programmers. Code generation. All of it optimises the part that was already getting faster on its own.&lt;/p&gt;
&lt;p&gt;Meanwhile, the review queue hasn't changed in a decade. Same process. Same bottleneck. Same "I'll get to it after standup."&lt;/p&gt;
&lt;p&gt;Anyone who's read a bit about manufacturing will recognise the shape. A pipeline only moves as fast as its slowest stage. Speed up any other stage and you don't get more out of the end, you just get more inventory stacked up in front of the slow one. In a factory that inventory is boxes on the floor. In software it's open PRs.&lt;/p&gt;
&lt;p&gt;For most of my career the slow stage really was writing. Understanding a codebase, finding the bug, typing the fix, getting the tests green. That's where the hours went, so that's where all the tooling went, and fair enough.&lt;/p&gt;
&lt;p&gt;Agents collapsed that stage. Investigation that took me a morning of grepping, reading logs and stepping through code now takes an agent a few minutes, with the evidence attached. The fix and the tests come with it. The stage that used to dominate the timeline is now a sliver.&lt;/p&gt;
&lt;p&gt;Which means the slowest stage is now something else. And we haven't touched it.&lt;/p&gt;
&lt;h2&gt;The maths nobody talks about&lt;/h2&gt;
&lt;p&gt;Here's the maths that nobody talks about:&lt;/p&gt;
&lt;p&gt;→ Time to write a fix with AI: 1-2 hours.&lt;/p&gt;
&lt;p&gt;→ Time that fix sits in review: 1-5 days.&lt;/p&gt;
&lt;p&gt;→ Ratio of productive time to waiting time: roughly 1:20.&lt;/p&gt;
&lt;p&gt;These are my numbers, from my own week, not a study. But I'd be surprised if yours look very different.&lt;/p&gt;
&lt;p&gt;You just 10x'd your writing speed and your delivery speed didn't change. Because delivery includes review, and review is still a human, with a calendar, with other priorities.&lt;/p&gt;
&lt;p&gt;Do the arithmetic properly and it's even starker. Say a fix used to be a day of writing plus three days in review: four days. Now it's an hour of writing plus three days in review. You made the writing eight times faster and the delivery went from four days to just over three. That's the whole improvement. Most of the time a change spends between "started" and "in production" was never time anyone was working on it.&lt;/p&gt;
&lt;p&gt;A PR that takes an hour to write and four days to merge is not a one-hour fix. It's a four-day fix. The calendar doesn't care which part was fast.&lt;/p&gt;
&lt;h2&gt;It's a system problem, not a people problem&lt;/h2&gt;
&lt;p&gt;I want to be careful here, because this is the bit that turns into blame very quickly.&lt;/p&gt;
&lt;p&gt;This isn't a people problem. Reviewers aren't lazy. They're busy. They have their own PRs, their own investigations, their own meetings. Review is important work that competes with every other kind of important work.&lt;/p&gt;
&lt;p&gt;And it's usually the worst-rewarded kind. Nobody's demo on Friday is "I reviewed eleven PRs". Your own ticket has your name on it. Someone else's review doesn't. So review gets done in the gaps, after standup, after lunch, after my own thing is done, and the gaps are exactly the part of the day that meetings eat first.&lt;/p&gt;
&lt;p&gt;It's a system problem. And it gets worse with AI, not better.&lt;/p&gt;
&lt;p&gt;Because AI increases the throughput on one side of the bottleneck. More PRs, produced faster, by fewer people. Same number of reviewers. Same 24 hours in a day.&lt;/p&gt;
&lt;p&gt;There's a second-order effect too. The reviewers are usually the same people producing PRs with their own agents. The faster their agents work, the more of their own output is waiting on &lt;em&gt;someone else's&lt;/em&gt; review, and the more review requests are waiting on &lt;em&gt;them&lt;/em&gt;. Everyone's producing more and everyone's reviewing at the same speed. The queue isn't one person's problem, it's the whole team's inventory.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/f06970/funnel.svg" alt="Two funnels side by side. Before: three PRs drop into a funnel whose narrow neck is review, and they flow through. With agents: nine PRs drop into the same funnel with the same narrow neck, and a pile of PRs builds up inside it. Out of the bottom of both, merges trickle out at the same rate." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;AI widened the pipe into review. It didn't widen review.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;If your team generates PRs twice as fast but reviews them at the same speed, you haven't improved. You've just built a bigger pile.&lt;/p&gt;
&lt;p&gt;So what actually helps? None of this is exotic. Most of it is stuff we always knew was good practice and got away with ignoring, because writing was slow enough to hide it. It isn't any more.&lt;/p&gt;
&lt;h2&gt;Write the PR description that answers the review&lt;/h2&gt;
&lt;p&gt;The first one is the one I care about most.&lt;/p&gt;
&lt;p&gt;If the reviewer has to investigate your change to understand it, you've shipped the wrong deliverable.&lt;/p&gt;
&lt;p&gt;Think about what a reviewer actually does with a bare PR. They open the diff. They try to work out what problem it's solving. They go and find the ticket. They try to reconstruct why you did it this way and not the obvious other way. They wonder whether you tested the case they're worried about. In other words, they redo half of your investigation, with less context than you had, in a gap between two meetings. No wonder it gets put off until later.&lt;/p&gt;
&lt;p&gt;The description should contain the problem, the root cause, the decisions, the evidence and the test results. A stranger should be able to approve it from the description alone.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;The problem.&lt;/strong&gt; What the user or the system sees, in plain words, with the ticket.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;The root cause.&lt;/strong&gt; Why it happens. Point at the line, the query, the race. Not "fixed the bug", but what the bug actually was.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;The decisions.&lt;/strong&gt; What I chose, and what I considered and rejected. This is where most round trips come from: "why didn't you just...?" Answer it before it's asked.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;The evidence.&lt;/strong&gt; The log line, the query result, the before and after. Proof that the root cause is the root cause.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;The tests.&lt;/strong&gt; What ran, and what each one proves. Not "tests pass", but which behaviour is now pinned down.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/f06970/pr-description.svg" alt="On the left, a PR titled fix stuff, crossed out: the reviewer has to reverse-engineer it. On the right, a PR description drawn as a document with five sections: problem, what the user sees; root cause, why it happens; decisions, what was chosen and rejected; evidence, logs and before and after; tests, what ran and what it proves. A note: one sitting, no investigation, no round trips." width="960" height="660" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The description is the deliverable. The diff is the evidence.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Here's the part that makes this a no-brainer now: the agent already has all of this. It did the investigation. It has the logs it read, the hypothesis it tested, the alternatives it dropped, the test output. Writing it down is nearly free. In my own setup, the PR description is the last step of the ticket-to-PR workflow, and it isn't optional. A PR with a thin description is an unfinished PR.&lt;/p&gt;
&lt;p&gt;The goal is that the review takes one sitting. No investigation, no round trips. Every question the description answers is a day that doesn't get added to the calendar.&lt;/p&gt;
&lt;h2&gt;Make the PR small enough to fit in a gap&lt;/h2&gt;
&lt;p&gt;A 50-line change with a clear description gets reviewed in 10 minutes. A 400-line change with "fix stuff" in the title sits for three days because nobody has a 45-minute block to understand it.&lt;/p&gt;
&lt;p&gt;That's not a rule about lines of code, it's a rule about calendars. Look at any reviewer's afternoon. It's meetings with gaps between them. Ten minutes here, fifteen there. A small PR fits in any of those gaps. A big one fits in none of them, so it gets opened, scrolled, closed, and filed under "later". Later is Thursday.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/f06970/pr-size.svg" alt="Left: a 50-line PR with a clear description, short to read, reviewed in about ten minutes between two meetings and merged today. Right: a 400-line PR titled fix stuff, a wall of lines that needs a 45-minute block to understand, so it sits for three days. Underneath, a reviewer's afternoon of meetings with small gaps: the small PR fits in any gap, the big one fits in none." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The small PR fits in any gap in a reviewer's day. The big one fits in none.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Agents make this easier, not harder, if you ask them to. The temptation with an agent is to let it do everything in one go, because it can. Resist that. Ask for the refactor as one PR and the behaviour change as another. Ask for the migration first, then the code that uses it. Splitting work used to cost me time, so I skipped it. With an agent, splitting is almost free, and every split is a PR that lands in somebody's ten-minute gap instead of their "later".&lt;/p&gt;
&lt;h2&gt;Let the agent take the first pass&lt;/h2&gt;
&lt;p&gt;The same AI that wrote the code can review someone else's code.&lt;/p&gt;
&lt;p&gt;Not as the final approval. As the first pass.&lt;/p&gt;
&lt;p&gt;Catch the obvious issues before a human spends time on them. Does the code actually do what the description says? Is there an edge case nobody handled? A missing test? An error swallowed? A pattern the team has banned? A leftover debug line? An agent can check all of that in minutes, at any hour, without waiting for a gap in anyone's calendar.&lt;/p&gt;
&lt;p&gt;That changes what the human review is for. The human review becomes focused on judgement: is the approach right, are the trade-offs acceptable, does this fit the system.&lt;/p&gt;
&lt;p&gt;That's the part only someone who knows the system can do, and it's the part that was always getting squeezed. When a reviewer spends their fifteen minutes pointing out a missing null check, they've spent their fifteen minutes. When the agent has already caught the null check, the reviewer's fifteen minutes go on the question that actually matters: should we be doing it this way at all?&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/f06970/review-layers.svg" alt="A PR flows into two stages. First an agent pass, which checks that the code matches the description, obvious bugs and edge cases, missing tests, unhandled errors, banned patterns and leftover debug code, in minutes at any hour. Then a human stage for judgement: is the approach right, are the trade-offs acceptable, does this fit the system. Underneath: stop counting PRs opened, start counting time to first review and merge-to-deploy time, with a review SLA that is a tracked, visible number." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The agent catches the obvious. The human spends their time on judgement.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;I'll go further than that: the author should run the agent review &lt;em&gt;before&lt;/em&gt; asking a human. If an agent can find it, a colleague shouldn't have to. Every comment the agent leaves on my own PR is a round trip that never happens.&lt;/p&gt;
&lt;h2&gt;Give the queue a number&lt;/h2&gt;
&lt;p&gt;Review SLAs that the team actually tracks. Not "review when you can." A number. 4 hours. 8 hours. Whatever fits your team.&lt;/p&gt;
&lt;p&gt;Measure it. Make the queue visible. Treat it like you treat deployment frequency, because it is deployment frequency.&lt;/p&gt;
&lt;p&gt;"When you can" is how we got here. Without a number, review always loses to whatever feels more urgent, and something always feels more urgent. With a number, a PR that's been waiting six hours on a four-hour SLA is visibly late, the same way a failing build is visibly red. Nobody has to nag. The queue nags.&lt;/p&gt;
&lt;p&gt;Making it visible matters as much as the number. A list of open PRs with how long each has been waiting, somewhere the whole team sees it every day. Most of the four-day waits I've seen weren't anyone deciding not to review. They were nobody noticing.&lt;/p&gt;
&lt;h2&gt;Celebrate the right number&lt;/h2&gt;
&lt;p&gt;Stop celebrating PR creation speed. Start celebrating merge-to-deploy time. That's the number that tells you how fast value reaches the customer.&lt;/p&gt;
&lt;p&gt;This one matters more as agents get better, because PR creation is about to become the easiest number in the world to inflate. An agent can open ten PRs before you've had your coffee. If that's the number on the dashboard, you'll get a lot of PRs, and the pile will grow, and delivery won't move.&lt;/p&gt;
&lt;p&gt;The customer doesn't see a PR. They see the change when it's in production. Everything before that moment is inventory. The number worth watching is how long it takes a change to get from "ready" to "running", and how much of that time anyone was actually working on it.&lt;/p&gt;
&lt;h2&gt;The bottleneck moved&lt;/h2&gt;
&lt;p&gt;AI changed the economics of writing code. It hasn't changed the economics of reviewing it. That's the gap.&lt;/p&gt;
&lt;p&gt;I don't think the answer is to slow the agents down. That would be optimising for the bottleneck instead of removing it. The answer is to treat review as part of the system you engineer, with the same seriousness we gave to build times and deploy pipelines. Descriptions that answer the review. PRs small enough to fit in a gap. Agents doing the first pass. A number on the queue. The right thing on the dashboard.&lt;/p&gt;
&lt;p&gt;None of that is glamorous. All of it is cheaper than it has ever been, because the same agents that created the pile can do most of the work of draining it.&lt;/p&gt;
&lt;p&gt;The teams that figure this out will ship circles around the teams that don't.&lt;/p&gt;
&lt;p&gt;The bottleneck moved. Has your process moved with it?&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>The Best Engineers I Know Are Lazy</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/7837ff.html"/>
    <id>https://nehem.dev/7837ff.html</id>
    <published>2026-11-14T00:00:00+10:00</published>
    <updated>2026-11-14T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>The best engineers refuse to do the same thing twice. Manual once, automated twice, runs itself the third time. Why compounded laziness wins, especially with AI.</summary>
    <category term="Developer Productivity"/><category term="Automation"/><category term="AI"/><category term="Software Engineering"/>
    <content type="html">&lt;p&gt;The best engineers I know are lazy.&lt;/p&gt;
&lt;p&gt;Not lazy as in they don't work hard. Lazy as in they refuse to do the same thing twice.&lt;/p&gt;
&lt;p&gt;The first time, they do it manually. Fine. You have to learn the shape of the problem.&lt;/p&gt;
&lt;p&gt;The second time, they automate it.&lt;/p&gt;
&lt;p&gt;The third time, it runs itself.&lt;/p&gt;
&lt;p&gt;I've been watching this pattern my entire career and it's the single most reliable predictor of who becomes a 10x engineer.&lt;/p&gt;
&lt;p&gt;It's not typing speed. It's not knowing more languages. It's not working weekends.&lt;/p&gt;
&lt;p&gt;It's an allergic reaction to repetition.&lt;/p&gt;
&lt;p&gt;This post is about that allergy: what it looks like day to day, why my whole AI setup is really just a pile of it, the maths that makes it worth it, and why it matters more now that we have agents than it ever did before.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/7837ff/hero.svg" alt="A staircase of three steps. On the first, a person does the task by hand and learns the shape of the problem. On the second, they write it down as a script. On the third, the script runs on its own, triggered by a hook or a schedule, while the person has walked off to the next problem." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;First time manual, second time automated, third time it runs itself.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Three times, three different jobs&lt;/h2&gt;
&lt;p&gt;Each of those three times is doing a different job, and skipping any of them is a mistake.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The first time is research.&lt;/strong&gt; You do it by hand because you don't know the problem yet. Which server? Which flags? What does "healthy" actually look like on that dashboard? What breaks if you get the order wrong? People who automate on the first pass usually automate the wrong thing, because they're guessing at a shape they haven't seen. Doing it once, slowly, with your own hands, is how you find out what the task really is.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The second time is recognition.&lt;/strong&gt; This is the moment that separates the lazy engineer from everybody else. Most people do the task a second time and feel nothing. The lazy engineer does it a second time and feels an itch: &lt;em&gt;I've been here before.&lt;/em&gt; That itch is the whole skill. The second time, they write it down, not in a wiki, in something that can run.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The third time is the payoff.&lt;/strong&gt; The third time it isn't "run my script", it's that the script runs itself. It's wired into a hook, a schedule, a deploy pipeline, an agent workflow. The engineer doesn't even have to remember it exists. That's the difference between a tool and infrastructure: you use a tool, infrastructure just happens.&lt;/p&gt;
&lt;h2&gt;The allergy, in practice&lt;/h2&gt;
&lt;p&gt;Here's what the allergy looks like in a normal week.&lt;/p&gt;
&lt;p&gt;→ Typed the same SSH command three days in a row? Now it's a shell function.&lt;/p&gt;
&lt;p&gt;→ Manually checked the same five dashboards after every deploy? Now it's a health check script.&lt;/p&gt;
&lt;p&gt;→ Copied credentials from a Slack thread for the third time? Now they're in config.&lt;/p&gt;
&lt;p&gt;→ Wrote the same PR description structure again? Now the agent writes it.&lt;/p&gt;
&lt;p&gt;→ Investigated a bug the same way you investigated the last one? Now there's a workflow for it.&lt;/p&gt;
&lt;p&gt;None of these are impressive on their own. A shell function is three lines. A health check is a loop over some URLs. That's exactly the point. The allergy isn't triggered by big painful problems, everyone fixes those. It's triggered by small ones. The ones everybody else has decided are just part of the job.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/7837ff/allergy.svg" alt="Five small repeated chores, each drawn as a stack of the same card copied three times: an SSH command, five dashboards after a deploy, credentials from a Slack thread, a PR description, a bug investigation. Each stack passes through the sentence I'm not doing this again and comes out as one thing: a shell function, a health check script, config, an agent, a workflow." width="960" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The allergy: the same task, a third time, turns into something that runs.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;The SSH one is my favourite because it's so small. It's literally this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# ~/.bashrc: written the third morning I typed the same thing&lt;/span&gt;
stg&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ssh&lt;span class="w"&gt; &lt;/span&gt;-t&lt;span class="w"&gt; &lt;/span&gt;staging-bastion&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cd /srv/app &amp;amp;&amp;amp; exec bash -l"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
logs&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ssh&lt;span class="w"&gt; &lt;/span&gt;staging-bastion&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"journalctl -u app -n &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="nv"&gt;200&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; --no-pager"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ugly. Undocumented. Saves me a few seconds and, more importantly, a tiny bit of remembering, every single day. Multiply that by a hundred little things and you get an environment that feels like it reads your mind.&lt;/p&gt;
&lt;h2&gt;My AI setup is accumulated laziness&lt;/h2&gt;
&lt;p&gt;Every shortcut I've built, every steering file, every hook, every agentic workflow exists for one reason:&lt;/p&gt;
&lt;p&gt;I got tired of doing it by hand.&lt;/p&gt;
&lt;p&gt;My entire AI setup is just accumulated laziness turned into infrastructure.&lt;/p&gt;
&lt;p&gt;The MCP integrations connecting Jira, GitLab, Grafana, Slack? Laziness. I got tired of switching tabs. The agent can read the ticket, look at the merge request, pull the panel and check the incident channel itself, instead of me being the human copy-paste layer between four browser tabs.&lt;/p&gt;
&lt;p&gt;The steering files that tell the agent how this codebase works? Laziness. I got tired of re-explaining context. How the services fit together, where the tests live, which patterns we use and which we've banned, how to run things locally. Explaining it once in a file beats explaining it in every conversation.&lt;/p&gt;
&lt;p&gt;The hooks that block bad patterns before they reach a commit? Laziness. I got tired of catching them in review. If I've left the same review comment three times, it shouldn't be a comment any more. It should be a check that runs before anyone, human or agent, can commit it.&lt;/p&gt;
&lt;p&gt;The workflow that takes a ticket from investigation to PR? Laziness. I got tired of doing each step manually. Read the ticket, gather evidence from logs and metrics, reproduce, fix, test, write the PR. Every step was something I'd done by hand dozens of times before it became a workflow.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/7837ff/ai-setup.svg" alt="A cross-section of rock strata, oldest at the bottom. Shell functions and aliases. Config instead of credentials in Slack. MCP integrations for Jira, GitLab, Grafana and Slack. Steering files that explain the codebase. Hooks that block bad patterns. On top, the ticket to PR workflow. Each layer is labelled with the thing I got tired of." width="960" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;My AI setup, in cross-section: every layer is a thing I got tired of doing by hand.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;None of this was a grand plan. It was a series of small refusals.&lt;/p&gt;
&lt;p&gt;"I'm not doing this again."&lt;/p&gt;
&lt;p&gt;That sentence, repeated enough times, builds systems.&lt;/p&gt;
&lt;p&gt;I think that's worth saying because people look at a mature agentic setup and assume it came from a design document. Mine didn't. Nobody sat down and architected it. Each layer was a reaction to a specific Tuesday afternoon when I caught myself doing something for the third time.&lt;/p&gt;
&lt;h2&gt;The maths of a five-minute function&lt;/h2&gt;
&lt;p&gt;Here's the thing nobody tells you about automation:&lt;/p&gt;
&lt;p&gt;It doesn't save time the day you build it. It saves time every day after.&lt;/p&gt;
&lt;p&gt;A shell function takes 5 minutes to write. It saves 2 minutes a day. In a month, you've saved an hour. In a year, you've saved days.&lt;/p&gt;
&lt;p&gt;On build day you're behind. You spent five minutes and saved two. By the third day you're ahead, and you stay ahead for as long as the function exists. Nothing else you do at work has a return like that, and it's just sitting there in the boring corners of your day.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/7837ff/payoff.svg" alt="A line chart of time saved by one shell function. It starts below zero on build day, five minutes spent. It climbs two minutes a day, crosses zero within the first few days, reaches about an hour after a month and keeps climbing to days by the end of the year. A note: the friction of remembering is not on this chart." width="960" height="580" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;It doesn't save time the day you build it. It saves time every day after.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;And that's one function. The lazy engineer doesn't have one. They have dozens, each paying out a couple of minutes a day, every day, for years.&lt;/p&gt;
&lt;p&gt;The chart also leaves out the most important thing.&lt;/p&gt;
&lt;h2&gt;The hidden cost is context load&lt;/h2&gt;
&lt;p&gt;And you've also saved something that doesn't show up on a timesheet: the mental friction of remembering how to do it.&lt;/p&gt;
&lt;p&gt;Because that's the hidden cost of manual work. It's not just the minutes. It's the context load. Every manual step is a thing you have to remember, a thing you can get wrong, a thing that lives in your head instead of in code.&lt;/p&gt;
&lt;p&gt;Your head has limited room. Every "remember to run the migration before the seed", every "the staging box needs the other key", every "check the queue depth after deploy, but only on Mondays when the batch runs" is taking up space that should be holding the actual problem. When you're in the middle of an incident at the end of a long day, that's exactly when one of those half-remembered steps gets skipped.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/7837ff/context-load.svg" alt="Two heads side by side. The first is crowded with half-remembered steps: run the migration first, which key for staging, check five dashboards, the PR template, how we debugged this last time. The second head has room for one thing, the actual problem, while the steps sit outside it in a small script that never forgets." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Every manual step lives in your head. Every automated one lives in code.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Automated things don't forget. They don't get tired. They don't skip steps on a Friday afternoon.&lt;/p&gt;
&lt;h2&gt;Ugly scripts, compounded&lt;/h2&gt;
&lt;p&gt;The most productive developers I've worked with all share this trait. Their environments are full of small, ugly, undocumented scripts that solve exactly one problem each. They didn't build them for anyone else. They built them because doing it manually one more time felt physically painful.&lt;/p&gt;
&lt;p&gt;I want to defend the ugly part. The urge to make every helper beautiful, generic and documented is often what stops people writing them at all. A script that solves one problem for one person is allowed to be ugly. If it turns out other people need it, &lt;em&gt;that's&lt;/em&gt; when it graduates into the repo, gets a test and a README. Most never need to.&lt;/p&gt;
&lt;p&gt;And over the years, those ugly scripts add up to something that looks, from the outside, like superhuman productivity.&lt;/p&gt;
&lt;p&gt;It's not. It's just compounded laziness.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/7837ff/compounding.svg" alt="From a distance, the outline of a giant figure striding forward, labelled superhuman productivity. Up close, the figure is made of dozens of tiny, scruffy boxes, each one a small script: stg, logs, deploy-check, seed, pr-desc, tail-errors, and many more." width="960" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;From the outside it looks superhuman. Up close it's a hundred small, ugly scripts.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;A lazy person for a hard job&lt;/h2&gt;
&lt;p&gt;There's a quote I think about often:&lt;/p&gt;
&lt;p&gt;"I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it."&lt;/p&gt;
&lt;p&gt;That's not about cutting corners. That's about refusing to accept friction as permanent.&lt;/p&gt;
&lt;p&gt;There's a version of laziness that really is a problem: skipping the tests, not reading the error, shipping it and hoping. That's not what I mean. Cutting corners leaves the friction where it is and hides it. The good kind of laziness goes after the friction itself and removes it, so that the right way becomes the easy way. A hook that blocks a bad pattern is lazy. It's also the most disciplined thing in the repo.&lt;/p&gt;
&lt;h2&gt;The laziest tool we've ever had&lt;/h2&gt;
&lt;p&gt;The engineers who will thrive in the AI era are the same ones who thrived before it. The lazy ones. The ones who see repetition and feel an itch they can't ignore.&lt;/p&gt;
&lt;p&gt;AI agents are just the most powerful laziness tool we've ever been given.&lt;/p&gt;
&lt;p&gt;Before agents, the allergy had a ceiling. You could automate the mechanical stuff, the commands and checks and templates, but anything that needed judgement stayed manual. Investigating a bug, writing a PR description, working out which logs matter, those were "you have to do it yourself" jobs.&lt;/p&gt;
&lt;p&gt;That ceiling is gone. Now the same reflex applies to judgement-shaped work. Did the same kind of investigation twice? Write it down as a workflow and let the agent run it. Explained the codebase twice? Put it in a steering file. Gave the same review feedback twice? Make it a hook the agent has to pass.&lt;/p&gt;
&lt;p&gt;The people who get the most out of agents won't be the ones who type the cleverest prompts. They'll be the ones who keep noticing what they're doing for the third time, and never do it a fourth.&lt;/p&gt;
&lt;p&gt;The gap between a productive engineer and an unproductive one has never been about effort.&lt;/p&gt;
&lt;p&gt;It's about what they refuse to do twice.&lt;/p&gt;
&lt;p&gt;So here's a small challenge for this week: next time you catch yourself doing something for the third time, stop, and spend the five minutes.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Mise en Place for Developers</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/4d6cd9.html"/>
    <id>https://nehem.dev/4d6cd9.html</id>
    <published>2026-11-12T00:00:00+10:00</published>
    <updated>2026-11-12T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Fast developers don't type faster. They never stop to fix their environment mid-problem. Mise en place for developers: one flow, one command, no walking.</summary>
    <category term="Developer Productivity"/><category term="Software Engineering"/><category term="DevOps"/><category term="Docker"/>
    <content type="html">&lt;p&gt;Treat your dev environment like a chef treats his kitchen.&lt;/p&gt;
&lt;p&gt;A great chef doesn't cook faster by being more talented. He cooks faster because everything is already in place before the first flame is lit.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Mise en place.&lt;/em&gt; Everything in its place.&lt;/p&gt;
&lt;p&gt;Knives sharpened. Ingredients prepped. Pans in reach. Spices lined up in order. The cutting board is clean before the next vegetable hits it.&lt;/p&gt;
&lt;p&gt;A chef who has to stop mid-service to find the salt, wash a pan, or figure out which burner works is not a slow chef. He's a chef with a bad kitchen.&lt;/p&gt;
&lt;p&gt;This post is about the developer version of that kitchen: what "walking" looks like in software, the setup I built to stop doing it, and the small daily habits that keep it from rotting.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4d6cd9/hero.svg" alt="Two lines drawn one above the other. The kitchen: refrigerator, prep station, mini sink, burner, plating, main sink, every arrow pointing the same way. The dev environment: ticket, codebase, local stack, gather evidence, fix, tests, PR, also flowing one way. Same shape, same rule: never double back." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;One direction, two kitchens. The stations are different, the rule is the same: never double back.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Minimise walking&lt;/h2&gt;
&lt;p&gt;The best kitchens in the world are designed around one principle:&lt;/p&gt;
&lt;p&gt;Minimise walking.&lt;/p&gt;
&lt;p&gt;Think about a professionally designed kitchen. It flows in one direction:&lt;/p&gt;
&lt;p&gt;Refrigerator → Prep station → Mini sink → Burner → Plating → Main sink.&lt;/p&gt;
&lt;p&gt;You start at the fridge, pull what you need, move to the prep station right next to it, wash at the built-in sink, cook on the burner beside it, plate, and clean up at the end. You never double back. You never cross the room to find something. Every station is exactly where you need it, exactly when you need it.&lt;/p&gt;
&lt;p&gt;That mini sink is my favourite detail. Somebody looked at a cook walking to the main sink twenty times a service, just to rinse herbs, and decided that walk was worth a whole extra piece of plumbing. That's the mindset. Not "how do I move faster between stations?" but "why is this station so far away?"&lt;/p&gt;
&lt;p&gt;The enemy of speed in a kitchen is not slow hands. It's walking.&lt;/p&gt;
&lt;h2&gt;In software, walking is context switching&lt;/h2&gt;
&lt;p&gt;Every time you leave your editor to find a credential, that's walking. Every time you open a browser to check a dashboard that should be in your terminal, that's walking. Every time you SSH into a box to check something your local environment should already have, that's walking. Every time you alt-tab through nine windows to find the one with the error log, that's walking.&lt;/p&gt;
&lt;p&gt;None of those trips is long. That's exactly why we don't notice them. Thirty seconds to find a password. A minute to remember which tab had the Grafana panel. Two minutes to get onto the bastion because the VPN dropped. Each one feels too small to fix.&lt;/p&gt;
&lt;p&gt;But the clock is not the real cost. The real cost is what you were holding in your head when you left. You were three steps into a hypothesis about why a webhook fired twice, and now you're reading a Slack thread from March looking for a connection string. By the time you're back in the editor, the hypothesis has gone cold. You re-read the code. You rebuild the picture. Then you walk again.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4d6cd9/walking.svg" alt="A messy kitchen seen from above: a cook's path loops from the stove to a far-off spice rack, back to the sink, across the room to a drawer and back again. Next to it the developer's version: from the editor out to Slack for a credential, to a browser dashboard, to an SSH session, through nine windows for a log, and back to the editor each time. Every loop is a walk." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Every loop back to the editor is a walk across the kitchen mid-service.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;One direction, one flow&lt;/h2&gt;
&lt;p&gt;An optimally designed dev environment works like an optimally designed kitchen. One direction. One flow:&lt;/p&gt;
&lt;p&gt;Ticket → Codebase → Local stack → Gather Evidence → Fix → Tests → PR&lt;/p&gt;
&lt;p&gt;You read the ticket in context (not in a browser tab you have to find). Your editor already knows the repo. The local stack is running. Logs stream where you can see them. You fix, the tests run, the PR writes itself. No backtracking. No hunting. No friction.&lt;/p&gt;
&lt;p&gt;Each station deserves its own design:&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Ticket.&lt;/strong&gt; The ticket shows up next to the code, not in a tab you have to go and find. I want to read the ticket and the codebase in the same field of view.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Codebase.&lt;/strong&gt; The editor already knows the repo: it's cloned, indexed, the virtualenv is active, the right Python version is the one that runs.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Local stack.&lt;/strong&gt; Already up. Not "I'll start it when I need it". If the stack is the burner, the burner is lit before service.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Gather evidence.&lt;/strong&gt; Logs, queries and metrics are a command away, in the terminal I'm already in. This is the station most setups forget, and it's where most of the walking happens.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Fix.&lt;/strong&gt; The only station that should take real thinking.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Tests.&lt;/strong&gt; They run locally against the same stack, with the same data shapes, and they're fast enough that I actually run them.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;PR.&lt;/strong&gt; The branch, the description and the evidence are already sitting there. The PR is plating, not cooking.&lt;/p&gt;
&lt;p&gt;Every extra click, every extra tab, every "wait, where was that?" is walking across the kitchen mid-service.&lt;/p&gt;
&lt;h2&gt;Look at your own kitchen&lt;/h2&gt;
&lt;p&gt;Now look at your setup. How many times a day do you walk?&lt;/p&gt;
&lt;p&gt;→ How long does it take you to go from "I just cloned the repo" to "I can run the app locally"?&lt;/p&gt;
&lt;p&gt;→ When a production bug comes in, how many tabs do you open before you see your first log line?&lt;/p&gt;
&lt;p&gt;→ How many times a week do you restart Docker because something got into a weird state?&lt;/p&gt;
&lt;p&gt;→ How many credentials are you copy-pasting from Slack messages and sticky notes?&lt;/p&gt;
&lt;p&gt;→ When was the last time your local stack matched production closely enough that a local repro actually meant something?&lt;/p&gt;
&lt;p&gt;Be honest. Most dev environments are messy kitchens.&lt;/p&gt;
&lt;p&gt;And we accept it. We work around it. We tell ourselves "it works on my machine" and move on. The new joiner spends their first week getting the app to boot, and we call that onboarding. The senior engineer has a private folder of scripts nobody else knows about, and we call that experience. It's neither. It's a kitchen where only one cook knows where the salt is.&lt;/p&gt;
&lt;h2&gt;My dev environment is a product&lt;/h2&gt;
&lt;p&gt;Here's what I did instead:&lt;/p&gt;
&lt;p&gt;I treated my dev environment as a first-class product.&lt;/p&gt;
&lt;p&gt;Not a side project. Not a "when I get time" thing. A product with requirements, maintenance and a definition of done.&lt;/p&gt;
&lt;p&gt;Requirements means I wrote down what "working" means: the whole stack boots from cold with one command, a bug from production can be reproduced locally, a new person is productive on day one. Maintenance means it gets fixed when it breaks, the same way I'd fix a bug in the app, not worked around. Definition of done means a feature isn't finished until the local stack knows about it too.&lt;/p&gt;
&lt;p&gt;Five things made the biggest difference.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. One command to bring up the entire local stack.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Databases, caches, queues, the API, the admin, the background workers. One command. If it takes more than one, automate it until it doesn't.&lt;/p&gt;
&lt;p&gt;The command itself doesn't matter. &lt;code&gt;make up&lt;/code&gt;, &lt;code&gt;just up&lt;/code&gt;, a shell script, a Docker Compose profile. What matters is that it's the only thing anyone needs to remember, and that it works from a fresh clone. The README that says "first install these seven things, then run these four commands in this order, then if you see this error do that" is a recipe written for a chef who has time to read during service.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Dev data that matches production patterns.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Not empty databases. Not "test user 1, test user 2." Real-shaped data with real edge cases. When you reproduce a bug locally, you need to see the same shapes you'd see in prod.&lt;/p&gt;
&lt;p&gt;Real-shaped doesn't mean real. Never copy customer data onto a laptop. It means the same &lt;em&gt;distributions&lt;/em&gt;: customers with ten years of history next to customers created yesterday, names with apostrophes and accents, accounts with a cancelled plan and a pending refund at the same time, the one tenant with forty thousand rows in a table everyone assumes is small. Those are the shapes production bugs hide in. An empty database can't reproduce anything except the happy path.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Credentials managed, not memorised.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Every connection string, every API key, every SSH tunnel in config. Not in your head. Not in a Slack thread from six months ago.&lt;/p&gt;
&lt;p&gt;For a local stack that means a &lt;code&gt;.env&lt;/code&gt; the boot script generates or pulls from a secrets manager, never one you assemble by hand. For the real environments, it means a proper secret store and named tunnels in your SSH config, so "connect to the staging database" is one command and not an archaeology project. The test is simple: could a new developer get to every environment they're allowed to see without asking anyone for a password in a DM?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. Local monitoring that mirrors production.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you debug with print statements locally but Grafana dashboards in prod, you're practising for a different sport than the one you play.&lt;/p&gt;
&lt;p&gt;Run the same log format, the same structured fields, ideally the same dashboards against your local stack. When an incident comes in, you want your hands to already know where everything is. A chef doesn't use a different knife at home and a different one at work and expect the same cuts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5. A boot script that checks health.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Not just "did the containers start." Did the database accept connections? Is Redis reachable? Is Sentinel pointing to the right master? Did the background workers actually pick up the queue?&lt;/p&gt;
&lt;p&gt;"Container is running" is the most misleading green light in software. A Postgres container can be running and still replaying its startup. A worker can be running and connected to the wrong broker. A Sentinel can be running and pointing at a master that no longer exists. The boot script's job isn't to start things. It's to prove they work, and to fail loudly, with the exact reason, when they don't.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4d6cd9/boot-health.svg" alt="A boot flow: one command starts the stack, then a chain of checks, each one a real question. Does Postgres accept a connection and answer a query? Does Redis answer PING? Does Sentinel name the right master? Did a worker pick up a test job from the queue? Each check either passes to the next or stops the boot with the exact reason. At the end: ready to cook." width="960" height="700" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;A boot script that proves the stack works, not one that just starts containers.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Here's roughly what that looks like. It's an illustrative sketch rather than my actual script, for a typical Django stack with Postgres, Redis behind Sentinel and Celery workers:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c1"&gt;# up.sh: one command, from a fresh clone to a stack that's proven healthy&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-euo&lt;span class="w"&gt; &lt;/span&gt;pipefail

fail&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"BOOT FAILED: &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="p"&gt;&amp;amp;&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;exit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
wait_for&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# wait_for "&amp;lt;description&amp;gt;" &amp;lt;seconds&amp;gt; &amp;lt;command...&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;local&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;what&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;secs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;shift&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;_&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;seq&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$secs&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;/dev/null&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&amp;gt;&lt;span class="p"&gt;&amp;amp;&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok  &lt;/span&gt;&lt;span class="nv"&gt;$what&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;sleep&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;fail&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$what&lt;/span&gt;&lt;span class="s2"&gt; (gave up after &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;secs&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;s)"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

docker&lt;span class="w"&gt; &lt;/span&gt;compose&lt;span class="w"&gt; &lt;/span&gt;up&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;--wait

wait_for&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"postgres accepts queries"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;60&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;docker&lt;span class="w"&gt; &lt;/span&gt;compose&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-T&lt;span class="w"&gt; &lt;/span&gt;db&lt;span class="w"&gt; &lt;/span&gt;psql&lt;span class="w"&gt; &lt;/span&gt;-U&lt;span class="w"&gt; &lt;/span&gt;app&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;app&lt;span class="w"&gt; &lt;/span&gt;-c&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"select 1"&lt;/span&gt;
wait_for&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"redis answers PING"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;docker&lt;span class="w"&gt; &lt;/span&gt;compose&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-T&lt;span class="w"&gt; &lt;/span&gt;redis&lt;span class="w"&gt; &lt;/span&gt;redis-cli&lt;span class="w"&gt; &lt;/span&gt;ping
wait_for&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sentinel names the right master"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bash&lt;span class="w"&gt; &lt;/span&gt;-c&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="s1"&gt;'[ "$(docker compose exec -T sentinel redis-cli -p 26379 sentinel get-master-addr-by-name main | head -1)" = "redis" ]'&lt;/span&gt;

docker&lt;span class="w"&gt; &lt;/span&gt;compose&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-T&lt;span class="w"&gt; &lt;/span&gt;api&lt;span class="w"&gt; &lt;/span&gt;python&lt;span class="w"&gt; &lt;/span&gt;manage.py&lt;span class="w"&gt; &lt;/span&gt;migrate&lt;span class="w"&gt; &lt;/span&gt;--noinput
docker&lt;span class="w"&gt; &lt;/span&gt;compose&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-T&lt;span class="w"&gt; &lt;/span&gt;api&lt;span class="w"&gt; &lt;/span&gt;python&lt;span class="w"&gt; &lt;/span&gt;manage.py&lt;span class="w"&gt; &lt;/span&gt;seed_dev_data&lt;span class="w"&gt; &lt;/span&gt;--if-empty

&lt;span class="c1"&gt;# the real test: a worker must actually pick up a job&lt;/span&gt;
docker&lt;span class="w"&gt; &lt;/span&gt;compose&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-T&lt;span class="w"&gt; &lt;/span&gt;api&lt;span class="w"&gt; &lt;/span&gt;python&lt;span class="w"&gt; &lt;/span&gt;manage.py&lt;span class="w"&gt; &lt;/span&gt;enqueue_healthcheck_job
wait_for&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"worker picked up the healthcheck job"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;60&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;docker&lt;span class="w"&gt; &lt;/span&gt;compose&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-T&lt;span class="w"&gt; &lt;/span&gt;api&lt;span class="w"&gt; &lt;/span&gt;python&lt;span class="w"&gt; &lt;/span&gt;manage.py&lt;span class="w"&gt; &lt;/span&gt;healthcheck_job_done

&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"stack is ready: http://localhost:8000"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The details will differ for your stack. The pattern doesn't: every check asks a question a real request would ask, and the script refuses to say "ready" until all of them pass.&lt;/p&gt;
&lt;p&gt;This isn't over-engineering. This is the engineering equivalent of a clean kitchen.&lt;/p&gt;
&lt;h2&gt;A fast developer doesn't type fast&lt;/h2&gt;
&lt;p&gt;Here's the part most people miss:&lt;/p&gt;
&lt;p&gt;A fast developer isn't someone who types fast. A fast developer is someone who never has to stop and fix their environment in the middle of fixing the actual problem.&lt;/p&gt;
&lt;p&gt;Every minute you spend fighting Docker, hunting for credentials, or wondering why your local stack doesn't match prod is a minute you're not spending on the work that matters.&lt;/p&gt;
&lt;p&gt;And it compounds.&lt;/p&gt;
&lt;p&gt;Five minutes of environment friction, ten times a day, fifty weeks a year. That's over 200 hours a year. Five full working weeks. Lost to a messy kitchen.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4d6cd9/compounding.svg" alt="Five minutes of friction, drawn as a small block. Ten blocks make a day: fifty minutes. Five days make a week: about four hours. Fifty weeks make a year: over two hundred hours, the same as five full working weeks, drawn as five long bars. Then the same stack repeated for every developer on the team." width="960" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Five minutes, ten times a day, fifty weeks a year. That's over 200 hours, five full working weeks.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Now multiply that by every developer on your team.&lt;/p&gt;
&lt;p&gt;And the hours aren't even the whole story. The friction tends to land at the worst possible moments: in the middle of an incident, during a tricky debugging session, when someone new is trying to get their first change out. The cost of walking is highest exactly when your head is fullest.&lt;/p&gt;
&lt;h2&gt;Clean as you go&lt;/h2&gt;
&lt;p&gt;Here's another thing chefs know:&lt;/p&gt;
&lt;p&gt;You clean as you go. Not at the end of the night.&lt;/p&gt;
&lt;p&gt;A kitchen doesn't get messy in one go. It gets messy one unwiped board at a time. Dev environments rot the same way: one undocumented workaround, one service added to prod but not to the local stack, one config value someone tweaked on staging and never mentioned.&lt;/p&gt;
&lt;p&gt;The dev equivalent:&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Container acting weird?&lt;/strong&gt; Fix it now. Don't restart and hope. A restart that "fixes" something hides a bug you'll meet again, usually at a worse time.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;New service added to the stack?&lt;/strong&gt; Update the boot script today. Not "when someone else needs it." The person who added it is the only one who knows what healthy looks like.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Config changed in prod?&lt;/strong&gt; Mirror it locally before you forget what changed. Drift between local and prod is how a local repro stops meaning anything.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;Something took you 20 minutes to figure out?&lt;/strong&gt; Write it down in 2 minutes so it never costs 20 again. Better still, put it in the script so nobody has to read it.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4d6cd9/clean-as-you-go.svg" alt="A small loop: something breaks or changes, fix it now, put the fix in the script or config, the kitchen stays clean, back to cooking. A dashed side path labelled restart and hope leads to a growing pile of dirty dishes, the debt you pay later, mid-service." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Clean as you go: every fix lands in the script, so the mess never piles up.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Discipline, not equipment&lt;/h2&gt;
&lt;p&gt;The best kitchens in the world aren't impressive because of the equipment. They're impressive because of the discipline.&lt;/p&gt;
&lt;p&gt;Same with dev environments.&lt;/p&gt;
&lt;p&gt;You don't need a fancier laptop. You don't need more RAM. You don't need a new tool.&lt;/p&gt;
&lt;p&gt;I've watched people buy their way out of this problem: a faster machine, a new terminal, a shiny dev-container product. Sometimes those help. But a fast laptop running a stack that needs eleven manual steps is still a messy kitchen, just with better lighting. The win comes from deciding the environment is your job, and keeping it that way every single day.&lt;/p&gt;
&lt;p&gt;This matters even more now that a lot of my work runs through AI agents. An agent dropped into a messy kitchen walks just as much as a human, it just walks faster and gets lost more confidently. Give it one command to boot, health checks that say what's wrong, and logs in the terminal, and it can go from ticket to PR without asking me where the salt is.&lt;/p&gt;
&lt;p&gt;You need everything in its place, ready to go, before the ticket lands.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Mise en place.&lt;/em&gt; For developers.&lt;/p&gt;
&lt;p&gt;How long does your local stack take to boot from cold? Be honest.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Why Blackbox Testing Always Wins</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/d5d0f8.html"/>
    <id>https://nehem.dev/d5d0f8.html</id>
    <published>2026-11-08T00:00:00+10:00</published>
    <updated>2026-11-08T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Blackbox tests check what the product does, not how it's built. With AI agents writing them, a thousand real user journeys is now months of work, not years.</summary>
    <category term="AI"/><category term="Testing"/><category term="Software Engineering"/><category term="AI Agents"/>
    <content type="html">&lt;p&gt;Ever since LLMs arrived, there's one thing they've always been terrifyingly good at:&lt;/p&gt;
&lt;p&gt;Writing tests.&lt;/p&gt;
&lt;p&gt;Not the crap unit tests that mock everything, test nothing real and burn CI minutes on every push. I'm talking about blackbox tests. Tests that don't care &lt;em&gt;how&lt;/em&gt; the system is implemented. Tests that care &lt;em&gt;what&lt;/em&gt; the system does.&lt;/p&gt;
&lt;p&gt;Input goes in. Output comes out. Does it match? That's it.&lt;/p&gt;
&lt;p&gt;No mocking of your own services. No internal wiring. No "this test broke because someone renamed a private method."&lt;/p&gt;
&lt;p&gt;This post is my case for why that kind of test wins, how I get AI agents to write hundreds of them, and the honest small print that makes the difference between a suite you trust and a suite everyone learns to ignore.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/d5d0f8/hero.svg" alt="Two rows of the same journey, log in, get token, call /me, right user back, both passing. Under the first, hidden from the test, one Django app and Postgres. Under the second, an auth service, a token service, a profile API and a new database. The test only touches the journey, so it survives." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Same journey, new insides. The test only sees what a user sees, so it survives the rewrite underneath.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;What I mean by blackbox&lt;/h2&gt;
&lt;p&gt;A blackbox test talks to the system the way a user or a client does: through its public API, its UI or its device protocol. It knows the contract. It doesn't know the code.&lt;/p&gt;
&lt;p&gt;That's a slightly different thing from "end-to-end". An end-to-end test is about &lt;em&gt;scope&lt;/em&gt;, the whole chain from the front door to the database and back. Blackbox is about &lt;em&gt;knowledge&lt;/em&gt;, what the test is allowed to know. Most of my tests are both: they drive a whole journey, and they only use what's visible from outside. But you can have a blackbox test of a single service, and you can have a so-called end-to-end test that peeks into tables and mocks half the world. The second one is not what I'm talking about.&lt;/p&gt;
&lt;p&gt;The thing a blackbox test protects is a &lt;strong&gt;behavioural contract&lt;/strong&gt;: given this user, in this state, doing this, the system responds with that. Those contracts are what your customers actually depend on. Nobody has ever filed a support ticket about a private method.&lt;/p&gt;
&lt;h2&gt;Four journeys, four tests&lt;/h2&gt;
&lt;p&gt;Here's what I do. I point an AI agent at a real user journey and say: write a test for this. End to end. Realistic data. Realistic environment. Test the outcome, not the implementation.&lt;/p&gt;
&lt;p&gt;Some examples of the kind of journeys I mean:&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;A user authenticates.&lt;/strong&gt; Gets a token. The token works on the next call. That's a test.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;A user enters credentials.&lt;/strong&gt; The 2FA screen is shown. A code is entered. The welcome screen appears. That's a test.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;A customer buys an episode.&lt;/strong&gt; An entitlement is created. The episode plays. The purchase appears in billing. That's a test.&lt;/p&gt;
&lt;p&gt;→ &lt;strong&gt;An admin changes a plan.&lt;/strong&gt; The change propagates to the device. The device sees the new channels. That's a test.&lt;/p&gt;
&lt;p&gt;Not one assertion. An entire journey, step by step, the way a real human uses the system.&lt;/p&gt;
&lt;p&gt;The purchase one is my favourite, because it crosses every layer that tends to break quietly.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/d5d0f8/purchase-chain.svg" alt="Four hops in a row: buy episode at the store API, entitlement in the rights service, playback through the player and CDN, billing in the ledger. Under each, the assertions: order id and price, entitlement for the right user and episode, a working stream, one charge of the correct amount." width="960" height="520" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;One purchase crosses four layers. A journey test asserts at every hop, not just the first status code.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;A unit test might tell you that the purchase handler returns 201. Lovely. It won't tell you that the entitlement never got written because an event was dropped, or that the stream URL comes back 403 for this region, or that billing charged twice because a retry wasn't idempotent. Each of those has its own unit tests, and each of those unit tests passes. The customer still can't watch their episode.&lt;/p&gt;
&lt;h2&gt;Assertions are the whole game&lt;/h2&gt;
&lt;p&gt;Here's where a lot of "end-to-end" suites go wrong: they drive the whole journey and then assert almost nothing. &lt;code&gt;assert response.status_code == 200&lt;/code&gt; is not a test of a product. It's a test that the server didn't crash.&lt;/p&gt;
&lt;p&gt;A good blackbox assertion is about an outcome a person would notice:&lt;/p&gt;
&lt;p&gt;→ The token works on the &lt;em&gt;next&lt;/em&gt; call, for &lt;em&gt;this&lt;/em&gt; user, and not for another one.&lt;/p&gt;
&lt;p&gt;→ The welcome screen shows &lt;em&gt;this&lt;/em&gt; user's name.&lt;/p&gt;
&lt;p&gt;→ Billing has exactly &lt;em&gt;one&lt;/em&gt; charge, for the right amount, in the right currency.&lt;/p&gt;
&lt;p&gt;→ After cancelling, the device &lt;em&gt;stops&lt;/em&gt; seeing the channel.&lt;/p&gt;
&lt;p&gt;The negative ones matter as much as the positive ones. A plan downgrade that adds the new channels but forgets to remove the old ones passes a lazy test and fails a real one.&lt;/p&gt;
&lt;p&gt;My unit-test-versus-blackbox line is this: a unit test says "the add_to_cart function returns 200". A blackbox test says "a customer in Melbourne with a prepaid card can buy a subscription, see it on their device, get charged correctly, and cancel without calling support."&lt;/p&gt;
&lt;p&gt;Which one do you trust more?&lt;/p&gt;
&lt;h2&gt;Here's roughly what one looks like&lt;/h2&gt;
&lt;p&gt;This is an illustrative example, not code from any real system, but it shows the shape. It's plain Python and &lt;code&gt;pytest&lt;/code&gt;, talking to a staging API over HTTP. Nothing is imported from the application.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;uuid&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;tests.journeys.client&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Api&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;poll_until&lt;/span&gt;  &lt;span class="c1"&gt;# thin HTTP helpers, no app imports&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;test_customer_buys_episode_and_can_watch_it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Api&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sandbox_card&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# realistic, unique, disposable customer for this run only&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"journey+&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uuid4&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hex&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;@example.test"&lt;/span&gt;
    &lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Melbourne"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sandbox_card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"prepaid"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;episode_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"S01E03"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"paid"&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price_of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"S01E03"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# entitlement is written asynchronously: wait for it, with a hard limit&lt;/span&gt;
    &lt;span class="n"&gt;poll_until&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;can_play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"S01E03"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;timeout_s&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;stream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"S01E03"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;http_status&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;manifest_has_segments&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;charges&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;billing_history&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reference&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;charges&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# exactly one charge&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Read it top to bottom and you know what the product promises. That's not an accident. I'll come back to it.&lt;/p&gt;
&lt;h2&gt;Determinism is designed, not hoped for&lt;/h2&gt;
&lt;p&gt;The biggest reason people distrust journey tests is that they've seen bad ones. Tests that pass on Tuesday and fail on Wednesday. Tests that only work if run in a particular order. The fix isn't to write fewer of them. It's to build them properly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fixtures.&lt;/strong&gt; Every test creates its own data: its own user, its own account, its own order. Synthetic but realistic: real-looking names, real postcodes, real plan combinations, card types that exist. Never real customer data. A test that depends on "the demo user" will eventually fight another test over it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Setup and teardown.&lt;/strong&gt; Whatever a test creates, it cleans up, or it creates it in a namespace that gets thrown away. Leftover data from the last run is one of the most common sources of mysterious failures.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Payments.&lt;/strong&gt; Always sandbox. Test cards, a payment provider's test mode, a ledger that can't move real money. Nobody should get a real charge because a test ran.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Waiting.&lt;/strong&gt; Modern systems are eventually consistent. Entitlements are written by a consumer, plans propagate through a cache, a device picks up changes on its next sync. The wrong answer is &lt;code&gt;sleep(5)&lt;/code&gt;. That's too slow when the system is fast and too short when it's slow. The right answer is to poll for the outcome with a bounded timeout, like &lt;code&gt;poll_until&lt;/code&gt; above, and fail with a clear message if the deadline passes. "Eventually" must still have a deadline, otherwise you're not testing a promise.&lt;/p&gt;
&lt;h2&gt;The three objections&lt;/h2&gt;
&lt;p&gt;There are three objections I hear every time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;"It's slow."&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Run them in parallel. Massively parallel. If the journeys are independent, every worker gets its own users and its own data, and a few hundred tests across tens of workers finish in minutes rather than hours.&lt;/p&gt;
&lt;p&gt;The honest small print is that parallelism has a ceiling, and it's usually not the number of workers.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/d5d0f8/parallel-workers.svg" alt="A suite queue fans out to many workers, each with its own user, data and namespace. All of them funnel back into shared dependencies: a shared test database, an auth rate limit, a payment sandbox and one slow service, which set the real clock." width="960" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Workers scale out. Shared dependencies don't. Your suite time is the slowest journey plus whatever everyone queues on.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Fifty workers all logging in at once will find your auth rate limit. They'll find the one small staging database, the payment sandbox's request limit, the service everyone calls that only has one replica. Suite time ends up being roughly the slowest journey plus the queueing at whatever is shared. So the work is: make tests independent, give the environment enough capacity, and treat a sudden slowdown as information about your system, not just a CI annoyance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;"It's flaky."&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A flaky test is a signal, not a nuisance. Often it's telling you the product isn't behaving deterministically: a race between two writes, a retry that double-charges, an event lost under load, a cache serving a stale plan. Those are product bugs, and some of them are exactly the bugs your customers hit once in a hundred times and you can never reproduce. Fix the product.&lt;/p&gt;
&lt;p&gt;But I want to be precise here, because "every flaky test is a product bug" isn't true, and believing it wastes days.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/d5d0f8/flaky-fork.svg" alt="A flaky test forks two ways. The product: a race between writes, a retry that double-charges, a lost event, a stale cache, so fix the product. The harness or environment: sleeps instead of polling, shared users, leftover data, a staging dependency down, so fix the test or environment." width="960" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;A flaky test is always a signal. Find out which branch it's on before you blame the product or the test.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Flakiness can also come from the test harness (a sleep instead of polling, two tests sharing a user, an order dependency) or from the environment (a staging dependency that's down, a noisy neighbour, a clock that's off). The discipline is to find out which branch you're on. Rerun with request ids, timings and logs. If it's the product, fix the product. If it's the test or the environment, fix that, properly, not by adding a retry that hides both.&lt;/p&gt;
&lt;p&gt;What makes outcome-based tests stable is that they aren't coupled to incidental details. If the login journey returns a valid token, it doesn't matter which microservice generated it or which database it hit. The outcome stays the same when the internals change.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;"It's hard to write."&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It was. Before LLMs.&lt;/p&gt;
&lt;h2&gt;Where the AI comes in&lt;/h2&gt;
&lt;p&gt;Now you describe the journey in plain English and the agent writes the test. With realistic data. With proper assertions. With setup and teardown. You review it, tune it and add it to the suite.&lt;/p&gt;
&lt;p&gt;The review is not optional, and it's where my time actually goes.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/d5d0f8/ai-review-loop.svg" alt="A loop: journey in plain English, agent drafts the test, human review, run against a real environment, evidence with ids, logs and diffs, then back to the journey. In the middle the review asks: does it assert the outcome, or just echo the code, and would it fail if the product were broken?" width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The AI writes it. You decide if it's true. Review asks one question: would this fail if the product were broken?&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;The main failure mode of an AI-written test is that it parrots the implementation. If you let the agent read the code first, it will happily write a test that asserts whatever the code currently does, bugs included. So I give it the journey and the public contract, not the internals. Then I review with a few questions:&lt;/p&gt;
&lt;p&gt;→ Does it assert the outcome a user would notice, or just a status code?&lt;/p&gt;
&lt;p&gt;→ Would it fail if the product were broken? (The quickest check: break it on purpose, and watch the test go red.)&lt;/p&gt;
&lt;p&gt;→ Is the data realistic, unique and cleaned up?&lt;/p&gt;
&lt;p&gt;→ Does it wait for outcomes with a deadline, or with sleeps?&lt;/p&gt;
&lt;p&gt;Then it runs against a real environment, and the evidence comes back: pass or fail, with ids, logs and diffs I can actually act on. That loop is fast enough that the bottleneck stops being typing tests and becomes knowing which journeys matter.&lt;/p&gt;
&lt;p&gt;For me, that went from "we should write more integration tests" to "we have about a thousand blackbox tests" in months. Not years. That's my own experience on my own projects, not a benchmark, and your mileage will depend on how testable your environment is. But the shift in what's practical is real.&lt;/p&gt;
&lt;h2&gt;The suite is the spec&lt;/h2&gt;
&lt;p&gt;Here's the part that will really cook your brain: these tests double as documentation.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/d5d0f8/living-spec.svg" alt="A short illustrative test: a prepaid customer in Melbourne subscribes to Sports, the device sees it, billing shows one charge, they cancel, the device no longer sees it, no support tickets. Arrows: a new developer reads what the product does, and CI checks it is still true every deploy." width="960" height="500" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;A suite that reads like a spec, and proves itself on every deploy.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Read a blackbox test and you know exactly what the system does. Not what the code says. What the system actually does when a real user touches it.&lt;/p&gt;
&lt;p&gt;New developer joins the team? Don't just give them a wiki. Give them the test suite. Every user journey, spelled out, with realistic data, verified against a real environment. Unlike the wiki, it can't silently go out of date, because the day it stops being true, CI goes red.&lt;/p&gt;
&lt;p&gt;That's not a test suite. That's a living specification.&lt;/p&gt;
&lt;h2&gt;What happens when you refactor&lt;/h2&gt;
&lt;p&gt;Internal refactors stop breaking tests.&lt;/p&gt;
&lt;p&gt;Because the tests don't know about the internals, they don't care that you rewrote the payment module from scratch. They care that the customer can still buy things and get charged correctly. Rewrite modules, swap databases, split a monolith into services: if the outcomes still match, you're good.&lt;/p&gt;
&lt;p&gt;The one caveat worth saying out loud: if a refactor changes something users can see, a response field, an error message, a timing a device depends on, the blackbox suite &lt;em&gt;will&lt;/em&gt; break. That's not a weakness. That's the suite doing its job, telling you that your "internal" change wasn't internal.&lt;/p&gt;
&lt;p&gt;Try getting that signal from 3,000 unit tests coupled to internal method signatures. I'll wait.&lt;/p&gt;
&lt;h2&gt;Where unit tests still belong&lt;/h2&gt;
&lt;p&gt;I'm deliberately provocative about unit tests, so let me be fair to them. A pure function that calculates GST, parses a date format or rounds a currency amount has dozens of edge cases, and a unit test is the fastest, cheapest place to pin them down. I still write those.&lt;/p&gt;
&lt;p&gt;What I don't write any more is the mock-everything kind: tests that stub out the database, the queue and three of my own services, then assert that a function called another function. Those tests break on every refactor and pass through every real outage. They measure the wrong thing.&lt;/p&gt;
&lt;p&gt;The balance I've landed on: unit tests for logic with many edge cases, blackbox tests for every journey a user or client depends on. When I have to choose where to spend effort, the journeys win.&lt;/p&gt;
&lt;h2&gt;Start today&lt;/h2&gt;
&lt;p&gt;Every blackbox test you don't write is a user journey you're not protecting.&lt;/p&gt;
&lt;p&gt;Every journey you're not protecting is a production incident waiting to happen.&lt;/p&gt;
&lt;p&gt;Every production incident is a week of your life you're not getting back.&lt;/p&gt;
&lt;p&gt;If you're relying on unit tests and manual QA alone to tell you the product works, you're flying with instruments that measure the wrong thing.&lt;/p&gt;
&lt;p&gt;Stop testing how the code works. Start testing what the system does.&lt;/p&gt;
&lt;p&gt;Pick your five most important user journeys. Describe each one in plain English. Hand them to an agent, review what it writes against the questions above, and run them on every deploy. Not next sprint. Not next quarter. Today.&lt;/p&gt;
&lt;p&gt;The AI will write the tests. You just need to describe the journeys.&lt;/p&gt;
&lt;p&gt;What's stopping you?&lt;/p&gt;
&lt;p&gt;&lt;em&gt;All drawings and code here are illustrative, not taken from any production system.&lt;/em&gt;&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Nobody Builds a Road to Nowhere</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/b3667c.html"/>
    <id>https://nehem.dev/b3667c.html</id>
    <published>2026-11-08T00:00:00+10:00</published>
    <updated>2026-11-08T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>AI data centres use real water, power and land. But infrastructure never grows without limit, and water is about where and when. An optimist's case.</summary>
    <category term="AI"/><category term="Infrastructure"/><category term="Energy"/><category term="Sustainability"/>
    <content type="html">&lt;p&gt;"AI data centers will destroy the planet."&lt;/p&gt;
&lt;p&gt;I keep hearing this. And I disagree.&lt;/p&gt;
&lt;p&gt;Not because the concerns aren't real. They are. Data centres use water. They use electricity. They take up land. All true, and I'll put numbers on each of them below.&lt;/p&gt;
&lt;p&gt;But the doom version of the argument stretches those truths far beyond their proportion. It imagines a straight line going up forever: more chips, more halls, more cooling towers, until the server farm is the planet.&lt;/p&gt;
&lt;p&gt;That isn't how infrastructure has ever grown. And it isn't how this will grow either.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/b3667c/hero.svg" alt="Conceptual, not to scale. Left: the fear, a planet tiled edge to edge with server halls. Right: what actually gets built, a planet of rivers, farms, trees and a road, with two small clusters of data centres where power, water, land and a paying customer meet." width="960" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The fear imagines infinite sprawl. What gets built is bounded by power, water, land and someone willing to pay.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;First, the honest numbers&lt;/h2&gt;
&lt;p&gt;I want to start with the facts, because an optimist who skips them isn't an optimist, just someone who hasn't looked.&lt;/p&gt;
&lt;p&gt;The International Energy Agency's &lt;em&gt;Energy and AI&lt;/em&gt; report estimates that data centres used around &lt;strong&gt;415 TWh of electricity in 2024, about 1.5% of the world's electricity&lt;/strong&gt;. Their consumption has grown about 12% a year since 2017, and the IEA's base case projects it to &lt;strong&gt;more than double to around 945 TWh by 2030&lt;/strong&gt;. That last number is a projection, not a measurement, and the IEA's own range for 2035 spans 700 to 1,700 TWh depending on how fast AI is adopted and how quickly efficiency improves. [1]&lt;/p&gt;
&lt;p&gt;So yes, it's growing fast. But the same report also says data centres account for around a tenth of global electricity demand growth to 2030, less than industrial motors, air conditioning or electric vehicles. [1]&lt;/p&gt;
&lt;p&gt;The bigger story is local. In the United States, Lawrence Berkeley National Laboratory estimates data centres used &lt;strong&gt;176 TWh in 2023, 4.4% of the country's electricity&lt;/strong&gt;, and projects 6.7% to 12% by 2028. [2] The IEA notes nearly half of US data centre capacity sits in five regional clusters. [1] A global share of 1.5% can still mean a very large share of one town's grid.&lt;/p&gt;
&lt;p&gt;On water, the same LBNL report estimates US data centres directly consumed about &lt;strong&gt;66 billion litres in 2023&lt;/strong&gt;, mostly for cooling, plus nearly &lt;strong&gt;800 billion litres consumed indirectly&lt;/strong&gt; through the power stations that generated their electricity. [3]&lt;/p&gt;
&lt;p&gt;Those are real numbers. They deserve engineering, not denial. They also don't describe a planet turning into a server farm.&lt;/p&gt;
&lt;h2&gt;Infrastructure has always had a governor&lt;/h2&gt;
&lt;p&gt;Look at how the big infrastructure waves actually went.&lt;/p&gt;
&lt;p&gt;Electricity arrived and wires went up everywhere. Streets, highways, suburbs, countryside. Roads followed the same story, from the Roman network and the Silk Road to concrete highways. Each wave changed the landscape. Each one cut down trees and altered rivers and habitats. I'm not going to pretend otherwise.&lt;/p&gt;
&lt;p&gt;But farming still happens. Water still flows. People still hike. Planes still take off and land. We didn't fill the earth with power lines or pave the whole planet. We built enough to be useful, and then the building slowed.&lt;/p&gt;
&lt;p&gt;Why? Because every one of these things has to be paid for, powered, permitted and placed somewhere. Nobody builds a road to nowhere, because somebody has to pay for it. That constraint is the governor on the engine.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/b3667c/infrastructure-curve.svg" alt="Conceptual curve, not data. A teal S-curve of how much infrastructure gets built rises through: it arrives, it booms fast, fear peaks, only what pays gets built, life adapts, flattening under a dashed coral ceiling labelled power, water, land, capital, permits and demand." width="900" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The shape of the argument: a boom, a peak of fear, then a ceiling set by what can be powered, permitted and paid for.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Data centres have this governor built in, and it's already biting. The IEA estimates around &lt;strong&gt;20% of planned data centre projects could be delayed&lt;/strong&gt; by grid constraints, with new transmission lines taking four to eight years in advanced economies and lead times for transformers and cables doubling in three years. [1] A data centre without a grid connection is an expensive shed.&lt;/p&gt;
&lt;p&gt;I want to be precise about what the governor does and doesn't do, though. Economics limits how much gets built. It does not guarantee that what gets built is a good investment. Booms overshoot. Some projects will lose money, and some regions will get more than they needed for a while. The claim I'm making is narrower: physical and financial limits stop the expansion long before "everything". They always have.&lt;/p&gt;
&lt;h2&gt;"Data centres waste water"&lt;/h2&gt;
&lt;p&gt;This is the argument I hear most, and I think it's both right and wrong.&lt;/p&gt;
&lt;p&gt;Here's what's right about my instinct. The water on this planet isn't going anywhere. It cycles: ocean, atmosphere, rain, ground, river, ocean again. A data centre does not delete water from the Earth.&lt;/p&gt;
&lt;p&gt;Here's what that instinct misses. Hydrologists don't measure water use by whether water leaves the planet. The US Geological Survey defines &lt;strong&gt;consumptive use&lt;/strong&gt; as the part of withdrawn water that is "evaporated, transpired, incorporated into products or crops, consumed by humans or livestock, or otherwise removed from the immediate water environment." [4]&lt;/p&gt;
&lt;p&gt;That word &lt;em&gt;immediate&lt;/em&gt; is the whole point. When a cooling tower evaporates water in a dry basin in summer, that water really does come back as rain. Just not necessarily there, and not necessarily this year. For the farms and homes drawing on the same aquifer, it's gone.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/b3667c/water-local.svg" alt="Left: the global water cycle, atmosphere, rain, ground and river, ocean, with a total that stays about the same. Right: a zoom into one dry basin where a data centre withdraws from the shared aquifer, river or reservoir and evaporates some of it, which is consumed locally even though the rain falls somewhere else, some time later." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The planet keeps its water. A town can still run dry. Both are true.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;So I'd put my original point more carefully. When people say "wasting water", a lot of what they mean is: water that has moved out of reach, and the energy and infrastructure it would take to bring it back. Water goes to the sea? You can desalinate it. Water goes deep underground? You can pump it. Water is dirty? You can treat it.&lt;/p&gt;
&lt;p&gt;Energy is a big part of that cost. It isn't the only part. Desalination leaves brine that has to go somewhere. Pipes, plants and permits take years. Ecosystems depend on rivers actually flowing, not just on the water existing somewhere. Cheap energy makes these problems much easier. It doesn't make them disappear.&lt;/p&gt;
&lt;h2&gt;The engineering is already moving&lt;/h2&gt;
&lt;p&gt;The more encouraging part is that the industry is designing its way out of the worst of this, and it's doing so because water scarcity has become a cost, a permitting risk and a reputational risk.&lt;/p&gt;
&lt;p&gt;Microsoft says that since August 2024 all its new data centre designs use chip-level, closed-loop liquid cooling that &lt;strong&gt;evaporates zero water for cooling&lt;/strong&gt;. The loop is filled once during construction and recirculated. They estimate it avoids more than 125 million litres a year per data centre, with pilots in Phoenix and Wisconsin from 2026. They're also candid about the trade: replacing evaporation with mechanical cooling means "a nominal increase" in annual energy use. [5]&lt;/p&gt;
&lt;p&gt;That trade-off is the honest shape of the whole debate.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/b3667c/cooling-trade.svg" alt="Three cooling choices as panels. Evaporative: less electricity but evaporates water on site, hard on dry towns. Closed loop: water filled once and recirculated, no evaporation for cooling, chillers use more power. Reclaimed or seawater: non-potable sources that need treatment and pipes, with outfalls and brine to manage." width="960" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Every cooling choice is a trade between water, electricity, money and the local environment. There is no free option.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Evaporative cooling saves electricity and spends water. Closed loops save water and spend some electricity. Reclaimed water or seawater avoids drinking water but needs treatment, pipes and somewhere for the brine or warm discharge to go. Where you build decides which trade makes sense. In a wet, cool climate on a clean grid, it's an easy call. In a desert on a gas-heavy grid, it's a hard one.&lt;/p&gt;
&lt;p&gt;That's not a reason for doom. It's a reason to site and design carefully.&lt;/p&gt;
&lt;h2&gt;Where AI helps the energy problem&lt;/h2&gt;
&lt;p&gt;Now the part I'm genuinely optimistic about.&lt;/p&gt;
&lt;p&gt;I don't think data centres only consume energy. I think AI can help us produce more of it, run it smarter and waste less of it. The IEA, which is hardly a cheerleader, lays out some of the opportunities: [1]&lt;/p&gt;
&lt;p&gt;→ AI-based fault detection that can cut outage durations by 30–50%.&lt;/p&gt;
&lt;p&gt;→ Sensors and AI management that could unlock up to 175 GW of extra transmission capacity on existing lines, more than the base-case increase in data centre load to 2030.&lt;/p&gt;
&lt;p&gt;→ Existing AI applications in buildings that, if scaled up, could save around 300 TWh of electricity, roughly the annual generation of Australia and New Zealand combined.&lt;/p&gt;
&lt;p&gt;→ Faster discovery of materials for solar, batteries and carbon capture, where only a tiny fraction of candidate materials has ever been made and tested.&lt;/p&gt;
&lt;p&gt;Those are potentials, not results. The IEA is careful to say so, and I want to be too. Its own estimate is that broad use of existing AI solutions could cut emissions by an amount equivalent to about 5% of energy-related emissions in 2035. That's far larger than data centre emissions, and far smaller than what climate change needs. In the IEA's words, AI "is not a silver bullet and does not remove the need for proactive policy." [1]&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/b3667c/ai-energy-loop.svg" alt="A loop, labelled an opportunity not a guarantee: compute, smarter grids, new materials, cheaper clean power, cheaper water through recycling and desalination, back to compute. In the middle: it only spins if grids and permits keep up, the gains get deployed, rebound effects are managed and policy prices the side effects." width="960" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The loop I'm betting on. It only spins if the gains actually get built and deployed.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;This is the loop I'm betting on: compute helps make energy cheaper and cleaner, cheaper energy makes water easier to recycle and move, and that supports more compute. It isn't automatic. Every arrow in it needs someone to build something, approve something or pay for something.&lt;/p&gt;
&lt;h2&gt;The market is the governor. It needs a second hand on it.&lt;/h2&gt;
&lt;p&gt;I still believe the core of my argument. Nobody builds a data centre they don't expect to pay for itself. Nobody strings power lines to empty land. Financial constraint has always limited infrastructure, and it will limit this.&lt;/p&gt;
&lt;p&gt;But I've changed one thing in how I say it. The market limits how &lt;em&gt;much&lt;/em&gt; gets built. It doesn't automatically count everything that building costs.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/b3667c/market-ledger.svg" alt="Two columns. On the invoice: land and construction, chips and servers, electricity and water at the meter, grid connection fees. Often not on it: an aquifer in a drought year, local grid upgrades others fund, emissions from the power mix, noise, land and habitat, a bubble that overbuilds." width="900" height="400" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Prices, permits and local rules are how the costs on the right get onto the invoice on the left.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;An operator pays for the land, the chips and the electricity at the meter. They don't automatically pay for a drawn-down aquifer in a drought year, a grid upgrade that other customers end up funding, or the emissions of the power mix. Those costs are real, and they only reach the invoice through water pricing, connection rules, planning conditions and disclosure.&lt;/p&gt;
&lt;p&gt;That's not an argument against data centres. It's how every infrastructure wave got civilised: roads got environmental reviews, power stations got emission limits, factories got discharge permits. Good rules didn't stop the build. They made it fit.&lt;/p&gt;
&lt;h2&gt;Where I land&lt;/h2&gt;
&lt;p&gt;AI data centres are becoming critical infrastructure, like electricity, roads and running water. Saying "data centres are bad for the environment" is a lot like saying "building roads is bad for the countryside". Technically true. Missing most of the point.&lt;/p&gt;
&lt;p&gt;So here's my position, as precisely as I can put it.&lt;/p&gt;
&lt;p&gt;Will there be growing pains? Yes.&lt;/p&gt;
&lt;p&gt;Will there be real environmental impact during the boom, especially in a few concentrated places? Yes.&lt;/p&gt;
&lt;p&gt;Will the entire planet become a server farm? No. Power, water, land, capital and permits make sure of that.&lt;/p&gt;
&lt;p&gt;Will AI pay back its footprint by making energy and water systems smarter? It can. Whether it does depends on engineering, siting, incentives and governance, not on optimism alone.&lt;/p&gt;
&lt;p&gt;The fear is understandable. The doom is disproportionate. We've been here before with electricity, with roads, with every infrastructure leap. We adapted every time, because people did the work of adapting. We'll adapt again the same way.&lt;/p&gt;
&lt;p&gt;Where do you stand on the AI infrastructure debate?&lt;/p&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;International Energy Agency, &lt;a href="https://www.iea.org/reports/energy-and-ai/executive-summary"&gt;Energy and AI: Executive summary&lt;/a&gt; (2025). Figures for 2030 and 2035 are IEA projections and scenario ranges.&lt;/li&gt;
&lt;li&gt;Lawrence Berkeley National Laboratory, &lt;a href="https://newscenter.lbl.gov/2025/01/15/berkeley-lab-report-evaluates-increase-in-electricity-demand-from-data-centers/"&gt;Berkeley Lab Report Evaluates Increase in Electricity Demand from Data Centers&lt;/a&gt; (January 2025). 2028 figures are scenario ranges.&lt;/li&gt;
&lt;li&gt;Shehabi et al., &lt;a href="https://eta-publications.lbl.gov/sites/default/files/2024-12/lbnl-2024-united-states-data-center-energy-usage-report_1.pdf"&gt;2024 United States Data Center Energy Usage Report&lt;/a&gt;, Lawrence Berkeley National Laboratory (December 2024), section on water.&lt;/li&gt;
&lt;li&gt;U.S. Geological Survey, &lt;a href="https://pubs.usgs.gov/chapter11/chapter11M.html"&gt;Water-use glossary: consumptive use&lt;/a&gt;, and &lt;a href="https://www.usgs.gov/special-topics/water-science-school/science/water-cycle-adults-and-advanced-students"&gt;the USGS water cycle diagrams&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Microsoft, &lt;a href="https://www.microsoft.com/en-us/microsoft-cloud/blog/2024/12/09/sustainable-by-design-next-generation-datacenters-consume-zero-water-for-cooling/"&gt;Sustainable by design: Next-generation datacenters consume zero water for cooling&lt;/a&gt; (December 2024). Company claims, not independent measurements.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;All drawings are conceptual illustrations, not to scale and not data.&lt;/em&gt;&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>The Cheapest Line Item</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/c93c8c.html"/>
    <id>https://nehem.dev/c93c8c.html</id>
    <published>2026-11-06T00:00:00+10:00</published>
    <updated>2026-11-06T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>The cost of the model thinking is nothing compared to the cost of a wrong answer. Tokens are cheap. Your time is not. Stop optimising for the cheapest line item.</summary>
    <category term="AI"/><category term="AI Agents"/><category term="Developer Productivity"/><category term="Debugging"/>
    <content type="html">&lt;p&gt;The cost of the model thinking is nothing compared to the cost of a wrong answer.&lt;/p&gt;
&lt;p&gt;Let that sink in for a second, because most of the advice going around right now points the other way.&lt;/p&gt;
&lt;p&gt;People are out here choosing faster, cheaper models to save a few cents per query. Turning off extended thinking to shave seconds. Picking the lightweight option because "it's good enough."&lt;/p&gt;
&lt;p&gt;Good enough for what?&lt;/p&gt;
&lt;p&gt;I've been running AI agents on real production work for six months now. Bugs, incidents, investigations, fixes that go out to real users. And the single biggest lesson I've taken from it is almost boring in how obvious it sounds once you say it out loud: the model's thinking time is the cheapest part of the entire pipeline. Everything else around it, especially the humans, costs far more.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/c93c8c/hero.svg" alt="A tiny teal bar labelled thinking, a few cents, next to a tall coral stack labelled a wrong answer: symptom fix, deploy, alert returns, second investigation, second PR, review and deploy, customer impact." width="960" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The tokens are cheap. The wrong answer isn't.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;What "saving on thinking" actually costs&lt;/h2&gt;
&lt;p&gt;Here's the scenario I keep seeing. An agent investigates a production bug. It's running on the fast option, or the thinking budget has been turned down, because the investigation "looked simple". It comes back quickly with a confident root cause. The root cause is wrong.&lt;/p&gt;
&lt;p&gt;Nothing about that moment feels expensive. The answer arrived in ten seconds. It read well. It sounded sure of itself. The cost doesn't show up there. It shows up over the next several days, one perfectly reasonable step at a time:&lt;/p&gt;
&lt;p&gt;→ A fix that addresses the symptom, not the cause.&lt;/p&gt;
&lt;p&gt;→ A deploy that doesn't actually fix anything.&lt;/p&gt;
&lt;p&gt;→ The same alert firing again three days later.&lt;/p&gt;
&lt;p&gt;→ A second investigation from scratch.&lt;/p&gt;
&lt;p&gt;→ A second PR, a second review, a second deploy.&lt;/p&gt;
&lt;p&gt;→ And whatever customer impact accumulated in between.&lt;/p&gt;
&lt;p&gt;What makes this nasty is that every step after the first one is done properly. The fix is well written. The PR is reviewed. The deploy goes out cleanly. The team is doing good work, on the wrong problem. Nobody is being careless. The mistake was made once, at the very top, and everything downstream faithfully inherits it.&lt;/p&gt;
&lt;p&gt;And the second investigation is not cheaper than the first. It's usually more expensive, because now you also have to unpick the first theory, explain why the fix didn't work and convince yourself the new answer isn't another confident guess.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/c93c8c/rework-loop.svg" alt="A loop of six boxes: wrong root cause, symptom fix, deploy, alert fires again, second investigation, second PR, review and deploy, and back round. In the middle, customer impact accumulates." width="600" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Every step after the first is done properly. On the wrong problem.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Now put that next to what you saved. The "expensive" model that took 90 seconds to think instead of 10? It would have cost you about $0.30 more.&lt;/p&gt;
&lt;p&gt;The wrong answer cost you a week.&lt;/p&gt;
&lt;h2&gt;Let me put actual numbers on this&lt;/h2&gt;
&lt;p&gt;These are the rough numbers I work with. They're not precise, and they don't need to be, because the gap is so wide that precision doesn't change the conclusion.&lt;/p&gt;
&lt;p&gt;→ A senior developer's time: $80-150/hour.&lt;/p&gt;
&lt;p&gt;→ A production rollback: 2-4 hours of team time.&lt;/p&gt;
&lt;p&gt;→ A wrong root cause that sends you down the wrong path: half a day, minimum.&lt;/p&gt;
&lt;p&gt;→ Extended thinking on the best available model: a few cents. Maybe a dollar for a complex investigation.&lt;/p&gt;
&lt;p&gt;Do the simple arithmetic on just one of those lines. Half a day is about four hours. At $80-150 an hour, that's roughly $320-600 of one senior developer's time, and that's the minimum, for one person, before anyone else gets pulled in. A rollback is 2-4 hours of team time, so multiply by however many people are in the room for it.&lt;/p&gt;
&lt;p&gt;On the other side of the ledger: a few cents. Maybe a dollar.&lt;/p&gt;
&lt;p&gt;Even in the most generous framing for the cheap option, a dollar of thinking against a few hundred dollars of one person's half day is a difference of hundreds of times. Stretch that out to the week the wrong answer actually cost, and it isn't worth doing the division.&lt;/p&gt;
&lt;p&gt;The economics aren't even close.&lt;/p&gt;
&lt;p&gt;And yet people optimise for the cheapest part.&lt;/p&gt;
&lt;p&gt;It's like buying the cheapest tyres for a race car. You saved $200 and lost the race. The tyres were never the expensive bit. They were just the bit with a price tag you could see.&lt;/p&gt;
&lt;p&gt;That's the trap, I think. Token costs show up on a dashboard, itemised, per query, with a nice graph. The cost of a wrong answer doesn't show up anywhere. It's spread across calendars, standups, a re-opened ticket, a slightly annoyed customer. So people trim the line item they can see and quietly pay the one they can't.&lt;/p&gt;
&lt;h2&gt;The question that changed my approach&lt;/h2&gt;
&lt;p&gt;For a while I picked models the way most people do. Which one is cheapest for this? Which one is fast enough? Can I get away with the small one here?&lt;/p&gt;
&lt;p&gt;Then I flipped the question. I stopped asking "which model is cheapest?" and started asking:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;"What's the cost if this answer is wrong?"&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;That one question sorts almost every task I give an agent. Here are three from my real work, and all three get the same treatment.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Investigating a concurrency bug in a connection pool that's causing auth failures.&lt;/strong&gt; That's a top-tier model with max reasoning. Non-negotiable. Concurrency bugs are exactly where a plausible story is easy to tell and hard to verify. Get it wrong and you ship a fix for a race that isn't the race.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tracing a content visibility leak across three API layers.&lt;/strong&gt; Same. Full power. A visibility leak means someone is seeing something they shouldn't, or not seeing something they should. The answer has to be right at every layer, not just the first one the model looks at.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Correlating 30 days of error data to measure whether shipped fixes actually worked.&lt;/strong&gt; Same. This one is sneaky, because it feels like reporting rather than engineering. But the output decides whether we call a problem solved and move on. A wrong "yes, it worked" is how the same incident comes back next quarter with nobody looking for it.&lt;/p&gt;
&lt;p&gt;These are high-stakes questions. A wrong answer doesn't just waste tokens. It wastes human time, the most expensive resource in the pipeline.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/c93c8c/decision-rule.svg" alt="A decision diagram. Top: what's the cost if this answer is wrong? Low leads to a fast, cheap model for the debrief, formatting and summaries. High leads to the strongest model at highest effort when the answer drives a decision, a deploy or a customer-facing change." width="600" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;One question decides the model. Not the price per token.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;It doesn't just think longer. It thinks differently.&lt;/h2&gt;
&lt;p&gt;This is the counterintuitive part, and it's the bit that actually changed my mind rather than just my spreadsheet.&lt;/p&gt;
&lt;p&gt;I used to imagine extended thinking as the same answer with extra steps. Same conclusion, more words getting there, a bit more polish. If that were true, turning it off would be a reasonable saving.&lt;/p&gt;
&lt;p&gt;It isn't true. Extended thinking is the model considering possibilities it would have skipped in fast mode. Checking its own reasoning. Going back to a piece of evidence and asking whether it really supports the story. Catching the subtle thing that changes the whole picture.&lt;/p&gt;
&lt;p&gt;Here's the example that made it click for me.&lt;/p&gt;
&lt;p&gt;I've seen an agent in fast mode look at a set of auth failures and confidently say "root cause: connection pool exhaustion", and move on. It's a perfectly reasonable answer. Auth is failing, connections are involved, pools run out. It's the kind of root cause that sounds right in a standup.&lt;/p&gt;
&lt;p&gt;Same agent, same problem, with extended thinking, said something different:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"Wait, the pool metrics are normal. The connection that failed was in a subscribed state. This is a pub/sub cleanup race, not a pool issue."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Same logs. Same code. Completely different conclusion. The second one was right.&lt;/p&gt;
&lt;p&gt;Look at what that "wait" is doing. It's the model checking its first theory against evidence it already had. The pool metrics were right there. The fast answer simply never went back to look at them, because it had a story that fit well enough. The thinking answer did go back, found the story didn't fit, and then noticed the detail that actually mattered: the state of the connection that failed.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/c93c8c/same-logs.svg" alt="Auth-failure evidence forks two ways. Fast mode says connection pool exhaustion, which leads to the wrong theory and a week chasing it. Extended thinking notices the pool metrics are normal and the failed connection was in a subscribed state, so it's a pub/sub cleanup race." width="600" height="680" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Same logs, same code. The extra thinking changed the conclusion, not just the length.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;That extra 60 seconds of thinking saved a week of chasing the wrong theory.&lt;/p&gt;
&lt;p&gt;If the fast answer had gone out, the likely path is the loop from earlier. Someone tunes the pool. The deploy goes out. The pool metrics, which were already normal, stay normal. The auth failures come back. And then we start again, now with a fix in production that didn't fix anything and needs explaining.&lt;/p&gt;
&lt;h2&gt;My rule now&lt;/h2&gt;
&lt;p&gt;So here's where I've landed, and I don't make exceptions to it any more.&lt;/p&gt;
&lt;p&gt;If the answer drives a decision, a deploy, or a customer-facing change, use the strongest model at the highest effort. Always. No exceptions.&lt;/p&gt;
&lt;p&gt;That doesn't mean everything needs the biggest model. Save the fast, cheap model for the debrief. For formatting. For the parts where accuracy was already established and you just need a summary. I wrote about that split in more detail in &lt;a href="https://nehem.dev/4350e5.html"&gt;Cut to the Chase&lt;/a&gt;: let the strong model do the hard thinking, then hand its notes to a fast one to tell me what it found in a few lines. Speed is genuinely valuable there, because the expensive question has already been answered properly.&lt;/p&gt;
&lt;p&gt;But for the work that matters? Let the model think.&lt;/p&gt;
&lt;p&gt;The tokens are cheap. Your time is not. The wrong answer is the most expensive thing in your workflow.&lt;/p&gt;
&lt;p&gt;Stop optimising for the cheapest line item.&lt;/p&gt;
&lt;p&gt;What's the most expensive wrong answer you've seen from a "fast" approach?&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Cut to the Chase</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/4350e5.html"/>
    <id>https://nehem.dev/4350e5.html</id>
    <published>2026-11-05T00:00:00+10:00</published>
    <updated>2026-11-05T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Let the strongest model think as long as it needs. Then hand the debrief to a fast one. Verbose is good at the wrong time and costly at the right one.</summary>
    <category term="AI"/><category term="AI Agents"/><category term="Developer Productivity"/><category term="Engineering Culture"/>
    <content type="html">&lt;p&gt;Cut to the chase.&lt;/p&gt;
&lt;p&gt;Focus is expensive. I don't have time. You don't have time. Nobody has time. And yet most AI output reads like it's being paid by the word.&lt;/p&gt;
&lt;p&gt;"Certainly! Here's a comprehensive overview of the potential considerations you might want to take into account when evaluating the various approaches to..."&lt;/p&gt;
&lt;p&gt;Stop. I already know the approaches. I evaluated them yesterday. I just need the answer.&lt;/p&gt;
&lt;p&gt;For a long time I treated this as a prompting problem. Add "be concise" to the system prompt, add "no preamble", add "don't repeat the question". It helps a little. Then the next task needs real depth, and the same instruction makes the agent cut corners exactly where I didn't want it to. I'd swing the dial back, and the waffle came back with it.&lt;/p&gt;
&lt;p&gt;It took me an embarrassingly long time to see that I was trying to fix two different jobs with one setting.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4350e5/hero.svg" alt="On the left, a small agent at a desk surrounded by long, scribbled pages of notes. A single arrow leads right to a short card with one bold teal line at the top, held up to a person." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The thinking can be long. The answer shouldn't be.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Two completely different modes of work&lt;/h2&gt;
&lt;p&gt;When I work with AI agents now, almost everything falls into one of two modes, and they need different things from the model.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Mode 1 is the agent doing the hard work.&lt;/strong&gt; Investigating a production bug. Reading thirty files. Pulling logs. Cross-referencing data. Building a timeline. Writing the fix. Running the tests. Going back when the tests fail.&lt;/p&gt;
&lt;p&gt;This is not the time to cut corners. This is the time for maximum reasoning: the strongest model I have access to, the highest effort level, and as long as it needs to think. Let it write ten pages of analysis nobody will read. That's fine. The fluff isn't fluff here. It's the agent reasoning out loud, working through possibilities, eliminating hypotheses. That verbose internal monologue is how it gets to the right answer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Mode 2 is me making the judgment call.&lt;/strong&gt; The investigation is done. The analysis exists. The options are laid out. Now I need to understand, decide and move.&lt;/p&gt;
&lt;p&gt;This is a debrief, not a discovery session. I don't need the agent to re-explore the entire solution space. I don't need three paragraphs of context I already have. I don't need "Great question!" before the answer. I need three things: here's what we found, here's what it means, here's what I'd do. Done.&lt;/p&gt;
&lt;p&gt;That's where "cut to the chase" comes in.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4350e5/two-modes.svg" alt="Two horizontal lanes over time. The top lane, deep work, is long and full of dense scribbled loops, branches and crossed-out dead ends. At its end a notes file drops down to the bottom lane, debrief, which is a short, clean straight line ending in a decision tick." width="600" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Mode 1 is long and messy on purpose. Mode 2 is short and clean on purpose. The handoff between them is a file.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;You don't just change the prompt. You change the model.&lt;/h2&gt;
&lt;p&gt;This was the part that surprised me.&lt;/p&gt;
&lt;p&gt;My first instinct was to keep one model and change the instructions between phases. "Now summarise." It works, sort of. But a model tuned to think hard tends to keep thinking hard when you ask it for a summary. It re-opens questions. It hedges. It reaches for completeness because completeness is what made it good at the first job. You end up with a summary that is itself six paragraphs long and still mentions the three hypotheses it already ruled out.&lt;/p&gt;
&lt;p&gt;So I split it.&lt;/p&gt;
&lt;p&gt;For deep work, I use the strongest reasoning model available and let it run hot. The cost of thinking is nothing compared to the cost of a wrong answer. A wrong root cause on a production incident costs a second incident, a rollback, a weekend, sometimes a customer. Thinking tokens are cheap by comparison, and they get cheaper every few months.&lt;/p&gt;
&lt;p&gt;For the debrief, I switch to a fast, articulate model. One that sounds human. Gets to the point. Doesn't pad. Doesn't hedge. Doesn't repeat my question back to me before answering it.&lt;/p&gt;
&lt;p&gt;Think about how a good team already works. You wouldn't send your most thorough, methodical engineer to give a two-minute status update to the CTO. That engineer is exactly the person you want on the investigation. They will check the thing everyone else assumed. But ask them for a status update and you get the full history of every theory, in order, because to them the history is the point.&lt;/p&gt;
&lt;p&gt;You'd send the person who can summarise a week of work in three sentences without losing the substance. Not because they're smarter. Because that's a different skill, and the CTO's next twenty minutes depend on it.&lt;/p&gt;
&lt;p&gt;Same principle. Different model for a different job.&lt;/p&gt;
&lt;h2&gt;Why the verbose part is not waste&lt;/h2&gt;
&lt;p&gt;I want to defend the long, rambling part properly, because "AI is too verbose" has become a lazy complaint and it gets aimed at the wrong place.&lt;/p&gt;
&lt;p&gt;When an agent investigates, its written-out reasoning is doing real work. It's the scratchpad. "The error started at 14:02. The deploy finished at 13:58. That's suspicious, but the error rate is flat for four minutes after, so maybe not the deploy. Let me check what else changed at 14:00. There's a cron job..." Every one of those sentences is a step that, if skipped, could send the investigation the wrong way. A good engineer does exactly the same thing in their head or on a notepad. We just never had to read it.&lt;/p&gt;
&lt;p&gt;Cut that short and you don't get a faster correct answer. You get a faster guess.&lt;/p&gt;
&lt;p&gt;So I don't want the deep-work model to be concise. I want it to be thorough, to write its notes down, and to leave them somewhere I can check if I ever need to. I just don't want to be the one reading them by default.&lt;/p&gt;
&lt;h2&gt;The fluff problem is a timing problem&lt;/h2&gt;
&lt;p&gt;Here's the reframe that made all of this click for me.&lt;/p&gt;
&lt;p&gt;The fluff problem isn't that AI generates too many words. It's that it generates too many words at the wrong time.&lt;/p&gt;
&lt;p&gt;During investigation, verbose is good. That's the agent processing. During the debrief, every unnecessary sentence is a tax on human attention.&lt;/p&gt;
&lt;p&gt;And human attention is the most expensive resource in the entire pipeline. More expensive than compute. More expensive than tokens. More expensive than the model itself.&lt;/p&gt;
&lt;p&gt;Look at what's actually scarce in a working day. I can buy more compute with a credit card in a minute. I can run the investigation again overnight. I can't buy more of my own focus. I get a few good hours a day where I can make careful decisions, and every one of those hours is shared between code review, incidents, design calls and the people I work with. When a debrief burns ten minutes of that on preamble, that's ten minutes I didn't spend deciding something else well.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4350e5/cost-of-attention.svg" alt="An illustrative sketch with no numbers. Two bars per stage across the pipeline: investigation, writing notes, the debrief. Machine cost, sketched in grey, is tall during investigation and tiny for the debrief. Human attention, in coral, is near zero during investigation and tall at the debrief, where it is the dominant cost." width="600" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Illustrative only, not measured and not to scale. The machine spends most during the investigation. The human spends most at the debrief, and that's the bill worth cutting.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;That picture is deliberately rough. I'm not claiming numbers. The shape is the point. The machine's cost peaks while it investigates, and that's exactly where I want to spend more, not less. My cost peaks at the moment I read the result. That's the only place where cutting words saves anything that matters.&lt;/p&gt;
&lt;h2&gt;Paragraph six&lt;/h2&gt;
&lt;p&gt;One more thing most people haven't realised: this isn't just about saving time. It's about decision quality.&lt;/p&gt;
&lt;p&gt;When an agent buries the key finding inside paragraph six of a twelve-paragraph response, you're not just slower. You're more likely to miss it.&lt;/p&gt;
&lt;p&gt;Be honest about how you read long AI responses. I know how I do. I read the first paragraph carefully. I skim the second. By the fourth I'm reading the first few words of each line, looking for something that sounds like an answer. When I find something that sounds like one, I stop and move on. I pattern-match on the first plausible conclusion.&lt;/p&gt;
&lt;p&gt;If the real finding is in paragraph six, and paragraph two contained a plausible-sounding hypothesis the agent later ruled out, I can walk away with the ruled-out one. Not because the agent was wrong. Because the agent was right in the wrong place.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4350e5/paragraph-six.svg" alt="Two responses side by side, with a pencil eye-path drawn over each. On the left, a long response of twelve paragraphs: the eye path reads the first lines closely, then zig-zags faster and fades out around paragraph four; the key finding, highlighted in teal, sits in paragraph six, past where the path fades. On the right, a short debrief with the key finding as its first line, right where the path starts." width="600" height="640" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Most of us read long responses like this. Put the finding where the eye actually is.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;A concise debrief doesn't just respect your time. It forces the important thing to be the first thing you read. That's not a style preference. That's a design decision for better outcomes.&lt;/p&gt;
&lt;h2&gt;What this looks like on a real bug&lt;/h2&gt;
&lt;p&gt;Let me make this concrete with an example. It's illustrative, a composite of the kind of incident I've worked many times, not a transcript.&lt;/p&gt;
&lt;p&gt;Checkout requests start failing intermittently on a Tuesday afternoon. Around one in fifty orders gets a 502. I hand it to the deep-work agent with the logs, the deploy history, the service map and the repo. Then I go and do something else.&lt;/p&gt;
&lt;p&gt;It spends a long time. It reads the load balancer logs and finds the 502s cluster on one upstream. It checks the deploy history: a payment client library was bumped that morning. It reads the library's changelog and finds a default connection pool size went down. It cross-references traffic: the failures line up with the afternoon peak, not with the deploy time. It reads the client code and finds we never set the pool size explicitly. It considers and rules out a DNS change, a certificate rotation and a database lock it found in the logs. It writes a fix that sets the pool size, writes a test, runs the suite. Its notes run to many pages.&lt;/p&gt;
&lt;p&gt;Now here are two ways that work can come back to me.&lt;/p&gt;
&lt;p&gt;The first is what I used to get by default:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Certainly! I've completed a thorough investigation into the intermittent 502 errors affecting the checkout service. This was a complex issue with several potential contributing factors, so let me walk you through my analysis step by step.&lt;/p&gt;
&lt;p&gt;First, I examined the overall error landscape. Errors began on Tuesday afternoon and affected roughly 2% of checkout requests. Initially, I considered whether a recent DNS change could be responsible, since DNS issues often manifest as intermittent upstream failures...&lt;/p&gt;
&lt;p&gt;Next, I looked at the database. I noticed some lock waits around the same period, which could plausibly cause timeouts...&lt;/p&gt;
&lt;p&gt;&lt;em&gt;(three more paragraphs of eliminated hypotheses)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Interestingly, I found that the payment client library was updated this morning, and the new version reduces the default connection pool size. Since our code doesn't set this explicitly, under peak load...&lt;/p&gt;
&lt;p&gt;&lt;em&gt;(two paragraphs of fix details, then "I hope this helps! Let me know if you have any questions.")&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Everything in it is true. The finding is in there. It's just in paragraph six, behind a DNS theory and a database theory, both of which I could easily walk away believing if I'm reading it between two meetings.&lt;/p&gt;
&lt;p&gt;The second is the debrief I want:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Finding:&lt;/strong&gt; The 502s come from the payment client running out of connections at peak. This morning's library upgrade lowered the default pool size, and we never set it ourselves.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What it means:&lt;/strong&gt; It's not data loss. Failed checkouts weren't charged. It will get worse at the evening peak.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What I'd do:&lt;/strong&gt; Ship the one-line fix in the PR I opened, which pins the pool size to the old default. It has a test. Then add the pool size to our config so library defaults can't move it again.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Confidence:&lt;/strong&gt; High. Failures line up with pool exhaustion warnings to the second. Evidence: &lt;code&gt;notes/checkout-502.md&lt;/code&gt;, sections 3 and 4.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Not checked:&lt;/strong&gt; Whether the other two services on the same library are affected. Same risk, lower traffic.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Same investigation. Same facts. One of them I can act on in a minute, standing up. The other I have to read twice and hope I read the right part.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4350e5/verbose-vs-tight.svg" alt="Two cards side by side. The left card is long, with twelve grey paragraph lines; a small teal highlight sits in paragraph six with a coral arrow pointing at it labelled 'the finding'. The right card is short, with five labelled rows: finding (teal, first), meaning, what I'd do, confidence, not checked." width="600" height="620" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Same facts, two shapes. The finding is either where you look first or where you stopped looking.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;The handoff: notes in a file, debrief in a fixed shape&lt;/h2&gt;
&lt;p&gt;Here's how I actually wire it, because "use two models" is easy to say and easy to get wrong.&lt;/p&gt;
&lt;p&gt;The deep-work agent's last job is to write its notes to a file. Not a summary, the notes: the timeline, the evidence with links to the log lines and commits, every hypothesis and why it was kept or ruled out, the fix, the test results. Markdown is fine. It's for the record, and for the second model.&lt;/p&gt;
&lt;p&gt;Then a second, fast model reads that file and produces the debrief. Its instructions are short and strict. Answer in this shape and nothing else: the finding, what it means, what I'd do, how confident you are and why, and what was not checked. First line is the finding. No preamble, no sign-off. Every claim points back at a section of the notes.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4350e5/handoff.svg" alt="A pipeline sketch. On the left, a large deep-work agent with a dense scribbled page labelled notes.md. An arrow carries the file to a small, quick agent in the middle. An arrow from it leads to a short card with five labelled rows: finding, meaning, recommendation, confidence, not checked. A dashed arrow loops from the card back to notes.md, labelled 'cite'." width="600" height="700" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The deep-work model writes the record. The fast model writes the debrief, in a fixed shape, citing the record.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;There are a few reasons this works better than asking one model to do both.&lt;/p&gt;
&lt;p&gt;The file is a clean boundary. The fast model doesn't inherit the deep model's habits, its half-explored branches, or its urge to show its work. It gets a finished body of evidence and one job.&lt;/p&gt;
&lt;p&gt;The file outlives the conversation. If I want to check the reasoning, it's there. If I hand the incident to a colleague, I hand them the debrief and the file. The debrief is the front page; the notes are the appendix. That's how good incident reports have always worked. We just used to write both by hand.&lt;/p&gt;
&lt;p&gt;And the shape is fixed, so I learn where to look. After a week of debriefs in the same shape, my eyes go straight to "Finding" and "Not checked". That's a small thing that makes a big difference when you read a lot of them.&lt;/p&gt;
&lt;h2&gt;Cut to the chase is not permission to be wrong&lt;/h2&gt;
&lt;p&gt;This is the counterintuitive part, and it's the part I care about most.&lt;/p&gt;
&lt;p&gt;"Cut to the chase" is not "skip the hard work". It's not "give me the first thing that sounds good". It's the opposite. The agent already did the hard work. It already went through the whole universe of information: the markdown files, the proof, the citations, the progress logs, the test results, the PR descriptions. Cut to the chase means you've done the thinking, now give me the conclusion. Tight. Clean. No ceremony.&lt;/p&gt;
&lt;p&gt;But short text has its own failure mode. A confident three-line answer reads as more certain than it is. Padding at least has the side effect of exposing doubt; a tight debrief can hide it. So the guardrails go into the shape itself.&lt;/p&gt;
&lt;p&gt;The debrief has to cite where the evidence is. Not "I checked the logs", but which section of the notes, which log query, which commit. If it can't point at evidence, it doesn't get to say it.&lt;/p&gt;
&lt;p&gt;It has to state its confidence and the reason for it in a sentence. "High, because the timing matches to the second" is useful. "High" on its own is decoration.&lt;/p&gt;
&lt;p&gt;It has to list what was not checked. This is the line I read most carefully. Every investigation has edges, and the most dangerous ones are the ones nobody mentions. A verbose response often hides its gaps in paragraph nine. A good debrief puts them on the page in their own row, where I can't miss them.&lt;/p&gt;
&lt;p&gt;And it doesn't get to add anything that isn't in the notes. The fast model is a writer, not a second investigator. If it thinks something's missing, the right move is to say so under "not checked", not to quietly fill the gap with something that sounds right.&lt;/p&gt;
&lt;p&gt;With those four rules, short stops meaning shallow. It means compressed, with the compression made visible.&lt;/p&gt;
&lt;h2&gt;My setup, today&lt;/h2&gt;
&lt;p&gt;So here's where I've landed.&lt;/p&gt;
&lt;p&gt;Deep work goes to the strongest model with maximum effort and as much thinking time as it wants. It writes everything down. I don't read it unless I need to.&lt;/p&gt;
&lt;p&gt;The debrief goes to a fast model with a direct tone and zero padding, in the same five-part shape every time, citing the notes.&lt;/p&gt;
&lt;p&gt;Two modes. Two models. One workflow. The agent does the hard thinking. I do the hard deciding. Nobody wastes time on ceremony.&lt;/p&gt;
&lt;p&gt;I expect the details to change. Models get faster, and the strong ones get better at switching register on their own. Maybe one day a single model will do both jobs well. The principle won't change, though. Thinking should be as long as the problem needs, and the answer should be as short as the reader can afford. Those are two different budgets, and the second one is mine.&lt;/p&gt;
&lt;p&gt;Cut to the chase isn't lazy. It's what happens when you respect both the work and the human reading it.&lt;/p&gt;
&lt;p&gt;What's your setup? One model for everything, or have you started splitting the modes?&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>The Ticket Title Is Not the Bug</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/4037c1.html"/>
    <id>https://nehem.dev/4037c1.html</id>
    <published>2026-11-05T00:00:00+10:00</published>
    <updated>2026-11-05T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>In 1973 Rosenhan showed how a label rewrites every observation after it. Engineers do the same with ticket titles, and AI agents can help us stop.</summary>
    <category term="AI"/><category term="AI Agents"/><category term="Debugging"/><category term="Engineering Culture"/>
    <content type="html">&lt;p&gt;The ticket said "database issue".&lt;/p&gt;
&lt;p&gt;It was assigned to me with a high priority flag, a screenshot of a timeout and a one-line description from someone who had clearly had a bad morning. So I did what I'd been trained to do by years of first-line triage. I opened the database dashboards. I looked at slow query logs. I checked connection pool usage, lock waits and replication lag. Every graph I opened, I read through the lens of that title. A small spike in connections? Suspicious. A query that took longer than usual? Probably related.&lt;/p&gt;
&lt;p&gt;It wasn't the database. It was a network timeout between two services, set far too low after a config change, and the database was just the place where the waiting showed up. I'd spent a good chunk of the day collecting evidence for a story somebody else had written in five words.&lt;/p&gt;
&lt;p&gt;I've told versions of that story for years as a funny debugging anecdote. Recently I found out a psychologist ran the same experiment on hospitals, fifty years ago, and it isn't funny at all.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/4037c1/hero.svg" alt="A ticket card with a coral tag tied to it points at a page of log lines. A small agent with a magnifying glass looks past the tag at one teal line in the logs that doesn't match it." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The tag says one thing. The evidence is in the logs.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Eight people who said one strange thing&lt;/h2&gt;
&lt;p&gt;In 1973, the Stanford psychologist David Rosenhan published a paper in &lt;em&gt;Science&lt;/em&gt; called "&lt;a href="https://doi.org/10.1126/science.179.4070.250"&gt;On Being Sane in Insane Places&lt;/a&gt;". The setup, as he reported it, was simple. Eight people with no history of mental illness, Rosenhan included, phoned psychiatric hospitals and asked for an appointment. At the interview, each said they had been hearing a voice. It was unclear, but it seemed to say "empty", "hollow" and "thud". Apart from a false name and, for the professionals among them, a false job, everything else they said about their lives was true.&lt;/p&gt;
&lt;p&gt;All of them were admitted, across twelve hospitals in five states. Seven were diagnosed with schizophrenia and one with manic-depressive psychosis. The moment they were on the ward, they stopped mentioning the voices and behaved normally. They said they felt fine. They were friendly and cooperative.&lt;/p&gt;
&lt;p&gt;Nobody on staff spotted them. They stayed between 7 and 52 days, 19 on average, and when they were released it was not as healthy people who had been misjudged. They were discharged with schizophrenia "in remission". The label didn't get removed. It got a status update.&lt;/p&gt;
&lt;p&gt;The detail that stuck with me most is small. The pseudo-patients took notes, openly, all day. In one set of records a nurse wrote it down as "patient engages in writing behavior". Ordinary note-taking, observed by a professional, was recorded as a symptom, because the person doing it already had a diagnosis. Meanwhile, in the first three hospitalisations where counts were kept, 35 of the 118 patients on the admissions ward voiced suspicion that the newcomers were sane. "You're not crazy. You're a journalist, or a professor." The people with no authority and no label to protect read the evidence better than the people whose job it was.&lt;/p&gt;
&lt;h2&gt;The ticket title is a diagnosis&lt;/h2&gt;
&lt;p&gt;If you've worked in software for any length of time, you have seen "writing behaviour" in a Jira comment.&lt;/p&gt;
&lt;p&gt;A ticket comes in labelled "database issue", "frontend bug" or "customer error". From that point on, every log line gets read in the light of that label. Evidence that fits is noted. Evidence that doesn't fit is noise, or a separate issue, or "probably unrelated". The title is written once, often by the person with the least information, at the moment of maximum panic, and then it quietly becomes the frame for everyone downstream.&lt;/p&gt;
&lt;p&gt;We have a whole vocabulary of labels that work like this. A test marked "flaky" stops being investigated. When it fails, people hit retry, and the one time it fails because of a real race condition, nobody looks, because it's the flaky one. A module tagged "legacy" gets blamed for anything odd that happens near it. "Works as intended" closes a conversation that might have been the first report of a real design problem. "Won't fix" turns into a reason to dismiss the next report that looks similar, even when it isn't.&lt;/p&gt;
&lt;p&gt;People get labels too. A pull request from a contributor everyone considers senior and careful gets a lighter review. The same change from someone tagged "junior" gets picked apart line by line.&lt;/p&gt;
&lt;p&gt;And the reporter's framing sticks harder than anything. "The export is broken" sends you to the export code. "The export is slow since Tuesday" sends you to Tuesday's deploy. Same bug, two different investigations, decided before anyone has looked at a single log line.&lt;/p&gt;
&lt;p&gt;Rosenhan's point, at least as he framed it, was that once the label was applied, the behaviour stopped being information. That's the failure mode I care about as an engineer. The first label isn't a problem in itself. We have to call the ticket something. The problem is when the label stops being a hypothesis and starts being the lens.&lt;/p&gt;
&lt;h2&gt;The hospital that caught impostors who didn't exist&lt;/h2&gt;
&lt;p&gt;The second part of the paper is the one I find most useful for engineers, and it's also the part that tends to get slightly garbled when the story is retold.&lt;/p&gt;
&lt;p&gt;After the first results came out, a research and teaching hospital told Rosenhan that kind of mistake couldn't happen there. So he made them an offer. Over the next three months, he said, one or more pseudo-patients would try to get admitted. Staff should rate every new patient on how likely they were to be an impostor.&lt;/p&gt;
&lt;p&gt;Out of 193 patients, 41 were judged with high confidence to be pseudo-patients by at least one staff member. Twenty-three were considered suspect by at least one psychiatrist. Nineteen were suspected by both a psychiatrist and another staff member. Rosenhan had sent nobody. Note that's 41 flagged by &lt;em&gt;someone&lt;/em&gt;, not 41 the hospital agreed on, but it's still a lot of alarms about a problem that wasn't there.&lt;/p&gt;
&lt;p&gt;Anyone who has tuned monitoring will recognise this immediately. Tell an on-call team "we think someone is attacking the login endpoint this week" and watch the false positives roll in. Every slightly odd IP is suspicious. Every burst of failed logins is the attack. You haven't made them better at detecting attacks. You've changed their threshold. Rosenhan himself framed it in terms of errors: the first study showed the hospitals leaning hard towards calling healthy people sick, and the second showed that if you raise the stakes, you can push staff to lean the other way. Neither shows a well-calibrated detector. Every alert tuned too sensitive, and every label like "it's always the database", moves the threshold the same way. (A small nerd aside: in the paper he calls the false positive a "Type 2" error, which is the opposite of how most statisticians label it today. Even the error labels in the famous paper about labels are swapped.)&lt;/p&gt;
&lt;h2&gt;What's contested, and why I'm still telling the story&lt;/h2&gt;
&lt;p&gt;Here's the part the short versions of this story usually leave out, and I think it matters.&lt;/p&gt;
&lt;p&gt;The Rosenhan study has come under serious criticism. Critics at the time, most famously the psychiatrist Robert Spitzer, pointed out that if you lie convincingly about a symptom, a doctor treating you for that symptom isn't proof that diagnosis is broken. Seymour Kety put it as: if he drank a quart of blood and showed up vomiting it, nobody would conclude medicine can't diagnose ulcers. That's a fair hit.&lt;/p&gt;
&lt;p&gt;Then, in 2019, the journalist Susannah Cahalan published &lt;em&gt;&lt;a href="https://www.hachettebookgroup.com/titles/susannah-cahalan/the-great-pretender/9781538715284/"&gt;The Great Pretender&lt;/a&gt;&lt;/em&gt;, after going through Rosenhan's private papers. She found inconsistencies between his records and the published paper, and she could only identify two of the eight pseudo-patients for certain. One of them, a graduate student, described his experience differently from how it appeared in the study, and his data seems to have been left out. Records she found suggest that at least one pseudo-patient, by her account Rosenhan himself, told the admitting doctor more than just "thud". &lt;a href="https://www.nature.com/articles/d41586-019-03268-y"&gt;Nature's review&lt;/a&gt; of the book summarises the trail, and in 2023 the historian Andrew Scull went further and called the study a "successful scientific fraud" in the journal &lt;em&gt;History of Psychiatry&lt;/em&gt;. Those claims are disputed and can't be fully settled now that Rosenhan is gone, but the honest summary is that the study's details aren't trustworthy enough to carry the weight it has been given.&lt;/p&gt;
&lt;p&gt;The second experiment has its own catch. Since no fake patients were sent, it can't tell you anything about whether staff could detect real impostors. What it shows is how expectations and incentives change what people flag, which is useful, but it's a different and smaller claim than "psychiatrists can't tell the sane from the insane".&lt;/p&gt;
&lt;p&gt;And yet the paper landed at a moment when American psychiatry already knew its diagnoses were unreliable, and it added a lot of pressure. Spitzer, one of its sharpest critics, went on to lead the work on &lt;a href="https://en.wikipedia.org/wiki/DSM-III"&gt;DSM-III&lt;/a&gt; in 1980, which moved psychiatric diagnosis towards explicit, checkable criteria. The &lt;a href="https://en.wikipedia.org/wiki/Rosenhan_experiment"&gt;Wikipedia article on the experiment&lt;/a&gt; covers both the influence and the criticism well.&lt;/p&gt;
&lt;p&gt;I find that whole arc strangely fitting. A famous study about how labels distort evidence was itself carried for decades by its label: "landmark experiment", "Stanford", "&lt;em&gt;Science&lt;/em&gt;". Plenty of people, me included, repeated it without checking the records. The fix was the same as for any bad ticket: someone went back and read the primary evidence instead of the summary.&lt;/p&gt;
&lt;h2&gt;Where AI agents come in&lt;/h2&gt;
&lt;p&gt;I use AI coding agents every day, and I'm strongly in favour of them. So I want to be precise about where they fit here, because "AI hallucinates, AI is biased" is the lazy take.&lt;/p&gt;
&lt;p&gt;An agent given a wrong label behaves a lot like a tired engineer given a wrong label. Hand it a ticket titled "database issue" and a plan that starts with "check the slow queries", and it will check the slow queries. If it finds something slightly odd, it will often build an explanation around it. If it hits evidence that doesn't fit, it can explain that away too, with complete confidence and very good grammar. It didn't invent that frame. It inherited it from the ticket, from the docs, from our runbooks and from the label we wrote at the worst possible moment.&lt;/p&gt;
&lt;p&gt;But there are two important differences, and both are good news.&lt;/p&gt;
&lt;p&gt;First, an agent has no ego in the outcome. It didn't write the ticket. It doesn't have a reputation as "the database person" to defend, and it won't be embarrassed to say the senior engineer's diagnosis was wrong. I've written before about &lt;a href="/7b5ed3.html"&gt;ego running production&lt;/a&gt;. Agents don't fix that problem in us, but they don't add to it either.&lt;/p&gt;
&lt;p&gt;Second, an agent will happily start again from scratch, as many times as you ask, which is the thing humans are worst at. Once I've spent three hours on the database theory, I'm invested. Ask an agent to drop everything and re-read the evidence, and it just does it.&lt;/p&gt;
&lt;p&gt;So I've changed how I hand over investigations. Instead of passing the ticket title through as the goal, I'll often say: ignore the title and the reporter's guess. Here are the logs, the deploy history and the error timeline. Tell me what you think is happening, and what evidence would prove you wrong. Then, separately, I'll ask it to evaluate the original label against what it found. Two passes, one with the label and one without, and I compare.&lt;/p&gt;
&lt;p&gt;This is the same lesson I keep relearning: &lt;a href="/54d94d.html"&gt;the quality of the ask decides the quality of the answer&lt;/a&gt;. A vague or loaded ask gets a loaded answer. It's also why I like giving agents &lt;a href="/ba4aab.html"&gt;the boring parts of the job&lt;/a&gt;, like pulling thirty days of logs and lining up the timeline. That's exactly the work that a rushed human skips, and skipping it is how a label survives unchallenged.&lt;/p&gt;
&lt;p&gt;And I review the evidence, not just the conclusion. An agent's summary that says "root cause: connection pool exhaustion" is a label too. What I want to see underneath is the log lines, the timestamps and the graph that shows it. If the evidence doesn't support the conclusion, the conclusion goes, no matter how confidently it's written.&lt;/p&gt;
&lt;h2&gt;Re-reading from scratch&lt;/h2&gt;
&lt;p&gt;Rosenhan's wards, real or exaggerated, had no cheap way to re-read a patient from zero. Every observation went into a chart that already had a diagnosis at the top. Our systems are the same if we let them be: the ticket title sits at the top, every comment below is written in its shadow, and the post-mortem often ends up confirming the first guess because that's the story everyone already told.&lt;/p&gt;
&lt;p&gt;We can design against it. Treat the first label as a hypothesis with an owner and a timestamp, not a fact. Let the post-mortem say "the initial triage label was wrong, and here's how that slowed us down" without blaming anyone. Retire "flaky" as a permanent tag and make it expire. Review the trusted contributor's diff with the same care as the new person's. And use agents for what they're unusually good at: looking at the same evidence again, with no memory of the story we've been telling ourselves.&lt;/p&gt;
&lt;p&gt;The patients on those wards saw through the label because they weren't invested in it. A good agent, given clean context, can be that outside voice for us. It still needs a human to decide what matters. But it can read "writing behaviour" and say what nobody on the ward would: that's just someone taking notes.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;What sent me down this rabbit hole was &lt;a href="https://www.facebook.com/watch/?v=1797525581628021"&gt;a short video by Reni B-Alfred&lt;/a&gt; about the experiment. It's worth four minutes. The facts above come from the paper and the sources linked, and the criticism is worth reading as closely as the story.&lt;/em&gt;&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Give the Boring Parts of Software Engineering to AI</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/ba4aab.html"/>
    <id>https://nehem.dev/ba4aab.html</id>
    <published>2026-11-02T00:00:00+10:00</published>
    <updated>2026-11-02T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>The boring parts of engineering get rushed: logs, legacy code, PR descriptions, week-after checks. I hand them to an agent and keep the decisions.</summary>
    <category term="AI"/><category term="AI Agents"/><category term="Developer Productivity"/><category term="Engineering Culture"/>
    <content type="html">&lt;p&gt;Nobody talks about the boring parts of software engineering.&lt;/p&gt;
&lt;p&gt;They don't make it into tech talks or blog posts. Nobody gives a conference keynote on how they pulled thirty days of logs to find when an error started, or how they read four hundred lines of legacy code to work out why one flag exists. And yet, by my estimate, this stuff is about 70% of the job.&lt;/p&gt;
&lt;p&gt;It's also the part most engineers rush through. I know because I did it for years.&lt;/p&gt;
&lt;p&gt;This post is about what changed when I stopped doing the boring parts myself and handed them to my agentic workflow. All of them. Not because I want to do less work, but because the boring work finally gets done properly, and I get to spend my own attention on the bit that actually needs a human.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/ba4aab/hero.svg" alt="A page of logs, three database cylinders, a page of code, a PR document and a before-and-after bar chart ride a conveyor belt into a small robot agent. One arrow leads out of the agent to a person standing where three dashed paths fork towards three flags." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The boring work rides through the agent. The fork at the end is still mine.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;What the boring parts actually look like&lt;/h2&gt;
&lt;p&gt;When people imagine software engineering, they picture the interesting part: designing a system, writing a clever fix, arguing about architecture on a whiteboard. That part is real, but it's the thin end of the week. Here's the rest, in generic terms.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pulling 30 days of logs to find when an error started.&lt;/strong&gt; A customer reports something broken. The error rate graph looks a bit higher than usual, but it's noisy. Did this start with last Tuesday's deploy? With a config change? With a third-party API that quietly changed its response format? The answer is in the logs, spread across a month and a few services, and finding the first occurrence means filtering, grouping, exporting, and squinting at timestamps in two different timezones.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cross-referencing three databases to trace one customer's broken state.&lt;/strong&gt; The orders table says the payment went through. The billing service says it didn't. The analytics warehouse has a third opinion. Somewhere between them is the moment this customer's account went wrong, and the only way to find it is to pull the same customer's rows from each system, line them up by time and spot where the story stops making sense.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reading 400 lines of legacy code to understand why a flag exists.&lt;/strong&gt; There's a boolean called something like &lt;code&gt;skip_legacy_sync&lt;/code&gt; that's checked in a dozen places. Nobody on the team remembers who added it. The person who did left years ago. Before you can safely remove it, or even safely change the code around it, you have to read everything that touches it and reconstruct the reason from the code itself, the commit history and whatever tickets still exist.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Writing the PR description that nobody will read but everyone will need later.&lt;/strong&gt; The fix is done. The tests pass. Now you have to write down what changed, why, what you considered and rejected, how you verified it and what to watch afterwards. Today, the reviewer will skim it. A year or two from now, someone running &lt;code&gt;git blame&lt;/code&gt; at midnight during an incident will need every word of it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Checking if the fix actually reduced errors a week after shipping.&lt;/strong&gt; This is the one that almost never happens. You shipped the fix, closed the ticket and moved on. Did the errors actually go down? Or did they drop for a day and creep back, because the real cause was something else? Finding out means going back to the dashboards a week later, comparing before and after, and writing it up. By then you're three tickets deep into something else.&lt;/p&gt;
&lt;p&gt;None of this is glamorous. All of it matters.&lt;/p&gt;
&lt;h2&gt;Why the boring work gets rushed&lt;/h2&gt;
&lt;p&gt;It's not because engineers are lazy. I've worked with plenty of engineers and very few of them were lazy. The boring work gets rushed because engineers are human.&lt;/p&gt;
&lt;p&gt;We get tired. Correlating log lines at four in the afternoon is not the same as doing it at nine in the morning. By the third hour, you start skimming. You see a pattern that fits your theory and you stop looking for the one that doesn't.&lt;/p&gt;
&lt;p&gt;We context switch. There are always three other tickets open, a review waiting, a Slack thread asking for an update. Every interruption resets the careful mental model you were building of that legacy module, and rebuilding it costs more each time.&lt;/p&gt;
&lt;p&gt;We're under ticket pressure. The visible output of the job is the fix. The investigation behind it, the description around it and the follow-up after it don't show up on a board. So when time is short, those are the first things to get trimmed.&lt;/p&gt;
&lt;p&gt;And honestly, we want to get to the interesting part, so we pay the price of admission as quickly as we can. That's when shortcuts creep in: the timeline that's "probably" right, the legacy code we read half of, the PR description that just says "fixes the export bug", the week-after check that never happens.&lt;/p&gt;
&lt;h2&gt;Why it matters more than it looks&lt;/h2&gt;
&lt;p&gt;The cost of rushing the boring work doesn't show up straight away. It shows up later, and usually on someone else's afternoon.&lt;/p&gt;
&lt;p&gt;A rushed investigation means a fix for the wrong cause. The symptom goes away for a while, the ticket closes, and the real problem comes back next month with a new ticket number. A half-read legacy module means the flag you removed was load-bearing for some edge case nobody remembered, and now that edge case is an incident.&lt;/p&gt;
&lt;p&gt;A thin PR description is a debt the whole team pays. Code tells you what it does. Only the description, written at the time, tells you why it was done that way and what else was tried. When that's missing, the next engineer has to redo the investigation from scratch, or worse, guesses.&lt;/p&gt;
&lt;p&gt;And skipping the week-after check means you never actually know whether your work helped. You think it did. You moved on believing it did. That's a quiet kind of overconfidence, and it's the same trap I wrote about in &lt;a href="/7b5ed3.html"&gt;ego in production&lt;/a&gt;: certainty that nobody ever asked you to prove.&lt;/p&gt;
&lt;p&gt;The boring parts are where the evidence lives. Skip them and you're doing engineering by vibes.&lt;/p&gt;
&lt;h2&gt;What I hand to the agent&lt;/h2&gt;
&lt;p&gt;AI doesn't get tired. It doesn't rush because it has three other tickets open. It doesn't skip the last week of logs because it's nearly home time. It's not perfect, and I'll come back to that, but it is relentlessly thorough in exactly the places where I used to cut corners.&lt;/p&gt;
&lt;p&gt;So I gave my agentic workflow the boring work. In practice the instructions are short and blunt, because I've learnt that &lt;a href="/54d94d.html"&gt;clear asks get clear results&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For the logs, it's roughly: &lt;em&gt;pull the logs, correlate them, show me the timeline.&lt;/em&gt; The agent queries the last thirty days across the services involved, finds the first occurrence of the error, lines it up against deploys and config changes, and hands me a timeline with the actual log lines and queries attached. Not a summary I have to trust, but the raw evidence behind each step.&lt;/p&gt;
&lt;p&gt;For the broken customer, it's the same shape: pull the records from each system, line them up by time, show me where they disagree. An afternoon of copy-pasting between query windows becomes one table.&lt;/p&gt;
&lt;p&gt;For legacy code: &lt;em&gt;read it, explain what it does, tell me what breaks if I change it.&lt;/em&gt; The agent reads every call site of that flag, the commits that touched it and any linked tickets it can find, then writes a plain-language explanation and a list of the paths that would behave differently if the flag went away. It reads all four hundred lines. Every time. I used to read the first hundred carefully and the rest hopefully.&lt;/p&gt;
&lt;p&gt;For the PR: &lt;em&gt;write the description, include the evidence, link the dashboards.&lt;/em&gt; By the time the fix is ready, the agent has already been part of the investigation, so it knows what we found, what we ruled out and why. The description it drafts has the timeline, the root cause, the alternatives we rejected, how we tested it and the links to the graphs that prove it. I edit it, but I'm editing a complete draft, not staring at an empty text box at the end of a long day.&lt;/p&gt;
&lt;p&gt;And for the follow-up: &lt;em&gt;check the error rates next week, compare before and after, write the report.&lt;/em&gt; This is the one I'm happiest about, because it's the one I used to skip entirely. A week after the fix ships, the agent pulls the same metrics for the same window before and after, compares them and writes a short report. Sometimes the report says the fix worked. Sometimes it says the errors dropped but a related one went up. Either way, I find out, instead of assuming.&lt;/p&gt;
&lt;h2&gt;The guardrails&lt;/h2&gt;
&lt;p&gt;I'm very pro-AI, but I'm not naive about it. Agents make mistakes. They misread a timestamp, pick the wrong join key, or confidently explain code that does something slightly different from what they said. So the way I work has a few rules that never bend.&lt;/p&gt;
&lt;p&gt;The agent gets read-only access for this kind of work. It can query logs, read databases through read-only credentials and browse the code and dashboards. It doesn't change production data, deploy anything or close tickets on its own. Investigation is reading, so the access is reading.&lt;/p&gt;
&lt;p&gt;I verify the evidence, not just the conclusion. That's why I ask for the raw log lines and the queries, not just the timeline. If the agent says the errors started at a particular deploy, I open that deploy and the first few log lines myself. It takes minutes, because the agent has already done the hours of searching.&lt;/p&gt;
&lt;p&gt;I spot-check the correlation. Things happening at the same time aren't always cause and effect. When the agent lines up an error spike with a deploy, I ask what else changed in that window, and I sometimes ask it to argue the opposite case. A good timeline survives that.&lt;/p&gt;
&lt;p&gt;And the agent proposes, the human decides. It can tell me what the flag does and what breaks if I remove it. It doesn't decide whether to remove it. It can draft the PR description. I decide whether it's true before it goes out under my name.&lt;/p&gt;
&lt;p&gt;Checking evidence is much faster than gathering it, and that's the whole trick.&lt;/p&gt;
&lt;h2&gt;The part that actually needs a human&lt;/h2&gt;
&lt;p&gt;So what do I do with the time I get back?&lt;/p&gt;
&lt;p&gt;The part that was always the actual job: deciding what to fix, how to fix it and whether the trade-offs are worth it.&lt;/p&gt;
&lt;p&gt;Deciding what to fix means looking at the timeline and the customer impact and choosing. Is this worth fixing properly now, or patching and scheduling? Is it even the most important problem this week? An agent can lay out the evidence, but it doesn't know that the finance team is mid-audit, or that this customer is about to renew, or that the team is stretched thin this sprint.&lt;/p&gt;
&lt;p&gt;Deciding how to fix it means weighing options with judgement and context. A quick guard clause, or the refactor the module has needed for years? A data migration now, or a backfill later? These calls depend on people, timing and risk appetite as much as on code.&lt;/p&gt;
&lt;p&gt;And deciding whether the trade-offs are worth it is the most human part of all. Every fix costs something: review time, deploy risk, a bit more complexity, a behaviour change someone depends on. Saying "yes, this is worth it" or "no, leave it alone" is a judgement call, and I'd rather make it with a clear head and complete evidence than after three hours of squinting at logs.&lt;/p&gt;
&lt;p&gt;There's a broader point here too. In the &lt;a href="/539a49.html"&gt;middleman post&lt;/a&gt; I argued that the gap between a powerful tool and the people who need it doesn't close by itself. The same is true inside an engineering team. Agents produce the evidence. Someone still has to turn that evidence into the right decision for this team, this product and this week.&lt;/p&gt;
&lt;h2&gt;The result&lt;/h2&gt;
&lt;p&gt;The boring work actually gets done now. Properly. Every time.&lt;/p&gt;
&lt;p&gt;The timelines are complete instead of probably right. The legacy code gets read end to end. The PR descriptions are good enough that future me will be grateful. And the week-after check happens, which means I actually know whether my fixes worked, rather than hoping they did.&lt;/p&gt;
&lt;h2&gt;Automate the boring parts&lt;/h2&gt;
&lt;p&gt;There's a lot of excitement about AI doing the fun parts of engineering: generating whole features, designing systems, writing the clever bit. But I think the engineers who'll really win with AI aren't the ones who automate the fun parts.&lt;/p&gt;
&lt;p&gt;They're the ones who automate the boring parts and do the fun parts better.&lt;/p&gt;
&lt;p&gt;Hand the agent the logs, the cross-checks, the legacy code, the PR description and the follow-up. Give it read-only access, check its evidence and keep the decisions for yourself. Then spend your own energy on the part that actually needs a human.&lt;/p&gt;
&lt;p&gt;What's the most tedious part of your workflow that you'd hand to an AI today?&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Why You Rarely Hear Live Singing in Small Indian Venues</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/bf3a73.html"/>
    <id>https://nehem.dev/bf3a73.html</id>
    <published>2026-11-02T00:00:00+10:00</published>
    <updated>2026-11-02T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Why small Indian cafes rarely have live singers: an average Tamil film song needs two vocalists and a ten-piece band, while a pop song needs a guitar.</summary>
    <category term="Music"/><category term="India"/><category term="Tamil"/><category term="Culture"/>
    <content type="html">&lt;p&gt;This one is off topic. No Django, no Kubernetes, no AI agents. Just something that has been bugging me for years, every time I walk into a small bar or cafe overseas and there's a guy in the corner with a guitar, singing his heart out to forty people and a coffee machine.&lt;/p&gt;
&lt;p&gt;Why don't we have that in India?&lt;/p&gt;
&lt;p&gt;I don't mean concerts. India has huge concerts, film music nights, temple festivals and wedding bands. I mean the small, everyday version: a Friday night in a neighbourhood cafe, two or three musicians, a mic stand and a tip jar. Travel a bit and you'll see it everywhere. In Chennai or Bangalore it exists, but it's much rarer, and when it does happen it's usually not Tamil film songs.&lt;/p&gt;
&lt;p&gt;My theory: &lt;strong&gt;it's not about talent or taste. It's about arithmetic.&lt;/strong&gt; Faithfully reproducing even an average Tamil film song takes a big band, and a big band costs money that a small venue doesn't have.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/bf3a73/hero.svg" alt="Left: a single guitarist on a stool with a small amp, sketched as a sandwich of three layers. Right: a crowded stage of two singers, flute, tabla, keyboard, guitar, drum pads and violin, sketched as a pot of biryani with many layers." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;One song, two very different headcounts.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Indian film songs are complex at the foundation&lt;/h2&gt;
&lt;p&gt;Let me say the part that surprises a lot of Western friends. On a foundation level, Indian film songs are &lt;em&gt;very&lt;/em&gt; complex.&lt;/p&gt;
&lt;p&gt;Don't get me wrong. Complex Western songs exist. Queen exists. Prog rock exists. Jazz will happily melt your brain. But the default Western pop or rock song is built to be carried by a few people. The default Tamil film song is built in a studio, by a composer with an orchestra at his disposal, for a scene in a movie, and nobody involved was thinking about whether three people in a cafe could play it later.&lt;/p&gt;
&lt;p&gt;Take an ordinary example. Not a Rahman masterpiece, not an Ilaiyaraaja symphony. Just a regular, well-loved album: Yuvan Shankar Raja's soundtrack for &lt;em&gt;&lt;a href="https://en.wikipedia.org/wiki/Yaaradi_Nee_Mohini"&gt;Yaaradi Nee Mohini&lt;/a&gt;&lt;/em&gt; (2008), the Dhanush and Nayanthara film. Put on "Oru Naalaikkul" and actually listen to everything happening underneath the vocals. Then imagine reproducing it faithfully, live, in a room the size of a living room.&lt;/p&gt;
&lt;p&gt;My first instinct is to say you'd need a 200-member band. Okay, 200 is a stretch. But you will not get anywhere near the record with two people. Let's count properly.&lt;/p&gt;
&lt;h2&gt;You need two singers before you play a single note&lt;/h2&gt;
&lt;p&gt;Most Indian film songs are duets. Whether you agree with that or not, it's the reality of the catalogue. There's a male portion, there's a female portion, and they trade lines, verses and sometimes whole stanzas. "Oru Naalaikkul" is Karthik and Rita. "Nenjai Kasakki" on the same album is Udit Narayan and Suchitra.&lt;/p&gt;
&lt;p&gt;And here's the funny part: you can't just have one singer cover both. A man can't really sing the female portion, and the other way round sounds odd too. The keys sit in different ranges, and because most of these duets are romantic, it gets awkward fast when one person is singing both sides of a love conversation. It's like a one-man play of a wedding proposal.&lt;/p&gt;
&lt;p&gt;Long story short: &lt;strong&gt;one male vocalist, one female vocalist. Period.&lt;/strong&gt; That's two people on the payroll and we haven't touched an instrument.&lt;/p&gt;
&lt;h2&gt;Then the instruments&lt;/h2&gt;
&lt;p&gt;Here's the smallest band I can imagine that would get through a typical Tamil film song without the audience wincing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Flute.&lt;/strong&gt; So much of the melodic colour lives in the flute lines between verses. Without it the interludes are empty.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tabla.&lt;/strong&gt; The rhythmic feel of a lot of songs comes from tabla or a similar hand percussion, not a drum kit.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Keyboard or piano.&lt;/strong&gt; The workhorse. A good keyboardist covers strings, pads, bells and half the orchestra with patches.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Guitar.&lt;/strong&gt; Rhythm parts, and often a lead line or solo.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Drum pads.&lt;/strong&gt; Most bands don't bring a full acoustic kit anymore, and that's fine. Electronic pads are highly versatile and can trigger almost any sound.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That's seven people including the two singers. Now the "you really should have" list:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Congas or triple drums&lt;/strong&gt;, because so many songs have a percussion section that tabla and pads don't quite nail.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bass guitar&lt;/strong&gt;, because the low end matters more than people think.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A dedicated lead guitar&lt;/strong&gt;, separate from rhythm.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Violin&lt;/strong&gt;, for the string lines a keyboard patch only imitates.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And the "nice to have, but forget about it" list: &lt;strong&gt;nadaswaram&lt;/strong&gt; for the songs that need it, and &lt;strong&gt;veena&lt;/strong&gt; if you're feeling ambitious. You don't need them for every song, but when a song does, nothing else sounds the same.&lt;/p&gt;
&lt;p&gt;Some people try to play tabla on the pads too. You can, and good players get close, but it isn't real tabla. The bols, the bends from the left-hand drum, the way the sound breathes: a sample doesn't do all of that.&lt;/p&gt;
&lt;p&gt;Add it up and you land somewhere around ten people for a respectable version. Some parts can be folded into the keyboard, and that's fine, but &lt;strong&gt;I genuinely can't picture a Tamil live band that does justice to film songs with fewer than about ten members.&lt;/strong&gt; For the full experience, think closer to twenty.&lt;/p&gt;
&lt;h2&gt;Two separate lanes: singers and players&lt;/h2&gt;
&lt;p&gt;Meanwhile, in plenty of places I've travelled, I've seen two-piece and three-piece acts holding a room. And very often the person singing is also the person playing guitar.&lt;/p&gt;
&lt;p&gt;That's something you rarely see with Indian musicians, and I think there's a real reason for it. Indian vocals, Tamil film vocals included, are demanding. A huge number of our singers trained classically for years and dedicated their whole lives to the voice alone. Think about how many top Indian playback singers you've seen holding a guitar on stage. Not many. Playing an instrument at a high level is its own lifelong discipline, and singing at that level is another one. So it becomes &lt;strong&gt;two separate lanes&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In the West, the singer-songwriter with a guitar is practically an archetype. Ed Sheeran builds entire stadium sets out of one voice, a guitar and a loop pedal. Bruno Mars sings while playing. In a lot of Western bands the guitarist sings, the keyboard player sings, and sometimes even the drummer sings. One person covering two jobs halves the headcount, and that changes the economics of a small gig completely.&lt;/p&gt;
&lt;p&gt;To be fair, it's not because Western singing is easy. A great pop vocal is hard. It's that the songs are usually &lt;em&gt;designed&lt;/em&gt; so the voice and a couple of instruments can carry them.&lt;/p&gt;
&lt;h2&gt;Biryani versus a sandwich&lt;/h2&gt;
&lt;p&gt;The more you listen, the more you realise an Indian film song is like a &lt;strong&gt;biryani&lt;/strong&gt;. There are layers and layers. Rice, masala, meat, fried onions, saffron, mint, a dozen spices doing their own thing, and somehow it all has to come together at once.&lt;/p&gt;
&lt;p&gt;A typical English pop song is more like a &lt;strong&gt;sandwich&lt;/strong&gt;. Toast two slices of bread, put something good inside, done. And I say that with love. A great sandwich is a great meal, and nobody complains that a sandwich isn't a biryani.&lt;/p&gt;
&lt;p&gt;There's a running meme online where someone proudly shows a "perfect meal" and an Indian person replies, roughly, &lt;em&gt;"Perfect meal? That's just the prep work. Where does the cooking start?"&lt;/em&gt; That's exactly the gap I'm talking about, applied to music.&lt;/p&gt;
&lt;h2&gt;Where the richness actually comes from&lt;/h2&gt;
&lt;p&gt;Now let me correct my own brainstorm, because my first take was unfair.&lt;/p&gt;
&lt;p&gt;It's tempting to say Western music is "flat" and "just twelve semitones". That's not quite right. Indian music uses the same twelve-note octave as its working frame; the harmonium and keyboard that half our film industry runs on are tuned to it. The richness isn't in having more notes. It's in &lt;strong&gt;what you do between and around them&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Raga grammar.&lt;/strong&gt; A raga isn't just a scale. It has rules for how you approach and leave notes, which phrases belong to it and which notes to emphasise.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Gamakas.&lt;/strong&gt; The ornaments, slides and oscillations that make a note &lt;em&gt;move&lt;/em&gt;. A note in Carnatic music is often more of a gesture than a fixed point.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shrutis.&lt;/strong&gt; The finer pitch shades that theory recognises within the octave, which singers use for intonation and expression.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tala.&lt;/strong&gt; Rhythmic cycles that percussionists play with, around and against.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Layered orchestration.&lt;/strong&gt; Film composers stack all of the above with strings, synths, folk percussion and choir.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Western music has its own depth, especially in harmony. Chord progressions, voice leading and counterpoint are where a lot of its richness sits. Popular Western songs just tend to be lighter on layers &lt;em&gt;by design&lt;/em&gt;, and that is precisely why they travel so well into small rooms. A strummed chord progression can carry a song. A raga-based melody with orchestral interludes can't be carried by strumming alone.&lt;/p&gt;
&lt;p&gt;Different recipes, not better and worse cooks.&lt;/p&gt;
&lt;h2&gt;So it comes down to money&lt;/h2&gt;
&lt;p&gt;Here's where it lands. If a cafe wants a two-piece, that's two people to pay, two people to feed and a corner of the room. If it wants a Tamil film band that won't get booed, it needs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;bigger group&lt;/strong&gt;, so a much bigger total fee.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;bigger space&lt;/strong&gt;, with room for ten musicians, their gear and a proper sound system.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;bigger crowd&lt;/strong&gt;, to justify all of that on a Friday night.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And the audience is unforgiving. Everyone in the room knows the original recording note for note. Try a thin cover of a beloved song with one guitar and the missing flute line and percussion break are obvious. It sounds flat, and you'll be booed off stage. So the small venues mostly don't bother. They play recorded music or hire a DJ, and live film music moves to bigger venues, weddings, college culturals and ticketed shows, where the budget exists.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/bf3a73/venue-cost.svg" alt="An illustrative chart with no numbers. Venue size runs from cafe, bar and lounge to wedding and concert. A two-piece act is a low flat cost line and a ten-piece film band with sound is a high flat line. What the venue can spend rises with size: a cafe covers the two-piece but leaves a big gap under the ten-piece, which only becomes affordable around weddings and concerts." width="600" height="700" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Illustrative only: no real prices, not to scale. Just the shape of the argument. A band's cost is set by its headcount; what a venue can spend grows with its size.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;The honest counterpoints&lt;/h2&gt;
&lt;p&gt;I don't want to overstate this, because small live music in India does exist.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Unplugged and acoustic covers&lt;/strong&gt; of Tamil and Hindi songs are popular, especially online and in some cafes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ghazal nights&lt;/strong&gt; have always been intimate: a singer, a harmonium, a tabla, often in small rooms.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Carnatic concerts&lt;/strong&gt; in Chennai's sabhas, especially during the December music season, are often small ensembles: a vocalist with violin and mridangam.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Indie bands&lt;/strong&gt; in Bangalore, Mumbai, Delhi, Chennai and the Northeast play small venues all the time, usually their own songs, often in English.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Karaoke and backing-track nights&lt;/strong&gt; are a whole culture of their own.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Folk traditions&lt;/strong&gt; across India have performed with small groups for centuries.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And simplicity isn't inferior. Some of my favourite live moments anywhere have been one person and one instrument.&lt;/p&gt;
&lt;p&gt;There are also ways a small act can make Tamil film songs work:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reduced arrangements&lt;/strong&gt; that keep the hook and drop the orchestra.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Acoustic reinterpretations&lt;/strong&gt;, where the point is a new take, not a copy.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Backing tracks&lt;/strong&gt; for the parts you can't staff, with live vocals and one or two live instruments on top.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loop pedals&lt;/strong&gt;, the Ed Sheeran trick, to layer parts live.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A really strong keyboardist&lt;/strong&gt;, who is honestly worth three people.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The catch is that each of these changes the promise. You're no longer selling "the song you love, played live". You're selling "a new version of the song you love". Some audiences love that. Many still want the biryani.&lt;/p&gt;
&lt;h2&gt;My take&lt;/h2&gt;
&lt;p&gt;Small venues in India rarely have live singers because our songs are built for a full kitchen, our singers and instrumentalists usually work in separate lanes, and a ten-piece band is expensive. That's not a weakness. It's the price of a musical tradition that layers everything.&lt;/p&gt;
&lt;p&gt;I'd still love to see more small acts try the reinterpretation route, with a keyboardist, a tabla player and two good singers. A smaller biryani, not a sandwich.&lt;/p&gt;
&lt;p&gt;If you've been to a small venue in India that pulls this off, tell me where. And if you're a musician who has tried, how small did you manage to make the band?&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>AI Made Me a Better Engineer by Exposing How Vague I Was</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/54d94d.html"/>
    <id>https://nehem.dev/54d94d.html</id>
    <published>2026-11-02T00:00:00+10:00</published>
    <updated>2026-11-02T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Agents read tickets literally, so vague asks get vague code. The ticket, acceptance-criteria, assumption and edge-case habits that made me a better engineer.</summary>
    <category term="AI"/><category term="Engineering Culture"/><category term="AI Agents"/><category term="Requirements"/>
    <content type="html">&lt;p&gt;Unpopular opinion: AI made me a better engineer.&lt;/p&gt;
&lt;p&gt;Not because it writes code for me. It does write a lot of my code, and I'm glad it does. The bigger change happened before any code got written. Working with AI agents every day forced me to get clear about what I actually want, and that turned out to be a skill I'd been quietly faking for years.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/54d94d/hero.svg" alt="Top: a crumpled sticky note with a scribble sends a dashed, wandering arrow through a small robot agent to a shapeless grey blob and a question mark. Bottom: a neat ticket with three boxed sections sends a straight arrow through the same agent to a clean block under a tick." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Same agent, two tickets. The output is only ever as clear as the ask.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;I used to get away with vague&lt;/h2&gt;
&lt;p&gt;For most of my career I could be vague and nobody noticed. I could hold half a plan in my head, start coding and work the rest out as I went. A ticket that said "fix the export" was fine, because I was the one fixing it. The missing detail lived in my head, and nobody could see inside my head to question it.&lt;/p&gt;
&lt;p&gt;Teammates covered for it too. A good senior engineer reads a sloppy ticket, fills the gaps from context and gets on with it. A junior messages you three times on Slack. Either way the work gets done eventually, and the cost of the vagueness is spread across other people's afternoons, where nobody counts it.&lt;/p&gt;
&lt;p&gt;An agent doesn't absorb that cost. It needs precision, context and a clear definition of done. It reads what you wrote, not what you meant. &lt;strong&gt;When I give it vague instructions, I get vague results. Every time.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;That isn't a complaint about agents. It's the most honest feedback on my own writing I've ever had.&lt;/p&gt;
&lt;h2&gt;Vague versus agent-ready&lt;/h2&gt;
&lt;p&gt;Here's an illustrative ticket, the kind I'd have written a few years ago without a second thought:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Title: Fix order export

The CSV export is broken for big customers. Please fix.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Give that to an agent and you'll get &lt;em&gt;something&lt;/em&gt;. Maybe it adds pagination. Maybe it bumps the gunicorn timeout. Maybe it rewrites the export as a background job and invents an email notification nobody asked for. Each one is a reasonable reading of "fix". None of them is guaranteed to be the one I had in my head.&lt;/p&gt;
&lt;p&gt;Here's the same ticket, again illustrative, written so an agent or a new teammate can actually finish it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Title: Order CSV export times out for accounts with 10k+ orders

Context
  /admin/orders/export/ builds the whole CSV inside the request.
  Large accounts hit the 30s load balancer timeout and get a 504.

Goal
  Large exports finish reliably. Small exports stay instant.

Acceptance criteria
  - Under 10k orders: the CSV downloads in the request, as today.
  - 10k or more: the export runs as a Celery task. The user sees
    "We'll email you a link" and gets a download link valid for 24h.
  - Columns, column order and date format are unchanged.
    Finance imports this file.
  - Tests cover both paths and the 10k boundary.

Out of scope
  - New columns or filters. Any other export.

Assumptions (confirm or correct)
  - The existing Celery worker and S3 bucket can be reused.
  - Dates stay in the account's timezone, as they are now.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The second version took about ten minutes. It isn't a spec document. But look at what writing it forced me to decide: where the threshold sits, what the user sees, what must not change, and what I'm &lt;em&gt;not&lt;/em&gt; asking for. Someone was always going to make those decisions. The only question was whether I'd make them on purpose or the agent would make them by accident.&lt;/p&gt;
&lt;h2&gt;Four habits that stuck&lt;/h2&gt;
&lt;p&gt;Once I started treating agents as literal readers, four habits followed. None of them is new. I just stopped skipping them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Better ticket descriptions, because the agent reads them literally.&lt;/strong&gt; Context, goal, scope. When a word could mean two things ("fix", "clean up", "support", "handle"), I replace it with what I actually mean.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Acceptance criteria up front, because the agent checks them.&lt;/strong&gt; This changed the most. Here's the template I use now:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Done when:
  - [observable behaviour] happens when [condition]
  - [existing behaviour] is unchanged
  - [error case] returns [message or status code], not a 500
  - tests cover [main path], [boundary] and [failure]
Not done if:
  - [something that looks done but isn't]
    e.g. only works with the local seed data
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;"Not done if" is the underrated part. It catches the agent declaring victory early, and it catches me doing the same.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Documented assumptions, because the agent doesn't guess, it asks.&lt;/strong&gt; A good agent stops and asks when something is unclear, and every question it asks points at a gap I left. So I write the assumptions down first. An illustrative log from a performance investigation:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Assumptions: slow checkout investigation
  A1  It started with Tuesday's deploy.       CONFIRMED  (APM graph)
  A2  It only affects card payments.          WRONG      (PayPal too)
  A3  The new discount query is the cause.    OPEN       (profiling next)
  A4  No migration went out that day.         CONFIRMED  (deploy log)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Writing A2 down is what made it checkable. In my head it was a fact. On paper it was a guess, and it was wrong. This is the same trap I wrote about in &lt;a href="/7b5ed3.html"&gt;ego in production&lt;/a&gt;: certainty that outruns the evidence, because nothing ever asked me to prove it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edge cases before code, because the agent will find them anyway.&lt;/strong&gt; An agent writing tests will happily throw empty lists, odd timezones and Unicode at your code. I'd rather think about them before it does. My pre-flight for most backend changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Empty, one, many.&lt;/strong&gt; Zero rows, exactly one, more than a page.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Boundaries.&lt;/strong&gt; The threshold itself, and one either side of it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Time.&lt;/strong&gt; Timezones, midnight, month end and the &lt;a href="/2c2a28.html"&gt;DST changeover&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bad input.&lt;/strong&gt; Missing fields, wrong types, Unicode names, very long strings.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Concurrency.&lt;/strong&gt; Double clicks, retries, two workers picking up the same job.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Permissions.&lt;/strong&gt; The user who shouldn't see this, and the admin who should.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Failure.&lt;/strong&gt; The third-party API is slow, down or returns rubbish.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rollback.&lt;/strong&gt; What happens to data the new code wrote if we revert.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The spill-over I didn't expect&lt;/h2&gt;
&lt;p&gt;Six months in, the surprise isn't the agent work. It's everything around it.&lt;/p&gt;
&lt;p&gt;My MR descriptions are better. They say what changed, why, and how to check it, because I'm used to writing exactly that for an agent. My investigation reports are more thorough, because the assumptions log is already sitting there when I write them up. My test coverage is tighter, because the edge cases were on paper before the first line of code.&lt;/p&gt;
&lt;p&gt;Not because AI does those things for me. Because working with AI made me realise how sloppy I'd been doing them before.&lt;/p&gt;
&lt;h2&gt;The irony&lt;/h2&gt;
&lt;p&gt;Here's the uncomfortable bit. The engineers who complain "AI doesn't understand what I want" are often the same engineers who skip writing requirements, leave ticket descriptions blank and expect teammates to just figure it out.&lt;/p&gt;
&lt;p&gt;The agent isn't uniquely dense. It's the first teammate that won't quietly absorb the cost. Every blank ticket a human picks up costs someone a Slack thread, a meeting or a wrong guess that ships. We just never put that cost on a dashboard.&lt;/p&gt;
&lt;p&gt;AI has no patience for ambiguity. Honestly, neither should your team.&lt;/p&gt;
&lt;h2&gt;The spec test&lt;/h2&gt;
&lt;p&gt;Anthropic's prompting guide has a test I like. It suggests treating the model like "a brilliant but new employee who lacks context on your norms and workflows", and says: "Show your prompt to a colleague with minimal context on the task and ask them to follow it. If they'd be confused, Claude will be too." (&lt;a href="https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#be-clear-and-direct"&gt;source&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;I run it the other way round too. Before I hand off any non-trivial work, I ask one question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Could a developer who joined last week, or an agent with the repo and nothing else, finish this without asking me anything important?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Then, every so often, I test it for real. Paste the ticket into a fresh agent session with no chat history and read what comes back. Where it goes somewhere strange, it's usually not the model being stupid. It's usually a gap in the ticket. Fix the ticket, not just the code, because the next human who reads it has the same gap.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If your instructions aren't clear enough for an AI agent, they probably aren't clear enough for a junior developer either.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Where this goes wrong&lt;/h2&gt;
&lt;p&gt;I don't want to oversell it. Some honest caveats:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A clear ticket doesn't make the agent right.&lt;/strong&gt; Agents still misread code, call functions that don't exist and write tests that pass for the wrong reason. A clear spec gives you something to review against. It doesn't replace the review. Read the diff, and run it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agents don't always ask.&lt;/strong&gt; Sometimes they guess confidently instead. Writing your assumptions down is how you catch the guesses you didn't know were made.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Over-specifying costs time.&lt;/strong&gt; If I spend an hour specifying a ten-minute change, I've lost. And if I dictate every line, I've written the code in English and thrown away the reason to use an agent.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don't write novels for trivial tasks.&lt;/strong&gt; "Rename &lt;code&gt;get_usr&lt;/code&gt; to &lt;code&gt;get_user&lt;/code&gt; across the repo" is a complete ticket. Match the effort to the risk: a typo fix gets one line, a payments change gets acceptance criteria, assumptions and an edge-case pass.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A precise spec can still be the wrong spec.&lt;/strong&gt; Clarity about the wrong thing just gets you the wrong thing faster. It doesn't replace talking to the people who'll use what you build.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why I want more of this, not less&lt;/h2&gt;
&lt;p&gt;I'm pro-AI, and I want these tools to get better faster. Better agents will need less hand-holding on the small stuff, and that's great. But typing was never the hard part. The hard part is deciding what done means, what's out of scope and what happens when things fail. The faster agents get, the more that thinking &lt;em&gt;is&lt;/em&gt; the job.&lt;/p&gt;
&lt;p&gt;Faster agents also mean more work gets handed off, to agents and to people. Every handoff rewards a clear ask. So I don't see this habit fading as the models improve. If anything, it's worth more each time they do.&lt;/p&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;AI didn't make me a better engineer by doing my work. It made me better by refusing to read my mind. Write the ticket so a stranger could finish it. Put the acceptance criteria first. Write the assumptions down. Think about the edges before the code. Then review what comes back.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The standard you set for AI is the standard you should have been setting all along.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Has AI changed how you think about your own work, or just how you do it?&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>AI Won't Kill the Middleman. Be the Middleman.</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/539a49.html"/>
    <id>https://nehem.dev/539a49.html</id>
    <published>2026-10-31T00:00:00+10:00</published>
    <updated>2026-10-31T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>AI won't wipe out the people who connect products to customers. Why the gap between AI and a plumber stays open, the bridging work in it and how to price it.</summary>
    <category term="AI"/><category term="Careers"/><category term="Small Business"/><category term="Automation"/>
    <content type="html">&lt;p&gt;Every few weeks someone tells me AI is going to take all our jobs. Developers, designers, admin staff, the lot. Usually it's said with the same nervous energy people had about the internet in the late nineties.&lt;/p&gt;
&lt;p&gt;I don't buy it, and I'm about as pro-AI as you can get. I want better models, sooner. But the fear misreads where the money and the work actually go.&lt;/p&gt;
&lt;p&gt;The position: &lt;strong&gt;AI companies will keep making money, and people will keep paying them. What doesn't disappear is the gap between a powerful product and the person who needs it.&lt;/strong&gt; A doctor won't wire up an AI stack between patients. A plumber won't either. Someone has to turn the tool into a service that fits a real business on a real Tuesday. That someone has work for a long time. Be that someone.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/539a49/hero.svg" alt="On the left bank, a medical clinic, a tradie's van and a customer. On the right bank, a tall stack of AI products. Between them a gap, and across it a hand-drawn bridge with one person standing in the middle, under a tick." width="960" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;The products keep getting better. The gap between them and a busy clinic doesn't close by itself.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;We've heard this before&lt;/h2&gt;
&lt;p&gt;Australians have watched this story play out with two of our own companies.&lt;/p&gt;
&lt;p&gt;When &lt;a href="https://www.rea-group.com/about-us/our-people-and-story/our-story/"&gt;realestate.com.au launched in 1995&lt;/a&gt;, the obvious prediction was that sellers would list their own homes and agents would fade away. The listings did move online. The agents didn't go anywhere. &lt;a href="https://www.jobsandskills.gov.au/data/occupation-and-industry-profiles/occupations/6121-real-estate-sales-agents"&gt;Jobs and Skills Australia&lt;/a&gt; counts roughly 104,000 people working as real estate sales agents today, and the number is still growing. The portal took over the noticeboard. It didn't take over pricing, negotiating, running inspections or holding a nervous vendor's hand through an auction.&lt;/p&gt;
&lt;p&gt;Same with hiring. &lt;a href="https://au.seek.com/about"&gt;SEEK was founded in 1997&lt;/a&gt;, LinkedIn came a few years later, and recruiters were supposed to be finished. Instead, job boards made applying nearly free, so a single role started pulling in a pile of resumes nobody had time to read. A hiring manager with a team to run can't spend a week sifting applications. Recruitment is still a whole profession: &lt;a href="https://www.jobsandskills.gov.au/data/occupation-and-industry-profiles/occupations/223112-recruitment-consultants"&gt;around 33,000 recruitment consultants&lt;/a&gt; at the last Census. The platform made the middle &lt;em&gt;more&lt;/em&gt; necessary, not less.&lt;/p&gt;
&lt;p&gt;There's a classic version of this from outside Australia too. James Bessen &lt;a href="https://www.imf.org/external/pubs/ft/fandd/2015/03/bessen.htm"&gt;showed&lt;/a&gt; that ATMs didn't wipe out US bank tellers. Each branch needed fewer of them, branches got cheaper to run, banks opened more, and the teller's job shifted from counting cash to looking after customers.&lt;/p&gt;
&lt;p&gt;The pattern: &lt;strong&gt;when a technology makes something cheap, demand for it grows, and the human work moves to wherever the product stops.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Why the gap doesn't close by itself&lt;/h2&gt;
&lt;p&gt;AI products are general by design. They have to be, to sell to hundreds of millions of people. Every business that might use them is specific. The distance between those two things is where the work lives, and it's made of very ordinary stuff:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Time.&lt;/strong&gt; A GP's day is booked in fifteen-minute blocks. Learning prompt patterns, testing tools and reading API docs is a second job they didn't apply for.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Context.&lt;/strong&gt; The model doesn't know that this plumber never quotes hot water jobs over the phone, or that this clinic's referral letters go to three specific specialists.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integration.&lt;/strong&gt; The value is never in the chat window. It's in connecting the model to the calendar, the job management system, the accounting software and the inbox the business already lives in.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accountability.&lt;/strong&gt; When something goes wrong, the owner wants a person to call. "The model did it" isn't an answer a customer accepts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Trust.&lt;/strong&gt; Most small business owners will try something new because someone they know set it up and stands behind it, not because a landing page told them to.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;None of that is solved by a smarter model. A smarter model makes the opportunity bigger.&lt;/p&gt;
&lt;h2&gt;What the bridge actually looks like&lt;/h2&gt;
&lt;p&gt;Here's the kind of work I mean. None of it is exotic, and that's the point.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The phone and the inbox.&lt;/strong&gt; Missed calls are lost jobs for a tradie. An AI receptionist that answers, works out what's needed, books a slot in the real calendar and texts a summary to the owner's phone is worth far more than the model behind it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Admin for clinics.&lt;/strong&gt; Drafting referral letters and recall reminders from notes, for a human to check before anything is sent. Health information is sensitive, so this one is as much about privacy and process as it is about prompts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Paperwork plumbing.&lt;/strong&gt; Supplier invoices read and coded into the accounting system, quotes drafted from a site visit's voice note, timesheets checked against rosters.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Knowledge on tap.&lt;/strong&gt; The procedures manual nobody reads, turned into something a new staff member can ask questions of.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Marketing that actually ships.&lt;/strong&gt; Social posts, Google Business updates and review replies, drafted every week in the owner's voice and approved with one tap.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The small custom app.&lt;/strong&gt; A Django app with a model API behind it, doing one job that no off-the-shelf product does for this particular business.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;How to price and position it&lt;/h2&gt;
&lt;p&gt;A few things that, in my experience, separate a real service from a side project:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Sell the outcome, not the AI.&lt;/strong&gt; "Every call answered and booked" is something an owner can value. "A GPT-powered voice agent" isn't. Many of them don't care which model it is, and they shouldn't have to.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pick a lane.&lt;/strong&gt; Dental clinics, or electricians, or real estate offices. The second clinic is much easier than the first, because you already know the software, the vocabulary and the objections.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Setup plus a monthly fee.&lt;/strong&gt; A one-off fee to map the workflow and build the integration, then a monthly fee to run, monitor and improve it. The monthly part is honest: models change, APIs change and the business changes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stay model-agnostic.&lt;/strong&gt; Keep the model behind your own small interface, like &lt;code&gt;llm_extract&lt;/code&gt; above. When a better or cheaper model ships, your clients get the upgrade and you keep the relationship.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Own the boring parts.&lt;/strong&gt; Monitoring, logs, an off switch, a human fallback and a clear answer to "what happens to my data?" These are what make an owner trust you with their phones.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Where this breaks down&lt;/h2&gt;
&lt;p&gt;I'd be lying if I said every middleman survives. They don't.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;When the product closes the gap itself, thin middlemen get squeezed.&lt;/strong&gt; If your whole service is something the platform turns into a checkbox next quarter, you're renting time. Even the bank teller story has a second chapter: the &lt;a href="https://www.bls.gov/ooh/office-and-administrative-support/tellers.htm"&gt;US Bureau of Labor Statistics&lt;/a&gt; now projects teller jobs to fall 13% from 2024 to 2034, as banking moves onto phones.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Middlemen who only pass information along are the most exposed.&lt;/strong&gt; The ones who last carry judgement, relationships and accountability. Real estate agents survived because they negotiate and take responsibility, not because they hold the listings.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You become the support line.&lt;/strong&gt; When it breaks at 7 am, they call you. Price that in, or don't take the work.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regulated data needs real care.&lt;/strong&gt; Health, legal and financial information comes with obligations. If you can't explain where the data goes and who can see it, you're not ready to sell to clinics.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The skill moves.&lt;/strong&gt; Today the gap is wiring up APIs. Tomorrow it may be supervising agents, or redesigning a whole workflow around them. The bridge-builder has to keep learning faster than the gap moves.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why I want AI to move faster&lt;/h2&gt;
&lt;p&gt;None of this is an argument for slowing anything down. The opposite.&lt;/p&gt;
&lt;p&gt;Every jump in capability makes something possible that wasn't last year, and every one of those things needs someone to bring it to a clinic, a trade business or a corner shop. Better models don't shrink the bridge-building market. They keep adding new places to build bridges.&lt;/p&gt;
&lt;p&gt;Most people won't follow model releases or read API docs. They'll keep doing their actual jobs, and they'll pay someone they trust to bring the new capability to them.&lt;/p&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;The fear is "AI will replace us". The more useful question is where the gap between the product and the customer sits, and who's standing in it. &lt;strong&gt;Don't just use AI. Bridge it.&lt;/strong&gt; Pick a kind of business, learn its day, connect the tools to the systems it already runs on, and stand behind the result. AI companies will keep getting paid. So will the people who make what they sell actually work for a busy plumber.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Urda: What Happens When Automation Hands Control Back to Humans</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/d28b21.html"/>
    <id>https://nehem.dev/d28b21.html</id>
    <published>2026-10-30T00:00:00+10:00</published>
    <updated>2026-10-30T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>A train protection fault near Urda stopped trains safely; a manual restart order ended in a collision. What it teaches about degraded modes, handovers and AI safety.</summary>
    <category term="Rail Safety"/><category term="Incidents"/><category term="Safety Engineering"/><category term="AI Safety"/><category term="Postmortems"/>
    <content type="html">&lt;p&gt;This is far from my usual topics of Django, Postgres and AWS bills. But I've spent most of my career thinking about what happens when automation stops and people take over. On Wednesday that question cost lives in Spain.&lt;/p&gt;
&lt;p&gt;At least 69 people were killed when two high-speed trains collided near Urda, in Toledo province, on the morning of Wednesday 28 October. My thoughts are with them, their families and everyone still in hospital.&lt;/p&gt;
&lt;p&gt;What follows is based only on what officials, the accident investigators and reliable outlets had reported &lt;strong&gt;as of the evening of Friday 30 October in Spain (the morning of Saturday 31 October in Sydney)&lt;/strong&gt;. The investigation has barely started. The investigators' first note is a description, not a finding, and nobody should be judged on a blog post.&lt;/p&gt;
&lt;h2&gt;What we know so far&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The collision.&lt;/strong&gt; At about 08:53, a Renfe AVE travelling south from Madrid ran into the back of an Iryo train that was stopped on the line. It happened at kilometre 118 of the Madrid–Seville high-speed line, just short of Urda station (&lt;a href="https://elpais.com/espana/2026-10-29/los-cabos-por-atar-del-siniestro-de-urda-en-las-investigaciones-judicial-y-tecnica.html"&gt;El País&lt;/a&gt;, &lt;a href="https://www.reuters.com/graphics/SPAIN-ACCIDENT/dwvkmmgbrvm/"&gt;Reuters&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The toll.&lt;/strong&gt; The provisional count is 69 dead, and officials have not ruled out more: by Friday there were 70 missing-person reports, and the regional president said up to 31 bags of partial remains had still to be analysed. Forensic teams had carried out 65 autopsies and 13 victims had been identified (&lt;a href="https://efe.com/espana/2026-10-30/accidente-trenes-urda-toledo-victimas/"&gt;EFE&lt;/a&gt;, &lt;a href="https://es.euronews.com/2026/10/30/autoridades-descartan-victimas-urda-70-denuncias-desaparecidos"&gt;Euronews&lt;/a&gt;). Earlier in the count, when it stood at 68, the regional president said 44 of the dead had been on the Iryo and 24 on the AVE (&lt;a href="https://clmpress.com/n/2026/10/page-afirma-que-24-de-los-fallecidos-viajaban-en-el-ave-y-44-en-el-iryo/"&gt;CLM Press&lt;/a&gt;); I haven't seen a breakdown of the latest figure. Of the 110 injured people admitted to the region's hospitals, 71 had gone home by Friday and 39 were still in hospital, 17 of them in intensive care (&lt;a href="https://efe.com/espana/2026-10-30/accidente-trenes-urda-toledo-victimas/"&gt;EFE&lt;/a&gt;, &lt;a href="https://es.euronews.com/2026/10/30/autoridades-descartan-victimas-urda-70-denuncias-desaparecidos"&gt;Euronews&lt;/a&gt;). The investigators' first note puts 147 passengers and 5 crew on the Iryo, and 379 passengers and 7 crew on the AVE (&lt;a href="https://www.eldiario.es/castilla-la-mancha/primer-informe-accidente-urda-estima-colision-ave-iryo-produjo-160-200-km-h_1_13625882.html"&gt;elDiario.es&lt;/a&gt;). Early figures from the regional government had the AVE at 397 (&lt;a href="https://efe.com/portada-espana/2026-10-28/tren-iryo-ave-accidentados-pasajeros/"&gt;EFE&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The fault.&lt;/strong&gt; According to Transport Minister Óscar Puente, a communication fault between three computers took the LZB train protection system out of service along about 63 km of line. The independent accident investigators, AITAT, put the start of the failure at 08:31. Six trains stopped automatically, and Adif's control centre at Atocha took over, managing traffic by formal phone orders (&lt;em&gt;telefonemas&lt;/em&gt;) under lateral signal block working (BSL) (&lt;a href="https://es.euronews.com/2026/10/30/primer-informe-urda-apunta-cadena-fallos"&gt;Euronews&lt;/a&gt;, &lt;a href="https://www.eldiario.es/castilla-la-mancha/primer-informe-accidente-urda-estima-colision-ave-iryo-produjo-160-200-km-h_1_13625882.html"&gt;elDiario.es&lt;/a&gt;). The minister says it's still not known what caused the fault, and that LZB has had 170 incidents so far this year, in line with previous years (&lt;a href="https://www.rtve.es/noticias/20261030/accidente-tren-toledo-oscar-puente-ruede-prensa-declaraciones/17289862.shtml"&gt;RTVE&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The order.&lt;/strong&gt; The minister said that at 08:36 the AVE was authorised to resume running "normally", even though a red signal was showing and the track ahead was occupied by the stopped Iryo. The published recordings match that account. The AVE's driver, Antonio Acedo, who was killed in the collision, reported a "meta cero" (target speed zero), which means the section ahead is occupied. For that case, the rules provide an order (LZB3) to continue on sight. According to El País's analysis of the audio, Atocha instead dictated LZB4, an order that leaves the running conditions to the control centre, and filled them in as "normal running". The driver, who had been repeating each phrase back, asked "With normal running?", and the answer was yes (&lt;a href="https://elpais.com/espana/2026-10-30/las-llamadas-entre-atocha-y-los-maquinistas-explicadas-paso-a-paso.html"&gt;El País&lt;/a&gt;, &lt;a href="https://cadenaser.com/nacional/2026/10/28/la-ser-accede-a-los-audios-de-las-conversaciones-entre-el-centro-de-control-de-adif-y-los-maquinistas-de-los-trenes-accidentados-en-urda-reanude-con-marcha-normal-cadena-ser/"&gt;Cadena SER&lt;/a&gt;). The AVE travelled about 25 km in 17 minutes before the impact. AITAT's first note estimates the collision speed at between 160 and 200 km/h; the exact figure will come from the trains' recorders (&lt;a href="https://cadenaser.com/nacional/2026/10/29/la-aitat-recupera-las-cajas-negras-de-los-trenes-de-urda-y-arranca-la-investigacion-del-accidente-cadena-ser/"&gt;Cadena SER&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The rule.&lt;/strong&gt; In Puente's account, two basic rules apply. A train behind doesn't move until the one ahead in the same block has moved, and the restart should be under &lt;em&gt;marcha a la vista&lt;/em&gt;: driving on sight, at a speed low enough to stop short of any obstacle, and never above 40 km/h. On Friday he said the Iryo, which was ahead, should have been authorised first (&lt;a href="https://www.rtve.es/noticias/20261030/accidente-tren-toledo-oscar-puente-ruede-prensa-declaraciones/17289862.shtml"&gt;RTVE&lt;/a&gt;, &lt;a href="https://www.rtve.es/noticias/20261030/ciaf-investigacion-accidente-trenes-urda-causas/17289829.shtml"&gt;RTVE&lt;/a&gt;). On Wednesday he called the decision "inexplicable", said the train drivers were not to blame, said there had been time to correct the order, and left responsibility to the investigation. He also acknowledged that no safety system was in place to stop a human error like this from ending in a collision (&lt;a href="https://www.elespanol.com/espana/20261028/oscar-puente-senala-adif-decidir-tren-renfe-reanudara-marcha-circunstancias-inexplicables/1003744437994_0.html"&gt;El Español&lt;/a&gt;, &lt;a href="https://www.euronews.com/2026/10/28/inexplicable-order-by-control-centre-investigated-after-spain-train-crash"&gt;Euronews&lt;/a&gt;). On Friday he said he hadn't used the words "human error" himself, but that people are the last resort in every transport system (&lt;a href="https://www.rtve.es/noticias/20261030/ciaf-investigacion-accidente-trenes-urda-causas/17289829.shtml"&gt;RTVE&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The written procedure.&lt;/strong&gt; Europa Press reports that an Adif instruction issued in February 2025 says that after an LZB failure, trains may only restart under lateral signal block working (BSL), and only when the block ahead is clear of trains (&lt;a href="https://www.europapress.es/economia/transportes-00343/noticia-reglamento-adif-prohibia-centro-control-autorizar-ave-reanudar-marcha-20261028200123.html"&gt;Europa Press&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Iryo's calls.&lt;/strong&gt; In the published recordings, the Iryo driver tells Atocha she is stopped at the Urda entry signal after losing transmission. At 08:41 she too is told to resume "with normal running", four minutes after the AVE, which was behind her. At 08:48 she calls back to say the train won't let her restart LZB and she is still stopped; the reply is "whenever you can, and if you have problems, call us". The collision came five minutes later. Sources close to Iryo say she tried to restart twice and then called Iryo's own control centre (&lt;a href="https://www.rtve.es/noticias/20261030/ciaf-investigacion-accidente-trenes-urda-causas/17289829.shtml"&gt;RTVE&lt;/a&gt;, &lt;a href="https://elpais.com/espana/2026-10-30/las-llamadas-entre-atocha-y-los-maquinistas-explicadas-paso-a-paso.html"&gt;El País&lt;/a&gt;, &lt;a href="https://cadenaser.com/nacional/2026/10/28/la-maquinista-de-iryo-llamo-al-centro-de-control-de-adif-porque-no-podia-arrancar-el-tren-pues-nada-cuando-pueda-y-si-tiene-problemas-nos-llama-cadena-ser/"&gt;Cadena SER&lt;/a&gt;). As far as reporting shows, no one then told the AVE to stop.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A green signal and a full screen.&lt;/strong&gt; On Friday the minister added two things. When the Iryo was authorised, its signal was changed from red to green, even though the train never moved. ASFA, the beacon-based backup still working without LZB, therefore had nothing to warn the AVE about as it approached. And Atocha's screens showed both trains in the same block throughout: "you can see dramatically how one train is approaching and the other is stopped" (&lt;a href="https://www.rtve.es/noticias/20261030/accidente-tren-toledo-oscar-puente-ruede-prensa-declaraciones/17289862.shtml"&gt;RTVE&lt;/a&gt;, &lt;a href="https://www.lasexta.com/noticias/nacional/puente-asegura-que-ave-vio-semaforo-verde-antes-chocar-pantalla-como-tren-acercando-otro-esta-parado_202610306ae4921a6973466c29e341b0.html"&gt;laSexta&lt;/a&gt;). That is his account; the investigators haven't confirmed it yet.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A driver who pushed back.&lt;/strong&gt; The minister said on Wednesday that the driver of another train, given the same "normal running" order, pointed out that it should be on sight (&lt;a href="https://www.lavanguardia.com/politica/20261028/11670324/puente-ve-inexplicable-operador-adif-autorizara-marchar-tren-renfe-impacto-iryo.html"&gt;La Vanguardia&lt;/a&gt;). Sources quoted by RTVE say it was an Iryo coming from Seville, about 50 km away, which spoke to the controller again and set off on sight (&lt;a href="https://www.rtve.es/noticias/20261030/ciaf-investigacion-accidente-trenes-urda-causas/17289829.shtml"&gt;RTVE&lt;/a&gt;). As far as is known, that correction never reached the AVE (&lt;a href="https://elpais.com/espana/2026-10-29/los-cabos-por-atar-del-siniestro-de-urda-en-las-investigaciones-judicial-y-tecnica.html"&gt;El País&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The investigation.&lt;/strong&gt; A court in Orgaz has opened a judicial investigation under secrecy. The judge ordered the trains' recorders seized, closed 2 km of line either side of the site, and asked for Adif's traffic data and procedures (&lt;a href="https://www.poderjudicial.es/cgpj/es/Poder-Judicial/Noticias-Judiciales/La-jueza-instructora-del-accidente-ferroviario-de-Urda--Toledo--acuerda-la-prohibicion-de-acceso-de-terceras-personas-a-la-zona-del-siniestro"&gt;Spanish judiciary&lt;/a&gt;). The controller who gave the order is, so far, the only person under investigation. He tested negative for alcohol and drugs on the day, and on Thursday he declined to answer the Guardia Civil's questions; the judge is expected to call him (&lt;a href="https://elpais.com/espana/2026-10-30/el-operador-que-autorizo-al-ave-a-retomar-la-marcha-se-acoge-ante-la-guardia-civil-a-su-derecho-a-no-declarar.html"&gt;El País&lt;/a&gt;, &lt;a href="https://www.elconfidencial.com/espana/2026-10-30/el-operario-de-la-sala-de-control-senalado-por-puente-y-unico-investigado-por-ahora-rechaza-declarar-ante-la-uco_4456193/"&gt;El Confidencial&lt;/a&gt;). The technical investigation is run by AITAT, the independent authority that took over from the rail accident commission (CIAF) this year. Its first note, published on Thursday, describes "a chain of failures, instructions and actions" that, in its provisional wording, would have led to the collision "without the necessary mitigating barriers having acted". It says all hypotheses remain open, that it hasn't yet been able to interview the controllers or drivers, and that it has, in principle, a year to publish its final report (&lt;a href="https://www.eldiario.es/castilla-la-mancha/primer-informe-accidente-urda-estima-colision-ave-iryo-produjo-160-200-km-h_1_13625882.html"&gt;elDiario.es&lt;/a&gt;, &lt;a href="https://www.abc.es/espana/primer-informe-urda-apunta-cadena-averias-instrucciones-20261029215855-nt.html"&gt;ABC&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The aftermath.&lt;/strong&gt; The government declared three days of official mourning, 29 to 31 October (&lt;a href="https://www.lamoncloa.gob.es/presidente/actividades/paginas/2026/281026-sanchez-visita-accidente-tren.aspx"&gt;La Moncloa&lt;/a&gt;), and on Friday the regional emergency was lowered to level 1 (&lt;a href="https://efe.com/espana/2026-10-30/accidente-trenes-urda-toledo-victimas/"&gt;EFE&lt;/a&gt;). Most parties paused campaigning for the 29 November general election, Vox being the exception; the PP plans to resume on Monday (&lt;a href="https://www.elplural.com/politica/espana/luto-traslada-campana-vox-mantiene-agenda-politica-mientras-resto-partidos-guardan-respeto_802676102"&gt;elplural.com&lt;/a&gt;, &lt;a href="https://www.servimedia.es/noticias/feijoo-retomara-campana-lunes-reunira-barones-genova-una-vez-acabado-luto-urda/1413502474"&gt;Servimedia&lt;/a&gt;). Puente has ruled out resigning despite calls from the opposition and some of the government's partners (&lt;a href="https://www.rtve.es/noticias/20261030/accidente-tren-toledo-oscar-puente-ruede-prensa-declaraciones/17289862.shtml"&gt;RTVE&lt;/a&gt;). It is Spain's deadliest rail crash since 2013, and the second fatal collision on this line in nine months, after Adamuz in January killed 46 (&lt;a href="https://www.reuters.com/graphics/SPAIN-ACCIDENT/dwvkmmgbrvm/"&gt;Reuters&lt;/a&gt;, &lt;a href="https://www.rtve.es/noticias/20261030/accidente-tren-toledo-oscar-puente-ruede-prensa-declaraciones/17289862.shtml"&gt;RTVE&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;figure class="fig fig-tall"&gt;&lt;a class="fig-open" href="/media/d28b21/timeline.svg" title="Open full size"&gt;&lt;img src="https://nehem.dev/media/d28b21/timeline.svg" alt="Five stacked panels. One: the LZB line is crossed out and two trains wait at red signals. Two: a control desk with three screens showing both trains, and radio waves towards the trains. Three: the AVE moves past a red signal while the Iryo is stopped ahead; the recorded order reads &amp;quot;under BSL with normal running&amp;quot;. Four: what the rule requires, a train at no more than 40 km/h with a sight line and a stop line short of an obstacle. Five: the two trains meet at the kilometre 118 post, five minutes after the Iryo reported it still could not restart." width="800" height="1560" loading="lazy" decoding="async"&gt;&lt;/a&gt;&lt;figcaption&gt;How it unfolded, according to the transport minister, the published control-centre recordings and the investigators' first note, as of 31 October. Schematic, not to scale. Tap to open full size.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;What we don't know yet&lt;/h2&gt;
&lt;p&gt;Why LZB went down, and why the Iryo couldn't restart it. Why Atocha chose an order that left the speed to the control centre, and filled it in as "normal running", when the AVE had reported an occupied section ahead. Whether the decision was individual or collective: the recordings have other voices in the room weighing in (&lt;a href="https://elpais.com/espana/2026-10-30/las-llamadas-entre-atocha-y-los-maquinistas-explicadas-paso-a-paso.html"&gt;El País&lt;/a&gt;), and the Guardia Civil wants to know who decided, who passed it on, and whether anyone was pushing to get traffic moving again quickly (&lt;a href="https://elpais.com/espana/2026-10-30/el-operador-que-autorizo-al-ave-a-retomar-la-marcha-se-acoge-ante-la-guardia-civil-a-su-derecho-a-no-declarar.html"&gt;El País&lt;/a&gt;). Controllers quoted anonymously by El Español say they're pressured to avoid delays; the minister rejects any problem with their working conditions and says the shift had been on for about two hours (&lt;a href="https://www.elespanol.com/invertia/observatorios/movilidad/20261030/controladores-adif-culpan-puente-presionan-no-retrasos-trenes-pueden-parados/1003744440265_0.html"&gt;El Español&lt;/a&gt;, &lt;a href="https://www.rtve.es/noticias/20261030/ciaf-investigacion-accidente-trenes-urda-causas/17289829.shtml"&gt;RTVE&lt;/a&gt;). Why the Iryo's 08:48 call, the other driver's challenge and a screen showing two trains in one block didn't lead anyone to stop the AVE. And whether the minister's account of ASFA and the green signal holds up. The recorders, which haven't been downloaded yet, and the investigators' report are what matter.&lt;/p&gt;
&lt;h2&gt;The system did the right thing first&lt;/h2&gt;
&lt;p&gt;Start with what worked. LZB continuously supervises a train's speed and can brake it automatically (&lt;a href="https://english.elpais.com/spain/2026-10-28/what-is-the-lzb-signaling-system-one-of-the-key-factors-in-the-fatal-train-accident-in-spain.html"&gt;El País&lt;/a&gt;). When it lost its data link, it failed safe: every train in the section stopped. Puente made the point himself. The computer fault wasn't the deciding factor, because the safety mechanism stopped the trains (&lt;a href="https://es.euronews.com/2026/10/28/oscar-puente-considera-inexplicable-que-el-centro-de-control-autorizara-al-ave-a-reanudar-"&gt;Euronews&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Stopping is the easy part. &lt;strong&gt;The dangerous part is restarting.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Once continuous supervision is gone, the railway falls back on older layers: lateral signals, block working, the ASFA beacons and written rules. ASFA reads trackside beacons at fixed points rather than supervising continuously (&lt;a href="https://english.elpais.com/spain/2026-10-28/what-is-the-lzb-signaling-system-one-of-the-key-factors-in-the-fatal-train-accident-in-spain.html"&gt;El País&lt;/a&gt;). As &lt;a href="https://www.rtve.es/noticias/20261029/accidente-tren-toledo-sistema-seguridad-lzb-como-funciona-ocurre-si-falla/17287266.shtml"&gt;RTVE&lt;/a&gt; put it, once a control centre authorises a train past a red signal, safety no longer rests on an automatic system. It rests on the driver, which is exactly why the rule demands driving on sight.&lt;/p&gt;
&lt;p&gt;In degraded mode, protection moves out of the machine and into procedures and people's heads.&lt;/p&gt;
&lt;figure class="fig fig-tall"&gt;&lt;a class="fig-open" href="/media/d28b21/layers.svg" title="Open full size"&gt;&lt;img src="https://nehem.dev/media/d28b21/layers.svg" alt="Seven stacked layers seen edge-on, each with small ordinary holes. A dashed line runs down through a large hole in LZB, the lateral signals, the control-centre authorisation, the block-clear check and driving on sight, and through amber holes in the control-room cross-check and ASFA. The line ends at a collision marker." width="800" height="1616" loading="lazy" decoding="async"&gt;&lt;/a&gt;&lt;figcaption&gt;Layers of defence, marked only as far as reporting supports, as of 31 October. Coral: a reported gap. Amber: reported, but details unclear (for ASFA, the minister's account, not yet confirmed by investigators).&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Accidents need the holes to line up&lt;/h2&gt;
&lt;p&gt;James Reason's &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC1117770/"&gt;Swiss cheese model&lt;/a&gt; describes safety as layers of defence, each with holes that open and close. Harm gets through only when the holes briefly line up. Richard Cook says the same in &lt;a href="https://how.complexsystems.fail/"&gt;How Complex Systems Fail&lt;/a&gt;: "Catastrophe requires multiple failures – single point failures are not enough."&lt;/p&gt;
&lt;p&gt;Read the reported sequence that way and the computer fault is only the first hole. The trains stopping shows the next layer working. What came after, by the minister's account, was a restart order that didn't match the written procedure. Then the chances to catch it came and went: a driver on another train challenged the same order, and the Iryo called in to say it was still stuck. As far as reporting shows, neither turned into a stop order for the AVE. With continuous protection gone, the minister says not even ASFA could help, because the Iryo's signal had been cleared to green for a train that never moved. And the control room, by his account, could see both trains on screen the whole time.&lt;/p&gt;
&lt;p&gt;Cook has another warning that belongs right here: "Hindsight biases post-accident assessments of human performance." Knowing the outcome makes the right call look obvious. It rarely looks that way in a busy control room during a fault. That's why the question investigators ask isn't "who got it wrong" but "what made this action make sense at the time".&lt;/p&gt;
&lt;h2&gt;The recovery path is the least tested path&lt;/h2&gt;
&lt;p&gt;Lisanne Bainbridge described this in 1983. In &lt;a href="https://ckrybus.com/static/papers/Bainbridge_1983_Automatica.pdf"&gt;Ironies of Automation&lt;/a&gt; she argued that automation takes over the routine work and leaves people the hardest jobs: taking over when something has already gone wrong. Their skills fade because they rarely use them. Her conclusion: "one can argue that the operator needs to be more rather than less skilled, and less rather than more loaded, than average."&lt;/p&gt;
&lt;p&gt;Nancy Leveson's &lt;a href="https://direct.mit.edu/books/oa-monograph/2908/Engineering-a-Safer-WorldSystems-Thinking-Applied"&gt;Engineering a Safer World&lt;/a&gt; frames safety as a control problem. Accidents happen when a controller issues a command that is unsafe for the real state of the system, often because its picture of that state has drifted from reality. Degraded mode is where that drift is most likely. The automation that kept the picture accurate is the thing that just failed.&lt;/p&gt;
&lt;p&gt;The general lesson is uncomfortable. Normal running happens thousands of times a day and is superbly tested. Restarting traffic manually after a protection failure happens rarely, under pressure, with the strongest safety layer missing. &lt;strong&gt;The recovery path is the least exercised path in the system, and it runs with the fewest guard rails.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Make the safe restart the default&lt;/h2&gt;
&lt;p&gt;A few principles follow, for any system that fails safe and then needs people to bring it back:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;The degraded-mode default should be the cautious one.&lt;/strong&gt; Driving on sight at 40 km/h should be what a restart &lt;em&gt;means&lt;/em&gt;, not an option someone has to remember to say.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Overriding a stop should need an independent check.&lt;/strong&gt; The section-clear condition is the right idea. It works best when a second person or the system itself has to confirm it, not just recall it. The one bright spot reported so far is that on another train, a driver questioned the order and set off on sight. That's the second check working, but as far as is known it didn't reach the order already given to the AVE. A check only protects you if what it finds is applied to everything already in motion.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rehearse the restart.&lt;/strong&gt; If manual recovery is rare, practise it, the way Bainbridge recommended simulator time for rare failures.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Give the people in the loop the same picture the automation had, and make the system act on it.&lt;/strong&gt; By the minister's account, Atocha's screens did show both trains in the same block. A picture someone has to notice isn't a safeguard. If the panel shows a train in the section ahead, the restart procedure should refuse to proceed without an explicit, recorded override.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Why software people should care&lt;/h2&gt;
&lt;p&gt;We build the same shape constantly. A circuit breaker trips, a deploy halts, a database fails over. Then someone has to "resume", usually by hand, often by bypassing the very guard that stopped things. Knight Capital lost more than $460 million in 2012, and its improvised fix during the incident made the problem worse. I wrote about that in &lt;a href="/7b5ed3.html"&gt;Is Your Ego Running Production?&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The stakes in Urda are of a completely different order, and I don't want to blur that. But the engineering lesson carries over. Design the recovery path as carefully as the happy path. Make the safe restart the default. Require a second check before anyone overrides a stop. And when it goes wrong, look at the system before the person.&lt;/p&gt;
&lt;h2&gt;What Urda does and doesn't say about AI &amp;amp; Automation&lt;/h2&gt;
&lt;p&gt;One fact first, because it will get lost. Nothing reported so far suggests AI played any part in this. LZB and ASFA are conventional railway signalling: deterministic train protection built to fixed rules (&lt;a href="https://english.elpais.com/spain/2026-10-28/what-is-the-lzb-signaling-system-one-of-the-key-factors-in-the-fatal-train-accident-in-spain.html"&gt;El País&lt;/a&gt;). Nobody was running a model.&lt;/p&gt;
&lt;p&gt;I still expect Urda to be pulled into the AI debate, so it's worth getting the argument right. It goes like this: as automation becomes more capable, people lose the skill and context to take over when it fails. So slow down, and keep humans firmly in control until we know they can catch the machine.&lt;/p&gt;
&lt;p&gt;That argument deserves a fair hearing, because it rests on real work. Bainbridge put it sharply: "the designer who tries to eliminate the operator still leaves the operator to do the tasks which the designer cannot think how to automate." Parasuraman and Riley described how people come to over-rely on automation and stop monitoring it, and how designers sometimes treat the operator's role as a by-product of the automation (&lt;a href="https://doi.org/10.1518/001872097778543886"&gt;Human Factors, 1997&lt;/a&gt;). Sarter and Woods documented "automation surprises", where crews lose track of what the system is doing and why (&lt;a href="https://doi.org/10.1518/001872097778667997"&gt;Human Factors, 1997&lt;/a&gt;). And automation can be the hazard itself. The US House transportation committee found that "faulty assumptions about pilot responses" were among the causes of the two Boeing 737 MAX crashes, which killed 346 people (&lt;a href="https://democrats-transportation.house.gov/imo/media/doc/2020.09.15%20FINAL%20737%20MAX%20Report%20for%20Public%20Release.pdf"&gt;House report, 2020&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;I take all of that seriously. I just think it points the other way.&lt;/p&gt;
&lt;p&gt;Look at what failed at Urda, on the account we have today. The automation did its job: it lost its data and stopped every train. What failed, according to the minister and the investigators' first note, was the manual path: a chain of instructions and actions in which a human authorisation didn't match the written rule. The weak link wasn't the sophisticated machine. It was the assumption that a person can always step in safely.&lt;/p&gt;
&lt;p&gt;That assumption has a poor record. On Air France 447 in 2009, iced airspeed probes caused the autopilot to disconnect. The French investigators, the BEA, found the crew never identified the approach to the stall or the stall itself, and 228 people died (&lt;a href="https://bea.aero/fileadmin/documents/docspa/2009/f-cp090601.en/pdf/f-cp090601.en.pdf"&gt;BEA final report&lt;/a&gt;). In Tempe in 2018, Uber's test vehicle detected a pedestrian 5.6 seconds before impact but never classified her correctly. Its design relied on the safety operator, not the system, to brake in an emergency. The NTSB found the operator was distracted by her phone and called it "a typical effect of automation complacency" (&lt;a href="https://www.ntsb.gov/investigations/accidentreports/reports/har1903.pdf"&gt;NTSB HAR-19/03&lt;/a&gt;). In both cases "a human takes over" was the safety plan, and it failed.&lt;/p&gt;
&lt;p&gt;Bainbridge saw the trend coming too: "it is the most successful automated systems, with rare need for manual intervention, which may need the greatest investment in human operator training." The better the automation, the harder the handover. Slowing down doesn't fix that. Only designing the handover does.&lt;/p&gt;
&lt;p&gt;The status quo has its own body count, too. The WHO estimates 1.19 million people died on the world's roads in 2021 (&lt;a href="https://www.who.int/publications/i/item/9789240086517"&gt;WHO, 2023&lt;/a&gt;). Waymo researchers compared 56.7 million miles of driverless operation against human drivers in the same cities. They found statistically significant reductions in injury, airbag-deployment and serious-injury crashes (&lt;a href="https://doi.org/10.1080/15389588.2025.2499887"&gt;Kusano et al., 2025&lt;/a&gt;). The authors work for Waymo, and it covers a few cities, so read it as evidence, not proof. But it is peer-reviewed evidence that every year of delay has a cost, and that cost is counted in lives too.&lt;/p&gt;
&lt;h2&gt;Responsible acceleration&lt;/h2&gt;
&lt;p&gt;I'm openly an accelerationist. I want AGI and ASI as soon as we can build them. To me Urda is a case for faster, better engineering, not for slower progress. That means treating the handover as a first-class system, not a footnote:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Degrade gracefully, and by default.&lt;/strong&gt; When capability drops, the system should fall into a bounded, slower mode on its own. The 40 km/h rule belongs in the machine, not in someone's memory.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Check every override independently.&lt;/strong&gt; A separate check should be able to refuse an unsafe command, whether it comes from a person or a model.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Make the state visible.&lt;/strong&gt; Whoever takes over needs what the system knew, not a blank screen and a radio.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rehearse recovery.&lt;/strong&gt; Test the manual path as often as the happy path. Drills, game days, simulators.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Let capable automation be the fallback where it can.&lt;/strong&gt; A tired human at the worst possible moment is not a safety guarantee. Better automation often is.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure class="fig fig-tall"&gt;&lt;a class="fig-open" href="/media/d28b21/handover.svg" title="Open full size"&gt;&lt;img src="https://nehem.dev/media/d28b21/handover.svg" alt="A vertical flow: automation degrades; the system falls back automatically to a slow, bounded safe mode; people are shown the full picture; a person proposes an action; an independent check asks whether it is consistent with reality. If not, it refuses, explains and escalates. If so, the system proceeds in degraded mode, then restores full automation and verifies. A bracket notes the whole path is rehearsed in drills." width="800" height="1440" loading="lazy" decoding="async"&gt;&lt;/a&gt;&lt;figcaption&gt;A handover designed as a system. An illustration of the principles above, not of any real railway's procedure.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;None of this is exotic. It's what aviation, nuclear and the better software teams already do on their best days. The lesson of Urda isn't "fear capable machines". It's "never trust a fragile handover", whoever or whatever sits on either side of it.&lt;/p&gt;
&lt;p&gt;We'll know much more when the investigators report. Until then, the right posture is patience, and respect for the people who lost their lives.&lt;/p&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Euronews, &lt;a href="https://www.euronews.com/2026/10/28/inexplicable-order-by-control-centre-investigated-after-spain-train-crash"&gt;'Inexplicable' order by control centre investigated&lt;/a&gt;, 28 Oct 2026&lt;/li&gt;
&lt;li&gt;Reuters, &lt;a href="https://www.reuters.com/graphics/SPAIN-ACCIDENT/dwvkmmgbrvm/"&gt;How a high-speed train crash unfolded in central Spain&lt;/a&gt;, 28 Oct 2026&lt;/li&gt;
&lt;li&gt;AITAT first note, as reported by elDiario.es: &lt;a href="https://www.eldiario.es/castilla-la-mancha/primer-informe-accidente-urda-estima-colision-ave-iryo-produjo-160-200-km-h_1_13625882.html"&gt;El primer informe sobre el accidente de Urda estima que la colisión… se produjo a "entre 160 y 200 km/h"&lt;/a&gt; (Spanish), 29 Oct 2026&lt;/li&gt;
&lt;li&gt;ABC, &lt;a href="https://www.abc.es/espana/primer-informe-urda-apunta-cadena-averias-instrucciones-20261029215855-nt.html"&gt;El primer informe de Urda apunta a una «cadena de averías e instrucciones»&lt;/a&gt; (Spanish), 29 Oct 2026&lt;/li&gt;
&lt;li&gt;Cadena SER, &lt;a href="https://cadenaser.com/nacional/2026/10/29/la-aitat-recupera-las-cajas-negras-de-los-trenes-de-urda-y-arranca-la-investigacion-del-accidente-cadena-ser/"&gt;La AITAT recupera las cajas negras de los trenes de Urda&lt;/a&gt; (Spanish), 29 Oct 2026&lt;/li&gt;
&lt;li&gt;Euronews (Spanish), &lt;a href="https://es.euronews.com/2026/10/30/primer-informe-urda-apunta-cadena-fallos"&gt;El primer informe técnico de Urda apunta a una "cadena" de fallos&lt;/a&gt;, 30 Oct 2026&lt;/li&gt;
&lt;li&gt;EFE, &lt;a href="https://efe.com/espana/2026-10-30/accidente-trenes-urda-toledo-victimas/"&gt;Se mantienen los 69 fallecidos en el accidente de Urda&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;Euronews (Spanish), &lt;a href="https://es.euronews.com/2026/10/30/autoridades-descartan-victimas-urda-70-denuncias-desaparecidos"&gt;Las autoridades no descartan más víctimas en Urda&lt;/a&gt;, 30 Oct 2026&lt;/li&gt;
&lt;li&gt;CLM Press, &lt;a href="https://clmpress.com/n/2026/10/page-afirma-que-24-de-los-fallecidos-viajaban-en-el-ave-y-44-en-el-iryo/"&gt;Page afirma que 24 de los fallecidos viajaban en el AVE y 44 en el Iryo&lt;/a&gt; (Spanish), Oct 2026&lt;/li&gt;
&lt;li&gt;El País, &lt;a href="https://elpais.com/espana/2026-10-30/las-llamadas-entre-atocha-y-los-maquinistas-explicadas-paso-a-paso.html"&gt;Las llamadas entre Atocha y los maquinistas… explicadas frase a frase&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;El País, &lt;a href="https://elpais.com/espana/2026-10-30/el-operador-que-autorizo-al-ave-a-retomar-la-marcha-se-acoge-ante-la-guardia-civil-a-su-derecho-a-no-declarar.html"&gt;El operador que autorizó al AVE a retomar la marcha se acoge… a su derecho a no declarar&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;El Confidencial, &lt;a href="https://www.elconfidencial.com/espana/2026-10-30/el-operario-de-la-sala-de-control-senalado-por-puente-y-unico-investigado-por-ahora-rechaza-declarar-ante-la-uco_4456193/"&gt;El operario de la Sala de Control… único investigado por ahora&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;RTVE, &lt;a href="https://www.rtve.es/noticias/20261030/accidente-tren-toledo-oscar-puente-ruede-prensa-declaraciones/17289862.shtml"&gt;Puente descarta dimitir e insiste en una cadena de errores en el Centro de Control&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;RTVE, &lt;a href="https://www.rtve.es/noticias/20261030/ciaf-investigacion-accidente-trenes-urda-causas/17289829.shtml"&gt;La Comisión de Accidentes Ferroviarios advirtió en 2025 de "carencias sistémicas"…&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;laSexta, &lt;a href="https://www.lasexta.com/noticias/nacional/puente-asegura-que-ave-vio-semaforo-verde-antes-chocar-pantalla-como-tren-acercando-otro-esta-parado_202610306ae4921a6973466c29e341b0.html"&gt;Puente asegura que el AVE vio un semáforo "verde" antes de chocar&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;El Español, &lt;a href="https://www.elespanol.com/invertia/observatorios/movilidad/20261030/controladores-adif-culpan-puente-presionan-no-retrasos-trenes-pueden-parados/1003744440265_0.html"&gt;Los controladores de Adif culpan a Puente&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;elplural.com, &lt;a href="https://www.elplural.com/politica/espana/luto-traslada-campana-vox-mantiene-agenda-politica-mientras-resto-partidos-guardan-respeto_802676102"&gt;Vox mantiene su agenda política mientras el resto de partidos guardan respeto&lt;/a&gt; (Spanish), Oct 2026&lt;/li&gt;
&lt;li&gt;Servimedia, &lt;a href="https://www.servimedia.es/noticias/feijoo-retomara-campana-lunes-reunira-barones-genova-una-vez-acabado-luto-urda/1413502474"&gt;Feijóo retomará la campaña el lunes&lt;/a&gt; (Spanish), 30 Oct 2026&lt;/li&gt;
&lt;li&gt;El País English, &lt;a href="https://english.elpais.com/spain/2026-10-28/what-is-the-lzb-signaling-system-one-of-the-key-factors-in-the-fatal-train-accident-in-spain.html"&gt;What is the LZB signaling system&lt;/a&gt;, 28 Oct 2026&lt;/li&gt;
&lt;li&gt;La Vanguardia, &lt;a href="https://www.lavanguardia.com/politica/20261028/11670324/puente-ve-inexplicable-operador-adif-autorizara-marchar-tren-renfe-impacto-iryo.html"&gt;Puente ve "inexplicable"…&lt;/a&gt; (Spanish), 28 Oct 2026&lt;/li&gt;
&lt;li&gt;Euronews (Spanish), &lt;a href="https://es.euronews.com/2026/10/28/oscar-puente-considera-inexplicable-que-el-centro-de-control-autorizara-al-ave-a-reanudar-"&gt;Óscar Puente considera "inexplicable"…&lt;/a&gt;, 28 Oct 2026&lt;/li&gt;
&lt;li&gt;EFE, &lt;a href="https://efe.com/portada-espana/2026-10-28/tren-iryo-ave-accidentados-pasajeros/"&gt;El tren Iryo accidentado viajaba con 147 pasajeros y el AVE con 397&lt;/a&gt; (Spanish), 28 Oct 2026&lt;/li&gt;
&lt;li&gt;El Español, &lt;a href="https://www.elespanol.com/espana/20261028/oscar-puente-senala-adif-decidir-tren-renfe-reanudara-marcha-circunstancias-inexplicables/1003744437994_0.html"&gt;Puente… reconoce que no había ningún sistema de seguridad que impidiera un error humano&lt;/a&gt; (Spanish), 28 Oct 2026&lt;/li&gt;
&lt;li&gt;Cadena SER, &lt;a href="https://cadenaser.com/nacional/2026/10/28/la-ser-accede-a-los-audios-de-las-conversaciones-entre-el-centro-de-control-de-adif-y-los-maquinistas-de-los-trenes-accidentados-en-urda-reanude-con-marcha-normal-cadena-ser/"&gt;Audios: "Reanude con marcha normal"&lt;/a&gt; (Spanish), 28 Oct 2026&lt;/li&gt;
&lt;li&gt;Cadena SER, &lt;a href="https://cadenaser.com/nacional/2026/10/28/la-maquinista-de-iryo-llamo-al-centro-de-control-de-adif-porque-no-podia-arrancar-el-tren-pues-nada-cuando-pueda-y-si-tiene-problemas-nos-llama-cadena-ser/"&gt;La maquinista de Iryo llamó al centro de control…&lt;/a&gt; (Spanish), 28 Oct 2026&lt;/li&gt;
&lt;li&gt;El País, &lt;a href="https://elpais.com/espana/2026-10-29/los-cabos-por-atar-del-siniestro-de-urda-en-las-investigaciones-judicial-y-tecnica.html"&gt;Los cabos por atar del siniestro de Urda&lt;/a&gt; (Spanish), 29 Oct 2026&lt;/li&gt;
&lt;li&gt;Consejo General del Poder Judicial, &lt;a href="https://www.poderjudicial.es/cgpj/es/Poder-Judicial/Noticias-Judiciales/La-jueza-instructora-del-accidente-ferroviario-de-Urda--Toledo--acuerda-la-prohibicion-de-acceso-de-terceras-personas-a-la-zona-del-siniestro"&gt;La jueza instructora… acuerda la prohibición de acceso&lt;/a&gt; (Spanish), 28 Oct 2026&lt;/li&gt;
&lt;li&gt;RTVE, &lt;a href="https://www.rtve.es/noticias/20261029/accidente-tren-toledo-sistema-seguridad-lzb-como-funciona-ocurre-si-falla/17287266.shtml"&gt;Qué es el sistema LZB y cómo funciona&lt;/a&gt; (Spanish), 29 Oct 2026&lt;/li&gt;
&lt;li&gt;Europa Press, &lt;a href="https://www.europapress.es/economia/transportes-00343/noticia-reglamento-adif-prohibia-centro-control-autorizar-ave-reanudar-marcha-20261028200123.html"&gt;El reglamento de Adif prohibía…&lt;/a&gt; (Spanish), 28 Oct 2026&lt;/li&gt;
&lt;li&gt;La Moncloa, &lt;a href="https://www.lamoncloa.gob.es/presidente/actividades/paginas/2026/281026-sanchez-visita-accidente-tren.aspx"&gt;Three days of official mourning&lt;/a&gt; (Spanish), 28 Oct 2026&lt;/li&gt;
&lt;li&gt;James Reason, &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC1117770/"&gt;Human error: models and management&lt;/a&gt;, BMJ, 2000&lt;/li&gt;
&lt;li&gt;Richard Cook, &lt;a href="https://how.complexsystems.fail/"&gt;How Complex Systems Fail&lt;/a&gt;, 1998&lt;/li&gt;
&lt;li&gt;Lisanne Bainbridge, &lt;a href="https://ckrybus.com/static/papers/Bainbridge_1983_Automatica.pdf"&gt;Ironies of Automation&lt;/a&gt;, Automatica, 1983&lt;/li&gt;
&lt;li&gt;Nancy Leveson, &lt;a href="https://direct.mit.edu/books/oa-monograph/2908/Engineering-a-Safer-WorldSystems-Thinking-Applied"&gt;Engineering a Safer World&lt;/a&gt;, MIT Press, 2012&lt;/li&gt;
&lt;li&gt;Raja Parasuraman and Victor Riley, &lt;a href="https://doi.org/10.1518/001872097778543886"&gt;Humans and Automation: Use, Misuse, Disuse, Abuse&lt;/a&gt;, Human Factors, 1997&lt;/li&gt;
&lt;li&gt;Nadine Sarter and David Woods, &lt;a href="https://doi.org/10.1518/001872097778667997"&gt;Team play with a powerful and independent agent&lt;/a&gt;, Human Factors, 1997&lt;/li&gt;
&lt;li&gt;US House Committee on Transportation and Infrastructure, &lt;a href="https://democrats-transportation.house.gov/imo/media/doc/2020.09.15%20FINAL%20737%20MAX%20Report%20for%20Public%20Release.pdf"&gt;Final Committee Report: The Boeing 737 MAX&lt;/a&gt;, September 2020&lt;/li&gt;
&lt;li&gt;BEA, &lt;a href="https://bea.aero/fileadmin/documents/docspa/2009/f-cp090601.en/pdf/f-cp090601.en.pdf"&gt;Final report on Air France flight AF447&lt;/a&gt;, July 2012&lt;/li&gt;
&lt;li&gt;NTSB, &lt;a href="https://www.ntsb.gov/investigations/accidentreports/reports/har1903.pdf"&gt;Collision Between Vehicle Controlled by Developmental Automated Driving System and Pedestrian, Tempe, Arizona (HAR-19/03)&lt;/a&gt;, 2019&lt;/li&gt;
&lt;li&gt;World Health Organization, &lt;a href="https://www.who.int/publications/i/item/9789240086517"&gt;Global status report on road safety 2023&lt;/a&gt;, 2023&lt;/li&gt;
&lt;li&gt;Kristofer Kusano et al. (Waymo), &lt;a href="https://doi.org/10.1080/15389588.2025.2499887"&gt;Comparison of Waymo rider-only crash rates by crash type to human benchmarks at 56.7 million miles&lt;/a&gt;, Traffic Injury Prevention, 2025&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  <entry>
    <title>Does Your Company Really Need Kubernetes? Or Are You Just Cosplaying as Netflix?</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/c261f5.html"/>
    <id>https://nehem.dev/c261f5.html</id>
    <published>2026-10-29T00:00:00+10:00</published>
    <updated>2026-10-29T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Kubernetes is brilliant technology, but most small teams don't need it. What premature infrastructure really costs, what to run instead, and when to switch.</summary>
    <category term="Kubernetes"/><category term="Infrastructure"/><category term="Architecture"/><category term="Startups"/>
    <content type="html">&lt;p&gt;Everyone wants Kubernetes.&lt;/p&gt;
&lt;p&gt;The DevOps engineer wants it. The CTO read about it. The founder saw a company using it and thought, "We should probably do that too."&lt;/p&gt;
&lt;p&gt;Suddenly a company with three developers, one API and a PostgreSQL database is planning a Kubernetes migration.&lt;/p&gt;
&lt;p&gt;For what? Millions of requests? Hundreds of microservices? Multiple regions?&lt;/p&gt;
&lt;p&gt;No. Because Kubernetes is what serious engineering teams use.&lt;/p&gt;
&lt;p&gt;Right?&lt;/p&gt;
&lt;p&gt;Wrong.&lt;/p&gt;
&lt;p&gt;This is one of the most expensive mistakes in modern software engineering: &lt;strong&gt;confusing infrastructure complexity with engineering maturity.&lt;/strong&gt;&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/c261f5/hero.svg" alt="On the left, a single small server serves a short line of users. On the right, a large tangle of pods, boxes and arrows. One coral journey line runs through each side, and both arrive at the same tick." width="960" height="560" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Same login page, same dashboard, same tick. One side just has a lot more to keep alive.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Great technology, wrong problem&lt;/h2&gt;
&lt;p&gt;Kubernetes is an incredible piece of technology. It orchestrates containers. It manages workloads across clusters. It handles service discovery, scaling and self-healing. It solves real problems. Big ones.&lt;/p&gt;
&lt;p&gt;But here's the part the shiny architecture diagrams leave out: &lt;strong&gt;Kubernetes doesn't eliminate complexity. It moves it somewhere else.&lt;/strong&gt; And sometimes it creates more of it.&lt;/p&gt;
&lt;h2&gt;The migration nobody can justify&lt;/h2&gt;
&lt;p&gt;Say you're building a SaaS product. You have an API, a background worker, a PostgreSQL database and maybe Redis for caching. You serve a few thousand customers. Deployments are straightforward. The cloud bill is manageable. When something breaks, the team knows where to look.&lt;/p&gt;
&lt;p&gt;Life is good.&lt;/p&gt;
&lt;p&gt;Then someone says, "We should move to Kubernetes."&lt;/p&gt;
&lt;p&gt;Why?&lt;/p&gt;
&lt;p&gt;"Scalability."&lt;/p&gt;
&lt;p&gt;What does that mean?&lt;/p&gt;
&lt;p&gt;"We need to be ready for growth."&lt;/p&gt;
&lt;p&gt;How much growth?&lt;/p&gt;
&lt;p&gt;Silence.&lt;/p&gt;
&lt;p&gt;What exactly is the current system failing to do?&lt;/p&gt;
&lt;p&gt;More silence.&lt;/p&gt;
&lt;p&gt;The migration begins anyway. Now the team needs to understand pods, deployments, services, ingress controllers, ConfigMaps, Secrets, persistent volumes, resource requests and limits, liveness probes, readiness probes and cluster networking. That's before anyone debugs why one service can't reach another at 2 am.&lt;/p&gt;
&lt;p&gt;Congratulations. You just turned a simple deployment into a distributed infrastructure problem.&lt;/p&gt;
&lt;p&gt;And your customers? They still see the same login page. The same dashboard. The same API. Nothing changed for them. Your team just has more to maintain, more to monitor, more that can fail and more that needs specialist knowledge. All for a scaling problem you haven't actually had.&lt;/p&gt;
&lt;p&gt;That's what optimising for imaginary problems instead of real ones looks like. I've made the same argument about &lt;a href="/8f88cf.html"&gt;microservices&lt;/a&gt;, and it applies here for the same reasons.&lt;/p&gt;
&lt;h2&gt;Kubernetes isn't the villain&lt;/h2&gt;
&lt;p&gt;Let's be fair. The villain is premature complexity. There's a difference.&lt;/p&gt;
&lt;p&gt;Kubernetes can be an excellent choice when:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You run dozens of services across multiple teams.&lt;/li&gt;
&lt;li&gt;Your deployment requirements are genuinely complex.&lt;/li&gt;
&lt;li&gt;Your workloads really benefit from orchestration.&lt;/li&gt;
&lt;li&gt;An infrastructure team needs consistent deployment patterns across many applications.&lt;/li&gt;
&lt;li&gt;Your organisation has the operational expertise to run it properly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A five-person startup shipping an MVP is none of those. It's solving the wrong problem.&lt;/p&gt;
&lt;p&gt;Here's the uncomfortable truth: your company probably doesn't need more infrastructure. It needs more customers. Product-market fit. Faster feedback loops. Better onboarding. Fewer bugs. A product people will pay for.&lt;/p&gt;
&lt;p&gt;Nobody has ever bought your SaaS because you used Kubernetes. Nobody woke up this morning thinking, "I'd love to use this project management tool, but I'm not convinced their containers are orchestrated properly."&lt;/p&gt;
&lt;p&gt;Customers care whether the product works. Whether it's fast enough. Whether it solves their problem. Whether they can trust it.&lt;/p&gt;
&lt;p&gt;That's it. If a simpler platform delivers those outcomes, why add another layer to operate?&lt;/p&gt;
&lt;h2&gt;You don't install Kubernetes. You operate it.&lt;/h2&gt;
&lt;p&gt;This is the hidden cost. Someone has to understand how it works, configure it securely, monitor it, upgrade it and investigate its incidents. Someone has to manage networking, resource allocation, failed deployments and the growing pile of YAML nobody wants to touch.&lt;/p&gt;
&lt;p&gt;If you don't have those people, your application developers become your infrastructure team. Instead of building features, they debug the cluster. Instead of talking to customers, they chase failed deployments. Instead of improving the product, they learn why a workload keeps restarting.&lt;/p&gt;
&lt;p&gt;Sometimes that's a worthwhile investment. Often it's an expensive distraction. The difference is whether the infrastructure solves a problem that matters to the business.&lt;/p&gt;
&lt;p&gt;Every technology choice has an opportunity cost. Time spent maintaining infrastructure is time not spent on anything else. That doesn't make infrastructure work wasted. It means it has to earn its place.&lt;/p&gt;
&lt;h2&gt;A single server. In 2026.&lt;/h2&gt;
&lt;p&gt;Kubernetes isn't the only way to run containers.&lt;/p&gt;
&lt;p&gt;Sometimes a managed container service is enough. Sometimes a platform-as-a-service is enough. Sometimes a virtual machine with a well-understood deployment process is enough.&lt;/p&gt;
&lt;p&gt;Sometimes a single server is all you need.&lt;/p&gt;
&lt;p&gt;Yes. A single server. In 2026. No service mesh. No twelve microservices. No elaborate GitOps pipeline.&lt;/p&gt;
&lt;p&gt;Just an application that works, a database that's backed up, and a deployment process that doesn't require a ritual sacrifice. Imagine that. (The database is probably &lt;a href="/ffbf73.html"&gt;Postgres, and Postgres is probably enough&lt;/a&gt;.)&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/c261f5/ladder.svg" alt="A pencil-drawn staircase with three steps: a single server, then managed containers or a platform-as-a-service, then orchestration. A coral arrow climbs one step at a time." width="960" height="360" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Start on the bottom step. Climb when reality demands it.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Complexity is easy to add and hard to remove&lt;/h2&gt;
&lt;p&gt;You can always add complexity later. Migrate when the constraints are real. Adopt orchestration when managing deployments by hand actually hurts. Invest in sophisticated infrastructure when the business benefits from it.&lt;/p&gt;
&lt;p&gt;Removing complexity after you've built the organisation around it is much harder.&lt;/p&gt;
&lt;p&gt;Infrastructure decisions don't live in isolation. They shape hiring, team structure, developer workflows, incident response, documentation, security practices and what it costs to run the product. What starts as a technical decision becomes an organisational commitment.&lt;/p&gt;
&lt;h2&gt;Questions to ask first&lt;/h2&gt;
&lt;p&gt;Before you introduce Kubernetes, answer these honestly:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;What specific problem are we solving?&lt;/li&gt;
&lt;li&gt;Can our current infrastructure handle the workload?&lt;/li&gt;
&lt;li&gt;Are deployments genuinely becoming hard to manage?&lt;/li&gt;
&lt;li&gt;Do we need orchestration, or just better deployment automation?&lt;/li&gt;
&lt;li&gt;Do we have the expertise to run Kubernetes reliably?&lt;/li&gt;
&lt;li&gt;Most importantly: what evidence would convince us we need it?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you can't answer those, you're not making an infrastructure decision. You're following a trend. And trends are a terrible reason to redesign production.&lt;/p&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;The goal isn't the most sophisticated infrastructure possible. It's &lt;strong&gt;the simplest infrastructure that reliably meets your requirements&lt;/strong&gt;, evolved as those requirements change.&lt;/p&gt;
&lt;p&gt;Not before. Not because another startup uses it. Not because someone on YouTube built an impressive homelab. And definitely not because Kubernetes looks good on your CV.&lt;/p&gt;
&lt;p&gt;Use it when it solves your problems. Avoid it when it creates more than it solves.&lt;/p&gt;
&lt;p&gt;Engineering maturity isn't about how many tools you can operate. It's about knowing which ones you don't need. Your architecture doesn't need to impress other engineers. It needs to serve your business. Sometimes the most senior decision you can make is to &lt;a href="/c150db.html"&gt;leave the shiny thing out&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Build the product. Get customers. Solve real problems. Let your infrastructure grow when reality demands it.&lt;/p&gt;
&lt;p&gt;Not when your ego does.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>What a Decade of Python Taught Me About Boring Technology</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/c150db.html"/>
    <id>https://nehem.dev/c150db.html</id>
    <published>2026-10-29T00:00:00+10:00</published>
    <updated>2026-10-29T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Lessons from a decade of Python, Django and AWS: why boring technology wins, why journey tests outlive your stack, and the habits that keep systems shippable.</summary>
    <category term="Python"/><category term="Engineering"/><category term="Testing"/><category term="Architecture"/>
    <content type="html">&lt;p&gt;There's a version of a software career where you chase every new framework, rewrite your stack every eighteen months and spend more time on migrations than on the product. Plenty of us have done a stretch of it. The systems that last, the ones that ship features for years without drama, are almost always built on the dullest tools available.&lt;/p&gt;
&lt;p&gt;The position: &lt;strong&gt;boring technology is a competitive advantage, not a compromise.&lt;/strong&gt; Python, Django, Postgres, a load balancer and a few well-understood AWS services will take most products further than any shiny stack. The skill isn't knowing the newest tool. It's knowing when not to use it.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/c150db/hero.svg" alt="A stack of five layers. One continuous test line runs from a user at the top, straight down through every layer, to a tick at the bottom. The middle layer has been pulled out to the side and a new one sits in its place." width="960" height="600" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Layers come and go. The journey test runs straight through all of them and still ends in a tick.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Boring means understood, not old&lt;/h2&gt;
&lt;p&gt;Dan McKinley's essay &lt;a href="https://mcfunley.com/choose-boring-technology"&gt;Choose Boring Technology&lt;/a&gt; put it better than anyone: a boring tool is one whose &lt;strong&gt;failure modes are known.&lt;/strong&gt; You can search the error message and find the answer. You know how it behaves under load, how it breaks, and how to fix it at 2 am.&lt;/p&gt;
&lt;p&gt;That's the real asset. Not features. Not benchmarks. Predictability.&lt;/p&gt;
&lt;p&gt;Django is boring in exactly this way. The ORM has its sharp edges, and they're documented. The migration system has its quirks, and Stack Overflow has an answer for each one. Postgres is boring. Gunicorn is boring. SQS is boring. Every one of them has had its corner cases found by many people before you.&lt;/p&gt;
&lt;p&gt;A new tool has failure modes too. You just don't know them yet, and you'll discover them in production.&lt;/p&gt;
&lt;h2&gt;Spend your innovation where customers notice&lt;/h2&gt;
&lt;p&gt;McKinley's other idea is the &lt;strong&gt;innovation token&lt;/strong&gt;: every team gets a small number, and each new, unproven technology spends one. Spend them on what makes your product different. Not on the plumbing.&lt;/p&gt;
&lt;p&gt;If your product is a pricing engine, innovate on pricing. Run it on Django and Postgres. If your product is a new kind of search, maybe the search engine is your token, and everything else should be as dull as possible.&lt;/p&gt;
&lt;p&gt;The common failure is the reverse: a completely ordinary CRUD product running on a novel database, a new frontend framework, an event-sourcing library and a service mesh. Four tokens spent, none of them on anything a customer will ever see.&lt;/p&gt;
&lt;h2&gt;The habits that held up&lt;/h2&gt;
&lt;p&gt;Some lessons I'd give my younger self, in no particular order:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Read the standard library before installing a package.&lt;/strong&gt; &lt;code&gt;dataclasses&lt;/code&gt;, &lt;code&gt;pathlib&lt;/code&gt;, &lt;code&gt;itertools&lt;/code&gt;, &lt;code&gt;functools&lt;/code&gt;, &lt;code&gt;zoneinfo&lt;/code&gt;, &lt;code&gt;concurrent.futures&lt;/code&gt;, &lt;code&gt;sqlite3&lt;/code&gt;. Python ships a lot. Every dependency is code you didn't write and will have to upgrade.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prefer a function to a class, and a module to a framework.&lt;/strong&gt; Most abstractions people build in Python are a function with extra steps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Plain SQL is a skill, not a smell.&lt;/strong&gt; The ORM is great for 90% of queries. For the other 10%, reading &lt;code&gt;EXPLAIN ANALYZE&lt;/code&gt; beats any amount of queryset cleverness.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Delete code aggressively.&lt;/strong&gt; Dead feature flags, unused endpoints, compatibility shims for clients that no longer exist. Every line you keep is a line someone has to understand.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logs and metrics before features.&lt;/strong&gt; You can't fix what you can't see. A structured log line with a request ID has saved more incidents than any architecture change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Upgrade little and often.&lt;/strong&gt; Staying one minor version behind on Python and Django is cheap. Falling three major versions behind is a project with its own budget. I say that as someone who defended Python 2.7 long after the argument was lost.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write the boring test.&lt;/strong&gt; Not a clever property-based suite for everything. One test per business rule, named after the rule, that fails clearly.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Invest in tests that don't know how the code is written&lt;/h2&gt;
&lt;p&gt;If I could move one budget line on most teams, it would be this: spend far more on black-box tests that walk through real user journeys. Sign up. Log in. Place an order. Cancel it. Get the refund email. Drive them through the public surface, the HTTP API or the UI, and check what a user would check. Nothing else.&lt;/p&gt;
&lt;p&gt;These tests don't import your models. They don't patch your functions. They don't know whether there's a service layer, a serializer or a stored procedure behind the endpoint. That's the point.&lt;/p&gt;
&lt;p&gt;Everything in your stack is temporary. The framework gets a major version. The database moves. The queue gets swapped for something managed. The cloud service you picked gets deprecated. Python itself moves on, whether you're ready or not. And one day somebody will want to rewrite the whole backend.&lt;/p&gt;
&lt;p&gt;When that day comes, everyone asks the same question: did we break the product? Unit tests tied to internals can't answer it. They die with the refactor, because they were testing the code you just deleted. A journey suite survives it. It runs against the new system exactly as it ran against the old one, and when it goes green you can say, with evidence, that the product still works.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/c150db/swap-a-layer.svg" alt="A user journey line runs left to right through three boxes and ends in a tick. The middle box has been lifted out and replaced with a new one; the line passes through the new box unchanged." width="960" height="280" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Swap any box. The journey doesn't change, so the test doesn't either.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;That's why I call it an asset. It grows. Every journey you add is one more thing you can never silently break again, through any number of rewrites. Most code loses value as it ages. This suite gains it.&lt;/p&gt;
&lt;p&gt;How I'd keep it boring:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Few and honest.&lt;/strong&gt; Tens of journeys, not thousands. Cover what earns money, and what would have customers emailing you before your coffee.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Real dependencies.&lt;/strong&gt; Run them in CI against a real Postgres, a real queue and real services in containers. Fake only what you don't own, like the payment provider, and fake it at the network edge.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Behaviour, not implementation.&lt;/strong&gt; Assert on status codes, response bodies, emails sent, what the user can see. Never on which function got called.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Slow is fine.&lt;/strong&gt; A few minutes per run is the price of honesty. Run them on every merge, not on every keystroke.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cheap to keep.&lt;/strong&gt; They don't know how the code is written, so refactors don't touch them. If a refactor breaks one, either behaviour changed or the test was peeking inside.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is boring technology applied to testing. The journey suite is the one part of the system that doesn't care what's fashionable underneath. Rip out Django REST Framework for plain Django views (I'd encourage it) and the suite won't notice. That's exactly the predictability you want while everything else moves.&lt;/p&gt;
&lt;p&gt;Unit tests still earn their place for tricky pure logic: date maths, pricing rules, parsers. Keep those. Just don't mistake a pile of mocks for proof that the product works.&lt;/p&gt;
&lt;h2&gt;Complexity is a loan&lt;/h2&gt;
&lt;p&gt;Every piece of complexity you add is borrowed against future time. Microservices, a second database, a message bus, a custom deploy tool. Each one might be justified. Each one charges interest: on-call load, onboarding time, upgrade work, things that can partially fail.&lt;/p&gt;
&lt;p&gt;The question I ask now before adding anything is simple: &lt;strong&gt;what's the cheapest thing that could possibly work, and what evidence would make me outgrow it?&lt;/strong&gt; Write the evidence down. "When the jobs table bloats past what autovacuum can handle." "When two teams are blocked on the same deploy." Then build the cheap thing and watch for the evidence.&lt;/p&gt;
&lt;p&gt;Most of the time, it never shows up.&lt;/p&gt;
&lt;h2&gt;Where boring goes wrong&lt;/h2&gt;
&lt;p&gt;Boring isn't the same as stagnant. A few traps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Boring isn't unmaintained.&lt;/strong&gt; Running an end-of-life Python version isn't conservative, it's a security liability. Boring tools still need upgrades.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Boring isn't "what we used last time" forever.&lt;/strong&gt; If a new tool is mature, well understood and clearly better for a real problem, like &lt;code&gt;uv&lt;/code&gt; for Python packaging or &lt;code&gt;ruff&lt;/code&gt; for linting, adopt it. The test is maturity and fit, not age.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Boring isn't refusing to learn.&lt;/strong&gt; Learn the new things. Build side projects with them. Just don't make your production system the place where you learn them.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What actually made the difference&lt;/h2&gt;
&lt;p&gt;Looking back, the projects that went well had little to do with the stack. They had:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A clear understanding of what the business actually needed this quarter.&lt;/li&gt;
&lt;li&gt;A small number of well-understood moving parts.&lt;/li&gt;
&lt;li&gt;Fast, boring deploys, many times a week.&lt;/li&gt;
&lt;li&gt;Engineers who could explain the whole system on a whiteboard.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The projects that struggled usually had an impressive architecture diagram and nobody who could explain all of it.&lt;/p&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;Years of Python have taught me that &lt;strong&gt;the most valuable engineering skill is restraint.&lt;/strong&gt; Use the tool everyone understands. Spend novelty only where it creates value customers can feel. Keep the system small enough to fit in one head, and keep a suite of journey tests that will outlive it. It doesn't make for exciting conference talks, but it makes for software that ships, keeps shipping and lets you sleep.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Is Your Ego Running Production?</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/7b5ed3.html"/>
    <id>https://nehem.dev/7b5ed3.html</id>
    <published>2026-10-15T00:00:00+10:00</published>
    <updated>2026-10-15T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Postmortems never list ego as a cause, but it's behind big-bang deploys, blame, rewrites and heroics. Public incidents, what experts say, and how to take ego out.</summary>
    <category term="Engineering Culture"/><category term="Incidents"/><category term="Architecture"/><category term="Postmortems"/>
    <content type="html">&lt;p&gt;Nobody writes "ego" in the root cause field.&lt;/p&gt;
&lt;p&gt;The postmortem says a server was missed. A command had a typo. A backup job had been failing quietly for months. Read enough of them, though, and the same shape keeps turning up behind the technical detail: someone was sure, and nothing in the system asked them to prove it.&lt;/p&gt;
&lt;p&gt;That's what I mean by ego in production. Not arrogance as a personality trait. &lt;strong&gt;Certainty that outruns the evidence&lt;/strong&gt;, and a system built to trust it.&lt;/p&gt;
&lt;p&gt;It turns up in all sorts of places:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Resume-driven architecture.&lt;/li&gt;
&lt;li&gt;Rewrites, because the old code "is a mess".&lt;/li&gt;
&lt;li&gt;Big-bang releases that skip review because "I know this code".&lt;/li&gt;
&lt;li&gt;Refusing to roll back because rolling back means admitting the change was wrong.&lt;/li&gt;
&lt;li&gt;Hero on-call culture, and the blame that comes with it when the hero is the one who slipped.&lt;/li&gt;
&lt;/ul&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/7b5ed3/hero.svg" alt="On the left, one huge block drops onto a production base in a single move, and its return path is crossed out. On the right, the same change is split into six small blocks, each going down on its own with a small curved arrow back up." width="960" height="540" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Same change, two shapes. Only one of them comes with a way back.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;The postmortems don't say ego. They say "nobody checked".&lt;/h2&gt;
&lt;p&gt;On 1 August 2012, Knight Capital deployed new code for the NYSE's Retail Liquidity Program. According to the &lt;a href="https://www.sec.gov/litigation/admin/2013/34-70694.pdf"&gt;SEC's order&lt;/a&gt;, a technician didn't copy the new code to one of the eight servers. The new code reused a flag that used to switch on "Power Peg", logic Knight had stopped using in 2003 but never removed. On the eighth server, that flag woke the dead code up. In about 45 minutes the router sent millions of orders into the market, and Knight lost more than $460 million.&lt;/p&gt;
&lt;p&gt;The SEC's findings are dull, which is exactly the point. There was no second technician reviewing the deployment and no written procedure requiring one. In the SEC's words, "a written procedure requiring a simple double-check of the deployment of the RLP code could have identified that a server had been missed." It gets worse. During the incident, Knight uninstalled the new code from the seven healthy servers, and that &lt;em&gt;spread&lt;/em&gt; the problem. Their rollback had never been designed or rehearsed. It was improvised under pressure.&lt;/p&gt;
&lt;p&gt;On 31 January 2017, a GitLab engineer trying to rebuild database replication wiped what they thought was the secondary's data directory. It was the primary. Roughly 300 GB was gone before they stopped it. Then the backups turned out not to exist: &lt;code&gt;pg_dump&lt;/code&gt; was running a 9.2 binary against a 9.6 database, failing every time, and the failure emails were being rejected. GitLab's &lt;a href="https://about.gitlab.com/blog/2017/02/10/postmortem-of-database-outage-of-january-31/"&gt;postmortem&lt;/a&gt; names the deepest cause plainly: nobody owned testing the backups. Their conclusion is the best sentence in the whole document: "An ideal environment is one in which you can make mistakes but easily and quickly recover from them with minimal to no impact."&lt;/p&gt;
&lt;p&gt;On 28 February 2017, an S3 engineer following an established playbook mistyped one input to a command and &lt;a href="https://aws.amazon.com/message/41926/"&gt;removed far more servers than intended&lt;/a&gt; in US-EAST-1. S3 was down in that region for hours. Amazon's write-up doesn't go looking for someone to blame. It fixes the tool, which "allowed too much capacity to be removed too quickly", so it now removes capacity slowly and refuses to go below a minimum.&lt;/p&gt;
&lt;p&gt;Notice what none of these say. None of them says "the engineer was arrogant". The ego wasn't in the person at the keyboard. It was baked into a system that assumed a careful person doesn't need a check, a backup doesn't need a restore test, and a rollback doesn't need a rehearsal.&lt;/p&gt;
&lt;h2&gt;Blame is ego wearing a manager's hat&lt;/h2&gt;
&lt;p&gt;When things go wrong, the ego move is to find the person. John Allspaw, then at Etsy, called this out in &lt;a href="https://www.etsy.com/codeascraft/blameless-postmortems"&gt;Blameless PostMortems and a Just Culture&lt;/a&gt;, borrowing what Sidney Dekker calls the "Bad Apple Theory": get rid of the bad apples and you get rid of human error. It feels like accountability. It produces the opposite.&lt;/p&gt;
&lt;p&gt;Allspaw's argument is that engineers have to be able to explain what they did, what they saw and what they expected, "without fear of punishment or retribution". Punish them and they go quiet. You get what he calls "Cover-Your-Ass" engineering, management stops learning how work really gets done, and the same accident comes back with a different name on it.&lt;/p&gt;
&lt;figure class="fig"&gt;&lt;img src="https://nehem.dev/media/7b5ed3/blame-loop.svg" alt="A closed loop of six circles joined by arrows: an incident, blame, punishment, silence (an amber circle with a closed mouth), less learning, and round again. One coral line leaves the loop and passes through three small notes, the fixes to the system, before ending at a tick." width="960" height="420" loading="lazy" decoding="async"&gt;&lt;figcaption&gt;Blame keeps the loop closed. A blameless review is the way out, through fixes to the system rather than the person.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Richard Cook's &lt;a href="https://how.complexsystems.fail/"&gt;How Complex Systems Fail&lt;/a&gt; goes further. Two of his points should be printed on the wall of every incident review: "Post-accident attribution to a 'root cause' is fundamentally wrong", and "Hindsight biases post-accident assessments of human performance". Failures need several things to go wrong at once. After the fact, the one human step looks obvious. It wasn't obvious at the time.&lt;/p&gt;
&lt;p&gt;Google's SRE book puts the practical version in one line in its &lt;a href="https://sre.google/sre-book/postmortem-culture/"&gt;chapter on postmortem culture&lt;/a&gt;: "You can't 'fix' people, but you can fix systems and processes."&lt;/p&gt;
&lt;h2&gt;Ego in the architecture&lt;/h2&gt;
&lt;p&gt;Production incidents are the loud version. The quiet version is architecture chosen to make someone look smart.&lt;/p&gt;
&lt;p&gt;Dan McKinley's &lt;a href="https://mcfunley.com/choose-boring-technology"&gt;Choose Boring Technology&lt;/a&gt; gives every company "about three innovation tokens". His most useful exercise is to ask how you'd solve the problem without adding anything new. Asking that, he says, catches the case where the real "problem" is that someone wants to use the technology. Resume-driven development fails that test every time. So does the Kubernetes cluster for a three-person team, and the &lt;a href="/8f88cf.html"&gt;microservices you split out before you had the teams for them&lt;/a&gt;. McKinley's verdict is short: "Technology for its own sake is snake oil."&lt;/p&gt;
&lt;p&gt;Not-invented-here is the same disease aimed at libraries. Writing your own job queue, your own ORM or your own serialization layer because the existing one offends you is ego with a commit history. (Yes, DRF offends me too. The boring answer is still plain Django views, not my own framework.) And the extra database you added because Postgres felt too ordinary? &lt;a href="/ffbf73.html"&gt;Postgres was probably enough&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then there are rewrites. Fred Brooks warned in &lt;em&gt;The Mythical Man-Month&lt;/em&gt; about the &lt;a href="https://en.wikipedia.org/wiki/Second-system_effect"&gt;second-system effect&lt;/a&gt;: confident after the first success, the designer piles every deferred idea into the next one, and that second system is "the most dangerous system a man ever designs". Joel Spolsky called rewriting from scratch "the single worst strategic mistake that any software company can make" in &lt;a href="https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/"&gt;Things You Should Never Do, Part I&lt;/a&gt;. His explanation is uncomfortably personal: "It's harder to read code than to write it." The old code looks like a mess because we didn't write it. Those ugly lines are often bug fixes we don't understand yet.&lt;/p&gt;
&lt;h2&gt;Heroes, rollbacks and the 2 am fix&lt;/h2&gt;
&lt;p&gt;Every team has the engineer who saves the day at 2 am. Celebrate that often enough and you get a team that needs saving at 2 am.&lt;/p&gt;
&lt;p&gt;The ego trap during an incident is fixing forward because rolling back feels like losing. The Google SRE book has a lovely counter-example. At a company all-hands, an engineer described a release that took down a critical service. It only lasted four minutes because he rolled it back immediately. He got two peer bonuses and a round of applause. That's the culture you want: &lt;strong&gt;the rollback is the heroic move&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Rollbacks only work if they're boring, though. Knight's improvised rollback made things worse. A rollback you've never practised is just another risky deploy.&lt;/p&gt;
&lt;p&gt;Size matters too. DORA's research on software delivery, behind the book &lt;em&gt;Accelerate&lt;/em&gt;, has found again and again that &lt;a href="https://dora.dev/guides/dora-metrics/"&gt;speed and stability are not tradeoffs&lt;/a&gt;. Their recommended lever is smaller changes: easier to reason about, easier to review, easier to recover from. A big-bang change bets everything on being right once. A small change only has to be right this time, and it's cheap when it isn't.&lt;/p&gt;
&lt;p&gt;I'll own my bias here. I was a Python 2.7 sympathiser and a late adopter of Python 3. I know exactly how it feels to defend a position past its sell-by date. The fix isn't to never hold strong opinions. It's to know in advance what would change them.&lt;/p&gt;
&lt;h2&gt;How to tell your ego is running production&lt;/h2&gt;
&lt;p&gt;A checklist of smells:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;"I know this code"&lt;/strong&gt; is the reason a change skipped review or tests.&lt;/li&gt;
&lt;li&gt;The release is &lt;strong&gt;one big change&lt;/strong&gt; because splitting it felt like admin.&lt;/li&gt;
&lt;li&gt;There's &lt;strong&gt;no rollback plan&lt;/strong&gt;, or the rollback has never been run.&lt;/li&gt;
&lt;li&gt;Rolling back is treated as &lt;strong&gt;failure&lt;/strong&gt; rather than a normal move.&lt;/li&gt;
&lt;li&gt;The new tool's main argument is that &lt;strong&gt;serious companies use it&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;rewrite&lt;/strong&gt; is pitched as the fix for code nobody has read carefully.&lt;/li&gt;
&lt;li&gt;Incident reviews end with &lt;strong&gt;a name&lt;/strong&gt; rather than a change to the system.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The most senior voice wins&lt;/strong&gt; design arguments that data could settle.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The same few people&lt;/strong&gt; get paged, and they like it that way.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nobody asks for help&lt;/strong&gt; until the incident is an hour old.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;"Works on my machine"&lt;/strong&gt; ends the conversation instead of starting one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Backups exist&lt;/strong&gt;, but nobody has restored one this quarter.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What to do instead&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Evidence over seniority.&lt;/strong&gt; Bring graphs, traces and load tests to design arguments. If the senior person is right, the evidence will say so.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Small, reversible changes.&lt;/strong&gt; Ship in slices behind flags. Make every deploy something you can undo in minutes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Make rollback a first-class move.&lt;/strong&gt; Rehearse it. Automate it. Praise the person who uses it early.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Two people on risky changes.&lt;/strong&gt; A second pair of eyes on production deploys, migrations and destructive commands. That's what the SEC wanted from Knight.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Guard rails in the tools.&lt;/strong&gt; Do what Amazon did after S3: make dangerous commands slow, bounded and loud, and make it obvious which host you're on.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Blameless reviews.&lt;/strong&gt; Ask what made the action seem reasonable at the time. Fix the system, not the person.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write the decision down, with how you'd know you're wrong.&lt;/strong&gt; Every architecture choice gets a short note covering the problem, the options and the signal that would make you reverse it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ask "what would change my mind?"&lt;/strong&gt; before the meeting ends. If the answer is "nothing", that's ego, not engineering.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test the restore, not the backup.&lt;/strong&gt; Restore it on a schedule, and give someone ownership of it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;None of this is exotic. It's boring technology applied to people.&lt;/p&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;Production doesn't care who you are. It doesn't care how senior you are, how clever the design is or how sure you feel. It responds to small changes, real checks, rehearsed rollbacks and honest reviews.&lt;/p&gt;
&lt;p&gt;Build systems that assume everyone, including you, will be wrong sometimes. Make being wrong cheap, quick to notice and safe to admit.&lt;/p&gt;
&lt;p&gt;Then let the evidence run production.&lt;/p&gt;
&lt;p&gt;Not your ego.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Postgres Is Enough: Skip the Extra Database Until It Hurts</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/ffbf73.html"/>
    <id>https://nehem.dev/ffbf73.html</id>
    <published>2026-06-09T00:00:00+10:00</published>
    <updated>2026-06-09T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Postgres can run your job queue, full-text search, JSON documents and cache. How to do each one, with SQL and Django examples, and the signs it's time to add more.</summary>
    <category term="Postgres"/><category term="Django"/><category term="Architecture"/><category term="Databases"/>
    <content type="html">&lt;p&gt;Every new project seems to start with the same architecture diagram: Postgres for data, Redis for cache, RabbitMQ or SQS for jobs, Elasticsearch for search, maybe MongoDB "for the flexible stuff". Five systems to provision, secure, back up, monitor and keep consistent, for an app with three hundred users.&lt;/p&gt;
&lt;p&gt;The position: &lt;strong&gt;Postgres is enough for far longer than you think.&lt;/strong&gt; It's a queue, a search engine, a document store and a cache, all with transactions, one backup and one connection string. Add another datastore when Postgres is measurably hurting, not when a blog post says you'll need it "at scale".&lt;/p&gt;
&lt;h2&gt;The real cost of the extra box&lt;/h2&gt;
&lt;p&gt;Every additional datastore costs more than its hosting bill:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Consistency.&lt;/strong&gt; Write an order to Postgres and a job to Redis. Postgres commits, Redis is unreachable. Now you have an order nobody will ever process. Or the reverse: the job runs before the transaction commits and can't find the row.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Operations.&lt;/strong&gt; Another thing to patch, monitor, alert on, upgrade and restore. Another set of credentials. Another failure mode at 3 am.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local development and CI.&lt;/strong&gt; Every service is one more container in &lt;code&gt;docker compose&lt;/code&gt;, one more thing to seed in tests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Knowledge.&lt;/strong&gt; Your team needs to understand the failure semantics of each system. Most teams deeply understand one database at best.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When the queue lives in the same database as the data, &lt;strong&gt;enqueuing a job is part of the same transaction.&lt;/strong&gt; Commit the order and the job together, or neither. That one property eliminates a whole category of bugs.&lt;/p&gt;
&lt;h2&gt;A job queue with SKIP LOCKED&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;FOR UPDATE SKIP LOCKED&lt;/code&gt; (since Postgres 9.5) is what makes a Postgres queue practical. Workers lock the next available row and skip rows other workers already hold, so they never block on each other or grab the same job.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TABLE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;jobs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="nb"&gt;bigint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;GENERATED&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ALWAYS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;IDENTITY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;PRIMARY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;DEFAULT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;jsonb&lt;/span&gt;&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;run_at&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="n"&gt;timestamptz&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;DEFAULT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;DEFAULT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INDEX&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;jobs_ready_idx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;jobs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;run_at&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;A worker runs this inside a transaction, does the work, then deletes the row and commits:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;jobs&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;run_at&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;run_at&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;FOR&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SKIP&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LOCKED&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- do the work in application code, then:&lt;/span&gt;
&lt;span class="k"&gt;DELETE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;jobs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;COMMIT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If the worker crashes mid-job, the transaction rolls back, the lock is released and the job becomes available again. No visibility timeouts, no lost messages. For failures you catch, bump &lt;code&gt;attempts&lt;/code&gt; and push &lt;code&gt;run_at&lt;/code&gt; forward for a retry with backoff.&lt;/p&gt;
&lt;p&gt;The trade-off: the transaction stays open while the job runs, so keep jobs short. For long jobs, claim the row with a &lt;code&gt;locked_until&lt;/code&gt; column instead, and reclaim expired ones.&lt;/p&gt;
&lt;p&gt;You don't have to build this yourself. In Python, &lt;strong&gt;Procrastinate&lt;/strong&gt; is a Postgres-backed task queue, and since Django 6.0 there's a built-in Tasks API (&lt;code&gt;django.tasks&lt;/code&gt;) with database-backed workers available through the &lt;code&gt;django-tasks-db&lt;/code&gt; package. Postgres also has &lt;code&gt;LISTEN&lt;/code&gt;/&lt;code&gt;NOTIFY&lt;/code&gt; for waking workers without polling.&lt;/p&gt;
&lt;h2&gt;Full-text search that's good enough&lt;/h2&gt;
&lt;p&gt;Before standing up Elasticsearch, try a generated &lt;code&gt;tsvector&lt;/code&gt; column with a GIN index:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TABLE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;ADD&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;COLUMN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;search&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tsvector&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;GENERATED&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ALWAYS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;setweight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_tsvector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'english'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;coalesce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;setweight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_tsvector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'english'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;coalesce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'B'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;STORED&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INDEX&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles_search_idx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;USING&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;search&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ts_rank&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rank&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="n"&gt;websearch_to_tsquery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'english'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'django "service layer" -celery'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;search&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@@&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;DESC&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That gives you stemming ("orders" matches "order"), weighted fields, quoted phrases and exclusions through &lt;code&gt;websearch_to_tsquery&lt;/code&gt;, which accepts the kind of syntax people type into search boxes. Add the &lt;code&gt;pg_trgm&lt;/code&gt; extension for typo-tolerant matching on names and short strings.&lt;/p&gt;
&lt;p&gt;Django supports this directly through &lt;code&gt;django.contrib.postgres.search&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;django.contrib.postgres.search&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchQuery&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SearchRank&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;django.db.models&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;F&lt;/span&gt;

&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SearchQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"django service layer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;search_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"websearch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"english"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;Article&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;annotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchRank&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;F&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"search"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"-rank"&lt;/span&gt;&lt;span class="p"&gt;)[:&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It won't match a dedicated search engine on relevance tuning, faceting at huge scale or multi-language analysis. For a product catalogue, a help centre or an admin search box, it's usually plenty.&lt;/p&gt;
&lt;h2&gt;JSON when the schema really is flexible&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;jsonb&lt;/code&gt; stores JSON in a binary, indexable form. Need to store webhook payloads, per-tenant settings or third-party API responses? You don't need a document database.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INDEX&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;events_payload_idx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;USING&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;jsonb_path_ops&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'{"type": "invoice.paid"}'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In Django, &lt;code&gt;models.JSONField&lt;/code&gt; maps to &lt;code&gt;jsonb&lt;/code&gt; on Postgres, and lookups like &lt;code&gt;filter(payload__type="invoice.paid")&lt;/code&gt; work out of the box.&lt;/p&gt;
&lt;p&gt;One warning: &lt;code&gt;jsonb&lt;/code&gt; is a pressure valve, not a design. If you're querying the same keys in every request, they're columns. Promote them.&lt;/p&gt;
&lt;h2&gt;A cache that's one table&lt;/h2&gt;
&lt;p&gt;For many apps the "cache" is a handful of expensive computed values. Postgres can hold those in an &lt;code&gt;UNLOGGED&lt;/code&gt; table, which skips the write-ahead log, so writes are cheaper. The catch is that it's truncated after a crash, which is exactly the durability a cache needs.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;UNLOGGED&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TABLE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;cache&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;PRIMARY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="n"&gt;jsonb&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;expires_at&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;timestamptz&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;cache&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;expires_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'dashboard:42'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'{"orders": 118}'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;interval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'5 minutes'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CONFLICT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;DO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;SET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;expires_at&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expires_at&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Django also ships a database cache backend, &lt;code&gt;django.core.cache.backends.db.DatabaseCache&lt;/code&gt;, set up with &lt;code&gt;manage.py createcachetable&lt;/code&gt;. Before you add a cache at all, check whether the real fix is an index, a &lt;code&gt;select_related()&lt;/code&gt; or a materialized view.&lt;/p&gt;
&lt;h2&gt;When it actually hurts&lt;/h2&gt;
&lt;p&gt;I'm not saying never. I'm saying wait for evidence. Signs that it's time:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Queue throughput.&lt;/strong&gt; Sustained high job volume where the jobs table churns faster than autovacuum keeps up, and the bloat shows in your metrics. That's when SQS or a dedicated broker earns its keep.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cache hit volume.&lt;/strong&gt; You need very high read rates on hot keys with sub-millisecond latency, and the cache traffic is competing with your real queries for connections and CPU. That's what Redis or Valkey is for.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Search quality.&lt;/strong&gt; Users need faceting, synonyms, typo tolerance across large corpora or relevance tuning you can't get from &lt;code&gt;ts_rank&lt;/code&gt;. Bring in OpenSearch, Meilisearch or similar.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Analytics.&lt;/strong&gt; Large aggregations over hundreds of millions of rows slow down the primary. Move them to a replica first, then to a columnar store if needed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fan-out and streaming.&lt;/strong&gt; Many consumers replaying an event log is Kafka's job, not a jobs table.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Every one of those is a measurement, not a feeling. Watch query latency, connection count, replication lag, table bloat and CPU. When a specific workload is the cause, extract that workload, and only that one.&lt;/p&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;Postgres has decades of engineering behind it, transactions across everything you put in it, and one backup story. &lt;strong&gt;Start with one database. Use it properly. Add the second system when a graph tells you to, not when a diagram does.&lt;/strong&gt; Most products never get there, and the ones that do will know exactly which piece to move out.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Lambda Is Not Cheap: When Serverless Costs More Than a Boring EC2 Box</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/2eccb3.html"/>
    <id>https://nehem.dev/2eccb3.html</id>
    <published>2026-02-19T00:00:00+10:00</published>
    <updated>2026-02-19T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>AWS Lambda bills wall-clock time per request, so steady traffic can cost more than an EC2 box. The formula, a worked example, cold starts and when Lambda wins.</summary>
    <category term="AWS"/><category term="Lambda"/><category term="Serverless"/><category term="EC2"/><category term="Cost"/>
    <content type="html">&lt;p&gt;"Serverless is cheaper" is one of those lines that gets repeated until nobody checks it. For a cron job that runs twice a day, it's true. For a Django API with steady traffic, it's often false, sometimes by a wide margin, and the bill arrives after the architecture is already committed.&lt;/p&gt;
&lt;p&gt;The position: &lt;strong&gt;Lambda is priced per unit of work, EC2 is priced per unit of time. Below a certain steady load, per-work wins. Above it, the boring box wins, and the crossover comes sooner than people expect.&lt;/strong&gt; You can work out where yours is with a calculator and ten minutes. Most teams never do.&lt;/p&gt;
&lt;h2&gt;How Lambda actually bills&lt;/h2&gt;
&lt;p&gt;The pricing model is simple, which is exactly why it's easy to underestimate:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A request charge&lt;/strong&gt; per invocation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A duration charge&lt;/strong&gt; in GB-seconds: allocated memory multiplied by the time your function runs, billed per millisecond.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A free tier&lt;/strong&gt; of 1 million requests and 400,000 GB-seconds per month.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Since 1 August 2025, the INIT phase is billed&lt;/strong&gt; for on-demand ZIP functions on managed runtimes too. Cold start time is now part of your bill, not just your latency.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Extras around it:&lt;/strong&gt; API Gateway or a function URL in front, CloudWatch Logs for every invocation, NAT gateway charges if your function sits in a VPC and calls the internet, and provisioned concurrency if you buy your way out of cold starts.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As of February 2026, the AWS pricing page lists x86 on-demand duration at $0.0000166667 per GB-second and requests at $0.20 per million, in its worked example. Prices vary by region and Arm (Graviton) is cheaper per GB-second, so check your own region before you plug in numbers.&lt;/p&gt;
&lt;h2&gt;The part everybody misses: you pay for waiting&lt;/h2&gt;
&lt;p&gt;A typical Django endpoint doesn't compute much. It receives a request, runs a few queries, maybe calls another service, serialises JSON. Most of its wall-clock time is spent &lt;strong&gt;waiting on I/O&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;On an EC2 box, that waiting is nearly free. While one request waits on Postgres, the same process, through threads, async or more workers, serves others. One instance overlaps hundreds of waiting requests.&lt;/p&gt;
&lt;p&gt;On default Lambda, each execution environment handles one request at a time, and you're billed for its full duration, waiting included. A 200 ms request that spends 180 ms waiting on the database costs you 200 ms of allocated memory. Lambda bills you for the time your code is idle.&lt;/p&gt;
&lt;p&gt;That's the structural reason I/O-heavy, steady-traffic APIs tend to be expensive on Lambda. It's not a pricing trick. It's the model.&lt;/p&gt;
&lt;h2&gt;The formula&lt;/h2&gt;
&lt;p&gt;Per month, ignoring the free tier:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;lambda_cost = R * (P_req + d * m * P_gbs)

R      = requests per month
P_req  = price per request           (e.g. 0.20 / 1,000,000)
d      = average billed duration, s  (include INIT for cold starts)
m      = allocated memory, GB
P_gbs  = price per GB-second         (e.g. 0.0000166667)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The cost per request is the bracket. Break-even against a fixed monthly server cost &lt;code&gt;E&lt;/code&gt; is simply:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;break_even_requests = E / (P_req + d * m * P_gbs)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As code, so you can play with it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;SECONDS_PER_MONTH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;lambda_monthly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;duration_s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;memory_gb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;p_req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1_000_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;p_gbs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0000166667&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rps&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;SECONDS_PER_MONTH&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_req&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;duration_s&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;memory_gb&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p_gbs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;break_even_rps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;server_monthly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;duration_s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;memory_gb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;p_req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1_000_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;p_gbs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0000166667&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;per_request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p_req&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;duration_s&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;memory_gb&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p_gbs&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;server_monthly&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;per_request&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;SECONDS_PER_MONTH&lt;/span&gt;


&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lambda_monthly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;      &lt;span class="c1"&gt;# 457.92&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;break_even_rps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     &lt;span class="c1"&gt;# 16.4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;A worked example (illustrative numbers)&lt;/h2&gt;
&lt;p&gt;These are made-up but realistic inputs, not a benchmark. Change them to yours.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An API averaging &lt;strong&gt;50 requests per second&lt;/strong&gt;, all month.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;200 ms&lt;/strong&gt; average duration, &lt;strong&gt;1 GB&lt;/strong&gt; of memory.&lt;/li&gt;
&lt;li&gt;That's about &lt;strong&gt;129.6 million requests&lt;/strong&gt; a month.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lambda, before the free tier, API Gateway, logs or NAT:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Requests: 129.6M x $0.20 per million = about &lt;strong&gt;$26&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Duration: 129.6M x 0.2 s x 1 GB = 25.9M GB-s, x $0.0000166667 = about &lt;strong&gt;$432&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Total: about &lt;strong&gt;$458 a month&lt;/strong&gt;, and that's before the extras.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now suppose your alternative, a pair of modest instances behind a load balancer for redundancy, costs &lt;strong&gt;$150 a month&lt;/strong&gt; (an illustrative figure, not a quote; price your own instance types). The break-even is about &lt;strong&gt;16 requests per second&lt;/strong&gt; of average load. Above that, every extra request widens the gap in the box's favour, because the box costs the same whether it's 20% or 70% busy.&lt;/p&gt;
&lt;p&gt;Notice what moves the answer most: &lt;strong&gt;duration and memory.&lt;/strong&gt; Halve your average duration and Lambda's duration bill halves. Teams that cut Lambda bills mostly do it by making functions faster or smaller, which is a fine outcome. But it's the same work that makes a box handle more load.&lt;/p&gt;
&lt;h2&gt;Cold starts are a cost, not just a delay&lt;/h2&gt;
&lt;p&gt;Django is not a small import. Load settings, the ORM, apps, DRF, a few SDKs, and the init phase can take a noticeable fraction of a second. Since INIT is billed, every cold start is paid time. The options all cost something:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Provisioned concurrency&lt;/strong&gt; keeps environments warm, and you pay for it by the hour whether requests arrive or not. Which is, functionally, a server.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SnapStart for Python&lt;/strong&gt; restores from a snapshot to cut init time, with its own charges and caveats around anything that must be unique per environment, like random seeds and connections.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Slimming the package&lt;/strong&gt; and lazy imports help, and they're worth doing anyway.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And then there's the database. Hundreds of concurrent Lambda environments each opening a Postgres connection will exhaust &lt;code&gt;max_connections&lt;/code&gt; quickly. The fix is RDS Proxy or another pooler, which is another line on the bill and another moving part.&lt;/p&gt;
&lt;h2&gt;Where Lambda genuinely wins&lt;/h2&gt;
&lt;p&gt;I'm not anti-Lambda. I'm anti-assuming. It's excellent when:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Traffic is spiky or near zero most of the time.&lt;/strong&gt; Internal tools, webhooks, a back-office API used during business hours. Scale to zero is real money.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It's event glue.&lt;/strong&gt; S3 upload triggers, SQS consumers, EventBridge rules, small transforms between AWS services. This is what Lambda was built for and it's hard to beat.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scheduled jobs.&lt;/strong&gt; A nightly report doesn't justify an always-on box.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parallel bursts.&lt;/strong&gt; Fan out thousands of independent tasks for five minutes, then nothing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You have no one to run servers.&lt;/strong&gt; Patching, scaling and replacing instances is real work. If nobody on the team will do it, that labour has a cost too, and it can outweigh the bill difference. Just count it honestly rather than assuming it's huge.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note the shape: Lambda wins when &lt;strong&gt;utilisation would be low&lt;/strong&gt; on a server. The less steady the traffic, the better it looks.&lt;/p&gt;
&lt;h2&gt;The boring middle ground&lt;/h2&gt;
&lt;p&gt;It isn't Lambda or a hand-built pet server. A Django app in a container on ECS with Fargate, or an EC2 Auto Scaling group behind a load balancer, gives you managed deploys, health checks and scaling while keeping the concurrency model where one process serves many waiting requests. Add a Compute Savings Plan or reserved capacity for the baseline and your steady load gets cheaper still. AWS itself launched Lambda Managed Instances in late 2025: functions run on EC2 instances, several requests share an execution environment, and you pay EC2 instance prices plus a management fee and the usual request charge, instead of per-request duration. When the vendor ships that hybrid for steady workloads, the trade-off is real.&lt;/p&gt;
&lt;h2&gt;How to decide&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Pull a month of real traffic. Get average requests per second and the &lt;strong&gt;peak-to-average ratio.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Measure average billed duration and memory from your Lambda &lt;code&gt;REPORT&lt;/code&gt; log lines, or estimate from your current app's response times.&lt;/li&gt;
&lt;li&gt;Run the formula. Add API Gateway, logs, NAT and any provisioned concurrency.&lt;/li&gt;
&lt;li&gt;Price the boring alternative honestly, including redundancy and a bit of headroom.&lt;/li&gt;
&lt;li&gt;If Lambda is cheaper, or close and the ops savings matter, use it. If it's several times more, stop calling it the cheap option.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Lambda bills you for every millisecond your code waits on a database.&lt;/strong&gt; That's perfect for bursty, event-driven and low-traffic work, and expensive for steady APIs. Do the arithmetic before the architecture diagram. The boring EC2 box doesn't have a conference talk, but it often has the smaller invoice.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Store Every Datetime as Naive Asia:Shanghai</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/b8dd4a.html"/>
    <id>https://nehem.dev/b8dd4a.html</id>
    <published>2025-12-31T00:00:00+10:00</published>
    <updated>2025-12-31T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Why I store every datetime as naive Asia/Shanghai (UTC+8, no DST) instead of UTC, how Chinese platforms already work this way, and the case for UTZ offsets.</summary>
    <category term="timezone"/><category term="china"/><category term="utc"/><category term="utz"/>
    <content type="html">&lt;p&gt;After more than a decade of fighting timezone bugs across distributed systems, I made a deliberate, non-reversible decision in late 2022:&lt;/p&gt;
&lt;p&gt;Every &lt;code&gt;TIMESTAMP&lt;/code&gt; and &lt;code&gt;DATETIME&lt;/code&gt; column in my production databases is stored &lt;strong&gt;naive&lt;/strong&gt; (timezone-unaware) and interpreted as &lt;strong&gt;Asia/Shanghai&lt;/strong&gt; (&lt;code&gt;UTC+8&lt;/code&gt;, no DST).&lt;/p&gt;
&lt;p&gt;No &lt;code&gt;timestamptz&lt;/code&gt;. No &lt;code&gt;UTC&lt;/code&gt;. No per-user offset metadata. Just clean, fixed-offset naive values in what is effectively Beijing-local time.&lt;/p&gt;
&lt;p&gt;At first glance this looks heretical. The orthodox answer is still "always store in &lt;code&gt;UTC&lt;/code&gt;". Yet after implementing this pattern at scale, the results are hard to argue with: drastically fewer bugs, simpler debugging, cleaner cron/scheduling logic, and - most importantly - alignment with where the majority of my users, traffic, and revenue actually live.&lt;/p&gt;
&lt;p&gt;More strikingly: this is &lt;strong&gt;not&lt;/strong&gt; an eccentric personal choice. It is already the reality inside the world's largest digital ecosystem.&lt;/p&gt;
&lt;h2&gt;Chinese platforms already operate on what we might call &lt;code&gt;utz+0&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;WeChat, Alipay, Douyin / TikTok (domestic), Pinduoduo - virtually every consumer-facing Chinese super-app stores and computes time as naive Asia/Shanghai.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Transaction logs, user activity events, payment timestamps -&amp;gt; all naive &lt;code&gt;UTC+8&lt;/code&gt;  &lt;/li&gt;
&lt;li&gt;Delivery ETAs, driver assignment windows, flash-sale timers -&amp;gt; calculated and stored in Beijing time  &lt;/li&gt;
&lt;li&gt;Billing cycles, daily analytics batches, fraud-detection windows -&amp;gt; anchored to Shanghai clock  &lt;/li&gt;
&lt;li&gt;Even many backend cron jobs and monitoring dashboards assume UTC+8 as the implicit reference  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This isn't accidental. When you serve 1.4 billion people whose daily life (work, school, meals, sleep) already orbits Beijing time, imposing &lt;code&gt;UTC&lt;/code&gt; adds pointless conversion overhead at every layer. &lt;/p&gt;
&lt;p&gt;The Chinese mantra goes something like this, instead of adapting to the world, the world starts adapting to you.&lt;/p&gt;
&lt;p&gt;Add Singapore, Malaysia, Philippines, Brunei, Indonesia, Mongolia, and Perth - all already on &lt;code&gt;UTC+8&lt;/code&gt; - and you have a coherent bloc of ~2 billion people already living and transacting on what I now informally call &lt;strong&gt;&lt;code&gt;UTZ&lt;/code&gt;&lt;/strong&gt; (Universal Temporal Zone = &lt;code&gt;Asia/Shanghai&lt;/code&gt; = &lt;code&gt;UTC+8&lt;/code&gt;, no DST).&lt;/p&gt;
&lt;h2&gt;Reframing the world in &lt;code&gt;UTZ&lt;/code&gt; offsets&lt;/h2&gt;
&lt;p&gt;Once you recenter the map on Beijing instead of Greenwich, the numbers become elegantly simple for the most populous part of the planet:&lt;/p&gt;
&lt;div class="table-scroll"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Region&lt;/th&gt;
&lt;th&gt;UTC&lt;/th&gt;
&lt;th&gt;UTZ&lt;/th&gt;
&lt;th&gt;Population&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Beijing, Singapore, Manila, KL, Perth, Indonesia&lt;/td&gt;
&lt;td&gt;UTC+8&lt;/td&gt;
&lt;td&gt;UTZ+0&lt;/td&gt;
&lt;td&gt;~2.0B+&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tokyo, Seoul, Pyongyang&lt;/td&gt;
&lt;td&gt;UTC+9&lt;/td&gt;
&lt;td&gt;UTZ+1&lt;/td&gt;
&lt;td&gt;~200M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bangkok, Hanoi, Vientiane, Phnom Penh&lt;/td&gt;
&lt;td&gt;UTC+7&lt;/td&gt;
&lt;td&gt;UTZ-1&lt;/td&gt;
&lt;td&gt;~220M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delhi&lt;/td&gt;
&lt;td&gt;UTC+5:30&lt;/td&gt;
&lt;td&gt;UTZ-2.5&lt;/td&gt;
&lt;td&gt;~1.4B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sydney / Melbourne&lt;/td&gt;
&lt;td&gt;UTC+10&lt;/td&gt;
&lt;td&gt;UTZ+2&lt;/td&gt;
&lt;td&gt;~26M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;London&lt;/td&gt;
&lt;td&gt;UTC+1&lt;/td&gt;
&lt;td&gt;UTZ-7&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;New York&lt;/td&gt;
&lt;td&gt;UTC-4&lt;/td&gt;
&lt;td&gt;UTZ-12&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;For ~50% of humanity, time suddenly feels centered rather than perpetually "ahead" or "behind".&lt;/p&gt;
&lt;h2&gt;How the shift gains momentum - a realistic, economics-driven roadmap&lt;/h2&gt;
&lt;p&gt;No IETF RFC or UN resolution will declare UTZ. Change will come through &lt;strong&gt;economic gravity, platform lock-in, infrastructure dependencies, and soft (but very real) incentives&lt;/strong&gt; - forces already in motion.&lt;/p&gt;
&lt;p&gt;Here are some of my predictions with respect to timezone adaptation. To accelerate this shift, Beijing must proactively wield soft power—issuing formal invitations backed by economic incentives and diplomatic charm—or, if resistance persists, apply subtle coercion through platform dominance and infrastructure dependencies.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Phase 1 - Core Already Secured&lt;/strong&gt;&lt;br /&gt;
China + Mongolia + Singapore + Malaysia + Philippines + Brunei + Indonesia + Perth = ~2B people effectively on &lt;code&gt;UTZ+0&lt;/code&gt; today. No action required. The foundation exists.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Phase 2 - High-Leverage Neighbors (Very Plausible Next 5-10 Years)&lt;/strong&gt;&lt;br /&gt;
Beijing should lead with official invitations to these neighbors, framing alignment as a mutual win for prosperity and efficiency. If soft appeals fall short, leverage economic ties for gentle coercion.  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tokyo / Seoul / Pyongyang&lt;/strong&gt; (&lt;code&gt;UTC+9&lt;/code&gt; -&amp;gt; &lt;code&gt;UTZ+0&lt;/code&gt;)&lt;br /&gt;
  Leverage: semiconductor supply chains, cloud &amp;amp; CDN dependencies, content distribution deals (anime, K-pop, games via Chinese platforms), massive Chinese tourism &amp;amp; student flows.&lt;br /&gt;
  Framing: "Your digital economy already runs on infrastructure timed to Beijing. Why keep forcing one-hour conversions everywhere?"  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bangkok / Hanoi / Vientiane / Phnom Penh&lt;/strong&gt; (&lt;code&gt;UTC+7&lt;/code&gt; -&amp;gt; &lt;code&gt;UTZ+0&lt;/code&gt;)&lt;br /&gt;
  Leverage: Belt &amp;amp; Road rail/highway/port projects, cross-border e-commerce (Shopee, Lazada, Temu), payment rails (Alipay / WeChat Pay integration), massive SME seller base on Chinese platforms.&lt;br /&gt;
  Framing: "Your delivery riders, street vendors, and exporters already live in our apps. One shared clock = faster growth, fewer disputes."  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Achieving these shifts alone brings ~2.3-2.5 billion people under a unified temporal framework - roughly one third of humanity, concentrated in the world's growth center.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Phase 3 - Broader Platform &amp;amp; Financial Pull&lt;/strong&gt;  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Stock exchanges &amp;amp; market hours begin syncing to a common UTZ window (e.g., 09:30 UTZ+0 open for Shanghai / Shenzhen / HK -&amp;gt; Tokyo / Seoul follow, then Jakarta / Bangkok adjust). Algo-trading desks and index funds hate timezone math; they will quietly reward alignment.  &lt;/li&gt;
&lt;li&gt;Global developers building mini-programs, TikTok Shop, or Douyin international increasingly default to naive Asia/Shanghai timestamps.  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once critical economic flows (trade settlements, ad impressions, delivery SLAs) assume UTZ, civil-time adjustments become the path of least resistance.&lt;/p&gt;
&lt;h2&gt;Why I commit to naive Asia/Shanghai storage today&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;My largest user cohorts and fastest-growing revenue streams are already in UTZ-aligned regions.  &lt;/li&gt;
&lt;li&gt;My primary regions (Singapore / Shanghai VPCs) run natively in &lt;code&gt;UTC+8&lt;/code&gt;.  &lt;/li&gt;
&lt;li&gt;Business events (peak usage, flash campaigns, financial cutoffs) are defined by "Beijing morning" - not Greenwich midnight.  &lt;/li&gt;
&lt;li&gt;Naive storage + consistent interpretation eliminates classes of bugs that have haunted every multi-region system I've ever inherited.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I'm not doing this out of sentiment. I'm doing it because the data, the traffic maps, and the platform momentum all point the same way.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;UTC&lt;/code&gt; was the right default when the internet was young and Western-centric. But infrastructure follows users, users follow economic centers, and economic mass has decisively shifted.&lt;/p&gt;
&lt;h2&gt;Final thought&lt;/h2&gt;
&lt;p&gt;Time is not purely technical - it is infrastructural, and infrastructure follows power.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;UTZ&lt;/code&gt; isn't a proposal. It's already partially deployed at planetary scale.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The only remaining question is how long the rest of the industry takes to notice Who knows... one day the Forbidden Kingdom might even become the prime meridian with 0° longitude.&lt;/p&gt;
&lt;p&gt;That goes without saying:  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;One Belt, One Road, One TZ.&lt;/strong&gt;&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Type Hints Pay Off Only If You Run a Type Checker in CI</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/1cd308.html"/>
    <id>https://nehem.dev/1cd308.html</id>
    <published>2025-10-14T00:00:00+10:00</published>
    <updated>2025-10-14T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Python type hints are just comments until mypy or pyright runs in CI. A pragmatic guide to gradual adoption, config that works and rules worth keeping.</summary>
    <category term="Python"/><category term="Typing"/><category term="Mypy"/><category term="CI"/>
    <content type="html">&lt;p&gt;Python type hints have a dirty secret: &lt;strong&gt;the interpreter ignores them.&lt;/strong&gt; &lt;code&gt;def total(x: int) -&amp;gt; int&lt;/code&gt; will happily accept a string and return a list. Nothing checks it at runtime unless you add a library that does. Annotations are metadata. Nothing more.&lt;/p&gt;
&lt;p&gt;So here's the position: &lt;strong&gt;type hints without a type checker in CI are decorative comments that can lie.&lt;/strong&gt; Worse than no hints, because they look authoritative. If you're going to write them, make a machine verify them on every pull request. If you're not going to do that, at least be honest that they're documentation.&lt;/p&gt;
&lt;h2&gt;Hints that lie&lt;/h2&gt;
&lt;p&gt;This is the failure mode in a codebase where hints are written but never checked:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;find_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That annotation is false. &lt;code&gt;.first()&lt;/code&gt; returns &lt;code&gt;None&lt;/code&gt; when nothing matches. Every caller trusts the signature, skips the &lt;code&gt;None&lt;/code&gt; check, and the bug surfaces as &lt;code&gt;AttributeError: 'NoneType' object has no attribute 'name'&lt;/code&gt; in production, three calls away from the cause.&lt;/p&gt;
&lt;p&gt;A type checker with the Django plugin flags this immediately: the function returns &lt;code&gt;User | None&lt;/code&gt;, not &lt;code&gt;User&lt;/code&gt;. The fix is one honest annotation:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;find_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now every caller is forced to handle the missing case, and the checker tells you which ones don't. That's the entire value proposition of typing: &lt;strong&gt;move a class of runtime errors to review time.&lt;/strong&gt; It only works if something actually runs.&lt;/p&gt;
&lt;h2&gt;Pick a checker and stop debating&lt;/h2&gt;
&lt;p&gt;The mainstream options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;mypy&lt;/strong&gt; - the original, maintained under the Python organisation, with a mature plugin system. If you use Django, the &lt;code&gt;django-stubs&lt;/code&gt; plugin makes querysets and model fields understood. This is the default choice for Django projects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;pyright&lt;/strong&gt; - Microsoft's checker, written in TypeScript and fast. It powers the Pylance extension in VS Code, so many developers already see its errors in their editor. Its inference is aggressive and its strict mode is strict.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Newer Rust-based checkers&lt;/strong&gt; such as Astral's &lt;code&gt;ty&lt;/code&gt; and Meta's Pyrefly are worth watching. Check their status before betting a large codebase on them.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My advice: Django-heavy codebase, start with mypy and &lt;code&gt;django-stubs&lt;/code&gt;. Library or non-Django service, pyright is a great default. Either is far better than neither, and arguing about it for a sprint is worse than picking one today.&lt;/p&gt;
&lt;h2&gt;Gradual adoption that doesn't stall&lt;/h2&gt;
&lt;p&gt;The common mistake is turning on &lt;code&gt;--strict&lt;/code&gt; across a 200,000-line codebase, seeing thousands of errors and giving up. Python typing is designed to be gradual. Use that.&lt;/p&gt;
&lt;p&gt;Start permissive globally and strict where it matters:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# pyproject.toml&lt;/span&gt;
&lt;span class="k"&gt;[tool.mypy]&lt;/span&gt;
&lt;span class="n"&gt;python_version&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"3.12"&lt;/span&gt;
&lt;span class="n"&gt;plugins&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"mypy_django_plugin.main"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;warn_unused_ignores&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;warn_redundant_casts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;no_implicit_optional&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;check_untyped_defs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="k"&gt;[tool.django-stubs]&lt;/span&gt;
&lt;span class="n"&gt;django_settings_module&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"config.settings"&lt;/span&gt;

&lt;span class="c1"&gt;# New and critical code: no untyped functions allowed.&lt;/span&gt;
&lt;span class="k"&gt;[[tool.mypy.overrides]]&lt;/span&gt;
&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"billing.*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"orders.services"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"orders.selectors"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;disallow_untyped_defs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;disallow_any_generics&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;warn_return_any&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="c1"&gt;# Third-party packages without stubs: don't let them block CI.&lt;/span&gt;
&lt;span class="k"&gt;[[tool.mypy.overrides]]&lt;/span&gt;
&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"legacy_vendor_sdk.*"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;ignore_missing_imports&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then ratchet:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Week one:&lt;/strong&gt; run the checker in CI on the whole repo with the permissive defaults. Fix or &lt;code&gt;# type: ignore[code]&lt;/code&gt; the existing errors. The goal is a green baseline, not perfection.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Every new module&lt;/strong&gt; goes into the strict override list. New code is typed from birth.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Every time you touch an old module&lt;/strong&gt; for real work, add it to the strict list and fix what falls out. Leave the place better than you found it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Track the ignore count.&lt;/strong&gt; &lt;code&gt;grep -rc "type: ignore"&lt;/code&gt; in CI is crude and it works. The number should only go down.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;code&gt;warn_unused_ignores&lt;/code&gt; matters more than it looks. When you fix the underlying problem, the stale ignore becomes an error, so suppressions can't rot silently.&lt;/p&gt;
&lt;h2&gt;Wire it into CI, not just the editor&lt;/h2&gt;
&lt;p&gt;Editor squiggles are advisory. A red CI check is a rule. A minimal GitHub Actions job:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;typecheck&lt;/span&gt;
&lt;span class="nt"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p p-Indicator"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;pull_request&lt;/span&gt;&lt;span class="p p-Indicator"&gt;]&lt;/span&gt;
&lt;span class="nt"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;mypy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;ubuntu-latest&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;actions/checkout@v5&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;actions/setup-python@v6&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nt"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;python-version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"3.12"&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;pip install -r requirements-dev.txt&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;mypy .&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Pin your checker version in &lt;code&gt;requirements-dev.txt&lt;/code&gt;. Checkers get smarter with each release, which means an unpinned upgrade can turn a green build red on a Monday morning with no code change. Upgrade on purpose, in its own pull request.&lt;/p&gt;
&lt;p&gt;Make the check required on the main branch. If it can be skipped, it will be.&lt;/p&gt;
&lt;h2&gt;Rules worth keeping&lt;/h2&gt;
&lt;p&gt;Typing everything perfectly isn't the goal. Typing the parts where bugs are expensive is.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Type the boundaries first.&lt;/strong&gt; Public functions, service layers, anything another module calls. Internals of a twenty-line helper can wait.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ban &lt;code&gt;Any&lt;/code&gt; from spreading.&lt;/strong&gt; &lt;code&gt;Any&lt;/code&gt; is contagious: whatever touches it becomes unchecked. Use it at the edge, such as parsing raw JSON, then convert to a real type immediately.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Model data, don't pass dicts.&lt;/strong&gt; A &lt;code&gt;dict[str, Any]&lt;/code&gt; travelling through five functions is a bug farm. Use a &lt;code&gt;dataclass&lt;/code&gt; for internal data and a &lt;code&gt;TypedDict&lt;/code&gt; when the shape really is a dict, like a JSON payload.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use &lt;code&gt;Protocol&lt;/code&gt; for dependencies.&lt;/strong&gt; It's structural typing: a fake in tests satisfies it without inheriting anything.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;decimal&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;typing&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;PaymentGateway&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;charge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reference&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;settle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;PaymentGateway&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;charge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reference&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"manual"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Every ignore carries an error code.&lt;/strong&gt; &lt;code&gt;# type: ignore[attr-defined]&lt;/code&gt;, never a bare &lt;code&gt;# type: ignore&lt;/code&gt;. Bare ignores hide every future error on that line too.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use &lt;code&gt;reveal_type()&lt;/code&gt; when confused.&lt;/strong&gt; Drop it in, run the checker, read what it thinks. It beats guessing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don't fight the checker with &lt;code&gt;cast()&lt;/code&gt;.&lt;/strong&gt; Each &lt;code&gt;cast&lt;/code&gt; is you overruling the machine. Sometimes you're right. Usually the type is wrong upstream.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What typing won't do&lt;/h2&gt;
&lt;p&gt;Be clear-eyed about it. A type checker won't validate data coming over the wire. Your request body is still untrusted bytes, and for that you want runtime validation: a serializer, Pydantic or a plain schema check. Typing also won't catch logic bugs where the types line up and the maths is wrong. That's what tests are for.&lt;/p&gt;
&lt;p&gt;Types and tests aren't competitors. Types eliminate a whole category of tests you'd otherwise write: "what if this is &lt;code&gt;None&lt;/code&gt;", "what if someone passes a string". Tests cover behaviour. Together they're cheaper than either alone.&lt;/p&gt;
&lt;h2&gt;The cost argument&lt;/h2&gt;
&lt;p&gt;The usual objection is speed: "annotations slow us down." For a throwaway script, sure, skip them. For code that lives longer than a quarter and is touched by more than one person, the trade usually goes the other way. Refactoring is where it shows. Rename a field, change a return type, split a function, and the checker gives you the list of every call site that needs to change. Without it, that list is "grep and hope".&lt;/p&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;A type hint is a promise. &lt;strong&gt;A type checker in CI is what makes the promise binding.&lt;/strong&gt; Pick mypy or pyright, start permissive, make new code strict, ratchet old code as you touch it, and make the check required. If you're not going to run a checker, stop writing hints that might be wrong. Unverified types aren't documentation, they're rumours.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>DST Is a Bug, Not a Feature</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/2c2a28.html"/>
    <id>https://nehem.dev/2c2a28.html</id>
    <published>2025-08-03T00:00:00+10:00</published>
    <updated>2025-08-03T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Daylight saving time causes twice-yearly software bugs. A look at countries that dropped DST, from Russia and China to Iceland and Turkey, and what devs can learn.</summary>
    <category term="DST"/><category term="DaylightSaving"/>
    <content type="html">&lt;p&gt;Daylight Saving Time isn't "saving" anything. It's a 100-year-old hack that introduces twice-yearly bugs into every system that touches schedules, logs, billing, notifications, cron jobs, and human sanity.&lt;/p&gt;
&lt;p&gt;We advance clocks in spring → people lose an hour of sleep → heart attacks spike slightly, accidents go up, life satisfaction dips. Fall back → everyone celebrates the "extra hour" until they realize it's just redistributing misery. Energy savings? Negligible or negative in modern AC-heavy worlds. Developer pain? Infinite.&lt;/p&gt;
&lt;p&gt;Yet somehow, most of Europe and North America still run this circus. Meanwhile, a growing list of countries said "nah" and haven't looked back. Let's meet the defectors who fixed their timezone code and moved on with fixed offsets forever.&lt;/p&gt;
&lt;h2&gt;1. Russia (abolished 2014, after a brief "permanent DST" experiment gone wrong)&lt;/h2&gt;
&lt;p&gt;Tried permanent summer time 2011–2014 → dark winter mornings, kids going to school in pitch black, massive complaints. Switched back to permanent standard time (winter time) in 2014. Result? No more biannual chaos, simpler scheduling across 11 time zones (now 11 again after earlier cuts), no regrets reported. Russians just shrugged and kept living. If a country spanning ~11 time zones can ditch the switch without imploding, your app can too.&lt;/p&gt;
&lt;h2&gt;2. China (tried 1986–1991, abolished permanently)&lt;/h2&gt;
&lt;p&gt;Short experiment for "energy conservation." Saved a bit of kWh in theory, but caused massive confusion-people forgot to change clocks, meetings double-booked, factories messed up. Government killed it in 1992 citing "inconvenience." China never looked back. One timezone (UTC+8, no DST ever), 1.4B+ people, zero clock-change bugs in WeChat/Alipay/Douyin. Coincidence? I think not. They basically run on naive Asia/Shanghai everywhere and it scales beautifully.&lt;/p&gt;
&lt;h2&gt;3. Iceland (abolished effectively since 1968, permanent UTC+0)&lt;/h2&gt;
&lt;p&gt;Way up north with insane summer daylight anyway (midnight sun vibes). Tried DST briefly, ditched it because extending already-long days made zero sense. No clock changes since the late 60s. Icelanders just live with consistent time. Productivity didn't collapse. Northern lights still appear. Win.&lt;/p&gt;
&lt;h2&gt;4. Turkey (switched to permanent DST in 2016 → effectively no more changes)&lt;/h2&gt;
&lt;p&gt;They didn't "abolish" the switch so much as lock it on summer time forever (UTC+3 year-round). No fall-back. No spring-forward. Just fixed. Energy arguments aside, no biannual disruptions. Business goes on.&lt;/p&gt;
&lt;h2&gt;5. Recent dropouts (last 10–15 years): Armenia, Azerbaijan, Belarus, Georgia, Iran, Jordan, Namibia, Samoa, Syria, Uruguay&lt;/h2&gt;
&lt;p&gt;These are the fresh ones. Jordan/Syria went permanent summer time recently (2022). Namibia, Uruguay ditched after trials showed meh energy gains and lots of hassle. Iran bounced for religious/political reasons but stayed off. Pattern? Once you stop the twice-yearly jolt, nobody riots to bring it back. The switch is the bug; fixed offset is the stable release.&lt;/p&gt;
&lt;p&gt;For Australia the story is entirely different, Australia - the chaotic half-defector that accidentally proved the point. Australia is the ultimate “we tried DST and mostly hated it” exhibit.&lt;/p&gt;
&lt;p&gt;Three mainland states (Queensland, Western Australia, Northern Territory) never observe DST and have been on permanent standard time forever.
Queensland in particular has been loud about it since 1992 - they tried it, voters hated the late sunsets messing with kids’ bedtimes and farmers’ routines, and they killed it permanently. No regrets.&lt;/p&gt;
&lt;p&gt;The other states (NSW, Victoria, SA, Tasmania, ACT) still do the biannual dance… but even there, every few years someone floats “permanent summer time” or “permanent standard” and the public usually says “just pick one and leave it alone.”
Result? A country with wildly inconsistent rules across borders, yet the non-DST states report zero chaos compared to the ones that still flip. Queensland businesses schedule with Brisbane time year-round, no bugs, no double-booked Zoom calls, no “did the meeting move because of DST?” drama. Meanwhile Sydney/Melbourne teams still deal with the March/October ritual.&lt;/p&gt;
&lt;p&gt;Australia basically runs a live A/B test: half the country on fixed offset, half still running legacy code. Guess which half has fewer timezone-support tickets? Fixed wins.
Bonus honorable mentions:&lt;/p&gt;
&lt;p&gt;Arizona (most of it, since 1968) - Hot desert + DST = more AC runtime in evenings = higher bills. Opted out permanently. Navajo Nation still does DST for border reasons, but the state as a whole? Nope.&lt;/p&gt;
&lt;p&gt;Most equatorial/tropical countries - Never bothered in the first place. Daylight barely varies year-round. Why add bugs when nature already gave you a stable API?&lt;/p&gt;
&lt;h2&gt;What These Countries Teach Us Devs&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Biannual changes are &lt;strong&gt;non-deterministic garbage&lt;/strong&gt; injected into otherwise predictable systems.&lt;/li&gt;
&lt;li&gt;Permanent fixed offset = fewer edge cases (no "did this event happen before/after the switch?"), simpler queries, no timezone DB updates breaking prod every March/October.&lt;/li&gt;
&lt;li&gt;"But energy savings!" - Modern studies show it's a wash or net negative. Countries that quit report no measurable regret spike.&lt;/li&gt;
&lt;li&gt;Humans adapt fast to fixed local wall-clock time. Meetings at 9 AM stay 9 AM forever. Cron jobs don't ghost or double-fire.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;DST isn't a feature. It's technical debt the world is slowly paying off.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Why Microservices Are a Luxury Tax on Startups</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/8f88cf.html"/>
    <id>https://nehem.dev/8f88cf.html</id>
    <published>2025-07-02T00:00:00+10:00</published>
    <updated>2025-07-02T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Why microservices are a luxury tax on startups: the deployment, network, data-consistency and cloud-cost overhead they add, and why modular monoliths keep winning.</summary>
    <category term="Microservices"/><category term="Monolith"/><category term="Startup"/><category term="Scalability"/>
    <content type="html">&lt;p&gt;It's 2025 and the discourse is still stuck in 2015: "Microservices = scale. Monoliths = legacy." Meanwhile, real startups are bleeding runway, burning investor cash, and dying on pagers because they chased distributed-system porn before they even had product-market fit.&lt;/p&gt;
&lt;p&gt;The truth nobody wants to tweet: &lt;strong&gt;Microservices are mostly a luxury tax&lt;/strong&gt;-a massive up-front cost in complexity, ops, debugging, and velocity that 90%+ of startups can't afford until way later (if ever). Monoliths, especially well-modularized ones, keep winning at actual scale for most companies that aren't Netflix or Amazon.&lt;/p&gt;
&lt;h2&gt;The tax breakdown: What you're actually paying for&lt;/h2&gt;
&lt;p&gt;You don't get "scale" for free with microservices. You pay in blood:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deployment &amp;amp; ops hell&lt;/strong&gt; - Separate repos/services = separate CI/CD pipelines, separate deploys, separate monitoring, separate rollbacks. One tiny auth service down? Good luck tracing why your whole app is 500-ing. A monolith? &lt;code&gt;git push&lt;/code&gt; - build - deploy once. Velocity stays high when your team is 5–15 people.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Network tax everywhere&lt;/strong&gt; - In-process function calls become 10–100 ms RPCs (or worse with retries/backoffs). Latency compounds. Debugging distributed traces feels like archaeology. Monolith? Method call is microseconds, stack traces are instant.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data consistency roulette&lt;/strong&gt; - Each service wants its own DB (cool story). Now you have eventual consistency, sagas, 2PC nightmares, or duplicated data. Monolith shares one DB transaction-boom, ACID for free where it matters.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Coordination overhead&lt;/strong&gt; - API contracts, versioning, backward compat, service discovery, circuit breakers, rate limiting per service. All that boilerplate before you ship your first feature. Monolith? Just refactor a module and commit.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cost tax&lt;/strong&gt; - More containers/pods = more cloud bill (even tiny ones eat RAM/CPU overhead). Orchestration (K8s) needs dedicated SRE time. Startups pay engineers to fight infra instead of building product.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Real numbers from trenches (anecdotal but repeated across Reddit/HN/startup war stories): teams that go micro early often see 2–5× slower iteration speed until they hit 50+ engineers. By then, many are already dead or pivoted.&lt;/p&gt;
&lt;h2&gt;Who actually wins with monoliths at "scale"?&lt;/h2&gt;
&lt;p&gt;Not just tiny MVPs-these are production beasts handling real traffic:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stack Overflow&lt;/strong&gt; - Still a modular monolith (ASP.NET). Millions of users, high traffic, legendary performance. They vertical-scale + optimize queries/caching and laugh at microservice FOMO.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Shopify&lt;/strong&gt; - Ruby monolith for core (they extract when needed, but the heart stays monolithic). Handles Black Friday insanity without rewriting everything.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Basecamp&lt;/strong&gt; - Rails monolith forever. Deliberately simple, scales to enterprise customers without distributed drama.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Many "successful" unicorns pre-unicorn&lt;/strong&gt; - Almost all start monolith (Shopify, Basecamp, early Stripe vibes, plenty of SaaS quietly). They extract services surgically &lt;em&gt;only when pain is proven&lt;/em&gt; (e.g., one hot path kills perf - pull it out).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Even big players backtrack: Amazon Prime Video famously ditched microservices/serverless for a monolith-ish approach on some workloads because the overhead was killing cost/efficiency at real scale.&lt;/p&gt;
&lt;h2&gt;The honest startup playbook&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Start monolithic&lt;/strong&gt; (modular from day 1-clean boundaries, dependency injection, bounded contexts). Ship fast, validate idea, get paying users.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scale vertically first&lt;/strong&gt; - Bigger instances, read replicas, caching (Redis), query optimization, CDNs. Handles 100k–1M+ users for most SaaS/apps without drama.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Extract only when you have concrete pain&lt;/strong&gt; -  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team coordination hell? (multiple teams blocked) - extract team-owned services.  &lt;/li&gt;
&lt;li&gt;One component eats all resources? - pull it out (e.g., reporting, image processing).  &lt;/li&gt;
&lt;li&gt;Need independent deploys/tech stacks? - micro now makes sense.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Prefer modular monolith&lt;/strong&gt; - Hexagonal/ports-and-adapters, domain-driven design modules. Refactor feels like surgery, not heart transplant. When extraction time comes, boundaries already exist.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Kill the FOMO&lt;/strong&gt; - "But Netflix/Amazon/Uber!" - They had 1000+ engineers and billions in revenue before microservices became mandatory. You're not them (yet). Premature microservices is how you turn a $2M seed into $1M infra bill and zero product.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Bottom line in 2025: &lt;strong&gt;Monoliths aren't dead-they're the cheat code for velocity and survival.&lt;/strong&gt; Microservices are a luxury tax you pay when you have luxury problems (big teams, uneven scaling, org-scale coordination). Most startups never reach that luxury. They die trying to afford it.&lt;/p&gt;
&lt;p&gt;The ones that win? They ship relentlessly in a monolith until the monolith screams for mercy-then (and only then) they pay the tax.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Stop Putting Business Logic in Django Views and Serializers</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/bc771e.html"/>
    <id>https://nehem.dev/bc771e.html</id>
    <published>2025-04-08T00:00:00+10:00</published>
    <updated>2025-04-08T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Why Django business logic belongs in plain service functions, not views or DRF serializers, with a before/after order example and tests that need no HTTP.</summary>
    <category term="Django"/><category term="Architecture"/><category term="Testing"/><category term="DRF"/>
    <content type="html">&lt;p&gt;Open any Django codebase that's older than eighteen months and find the most important thing the business does. Placing an order. Approving a loan. Issuing a refund. Now find where that logic lives. Nine times out of ten it's smeared across a view, a serializer's &lt;code&gt;create()&lt;/code&gt;, two model &lt;code&gt;save()&lt;/code&gt; overrides and a &lt;code&gt;post_save&lt;/code&gt; signal somebody added on a Friday.&lt;/p&gt;
&lt;p&gt;Here's the position: &lt;strong&gt;views and serializers are adapters, not homes.&lt;/strong&gt; A view translates HTTP into a function call. A serializer translates JSON into Python values. Neither should know what an order &lt;em&gt;is&lt;/em&gt;. Put the rules in plain Python functions that take plain arguments, and your app gets easier to test, easier to read and much easier to change.&lt;/p&gt;
&lt;h2&gt;How it goes wrong&lt;/h2&gt;
&lt;p&gt;Nobody decides to put business logic in a serializer. It happens because Django and DRF make the wrong place the convenient place:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;ModelSerializer.create()&lt;/code&gt; is right there.&lt;/strong&gt; It already has validated data and a model. Adding "and also charge the card" is one line.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Views have the request.&lt;/strong&gt; The user, the headers, the session. So the logic that needs the user ends up next to the request.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Signals look clean.&lt;/strong&gt; Until nobody can tell you what happens when an &lt;code&gt;Order&lt;/code&gt; is saved, because the answer is spread over four apps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fat models sound like good advice.&lt;/strong&gt; And they are, for logic about one row. They fall apart when a use case touches five models and an external API.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The result is logic you can only reach through HTTP. Want to place an order from a management command, a Celery task or a data migration? You either fake a request or copy the code. Both are bad.&lt;/p&gt;
&lt;h2&gt;Before: the serializer that does everything&lt;/h2&gt;
&lt;p&gt;This is a composite of code I've seen many times. It works. It's also a trap.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;OrderSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelSerializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;OrderItemSerializer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;many&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;Meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;
        &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"items"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;read_only_fields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;validated_data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;validated_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"items"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;
        &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"product"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stock&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"quantity"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ValidationError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Out of stock"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stock&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"quantity"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;OrderItem&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                     &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"quantity"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                                     &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"quantity"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;
        &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;stripe&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PaymentIntent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"aud"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                    &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stripe_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;send_mail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Order received"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Order &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Count the problems:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;No transaction.&lt;/strong&gt; If the payment call fails, you've already decremented stock and created a half-built order.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A race on stock.&lt;/strong&gt; Two requests read &lt;code&gt;stock = 1&lt;/code&gt;, both pass the check, both save &lt;code&gt;0&lt;/code&gt;. You've sold the same item twice.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The email goes out before anything is committed.&lt;/strong&gt; The customer gets "Order received" for an order that may roll back.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The rules are tied to &lt;code&gt;self.context["request"]&lt;/code&gt;.&lt;/strong&gt; You can't call this without an HTTP request, or a fake one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A &lt;code&gt;ValidationError&lt;/code&gt; for a business rule.&lt;/strong&gt; "Out of stock" isn't malformed input. It's a domain outcome, and it deserves its own type.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testing it means testing everything.&lt;/strong&gt; To check the stock rule you need a client, auth, JSON and a mocked Stripe.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;After: a service function&lt;/h2&gt;
&lt;p&gt;Make a &lt;code&gt;services.py&lt;/code&gt; (or &lt;code&gt;orders/services/place_order.py&lt;/code&gt; when it grows) with a plain function. Keyword-only arguments, explicit dependencies, a clear return type.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# orders/services.py&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;dataclasses&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;decimal&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;django.db&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;transaction&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;django.db.models&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;F&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;orders.models&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OrderItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;orders.notifications&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;send_order_received&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;OutOfStock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ne"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="fm"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;super&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="fm"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Product &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; is out of stock"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;


&lt;span class="nd"&gt;@dataclass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frozen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;LineRequest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;place_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;LineRequest&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;payments&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;transaction&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="n"&gt;ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="n"&gt;locked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select_for_update&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pk__in&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"pk"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;locked&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stock&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;OutOfStock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;stock&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;F&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"stock"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;OrderItem&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                     &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                     &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;

        &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;
        &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;update_fields&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;payments&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;charge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;reference&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;transaction&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;on_commit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;send_order_received&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;What changed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;transaction.atomic()&lt;/code&gt;&lt;/strong&gt; wraps the whole use case. Any exception, including a payment failure, rolls back the stock and the order.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;select_for_update()&lt;/code&gt;&lt;/strong&gt; locks the product rows, in a stable order, so two orders for the last item can't both win.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;F("stock") - quantity&lt;/code&gt;&lt;/strong&gt; does the decrement in the database rather than in Python.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;transaction.on_commit()&lt;/code&gt;&lt;/strong&gt; sends the email only once the order really exists.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;payments&lt;/code&gt; is passed in.&lt;/strong&gt; In production it's a thin wrapper around your provider. In tests it's a fake. No &lt;code&gt;mock.patch&lt;/code&gt; on a module path.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;OutOfStock&lt;/code&gt; is a real exception.&lt;/strong&gt; The caller decides what it means: a 409 for the API, a message in the admin, a log line in a batch job.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One honest caveat: charging a card inside a database transaction holds row locks while you wait on a network call. For a low-volume shop that's fine. At scale you'd split it into "reserve, then charge, then confirm" steps. The point is that once the logic lives in one function, that refactor is one file, not a hunt through serializers and signals.&lt;/p&gt;
&lt;h2&gt;The view and serializer get boring&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;PlaceOrderInput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serializers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Serializer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;LineInput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;many&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;PlaceOrderView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;APIView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;permission_classes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;IsAuthenticated&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PlaceOrderInput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_valid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raise_exception&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;lines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;LineRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;validated_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"items"&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;place_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="n"&gt;payments&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;get_payment_gateway&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;OutOfStock&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"out_of_stock"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"product_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
                &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HTTP_409_CONFLICT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;OrderOutput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HTTP_201_CREATED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The serializer checks shape: is &lt;code&gt;quantity&lt;/code&gt; an integer, is &lt;code&gt;product_id&lt;/code&gt; present. The view maps HTTP to a call and exceptions to status codes. That's all either of them should ever do. Boring is the goal.&lt;/p&gt;
&lt;h2&gt;Testing without HTTP&lt;/h2&gt;
&lt;p&gt;Now the important rules are tested directly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;FakePayments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="fm"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fail&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;charges&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;charge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reference&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="ne"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"card declined"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;charges&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;test_payment_failure_rolls_back_stock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_with_stock&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;product_with_stock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stock&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"10.00"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pytest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;raises&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ne"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;place_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;LineRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
                    &lt;span class="n"&gt;payments&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;FakePayments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refresh_from_db&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stock&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;No client, no JSON, no auth setup, no patching. The test reads like the rule it protects. Keep one or two API tests per endpoint to check the wiring, and put the volume of your tests at the service level.&lt;/p&gt;
&lt;h2&gt;Rules I actually follow&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;One use case, one function.&lt;/strong&gt; &lt;code&gt;place_order&lt;/code&gt;, &lt;code&gt;cancel_order&lt;/code&gt;, &lt;code&gt;refund_order&lt;/code&gt;. Name them after what the business says, not after HTTP verbs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Keyword-only arguments.&lt;/strong&gt; &lt;code&gt;place_order(customer=..., lines=...)&lt;/code&gt; can't be called with arguments in the wrong order.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Services take values, not requests.&lt;/strong&gt; Pass &lt;code&gt;request.user&lt;/code&gt;, never &lt;code&gt;request&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads can be selectors.&lt;/strong&gt; A &lt;code&gt;selectors.py&lt;/code&gt; with query functions keeps complex querysets out of views too. Simple &lt;code&gt;Model.objects.filter()&lt;/code&gt; calls in a view are fine. Don't build ceremony for one-liners.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Models keep row-level logic.&lt;/strong&gt; &lt;code&gt;order.is_refundable()&lt;/code&gt; belongs on the model. "Refund this order, restock, notify the warehouse and reverse the charge" does not.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No signals for business flow.&lt;/strong&gt; Signals are for decoupled side concerns like cache busting. If it's part of the use case, call it explicitly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don't build a framework.&lt;/strong&gt; No abstract base &lt;code&gt;Service&lt;/code&gt; class, no command bus, no dependency injection container. Functions and modules. Python already has them.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;When this is overkill&lt;/h2&gt;
&lt;p&gt;A CRUD admin over a few tables doesn't need a service layer. If a &lt;code&gt;ModelViewSet&lt;/code&gt; really is the whole feature, enjoy it. The moment an endpoint does more than save what it was given, such as touching a second model, calling an external API or enforcing a rule the business cares about, move it into a function. It takes ten minutes now, or a week later.&lt;/p&gt;
&lt;h2&gt;Bottom line&lt;/h2&gt;
&lt;p&gt;Django gives you an excellent ORM and a decent request cycle. It doesn't give you a place for your domain, so you have to make one. &lt;strong&gt;Thin views, dumb serializers, plain service functions.&lt;/strong&gt; Your rules become callable from anywhere, testable in milliseconds and readable by the next developer, who is usually you, six months from now, at 11 pm, during an incident.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>The Problems with Django REST Framework</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/1b6985.html"/>
    <id>https://nehem.dev/1b6985.html</id>
    <published>2025-02-02T00:00:00+10:00</published>
    <updated>2025-02-02T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>A critique of Django REST Framework: how it inherits Django Forms' design, its boilerplate and performance costs, the one thing it gets right, and why to move on.</summary>
    <category term="django"/><category term="rest"/><category term="api"/><category term="drf"/>
    <content type="html">&lt;p&gt;Let's start by burying REST itself real quick, because DRF is built on the rotting foundation of a 2000s architectural cargo cult that's been wheezing since &lt;a href="https://graphql.org/"&gt;GraphQL&lt;/a&gt;, &lt;a href="https://grpc.io/"&gt;gRPC&lt;/a&gt;, tRPC, and even plain JSON-RPC started laughing at it.&lt;/p&gt;
&lt;p&gt;RESTful, the idea was great in 2006 when &lt;a href="https://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm"&gt;Roy Fielding&lt;/a&gt; was drunk on HTTP verbs and everyone pretended &lt;a href="https://en.wikipedia.org/wiki/HATEOAS"&gt;HATEOAS&lt;/a&gt; was gonna save, decades later it's mostly a theater:  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Over-fetching/under-fetching hell  &lt;/li&gt;
&lt;li&gt;N+1 query nightmares hidden behind "pagination"  &lt;/li&gt;
&lt;li&gt;Verb gymnastics for what should just be RPC calls  &lt;/li&gt;
&lt;li&gt;Versioning nightmares because you can't change anything useful without breaking clients  &lt;/li&gt;
&lt;li&gt;Idempotent PUT/DELETE promises that fall apart the second you touch real business logic  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;REST isn't a protocol, it's a style guide nobody follows consistently. Most REST APIs are just RPC dressed in HTTP clothing with extra steps. We could roast REST for a whole post (and we should), but let's save the funeral for later. Today the victim is DRF, the greedy middle child that tried to turn Django into a REST cosplay while dragging the corpse of Django forms/templates into the API era.&lt;/p&gt;
&lt;h2&gt;The original sin: DRF is literally Django Forms 2.0 but for JSON&lt;/h2&gt;
&lt;p&gt;Django had this beautiful (for 2005) story:  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Models - Forms - Views - Templates  &lt;/li&gt;
&lt;li&gt;ModelForm auto-magics validation + rendering  &lt;/li&gt;
&lt;li&gt;Clean, batteries-included, beginner-friendly magic  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then mobile/SPA/React/Vue/Flutter happened. Templates died. Forms became irrelevant for anything except admin/internal tools. The backend's job shrank to "give me JSON, validate it, save it, bye."&lt;/p&gt;
&lt;p&gt;Instead of letting Django evolve into a clean, API-first beast, someone said:&lt;br /&gt;
"Wait… what if we just slap the exact same form/model magic onto APIs? Call it Serializer instead of Form! Call it ViewSet instead of View! Reuse all the terminology so nobody has to learn anything new!"&lt;/p&gt;
&lt;p&gt;Boom, DRF was born. Greedy as hell. It didn't innovate; it ported dying concepts to a new world and pretended it was progress.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ModelSerializer&lt;/strong&gt; = ModelForm but JSON  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serializer&lt;/strong&gt; = Form  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validation&lt;/strong&gt; = same clean/validate_{field} hooks  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;to_representation&lt;/strong&gt; = basically render_to_response but manual  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;They didn't simplify APIs. They forced every Django dev to keep thinking in form-based, server-rendered mental models when the client is now the one doing rendering/validation/display. The backend should be dumb, stateless, JSON-in/JSON-out. DRF makes it feel like you're still building a monolith MPA with extra steps.&lt;/p&gt;
&lt;h2&gt;The boilerplate apocalypse&lt;/h2&gt;
&lt;p&gt;You want a simple CRUD for a model? In plain Django + JsonResponse:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;thing_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'GET'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;things&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Thing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;JsonResponse&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s1"&gt;'things'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;things&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;())},&lt;/span&gt; &lt;span class="n"&gt;safe&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;
        &lt;span class="c1"&gt;# parse, validate, save, return 3-20 lines max&lt;/span&gt;
        &lt;span class="o"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;20–40 lines tops for basic endpoints. Readable. Controllable. No magic.&lt;/p&gt;
&lt;p&gt;DRF version?  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Serializer class  &lt;/li&gt;
&lt;li&gt;Meta fields/exclude/depth/nested hell  &lt;/li&gt;
&lt;li&gt;ViewSet (or GenericAPIView + mixins)  &lt;/li&gt;
&lt;li&gt;Router registration  &lt;/li&gt;
&lt;li&gt;Override get_queryset, get_serializer_class, perform_create, etc.  &lt;/li&gt;
&lt;li&gt;Custom actions @action(detail=True)  &lt;/li&gt;
&lt;li&gt;Throttling classes, permission classes, pagination classes  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Suddenly your "simple" API requires 300+ lines across 7 files for what should be a function. Inheritance chains so deep you need a map to debug why create() is calling update() sideways. New devs stare and go "this is Python?" Nope, it's DRF cult initiation.&lt;/p&gt;
&lt;p&gt;It's not beginner-friendly, it's Django-expert-only. New devs look at DRF code and think "this framework is fighting me." Because it is. The so called magic only works if you surrender to the DRF way. Deviate once (custom validation, non-model data, weird nesting) and you're overriding half the base classes anyway.&lt;/p&gt;
&lt;h2&gt;Performance? What performance?&lt;/h2&gt;
&lt;p&gt;ModelSerializer is infamous for being glacially slow. Benchmarks show it 300–400× slower than plain dict conversion on simple objects. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ModelSerializer dynamically builds fields every request - perf hit on hot paths  &lt;/li&gt;
&lt;li&gt;Deep nesting + source= tricks = N+1 + slow serialization  &lt;/li&gt;
&lt;li&gt;High-cardinality stuff (like dynamic fields) makes caching/debugging hell  &lt;/li&gt;
&lt;li&gt;ViewSets encourage god-classes with 10+ methods  &lt;/li&gt;
&lt;li&gt;Third-party packages? Either you lock into DRF ecosystem forever or you rewrite  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tom Christie (DRF creator) himself warned: &lt;a href="https://hakibenita.com/django-rest-framework-slow"&gt;avoid serializers in perf-critical paths&lt;/a&gt;. Yet DRF pushes them as default. In 2026, when your API hits 1k+ req/s, you're profiling and cursing because DRF decided "magic" &amp;gt; speed.&lt;/p&gt;
&lt;p&gt;Meanwhile, alternatives like &lt;a href="https://django-ninja.dev/"&gt;Django Ninja&lt;/a&gt; or plain views + &lt;a href="https://docs.pydantic.dev/"&gt;Pydantic&lt;/a&gt;/&lt;a href="https://fastapi.tiangolo.com/"&gt;FastAPI&lt;/a&gt;-style type hints let you write functions that look like functions. Async support? Native in Ninja/FastAPI. Auto OpenAPI? Built-in without extra config. DRF feels like it's still stuck in 2015 sync land.&lt;/p&gt;
&lt;h2&gt;Maintenance &amp;amp; stagnation&lt;/h2&gt;
&lt;p&gt;Last major release? 3.14 in late 2022. Anything since 3.15 is minor fixes which are basically pushing DRF into life support.  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No real async love, still sync-first, async hacks feel bolted-on. While Django grew async views/ORM, DRF stayed in sync land  &lt;/li&gt;
&lt;li&gt;Community shifting hard: Reddit/HN/Upwork points the trend of moving to FastAPI / Django Ninja for new projects  &lt;/li&gt;
&lt;li&gt;Django Ninja / FastAPI give auto OpenAPI, Pydantic validation, type hints, blazing perf, native async-DRF feels like a Windows XP app next to them  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Django core in 2025+ basically said "REST? Not our problem—use third-party." And people still defend DRF as "batteries-included" when it's the opposite: extra dependency that locks you out of modern Python niceties.&lt;/p&gt;
&lt;h2&gt;More nails in the coffin&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ecosystem lock-in trap&lt;/strong&gt; - DRF plugins everywhere, but deviate once (custom auth, weird nesting, non-CRUD) and you're rewriting base classes. Good luck migrating later.  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Documentation overwhelm&lt;/strong&gt; - Official docs are a wiki maze. Click one link - 47 new concepts - infinite tabs. Beginners get lost for weeks.  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ViewSet god-classes&lt;/strong&gt; - One class handles list/create/retrieve/update/partial_update/delete + 10 custom actions. Breaks single-responsibility so hard it's comical.  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pagination &amp;amp; throttling good? Sure&lt;/strong&gt; - But you can steal throttling in 50 lines. Don't need the whole framework for it.  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Community burnout signal&lt;/strong&gt; - Threads everywhere: "DRF in 2025? Why still third-party for batteries-included Django?" "Moved to Ninja—never looking back." "DRF feels bloated/clunky/stale."  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The one good thing (because fairness)&lt;/h2&gt;
&lt;p&gt;Throttling/rate-limiting in DRF is genuinely clean. ScopedThrottler, UserRateThrottle, etc., solid. If I ever touch DRF again, it's probably just to steal the throttling middleware and throw the rest away.&lt;/p&gt;
&lt;p&gt;But that's it. Everything else? You can roll in 20 lines of if/else + JsonResponse + basic validation. DRF is overkill for 80% of APIs and actively harmful for the rest.&lt;/p&gt;
&lt;h2&gt;Verdict 2025: Move on&lt;/h2&gt;
&lt;p&gt;DRF was peak 2015: when REST was king and Django needed API lipstick. In 2025 it's a luxury tax on velocity, perf, and sanity. Here is how to move on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For simple APIs use Plain views + JsonResponse &lt;/li&gt;
&lt;li&gt;For complex usecases &amp;amp; API docs stick to Django Ninja (FastAPI syntax + Django ORM/admin) or full FastAPI  &lt;/li&gt;
&lt;li&gt;For existing legacy projects, sure, maintain it. But start writing newer endpoints and versions using Django Ninja or FastAPI&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Whoever starts a greenfield project with full DRF in 2025 is either trying to get paid by the line of code or hasn't profiled serialization lag yet, Or hasn't discovered they can just write functions that return JSON  &lt;/p&gt;
&lt;p&gt;Rest in pieces, DRF. You overstayed your welcome. You were never necessary.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Why is Python unsuitable as a mobile application development language</title>
    <link rel="alternate" type="text/html" href="https://nehem.dev/17c24e.html"/>
    <id>https://nehem.dev/17c24e.html</id>
    <published>2016-07-16T00:00:00+10:00</published>
    <updated>2016-07-16T00:00:00+10:00</updated>
    <author><name>Nehemiah Jacob</name><uri>https://nehem.dev/</uri></author>
    <summary>Why Python missed the mobile era: the decade-long Python 2 to 3 transition (2008–2018) slowed libraries and innovation just as web and mobile took off.</summary>
    <category term="python"/><category term="mobiledevelopment"/><category term="python3"/>
    <content type="html">&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt;&lt;br /&gt;
PSF made migrating to Python 3 as priority to the community, which slowed down pythonic innovations during 2006-2016, which was the defining moment in history of modern Web technologies &amp;amp; Mobile Technologies.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Root Cause: The Launch of Python 3&lt;/strong&gt;&lt;br /&gt;
Python 3 was launched in 2008 and it didn't take off as quick as PSF expected. In order to overcome the gravity of Python 2.7 they had to deliberately kill Python 2 using numerous strategies, the main strategy is stop adding new features to Python 2.7 (a.k.a simply abandoning the world’s most popular dynamically typed language of that time).&lt;/p&gt;
&lt;p&gt;On the contrast there were various communities that kept back-porting new Python 3 features to Python 2.7 which further slowed down Python 3 adaption. So they have to press the kill switch by declaring as Python 2.7 as legacy despite the consequences, you have to remember Python 2 was having the most modern feature set of that time compared to C, C++, Perl, Java etc. There was nothing legacy about it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Nightmare of the 10-Year Transition Period (Roughly 2008–2018, with Full EOL in 2020)&lt;/strong&gt;&lt;br /&gt;
Those 10 years transition period was a great nightmare at the worst, communities(esp library owners) were forced to keep their code compatible with both 2 &amp;amp; 3, which caused the testing cost to sky-rocket, this impacted developers' freedom of thinking, free flow of ideas etc. What once was a simple and elegant language suddenly became a liability because you were ‘expected’ to write in both Python 2 &amp;amp; 3. Productivity was the original thing that made Python popular which wasn’t the experience during the transition.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Emergence of "Python X"&lt;/strong&gt;&lt;br /&gt;
In the whole 10 years Pytonists were neither coding in Python 2 nor in Python 3 there were coding an in between language(Python X) filled with hodgepodge hacks here and there without clear documentation, there were enough official guidelines for porting to Python 3 but not for maintaining the code in Python 2 &amp;amp; 3 since they genuinely didn’t expect such a problem would arise.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Challenges for Library Maintainers vs End Users&lt;/strong&gt;&lt;br /&gt;
Porting from 2 -&amp;gt; 3 was easy for an end user, but as a library owner maintaining for 2 &amp;amp; 3 was a nightmare. Many libraries were simply abandoned.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Impact on Learning and Resources&lt;/strong&gt;&lt;br /&gt;
Learning experience of Python via internet met the all time low, Googling questions would lead to blog posts and Stackoverflow which had snippets for Python 2. Every archived knowledge (even as simple as ‘sorting a dict’) had to be re-written once again for Python 3 and tagged with proper Python versions. This part caused great confusion for newbies and made JavaScript as a possible first language. Most of the Stack overflow answers stopped working suddenly since they were originally written for Python 2. New answers were not written as often asking same question for Python 3 will cause the question to be down-voted, locked &amp;amp; deleted or marked as duplicate by less informed random moderators who weren’t aware of this Python specific issue, also Stackoverflow was not designed to converse around questions of multiple versions of a same programming language.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Decline of GUI and Cross-Platform Tools&lt;/strong&gt;&lt;br /&gt;
Great tools like WxPython, PyQT, PySide became old &amp;amp; oblivious because 'Python 3' was suddenly imposed as priority. (Imagine you as a open source developer, suddenly PSF/community declares your work as deprecated, you might lose the spirit, you wouldn’t care much, that’s what happened to 100s of libraries, great libraries were declared legacy even thought they were working fine, just because PSF wanted to push Python3. It wasn’t indeed to kill 100s libraries just because the author didn’t have time/interest in porting(a.k.a maintaining in 2&amp;amp;3)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Hidden Cost for Library Owners&lt;/strong&gt;&lt;br /&gt;
The experience of porting to Python 3 was not as easy as you imagine or the PSF thought. For a developer it may be simply moving to 2 to 3. But for a library owner it is all about ‘maintaining’ 2 and 3 at the same time, with added testing cost.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Lack of Innovation During a Critical Decade&lt;/strong&gt;&lt;br /&gt;
Thus, everyone witnessed that during 2006 to 2016 there were no innovation or ground breaking things happened in Python's world, they were busy in solving Python 3 transition (porting &amp;amp; maintaining) and releasing small features by barely keeping the heads on the water. However we all knew 2006-2016 was the defining moment of web technology and mobile technologies.&lt;/p&gt;
&lt;p&gt;JavaScript started dominating everywhere with revolutionary frameworks and new ways of doing things(like non-blocking IO, web sockets etc) while Python community were busting their head around in cleaning the mess. Python 3 is good but wrongly timed. This is why Python doesn't have a suitable cross platform framework for mobile.&lt;/p&gt;
&lt;p&gt;While C# has Xamarin, JS has Cordova &amp;amp; Titanium, even Lua has Corona, but Python equivalents Kivy and PyQT do keep stalling.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Python's Strengths in Other Domains&lt;/strong&gt;&lt;br /&gt;
However, Python will have a strong future on the machine learning, NLP, statistical and scientific computing. So to repeat the point Python lost whatever it deserved from 2006–2016, but it will dominate what it really deserves from 2016–2026, unfortunately mobile development(front-end) isn’t one of them.&lt;/p&gt;</content>
  </entry>
</feed>
