[{"data":1,"prerenderedAt":343},["ShallowReactive",2],{"tag-labels":3,"site-header":4,"article-stock-says-four-the-shelf-says-six-en":75},{},{"featuredPost":5,"navigations":29},{"id":6,"title":7,"title_id":8,"slug":9,"excerpt":10,"excerpt_id":11,"has_translation":12,"published_at":13,"reading_time":14,"hidden_from_listing":15,"tags":16,"thumbnail_image":21,"og_image":22,"series":23,"authors":28},110,"When You Pick a Framework Just to Look Different","Ketika Pilih Framework Cuma Biar Kelihatan Beda","ketika-pilih-framework-cuma-biar-kelihatan-beda","The last time you chose a new framework or library, was it because your problem needed that tool, or because it sounded cool and few people around you were using it? That question is uncomfortable. Technology decisions are often made for reasons that never appear in any technical document.","Terakhir kali kamu milih framework atau library baru, itu karena masalahmu butuh alat itu, atau karena alatnya kedengaran keren dan belum banyak yang pakai? Pertanyaan ini nggak enak dijawab. Soalnya keputusan teknologi sering diambil dengan alasan yang nggak pernah ditulis di dokumen teknis mana pun.",true,"2026-10-06T15:25:21.000Z",5,false,[17,18,19,20],"karier","framework","opini","pengalaman",null,"\u002Fog\u002Fketika-pilih-framework-cuma-biar-kelihatan-beda.png",{"id":24,"title":25,"title_id":26,"slug":27},9,"Articles","Artikel","all",[],[30,49,70],{"collection":31,"item":32},"series",{"__typename":31,"title":25,"title_id":26,"slug":27,"children_series":33},[34,38,42,46],{"title":35,"title_id":36,"slug":37},"Artificial Intelligence","Kecerdasan Artifisial","kecerdasan-artifisial",{"title":39,"title_id":40,"slug":41},"Programming Fundamentals","Konsep Dasar Pemrograman","konsep-dasar-pemrograman",{"title":43,"title_id":44,"slug":45},"Algorithms and Data Structures","Algoritma dan Struktur Data","algoritma-struktur-data",{"title":47,"title_id":47,"slug":48},"LLM Systems","llm-systems",{"collection":31,"item":50},{"__typename":31,"title":51,"title_id":51,"slug":52,"children_series":53},"Tutorial","tutorial",[54,58,62,66],{"title":55,"title_id":56,"slug":57},"Learning Python","Belajar Python","belajar-python",{"title":59,"title_id":60,"slug":61},"Learning Go","Belajar Golang","belajar-golang",{"title":63,"title_id":64,"slug":65},"Learning Java","Belajar Java","belajar-java",{"title":67,"title_id":68,"slug":69},"Learning Pascal","Belajar Pascal","belajar-pascal",{"collection":31,"item":71},{"__typename":31,"title":72,"title_id":72,"slug":73,"children_series":74},"Lab","lab",[],{"article":76,"renderedBody":212,"renderedTakeaway":213,"latestArticles":214,"toc":326},{"id":77,"title":78,"title_id":79,"slug":80,"excerpt":81,"excerpt_id":82,"has_translation":12,"published_at":83,"reading_time":84,"hidden_from_listing":15,"tags":85,"thumbnail_image":21,"og_image":88,"series":89,"authors":204,"seoTitle":21,"seoDescription":21,"body_locale":207,"available_locales":208,"body":210,"takeway":211,"prerequisite":21},155,"Stock Says Four, the Shelf Says Six","Stok Bilang Empat, Raknya Bilang Enam","stock-says-four-the-shelf-says-six","Eleven stock messages, three of them out of order: the mug reads four while six sit on the shelf, and the cap counted at zero still sold. Five checks, one guard.","Sebelas pesan stok, tiga di antaranya datang tidak berurutan: mug terbaca empat sementara enam ada di rak, dan topi yang dihitung nol tetap terjual. Lima pemeriksaan, satu penjaga.","2026-11-13T01:00:00.000Z",6,[73,86,87],"event-driven","distributed-systems","\u002Fog\u002Fstock-says-four-the-shelf-says-six.png",{"id":90,"title":72,"title_id":72,"slug":73,"description":91,"description_id":92,"articles":93,"children_series":203,"parent_series":21},29,"Practice labs: work the problem first, then read the answer. Every lab ships with a repo you can clone, production-sized data, and a target you have to hit yourself. The write-up lives in this series too, and it only opens from the problem article.","Lab praktik: kerjakan masalahnya dulu, baru lihat jawabannya. Tiap lab punya repo yang bisa di-clone, data seukuran produksi, dan target yang harus kamu capai sendiri. Artikel jawabannya ada di seri ini juga, dan cuma bisa kamu buka dari artikel masalahnya.",[94,115,133,149,166,181,198],{"id":95,"title":96,"title_id":97,"slug":98,"excerpt":99,"excerpt_id":100,"has_translation":12,"published_at":101,"reading_time":14,"hidden_from_listing":15,"tags":102,"thumbnail_image":21,"og_image":106,"series":107,"authors":108},104,"N+1 Was Never the Bottleneck: 41 Queries Down to 2, Still One Second","Query-nya Tinggal 2, Tapi Response-nya Masih 1 Detik","query-tinggal-2-tapi-response-masih-1-detik","A feed endpoint that shows 20 posts takes a full second and hits the database with 41 queries. Apply the standard N+1 advice, get it down to 2 queries, and the latency does not move. This is that problem as it happened, plus the lab.","Endpoint feed yang cuma menampilkan 20 tulisan butuh satu detik, dan server database dihujani 41 query. Kamu kerjakan nasihat N+1 yang standar, query-nya turun jadi 2, dan latency-nya nggak bergerak. Ini versi \"apa adanya\" dari masalah itu, plus lab-nya.","2026-10-04T09:59:21.000Z",[103,104,105],"database","performance","backend","\u002Fog\u002Fquery-tinggal-2-tapi-response-masih-1-detik.png",{"id":90,"title":72,"title_id":72,"slug":73},[109],{"authors_id":110},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},1,"Daffa Izzuddin","izzudd","Writer",{"id":116,"title":117,"title_id":118,"slug":119,"excerpt":120,"excerpt_id":121,"has_translation":12,"published_at":122,"reading_time":123,"hidden_from_listing":15,"tags":124,"thumbnail_image":21,"og_image":128,"series":129,"authors":130},114,"One Payment, Four Ledger Rows: An Idempotency Lab","Saldo Naik Empat Kali untuk Satu Pembayaran","saldo-naik-empat-kali-untuk-satu-pembayaran","The code is not wrong and the gateway is not wrong, yet one payment shows up four times in the ledger. Guess why, then make `make check` green in the lab.","Kodenya nggak salah, dan gateway-nya juga nggak salah. Tapi satu pembayaran muncul empat kali di ledger. Coba tebak kenapa — lalu bikin `make check` hijau di lab-nya.","2026-10-11T13:45:00.000Z",4,[125,126,127,103,73],"idempotency","webhook","postgres","\u002Fog\u002Fsaldo-naik-empat-kali-untuk-satu-pembayaran.png",{"id":90,"title":72,"title_id":72,"slug":73},[131],{"authors_id":132},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":134,"title":135,"title_id":136,"slug":137,"excerpt":138,"excerpt_id":139,"has_translation":12,"published_at":140,"reading_time":141,"hidden_from_listing":15,"tags":142,"thumbnail_image":21,"og_image":144,"series":145,"authors":146},116,"The Webhook Arrived Late. The Reconciliation Job Had Already Run.","Webhook-nya Telat, Job Rekonsiliasinya Keburu Jalan","webhook-telat-job-rekonsiliasi-keburu-jalan","The webhook path is already idempotent. Then a morning reconciliation job appears, and one payment gets recorded twice from two paths that are both right. Guess where the key is wrong.","Jalur webhook sudah idempotent. Lalu ada job rekonsiliasi pagi, dan satu pembayaran tercatat dua kali dari dua jalur yang dua-duanya benar. Coba tebak kuncinya salah di mana.","2026-10-11T13:44:00.000Z",3,[125,143,126,127,73],"reconciliation","\u002Fog\u002Fwebhook-telat-job-rekonsiliasi-keburu-jalan.png",{"id":90,"title":72,"title_id":72,"slug":73},[147],{"authors_id":148},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":150,"title":151,"title_id":152,"slug":153,"excerpt":154,"excerpt_id":155,"has_translation":12,"published_at":156,"reading_time":123,"hidden_from_listing":15,"tags":157,"thumbnail_image":21,"og_image":161,"series":162,"authors":163},120,"Every Receipt in This Café Lists the Same Order","Tiap Nota di Kafe Ini Isinya Pesanan yang Sama","tiap-nota-isinya-pesanan-yang-sama","Every table's receipt holds the same items, and the total is Rp0, even though each table ordered exactly one thing. Guess why, then make `make check` green. A Python scope and mutation lab.","Nota tiap meja isinya sama semua, dan totalnya Rp0 — padahal tiap meja cuma pesan satu barang. Coba tebak kenapa.","2026-10-11T23:00:15.000Z",[158,159,160,73],"python","scope","mutasi","\u002Fog\u002Ftiap-nota-isinya-pesanan-yang-sama.png",{"id":90,"title":72,"title_id":72,"slug":73},[164],{"authors_id":165},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":167,"title":168,"title_id":169,"slug":170,"excerpt":171,"excerpt_id":172,"has_translation":12,"published_at":156,"reading_time":123,"hidden_from_listing":15,"tags":173,"thumbnail_image":21,"og_image":176,"series":177,"authors":178},122,"A Script That Cannot Say Where It Went Wrong","Script yang Nggak Bisa Bilang di Mana Salahnya","script-yang-tidak-bilang-di-mana-salahnya","A script that stops at the first bad line reports only part of the problem. This is what shows up on screen right now.","Script yang berhenti di baris jelek pertama cuma melaporkan sebagian masalah yang ada. Ini yang muncul di layar sekarang.",[158,174,175,73],"error-handling","validasi","\u002Fog\u002Fscript-yang-tidak-bilang-di-mana-salahnya.png",{"id":90,"title":72,"title_id":72,"slug":73},[179],{"authors_id":180},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":182,"title":183,"title_id":184,"slug":185,"excerpt":186,"excerpt_id":187,"has_translation":12,"published_at":188,"reading_time":141,"hidden_from_listing":15,"tags":189,"thumbnail_image":21,"og_image":193,"series":194,"authors":195},141,"A 6,000-Token Handbook and a 0% Cache Hit Rate","Buku Panduan 6.000 Token dan Hit Rate Cache 0%","cache-hit-rate-zero","Twenty-four turns, caching switched on, and a bill 21% higher than running with no cache at all. A support agent whose prompt looks static, and the three lines that quietly change it every turn.","Dua puluh empat giliran, caching menyala, dan tagihan 21% lebih tinggi daripada menjalankannya tanpa cache sama sekali. Agen support yang prompt-nya kelihatan statis, dan tiga baris yang diam-diam mengubahnya tiap giliran.","2026-11-08T01:20:00.000Z",[73,190,191,192],"llm","cache","api","\u002Fog\u002Fcache-hit-rate-zero.png",{"id":90,"title":72,"title_id":72,"slug":73},[196],{"authors_id":197},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":77,"title":78,"title_id":79,"slug":80,"excerpt":81,"excerpt_id":82,"has_translation":12,"published_at":83,"reading_time":84,"hidden_from_listing":15,"tags":85,"thumbnail_image":21,"og_image":88,"series":199,"authors":200},{"id":90,"title":72,"title_id":72,"slug":73},[201],{"authors_id":202},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},[],[205],{"authors_id":206},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},"en",[207,209],"id","\nA cap sits on a shelf, and the count a person made at 18:00 says zero. The system says -1. A sale arrived for an item the system already counted as zero, and the system accepted it. Two other products disagree with their shelves as well, and the program raised no error for any of the three. This lab reproduces all of it with one JSON file and `python3`. You clone `github.com\u002Fizzudd\u002Finva-lab`, open `0008.stale-writes\u002F`, and run three commands.\n\n## What the system records\n\nStart with `make demo`. It replays eleven messages and compares each product with the venue count, the number written down at 18:00.\n\n```plain\n$ make demo\npython3 scripts\u002Fdemo.py\nsku      system   venue   verdict\nCAP-03       -1       0   DIFFERENT\nMUG-01        4       6   DIFFERENT\nTEE-02       11       9   DIFFERENT\n\nmessages applied: 11, rejected: 0\nsales attempted on an empty shelf: 1\n```\n\nEvery product disagrees with its shelf count: MUG-01 is short by two, TEE-02 is high by two, and CAP-03 sits at -1.\n\nThe last two lines explain why nothing threw: the starter applied all eleven messages and rejected none, because it has no rule that refuses an update.\n\n## One queue, three wrong shelves\n\n`make run` replays the same eleven messages and prints one line per message, in arrival order. Each message carries `event_id`, `sku`, `type`, `quantity` and `event_time`, and the type is either `set` or `sale`. Three of the eleven arrive later than the event they describe.\n\n```plain\n$ make run\npython3 app\u002Fconsumer.py\n 1  e-101  MUG-01  set   12  @10:00  applied   MUG-01 = 12\n 2  e-104  MUG-01  set    6  @10:10  applied   MUG-01 = 6\n 3  e-102  MUG-01  set    4  @10:05  applied   MUG-01 = 4\n 4  e-201  TEE-02  set    9  @10:02  applied   TEE-02 = 9\n 5  e-203  TEE-02  set    9  @10:09  applied   TEE-02 = 9\n 6  e-202  TEE-02  set   11  @10:08  applied   TEE-02 = 11\n 7  e-301  CAP-03  set    3  @10:03  applied   CAP-03 = 3\n 8  e-302  CAP-03  sale   2  @10:07  applied   CAP-03 = 1\n 9  e-303  CAP-03  sale   1  @10:11  applied   CAP-03 = 0\n10  e-304  CAP-03  set    0  @10:12  applied   CAP-03 = 0\n11  e-305  CAP-03  sale   1  @10:14  applied   CAP-03 = -1\n\nsummary messages=11 applied=11 rejected=0\n```\n\nLine 3 is the bug. A message describing 10:05 lands after a message describing 10:10, and the consumer overwrites the row with whichever message arrived last. Read MUG-01 by arrival and you get 12, then 6, then 4. Read it by event time and the newest fact is the set to 6 at 10:10, which matches the shelf.\n\nTEE-02 has the same shape. The set to 11 describes 10:08, but it arrives after the set to 9 that describes 10:09, so line 6 wins over line 5. That count was accurate at 10:08, yet arriving after 10:09 lets an outdated reading overwrite a newer one.\n\nThe lab writes the arrival order into a JSON array, which is what makes the failure reproducible and free to run. A broker passes messages in delivery order rather than event order. Prefetch hands a message to a worker that is already busy, a retry sends one that was delivered before, and two consumers reading the same partition interleave. None of those is a fault in the broker.\n\nCAP-03 fails differently. It goes 3, then 1 after the first sale, then 0 after the second. The set to 0 keeps it there. Line 11 then takes it to -1, a state no shelf can be in. The summary at the bottom records all eleven updates as applied and zero rejected.\n\n## Your mission\n\n`scripts\u002Fcheck.py` holds five checks with one theme: a message about the past cannot overwrite the present, and a sale cannot take the shelf below zero.\n\n- **A:** every product's quantity matches the venue count.\n- **B:** an update older than the stored `event_time` is rejected, not applied.\n- **C:** no quantity is negative, and a sale on an empty shelf is refused.\n- **D:** a re-delivered event does not move the stock.\n- **E:** the consumer prints a summary whose counts are the ones it actually applied.\n\nA and C read `data\u002Fwarehouse.json`. B and D build their own small queues, so editing the data file cannot turn them green.\n\nA code review can read a loop that applies messages and find it reasonable. A check can feed it a late 3 after a 5 and show you the result.\n\n```plain\n$ make check\npython3 scripts\u002Fcheck.py\nFAIL  A  every product's quantity matches the venue count\n          CAP-03: system -1, venue 0; MUG-01: system 4, venue 6; TEE-02: system 11, venue 9\nFAIL  B  an update older than the stored event time is rejected\n          after 5 then a late 3 from an hour earlier: MUG-01 = 3, rejected 0\nFAIL  C  no quantity is negative, and a sale on an empty shelf is refused\n          one item, then two sales: CAP-03 = -1; negative rows in the replay: CAP-03: -1\nFAIL  D  a re-delivered event does not move the stock\n          with e-302 delivered twice: CAP-03 -3, MUG-01 4, TEE-02 11\nPASS  E  the consumer prints one summary line with the counts it actually applied\n          summary messages=11 applied=11 rejected=0\n\n1 of 5 checks passed\nmake: *** [Makefile:4: check] Error 1\n```\n\nYou start at 1 of 5. Check E passes because the summary accurately reports what the starter did: it applied every message.\n\n## What the answer changes\n\nThe answer is one file, `app\u002Fstore.py`, on the `solusi-0008-stale-writes` branch of the same repo. It adds three guards: skip any `event_id` already seen, reject any message older than the row's `event_time`, and refuse any sale larger than the current stock.\n\nWith those in place, all five checks pass and the consumer prints `summary messages=11 applied=8 rejected=3`. Three of eleven messages are refused. Two describe an older state, and one is a sale on an empty shelf.\n\nThe order of the guards matters for the counters. A message that is both a duplicate and stale is refused at the first one, so `applied` plus `rejected` still equals the number of messages read, whatever the data looks like.\n\nYou still have to write it. `HINTS.md` has three levels, and the first one only asks you to put two messages side by side.\n\n## What this lab does not do\n\n- No broker: the queue is a JSON array in arrival order, so prefetch and re-delivery are written into the file.\n- No concurrency: one process and one lane, because serializing messages would hide the bug rather than fix it.\n- No storefront push: the retry path from the original story is out of scope.\n- Two message types only: the vocabulary is `set` and `sale`, with no reservations, transfers, or returns.\n\nCheck which counts in your own system rely on arrival order when they should track event time.\n","- A message describing 10:05 can arrive after the one describing 10:10, and a consumer that applies what it reads keeps the older number.\n- Three of the eleven messages describe a state that was already gone: two older sets and one sale on a shelf counted at zero.\n- The starter applies all eleven and rejects none, which is why nothing throws and why the log looks tidy.\n- The answer adds three guards in order: a seen `event_id`, then an `event_time` newer than the row, then a sale the shelf can cover.\n- The answer ends at `applied=8 rejected=3` with five of five checks green, and `app\u002F` is the only directory that changes.\n- The lab has no broker and no concurrency, so the fix cannot be \"apply them in the right order\".","\u003Cp>A cap sits on a shelf, and the count a person made at 18:00 says zero. The system says -1. A sale arrived for an item the system already counted as zero, and the system accepted it. Two other products disagree with their shelves as well, and the program raised no error for any of the three. This lab reproduces all of it with one JSON file and \u003Ccode>python3\u003C\u002Fcode>. You clone \u003Ccode>github.com\u002Fizzudd\u002Finva-lab\u003C\u002Fcode>, open \u003Ccode>0008.stale-writes\u002F\u003C\u002Fcode>, and run three commands.\u003C\u002Fp>\n\u003Ch2 id=\"what-the-system-records\">What the system records\u003C\u002Fh2>\n\u003Cp>Start with \u003Ccode>make demo\u003C\u002Fcode>. It replays eleven messages and compares each product with the venue count, the number written down at 18:00.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20make%20demo%0Apython3%20scripts%2Fdemo.py%0Asku%20%20%20%20%20%20system%20%20%20venue%20%20%20verdict%0ACAP-03%20%20%20%20%20%20%20-1%20%20%20%20%20%20%200%20%20%20DIFFERENT%0AMUG-01%20%20%20%20%20%20%20%204%20%20%20%20%20%20%206%20%20%20DIFFERENT%0ATEE-02%20%20%20%20%20%20%2011%20%20%20%20%20%20%209%20%20%20DIFFERENT%0A%0Amessages%20applied%3A%2011%2C%20rejected%3A%200%0Asales%20attempted%20on%20an%20empty%20shelf%3A%201\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ make demo\u003C\u002Fspan>\npython3 scripts\u002Fdemo.py\nsku      system   venue   verdict\nCAP-03       -1       0   DIFFERENT\nMUG-01        4       6   DIFFERENT\nTEE-02       11       9   DIFFERENT\n\nmessages applied: 11, rejected: 0\nsales attempted on an empty shelf: 1\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Every product disagrees with its shelf count: MUG-01 is short by two, TEE-02 is high by two, and CAP-03 sits at -1.\u003C\u002Fp>\n\u003Cp>The last two lines explain why nothing threw: the starter applied all eleven messages and rejected none, because it has no rule that refuses an update.\u003C\u002Fp>\n\u003Ch2 id=\"one-queue-three-wrong-shelves\">One queue, three wrong shelves\u003C\u002Fh2>\n\u003Cp>\u003Ccode>make run\u003C\u002Fcode> replays the same eleven messages and prints one line per message, in arrival order. Each message carries \u003Ccode>event_id\u003C\u002Fcode>, \u003Ccode>sku\u003C\u002Fcode>, \u003Ccode>type\u003C\u002Fcode>, \u003Ccode>quantity\u003C\u002Fcode> and \u003Ccode>event_time\u003C\u002Fcode>, and the type is either \u003Ccode>set\u003C\u002Fcode> or \u003Ccode>sale\u003C\u002Fcode>. Three of the eleven arrive later than the event they describe.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20make%20run%0Apython3%20app%2Fconsumer.py%0A%201%20%20e-101%20%20MUG-01%20%20set%20%20%2012%20%20%4010%3A00%20%20applied%20%20%20MUG-01%20%3D%2012%0A%202%20%20e-104%20%20MUG-01%20%20set%20%20%20%206%20%20%4010%3A10%20%20applied%20%20%20MUG-01%20%3D%206%0A%203%20%20e-102%20%20MUG-01%20%20set%20%20%20%204%20%20%4010%3A05%20%20applied%20%20%20MUG-01%20%3D%204%0A%204%20%20e-201%20%20TEE-02%20%20set%20%20%20%209%20%20%4010%3A02%20%20applied%20%20%20TEE-02%20%3D%209%0A%205%20%20e-203%20%20TEE-02%20%20set%20%20%20%209%20%20%4010%3A09%20%20applied%20%20%20TEE-02%20%3D%209%0A%206%20%20e-202%20%20TEE-02%20%20set%20%20%2011%20%20%4010%3A08%20%20applied%20%20%20TEE-02%20%3D%2011%0A%207%20%20e-301%20%20CAP-03%20%20set%20%20%20%203%20%20%4010%3A03%20%20applied%20%20%20CAP-03%20%3D%203%0A%208%20%20e-302%20%20CAP-03%20%20sale%20%20%202%20%20%4010%3A07%20%20applied%20%20%20CAP-03%20%3D%201%0A%209%20%20e-303%20%20CAP-03%20%20sale%20%20%201%20%20%4010%3A11%20%20applied%20%20%20CAP-03%20%3D%200%0A10%20%20e-304%20%20CAP-03%20%20set%20%20%20%200%20%20%4010%3A12%20%20applied%20%20%20CAP-03%20%3D%200%0A11%20%20e-305%20%20CAP-03%20%20sale%20%20%201%20%20%4010%3A14%20%20applied%20%20%20CAP-03%20%3D%20-1%0A%0Asummary%20messages%3D11%20applied%3D11%20rejected%3D0\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ make run\u003C\u002Fspan>\npython3 app\u002Fconsumer.py\n 1  e-101  MUG-01  set   12  @10:00  applied   MUG-01 = 12\n 2  e-104  MUG-01  set    6  @10:10  applied   MUG-01 = 6\n 3  e-102  MUG-01  set    4  @10:05  applied   MUG-01 = 4\n 4  e-201  TEE-02  set    9  @10:02  applied   TEE-02 = 9\n 5  e-203  TEE-02  set    9  @10:09  applied   TEE-02 = 9\n 6  e-202  TEE-02  set   11  @10:08  applied   TEE-02 = 11\n 7  e-301  CAP-03  set    3  @10:03  applied   CAP-03 = 3\n 8  e-302  CAP-03  sale   2  @10:07  applied   CAP-03 = 1\n 9  e-303  CAP-03  sale   1  @10:11  applied   CAP-03 = 0\n10  e-304  CAP-03  set    0  @10:12  applied   CAP-03 = 0\n11  e-305  CAP-03  sale   1  @10:14  applied   CAP-03 = -1\n\nsummary messages=11 applied=11 rejected=0\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Line 3 is the bug. A message describing 10:05 lands after a message describing 10:10, and the consumer overwrites the row with whichever message arrived last. Read MUG-01 by arrival and you get 12, then 6, then 4. Read it by event time and the newest fact is the set to 6 at 10:10, which matches the shelf.\u003C\u002Fp>\n\u003Cp>TEE-02 has the same shape. The set to 11 describes 10:08, but it arrives after the set to 9 that describes 10:09, so line 6 wins over line 5. That count was accurate at 10:08, yet arriving after 10:09 lets an outdated reading overwrite a newer one.\u003C\u002Fp>\n\u003Cp>The lab writes the arrival order into a JSON array, which is what makes the failure reproducible and free to run. A broker passes messages in delivery order rather than event order. Prefetch hands a message to a worker that is already busy, a retry sends one that was delivered before, and two consumers reading the same partition interleave. None of those is a fault in the broker.\u003C\u002Fp>\n\u003Cp>CAP-03 fails differently. It goes 3, then 1 after the first sale, then 0 after the second. The set to 0 keeps it there. Line 11 then takes it to -1, a state no shelf can be in. The summary at the bottom records all eleven updates as applied and zero rejected.\u003C\u002Fp>\n\u003Ch2 id=\"your-mission\">Your mission\u003C\u002Fh2>\n\u003Cp>\u003Ccode>scripts\u002Fcheck.py\u003C\u002Fcode> holds five checks with one theme: a message about the past cannot overwrite the present, and a sale cannot take the shelf below zero.\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>A:\u003C\u002Fstrong> every product&#39;s quantity matches the venue count.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>B:\u003C\u002Fstrong> an update older than the stored \u003Ccode>event_time\u003C\u002Fcode> is rejected, not applied.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>C:\u003C\u002Fstrong> no quantity is negative, and a sale on an empty shelf is refused.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>D:\u003C\u002Fstrong> a re-delivered event does not move the stock.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>E:\u003C\u002Fstrong> the consumer prints a summary whose counts are the ones it actually applied.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>A and C read \u003Ccode>data\u002Fwarehouse.json\u003C\u002Fcode>. B and D build their own small queues, so editing the data file cannot turn them green.\u003C\u002Fp>\n\u003Cp>A code review can read a loop that applies messages and find it reasonable. A check can feed it a late 3 after a 5 and show you the result.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20make%20check%0Apython3%20scripts%2Fcheck.py%0AFAIL%20%20A%20%20every%20product's%20quantity%20matches%20the%20venue%20count%0A%20%20%20%20%20%20%20%20%20%20CAP-03%3A%20system%20-1%2C%20venue%200%3B%20MUG-01%3A%20system%204%2C%20venue%206%3B%20TEE-02%3A%20system%2011%2C%20venue%209%0AFAIL%20%20B%20%20an%20update%20older%20than%20the%20stored%20event%20time%20is%20rejected%0A%20%20%20%20%20%20%20%20%20%20after%205%20then%20a%20late%203%20from%20an%20hour%20earlier%3A%20MUG-01%20%3D%203%2C%20rejected%200%0AFAIL%20%20C%20%20no%20quantity%20is%20negative%2C%20and%20a%20sale%20on%20an%20empty%20shelf%20is%20refused%0A%20%20%20%20%20%20%20%20%20%20one%20item%2C%20then%20two%20sales%3A%20CAP-03%20%3D%20-1%3B%20negative%20rows%20in%20the%20replay%3A%20CAP-03%3A%20-1%0AFAIL%20%20D%20%20a%20re-delivered%20event%20does%20not%20move%20the%20stock%0A%20%20%20%20%20%20%20%20%20%20with%20e-302%20delivered%20twice%3A%20CAP-03%20-3%2C%20MUG-01%204%2C%20TEE-02%2011%0APASS%20%20E%20%20the%20consumer%20prints%20one%20summary%20line%20with%20the%20counts%20it%20actually%20applied%0A%20%20%20%20%20%20%20%20%20%20summary%20messages%3D11%20applied%3D11%20rejected%3D0%0A%0A1%20of%205%20checks%20passed%0Amake%3A%20***%20%5BMakefile%3A4%3A%20check%5D%20Error%201\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ make check\u003C\u002Fspan>\npython3 scripts\u002Fcheck.py\nFAIL  A  every product's quantity matches the venue count\n          CAP-03: system -1, venue 0; MUG-01: system 4, venue 6; TEE-02: system 11, venue 9\nFAIL  B  an update older than the stored event time is rejected\n          after 5 then a late 3 from an hour earlier: MUG-01 = 3, rejected 0\nFAIL  C  no quantity is negative, and a sale on an empty shelf is refused\n          one item, then two sales: CAP-03 = -1; negative rows in the replay: CAP-03: -1\nFAIL  D  a re-delivered event does not move the stock\n          with e-302 delivered twice: CAP-03 -3, MUG-01 4, TEE-02 11\nPASS  E  the consumer prints one summary line with the counts it actually applied\n          summary messages=11 applied=11 rejected=0\n\n1 of 5 checks passed\nmake: *** [Makefile:4: check] Error 1\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>You start at 1 of 5. Check E passes because the summary accurately reports what the starter did: it applied every message.\u003C\u002Fp>\n\u003Ch2 id=\"what-the-answer-changes\">What the answer changes\u003C\u002Fh2>\n\u003Cp>The answer is one file, \u003Ccode>app\u002Fstore.py\u003C\u002Fcode>, on the \u003Ccode>solusi-0008-stale-writes\u003C\u002Fcode> branch of the same repo. It adds three guards: skip any \u003Ccode>event_id\u003C\u002Fcode> already seen, reject any message older than the row&#39;s \u003Ccode>event_time\u003C\u002Fcode>, and refuse any sale larger than the current stock.\u003C\u002Fp>\n\u003Cp>With those in place, all five checks pass and the consumer prints \u003Ccode>summary messages=11 applied=8 rejected=3\u003C\u002Fcode>. Three of eleven messages are refused. Two describe an older state, and one is a sale on an empty shelf.\u003C\u002Fp>\n\u003Cp>The order of the guards matters for the counters. A message that is both a duplicate and stale is refused at the first one, so \u003Ccode>applied\u003C\u002Fcode> plus \u003Ccode>rejected\u003C\u002Fcode> still equals the number of messages read, whatever the data looks like.\u003C\u002Fp>\n\u003Cp>You still have to write it. \u003Ccode>HINTS.md\u003C\u002Fcode> has three levels, and the first one only asks you to put two messages side by side.\u003C\u002Fp>\n\u003Ch2 id=\"what-this-lab-does-not-do\">What this lab does not do\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>No broker: the queue is a JSON array in arrival order, so prefetch and re-delivery are written into the file.\u003C\u002Fli>\n\u003Cli>No concurrency: one process and one lane, because serializing messages would hide the bug rather than fix it.\u003C\u002Fli>\n\u003Cli>No storefront push: the retry path from the original story is out of scope.\u003C\u002Fli>\n\u003Cli>Two message types only: the vocabulary is \u003Ccode>set\u003C\u002Fcode> and \u003Ccode>sale\u003C\u002Fcode>, with no reservations, transfers, or returns.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>Check which counts in your own system rely on arrival order when they should track event time.\u003C\u002Fp>\n","\u003Cul>\n\u003Cli>A message describing 10:05 can arrive after the one describing 10:10, and a consumer that applies what it reads keeps the older number.\u003C\u002Fli>\n\u003Cli>Three of the eleven messages describe a state that was already gone: two older sets and one sale on a shelf counted at zero.\u003C\u002Fli>\n\u003Cli>The starter applies all eleven and rejects none, which is why nothing throws and why the log looks tidy.\u003C\u002Fli>\n\u003Cli>The answer adds three guards in order: a seen \u003Ccode>event_id\u003C\u002Fcode>, then an \u003Ccode>event_time\u003C\u002Fcode> newer than the row, then a sale the shelf can cover.\u003C\u002Fli>\n\u003Cli>The answer ends at \u003Ccode>applied=8 rejected=3\u003C\u002Fcode> with five of five checks green, and \u003Ccode>app\u002F\u003C\u002Fcode> is the only directory that changes.\u003C\u002Fli>\n\u003Cli>The lab has no broker and no concurrency, so the fix cannot be &quot;apply them in the right order&quot;.\u003C\u002Fli>\n\u003C\u002Ful>\n",[215,233,254,273,290,311],{"id":216,"title":217,"title_id":218,"slug":219,"excerpt":220,"excerpt_id":221,"has_translation":12,"published_at":222,"reading_time":223,"hidden_from_listing":15,"tags":224,"thumbnail_image":21,"og_image":227,"series":228,"authors":230},164,"Python Capstone: Why a Blank CSV Field Cut the Class Average","Python Capstone: Kenapa Satu Kolom CSV Kosong Memotong Rata-rata Kelas","python-capstone-gradebook","A gradebook reads four students and writes a JSON report. The class average says 52.42, because two empty fields became zeros.","Buku nilai membaca empat siswa dan menulis laporan JSON. Rata-rata kelasnya bilang 52.42, karena dua kolom kosong berubah jadi nol.","2026-11-21T01:00:00.000Z",8,[158,225,226],"input-output","cli","\u002Fog\u002Fpython-capstone-gradebook.png",{"id":229,"title":55,"title_id":56,"slug":57},10,[231],{"authors_id":232},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":234,"title":235,"title_id":236,"slug":237,"excerpt":238,"excerpt_id":239,"has_translation":12,"published_at":222,"reading_time":123,"hidden_from_listing":15,"tags":240,"thumbnail_image":21,"og_image":245,"series":246,"authors":251},48,"What a Linked List Actually Is","Tentang Struktur Data LinkedList","tentang-struktur-data-linked-list","A linked list is a linear chain of nodes, each holding data and a pointer to the next node. Here is what that chain looks like, what it costs next to an array, and the same minimal implementation in Java, Python, and JavaScript.","Linked list adalah rantai linear berisi node, dan setiap node menyimpan data plus pointer ke node berikutnya. Ini bentuk rantainya, ongkosnya dibanding array, dan implementasi paling sederhana dalam Java, Python, serta JavaScript.",[241,242,243,244],"struktur-data","linked-list","pointer","konsep","\u002Fog\u002Ftentang-struktur-data-linked-list.png",{"id":247,"title":248,"title_id":249,"slug":250},28,"Linear Data Structures","Struktur Data Linear","asd-struktur-linear",[252],{"authors_id":253},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":255,"title":256,"title_id":257,"slug":258,"excerpt":259,"excerpt_id":260,"has_translation":12,"published_at":261,"reading_time":84,"hidden_from_listing":15,"tags":262,"thumbnail_image":21,"og_image":267,"series":268,"authors":270},163,"Pascal Capstone: Why Every Gradebook Score Came Back Zero","Capstone Pascal: Kenapa Semua Skor Buku Nilai Kembali Nol","pascal-gradebook-capstone","A gradebook reads three students from a file, prints three rows, and every score is 0. The procedure filled a copy of the array, because the parameter was missing `var`. Add the word and the report matches the file; the compiler had already warned about the call that filled nothing.","Sebuah buku nilai membaca tiga siswa dari berkas, mencetak tiga baris, dan setiap skornya 0. Prosedurnya mengisi salinan array, karena parameternya kehilangan `var`. Tambahkan kata itu dan laporannya cocok dengan berkasnya; kompilator sudah memperingatkan soal pemanggilan yang tidak mengisi apa pun.","2026-11-20T01:00:00.000Z",[263,264,265,266],"pascal","record","array","prosedur","\u002Fog\u002Fpascal-gradebook-capstone.png",{"id":269,"title":67,"title_id":68,"slug":69},14,[271],{"authors_id":272},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":274,"title":275,"title_id":276,"slug":277,"excerpt":278,"excerpt_id":279,"has_translation":12,"published_at":261,"reading_time":84,"hidden_from_listing":15,"tags":280,"thumbnail_image":21,"og_image":281,"series":282,"authors":287},162,"Python File I\u002FO: Why the Second Read Came Back Empty","Python File I\u002FO: Kenapa Pembacaan Kedua Kembali Kosong","python-file-read-write","A notes script saves a line, prints it back, then counts zero. The file on disk is correct: `read()` left the pointer at the end, so the second call returned an empty string. Read once into a variable, or `seek(0)`, and the count matches the file.","Skrip catatan menyimpan satu baris, mencetaknya kembali, lalu menghitung nol. Berkas di disk sudah benar: `read()` meninggalkan pointer di ujung, jadi panggilan kedua mengembalikan string kosong. Baca sekali ke sebuah variabel, atau `seek(0)`, dan hitungannya cocok dengan berkas.",[158,225],"\u002Fog\u002Fpython-file-read-write.png",{"id":283,"title":284,"title_id":285,"slug":286},18,"Working with Python Scripts","Menggunakan Script Python","python-pemrograman-dengan-script",[288],{"authors_id":289},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":291,"title":292,"title_id":293,"slug":294,"excerpt":295,"excerpt_id":296,"has_translation":12,"published_at":297,"reading_time":298,"hidden_from_listing":15,"tags":299,"thumbnail_image":21,"og_image":302,"series":303,"authors":308},47,"Why Understanding Algorithms and Data Structures Actually Matters","Pentingnya Memahami Algoritma dan Struktur Data","pentingnya-memahami-algoritma-dan-struktur-data","An algorithm is an ordered list of steps, and that order decides how expensive a problem is. The examples are on the back of an instant noodle packet, in a factorial, and behind ctrl+z.","Sebagai konsep fundamental, algoritma menentukan seberapa mahal sebuah masalah diselesaikan. Contohnya ada di bungkus mie instan, di bilangan faktorial, dan di tombol undo.","2026-11-19T01:00:00.000Z",7,[300,241,244,301],"algoritma","dasar","\u002Fog\u002Fpentingnya-memahami-algoritma-dan-struktur-data.png",{"id":304,"title":305,"title_id":306,"slug":307},27,"About Algorithms and Data Structures","Tentang Algoritma dan Struktur Data","asd-intro",[309],{"authors_id":310},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":312,"title":313,"title_id":314,"slug":315,"excerpt":316,"excerpt_id":317,"has_translation":12,"published_at":318,"reading_time":298,"hidden_from_listing":15,"tags":319,"thumbnail_image":21,"og_image":321,"series":322,"authors":323},161,"Debugging Free Pascal with -gl and gdb","Men-debug Free Pascal dengan -gl dan gdb","pascal-debugging-fpc-gdb","A run with no prices ends at a hex address and status 217. `-gl` names the line, gdb names the values, and the mean of six positive prices comes out negative because `integer` is 2 bytes.","Jalan tanpa satu harga pun berakhir di alamat hex dan status 217. `-gl` menyebut barisnya, gdb menyebut nilainya, dan rata-rata dari enam harga positif keluar negatif karena `integer` berukuran 2 byte.","2026-11-18T01:00:00.000Z",[263,320],"debugging","\u002Fog\u002Fpascal-debugging-fpc-gdb.png",{"id":269,"title":67,"title_id":68,"slug":69},[324],{"authors_id":325},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},[327,331,334,337,340],{"text":328,"depth":329,"id":330},"What the system records",2,"what-the-system-records",{"text":332,"depth":329,"id":333},"One queue, three wrong shelves","one-queue-three-wrong-shelves",{"text":335,"depth":329,"id":336},"Your mission","your-mission",{"text":338,"depth":329,"id":339},"What the answer changes","what-the-answer-changes",{"text":341,"depth":329,"id":342},"What this lab does not do","what-this-lab-does-not-do",1795825297070]