protocol-conformance

A protocol drift check for keeping server-sent events and the desktop interface in agreement. It compares real event sequences with expected results and requires every event type to be handled.

In plain words
What is it for?
Use it after changing event data, state folding, run-tree display, resume or approval states, or the backend event contract. Run the conformance checks before release.
Why use it?
It catches changes where the backend and desktop interpret the same event differently, before the mismatch reaches users.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/lawofall/agentcore/protocol-conformance
Clone the repo
git clone --depth 1 https://github.com/Lawofall/AgentCore

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,115 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01115
Opus 5 $0.00000 $0.00558
Sonnet 5 $0.00000 $0.00223
Haiku 4.5 $0.00000 $0.00112

Measured yesterday against content hash ab36e9eea52f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

protocol-conformance scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/protocol-conformance.mdc · 38 lines

What it actually says

协议漂移巡检

生产 fold 只留桌面(fold(events[]) → ProjectedTurn)。手机 fold 已退役。行为对齐靠这套巡检让漂移「响」、可被 AI 自动发现。背景见 前端技术与架构.md §十 SSE 与协议一致性

现状:只跑桌面conformanceFold 适配器复用桌面真实的 projectExecution(团队图),单聊 process 时间线复用 @/lib/processTimeline

三支柱

  1. 后端权威向量 + golden oracle——packages/protocol-conformance 存:后端导出的真实事件序列(向量)+ 后端投影的期望 ProjectedTurngolden)。桌面 fold 跑同向量、断言 == golden后端是输入与期望的单一源
  2. 共享类型 + 穷尽——桌面 import 同一套事件类型;fold 用判别联合 switch + assertNever 兜底。后端加事件类型 → 重生成 → 编译失败直到处理。
  3. AI 可操作——pnpm conformance = 桌面 pnpm -C apps/desktop run conformance(vitest;根 pnpm -r run conformance 只跑仍声明该脚本的包)。失败打 ProjectedTurn diff(golden vs actual)指到分叉字段。发布前本地必跑 pnpm conformance / release:gate

何时必跑 / 必更新

  • 动桌面协议 fold → 必跑 pnpm conformance
  • 给已有事件 payload 加可选字段 → 字段消费棘轮必须绿(叶名在 desktop/admin/fold-kit 生产代码有读点,或基线分组豁免)。独立于事件名孤儿闸。判据是叶名零命中,不是 AST (事件,字段);解构 / idField / 整包再读 / 重命名拷贝都算读。禁止靠删契约字段过闸。uv run python scripts/check_event_field_consumers.pyrelease:gate backend)。
  • 新增向量 → 后端哨兵 apps/server/tests/test_conformance_projection*.py 有覆盖棘轮(未写手验断言的向量数只降不升),加向量会让它红:高危面(失败/中止/挂起态、无正文的空泡脸、生命周期不留幽灵卡)补一条手工推导的断言(禁抄 golden——抄了就和 oracle 同错),其余面显式抬基线数字。
  • 后端改事件契约 / 投影 → 重导向量 + golden(单一源),桌面对齐到红转绿。
  • 发现协议 bug → 先加一条复现向量(棘轮),再修。向量两来源:手写 builder(agentcore/conformance/vectors/)或从真实回合录制裁切(agentcore/conformance/recording_cut.py,产物 recorded_* 前缀)→ 见 前端技术与架构.md §十 SSE 与协议一致性
  • 手写向量字段值必须与生产实现逐字一致(group/channel 等分类字段尤甚),禁 null/占位敷衍。取证员向量若写 group:null 而生产发 debate:investigators:*,布局会在全绿 CI 下击穿。新增 run 类向量时对照产出该 run 的后端代码抄真值。

ProjectedTurn(规范化裁判态)

平台无关、可序列化:{ messages, runs(树), status, pendingInteraction, cost }。桌面实现 fold → ProjectedTurn 测试快照(内部 store 形状可不同)。

边界

只巡检协议 / 状态 fold(高危、静默、只能测试抓);组件 / chrome 不进巡检(错了一眼看见)。

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 38 lines · 0 tokens per session scan A ab36e9eea52f

Subscribe to this mod's changes

protocol-conformance is a cursor rule published in the GitHub repository Lawofall/AgentCore (78 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,115 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.