<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: aldyferdiansyah3-lang</title>
    <description>The latest articles on DEV Community by aldyferdiansyah3-lang (@aldyferdiansyah3lang).</description>
    <link>https://dev.to/aldyferdiansyah3lang</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4277700%2F90e15aa0-d332-4780-aee6-382531fb0379.png</url>
      <title>DEV Community: aldyferdiansyah3-lang</title>
      <link>https://dev.to/aldyferdiansyah3lang</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aldyferdiansyah3lang"/>
    <language>en</language>
    <item>
      <title>How We Killed a Fake Crowd (and What the Prior Math Cost Us)</title>
      <dc:creator>aldyferdiansyah3-lang</dc:creator>
      <pubDate>Wed, 02 Dec 2026 06:28:17 +0000</pubDate>
      <link>https://dev.to/aldyferdiansyah3lang/how-we-killed-a-fake-crowd-and-what-the-prior-math-cost-us-2e80</link>
      <guid>https://dev.to/aldyferdiansyah3lang/how-we-killed-a-fake-crowd-and-what-the-prior-math-cost-us-2e80</guid>
      <description>&lt;p&gt;&lt;em&gt;Building Haunted Verdict for Kiroween 2026 — a post-mortem on the two times our "crowd" wasn't one, and the audits that caught both.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Haunted Verdict is a small game with one big promise. Every day there is one spooky dilemma — &lt;em&gt;A vampire offers you eternal life. The catch?&lt;/em&gt; — and you vote blind, trying to call which way the crowd went. No percentages, no counts, nothing until you commit. Score +10 if you called the majority, +5 on an exact tie, and keep your candle streak alive.&lt;/p&gt;

&lt;p&gt;That promise lives or dies on one question: &lt;strong&gt;is the crowd real?&lt;/strong&gt; Twice during development, ours wasn't — and twice, it was an audit, not a player, that caught it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fake crowd #1: the hash that pretended to be people
&lt;/h2&gt;

&lt;p&gt;Our first crowd model was elegant and completely hollow. To give every dilemma a stable baseline split, we hashed the dilemma's ID into a pair of numbers. It was deterministic, trivially testable, and it never crashed. It was also causally empty: change the question to literally anything — keep the ID — and the "crowd" answered with exactly the same split. The percentages had nothing to do with the question being asked.&lt;/p&gt;

&lt;p&gt;We caught it in review and replaced it with two things. First, a &lt;strong&gt;Semantic Prior&lt;/strong&gt;: a per-dilemma estimate of the majority, read from the dilemma's actual content — humour, comfort, scariness, food appeal — authored as a table with a one-line rationale per entry, and keyed by the dilemma's &lt;em&gt;text&lt;/em&gt;, never its ID. Rename an ID and nothing changes. Rewrite the dilemma and its prior must be re-estimated. A dilemma whose text isn't in the table gets an honest 50/50; there is no automatic estimator pretending otherwise.&lt;/p&gt;

&lt;p&gt;Second, &lt;strong&gt;real votes&lt;/strong&gt;: a thin serverless endpoint (&lt;code&gt;POST /api/votes&lt;/code&gt;) that anonymously aggregates actual players, merged with the prior through Bayesian smoothing — the prior acts as pseudo-votes, real votes add on top.&lt;/p&gt;

&lt;p&gt;The architecture made this survivable. The game core — rotation, scoring, streaks — is a set of pure synchronous functions locked down by fast-check correctness properties. The spec had reserved a &lt;code&gt;CrowdProvider&lt;/code&gt; seam for crowd data, so reality plugged into the boundary without touching the core. The old seeded provider still exists, demoted to what it always should have been: a test oracle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fake crowd #2: the leak nobody could see
&lt;/h2&gt;

&lt;p&gt;The December polish passed its checks. A Playwright MCP audit verified the pre-vote DOM in online and offline scenarios — no percentages, no counts, 25 out of 25 checks. Production was live. We ran a final multi-model audit (several AI reviewers, different model families, reading the actual code) before calling it done.&lt;/p&gt;

&lt;p&gt;One of them opened the network tab.&lt;/p&gt;

&lt;p&gt;The app &lt;strong&gt;prefetched the real aggregate on page load&lt;/strong&gt;, to have it ready for the reveal. Which means the raw tally — the exact thing the game promises to hide — was sitting in DevTools → Network for anyone who looked, before they voted. The DOM was blind. The wire was not. Worse, Verdi, our little ghost mascot, whispers a pre-vote "controversy tell" — how divided the crowd is, never which side leads. That whisper was computed from the &lt;em&gt;live&lt;/em&gt; split. It leaked no numbers, but it was evidence about real votes, served before commitment.&lt;/p&gt;

&lt;p&gt;The fix was subtraction, not addition. We deleted the read path entirely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The client has exactly &lt;strong&gt;one&lt;/strong&gt; network surface: the vote POST. The first network call a player ever makes is their own vote, and the aggregate arrives only as that POST's response.&lt;/li&gt;
&lt;li&gt;Verdi's whisper is computed from the &lt;strong&gt;Semantic Prior alone&lt;/strong&gt; — a mood about the dilemma, not about the electorate.&lt;/li&gt;
&lt;li&gt;An automated test proves the whole pre-vote path performs &lt;strong&gt;zero network calls&lt;/strong&gt;, and steering rules in the repo now forbid prefetching tallies, in writing, for every future change.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The math we had to say out loud
&lt;/h2&gt;

&lt;p&gt;Fixing the leak exposed a quieter problem. Our prior counted as &lt;strong&gt;50 pseudo-votes&lt;/strong&gt;. Do the arithmetic a judging panel might: against a 65/35 prior, fourteen real players voting unanimously for the minority &lt;em&gt;still lose&lt;/em&gt;. "The split is made of real players" was technically true and practically false.&lt;/p&gt;

&lt;p&gt;But you can't just lower the weight. With a weight of 10 and no other defences, one spammer on a 10-votes-per-minute rate limit can flip a dilemma alone. So the order of operations mattered, and the audit was blunt about it: &lt;strong&gt;dedup first, then — and only then — lower the prior.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Dedup&lt;/strong&gt;: the endpoint now counts at most one vote per (IP, dilemma) per 24 hours. On Redis the claim is an atomic &lt;code&gt;SET NX EX&lt;/code&gt;; the IP is SHA-256 hashed into the key. Repeat votes return &lt;code&gt;counted: false&lt;/code&gt; with the unchanged aggregate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Then the weight&lt;/strong&gt;: prior = &lt;strong&gt;10 pseudo-votes&lt;/strong&gt;. About five real players voting together now overturn even a 65/35 prior. The trade-off is real and we wrote it in the open: with a weight of 10, a zero-vote reveal shows the prior rescaled to a coarser grid (43/57 can display as 40/60). That is the honest price of a prior that can actually lose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof, not adjectives&lt;/strong&gt;: Property 8 in the test suite gained an overturn guarantee — six unanimous real votes flip &lt;em&gt;any&lt;/em&gt; dilemma in the bank, checked by fast-check across all 50. Endpoint tests cover the dedup semantics and the &lt;code&gt;store&lt;/code&gt; field every response carries (&lt;code&gt;store: "redis" | "memory"&lt;/code&gt;), so even our storage claims are verifiable from the API itself instead of asserted in the write-up. We never seeded the tally with votes of our own; the aggregate counts real POSTs or it counts nothing.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What the spec-first habit bought us
&lt;/h2&gt;

&lt;p&gt;Every fix above landed spec-first: the requirements gained criteria 11.8–11.10 (no pre-vote tally fetch; dedup before a small prior; store named in responses) &lt;em&gt;before&lt;/em&gt; the code changed, and the commits pair the &lt;code&gt;.kiro&lt;/code&gt; spec edits with the &lt;code&gt;src&lt;/code&gt; changes they describe. When the second fake crowd was found, we didn't have to redesign — we had to amend, at exactly the seam the spec had reserved. The pure core and its seven original properties never moved a line.&lt;/p&gt;

&lt;p&gt;The suite stands at 160 tests, all green. The crowd, finally, is a crowd: small, deduplicated, lightly steadied by a prior that knows its place — and the blind vote is blind in the DOM, in the whisper, and on the wire.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Haunted Verdict is live at haunted-verdict.vercel.app, built spec-first with Kiro for Kiroween 2026. Source: github.com/aldyferdiansyah3-lang/haunted-verdict.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kiro</category>
      <category>kiroween</category>
      <category>gamedev</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
