惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
C
Check Point Blog
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
V.E.L.O.C.I.T.Y.-OS: Kimi K2.7 and the 'Safe-Room Securit...
UnitBuilds · 2026-06-28 · via DEV Community

It all started on June 23rd with a casual post about a VPS Manager benchmark.

Out of curiosity, I decided to ask the author of the benchmark,

, if he had tried Cloudflare's new Workers AI offering—specifically Kimi K2.7, a massive 1-trillion parameter MoE (Mixture of Experts) model that was incredibly cheap ($0.27 per million input tokens) and highly capable at code generation.

Pascal was intrigued. He pointed out a brilliant hypothesis: if a model makes significantly fewer mistakes, the total session cost drops dramatically even if the per-token price is higher. He cited GLM 5.2 as a model that self-corrected multiple bugs during verification to achieve 37/37 tests passing.

Curiosity got the better of me. I spun up my development environment, wrote a custom agent harness, and ran it on Kimi K2.7 using Cloudflare Workers AI.


The V.E.L.O.C.I.T.Y.-OS Series Table of Contents

We are building a bare-metal, self-healing operating system running entirely inside the CPU's L3 cache. Here is the roadmap for this 12-part series:

  1. Part 1: The Spark — Exposing the "Safe-Room" security leak and building the compiler gate. (You are here)
  2. Part 2: The NDA Language — Designing a content-addressed triplet representation to cure context bloat.
  3. Part 3: Ditching the Web Stack — Building a native 30MB IDE with 1,500,000x IPC latency drops.
  4. Part 4: The Closure JIT — Compiling AST blocks to nested closures and bypassing borrow checker limits.
  5. Part 5: JIT Math Optimizations — Replacing division operations with precomputed 16-bit lookup tables.
  6. Part 6: x86-64 Assembler & SCEV-Lite — Compiling scalar loops directly to native code in constant time.
  7. Part 7: Classic Compiler Passes — Implementing inter-procedural Dead Code Elimination and loop unrolling.
  8. Part 8: Reclaiming Ring 0 — Exiting UEFI boot services and transitioning the kernel to Ring 0.
  9. Part 9: Bare-Metal Drivers — Writing a PCI scanner, NVMe block storage controller, and FAT32 parser.
  10. Part 10: Synaptic Canvas — Rendering a spatial, force-directed GUI based on model token activation vectors.
  11. Part 11: Swarms & Hot-Patching — Building multi-agent scheduling and zero-downtime RCU driver updates.
  12. Part 12: Self-Evolution — Handing system control over to a local LLM Terminal that self-optimizes via telemetry.

The Leak: Safe-Room Security

The initial run looked amazing—Kimi successfully completed 19 of the 30 foundation files on my daily free allocation, delivering the cleanest architectural layout of any model tested. But in the meantime, Pascal had run Kimi K2.7 himself and caught a major security blocker on DB credential handling.

This prompted me to dig into the 19 files from my own Foundry run, only to find the exact same mistakes: Kimi had exposed database connection credentials directly in the code.

Pascal pointed out that this wasn't a failure in reasoning—it was a scope failure. Kimi was operating under "safe-room security": it optimized for code correctness against the written spec, assuming it was running in a secure, isolated sandbox rather than a live production environment.

The Solution: Gatekeeper Static Scanning

Pascal suggested that rather than bloating every single system prompt with complex, instruction-taxing security warnings (which models eventually ignore or drift from), I needed a systematic gateway.

That conversation was the spark. I went to work on gatekeeper.rs and built a local security static analysis scanner and sandbox verifier directly into the compilation gate. The rule was simple: before any generated file could be marked as complete and persisted, the Gatekeeper ran systematic regex-based and syntax-tree scans to detect database credentials, hardcoded keys, and common security flaws.

Furthermore, I wired the compiler directly into an isolated JIT sandbox (AssertUnwindSafe) to dry-run the generated bytecode. If the JIT compilation or the dry-run failed, the compiler rejected the output, forced the model to reflect on the diagnostic error, and triggered an automatic self-correction loop.

Here is the architectural flow of how code moves from the LLM model to the secure, bare-metal storage layer:

Architecture diagram showing the LLM output flowing through a Rust-based regex and JIT scanner before being saved to disk.

Here is the core logic from gatekeeper.rs that classifies and verifies LLM-generated code in an isolated environment before committing it to the codebase:

// gatekeeper.rs — Gatekeeper Hybrid LLM Router & Sandbox Verifier
pub enum LlmRoute {
    CloudSwarm, // High-complexity planning (GPT-4o/Claude 3.5)
    LocalAgent, // Low-complexity execution (Qwen-Coder-0.5B)
}

pub fn classify_query(query: &str) -> LlmRoute {
    let q_lc = query.to_lowercase();
    if q_lc.contains("architecture") || 
       q_lc.contains("blueprint") || 
       q_lc.contains("refactor kernel") 
    {
        LlmRoute::CloudSwarm
    } else {
        LlmRoute::LocalAgent
    }
}

// Returns Vec<f32> representing the token activation states (the embedding vector)
// rather than raw bytecode, laying the groundwork for semantic clustering in Part 10.
pub fn route_and_generate(query: &str, site_map: &crate::nda_jit::SiteMap) -> Result<Vec<f32>, &'static str> {
    let route = classify_query(query);
    match route {
        LlmRoute::CloudSwarm => {
            // Plan via high-capacity cloud swarm...
            generate_bytecode_from_prompt(&format!("/* Cloud Swarm: {query} */"), site_map)
        }
        LlmRoute::LocalAgent => {
            // Direct generation via local model...
            generate_bytecode_from_prompt(query, site_map)
        }
    }
}

This security gate raised the floor for any model running through the pipeline. It was no longer about finding the most "secure" model—it was about building an infrastructure that forced security by construction.

But as the agent continued generating files, I hit another wall: context bloat. The context accumulation of self-correction was costing me valuable seconds and tokens.

In the next post, I'll detail how I tamed the context monster by inventing a new binary format and a multi-agent debate board.


Discussion

How are you all handling LLM "scope failures" in your local agents? Do you prefer prompt engineering or, like me, a hard-coded "Gatekeeper"? Have you noticed your LLM-generated code taking "security shortcuts" like this? I'd love to hear how you're validating AI output in your own pipelines!

Special thanks to

, whose peer critique on scope failures pushed me to build this security gate rather than relying on prompt engineering.

Disclaimer: AI was used throughout this project, it is just fitting that it would co-author with me, so special thanks to the Foundry for it's tireless hours toiling away and Gemini for producing the cover image.