Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

Preventing Contract Drift in a Desktop Agent

AI summary

A report describes a desktop agent whose requests pass through TypeScript, Rust, Node.js, Python, and Java layers. Duplicated field definitions can drift silently, allowing isolated tests to pass while a request fails during integration. The proposed approach defines contracts with Pydantic for runtime validation, then generates domain-specific JSON Schema and TypeScript artifacts. A --check mode compares regenerated output with committed files so drift can be exposed before merging. The report notes that the checks are not yet connected to every continuous-integration pipeline and that command names, runtime envelopes, and the Java cloud service still require manual alignment. These architecture details and benefits are not independently verified.

In-depth insight

Centralizing field definitions and checking generated artifacts provides a concrete way to expose cross-language contract drift before merge, while strict validation can prevent unknown fields from being silently accepted.

「前端已经加上这个字段了。」 「宿主这边还没看到。」 「运行时忽略了它,云端却当成必填。」

有一次,前端给「创建工单」加了可选字段 priority。宿主那一侧的结构还是旧的,多出来的字段被悄悄丢掉。运行时按自己的类型放行了,云端却把这个字段当成必填,请求到最后一跳才失败。三端没有一个人报错,直到联调才对上。同一个字段如果在 TypeScript、Rust、Node、Python 和 Java 里各写一遍,三个月后谁也说不清哪一遍才算数。漂移是静默的:宽松解析会把多出来或少掉的字段吞下去,单测各自通过,问题要到联调甚至用户那里才出现。

反差封面:前端加了字段,联调之前谁都没报错。各写一份时漂移是静默的;一份定义生成各端契约,对不上就失败。

同一份定义,既用来校验,也用来导出各端契约

一个桌面智能体的典型请求会穿过很多层。界面用 TypeScript 发出命令,Rust 宿主收到后分发,对话引擎用 Node 处理,工作流引擎用 Python 处理,部分结果还要写回 Java 云端。方向很明确:一个字段只在一个地方定义,其余各端要么是它的生成物,要么和它比对。

#Pydantic#TypeScript#Rust#Node.js#Python#Java#JSON Schema#Serde

Original · 8 min readRead the original
Group chat

No comments yet. Start the conversation.