<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ayush Agarwal]]></title><description><![CDATA[Technical writing by Ayush Agarwal — 17-year-old Systems & Agent Engineer. AI agent architectures, production SaaS engineering, and high-performance web systems. Portfolio: theayush.pages.dev
]]></description><link>https://theayush.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 21:39:42 GMT</lastBuildDate><atom:link href="https://theayush.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Why Adding Queue Length Made My Bayesian Cluster Scheduler Worse]]></title><description><![CDATA[When I started writing AegisFlow, a zero-dependency Python scheduler for clusters with silent node failures, my first instinct was obvious: use queue depth…]]></description><link>https://theayush.hashnode.dev/why-adding-queue-length-made-my-bayesian-cluster-scheduler-worse</link><guid isPermaLink="true">https://theayush.hashnode.dev/why-adding-queue-length-made-my-bayesian-cluster-scheduler-worse</guid><category><![CDATA[Python]]></category><category><![CDATA[distributedsystems]]></category><category><![CDATA[MachineLearning]]></category><category><![CDATA[algorithms]]></category><dc:creator><![CDATA[Ayush Agarwal]]></dc:creator><pubDate>Sat, 28 Nov 2026 08:50:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a7b66522981ca41b171a66b/0c405710-6a1c-4878-8129-cade1f15e7b4.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When I started writing AegisFlow, a zero-dependency Python scheduler for clusters with silent node failures, my first instinct was obvious: use queue depth (<code>queue_len</code>) as distress evidence alongside latency and error rate.</p>
<p>It made inference worse. When I actually inspected <code>env/cluster_env.py</code>, <code>queue_len</code> did not depend on node health or sensor noise at all. It was literally echoing my own scheduler's past dispatches back to me. Feeding a deterministic echo of my own decisions into a Bayesian filter created circular confirmation bias.</p>
<p>Dropping <code>queue_len</code> completely and pulling real signal out of telemetry was where the numbers clicked.</p>
<h3>Inferring node health without heuristics</h3>
<p>Each node transitions latently between <code>Healthy</code>, <code>Degraded</code>, and <code>Down</code>. Instead of brittle z-score thresholds, <code>agent.py</code> runs an Exact 3-State Bayesian Hidden Markov Model forward filter over <code>heartbeat_ok</code>, <code>latency_ms</code>, <code>error_rate</code>, and per-task <code>duration_remaining</code> progress deltas. Across paired 400-step benchmarks, that reaches <strong>99.58% hidden state accuracy</strong>, catching degradation in <strong>0.13 steps</strong> and crashes in <strong>0.35 steps</strong> with <strong>0.000% false condemnations</strong>.</p>
<h3>Two math barriers that stopped cascading misses and thrashing</h3>
<ol>
<li><strong>Analytical Triage Gating</strong>: Leaving a doomed task pending costs <code>-0.01/step</code>, whereas missing its deadline on a live node slot costs <code>-1.00</code>. Computing completion probability before dispatch keeps uncompletable jobs out of healthy slots, cutting deadline misses by <strong>87%</strong> (<code>98.2 -&gt; 13.2</code>, raising on-time completion to <strong>98.3%</strong>). Removing triage alone swings ablation reward by <code>+714</code> points.</li>
<li><strong>Cold-Restart Expected-Value Barrier</strong>: In stateful jobs, reassigning a running task resets <code>duration_remaining</code> back to <code>duration_total</code>. Caching <code>duration_total</code> on first sight and requiring target survival gain to strictly beat the lost-progress penalty dropped unnecessary migrations to <strong>0.00</strong> (zero churn), paired with a recovery probation ramp so recovering nodes do not get stampeded immediately.</li>
</ol>
<p>Written in pure Python stdlib, <code>agent.py</code> runs at <strong>0.64 ms/step</strong> (39x under the 25.0 ms budget), passes <strong>31/31</strong> deterministic invariant checks (<code>test_invariants.py</code>), and reaches <strong>96% of the theoretical Oracle ceiling</strong> (<code>745.00 vs 750.94</code>).</p>
<p>Benchmark logs and ablation breakdown: <a href="https://theayush.pages.dev/projects/aegisflow">https://theayush.pages.dev/projects/aegisflow</a></p>
<p>Source code: <a href="https://github.com/theayushagarwal/AegisFlow">https://github.com/theayushagarwal/AegisFlow</a></p>
]]></content:encoded></item><item><title><![CDATA[How I Stopped Passcode Brute-Force From Freezing Live Keystrokes in Carrel]]></title><description><![CDATA[When I started building Carrel, a real-time collaborative CodeMirror 6 workspace, I thought auth was the easy part: hash room passcodes with scrypt, verify…]]></description><link>https://theayush.hashnode.dev/how-i-stopped-passcode-brute-force-from-freezing-live-keystrokes-in-carrel</link><guid isPermaLink="true">https://theayush.hashnode.dev/how-i-stopped-passcode-brute-force-from-freezing-live-keystrokes-in-carrel</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[websockets]]></category><category><![CDATA[YJS]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[Ayush Agarwal]]></dc:creator><pubDate>Sat, 28 Nov 2026 08:48:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a7b66522981ca41b171a66b/4688c4de-5934-4aab-ada8-b597268a2e21.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When I started building Carrel, a real-time collaborative CodeMirror 6 workspace, I thought auth was the easy part: hash room passcodes with <code>scrypt</code>, verify on join, done.</p>
<p>Then I tested what happens under brute-force traffic. <code>scrypt</code> is slow on purpose. Run it synchronously and it blocks Node's event loop; run dozens of async <code>scrypt</code> calls uncapped and they saturate libuv's threadpool. Either way, anyone hammering wrong passcodes starts stuttering live keystrokes for everyone typing in the room.</p>
<p>Here is how I ended up structuring the server and protocol across the 3-package TypeScript monorepo (<code>@carrel/shared</code>, <code>@carrel/server</code>, <code>@carrel/client</code>):</p>
<h3>1. Bounded scrypt + single-use WS tickets</h3>
<p>In <code>server/src/throttle.ts</code>, <code>POST /api/rooms/:id/ticket</code> runs async <code>scrypt</code> inside a 4-slot concurrency limiter paired with per-IP progressive lockouts (and ignores <code>X-Forwarded-For</code> unless <code>TRUST_PROXY</code> is explicitly enabled). Once verified, the client gets a short-lived, single-use nonce-bound HMAC ticket to upgrade <code>/ws</code>, which gets burned immediately on upgrade so replay attempts fail.</p>
<h3>2. One WebSocket with a 1-byte frame header</h3>
<p>Instead of pushing everything through JSON messages or opening parallel sockets, <code>shared/src/frames.ts</code> prefixes every binary WebSocket payload with one routing byte:</p>
<pre><code class="language-text">[0x00] -&gt; raw y-protocols/sync CRDT updates (Y.Doc persisted via SQLite WAL)
[0x01] -&gt; coalesced awareness updates (remote carets, selections, 80ms lerp)
[0x02] -&gt; typed JSON control events (role changes, kicks, host handover)
</code></pre>
<p>CodeMirror 6 renders remote carets with an 80ms interpolation curve (<code>CarrelProvider.ts</code>) and turns interpolation off automatically when <code>prefers-reduced-motion</code> is set.</p>
<h3>3. Not losing room admin on a 2-second Wi-Fi drop</h3>
<p>If a host refreshes a tab or drops Wi-Fi briefly, promoting someone else on the exact <code>close</code> event creates constant role churn. In <code>server/src/host.ts</code>, a <code>HOST_GRACE_MS</code> (5000ms) timer marks the seat <code>hostPending</code> first. Only if that timer expires does seniority election promote the next peer by <code>min(joinedAt)</code> (tie-broken by <code>min(clientId)</code>), while <code>SENIORITY_WINDOW_MS</code> (30s) restores standing on quick reconnects. Multi-tab promotion and creator-key reclamation are verified in Playwright E2E specs (<code>phase5.test.ts</code>).</p>
<p>Full architecture notes and failure-mode diagrams: <a href="https://theayush.pages.dev/projects/carrel">https://theayush.pages.dev/projects/carrel</a></p>
<p>Code on GitHub: <a href="https://github.com/theayushagarwal/carrel">https://github.com/theayushagarwal/carrel</a></p>
]]></content:encoded></item><item><title><![CDATA[I'm 17. I shipped 3 production AI/SaaS products in 30 days. Here's exactly how.
]]></title><description><![CDATA[I'm 17. I shipped 3 production AI/SaaS products in 30 days. Here's exactly how. No tutorials. No bootcamp. No co-founder. Just Python, TypeScript, and a…]]></description><link>https://theayush.hashnode.dev/i-m-17-i-shipped-3-production-ai-saas-products-in-30-days-here-s-exactly-how</link><guid isPermaLink="true">https://theayush.hashnode.dev/i-m-17-i-shipped-3-production-ai-saas-products-in-30-days-here-s-exactly-how</guid><dc:creator><![CDATA[Ayush Agarwal]]></dc:creator><pubDate>Tue, 11 Aug 2026 18:46:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a7b66522981ca41b171a66b/d5a751fc-3e33-43f7-8b3c-eabaf3f62314.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I'm 17. I shipped 3 production AI/SaaS products in 30 days. Here's exactly how. No tutorials. No bootcamp. No co-founder. Just Python, TypeScript, and a refusal to ship anything half-built.</p>
<p>In the 30 days before starting college, I built and shipped three production-grade systems from scratch:</p>
<p>Vurlo — A full-stack e-commerce SaaS with Razorpay, Firebase, atomic inventory locking, and a fully custom admin panel. Built in 10 days. Veltrix — An autonomous Instagram pipeline orchestrating 18 active API keys across 18 different AI agents, using an adversarial multi-model consensus loop to generate and post content twice a day for $0.0002 per post. Built in 12 days. Vcentre — A nightly competitor intelligence scraper that processes social media data through a 10-provider LLM fallback chain and generates production creative briefs. Built in 8 days. All three are live in production right now. You can see the full case studies at theayush.pages.dev.</p>
<p>Here's exactly what I built, how I built it, and what broke along the way.</p>
<p>Product 1: Vurlo — E-commerce SaaS in 10 Days Full case study →</p>
<p>The Problem Every beginner e-commerce tutorial shows you how to add items to a cart. None of them show you what happens when two users buy the last item simultaneously.</p>
<p>I needed to solve the race condition problem for real.</p>
<p>The Architecture Frontend: React + TanStack Router, deployed to Cloudflare Pages Backend: Firebase + Firestore security rules Payments: Razorpay with server-side HMAC-SHA256 payment verification Auth: Firebase Auth with role-based admin access The Key Technical Challenge: Atomic Inventory The critical piece was preventing overselling. Instead of a simple quantity-- update, I used Firestore transactions to atomically check and decrement inventory in a single operation:</p>
<p>python</p>
<p>@firestore.transactional def checkout_in_transaction(transaction, product_ref, quantity): snapshot = product_ref.get(transaction=transaction) current_stock = snapshot.get("stock") if current_stock &lt; quantity: raise Exception("Insufficient stock") transaction.update(product_ref, {"stock": current_stock - quantity}) If two requests hit simultaneously, Firestore's transaction system ensures only one succeeds. The other gets a clean failure and retries — no oversell, ever.</p>
<p>What Else I Built Multi-point rollback handlers for aborted Razorpay payment exits Real-time order management dashboard with live Firestore listeners Gemini AI-powered product recommendations Transactional emails via Resend 100/100 Lighthouse SEO score Build time: 10 days. Infrastructure cost: ₹0/month.</p>
<p>Product 2: Veltrix — Adversarial AI Consensus Engine Full case study →</p>
<p>The Problem Most "AI content generators" produce generic slop that gets 3 likes and dies. I wanted an autonomous system that actually thinks about quality before posting.</p>
<p>The Solution: Adversarial Multi-Model Loop Instead of using one model to generate and post, I built a system with 18 active API keys powering 18 different AI agents in an adversarial consensus loop:</p>
<p>1 agent (Gemini 2.0 Flash) drafts the caption 17 agents across Groq, Cerebras, and other providers act as independent auditors — each scoring quality, relevance, and authenticity The post is only published when the auditor agents reach consensus. If they reject it, the generator retries with their combined feedback as context. Each agent runs on its own API key — no shared rate limits, no single point of failure.</p>
<p>python</p>
<p>def adversarial_consensus(caption: str) -&gt; bool: groq_score = groq_audit(caption) # Independent audit #1 cerebras_score = cerebras_audit(caption) # Independent audit #2 if groq_score &gt;= THRESHOLD and cerebras_score &gt;= THRESHOLD: return True # Consensus reached — post it</p>
<pre><code class="language-plaintext">return False  # Rejected — regenerate with feedback
</code></pre>
<p>Rendering at Native DPI Instead of using a basic text overlay, I render full carousel images using Jinja2 HTML templates piped into a headless Playwright browser at native device DPI. The output looks like a human-designed post.</p>
<p>Results 2 automated posts per day \(0.0002 per post (Groq + Cerebras free tiers are generous) Zero human intervention required Build time: 12 days. Operational cost: ~\)0.006/month.</p>
<p>Product 3: Vcentre — Competitor Intelligence at 2AM Full case study →</p>
<p>The Problem Understanding why a competitor's post went viral — and separating genuine engagement spikes from random noise — is a data problem, not a creativity problem.</p>
<p>The Architecture Every night at 2:00 AM UTC, a GitHub Actions cron job triggers a Python pipeline:</p>
<p>Apify scrapes target competitor social channels SQLite stores raw engagement data with cohort separation (Reels vs Photos tracked separately to prevent category inflation) Outlier Filter removes posts with engagement &gt;3× the cohort median (real outliers, not just viral noise) LLM Fallback Chain — 10 AI providers in sequence. If Gemini fails, try Groq. If Groq fails, try Cerebras. If Cerebras fails... and so on. The pipeline never goes down due to a single provider outage. FastAPI serves the processed briefs python</p>
<p>PROVIDER_CHAIN = [ "gemini-2.0-flash", "groq-llama-3.3", "cerebras-llama-3.1", "together-mistral", # ... 6 more providers ] def analyze_with_fallback(data: str) -&gt; str: for provider in PROVIDER_CHAIN: try: return call_provider(provider, data) except Exception: continue # Try next provider raise Exception("All providers failed") The Output A structured creative brief containing:</p>
<p>Engagement benchmarks for the competitor's last 30 days Which content formats outperformed the baseline Specific hooks and caption patterns that drove above-average engagement Recommended posting time windows Build time: 8 days. Infrastructure cost: $0/month (all free tiers).</p>
<p>The Portfolio All three case studies, with architecture diagrams, challenge breakdowns, and metrics are documented at theayush.pages.dev.</p>
<p>The portfolio itself is also a production system:</p>
<p>Framework: React 19 + TanStack Start (SSR) Deployment: Cloudflare Pages with Workers (serverless SSR) Performance: Sub-400ms TTFB globally, 100/100 Lighthouse SEO What I Learned</p>
<ol>
<li><p>The failure mode matters more than the happy path. Every system I built has an explicit failure mode. Vurlo has rollback handlers. Veltrix rejects bad content. Vcentre has 10-provider fallbacks. Real production systems break — design for that first.</p>
</li>
<li><p>Free tiers are underrated. All three products run at near-zero infrastructure cost. Groq, Cerebras, Apify free tiers, Firebase free tier, Cloudflare free tier. You can build serious systems for free if you architect them carefully.</p>
</li>
<li><p>Ship before you're ready. I didn't wait until Vurlo was "perfect" to start Veltrix. Momentum compounds. Each shipped project made the next one faster to build.</p>
</li>
</ol>
<p>What's Next Starting VIT CSE in August. Building more. If you're working on something interesting or want to discuss any of these systems, reach me at <a href="mailto:theayush.codes@gmail.com">theayush.codes@gmail.com</a>.</p>
<p>Full portfolio + project case studies: <a href="https://theayush.pages.dev/">https://theayush.pages.dev/</a></p>
<p>Tags: #webdev #ai #javascript #python #showdev</p>
]]></content:encoded></item></channel></rss>