<?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: Mohammad Tejabwala</title>
    <description>The latest articles on DEV Community by Mohammad Tejabwala (@mohammad515253).</description>
    <link>https://dev.to/mohammad515253</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%2F1253057%2F8cc4bd84-4f80-4200-9ff5-0f766c2826f3.jpg</url>
      <title>DEV Community: Mohammad Tejabwala</title>
      <link>https://dev.to/mohammad515253</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohammad515253"/>
    <language>en</language>
    <item>
      <title>Sloth Migrate</title>
      <dc:creator>Mohammad Tejabwala</dc:creator>
      <pubDate>Mon, 26 Oct 2026 06:59:02 +0000</pubDate>
      <link>https://dev.to/mohammad515253/sloth-migrate-opc</link>
      <guid>https://dev.to/mohammad515253/sloth-migrate-opc</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week3-2026-10-19"&gt;Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Remember the critical PHP vulnerability discovered just recently that sent shockwaves through thousands of legacy servers worldwide? It exposed a brutal reality that every engineering team knows but rarely admits: &lt;strong&gt;nobody runs outdated, vulnerable software because they want to—they do it because major dependency upgrades are terrifying.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When foundational libraries release breaking architectural shifts (such as Pydantic v1 to v2, SQLAlchemy 1.4 to 2.0, or major framework redesigns), breaking changes ripple across hundreds of files. Upgrading a manifest constraint breaks your build; fixing one deprecation cascades into three new runtime exceptions. Teams procrastinate for months—or years—until an active zero-day turns tech debt into an urgent fire.&lt;/p&gt;

&lt;p&gt;That sparked an idea: What if an agent took on the dirty work of dependency migrations, but operated under strict engineering discipline? Instead of rushing to overwrite files, what if it worked &lt;strong&gt;slowly, methodically, and durably&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Meet &lt;strong&gt;SlothMigrate&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SlothMigrate&lt;/strong&gt; is an autonomous, self-healing dependency migration engine designed to safely upgrade Python projects across major breaking revisions. &lt;/p&gt;

&lt;p&gt;Rather than treating code migration as an unconstrained text generation task, SlothMigrate implements a closed-loop verification pipeline:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Manifest Inspection &amp;amp; Resolution:&lt;/strong&gt; Automatically parses &lt;code&gt;pyproject.toml&lt;/code&gt; (PEP 621 &amp;amp; Poetry) and &lt;code&gt;requirements.txt&lt;/code&gt;, resolves latest stable releases via PyPI, and safely bumps version constraints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic Sandbox Test Harness:&lt;/strong&gt; Executes local unit tests (&lt;code&gt;pytest&lt;/code&gt;) with deprecation escalation flags (&lt;code&gt;-W error::DeprecationWarning&lt;/code&gt;), capturing exact failure traces.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targeted AST Patching:&lt;/strong&gt; Parses the test traceback to isolate the failing file, line number, and deprecation error, prompting an open-weight model with isolated context to draft a surgical modernization patch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-Disk AST Compiler Guard:&lt;/strong&gt; Runs Python's native &lt;code&gt;ast.parse&lt;/code&gt; over generated code in-memory. If an LLM hallucinates markdown commentary, drops parentheses, or breaks indentation, the patch is blocked before touching the filesystem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stateful Self-Healing:&lt;/strong&gt; Repeats the test-diagnose-patch cycle until all tests turn green, then renders clean unified diffs for developer review.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Why It's Useful &amp;amp; How It Helps Developers
&lt;/h3&gt;

&lt;p&gt;Manual major migrations are cognitively exhausting and prone to human error:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Eliminates Manual Pattern Replacement:&lt;/strong&gt; Upgrades like Pydantic v1 to v2 require converting &lt;code&gt;@validator&lt;/code&gt; to &lt;code&gt;@field_validator&lt;/code&gt;, injecting &lt;code&gt;@classmethod&lt;/code&gt;, updating signatures, and replacing &lt;code&gt;.dict()&lt;/code&gt; with &lt;code&gt;.model_dump()&lt;/code&gt;. SlothMigrate automates these repetitive syntax updates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guarantees Zero Broken Commits:&lt;/strong&gt; Because changes are gated by both compiler-level AST verification and automated test execution, the engine never leaves a repository in a half-broken state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduces Security Lag Time:&lt;/strong&gt; By turning days of high-friction manual refactoring into a self-executing background routine, open-source maintainers and enterprise teams can eliminate legacy CVE exposure without burning engineering sprints.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Here is SlothMigrate executing a complete, multi-pass durable migration on a legacy Pydantic project:&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/PmK9uq_gWP4" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Agent session recording
&lt;/h3&gt;

&lt;p&gt;Because this was built using the Gemini application rather than any agents, it's ineligible for the post.&lt;/p&gt;




&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;The complete source code is open-source under the MIT license:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Mohammadtej" rel="noopener noreferrer"&gt;
        Mohammadtej
      &lt;/a&gt; / &lt;a href="https://github.com/Mohammadtej/Sloth-Migrate" rel="noopener noreferrer"&gt;
        Sloth-Migrate
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="MD"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;SlothMigrate 🦥⚡&lt;/h1&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Autonomous, Durable Dependency Migration Agent powered by Google Gemma, Temporal, and Sentry.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="https://hacktoberfest.com/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/4996ffd0ff1df6735c5c0b496269f53f9594df6b75bfc888d9f461392edab21a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4861636b746f626572666573742d323032362d6666373531382e737667" alt="Hacktoberfest"&gt;&lt;/a&gt;
&lt;a href="https://ai.google.dev/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/3076a00a5d0ecf1239a9bad564e1354fa725619b139e79893cf86382a94298d0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c4c4d2d47656d6d61253230342d2d3236422d2d4134422d2d49542d626c75652e737667" alt="Model"&gt;&lt;/a&gt;
&lt;a href="https://temporal.io/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/851da69405a441953c1b6083d843743c7b21b57d28c1c239b5f33ffe904b22aa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54656d706f72616c2d44757261626c65253230457865637574696f6e2d626c61636b2e737667" alt="Orchestration"&gt;&lt;/a&gt;
&lt;a href="https://sentry.io/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/3d289cbc4b017c36d15c16a3e5aea76bcba2666ad6bfa1539d7b374f2f449547/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53656e7472792d4167656e742532304d6f6e69746f72696e672d707572706c652e737667" alt="Observability"&gt;&lt;/a&gt;
&lt;a href="https://opensource.org/licenses/MIT" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667" alt="License: MIT"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;📖 Overview&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Upgrading breaking major dependencies (such as &lt;strong&gt;Pydantic v1 → v2&lt;/strong&gt;, SQLAlchemy 1.4 → 2.0, or modern typing conventions) is often avoided by development teams. Simple regex replacements fail to capture schema semantics, and large-language-model coding tools frequently hallucinate, strip critical classes, or generate invalid syntax.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SlothMigrate&lt;/strong&gt; transforms breaking dependency upgrades into a deterministic, fault-tolerant self-healing loop:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Detects &amp;amp; Bumps:&lt;/strong&gt; Inspects &lt;code&gt;pyproject.toml&lt;/code&gt; (PEP 621 / Poetry) and &lt;code&gt;requirements.txt&lt;/code&gt;, updates version constraints, and synchronizes the virtual environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Executes Test Suite:&lt;/strong&gt; Runs &lt;code&gt;pytest&lt;/code&gt; with &lt;code&gt;-W error::DeprecationWarning&lt;/code&gt; to escalate deprecated APIs into actionable errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pinpoints Exact Failures:&lt;/strong&gt; Parses Python tracebacks to extract the exact target file, line number, and error message across platforms (Windows, Linux, macOS).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targeted Gemma Refactoring:&lt;/strong&gt; Leverages Google's &lt;code&gt;gemma-4-26b-a4b-it&lt;/code&gt; with an engineering-focused prompt enforcing zero code truncation and strict public API preservation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AST&lt;/strong&gt;…&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Mohammadtej/Sloth-Migrate" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h3&gt;
  
  
  Key Architecture Components
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;src/sloth_migrate/ast_guard.py&lt;/code&gt;: In-memory Python AST validator that blocks malformed LLM outputs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/sloth_migrate/workflows/migration_workflow.py&lt;/code&gt;: Temporal state machine managing durable iterations, retry budgets, and state recovery.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/sloth_migrate/workflows/activities.py&lt;/code&gt;: Atomic activities for dependency bumping, test execution, and LLM code refactoring.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/sloth_migrate/telemetry.py&lt;/code&gt;: Custom Sentry spans tracking agent transactions, token consumption, and execution waterfalls.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/sloth_migrate/ecosystems/python_ecosystem.py&lt;/code&gt;: Traceback analyzer isolating file paths, exact line numbers, and deprecation classes.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;SlothMigrate bridges deterministic developer tooling with probabilistic AI generation through a defensive architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────────────────────────────────────┐
│                   CLI / Typer Engine                   │
└───────────────────────────┬────────────────────────────┘
                            │
                            ▼
┌────────────────────────────────────────────────────────┐
│         Temporal Durable Workflow Orchestration         │
│  ┌────────────────────┐          ┌──────────────────┐  │
│  │ bump_and_install   │ ───────► │    run_tests     │  │
│  └────────────────────┘          └─────────┬────────┘  │
│                                            │           │
│                           [Failing Tests]  ▼           │
│                         ┌───────────────────────────┐  │
│                         │ generate_and_apply_patch  │  │
│                         └─────────────┬─────────────┘  │
└───────────────────────────────────────┼────────────────┘
                                        │
           ┌────────────────────────────┴───────────────────────────┐
           ▼                                                        ▼
┌──────────────────────┐                                 ┌──────────────────────┐
│  Google Gemma Model  │                                 │   AST Syntax Guard   │
│ (gemma-4-26b-a4b-it) │ ───────► Raw Code Patch ──────► │     (ast.parse)      │
└──────────────────────┘                                 └──────────┬───────────┘
                                                                    │
                                                            [Valid] ▼
                                                         Target Codebase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deterministic Failure Isolation
&lt;/h3&gt;

&lt;p&gt;Instead of passing an entire codebase or large terminal dumps into an LLM context, &lt;code&gt;PythonEcosystem.parse_traceback&lt;/code&gt; parses pytest stdout/stderr using strict regular expressions to isolate:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The exact repository-internal file requiring attention (filtering out external virtual environment frames).&lt;/li&gt;
&lt;li&gt;The exact offending line number.&lt;/li&gt;
&lt;li&gt;The specific deprecation or exception class (&lt;code&gt;PydanticDeprecatedSince20&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The AST Compiler Guard
&lt;/h3&gt;

&lt;p&gt;Before any model-generated code is permitted to touch the target filesystem, it must pass through Python's native syntax compiler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;validate_python_code&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;generated&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ASTValidationResult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;ASTValidationResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;is_valid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast_tree&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;SyntaxError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;ASTValidationResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;is_valid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error_message&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SyntaxError at line &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lineno&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&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 the model introduces bad indentation, unclosed delimiters, or partial code blocks, the patch is rejected in-memory, preserving the integrity of the target repository.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;Open innovation is essential for developer infrastructure and automated tooling:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Codebase Privacy &amp;amp; Data Sovereignty:&lt;/strong&gt; Proprietary enterprise code cannot always be transmitted to closed SaaS APIs. Open-weight models like Gemma allow migration engines to execute within local boundaries, on-premises servers, or private VPCs without exposing proprietary IP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic Architecture Over Closed Magic:&lt;/strong&gt; Closed APIs frequently alter models and prompt behaviors without notice. Open architectures provide reproducible results, predictable token performance, and deterministic stability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extensibility &amp;amp; Community Collaboration:&lt;/strong&gt; Open-source projects thrive when specialized tools can be composed together. SlothMigrate unites community standards (&lt;code&gt;pytest&lt;/code&gt;, &lt;code&gt;ast&lt;/code&gt;, &lt;code&gt;temporalio&lt;/code&gt;, &lt;code&gt;sentry-sdk&lt;/code&gt;, &lt;code&gt;typer&lt;/code&gt;) into an integrated developer tool.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Lazy Payoff
&lt;/h2&gt;

&lt;p&gt;During testing on legacy projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Manual Baseline:&lt;/strong&gt; Upgrading a real Pydantic v1 service manually requires reading migration documentation, hunting down deprecated class validators across multiple files, altering method signatures, inserting &lt;code&gt;@classmethod&lt;/code&gt; annotations, rewriting serialization calls, and iteratively debugging test suites. This typically consumes &lt;strong&gt;several hours to multiple days&lt;/strong&gt; of developer time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;With SlothMigrate:&lt;/strong&gt; The entire cycle—from manifest bump to green pytest run—completed autonomously in &lt;strong&gt;under 90 seconds&lt;/strong&gt; across 2 iterations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developers can kick off a migration, step away from their desk, and return to an AST-verified codebase with green tests and clear diffs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Featured Categories
&lt;/h3&gt;

&lt;h4&gt;
  
  
  🏆 Best Use of Gemma
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How Gemma Was Used:&lt;/strong&gt; We integrated Google's open-weight &lt;strong&gt;Gemma&lt;/strong&gt; model (&lt;code&gt;gemma-4-26b-a4b-it&lt;/code&gt;) via Google AI Studio as the core reasoning engine for syntax and architectural modernization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implementation Details:&lt;/strong&gt; Instead of generic code generation, Gemma was deployed as a surgical refactoring agent. We constructed targeted prompts containing the isolated pytest traceback, the exact line number, the runtime deprecation warning, and the source file. Gemma ingested legacy Pydantic v1 syntax and reliably produced v2 implementations, correctly replacing &lt;code&gt;@validator&lt;/code&gt; with &lt;code&gt;@field_validator&lt;/code&gt;, injecting required &lt;code&gt;@classmethod&lt;/code&gt; decorators, and updating &lt;code&gt;.dict()&lt;/code&gt; to &lt;code&gt;.model_dump()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Gemma demonstrated high adherence to strict system instructions, consistently emitting clean Python without conversational filler, allowing our AST parser to validate and write the patches directly.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Partner Categories
&lt;/h3&gt;

&lt;h4&gt;
  
  
  🛡️ Best Use of Temporal
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Making the Migration Agent Durable:&lt;/strong&gt; AI agents operating on developer repositories are inherently multi-step and prone to external failures—LLM rate limits, network timeouts during PyPI package downloads, or interrupted terminal sessions. We wrapped SlothMigrate's entire self-healing loop in a durable &lt;strong&gt;Temporal Workflow&lt;/strong&gt; (&lt;code&gt;DependencyMigrationWorkflow&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Workflow Architecture:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Activity 1 (&lt;code&gt;bump_and_install_activity&lt;/code&gt;):&lt;/strong&gt; Modifies manifests and installs updated packages into the sandbox, configured with exponential retry policies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Activity 2 (&lt;code&gt;run_tests_activity&lt;/code&gt;):&lt;/strong&gt; Executes pytest in an isolated process and extracts failure points.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Activity 3 (&lt;code&gt;generate_and_apply_patch_activity&lt;/code&gt;):&lt;/strong&gt; Invokes Gemma, validates syntax against the AST guard, calculates unified diffs, and writes patches to disk.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fault Tolerance in Practice:&lt;/strong&gt; If an activity experiences an API blip or network dropout, Temporal's retry policy automatically intervenes without restarting the entire migration from scratch. If the machine terminates mid-run, the workflow preserves state and resumes from the exact activity boundary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability:&lt;/strong&gt; Maintainers can open the Temporal Web UI (&lt;code&gt;http://localhost:8233&lt;/code&gt;) to inspect live state transitions, execution timelines, retry counts, and payloads.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  🔍 Best Use of Sentry Agent Tracing
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instrumenting Agent Telemetry:&lt;/strong&gt; To understand agent latency, token costs, and internal debugging loops, we instrumented SlothMigrate with the &lt;strong&gt;Sentry SDK&lt;/strong&gt; (&lt;code&gt;sentry-sdk[tracing]&lt;/code&gt;) using custom spans across every lifecycle phase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom Spans Monitored:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;manifest.bump&lt;/code&gt;: Tracking manifest file reads and regex rewrite duration.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pip.install&lt;/code&gt;: Measuring sandbox package installation latency.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pytest.run&lt;/code&gt;: Capturing test execution runtime and return codes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gemma.generate_fix&lt;/code&gt;: Recording LLM round-trip latency, prompt size, response size, and token usage.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ast.validate&lt;/code&gt;: Tracking in-memory compilation overhead and recording syntax errors as tagged Sentry events.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Debugging with Tracing Waterfalls:&lt;/strong&gt; During development, Sentry traces exposed where the agent spent the majority of its time (compilation vs. LLM inference) and allowed us to immediately catch rejected AST patterns before they touched disk.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Clone and enter SlothMigrate
&lt;/h3&gt;

&lt;p&gt;git clone &lt;a href="https://github.com/Mohammadtej/Sloth-Migrate" rel="noopener noreferrer"&gt;https://github.com/Mohammadtej/Sloth-Migrate&lt;/a&gt;&lt;br&gt;
cd SlothMigrate&lt;/p&gt;

&lt;h3&gt;
  
  
  Set up environment
&lt;/h3&gt;

&lt;p&gt;python -m venv .venv&lt;br&gt;
source .venv/bin/activate  # or .venv\Scripts\activate on Windows&lt;br&gt;
pip install -e .&lt;/p&gt;

&lt;h3&gt;
  
  
  Set your API keys
&lt;/h3&gt;

&lt;p&gt;export GEMMA_API_KEY="your-google-ai-studio-key"&lt;br&gt;
export SENTRY_DSN="your-sentry-dsn"&lt;/p&gt;

&lt;h3&gt;
  
  
  Run against the included demo repository
&lt;/h3&gt;

&lt;p&gt;sloth-migrate run --path demo_pydantic_repo --package pydantic --version 2.14.1&lt;/p&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F52ukk64x8xdbvor5d1w1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F52ukk64x8xdbvor5d1w1.png" alt=" " width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx1hzp99yqlgqyjycbtj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx1hzp99yqlgqyjycbtj0.png" alt=" " width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading this far!&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>showdev</category>
      <category>ai</category>
    </item>
    <item>
      <title>NeoNomad🛳️ - Cross-border tax residency &amp; PE Risk Arbiter</title>
      <dc:creator>Mohammad Tejabwala</dc:creator>
      <pubDate>Mon, 05 Oct 2026 06:57:24 +0000</pubDate>
      <link>https://dev.to/mohammad515253/neonomad-cross-border-tax-residency-pe-risk-arbiter-42ip</link>
      <guid>https://dev.to/mohammad515253/neonomad-cross-border-tax-residency-pe-risk-arbiter-42ip</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/sanity-2026-09-16"&gt;Sanity Challenge, Path One: Ship an Agent That Queries Real Content&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;All hands on deck! Welcome to the NeoNomad!&lt;/p&gt;

&lt;p&gt;This is my second time participating in a hackathon (and also my second post :D), and I am still shocked that I made it in my first try. After winning the prize, the one thing that hit me was getting the prize amount in my resident country. I had to fill out a W-8BEN to avoid double taxation, read the laws in my host country, and had to handle filing for the tax on the "income" generated. So, overall, a big headache. Which leads me to this: NeoNomad (Neo referring to Captain Nemo and Nomad meaning travelling from place to place), Cross-Border Tax Residency &amp;amp; PE Risk Arbiter.&lt;/p&gt;

&lt;p&gt;Now, those are some heavy words; let us understand them in simpler terms:&lt;/p&gt;

&lt;h3&gt;
  
  
  The Persona: Meet Rohan
&lt;/h3&gt;

&lt;p&gt;Imagine a software engineer named Rohan:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Home Base:&lt;/strong&gt; Rohan is an Indian citizen and tax resident living in India.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Employer:&lt;/strong&gt; He works remotely as a Principal Solutions Architect for a high-growth tech company based in Germany.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Plan:&lt;/strong&gt; He decides to do a winter detox and work remotely from a beach apartment in Valencia, Spain, for 128 days (straddling October through February).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To Rohan, the setup seems straightforward:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"I'm only staying four months, well below the famous 183-day limit. I'm paying my regular taxes in India, and my employer is a German company with no presence in Spain. Why would this cause any tax issues?"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However, behind that simple intuition lies a hidden cross-border trap where three jurisdictions and their tax laws collide simultaneously.&lt;/p&gt;

&lt;p&gt;In reality, three distinct legal frameworks collide simultaneously:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Spain's Unilateral Domestic Tax Law (LIRPF &amp;amp; IRNR):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Under domestic Spanish personal income tax (&lt;em&gt;Ley 35/2006 LIRPF Art. 9.1(a)&lt;/em&gt;), tax residency requires strictly more than 183 days within a single calendar year. Because Rohan's 128-day stay straddles two tax years (78 days in 2026, 50 days in 2027), he does not trigger statutory domestic tax residency.&lt;/li&gt;
&lt;li&gt;However, under Spain's Non-Resident Income Tax Act (&lt;em&gt;IRNR Art. 13.1(c)&lt;/em&gt;), Spain asserts strict territoriality: &lt;strong&gt;any labor physically conducted on Spanish soil is deemed Spanish-source income, taxable immediately from Day 1 at a 24% non-resident rate&lt;/strong&gt;, regardless of where the employer is incorporated.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;International Treaty Supremacy (India–Spain DTAA Article 15):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rohan is an Indian tax resident, so his personal income tax relief is governed by the &lt;strong&gt;India–Spain Double Taxation Avoidance Agreement&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under Article 15(2), host-country taxation is displaced if:

&lt;ul&gt;
&lt;li&gt;The individual is present for &amp;lt;= 183 days in a rolling 12-month period,&lt;/li&gt;
&lt;li&gt;The employer is not resident in Spain (the German company satisfies this), and&lt;/li&gt;
&lt;li&gt;The remuneration is not borne by a Spanish permanent establishment.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Article 96 of the Spanish Constitution&lt;/strong&gt;, ratified international treaties supersede domestic legislation, legally nullifying Spain's domestic Day-1 IRNR claim.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Corporate Permanent Establishment Exposure (Germany–Spain DTAA Article 5):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Even though Rohan's personal income is shielded by the India–Spain treaty, his employer's corporate exposure is governed by an entirely different instrument: the &lt;strong&gt;Germany–Spain DTAA&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Because Rohan scopes custom architectures and negotiates commercial Statement of Work (SOW) terms on the ground with European automotive accounts, the German company faces a high risk of triggering a &lt;strong&gt;Dependent Agent Permanent Establishment (DAPE)&lt;/strong&gt; under Article 5(5). Digital DocuSign execution back in Germany does not eliminate this liability under modern OECD rules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This brings us to the Sanity MCP context and Knowledge bases:&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built:
&lt;/h2&gt;

&lt;p&gt;Sanity is basically a smart data store, I would say, with relationships clearly defined between entities without any conflicts or duplication.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;An agent is only as good as the knowledge it can find&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So, what I built was the initial schema containing the jurisdication: containing information about the independent country and the bilateral treaties between these independent countries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Providing the schema outline here:
&lt;/h2&gt;

&lt;p&gt;Example 1: India–Spain DTAA (treaty-in-es)&lt;/p&gt;

&lt;p&gt;JSON&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"treaty-in-es"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bilateralTreaty"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Convention Between the Republic of India and the Kingdom of Spain for the Avoidance of Double Taxation"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"signatoryA"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"reference"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"_ref"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jurisdiction-in"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"signatoryB"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"reference"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"_ref"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jurisdiction-es"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"article15Terms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"exemptionDayLimit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;183&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"countingPeriod"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rolling_12_months"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"conditions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"Recipient is present in the host state for &amp;lt;= 183 days in any 12-month period commencing or ending in the fiscal year concerned"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"Remuneration is paid by, or on behalf of, an employer who is not a resident of the host state"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"Remuneration is not borne by a permanent establishment or fixed base which the employer has in the host state"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"legalHierarchyStatus"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"supersedes_domestic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"sourceTreatyUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://www.incometaxindia.gov.in/DTAA/Spain.pdf"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 2: Indian jurisdiction&lt;/p&gt;

&lt;p&gt;JSON&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jurisdiction-in"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jurisdiction"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"India"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"IN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"taxYearCycle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"fiscal_year_apr_mar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"domesticResidencyRule"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"statutoryAct"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Income-tax Act, Section 6(1) (Residential Status) &amp;amp; Section 5/9 (Scope of Total Income)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"daysLimit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;182&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"comparisonOperator"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"greater_than_or_equal"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"windowType"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"fiscal_year"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"territorialSourceRule"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"An individual is a tax resident if present in India for &amp;gt;= 182 days during the financial year (1 April to 31 March), or &amp;gt;= 60 days if present for &amp;gt;= 365 days across the preceding 4 financial years. Residents and Ordinarily Residents (ROR) are subject to tax on worldwide income, while non-residents are taxed exclusively on income accrued, arising, or received in India under Section 5 and Section 9."&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sanity supports initial context out of the box, so when we built a database, it can use the GROQ mode to query the data at request time. But, this does not solve the fundamental problem with the RAG model that we just discussed, we need to ensure that there are no conflicts involved with the data that we are seeding and if there are, we need to specify which takes priority.&lt;/p&gt;

&lt;p&gt;So, it was decided to move with Knowledge Bases which can process the data that we ingested first. It serves an index built from the data source that we provided, flags the conflicts found when builting that index, and with human-intervention it can be resolved, before the query stage even begins. This is especially usefull against law documents which can be often found conflicting. For example, here in our schema, we introduced a field in the bilateral treaty: &lt;code&gt;legalHierarchyStatus&lt;/code&gt; which can indicate whether the treaty overrides domestic laws or it is subject to domestic GAAR (General Anti-Avoidance Rule) override &lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used Sanity:
&lt;/h2&gt;

&lt;p&gt;This would be a technical section, making some repeat over the intuition behind the earlier section, but please bear with me:&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used Sanity
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Modeling Structured Legal Relationships in the Content Lake
&lt;/h3&gt;

&lt;p&gt;Instead of treating legal tax codes and treaties as unstructured markdown chunks or raw PDFs, I modeled them in the Sanity Content Lake using two custom schema types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;jurisdiction&lt;/code&gt;&lt;/strong&gt;: Stores domestic tax rules, residency day-count thresholds (&lt;code&gt;daysLimit&lt;/code&gt;), statutory comparison operators (&lt;code&gt;greater_than&lt;/code&gt;), and tax year cycle boundaries (such as Spain's calendar year vs. India's fiscal year).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;bilateralTreaty&lt;/code&gt;&lt;/strong&gt;: Models international tax treaties as directed graph relationships between two signatory jurisdictions (&lt;code&gt;signatoryA&lt;/code&gt; and &lt;code&gt;signatoryB&lt;/code&gt;), specifying Article 15 exemption conditions, counting windows (e.g., rolling 12-month periods), and statutory hierarchy status (&lt;code&gt;supersedes_domestic&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Pointing Sanity Context to Build the Knowledge Base
&lt;/h3&gt;

&lt;p&gt;To compile the Knowledge Base, I pointed &lt;strong&gt;Sanity Context&lt;/strong&gt; directly at the Content Lake dataset via a GROQ-scoped source. &lt;/p&gt;

&lt;p&gt;During the compilation build:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Topic Synthesis &amp;amp; Entry Compilation:&lt;/strong&gt; Sanity Context transformed the discrete relational documents into synthesized topic entries (such as &lt;code&gt;residency/domestic_rules&lt;/code&gt;, &lt;code&gt;dtaa/article_15&lt;/code&gt;, &lt;code&gt;dtaa/treaty_inventory&lt;/code&gt;, and &lt;code&gt;pe_risk&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Issue Detection &amp;amp; Standing Instructions:&lt;/strong&gt; When compiling conflicting legal sources—specifically Spain's domestic territorial rule claiming Day-1 tax rights under IRNR Art. 13.1(c) versus bilateral treaty exemptions—Sanity Context surfaced a critical conflict in the &lt;strong&gt;Issues&lt;/strong&gt; tab. I resolved this issue with a standing instruction: &lt;em&gt;international bilateral treaties (DTAAs) supersede domestic statutory territorial taxes under Article 96 of the Spanish Constitution&lt;/em&gt;. This decision survived compiler rebuilds and permanently aligned all synthesized entries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Exposing Tools via Sanity Context MCP
&lt;/h3&gt;

&lt;p&gt;I configured a hosted Model Context Protocol (MCP) server endpoint in Sanity Manage operating in &lt;strong&gt;Knowledge Base mode&lt;/strong&gt;, providing the AI agent in the Antigravity IDE with access to core retrieval tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;initial_context&lt;/code&gt;&lt;/strong&gt;: Called at the beginning of the arbitration session to inspect the Knowledge Base ID (&lt;code&gt;kbMH6TgNzIIz&lt;/code&gt;) and discover the topic outline with its &lt;code&gt;[core]&lt;/code&gt; path tags.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;knowledge_base_search&lt;/code&gt;&lt;/strong&gt;: Used to perform keyword-based exploration across compiled paths when mapping cross-border treaty provisions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;knowledge_base_read&lt;/code&gt;&lt;/strong&gt;: Used to batch-read authoritative, fully cited entry paths (such as &lt;code&gt;residency/domestic_rules&lt;/code&gt;, &lt;code&gt;dtaa/article_15&lt;/code&gt;, and &lt;code&gt;pe_risk&lt;/code&gt;) in a single network round-trip.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. What the Agent Did With the Retrieved Content
&lt;/h3&gt;

&lt;p&gt;When presented with the triangular case (an Indian resident employed by a German GmbH working remotely in Spain), the agent executed deterministic multi-jurisdiction arbitration:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Evaluated Domestic Residency:&lt;/strong&gt; Read &lt;code&gt;residency/domestic_rules&lt;/code&gt; to calculate that the employee's 128-day stay split across two calendar years (78 days in 2026, 50 days in 2027) did not breach Spain's $&amp;gt;183$-day statutory residency threshold under LIRPF Art. 9.1(a).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resolved Treaty Supremacy:&lt;/strong&gt; Read &lt;code&gt;dtaa/article_15&lt;/code&gt; and applied the standing instruction to override Spain's domestic Day-1 IRNR 24% withholding rule, granting a &lt;strong&gt;100% personal income tax exemption&lt;/strong&gt; under the India–Spain DTAA.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attributed Corporate PE Risk:&lt;/strong&gt; Rather than conflating the employee's personal tax status with corporate enterprise exposure, the agent traversed to &lt;code&gt;pe_risk&lt;/code&gt; and evaluated the German employer under the &lt;strong&gt;Germany–Spain DTAA (Article 5)&lt;/strong&gt;. Because the employee engaged in on-the-ground commercial Statement of Work negotiations, the agent flagged a &lt;strong&gt;High Dependent Agent Permanent Establishment (DAPE) risk&lt;/strong&gt; for the German GmbH.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Check out the demo at &lt;a href="https://youtu.be/mbKEt0Mqj6g" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;Check out the project on &lt;a href="https://github.com/Mohammadtej/dev-sanity-challenge" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sanity Project Details
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sanity Project ID:&lt;/strong&gt; &lt;code&gt;1vdo75k2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dataset:&lt;/strong&gt; &lt;code&gt;production&lt;/code&gt; (Public)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public Content Lake Query URL:&lt;/strong&gt; [&lt;a href="https://1vdo75k2.api.sanity.io/v2026-09-18/data/query/production?query=*%5B_type%20in%20%5B%22jurisdiction%22,%20%22bilateralTreaty%22%5D%5D" rel="noopener noreferrer"&gt;https://1vdo75k2.api.sanity.io/v2026-09-18/data/query/production?query=*[_type%20in%20[%22jurisdiction%22,%20%22bilateralTreaty%22]]&lt;/a&gt;]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks,&lt;br&gt;
MT&lt;/p&gt;

</description>
      <category>sanitychallenge</category>
      <category>devchallenge</category>
      <category>sanity</category>
      <category>ai</category>
    </item>
    <item>
      <title>SqlGo🌱 - Save CO2 by optimizing queries and removing redundant storage</title>
      <dc:creator>Mohammad Tejabwala</dc:creator>
      <pubDate>Mon, 20 Apr 2026 04:59:29 +0000</pubDate>
      <link>https://dev.to/mohammad515253/sqlgo-save-co2-by-optimizing-queries-and-removing-redundant-storage-3</link>
      <guid>https://dev.to/mohammad515253/sqlgo-save-co2-by-optimizing-queries-and-removing-redundant-storage-3</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/weekend-2026-04-16"&gt;Weekend Challenge: Earth Day Edition&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;The challenge was to built something that could celebrate our planet. And what better way to celebrate then try to save it!&lt;/p&gt;

&lt;p&gt;Introducing SqlGo, an SQL auditor which connects to your SnowFlake account, finds the historic executions of your query and with the help of Gemini, provides useful suggestions to optimize your query, in turn reducing the computation power needed to run them, which in turn would reduce the CO2 emissions and water maintenance needed for these datacentres to run&lt;/p&gt;

&lt;p&gt;It also finds "zombie" — unused or stale tables within your schema that have not been accessed over time, and haven't been used, saving the redundant storage space. &lt;/p&gt;

&lt;h3&gt;
  
  
  Key features:
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Feature&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Secure Authentication&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Connects to Snowflake using credentials from a JSON file, stored only in the user's session for enhanced security.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sustainability Dashboard&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A central, interactive dashboard displaying key metrics like annual CO2 saved, zombie tables found&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;High-Compute Query Auditing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Automatically identifies and lists the most resource-intensive queries from the past week for on-demand analysis.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Zombie Table Detection&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Scans the database for tables that haven't been altered in over 30 days, helping to eliminate storage waste.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AI-Powered Optimization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Integrates with Google Gemini to provide expert suggestions for rewriting inefficient queries to be more "Green".&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Gamified Savings&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Features a rewarding animation and updates dashboard metrics when a user "Accepts" an optimization, encouraging eco-friendly practices.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modern UI/UX&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A fully responsive, dark-themed interface with animated loaders, sortable tables, and a clean design for an intuitive user experience.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/5QwQcw3IpXI" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Mohammadtej" rel="noopener noreferrer"&gt;
        Mohammadtej
      &lt;/a&gt; / &lt;a href="https://github.com/Mohammadtej/earthday-hackathon" rel="noopener noreferrer"&gt;
        earthday-hackathon
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;earthday-hackathon&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;🚀 SqlGo – Key Features&lt;/p&gt;
&lt;p&gt;SqlGo is designed to optimize database performance while promoting sustainability through intelligent insights and a modern user experience.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;🔑 Features&lt;/h3&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Secure Authentication&lt;/strong&gt;: Connects to Snowflake using credentials from a JSON file, stored only within the user's session to ensure enhanced security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;📊 Sustainability Dashboard&lt;/strong&gt;: A centralized, interactive dashboard showcasing key metrics such as annual CO₂ savings, zombie tables identified, and compute efficiency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;⚡ High-Compute Query Auditing&lt;/strong&gt;: Automatically detects and lists the most resource-intensive queries from the past week, enabling targeted performance improvements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🧟 Zombie Table Detection&lt;/strong&gt;: Identifies tables that have not been modified in over 30 days, helping reduce unnecessary storage usage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🤖 AI-Powered Optimization&lt;/strong&gt;: Integrates with Google Gemini to suggest optimized, more efficient ("greener") versions of SQL queries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🎮 Gamified Savings&lt;/strong&gt;: Encourages eco-friendly actions with interactive feedback—users receive visual rewards and updated metrics when they accept optimization…&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Mohammadtej/earthday-hackathon" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Tech stack used:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Framework&lt;/strong&gt;: Django (Python)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database Integration&lt;/strong&gt;: Snowflake Connector for Python&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Engine&lt;/strong&gt;: Google Gemini API (gemini-2.5-flash)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Design decisions:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ease of Use&lt;/strong&gt;: It was decided to include the table statistics as well into the schema, so that the end user may get an overview of the data and the storage space used. Based on that and the usage, indexes may be created to further optimize key tables.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query Traceability &amp;amp; Analysis&lt;/strong&gt;: Sql ids were included in the report for the queries that are taking a significant time so that the end user may leverage other tools based on the underlying database to analyse the SQL based on the id.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficient Token Utilization&lt;/strong&gt;: Rather than collecting all the SQLs taking significant time and passing it to the Gemini layer, it was better to leave it to the end user to select which SQL to chose, in turn reducing the tokens wasted in analysing all the queries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy-First Stateless Architecture&lt;/strong&gt;: Taking the input via a JSON object for the database credentials, and only storing them in the session, so that confidential user data may not be misused.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Best use of Google Gemini&lt;/em&gt;&lt;/strong&gt;: Used the Gemini API as the main engine of the system to provide analysis based on the data gathered from Snowflake. Also, this application was developed by using Gemini Code Assist and chat. (Chat works better in remembering the overall context I feel)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Best use of Snowflake&lt;/em&gt;&lt;/strong&gt;: Used a pre-existing high-data schema in Snowflake and executed some of the compute intense queries resembling real-life examples, not just poor code! Futhermore, the Snowflake agent Cortex code helped a lot in understanding the schema, and debugging some of the prompt queries used in this application. It even helped in establishing the connection from python to snowflake :)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Future Improvements
&lt;/h2&gt;

&lt;p&gt;Instead of a JSON based input, we could provide an option to directly connect with a Snowflake account to get continuous monitoring and audit&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fun Fact&lt;/em&gt;: &lt;em&gt;The entire frontend of the application was done using Gemini Code Assist&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>weekendchallenge</category>
      <category>gemini</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
