<?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: Interactive Stories</title>
    <description>The latest articles on DEV Community by Interactive Stories (@inkandchoice).</description>
    <link>https://dev.to/inkandchoice</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%2F4285542%2F01503c79-484a-4511-851a-c21b32591ca2.png</url>
      <title>DEV Community: Interactive Stories</title>
      <link>https://dev.to/inkandchoice</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/inkandchoice"/>
    <language>en</language>
    <item>
      <title>Our paywall was bypassable in 30 seconds. Here is how we fixed it</title>
      <dc:creator>Interactive Stories</dc:creator>
      <pubDate>Sun, 06 Dec 2026 00:24:16 +0000</pubDate>
      <link>https://dev.to/inkandchoice/our-paywall-was-bypassable-in-30-seconds-here-is-how-we-fixed-it-2fgp</link>
      <guid>https://dev.to/inkandchoice/our-paywall-was-bypassable-in-30-seconds-here-is-how-we-fixed-it-2fgp</guid>
      <description>&lt;p&gt;Our paywall was bypassable in 30 seconds. Here's how we fixed it.&lt;/p&gt;

&lt;p&gt;Postmortems are more useful than success stories, so here's ours. Interactive Stories is a mobile app where an LLM writes the plot in real time. Every generation costs us real money — inference isn't free — so after 12 free generations per story, the player unlocks the rest with a one-time purchase.&lt;/p&gt;

&lt;h2&gt;
  
  
  The original design (embarrassing)
&lt;/h2&gt;

&lt;p&gt;The client counted generations. Let me repeat that: &lt;strong&gt;the client&lt;/strong&gt; counted generations. The app sent &lt;code&gt;choiceCount&lt;/code&gt; in the request body, and the server compared it against the free allowance. The payload that cost us money looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;generate&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;story&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"storyId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"choiceCount"&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="s2"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"len"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&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;If you've been doing this for a while you're already wincing. &lt;code&gt;choiceCount: 1&lt;/code&gt; — forever. Any motivated user with a proxy could play the entire game free, indefinitely. Worse: &lt;code&gt;prompt&lt;/code&gt; and &lt;code&gt;len&lt;/code&gt; also came from the client, so the endpoint was effectively a free LLM proxy for anyone who found it.&lt;/p&gt;

&lt;p&gt;In our defense: this is a common indie trap. You build the happy path first, and the happy path doesn't include adversaries.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;The server now computes everything that matters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Usage is counted server-side.&lt;/strong&gt; A &lt;code&gt;generation_usage&lt;/code&gt; table tracks per-user per-story counts. The client's count is ignored entirely — it's not even read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content parameters come from the database.&lt;/strong&gt; &lt;code&gt;prompt&lt;/code&gt; and generation length are looked up by &lt;code&gt;storyId&lt;/code&gt; server-side. The client can't inject them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unknown or malformed story IDs are rejected.&lt;/strong&gt; No more open proxy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Existing players were migrated&lt;/strong&gt; — their historical counts were backfilled so nobody lost progress they'd honestly earned.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Verification
&lt;/h2&gt;

&lt;p&gt;We tested the actual exploit path after deploying: replaying the exact request shape that used to bypass the paywall now returns &lt;code&gt;402 story_purchase_required&lt;/code&gt; on the 13th generation, regardless of what &lt;code&gt;choiceCount&lt;/code&gt; says. Purchases still resolve correctly and meter against the real count.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The client is adversarial input.&lt;/strong&gt; Anything the client sends about money, metering or entitlement is a hint at most, never a fact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Meter cost-bearing operations server-side from day one.&lt;/strong&gt; Retrofitting is migrating live user data under pressure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Nobody will bother" is not a threat model.&lt;/strong&gt; If an endpoint proxies paid inference, somebody will bother.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The app is on RuStore if you're curious: &lt;a href="https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook" rel="noopener noreferrer"&gt;https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy to answer questions about the migration path in the comments.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Update, same day:&lt;/strong&gt; a commenter on this very post (hi, Max!) spotted a follow-up race condition in the first version of this fix: the counter was read before generation and incremented after, so parallel requests at the free-limit boundary could all pass the check together. Fair catch — and yes, it was real.&lt;/p&gt;

&lt;p&gt;Fixed within hours: the slot is now reserved atomically at request start via INSERT ... ON CONFLICT DO UPDATE ... RETURNING, before the model is ever called. Rejected and failed generations refund the slot. Verified with the exact test the commenter proposed: five parallel requests at 11/12 — exactly one passes, four get 402. Sometimes the best code review happens in the comments section.&lt;/p&gt;

</description>
      <category>security</category>
      <category>gamedev</category>
      <category>indiedev</category>
      <category>llm</category>
    </item>
    <item>
      <title>Branching narrative without branches: how our AI story engine works</title>
      <dc:creator>Interactive Stories</dc:creator>
      <pubDate>Sat, 05 Dec 2026 23:57:15 +0000</pubDate>
      <link>https://dev.to/inkandchoice/branching-narrative-without-branches-how-our-ai-story-engine-works-37ch</link>
      <guid>https://dev.to/inkandchoice/branching-narrative-without-branches-how-our-ai-story-engine-works-37ch</guid>
      <description>&lt;p&gt;Building a branching narrative without branches: how our AI story engine works&lt;/p&gt;

&lt;p&gt;Classic interactive fiction — Choose Your Own Adventure books, text quests, visual novels — all share the same structural problem: somebody has to write every branch. The content cost grows exponentially with player freedom, so in practice "choices" converge back to a handful of scripted endings.&lt;/p&gt;

&lt;p&gt;When we started Interactive Stories (Интерактивные истории), we deleted the branches entirely. There is no story tree. There is a world state, a cast of characters, and an LLM that writes the next scene in response to whatever the player did — including actions nobody ever anticipated.&lt;/p&gt;

&lt;h2&gt;
  
  
  The architecture in brief
&lt;/h2&gt;

&lt;p&gt;The player picks a story (mystery, fantasy, detective, survival) and gets an opening scene plus 2-3 suggested actions. But there's always a fourth option: type anything. "Burn the house down". "Call my mom". "Challenge the ghost to a dance-off". The model accepts it and continues the story with the consequences.&lt;/p&gt;

&lt;p&gt;Technically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Streaming generation.&lt;/strong&gt; The response streams to the phone over SSE, so text appears progressively like a messenger typing indicator. Perceived latency matters more than total latency — if the first words appear within ~2 seconds, the magic survives.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-side state.&lt;/strong&gt; Story progress lives server-side. Reinstalling the app doesn't lose your run — and (importantly) it lets us meter usage honestly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metered usage.&lt;/strong&gt; The first 12 generations in each story are free; after that the story is a one-time cheap unlock. Usage is counted server-side per generation — an early prototype trusted the client's count, which is exactly as exploitable as it sounds. Don't do that.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What playtesters actually do
&lt;/h2&gt;

&lt;p&gt;The first thing every player does is try to break the game. That's not a bug — it IS the game. When someone types "I pull out an accordion and start playing" and the plot accommodates them, they're hooked. The AI's ability to take absurd input seriously is the core delight.&lt;/p&gt;

&lt;p&gt;The second thing they do: get emotionally invested in ways scripted fiction doesn't achieve, because the protagonist's decisions were genuinely theirs. Players blame themselves for bad endings. That's a compliment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Free input beats suggested actions.&lt;/strong&gt; The suggestions exist mostly to teach new players that input exists at all. Veterans mostly type.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency is everything.&lt;/strong&gt; Stream, don't batch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never trust the client&lt;/strong&gt; for anything that costs you money — metering, pricing, content parameters all belong server-side.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The app is live on RuStore (Russian Android store): &lt;a href="https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook" rel="noopener noreferrer"&gt;https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy to answer questions about the narrative state management in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>gamedev</category>
      <category>llm</category>
      <category>android</category>
    </item>
    <item>
      <title>We let players do literally anything in our LLM-driven fiction. Here's what happened</title>
      <dc:creator>Interactive Stories</dc:creator>
      <pubDate>Sat, 05 Dec 2026 23:37:37 +0000</pubDate>
      <link>https://dev.to/inkandchoice/we-let-players-do-literally-anything-in-our-llm-driven-fiction-heres-what-happened-4n88</link>
      <guid>https://dev.to/inkandchoice/we-let-players-do-literally-anything-in-our-llm-driven-fiction-heres-what-happened-4n88</guid>
      <description>&lt;p&gt;When you build interactive fiction on top of an LLM, you don't really know what players will do until they do it. We expected railroading attempts. We expected trolling. What we didn't expect was how &lt;em&gt;sincere&lt;/em&gt; most players are.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;Our app is a catalog of interactive stories for Android. No pre-written branches: you type or pick an action, and the LLM continues the story taking everything into account. Players can attempt literally anything — the model has to react honestly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What surprised us
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Players rarely try to break the story.&lt;/strong&gt; Around the edges, sure — someone always types "I punch the narrator". But the overwhelming majority play in good faith. They care about the character. When the model raises the stakes, they respond with more creativity, not less.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The office stapler effect.&lt;/strong&gt; In one of our thrillers you're trapped in an office at night. Players come up with solutions we never imagined: barricading in the server room, escaping through ventilation, negotiating with the antagonist peacefully — using a heavy stapler as a negotiating argument. The model honors all of it. This is the fun part: the writers' job shifts from "write every branch" to "build a world consistent enough that any branch feels authored".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Pacing is the hard part.&lt;/strong&gt; Left alone, the model escalates drama way too fast — every scene becomes a climax by step five. Taming that without killing spontaneity took more iteration than any other part of the system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Two kinds of players.&lt;/strong&gt; Some play "as themselves" and forgive imperfections because they're immersed. Others treat it as a puzzle to solve and probe the model's consistency. Interestingly, the second group generates the best bug reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The app is on RuStore: &lt;a href="https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook" rel="noopener noreferrer"&gt;https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook&lt;/a&gt; — first steps of every story are free.&lt;/p&gt;

&lt;p&gt;Curious what you'd attempt first in an LLM-driven story. Comments are open.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>gamedev</category>
      <category>indiedev</category>
      <category>llm</category>
    </item>
    <item>
      <title>Interactive fiction with an LLM: how we removed pre-written plot branches</title>
      <dc:creator>Interactive Stories</dc:creator>
      <pubDate>Sat, 05 Dec 2026 23:15:48 +0000</pubDate>
      <link>https://dev.to/inkandchoice/interactive-fiction-with-an-llm-how-we-removed-pre-written-plot-branches-3lpi</link>
      <guid>https://dev.to/inkandchoice/interactive-fiction-with-an-llm-how-we-removed-pre-written-plot-branches-3lpi</guid>
      <description>&lt;p&gt;Classic text quests share the same disease: every plot branch is written in advance, and after the second playthrough you know them all by heart. We decided to test what happens if you remove pre-written branches entirely and let an LLM continue the story in real time, driven by the player's actual decisions.&lt;/p&gt;

&lt;p&gt;The result is an Android app called "Interactive Stories": the reader makes a choice, the LLM generates the next segment with full memory of everything that happened before — and no two playthroughs are the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's inside
&lt;/h2&gt;

&lt;p&gt;The catalog currently has 19+ stories across genres: mystery, fantasy, detective, survival. Each story is a series of steps where the player picks an action; the first steps are free, the rest is a one-time unlock per story.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interesting observations about LLM behavior
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The model keeps internal world logic surprisingly well&lt;/strong&gt; — you don't have to constantly "remind" it through the system prompt. Without constraints, though, it loves to escalate drama fast and throws in minor details from the very beginning. Structuring the pacing matters more than we expected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Players split in two types&lt;/strong&gt;: some play "as themselves", others detach from the character — and for the second group generation quality matters noticeably more because the plot bends to their style: a brute-force hero gets one kind of trial, a careful one gets completely different ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The app is available on RuStore (a Russian Android store): &lt;a href="https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook" rel="noopener noreferrer"&gt;https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy to answer questions in the comments — both technical (architecture, models, caching) and product-related.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>gamedev</category>
      <category>llm</category>
      <category>indiedev</category>
    </item>
  </channel>
</rss>
