<?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: sainath manda</title>
    <description>The latest articles on DEV Community by sainath manda (@sainath_manda).</description>
    <link>https://dev.to/sainath_manda</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%2F4228837%2F3cb174e6-371b-426a-ab8e-c503f122d6e0.png</url>
      <title>DEV Community: sainath manda</title>
      <link>https://dev.to/sainath_manda</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sainath_manda"/>
    <language>en</language>
    <item>
      <title>Why Editing One Day Breaks Most Trip Planners (And How I Built TripGraph)</title>
      <dc:creator>sainath manda</dc:creator>
      <pubDate>Thu, 03 Dec 2026 07:36:19 +0000</pubDate>
      <link>https://dev.to/sainath_manda/why-editing-one-day-breaks-most-trip-planners-and-how-i-built-tripgraph-3jaa</link>
      <guid>https://dev.to/sainath_manda/why-editing-one-day-breaks-most-trip-planners-and-how-i-built-tripgraph-3jaa</guid>
      <description>&lt;p&gt;Most trip planners do a fine job generating a first draft. Where they usually fall apart is the moment a user edits something.&lt;/p&gt;

&lt;p&gt;Imagine 3-day Japan trip: Sunday in Tokyo, Monday in Tokyo (with a locked visit to Meiji Shrine), a Shinkansen ride, and Tuesday in Kyoto split across two hotels. Now suppose the user makes one small change on Monday, like trying to fit in the Mori Art Museum.&lt;/p&gt;

&lt;p&gt;If you just re-run a global planner or ask an LLM to update the itinerary, you usually get one of two annoying outcomes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It schedules a venue that is closed on Mondays. &lt;/li&gt;
&lt;li&gt;It re-optimizes the whole trip and shuffles around Sunday, the train, or Kyoto, even though the user already signed off on those parts.&lt;/li&gt;
&lt;/ol&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%2Fwllaphi47uq0zwpvb5jx.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%2Fwllaphi47uq0zwpvb5jx.png" alt="Trip Graph" width="800" height="190"&gt;&lt;/a&gt;&lt;br&gt;
I built &lt;strong&gt;TripGraph (v7)&lt;/strong&gt; to treat itinerary replanning as a deterministic systems problem rather than a prompt-engineering one. Below is a quick walkthrough of the live API, followed by the architecture choices and tradeoffs behind it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DEMO HERE&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body flex items-center justify-between"&gt;
        &lt;a href="https://github-production-user-asset-6210df.s3.amazonaws.com/210060579/727639592-d312f241-1bef-467c-9dbc-ba30d6f457ca.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;amp;X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20261203%2Fus-east-1%2Fs3%2Faws4_request&amp;amp;X-Amz-Date=20261203T073618Z&amp;amp;X-Amz-Expires=300&amp;amp;X-Amz-Signature=b98840a32765cd7a42f5ad526081a87370e18a6a36afaaf6ca628a2f6095eb52&amp;amp;X-Amz-SignedHeaders=host&amp;amp;response-content-type=video%2Fmp4" rel="noopener noreferrer" class="c-link fw-bold flex items-center"&gt;
          &lt;span class="mr-2"&gt;github-production-user-asset-6210df.s3.amazonaws.com&lt;/span&gt;
          

        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;





&lt;h2&gt;
  
  
  Walking Through a Real Edit Cycle
&lt;/h2&gt;

&lt;p&gt;To make the failure modes easy to test without burning external API quotas, the public demo runs against seeded fixtures. Here is the exact 5-step sequence from &lt;code&gt;scripts/live_demo.py&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create the baseline trip (&lt;code&gt;HTTP 201&lt;/code&gt;):&lt;/strong&gt; Commits &lt;code&gt;version=1&lt;/code&gt; with Sunday Tokyo, Monday Tokyo (Meiji Shrine locked as &lt;code&gt;a_mon_shrine&lt;/code&gt;), the Shinkansen transfer, and Tuesday Kyoto.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify the user's Monday edit:&lt;/strong&gt; The user tries to add Mori Art Museum on Monday. Before touching the solver, an independent verifier checks opening rules and rejects it:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   VIOLATED_FALSE | CLOSED_BY_AUTHORITATIVE_SOURCE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Localized repair (&lt;code&gt;version=2&lt;/code&gt;):&lt;/strong&gt; CP-SAT repairs only Monday. The response returns:
&lt;/li&gt;
&lt;/ol&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="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="nl"&gt;"solver_status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"PROVEN_OPTIMAL_IN_SCOPE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="nl"&gt;"verification"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"VERIFIED_TRUE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="nl"&gt;"blast_radius"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nl"&gt;"semantic"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="nl"&gt;"temporal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0&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;Sunday Tokyo, the Shinkansen leg, and Kyoto come back with the exact same SHA-256 hashes they had in &lt;code&gt;version=1&lt;/code&gt;. Not "mostly unchanged"—byte-for-byte frozen.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Attempt a 2-day global shift (&lt;code&gt;HTTP 409&lt;/code&gt;):&lt;/strong&gt; If a request tries to shift the entire itinerary by two days, TripGraph refuses it upfront because Meiji Shrine is locked:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   HTTP 409 | status=LOCKED_NODE_CONFLICT | locked_activities=['a_mon_shrine']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Explicit opt-in async shift (&lt;code&gt;HTTP 202&lt;/code&gt;):&lt;/strong&gt; Pass the explicit opt-in flag to override the lock, and TripGraph accepts the work asynchronously, polls until &lt;code&gt;"stage": "completed"&lt;/code&gt;, runs LockGuard and the verifier again before writing, and commits &lt;code&gt;version=3&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  The Solver Was the easy Part
&lt;/h1&gt;

&lt;p&gt;Getting OR-Tools CP-SAT to schedule 20 activities isn't hard. The hard part is what happens when a constraint solver meets partial data, concurrent requests, and users who don't want their approved plans silently rewritten.&lt;/p&gt;

&lt;p&gt;I ended up putting four hard boundaries around the solver.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Localized Dirty Closure + SHA-256 Blast Radius Checks
&lt;/h2&gt;

&lt;p&gt;Instead of feeding the entire trip into the solver on every edit, &lt;strong&gt;TripGraph&lt;/strong&gt; computes the minimal dirty subgraph—the specific day or coupled dependency chain touched by the edit. Everything outside that dirty scope is treated as read-only context.&lt;/p&gt;

&lt;p&gt;Before a commit goes through, TripGraph hashes the untouched days and transit legs and verifies they match the pre-edit SHA-256 hashes. If an edit to Monday somehow leaks a side effect into Tuesday's hotel check-in or the Shinkansen leg, the commit fails rather than silently corrupting the trip.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Three-Valued Logic (Kleene K3) Instead of Booleans
&lt;/h2&gt;

&lt;p&gt;Standard boolean validation (&lt;code&gt;True&lt;/code&gt; / &lt;code&gt;False&lt;/code&gt;) is a trap in travel data because venue metadata is constantly incomplete. If a restaurant's Monday hours aren't in the database, what should &lt;code&gt;is_open(venue, monday)&lt;/code&gt; return?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you default to &lt;code&gt;True&lt;/code&gt;, you send users to closed places.&lt;/li&gt;
&lt;li&gt;If you default to &lt;code&gt;False&lt;/code&gt;, you throw away perfectly valid options just because your data source had a gap.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TripGraph's independent verifier uses Kleene three-valued logic (K3): &lt;code&gt;TRUE&lt;/code&gt;, &lt;code&gt;FALSE&lt;/code&gt;, and &lt;code&gt;UNKNOWN&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;A \ B&lt;/th&gt;
&lt;th&gt;AND B&lt;/th&gt;
&lt;th&gt;OR B&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TRUE&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;UNKNOWN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TRUE&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;FALSE&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;FALSE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;UNKNOWN&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UNKNOWN&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;UNKNOWN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;UNKNOWN&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When an authoritative source says Mori Art Museum is closed on Mondays, the verifier returns &lt;code&gt;VIOLATED_FALSE&lt;/code&gt; and blocks the plan. When data is missing, it propagates &lt;code&gt;UNKNOWN&lt;/code&gt; all the way to the API response instead of faking certainty. Separating verification from the solver also means a bug in the CP-SAT model can't rubber-stamp its own broken output.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Keeping OR-Tools Out of FastAPI
&lt;/h2&gt;

&lt;p&gt;CP-SAT is native C++ code wrapped in Python. If you call it directly inside a FastAPI request handler—even in a thread pool—a pathological constraint graph can pin CPU cores, ignore Python-level timeouts, and starve your entire API server.&lt;/p&gt;

&lt;p&gt;In TripGraph, OR-Tools never imports or executes inside the FastAPI process. Solver jobs are dispatched to a pool of isolated Linux worker subprocesses. Every solve has a hard wall-clock budget; if a worker stalls or runs long, the supervisor sends a &lt;code&gt;SIGKILL&lt;/code&gt; to the OS process, tears it down cleanly, and returns a controlled failure without touching the API event loop.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Full subprocess pool diagram is in &lt;a href="//docs/architecture.md"&gt;docs/architecture.md&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  4. LockGuard and SQLite Version Fencing
&lt;/h2&gt;

&lt;p&gt;Two problems show up the moment you add async replanning (&lt;code&gt;HTTP 202&lt;/code&gt;):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Accidental lock overrides:&lt;/strong&gt; Global operations shouldn't silently move an activity the user explicitly pinned. &lt;strong&gt;LockGuard&lt;/strong&gt; forces a &lt;code&gt;409 Conflict&lt;/code&gt; listing the exact conflicting node IDs unless the caller passes explicit opt-in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stale writes:&lt;/strong&gt; Imagine a slow async global shift finishes after the user already committed a quick local edit. Without concurrency control, the slower job overwrites newer state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every itinerary carries a monotonically increasing integer version, and commits are fenced atomically in SQLite (&lt;code&gt;WHERE id = ? AND version = expected_version&lt;/code&gt;). If the version moved while the solver was running, the stale write is rejected instead of clobbering the latest plan.&lt;/p&gt;




&lt;h2&gt;
  
  
  Numbers (And How They Were Measured)
&lt;/h2&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%2F9rcr4a68d4j65nh0hnez.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%2F9rcr4a68d4j65nh0hnez.png" alt="Accuracy across 116 scenarios" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I ran a local benchmark suite across 116 fixture scenarios spanning 12 to 40 activities, comparing a greedy baseline against CP-SAT + ontology constraints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Feasibility:&lt;/strong&gt; 100% for CP-SAT + ontology vs. 93.1% for greedy&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Median latency (p50):&lt;/strong&gt; 13–14 ms across 12 to 40 activities&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test suite:&lt;/strong&gt; 78 passing CI tests covering localized closure, K3 edge cases, LockGuard &lt;code&gt;409&lt;/code&gt;/&lt;code&gt;202&lt;/code&gt; paths, worker isolation, and version fencing&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What This Is Not
&lt;/h2&gt;

&lt;p&gt;To be upfront about scope: TripGraph is an embeddable replanning component, not a consumer booking app.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Seeded fixtures, not live GDS:&lt;/strong&gt; Opening hours, transit legs, and venue data come from deterministic fixtures rather than live Amadeus/Sabre feeds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In-memory async jobs:&lt;/strong&gt; The async &lt;code&gt;202&lt;/code&gt; job runner is in-memory for simplicity; in production you'd swap the queue/store behind the interface for Redis/Postgres or Temporal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQLite storage:&lt;/strong&gt; Great for single-node durability and deterministic tests, though a multi-region deployment would move the version-fenced commits to Postgres.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Code &amp;amp; Demo
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repo:&lt;/strong&gt; &lt;a href="https://github.com/sainathmanda7/tripgraph-engine" rel="noopener noreferrer"&gt;sainathmanda7/tripgraph-engine&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Swagger Docs:&lt;/strong&gt; &lt;a href="https://tripgraph-engine.onrender.com/docs" rel="noopener noreferrer"&gt;tripgraph-engine.onrender.com/docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The whole thing is open source. If you find bugs in the K3 propagation, the subprocess isolation model, or the version fencing, drop a comment or open an issue - I'd genuinely like the critique.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Side note: I'm currently looking for backend and systems engineering roles—if your team works on scheduling, distributed state, or reliability-heavy Python/Go/C++ systems, feel free to reach out.)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>backend</category>
      <category>python</category>
    </item>
    <item>
      <title>Running LLM-generated Go patches in a sandbox without Docker</title>
      <dc:creator>sainath manda</dc:creator>
      <pubDate>Thu, 05 Nov 2026 15:26:41 +0000</pubDate>
      <link>https://dev.to/sainath_manda/running-llm-generated-go-patches-in-a-sandbox-without-docker-3a5</link>
      <guid>https://dev.to/sainath_manda/running-llm-generated-go-patches-in-a-sandbox-without-docker-3a5</guid>
      <description>&lt;p&gt;I got tired of the same loop: copy a stack trace, paste it into a chat window(chat gpt), paste the reply into my editor, find out it doesn't compile, repeat.&lt;/p&gt;

&lt;p&gt;So I built &lt;a href="https://github.com/sainathmanda7/heal-cli" rel="noopener noreferrer"&gt;heal-cli&lt;/a&gt;. It wraps your build or test command. When that command fails, it asks an LLM for candidate patches, runs each one in a throwaway sandbox, and writes a fix back to your tree only if it compiles and the original failure is gone. The compiler and runtime decide what counts as fixed, not the model and not me.&lt;/p&gt;

&lt;p&gt;It's MIT licensed, Go-only (it leans on &lt;code&gt;gopls&lt;/code&gt;), and Linux/WSL-only for now. This post covers the three problems that took the most time.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shape of it
&lt;/h2&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%2Foh1ebw5y416fpt1pbufk.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%2Foh1ebw5y416fpt1pbufk.png" alt=" " width="799" height="457"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;your command fails
  → capture the error + a file skeleton from gopls
  → fan out prompts to the LLM for N candidate patches
  → for each candidate: copy file → sandbox → build → run
  → keep only candidates where the original failure is gone
  → write the winner back to your tree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The search over candidates is a concurrent Monte Carlo Tree Search: one goroutine per branch, channels to collect results. The rest of this post is about what happens inside that "sandbox" step and around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: Docker was the bottleneck
&lt;/h2&gt;

&lt;p&gt;My first version ran each candidate in a container. With a tree search, you run a lot of candidates, and container startup dominated the wall-clock time. I measured about [Y ms] per candidate with Docker.&lt;/p&gt;

&lt;p&gt;The replacement is the re-exec pattern with Linux user namespaces. The Go runtime is multithreaded, so you can't do the classic fork-then-set-up-the-child dance. Instead the binary starts a copy of itself through &lt;code&gt;/proc/self/exe&lt;/code&gt; with a marker argument, and that child process is created inside new namespaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;exec&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CommandContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"/proc/self/exe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"sandbox-child"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workDir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SysProcAttr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;syscall&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SysProcAttr&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Cloneflags&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;syscall&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CLONE_NEWUSER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c"&gt;// [add NEWNS / NEWPID / NEWNET if you use them]&lt;/span&gt;
    &lt;span class="n"&gt;UidMappings&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;syscall&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SysProcIDMap&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ContainerID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HostID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Getuid&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;Size&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;GidMappings&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;syscall&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SysProcIDMap&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ContainerID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HostID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Getgid&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;Size&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;Setpgid&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&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;The child sees an ephemeral temp directory holding a copy of the target file, builds and runs the candidate there, and exits. This costs about [X ms] per candidate, against [Y ms] with Docker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What this is and isn't.&lt;/strong&gt; It contains accidents: a patch that loops forever, deletes files, or writes somewhere it shouldn't. It is not a security boundary against deliberately hostile code, and I don't claim it is. If you need that, look at gVisor or a microVM. The threat model here is a confused model, not an attacker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A gotcha:&lt;/strong&gt; some distros restrict unprivileged user namespaces. Recent Ubuntu releases do this through AppArmor. [Describe what heal-cli does when namespace creation fails: error message, fallback, or doc link.]&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 2: The model loops
&lt;/h2&gt;

&lt;p&gt;Left alone, an LLM will happily go Fix A → Error B → Fix B → Error A forever, and every lap costs API tokens.&lt;/p&gt;

&lt;p&gt;After each sandbox run I normalize the failure output and hash it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;hexAddr&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;regexp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MustCompile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;`0x[0-9a-f]+`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;goroutine&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;regexp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MustCompile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;`goroutine \d+`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;waitTime&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;regexp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MustCompile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;`\d+ (minutes|seconds)`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c"&gt;// [your other normalizers: tmp dir paths, +0x offsets, etc.]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;fingerprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;hexAddr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReplaceAllString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"0x?"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;goroutine&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReplaceAllString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"goroutine N"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;waitTime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReplaceAllString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"N units"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;sha256&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sum256&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hex&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EncodeToString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&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 a fingerprint repeats along the same search path, that branch is pruned. SHA-256 is just a convenient fingerprint here, nothing cryptographic. The limitation is that it only catches exact-state cycles. Two failures with different text but the same underlying cause look different to it. Even so, it cut most of the wasted spend in my test runs [number or anecdote].&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 3: A killed process leaves nothing to learn from
&lt;/h2&gt;

&lt;p&gt;Candidates that hang get killed after a timeout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancel&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WithTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;cancel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Cancel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;syscall&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Kill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Process&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;syscall&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SIGKILL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// whole process group&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WaitDelay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Second&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem is that SIGKILL leaves no stack trace. The search had no failure text to feed back to the model, so it stalled. My fix is a synthetic trace for timed-out runs. It contains [describe: the timeout, the tail of the output, the command, whatever you include]. A hang is now just another failure the search can learn from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context: why gopls
&lt;/h2&gt;

&lt;p&gt;Raw error text is a thin signal. I run &lt;code&gt;gopls&lt;/code&gt; as a headless JSON-RPC daemon and extract the file skeleton (structs, interfaces, signatures) into the prompt. The goal is to nudge the model toward the root cause instead of wrapping the panic in a &lt;code&gt;recover()&lt;/code&gt;. It doesn't always work.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'm least sure about
&lt;/h2&gt;

&lt;p&gt;The MCTS reward function. Right now a candidate scores [compiles +A, original error gone +B, tests pass +C, diff-size penalty], and I hand-tuned the weights on [N] cases. The failure mode I keep hitting is [e.g. it prefers patches that make the error disappear by deleting the code that raised it].&lt;/p&gt;

&lt;p&gt;If you've designed reward signals over LLM output, how would you make this harder to game?&lt;/p&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Install heal-cli&lt;/span&gt;
go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/sainathmanda7/heal-cli@latest

&lt;span class="c"&gt;# 2. Install the gopls language server&lt;/span&gt;
go &lt;span class="nb"&gt;install &lt;/span&gt;golang.org/x/tools/gopls@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You bring your own OpenRouter/OpenAI key, so the API cost is yours. &lt;/p&gt;

&lt;p&gt;I'd like feedback on three things: the reward function, what escapes the sandbox, and how you'd map this idea to macOS, which has no namespaces.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/sainathmanda7/heal-cli" rel="noopener noreferrer"&gt;https://github.com/sainathmanda7/heal-cli&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>ai</category>
      <category>linux</category>
      <category>llm</category>
    </item>
  </channel>
</rss>
