Skip to content

读侧的 ADR-0008 OCC 载体没有契约:GET /meta/:type/:name 非缓存分支发 lock/lockReason/lockSource,GetMetaItemResponseSchema 只声明 {type,name,item} #5950

Description

@baozhoutao

#5545(给 client.meta.getItem 补返回类型注解)里测绘到。写侧的同一问题已由 #5745 修掉(SaveMetaItemResponseSchema 曾是真实 body 的真子集,version/seq/state 被抹);读侧还留着一个没人收的同形缺口。

事实(基线 origin/main @ a6b3ee7a1)

spec 声明(packages/spec/src/api/protocol.zod.ts:234)只有三个键:

export const GetMetaItemResponseSchema = lazySchema(() => z.object({
  type: z.string(), name: z.string(), item: z.unknown(),
}));

生产端(packages/metadata-protocol/src/protocol.ts getMetaItem,主 return 在 :3733 附近)发的是超集:

return {
    type: request.type,
    name: request.name,
    item: decorated,
    lock: lockState.lock,
    ...(lockState.lockReason !== undefined ? { lockReason: lockState.lockReason } : {}),
    ...(lockState.lockSource !== undefined ? { lockSource: lockState.lockSource } : {}),

REST 侧 translateMetaEnvelope(packages/rest/src/rest-server.ts:2714)...envelope 原样铺开,所以这三个键会到线上。而 #5563 收敛后的缓存分支(默认 enableCache: true)重建的信封只有 { type, name } + item,代码注释里写明是有意的:

rest-server.ts:4278 — "The cached read carries no lock — it is the fast published-value path and never consulted the lock resolver; a caller that needs the ADR-0008 OCC carriers reads the uncached path."

为什么这是个缺口

#5563文档的形状在两条分支上收敛了,但 OCC 载体没有:lock 是否出现仍由服务端 enableCache 决定,且这件事在 spec 里一个字也没有。于是

处置(建议,待分诊)

GetMetaItemResponseSchema 上把三个键声明为 optional,并在 describe 里写清「仅非缓存读路径提供;缓存读路径不解析锁」——这与 #5745 的做法一致(先实测哪些必选、哪些条件出现,再照实声明),且不改任何运行时行为。若认为「配置决定字段有无」本身才是要修的,那是更大的一步,应单独定案。

关联:#5545(测绘出处)、#5563(读路由形状收敛)、#5745(写侧同形缺口,已修)、ADR-0008。

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions