<?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: Rishabh Dwivedi</title>
    <description>The latest articles on DEV Community by Rishabh Dwivedi (@drishu070501).</description>
    <link>https://dev.to/drishu070501</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%2F4264283%2Ff77419a1-8233-423a-9ff4-5d29e9a0f8e4.jpg</url>
      <title>DEV Community: Rishabh Dwivedi</title>
      <link>https://dev.to/drishu070501</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drishu070501"/>
    <language>en</language>
    <item>
      <title>I built a time machine for a diamond factory, spec-first with Kiro</title>
      <dc:creator>Rishabh Dwivedi</dc:creator>
      <pubDate>Wed, 25 Nov 2026 08:58:13 +0000</pubDate>
      <link>https://dev.to/drishu070501/i-built-a-time-machine-for-a-diamond-factory-spec-first-with-kiro-1ao9</link>
      <guid>https://dev.to/drishu070501/i-built-a-time-machine-for-a-diamond-factory-spec-first-with-kiro-1ao9</guid>
      <description>&lt;h1&gt;
  
  
  I built a time machine for a diamond factory, spec-first with Kiro
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Kiroween 2026, Frankenstein category. &lt;a href="https://3-106-245-39.sslip.io" rel="noopener noreferrer"&gt;Live demo&lt;/a&gt; ·&lt;br&gt;
&lt;a href="https://youtu.be/Rw4WrUri5G0" rel="noopener noreferrer"&gt;3-minute video&lt;/a&gt; · &lt;a href="https://github.com/DRishu070501/RealityCheck" rel="noopener noreferrer"&gt;Code&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In a diamond factory, a rough packet takes about &lt;strong&gt;seventeen days&lt;/strong&gt; to reach dispatch. The people who work on&lt;br&gt;
it spend hours on it, not weeks. Every manager has a theory about the fix: more people, another shift, a faster&lt;br&gt;
machine. Nobody can test a theory on last week and see what would actually have happened.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;RealityCheck&lt;/strong&gt;. It replays what really happened in a factory, lets you stop at any recorded&lt;br&gt;
moment, change one decision, and simulates the other future beside the one that happened. In the&lt;br&gt;
demonstration, halving the time packets sit parked finishes the work about 30% sooner. Hiring three more&lt;br&gt;
inspectors changes nothing but the cost, because that stage was never waiting for people.&lt;/p&gt;

&lt;p&gt;The hard part wasn't the simulation. The hard part was keeping every number honest. This post covers how Kiro&lt;br&gt;
helped with that.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Frankenstein of five parts
&lt;/h2&gt;

&lt;p&gt;RealityCheck is five parts that were never meant to share a body:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Skeleton:&lt;/strong&gt; an append-only history in PostgreSQL. A database trigger refuses any edit to the past.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Heart:&lt;/strong&gt; a discrete-event simulation engine in plain Java, with no framework and no randomness.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blood:&lt;/strong&gt; patterns from one real factory's month of data, published only as rounded aggregates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Voice:&lt;/strong&gt; an AI analyst (Claude) that explains results but is forbidden to calculate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Face:&lt;/strong&gt; a React app where every number is tagged Actual, Simulated or AI interpretation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stitching those together is where projects like this usually go wrong. The AI makes up a percentage, or the&lt;br&gt;
simulation quietly uses a random seed. Or a chart shows a number nobody can trace. I wanted rules that&lt;br&gt;
couldn't drift, and that's what Kiro gave me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steering: write the rules down once
&lt;/h2&gt;

&lt;p&gt;Before any code, I wrote four steering documents in &lt;code&gt;.kiro/steering/&lt;/code&gt;, about 560 lines in all. Kiro loads them&lt;br&gt;
into every piece of work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;product.md:&lt;/strong&gt; every number shown comes from the engine or recorded data. AI explains and never calculates.
Simulation never alters recorded history.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;simulation-rules.md:&lt;/strong&gt; thirteen sections the engine must obey, covering determinism, event ordering, units,
calendars and work in progress at the fork, plus the properties its tests must hold.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;architecture.md:&lt;/strong&gt; module boundaries, enforced by ArchUnit tests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;tech.md:&lt;/strong&gt; the stack, and what not to add.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The surprise was how often these settled a design question before it became an argument. I needed per-stage&lt;br&gt;
handling delays, and the obvious answer was a random number generator. But the steering says the engine is&lt;br&gt;
deterministic: same input, same result, to the second. So the delay comes from a hash of the batch id&lt;br&gt;
instead. That's realistic variation with no randomness, and every run reproduces exactly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Specs: eleven features, requirements to tasks
&lt;/h2&gt;

&lt;p&gt;Every feature has a spec in &lt;code&gt;.kiro/specs/&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;requirements.md&lt;/code&gt;, in WHEN/THE SYSTEM SHALL form;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;design.md&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tasks.md&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are eleven specs, 83 requirements and over 120 tasks. Each task names the requirements it satisfies&lt;br&gt;
and the test that proves it.&lt;/p&gt;

&lt;p&gt;Day to day, I worked task by task. I opened a spec's task list, asked Kiro to implement the next task against&lt;br&gt;
its requirements, then checked the result against the acceptance criteria.&lt;/p&gt;

&lt;p&gt;The best moment was spec 11, calibrating against a real factory. My first offline backtest showed that queues&lt;br&gt;
on capacity couldn't explain how long packets sat in a department. Workers hold packets in parcels, so a packet&lt;br&gt;
waits a day or two while the stage runs well below capacity. I updated the &lt;strong&gt;design in the spec first&lt;/strong&gt;, adding&lt;br&gt;
calibrated handling delays with a dated note explaining why. Only then did I change the engine. The spec&lt;br&gt;
stayed the source of truth even when the data proved my first idea wrong.&lt;/p&gt;

&lt;p&gt;When the build departed from a design, the spec was updated instead of left stale. Every &lt;code&gt;tasks.md&lt;/code&gt; ends with&lt;br&gt;
implementation notes recording what changed and why.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hooks: checks on save
&lt;/h2&gt;

&lt;p&gt;Five hooks in &lt;code&gt;.kiro/hooks/&lt;/code&gt; run on save, each scoped to a narrow file pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the touched backend module's unit tests;&lt;/li&gt;
&lt;li&gt;frontend lint and type-check;&lt;/li&gt;
&lt;li&gt;an API contract check against &lt;code&gt;docs/api.md&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;simulation-engine review&lt;/strong&gt;, which checks engine changes against simulation-rules.md and decides whether
the algorithm version must change;&lt;/li&gt;
&lt;li&gt;an architecture-docs sync when migrations or Compose change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The engine review hook was my favourite. Changing the engine without bumping its version would make old&lt;br&gt;
results look comparable with new ones when they're not. The hook catches that at the moment of saving.&lt;/p&gt;

&lt;h2&gt;
  
  
  Custom agents and property-based tests
&lt;/h2&gt;

&lt;p&gt;Five custom agents in &lt;code&gt;.kiro/agents/&lt;/code&gt; act as specialists:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;simulation engineer;&lt;/li&gt;
&lt;li&gt;database designer;&lt;/li&gt;
&lt;li&gt;Java backend architect;&lt;/li&gt;
&lt;li&gt;React UI/UX;&lt;/li&gt;
&lt;li&gt;QA and testing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each is loaded with only its own steering and spec, so the UI agent never wanders into engine code.&lt;/p&gt;

&lt;p&gt;Spec 07 requires the engine's correctness properties to be verified with property-based tests. There are&lt;br&gt;
&lt;strong&gt;29 jqwik properties&lt;/strong&gt; across 8 test classes. They cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;determinism;&lt;/li&gt;
&lt;li&gt;stone and carat conservation at every stage;&lt;/li&gt;
&lt;li&gt;stage order;&lt;/li&gt;
&lt;li&gt;capacity that never goes negative;&lt;/li&gt;
&lt;li&gt;termination.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My favourite is property 10: &lt;em&gt;adding capacity never increases completion time&lt;/em&gt;. It holds only in the&lt;br&gt;
single-stage case. With several stages sharing pools, adding capacity can occasionally make the schedule&lt;br&gt;
longer, which is a known scheduling anomaly. The steering says so plainly, and the engine reports it rather&lt;br&gt;
than hiding it.&lt;/p&gt;

&lt;h2&gt;
  
  
  An AI that refuses to invent
&lt;/h2&gt;

&lt;p&gt;The analyst is Claude, and the steering rule "AI never calculates" shaped all of it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Claude sees only evidence keys from stored simulation results.&lt;/li&gt;
&lt;li&gt;Every number it writes is checked against those results.&lt;/li&gt;
&lt;li&gt;If an answer contains a figure the evidence can't support, it's replaced by a built-in analyst, and the
screen says so.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the demo, Claude says the evidence does not isolate a cause, and refuses to invent one. That's the answer I&lt;br&gt;
wanted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Honest accuracy
&lt;/h2&gt;

&lt;p&gt;A simulator you can't check is just a story. RealityCheck has a backtest: it simulates past dates with no&lt;br&gt;
changes and compares the result with what was recorded. On one real factory, imported privately, it's within&lt;br&gt;
about a fifth on packets finished over a week. We publish exactly where it's wrong.&lt;/p&gt;

&lt;p&gt;Our first real-data backtest actually looked better than that. The extract held only pieces that finished,&lt;br&gt;
which flattered the result. We fixed the comparison window and published the less flattering numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell someone starting with Kiro
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Write the steering first.&lt;/strong&gt; The rules you'd normally keep in your head ("never fabricate a number", "the&lt;br&gt;
engine is deterministic") become context for every task. That's what turned "AI on top of a simulation" into&lt;br&gt;
something I can trust.&lt;/p&gt;

&lt;p&gt;Try it at &lt;strong&gt;&lt;a href="https://3-106-245-39.sslip.io" rel="noopener noreferrer"&gt;https://3-106-245-39.sslip.io&lt;/a&gt;&lt;/strong&gt;, and the code, including the whole &lt;code&gt;.kiro&lt;/code&gt; directory, is at&lt;br&gt;
&lt;strong&gt;&lt;a href="https://github.com/DRishu070501/RealityCheck" rel="noopener noreferrer"&gt;https://github.com/DRishu070501/RealityCheck&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;#Kiro #Kiroween #KiroweenHackathon26&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kiro</category>
      <category>hackathon</category>
      <category>java</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
