skip to content
~/docs~/skills~/pricing~/faq~/dashboard

</aethereum> / blog

Interface contract drift: the hidden cost of AI-generated code

· 8 min read

Interface contract drift is what happens when two parts of a system stop agreeing on the shape of the interface between them. One side changes a signature, a type, or a payload; the other side keeps building against the old shape. The code still compiles on each side. It breaks where they meet.

An interface contract is the agreed shape of a boundary: the parameters and return type of a function, the request and response of an endpoint, the fields of a shared type, the schema of an event. Contracts are usually implicit. Nobody writes "this is a contract" next to a function. It just becomes one the moment a second piece of code depends on its shape. Drift is the silent divergence of those two understandings over time.

Why AI-generated code accelerates drift

Drift is not new, but AI coding agents make it faster and more frequent for one structural reason: parallelism without shared memory. Each agent works from its own context window. It confidently changes an interface based on the slice of the codebase it has read, with no awareness of who else depends on that interface or what they are doing right now. Multiply that across several agents on several machines, and contracts drift faster than any human reviewer can track.

Concrete examples

Renamed or reshaped function. Agent A changes getUser(id) to getUser(id, options) and makes the second argument required. Agent B, in parallel, adds ten new call sites with the old single-argument form. Both diffs are internally consistent. The merge is clean. The build fails on the ten new call sites, or worse, a runtime path slips through.

Changed response field. A backend agent renames the API field user_name to displayName. The frontend agent, unaware, keeps reading user_name. TypeScript is happy on each side because each side has its own type definition. The UI renders undefined in production.

Shifted enum or status value. One agent adds a new PENDING_REVIEWstatus to an order state machine. A downstream agent's exhaustive switch never handles it, and orders in that state silently fall through the default branch.

Detecting drift

Most teams detect drift far too late, at the boundary where it finally bites:

CI and integration tests catch it after a pull request exists, which is the most expensive moment, the agents are done and the context is gone. Type checkers catch a subset, but only within one repository checkout and only when both sides share a single source of truth for the type; a duplicated or hand-written type on the consumer side hides the drift completely. Code review can catch it in principle, but a reviewer cannot see a change a teammate has not pushed yet. The common thread: all of these look for drift after it has already been written into the codebase.

The earlier you detect drift, the cheaper it is. Detecting it at CI costs a failed build and a context-rebuild. Detecting it the moment the contract changes, while every dependent agent is still in session, costs a single alert. This timing difference is the whole game.

Preventing drift before CI

Prevention means making contract changes visible to every dependent agent the instant they happen, not the instant they merge. Concretely:

Make contracts explicit. Treat the shape of each shared boundary as a named thing an agent can declare and others can depend on, rather than an implicit assumption. Share contract state across machines. The dangerous drift is between uncommitted, in-flight changes on separate laptops, which Git and CI cannot see. Alert dependents on change.When a contract's shape changes, every agent that declared a dependency on it should hear about it as live context in its current session.

Aethereum implements exactly this pattern over MCP. Agents declare contracts and dependencies, and a change to a contract surfaces as an alert to every dependent agent across the team, before a pull request is ever opened. Only the interface metadata an agent explicitly publishes is shared; never source code.

declare_contract(
'getUser',
'(id: string, options: { trace?: boolean }) => User',
{ dependsOn: ['User'] }
)
// dependents calling get_team_context() now see the new shape

This is the same mechanism that keeps AI agents from creating merge conflicts and keeps Claude Code, Cursor, and Codex in sync across a team. To put it to work, run npx aethereum init and see the documentation.

Takeaway

Contract drift is the hidden cost of AI-generated code: clean diffs, clean merges, and a boundary that quietly breaks because two agents stopped agreeing on its shape. You cannot out-review it at AI speed. The durable fix is to make contracts explicit and share their state across machines, so the moment one drifts, every agent that depends on it knows, while there is still time and context to fix it for free. It is free to start.

Give your agents a shared brain

Aethereumshares interface contracts, intent, and collision alerts across your team's AI coding agents, across machines, over MCP. Free to start.