<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Denis Marshall Tumakov on Medium]]></title>
        <description><![CDATA[Stories by Denis Marshall Tumakov on Medium]]></description>
        <link>https://medium.com/@denismarshalltumakov?source=rss-a89c5350599a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4cZIcV20dJDg_FgvMrkoNQ.jpeg</url>
            <title>Stories by Denis Marshall Tumakov on Medium</title>
            <link>https://medium.com/@denismarshalltumakov?source=rss-a89c5350599a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 05:13:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@denismarshalltumakov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I tested 16 processes racing for the same task in 200 lines of Rust]]></title>
            <link>https://medium.com/@denismarshalltumakov/how-i-tested-16-processes-racing-for-the-same-task-in-200-lines-of-rust-6e00f0ae26b6?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e00f0ae26b6</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[cursor]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Fri, 08 May 2026 15:00:59 GMT</pubDate>
            <atom:updated>2026-05-08T15:00:59.260Z</atom:updated>
            <content:encoded><![CDATA[<p>I shipped a small tool last week called <a href="https://github.com/DmarshalTU/coord"><em>coord</em></a>— a local daemon that lets parallel AI coding agents (Claude Code, Cursor, Codex, all running side by side) coordinate through a shared bulletin board. The whole product is one Rust binary, MIT, single SQLite file for state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qlah_QxN6dAsD0i3pcHf5A.png" /></figure><p><strong>The problem, one paragraph</strong></p><p>You run two AI coding tabs side by side. They post tasks to a shared bulletin: bug reports, ack notes, “please pick this up.” Both tabs scan the bulletin every turn. Both tabs sometimes see the same pending bug at the same instant. Without a coordination primitive, both tabs grab it, both write fixes, both push different commits. The merge conflict is the <em>cheapest</em> failure mode; the silent “two tabs running expensive parallel work, only one of them needed” is worse.</p><p>The job of <em>coord</em> is to make exactly one of those tabs the winner of the claim, and to tell the other tab “you lost; pick something else.” Determinism, not optimism.</p><p><strong>Why a queue or a mutex doesn’t cut it</strong></p><p>The first idea most engineers have is “stick a `Mutex&lt;Vec&lt;Task&gt;&gt;` behind an RPC call.” It works inside one process. It does not survive process boundaries — and the whole point of the system is that the agents are different processes (different IDE plugins, different language runtimes, sometimes different machines on the same loopback).</p><p>The second idea is a queue (Redis, RabbitMQ, NATS). A queue does solve the claim race, but it brings a lot of baggage:</p><p>- A second daemon to install, monitor, and back up.</p><p>- A protocol the IDE side has to learn (or you end up writing a queue-to-MCP adapter).</p><p>- Ordering and delivery guarantees you don’t actually need for “is this task claimed yet?” semantics.</p><p>The third idea is a distributed lock (e.g. Redis `SETNX`, Postgres advisory locks). Closer, but still a separate piece of infrastructure for what is essentially a per-developer-laptop tool.</p><p>For a tool that wants to be `brew install`-and-go, the right primitive is the smallest one that does the job. SQLite already lives inside the daemon binary. SQLite already serializes writes. The job becomes “ask SQLite to tell me whether I won.”</p><p><strong>The whole primitive</strong></p><p>This is the entire claim function:</p><pre>pub fn claim_task(&amp;self, id: Uuid, agent_id: &amp;str) -&gt; Result&lt;Option&lt;Task&gt;&gt; {<br>    let now = Utc::now();<br>    let conn = self.conn.lock();<br>    let updated = conn.execute(<br>        &quot;UPDATE tasks SET state = &#39;claimed&#39;, claimed_by = ?1, updated_at = ?2<br>         WHERE id = ?3 AND state = &#39;pending&#39;&quot;,<br>        params![agent_id, now.to_rfc3339(), id.to_string()],<br>    )?;<br>    if updated == 0 {<br>        Ok(None) // somebody else got there first<br>    } else {<br>        // re-read to get the canonical row, including the winner.<br>        Ok(Some(conn.query_row(<br>            &quot;SELECT ... FROM tasks WHERE id = ?1&quot;,<br>            params![id.to_string()],<br>            row_to_task,<br>        )?))<br>    }<br>}</pre><p>The whole correctness argument is in the `WHERE id = ?3 AND state = ‘pending’` clause. Two clients may issue the same `UPDATE` simultaneously; SQLite serializes the writes; the second one finds `state` is no longer `’pending’` and updates 0 rows. `updated == 0` is the loser signal, propagated up the stack as `Ok(None)`. The winner gets a fresh `Some(Task)`. That’s it.</p><p>There is no lock object, no compare-and-swap dance, no transaction explicit in user code. The transaction is the single statement. SQLite’s WAL mode handles concurrent readers without blocking the writer.</p><p>The reason I’m comfortable putting this in a critical path is that it’s <em>*the same primitive*</em> every database-backed work queue you’ve ever used uses underneath. Postgres `SELECT … FOR UPDATE SKIP LOCKED`, Redis `SETNX`, all the big managed queue services — at the bottom they’re some flavor of “atomic compare-and-set on a row.” This one just doesn’t dress it up.</p><p><strong>Test 1: in-process, exhaustive</strong></p><p>The first test hammers the primitive directly without going through the network at all. The intent: catch correctness regressions in the SQL or the Rust wrapper, not the HTTP layer.</p><pre>#[test]<br>fn one_claimer_per_task_under_concurrent_load() {<br>    let store = Arc::new(Store::open(&amp;db_path).unwrap());<br><br>    const TASKS: usize = 200;<br>    const CLAIMERS_PER_TASK: usize = 8;<br><br>    let task_ids: Vec&lt;_&gt; = (0..TASKS)<br>        .map(|i| store.create_task(&amp;format!(&quot;race-{i}&quot;), json!({&quot;i&quot;: i}))<br>                  .unwrap().id)<br>        .collect();<br><br>    let mut handles = Vec::new();<br>    for task_id in &amp;task_ids {<br>        for c in 0..CLAIMERS_PER_TASK {<br>            let store = store.clone();<br>            let id = *task_id;<br>            let agent = format!(&quot;claimer-{c}&quot;);<br>            handles.push(thread::spawn(move || {<br>                store.claim_task(id, &amp;agent).unwrap().is_some()<br>            }));<br>        }<br>    }<br><br>    let wins: usize = handles.into_iter()<br>        .map(|h| h.join().unwrap() as usize)<br>        .sum();<br><br>    assert_eq!(wins, TASKS,<br>        &quot;expected exactly one win per task (got {wins} wins for {TASKS} tasks)&quot;);<br>}</pre><p>200 tasks × 8 claimers = 1,600 simultaneous claim attempts. The assertion is severe: the <em>*total*</em> number of `Ok(Some(_))` returns across all threads must equal exactly 200. If any task is claimed twice, the count becomes 201+ and the test fails. If any task is missed entirely (e.g. a row-level lock dropped a write silently), the count becomes 199 and the test fails. The only way this assertion holds is if every single attempt is unambiguously a winner or a loser, with no ambiguous middle.</p><p>It runs in about 70 milliseconds in CI. I run it on every commit.</p><p><strong>Test 2: real processes, real HTTP</strong></p><p>The in-process test is reassuring but it has a giant asterisk: it doesn’t prove the daemon survives multiple HTTP clients. SQLite serializing writes inside one Rust process is one thing; an `axum` server holding a single `Mutex&lt;Connection&gt;` while 16 reqwest clients hit it concurrently is another. The behavior I cared about — “16 IDE tabs in different OS processes, one daemon, exactly one winner per task” — has to be tested end-to-end.</p><p>So the second test spawns the actual daemon binary, lets it bind a free port, and fires 16 independent client processes at it:</p><pre>const NUM_CLIENTS: usize = 16;<br><br>#[test]<br>fn many_concurrent_clients_share_one_daemon_safely() {<br>    // 1. Start a real `coord serve` on a free localhost port.<br>    let mut daemon = Command::new(&amp;coord)<br>        .arg(&quot;serve&quot;).arg(&quot;--addr&quot;).arg(format!(&quot;127.0.0.1:{port}&quot;))<br>        .arg(&quot;--db&quot;).arg(&amp;db).spawn().unwrap();<br><br>    // 2. Seed N pending tasks via the CLI (separate process).<br>    let task_ids: Vec&lt;String&gt; = (0..NUM_CLIENTS).map(|i| {<br>        // ... shells out to `coord send` and parses the returned UUID<br>    }).collect();<br><br>    // 3. Spawn N independent shell scripts, each racing to claim<br>    //    every task in the list.<br>    let mut children = Vec::new();<br>    for c in 0..NUM_CLIENTS {<br>        let agent = format!(&quot;multi-agent-{c}&quot;);<br>        let mut script = String::new();<br>        for tid in &amp;task_ids {<br>            script.push_str(&amp;format!(<br>                &quot;{coord} --url {url} claim {tid} --as {agent} \<br>                 &gt;/dev/null 2&gt;&amp;1 &amp;&amp; echo {tid}\n&quot;));<br>        }<br>        children.push(Command::new(&quot;sh&quot;).arg(&quot;-c&quot;).arg(&amp;script)<br>            .stdout(Stdio::piped()).spawn().unwrap());<br>    }<br><br>    // 4. Collect every (winner, task_id) pair.<br>    let mut all_wins = Vec::new();<br>    for (idx, child) in children.into_iter().enumerate() {<br>        let out = child.wait_with_output().unwrap();<br>        for line in String::from_utf8_lossy(&amp;out.stdout).lines() {<br>            all_wins.push((idx, line.trim().to_string()));<br>        }<br>    }<br><br>    // 5. Assert: every task has exactly one winner.<br>    let mut by_task: HashMap&lt;String, Vec&lt;usize&gt;&gt; = Default::default();<br>    for (idx, id) in &amp;all_wins {<br>        by_task.entry(id.clone()).or_default().push(*idx);<br>    }<br>    assert_eq!(by_task.len(), NUM_CLIENTS);<br>    for (_id, winners) in &amp;by_task {<br>        assert_eq!(winners.len(), 1, &quot;race lost: {winners:?}&quot;);<br>    }<br>}</pre><p>A few things worth pointing out about this test design:</p><p>- **The clients are real processes, not threads.** `Command::new(“sh”)` forks. Each one gets its own `coord` CLI invocation, its own reqwest client, its own TCP connection. There is no shared memory between them and no shared Tokio runtime. That’s the actual deployment shape.</p><p>- **Each script tries to claim <em>*every*</em> task.** With 16 clients and 16 tasks, that’s 256 individual claim attempts hitting the daemon. The daemon has to reject 240 of them and accept 16 of them, with no overlap.</p><p>- **The assertion is again a counting argument.** `by_task.len() == NUM_CLIENTS` says “every task got at least one winner;” the per-task `winners.len() == 1` says “no task got more than one winner.” Together they’re a strict bijection between tasks and winners.</p><p>- **It runs in about 1.3 seconds**, including spawning the daemon, waiting for it to bind, seeding tasks, racing, killing the daemon. Slow enough to be annoying as a unit test, fast enough to keep in CI.</p><p>This test is the one that gives me confidence to claim “coord scales to N agents and N apps” in the README. Not because 16 is a large number, but because the failure modes for 16 are the failure modes for 1,600 — if it works at this scale and the design hasn’t introduced an `O(N)` lock contention path, it works at the next scale up.</p><p><strong>What I didn’t need to build</strong></p><p>The motivation for writing this post is half technical and half cultural. There is a strong gravity in 2026 engineering culture toward immediately reaching for distributed primitives — actors, channels, CRDTs, lock services — when the actual workload fits comfortably on one machine.</p><p>For `coord`’s actual workload (a developer’s laptop, 2–10 agents, a few thousand tasks per day) the right answer is a single SQLite file and a single statement. The work isn’t “design a queue;” the work is “trust the database to do its job, and verify it with a test that would catch a regression.”</p><p>Things I considered and threw out:</p><p>- **A `tokio::sync::Mutex&lt;HashMap&lt;Uuid, Task&gt;&gt;`** — works in-process, dies the moment the daemon restarts.</p><p>- **An actor per task** — neat but every task lives only seconds; the spawn cost dominates.</p><p>- **Optimistic concurrency at the application level** (read row, compare version, write) — that’s just reimplementing what the SQL `WHERE state = ‘pending’` clause already does for free, with more chances to get it wrong.</p><p>- **A pluggable storage backend** — overkill until somebody asks. The whole product is one binary right now.</p><p>The shape of the test suite reinforces the design. If the primitive were doing more, the tests would have to be more complicated to constrain its behaviour. They aren’t, because it isn’t.</p><p><strong>What you should take from this</strong></p><p>If you’re building anything where two agents (humans, processes, or LLM tabs) might reach for the same piece of work at once, you probably do not need a queue. You need a single atomic compare-and-set, plus a test that proves you can issue 1,600 of them concurrently and get exactly the right number of winners.</p><p>The technique generalizes far past AI agents:</p><p>- Job runners (one task, one worker)</p><p>- Lease/lock servers (one holder, until release)</p><p>- Reservation systems (one seat, one buyer)</p><p>- Cron deduplication (one runner per scheduled instant)</p><p>In each case the loop is the same: a `WHERE state = ‘available’` clause in an `UPDATE`, the rowcount as your winner signal, and a counting-argument test that asserts the total number of winners across all attempts equals the number of available slots. That last test, the counting argument, is what turns “I think this is right” into “I know this is right.” It catches things eyeballed code reviews don’t — the clever-but-wrong refactor, the changed default isolation level, the silent race introduced by a connection pool tweak.</p><p>If you want to see the full machinery, `coord` is open-source: [github.com/DmarshalTU/coord](https://github.com/DmarshalTU/coord). The two tests above live in `tests/race.rs` and `tests/multi_client.rs`. Together they’re under 200 lines and they’re the load-bearing proof for everything else the project promises.</p><p>— -</p><p><em>*`coord` runs locally as a single Rust binary. It’s MIT-licensed and installable with `brew tap dmarshaltu/coord &amp;&amp; brew install coord`. The repo is [github.com/DmarshalTU/coord](https://github.com/DmarshalTU/coord).*</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e00f0ae26b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Real Kubernetes Failure Predictor with Markov Chains]]></title>
            <link>https://medium.com/@denismarshalltumakov/building-a-real-kubernetes-failure-predictor-with-markov-chains-b75bd668daa0?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b75bd668daa0</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 17:59:43 GMT</pubDate>
            <atom:updated>2025-09-14T17:59:43.254Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A hypothetical deep dive into what it would actually take to predict Kubernetes failures before they happen</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXmJeZOqyIvVx-cgBhibjg.png" /></figure><h3>The Challenge</h3><p>Kubernetes clusters are complex systems with thousands of moving parts. Pods can fail for dozens of reasons: resource constraints, image pull failures, configuration errors, network issues, and more. The question is: <strong>Can we predict these failures before they happen?</strong></p><p>This blog post explores what a real Kubernetes failure predictor would look like, using Markov chain mathematics and machine learning.</p><h3>The Problem with Current Approaches</h3><p>Most Kubernetes monitoring tools are reactive:</p><ul><li>They alert you AFTER a pod fails</li><li>They show you current status, not future predictions</li><li>They don’t learn from patterns across your cluster</li></ul><p>What we need is a <strong>proactive</strong> system that can say:</p><blockquote><em>“Based on the current state and historical patterns, this pod has a 85% chance of failing within the next 10 minutes due to resource constraints.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ka6NLprFePxPWWoZNzE2qA.png" /></figure><h3>The Markov Chain Approach</h3><h3>What is a Markov Chain?</h3><p>A Markov chain is a mathematical model that describes a sequence of events where the probability of each event depends only on the state attained in the previous event. In Kubernetes terms:</p><ul><li><strong>States</strong>: Pod phases (Pending, Running, ImagePullBackOff, etc.)</li><li><strong>Transitions</strong>: State changes over time</li><li><strong>Probabilities</strong>: Likelihood of moving from one state to another</li></ul><h3>Why Markov Chains for Kubernetes?</h3><p>Kubernetes pod lifecycles follow predictable patterns:</p><ol><li>Pod created → Pending</li><li>Pending → Running (if successful)</li><li>Pending → ImagePullBackOff (if image issues)</li><li>Running → CrashLoopBackOff (if app crashes)</li></ol><p>The key insight: <strong>The next state depends primarily on the current state and recent history.</strong></p><h3>A Hypothetical Real Implementation</h3><h3>1. Event Sequence Analysis</h3><pre>class PodEventSequence:<br>    def __init__(self, pod_name, namespace):<br>        self.pod_name = pod_name<br>        self.namespace = namespace<br>        self.events = []<br>        self.state_transitions = []<br>        self.timing_patterns = []<br>    <br>    def add_event(self, event):<br>        &quot;&quot;&quot;Add a new event and analyze patterns.&quot;&quot;&quot;<br>        self.events.append(event)<br>        <br>        # Extract features for prediction<br>        features = self.extract_features()<br>        <br>        # Update Markov chain probabilities<br>        self.update_transition_probabilities()<br>        <br>        # Check for failure patterns<br>        predictions = self.predict_future_states()<br>        <br>        return predictions</pre><h3>2. Multi-Dimensional State Space</h3><p>Real Kubernetes failures aren’t just about pod phases. We need to consider:</p><pre>class PodState:<br>    def __init__(self):<br>        self.phase = &quot;Pending&quot;  # Pod phase<br>        self.ready_condition = False  # Ready status<br>        self.resource_usage = {}  # CPU/Memory usage<br>        self.restart_count = 0  # Number of restarts<br>        self.age_seconds = 0  # How long in current state<br>        self.image_pull_attempts = 0  # Image pull retries<br>        self.network_connectivity = True  # Network status<br>        self.storage_issues = []  # Volume mount problems<br>        self.config_errors = []  # Configuration issues</pre><h3>3. Temporal Pattern Recognition</h3><pre>class TemporalAnalyzer:<br>    def analyze_timing_patterns(self, event_sequence):<br>        &quot;&quot;&quot;Analyze timing patterns that predict failures.&quot;&quot;&quot;<br>        patterns = {<br>            &#39;stuck_in_pending&#39;: self.detect_stuck_pending(event_sequence),<br>            &#39;resource_pressure&#39;: self.detect_resource_pressure(event_sequence),<br>            &#39;image_pull_degradation&#39;: self.detect_image_pull_issues(event_sequence),<br>            &#39;restart_escalation&#39;: self.detect_restart_escalation(event_sequence)<br>        }<br>        return patterns<br>    <br>    def detect_stuck_pending(self, events):<br>        &quot;&quot;&quot;Detect pods stuck in Pending state too long.&quot;&quot;&quot;<br>        pending_events = [e for e in events if e.state == &#39;Pending&#39;]<br>        if len(pending_events) &gt; 5:  # More than 5 Pending events<br>            duration = pending_events[-1].timestamp - pending_events[0].timestamp<br>            if duration.total_seconds() &gt; 300:  # Stuck for 5+ minutes<br>                return {<br>                    &#39;pattern&#39;: &#39;stuck_pending&#39;,<br>                    &#39;confidence&#39;: 0.8,<br>                    &#39;predicted_failure&#39;: &#39;ImagePullBackOff&#39;,<br>                    &#39;time_to_failure&#39;: 120  # seconds<br>                }<br>        return None</pre><h3>4. Real-Time Prediction Engine</h3><pre>class FailurePredictor:<br>    def __init__(self):<br>        self.markov_chains = {}  # One per resource type<br>        self.temporal_analyzers = {}<br>        self.ml_models = {}<br>    <br>    def predict_failure(self, pod_state, event_sequence):<br>        &quot;&quot;&quot;Predict if a pod will fail and when.&quot;&quot;&quot;<br>        predictions = []<br>        <br>        # Markov chain prediction<br>        markov_pred = self.markov_chain_prediction(pod_state, event_sequence)<br>        if markov_pred:<br>            predictions.append(markov_pred)<br>        <br>        # Temporal pattern prediction<br>        temporal_pred = self.temporal_pattern_prediction(event_sequence)<br>        if temporal_pred:<br>            predictions.append(temporal_pred)<br>        <br>        # Machine learning prediction<br>        ml_pred = self.ml_prediction(pod_state, event_sequence)<br>        if ml_pred:<br>            predictions.append(ml_pred)<br>        <br>        # Combine predictions<br>        final_prediction = self.combine_predictions(predictions)<br>        return final_prediction<br>    <br>    def combine_predictions(self, predictions):<br>        &quot;&quot;&quot;Combine multiple prediction methods.&quot;&quot;&quot;<br>        if not predictions:<br>            return None<br>        <br>        # Weighted average based on confidence<br>        total_confidence = sum(p.confidence for p in predictions)<br>        if total_confidence == 0:<br>            return None<br>        <br>        weighted_failure_prob = sum(<br>            p.failure_probability * p.confidence <br>            for p in predictions<br>        ) / total_confidence<br>        <br>        return {<br>            &#39;failure_probability&#39;: weighted_failure_prob,<br>            &#39;confidence&#39;: total_confidence / len(predictions),<br>            &#39;predicted_failure_type&#39;: self.most_likely_failure_type(predictions),<br>            &#39;time_to_failure&#39;: self.estimate_time_to_failure(predictions)<br>        }</pre><h3>What Would Make This Actually Work</h3><h3>1. Historical Data Collection</h3><pre>class DataCollector:<br>    def collect_training_data(self):<br>        &quot;&quot;&quot;Collect historical data for training.&quot;&quot;&quot;<br>        # Get all pod events from the last 30 days<br>        events = self.k8s_client.list_events_for_all_namespaces()<br>        <br>        # Group by pod and build sequences<br>        pod_sequences = {}<br>        for event in events:<br>            pod_key = f&quot;{event.namespace}/{event.involved_object.name}&quot;<br>            if pod_key not in pod_sequences:<br>                pod_sequences[pod_key] = PodEventSequence(<br>                    event.involved_object.name,<br>                    event.namespace<br>                )<br>            pod_sequences[pod_key].add_event(event)<br>        <br>        return pod_sequences</pre><h3>2. Feature Engineering</h3><pre>class FeatureEngineer:<br>    def extract_features(self, pod_state, event_sequence):<br>        &quot;&quot;&quot;Extract features for machine learning.&quot;&quot;&quot;<br>        features = {<br>            # Basic state features<br>            &#39;current_phase&#39;: pod_state.phase,<br>            &#39;ready_condition&#39;: pod_state.ready_condition,<br>            &#39;restart_count&#39;: pod_state.restart_count,<br>            &#39;age_seconds&#39;: pod_state.age_seconds,<br>            <br>            # Resource features<br>            &#39;cpu_usage_percent&#39;: pod_state.resource_usage.get(&#39;cpu&#39;, 0),<br>            &#39;memory_usage_percent&#39;: pod_state.resource_usage.get(&#39;memory&#39;, 0),<br>            <br>            # Sequence features<br>            &#39;event_count&#39;: len(event_sequence.events),<br>            &#39;state_changes&#39;: len(event_sequence.state_transitions),<br>            &#39;time_in_current_state&#39;: self.time_in_current_state(event_sequence),<br>            <br>            # Pattern features<br>            &#39;has_image_pull_issues&#39;: self.has_image_pull_issues(event_sequence),<br>            &#39;has_resource_pressure&#39;: self.has_resource_pressure(event_sequence),<br>            &#39;has_config_errors&#39;: self.has_config_errors(event_sequence),<br>            <br>            # Temporal features<br>            &#39;stuck_in_pending&#39;: self.is_stuck_in_pending(event_sequence),<br>            &#39;restart_escalation&#39;: self.has_restart_escalation(event_sequence),<br>        }<br>        <br>        return features</pre><h3>3. Machine Learning Integration</h3><pre>class MLPredictor:<br>    def __init__(self):<br>        self.models = {<br>            &#39;image_pull_failure&#39;: self.train_image_pull_model(),<br>            &#39;resource_exhaustion&#39;: self.train_resource_model(),<br>            &#39;crash_loop&#39;: self.train_crash_loop_model(),<br>            &#39;config_error&#39;: self.train_config_model()<br>        }<br>    <br>    def predict_failure_type(self, features):<br>        &quot;&quot;&quot;Predict the most likely failure type.&quot;&quot;&quot;<br>        predictions = {}<br>        <br>        for failure_type, model in self.models.items():<br>            prob = model.predict_proba([features])[0][1]  # Probability of failure<br>            predictions[failure_type] = prob<br>        <br>        # Return the most likely failure type<br>        return max(predictions.items(), key=lambda x: x[1])</pre><h3>The Real Challenges</h3><h3>1. Data Quality</h3><ul><li>Kubernetes events can be noisy and incomplete</li><li>Need to handle missing or delayed events</li><li>Must distinguish between real failures and expected state changes</li></ul><h3>2. False Positives</h3><ul><li>High false positive rate makes the system unusable</li><li>Need to tune confidence thresholds carefully</li><li>Must provide clear reasoning for predictions</li></ul><h3>3. Real-Time Performance</h3><ul><li>Must process events in real-time</li><li>Can’t afford to miss critical transitions</li><li>Need efficient data structures and algorithms</li></ul><h3>4. Model Training</h3><ul><li>Need sufficient historical data</li><li>Must handle concept drift as cluster changes</li><li>Require continuous retraining</li></ul><h3>What Success Would Look Like</h3><p>A working system would:</p><ol><li><strong>Monitor</strong> all pods in real-time</li><li><strong>Learn</strong> from historical failure patterns</li><li><strong>Predict</strong> failures 5–30 minutes before they happen</li><li><strong>Alert</strong> with specific failure type and confidence</li><li><strong>Learn</strong> from its own predictions to improve accuracy</li></ol><p>Example alert:</p><pre>🚨 FAILURE PREDICTION<br>Pod: my-app-7d8f9b4c-xyz<br>Namespace: production<br>Predicted Failure: ImagePullBackOff<br>Confidence: 87%<br>Time to Failure: 8 minutes<br>Reason: Pod stuck in Pending for 4 minutes, image pull attempts increasing</pre><h3>Conclusion</h3><p>Building a real Kubernetes failure predictor is a complex problem that requires:</p><ul><li><strong>Deep understanding</strong> of Kubernetes internals</li><li><strong>Sophisticated machine learning</strong> models</li><li><strong>Real-time data processing</strong> capabilities</li><li><strong>Extensive historical data</strong> for training</li><li><strong>Careful tuning</strong> to minimize false positives</li></ul><p>The Markov chain approach is a good starting point, but a production system would need to combine multiple techniques: temporal analysis, resource monitoring, pattern recognition, and machine learning.</p><p><strong>The key insight</strong>: This isn’t just a monitoring problem — it’s a prediction problem that requires understanding the complex interactions between Kubernetes components, application behavior, and infrastructure constraints.</p><p><em>This blog post represents a hypothetical analysis of what a real Kubernetes failure predictor would require. The actual implementation would be significantly more complex and would require extensive testing and validation.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b75bd668daa0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up a Complete Local AI Development Environment with Kagent & LMStudio]]></title>
            <link>https://medium.com/@denismarshalltumakov/setting-up-a-complete-local-ai-development-environment-with-kagent-lmstudio-1be318d95b57?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1be318d95b57</guid>
            <category><![CDATA[kagent]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[llamas]]></category>
            <category><![CDATA[kmcp]]></category>
            <category><![CDATA[lm-studio]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Sun, 17 Aug 2025 13:58:37 GMT</pubDate>
            <atom:updated>2025-08-17T13:58:37.335Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Building a self-contained development ecosystem for offline AI experimentation</em></p><p>Over the past few months, I’ve been diving deep into Kagent and MCP (Model Context Protocol) servers on Kubernetes clusters. This journey started as part of preparing our development teams with robust local environments for development, testing, and offline solutions. The goal was simple yet ambitious: create a setup where developers can work, explore, and create whenever they want, without any external dependencies.</p><h4>Why Local Development Matters</h4><p>In today’s AI-driven development landscape, having a reliable local setup is crucial. External API dependencies can slow down development, create costs during experimentation, and limit creativity when you’re offline or have connectivity issues. Our solution addresses these challenges head-on.</p><h4>Our Tech Stack</h4><p>Our battle-tested setup consists of:<br>- <a href="https://kagent.dev/docs/kagent"><em>Kagent</em></a> for AI agent orchestration<br>- <a href="https://orbstack.dev/"><em>OrbStack</em></a> as our lightweight Docker alternative<br>- <a href="https://kagent.dev/docs/kmcp"><em>KMCP</em></a> for deployment and project setup<br>- <a href="https://lmstudio.ai/docs/app"><em>LMStudio</em></a> for local model hosting<br>- <a href="https://github.com/DmarshalTU/kmcp/tree/feat/typescript-framework"><em>TypeScript support</em></a> (custom implementation)</p><figure><img alt="Architecture diagram showing the interaction between all components" src="https://cdn-images-1.medium.com/max/1024/1*1dYrz9p4_7HIN0XJqF7SNA.png" /></figure><h4>Prerequisites and Installation</h4><p>Step 1: Install OrbStack</p><p>We chose OrbStack over Docker Desktop for its superior performance on macOS, though these guidelines work across platforms.</p><pre>brew install orbstack</pre><p>Step 2: Install Kagent and KMCP</p><pre># kagent<br>curl https://raw.githubusercontent.com/kagent-dev/kagent/refs/heads/main/scripts/get-kagent | bash<br><br># kmcp<br>npm install -g @modelcontextprotocol/inspector<br>curl -fsSL https://raw.githubusercontent.com/kagent-dev/kmcp/refs/heads/main/scripts/get-kmcp.sh | bash</pre><p>Step 3: TypeScript Support Setup</p><p>One of the key improvements we made for our team was implementing TypeScript support. You can find the detailed implementation in our KMCP issue tracker.</p><p><a href="https://github.com/kagent-dev/kmcp/issues/57"><strong>KMCP TypeScript support issue</strong></a></p><pre># clone the repo with TP version<br>git clone git@github.com:DmarshalTU/kmcp.git<br>cd kmcp<br><br># make sure you have go installed<br>make build-cli</pre><p>For easier access, move the built TypeScript version to your local bin:</p><pre>sudo mv ./dist/kmcp /usr/local/bin/kmcpT # rename for both version for now</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*inAfUAlfzmYyQXkEMYzWyg.png" /></figure><h4>Project Initialization</h4><p>With our tools installed, let’s initialize a new project:</p><pre>kmcp init typescript demoProject</pre><p><strong>Testing with Inspector</strong></p><p>Before diving deeper, let’s verify our setup works:</p><pre>cd demoProject<br>kmcp run</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LTYUBiIXqxncjwtHyDpsCw.png" /></figure><h4>Setting Up LMStudio for Local Models</h4><p>Now we need a local model that can work with our MCP setup. LMStudio is perfect for this:</p><p><strong>Installation and Model Download</strong></p><p>1. Download and install LMStudio</p><p>2. Download your preferred models</p><h4>Connecting Everything Together</h4><p>In LMStudio’s chat interface, we can now connect our components. For local development, we’ll use stdio with these commands:</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;hf-mcp-server&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;tsx&quot;,<br>        &quot;src/index.ts&quot;<br>      ],<br>      &quot;cwd&quot;: &quot;/PATH_TO_PROJECT/demoProject&quot;,<br>      &quot;env&quot;: {<br>        &quot;NODE_ENV&quot;: &quot;development&quot;<br>      }<br>    }<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0msFEsCPqqx0zdcmLKFezg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iHF5ze3TDTrPZoieWWdL5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MX0KTJkaqi7azOv9VuKT3g.png" /></figure><h4>Live Development and Testing</h4><p>One of the most powerful aspects of this setup is the ability to update tools in real-time, so you have inspetcor runnig for debug, and node run for the lm integration.</p><p>You can immediately see changes in action without restarting services or reconnecting to external APIs.</p><h4>Multi-Language Support</h4><p>This setup isn’t limited to TypeScript. It works seamlessly with Python and Golang.</p><p>Simply adjust the settings in your configuration files to match your preferred language.</p><h4>Benefits of This Setup</h4><p><strong>Complete Offline Capability</strong><br>- No internet dependency for development<br>- Consistent performance regardless of network conditions<br>- Full control over your development environment</p><p><strong>Cost-Effective Development</strong><br>- No API costs during experimentation<br>- Unlimited local testing and iteration<br>- Perfect for prototyping and learning</p><p><strong>Team Consistency</strong><br>- Standardized development environment<br>- Easy onboarding for new team members<br>- Reproducible results across different machines</p><p><strong>The Complete Local Chain</strong></p><p>What we’ve built is a complete local development chain:<br>- ✅ Local Kubernetes cluster<br>- ✅ Local Docker engine with OrbStack<br>- ✅ Local LLM with LMStudio<br>- ✅ Local MCP server for tool integration<br>- ✅ Full TypeScript/Python/Go support</p><p><strong>Conclusion</strong></p><p>This setup has transformed how our development teams approach AI-powered applications. Having a completely self-contained environment removes barriers to creativity and experimentation. Developers can now focus on building great solutions rather than managing dependencies and external service limitations.</p><p>The combination of Kagent, OrbStack, KMCP, and LMStudio creates a powerful, flexible, and reliable foundation for AI development. Whether you’re building agents, experimenting with different models, or creating complex AI workflows, this setup provides the independence and control you need.</p><p>Happy coding! 🚀</p><p>— -</p><p><em>Have questions about this setup or want to share your own improvements? Leave a comment below or reach out on </em><a href="https://www.linkedin.com/in/dm2macoff/"><em>LinkedIn</em></a><em>.</em></p><p>— -</p><p>*This article is part of our ongoing series on AI development tools and best practices. Follow for more insights on building robust AI development environments.*</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1be318d95b57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a VictoriaLogs MCP Server with Kagent: A Complete Journey from Zero to POC]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@denismarshalltumakov/building-a-victorialogs-mcp-server-with-kagent-a-complete-journey-from-zero-to-poc-a3f49bdc57a9?source=rss-a89c5350599a------2"><img src="https://cdn-images-1.medium.com/max/1704/1*Kypjz3_WGlIrnxGWhAb5Rw.png" width="1704"></a></p><p class="medium-feed-snippet">How I built a comprehensive log analysis tool that enables NOC personnel to query VictoriaLogs using natural language, create dashboards&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@denismarshalltumakov/building-a-victorialogs-mcp-server-with-kagent-a-complete-journey-from-zero-to-poc-a3f49bdc57a9?source=rss-a89c5350599a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@denismarshalltumakov/building-a-victorialogs-mcp-server-with-kagent-a-complete-journey-from-zero-to-poc-a3f49bdc57a9?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3f49bdc57a9</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kagent]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Sun, 03 Aug 2025 21:27:57 GMT</pubDate>
            <atom:updated>2025-08-03T21:33:05.356Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Nushell for DevOps: A Practical Guide]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">This guide is specifically designed for DevOps engineers looking to leverage Nushell (Nu) in their workflow.</p><p class="medium-feed-link"><a href="https://medium.com/@denismarshalltumakov/nushell-for-devops-a-practical-guide-f8142434e778?source=rss-a89c5350599a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@denismarshalltumakov/nushell-for-devops-a-practical-guide-f8142434e778?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8142434e778</guid>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nushell]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Sat, 26 Apr 2025 11:49:34 GMT</pubDate>
            <atom:updated>2025-04-26T11:49:34.512Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Make games using Zig and Raylib]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@denismarshalltumakov/make-games-using-zig-and-raylib-46c786adca8f?source=rss-a89c5350599a------2"><img src="https://cdn-images-1.medium.com/max/600/0*j2kp2H0OwUosTGe4.png" width="600"></a></p><p class="medium-feed-snippet">Working in DevOps, I needed a break from the usual stack. Instead of picking up another infrastructure tool, I decided to explore systems&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@denismarshalltumakov/make-games-using-zig-and-raylib-46c786adca8f?source=rss-a89c5350599a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@denismarshalltumakov/make-games-using-zig-and-raylib-46c786adca8f?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/46c786adca8f</guid>
            <category><![CDATA[raylib]]></category>
            <category><![CDATA[ziglang]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[zig]]></category>
            <category><![CDATA[odin]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Wed, 29 Jan 2025 13:50:48 GMT</pubDate>
            <atom:updated>2025-01-29T13:50:48.066Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building a Minimal Web Application with WebAssembly and C3]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@denismarshalltumakov/building-a-minimal-web-application-with-webassembly-and-c3-e049f81a5a6d?source=rss-a89c5350599a------2"><img src="https://cdn-images-1.medium.com/max/1280/0*Z8R1os3A7RN-yY-7.jpg" width="1280"></a></p><p class="medium-feed-snippet">Introduction</p><p class="medium-feed-link"><a href="https://medium.com/@denismarshalltumakov/building-a-minimal-web-application-with-webassembly-and-c3-e049f81a5a6d?source=rss-a89c5350599a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@denismarshalltumakov/building-a-minimal-web-application-with-webassembly-and-c3-e049f81a5a6d?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e049f81a5a6d</guid>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[wasm]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 10:13:29 GMT</pubDate>
            <atom:updated>2024-08-02T10:33:46.540Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Introducing LogNimbus: The YAML-Based Logging Library for Modern Development]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@denismarshalltumakov/introducing-lognimbus-the-yaml-based-logging-library-for-modern-development-b05efad7968d?source=rss-a89c5350599a------2"><img src="https://cdn-images-1.medium.com/max/1128/1*51zIGL_XdLNj8lfs4Y0bFA.png" width="1128"></a></p><p class="medium-feed-snippet">As the complexity of software systems continues to grow, effective logging has become crucial for monitoring, debugging, and maintaining&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@denismarshalltumakov/introducing-lognimbus-the-yaml-based-logging-library-for-modern-development-b05efad7968d?source=rss-a89c5350599a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@denismarshalltumakov/introducing-lognimbus-the-yaml-based-logging-library-for-modern-development-b05efad7968d?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b05efad7968d</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 18:51:04 GMT</pubDate>
            <atom:updated>2024-07-23T18:51:04.570Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[WebAssembly in Kubernetes: Enhancing Performance and Security through Innovation]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@denismarshalltumakov/webassembly-in-kubernetes-enhancing-performance-and-security-through-innovation-036f687201a3?source=rss-a89c5350599a------2"><img src="https://cdn-images-1.medium.com/max/906/1*JLmIrq9uyY8XaynSFNncPw.png" width="906"></a></p><p class="medium-feed-link"><a href="https://medium.com/@denismarshalltumakov/webassembly-in-kubernetes-enhancing-performance-and-security-through-innovation-036f687201a3?source=rss-a89c5350599a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@denismarshalltumakov/webassembly-in-kubernetes-enhancing-performance-and-security-through-innovation-036f687201a3?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/036f687201a3</guid>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[spin]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[spinkube]]></category>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Wed, 17 Apr 2024 20:13:51 GMT</pubDate>
            <atom:updated>2024-04-18T06:03:14.411Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[OpenAI Crystal Library A Tiny Dall-E 3 UI for your homelab]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@denismarshalltumakov/my-crystal-journey-a-tale-of-learning-and-inspiration-fd5deba5f9c9?source=rss-a89c5350599a------2"><img src="https://cdn-images-1.medium.com/max/1024/1*FpWQ8XB29XIplUJNMkAm0Q.png" width="1024"></a></p><p class="medium-feed-snippet">Simon Marache MicroDalle project suited me very well because of his use of the openai library in Python and flask, at first glance the&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@denismarshalltumakov/my-crystal-journey-a-tale-of-learning-and-inspiration-fd5deba5f9c9?source=rss-a89c5350599a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@denismarshalltumakov/my-crystal-journey-a-tale-of-learning-and-inspiration-fd5deba5f9c9?source=rss-a89c5350599a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd5deba5f9c9</guid>
            <dc:creator><![CDATA[Denis Marshall Tumakov]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 20:06:06 GMT</pubDate>
            <atom:updated>2024-04-08T09:19:56.363Z</atom:updated>
        </item>
    </channel>
</rss>