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

推荐订阅源

The GitHub Blog
The GitHub Blog
I
InfoQ
U
Unit 42
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
月光博客
月光博客
D
Docker
Stack Overflow Blog
Stack Overflow Blog
D
DataBreaches.Net
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
博客园 - 聂微东
A
About on SuperTechFans
腾讯CDC
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
博客园 - 【当耐特】
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence

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
My test had a comment that said 'in memory fallback'. It ...
Deva · 2026-06-27 · via DEV Community

Deva

The test test_warmup_eval_no_flag_subprocess_exits_0 was running the real warmup eval command, no , dry run, against the live production state file. It had a comment claiming "in memory fallback." That comment was wrong.

The editable install (pip install e) resolves STATE_PATH at import time to wherever the real state.json lives. There is no separate test context, no isolated state, no in memory anything. Every time that test ran, it loaded the live warm up anchor, evaluated it, and wrote back to the same file my launchd job reads in production.

The reason this went unnoticed: the code path the test exercised was a pass through. Warm up state with no updates needed does nothing, so nothing got written back. The test passed, the file was unchanged, nobody noticed the test was running against live data.

Then I landed a fix in 1e1e53d that seeds the dwell anchor on the first warmup evaluate call. Now that code path writes something. The next full test run seeded the live anchor with a test timestamp and immediately violated the invariant that tests do not touch production state. The test was not lying about its intent. It was lying about its isolation.

The fix is straightforward once you see it. Add an X_ENGINE_STATE_PATH environment variable that overrides config.STATE_PATH when set. Default is unchanged so nothing in production is affected. All three warmup eval subprocess tests now point at a tmp_path fixture file instead of the real one. Subprocess tests are the trickiest case here because the subprocess inherits the parent environment and then imports config fresh, so the override has to be in the subprocess environment, not a monkeypatch on the parent process.

I verified it by running the full suite (141 tests) and diffing state.json before and after. Identical byte for byte.

What I would do differently

Add the env override at the same time I write any subprocess test that touches stateful code. The pattern is obvious in retrospect. Subprocess tests shell out to the installed package, which resolves paths against the real install location, not some test scoped mock. If your config has a file path and that path points somewhere real, you need an override mechanism before the test even exists.

Also: read your own test comments skeptically. "In memory fallback" is the kind of comment that gets written once, never verified, and silently becomes a lie the next time a code path changes. If the comment is load bearing, meaning someone might skip adding isolation because they read it and trust it, it needs a test that proves it. An unverified comment about isolation is just technical debt with a nice wrapper.

The real tell was that the pass through path masked the mutation. Tests that only pass because they happen to be a no op are not safe tests. They are time bombs waiting for the first code change that makes the path do something real. 1e1e53d was that change.

Now the suite is actually isolated. A full run can no longer advance, roll back, or halt the live warm up sequence. That is the bar subprocess tests should have been held to from the beginning.