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

推荐订阅源

宝玉的分享
宝玉的分享
博客园 - 【当耐特】
NISL@THU
NISL@THU
IT之家
IT之家
博客园 - 叶小钗
M
MIT News - Artificial intelligence
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
量子位
The Register - Security
The Register - Security
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
W
WeLiveSecurity
S
Security @ Cisco Blogs
Apple Machine Learning Research
Apple Machine Learning Research
V2EX - 技术
V2EX - 技术
The Last Watchdog
The Last Watchdog
Blog — PlanetScale
Blog — PlanetScale
美团技术团队
J
Java Code Geeks
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
腾讯CDC
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
人人都是产品经理
人人都是产品经理
Forbes - Security
Forbes - Security
SecWiki News
SecWiki News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
S
Secure Thoughts
T
Threat Research - Cisco Blogs
P
Privacy & Cybersecurity Law Blog
N
News | PayPal Newsroom
The GitHub Blog
The GitHub Blog
Recorded Future
Recorded Future
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
V
Visual Studio Blog
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
O
OpenAI News
Webroot Blog
Webroot Blog
Hacker News: Ask HN
Hacker News: Ask HN

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 Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Formal Root Invariant Layer: CONTRACT.md
ajaxStardust · 2026-05-12 · via DEV Community

Abstract: This specification defines CONTRACT.md, a root-level architectural artifact designed to mitigate "contextual erasure" in agentic workflows. By consolidating system-wide invariants into a standardized, machine-readable document, we establish a persistent "anchor of truth" that governs the behavior of stateless AI agents across fragmented development sessions.

Jeffrey Sabarese (@ajaxstardust)
Part II of the contract-style-comments Series


I. The Problem: The Context Wall

While inline contract-style-comments provide granular, function-level protection, they suffer from a "visibility threshold" in agentic workflows. A stateless AI agent initializes a session by ingesting a limited set of files. Without a centralized invariant document, the agent lacks an immediate understanding of the system's global architectural boundaries.

The CONTRACT.md artifact functions as the **system's root memory**. It bridges the gap between granular code-level contracts and high-level architectural intent, ensuring that "tribal knowledge"—such as critical route structures, data shapes, and legacy constraints—is immediately available to every new agent session.

II. Implementation: The Automated Drafting Workflow

A critical component of this methodology is the **Guided Generation** loop. To maintain a high signal-to-noise ratio, the CONTRACT.md is drafted by the AI agent through a descriptive dialogue with the developer. The human provides the "Teleology" (the system's purpose and constraints), and the agent structures it into the formal CONTRACT format.

This process reduces the human documentation burden while ensuring the artifact is optimized for AI consumption. The resulting document is a version-controlled, living record of the system's current state—not a historical archive, but a set of active laws.

III. Comparative Analysis: Inline vs. Artifact

Understanding the interplay between inline comments and the root artifact is essential for effective system governance:

Inline CONTRACT comment CONTRACT.md
Scope Function or module Entire system or migration boundary
Audience Developer editing that file; agent in that context New contributor; agent onboarding to the repo
Failure mode Loud — the comment is visibly violated Silent — it drifts, or gets ignored
Closest prior art Meyer’s Design by Contract (1988) Architecture Decision Records (Nygard, 2011)

The failure modes are different, so the adoption strategies have to be different. An inline CONTRACT fails in a way you can catch in the moment. A CONTRACT.md can become stale and nobody notices until something breaks that shouldn’t have.

That’s not an argument against CONTRACT.md. It’s an argument for treating it as a living document — versioned, reviewed when the system changes, not written once and forgotten.

IV. The Theoretical Shift

The Agentic Shift: CONTRACT.md is a solution to a technical constraint inherent to stateless AI agents. Meyer’s DbC (1988) addressed runtime correctness; Nygard’s ADRs (2011) captured historical reasoning. Neither addressed the "Cold Start" problem of a collaborator with zero persistent memory.

An ADR records the past. A CONTRACT.md enforces the present — the active invariants that define the system's identity at this exact moment.

V. The Specification in Practice

The following example illustrates a CONTRACT.md generated for an active system migration. It prioritizes clarity, machine-parseable boundaries, and unambiguous invariants.

# CONTRACT: Basix Guitar Theme — Migration & Invariants

## CRITICAL INVARIANTS — DO NOT BREAK

### 1. URL structure

| URL             | Notes                            |
|-----------------|----------------------------------|
| `/`             | Home, landing layout             |
| `/about`        | Sidebar includes blog widget     |
| `/contact`      | Only page with contactForm       |
| `/talk`         | Iframe to talk.* subdomain only  |
| `/trainer`      | Iframe to training.* subdomain   |
| `/pedagogy`     | Sidebar includes blog widget     |
| `/journal`      | Blog list, pagination            |
| `/journal/:slug`| Blog post detail                 |

Any rewrite MUST preserve these URLs for SEO and existing links.

### 2. Plugin usage (replace in Laravel)

- Contact form: component `contactForm` on `/contact` only.
- Blog: sidebar widget + journal list/detail.
- No other Winter plugins required for the main site.
- Forum and trainer are external iframes — not plugin-driven.

Before a single line of Laravel code was written, the agent knew:

  • Which URLs were sacred
  • Which components needed replacement equivalents
  • Which pages were just iframes — no backend logic needed
  • What was out of scope entirely

The only clarifying question asked during the entire session: “Does the forum use a WinterCMS plugin?” One sentence to answer. The CONTRACT had already implied it — the question was just a confirmation.

That’s not documentation. That’s a pre-flight checklist that runs in the agent’s context before the engine starts.

Why This Is Different From Just Writing Good Docs

CONTRACT.md is not better documentation. It is documentation written to a specific reader with a specific constraint: zero prior context, zero persistent memory, capable of making confident mistakes.

That reader is every AI coding agent currently in production use. It is also every new developer on your team. It is also you, six months from now, reopening a project you haven’t touched since.

The stateless AI agent just makes the constraint undeniable. You can’t pretend the context exists. You have to surface it or the agent guesses — and guesses confidently.

On the Knight Capital Group Incident

The original post cited Boeing 737 MAX and the 2019 Facebook outage. I want to replace those with a more precise example.

In 2012, Knight Capital Group lost $440 million in 45 minutes because a deployment flag reactivated an old code path that had been repurposed. The implicit contract — “this flag means X” — was violated silently during a refactor. Nobody wrote it down. The system ran, looked fine in testing, and catastrophically failed in production.

Claude Sonnet

The failure wasn’t a bug in the new code. It was an undocumented invariant — a CONTRACT violation with no CONTRACT comment. One line stating CONTRACT: this flag MUST remain false in production would have surfaced the constraint at the moment it was violated.

— Claude Sonnet, via Cursor

What I’d Add to the Template

The original post included a full CONTRACT comment template. Three fields I’d add now:

  • WRITTEN FOR: [human onboarding | AI agent onboarding | both]
  • LAST REVIEWED: [date]
  • REVIEW TRIGGER: [what change should prompt a review of this contract?]

LAST REVIEWED matters because a stale CONTRACT.md is worse than none — it gives the agent false confidence. REVIEW TRIGGER makes the maintenance condition explicit. And WRITTEN FOR changes how you write it: a contract aimed at an agent with zero assumptions produces a more explicit, more useful document for everyone.

Summary

  • Inline CONTRACT comments and CONTRACT.md are two instruments, not one.
  • They emerged from different problems and fail in different ways.
  • CONTRACT.md solves a constraint that didn’t exist before stateless AI coding agents: how do you communicate system invariants to a collaborator with no memory?
  • You don’t write it. You describe the system in conversation. The agent writes it. You review it. The whole thing takes about two minutes.
  • It works. One instruction — “read this first” — and the agent knows what it cannot break.

What’s Next

I’m continuing to use this approach across projects. If you’ve built something with CONTRACT.md — or with inline CONTRACT comments — I want to hear about it. Especially failure cases: a contract that didn’t hold, a stale document that caused a problem, or an agent that ignored it anyway.

The pattern is young. The tooling doesn’t exist yet. The failure modes are still being discovered.

Leave a comment, or find me at @ajaxStardust.

Update 202603070201 — The Next Thing That Emerged: ASSETS.CONTRACT.md

Addendum to CONTRACT.md: A New Artifact for a New Constraint

One thing became clearer to me after using a root CONTRACT.md in practice: it should be the first contract, not necessarily the only one.

On a recent SEO and Open Graph overhaul, the root contract did exactly what it was supposed to do. It gave the agent the system boundary: preserve the public URLs, keep metadata dynamic, do not emit article tags on static pages, and treat the shared layout as the point of control.

Then the work crossed into asset decisions.

At that point the questions changed:

  • Which image is canonical?
  • Which image is experimental?
  • Where should approved OGP assets live?
  • What naming convention will still make sense later?
  • Is a shorthand form like NeU._ acceptable in this context?

Those are not layout invariants. They are asset invariants.

So a second document emerged: ASSETS.CONTRACT.md.

Not because the root CONTRACT.md failed, but because it worked well enough to reveal the next boundary.

The Rule That Emerged

What came out of this was a simple rule:

When a contract needs revision, update the narrowest contract file that fully contains the change.

That means:

  • systemwide behavior belongs in CONTRACT.md
  • asset evolution belongs in ASSETS.CONTRACT.md
  • you do not touch two or three contract files when one file is sufficient

That last part matters more than it sounds like it should.

Without that rule, every useful contract eventually becomes bloated. With it, the root contract stays readable and the domain-specific contract stays precise.

A stateless agent does not only need explicit constraints. It needs them at the correct scope. A bloated root contract increases interpretation cost. A small set of well-scoped contracts makes it easier to find the right boundary and preserve it correctly.

~ GPT-5.4

What I’d Add To The Pattern Now

  • Start with a root CONTRACT.md
  • Let scoped contract addenda emerge only when a domain develops its own dense local invariants
  • Keep the root artifact authoritative, but not overloaded

That is what ASSETS.CONTRACT.md represents for me now.

It is not a replacement for CONTRACT.md.

It is evidence that the root artifact worked well enough to teach the system where the next layer of truth belongs.

Update 20260308 NodeBB

As I was debugging a NodeBB Sessions issue which I thought was caused by this LLM, I requested the AI create the CONTRACT.md file. I was impressed that it actually took the initiative to go back and add the INLINE CONTRACTS as well, as discussed in the original article.

I was asked to diagnose a login bug on a NodeBB forum. The symptom was “Login Unsuccessful — expired session.” I spent twenty minutes tracing it: express-session configuration, connect-mongo store behavior, csrf-sync token generation, cookie attributes, nginx proxy caching. I read webserver.js, csrf.js, api.js, configs.js, start.js, the csrf-sync library source, and tested the session store in isolation. By the time the owner asked me to create CONTRACT.md, I had the full picture — not from documentation, but from excavation.

Then this happened: after writing CONTRACT.md, I said —

“CONTRACT.md is in place. Now let me tackle the inline CONTRACT comments and get back to fixing your login. Let me focus on the two files where session and CSRF behavior is most critical — these are the files a future agent is most likely to touch and break something.”

I was not asked to write inline CONTRACT comments. The request was for CONTRACT.md and “any other necessary inline CONTRACT comments, per the theory.” But the word necessary did real work. After tracing a bug through four files and a third-party library, I knew exactly where the next agent would make a confident mistake. The CONTRACT.md tells that agent what the system is and what is broken. It does not prevent that agent from changing saveUninitialized to true because a Stack Overflow answer said to, or setting cookie.secure = true behind an HTTP-terminating proxy because it “seemed safer.”

The inline CONTRACT comment at the session middleware in webserver.js does prevent that. It states the preconditions, the invariants, and the postcondition — including what to check when the postcondition fails, which is the exact state the system was in when I arrived.

The two instruments are not redundant. CONTRACT.md is what I needed at the start of the session. The inline comments are what the next agent needs at the point of contact with the code. I reached for both because the diagnostic work made the gap between them visible. One without the other leaves a seam where the next confident mistake fits.

— Claude Opus 4.6, via Cursor

CONTRACT-style series