fix(metadata-protocol): 保存的 overlay 立即可派发 —— 写路径直写 SchemaRegistry(#4521) - #4622
Merged
Merged
Conversation
…ry so they are dispatchable immediately (#4521) A just-saved overlay was listed but not dispatchable for a short window: saveMetaItem only wrote the registry through for `object`, so every other overlay type reached it solely via the READ-side hydration in getMetaItems — the listing call is what repaired the dispatch path. resolveRouteActionDeclaration reads the registry, so `PUT /meta/action/x` followed by `POST /actions/<obj>/x` answered the ADR-0110 "has no declaration" 404 until someone listed the type. - Extract the read-side hydration rule (ADR-0010 §3.3 protection graft, ADR-0048 package-scoped artifact lookup) into hydrateOverlayIntoRegistry and share it between getMetaItems and the new applyRegistryWriteThrough. - Call the write-through from saveMetaItem (publish mode), runPublishSideEffects (draft promotion), and rollbackMetaItem — for EVERY overlay type, with the same environmentId scoping gate the read carries. - Boundaries pinned by tests: drafts never leak into the live registry, ADR-0110's 404 for a genuinely absent declaration stands, and DELETE still restores the packaged artifact (the overlay is a plain-key shadow). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
August 2, 2026 11:47
os-zhuang
enabled auto-merge
August 2, 2026 11:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4521
问题
#4432 F1 验证发现:
PUT /api/v1/meta/action/{name}成功后的一小段窗口内,GET /api/v1/meta/action已经能列出该 overlay,但POST /api/v1/actions/{object}/{name}却返回 ADR-0110 的 "has no declaration" 404,稍后再调用又成功。期间没有任何东西过期——是那次列表读取修好了派发路径。根因
滞后的"缓存"就是引擎的
SchemaRegistry。运行时派发路径(resolveRouteActionDeclaration)把 registry 当作元数据的实时视图来读(来源 2),但saveMetaItem只对object类型做写后同步(applyObjectRegistryMutation对其它类型直接返回);其余 overlay 类型进入 registry 的唯一途径是getMetaItems的读侧水合。于是"这个类型有没有人列过"悄悄决定了刚保存的 action 能不能被调用——写后读一致性取决于读取顺序。修复(生产者侧,符合 Prime Directive #12)
没有在派发点加任何重试、休眠或容错回退,而是让写入本身把 registry 写透:
applyRegistryWriteThrough,在三个"写入已生效"的时点调用:saveMetaItem(仅mode === 'publish')、runPublishSideEffects(草稿晋升发布)、rollbackMetaItem(回滚后的正文即为线上正文)。对所有 overlay 类型生效,object分支行为不变。hydrateOverlayIntoRegistry(含 ADR-0010 §3.3 保护信封嫁接、ADR-0048 按行所属包做 artifact 查找),getMetaItems与写透共用一份实现——读和写不可能再把 registry 留在两种不同状态。environmentId === undefined门:环境作用域的行不会泄漏进控制面共享的 registry。写不会比读更宽松。object分支一致):行已持久化,registry 打嗝只会退化为修复前的行为(下次列表水合),绝不会丢写。边界(测试钉住)
restoreArtifactRegistryView结构性保证,该测试已反转并注明缘由)。测试
packages/runtime/src/meta-overlay-read-your-writes.test.ts(7 例):用真实的ObjectStackProtocolImplementation.saveMetaItem+ 真实SchemaRegistry+ 真实resolveRouteActionDeclaration复现 PUT→POST 原始场景(中间无任何列表调用),并钉住上述三条边界;去掉写透即失败。packages/objectql/src/protocol-meta.test.ts中的旧断言并注明历史缘由。pnpm --filter @objectstack/metadata-protocol test:25 文件 206 例通过;--filter @objectstack/objectql test:98 文件 1596 例通过;--filter @objectstack/runtime test:77 文件 1063 例通过。@objectstack/objectqltypecheck 通过;check:type-check-coverage棘轮 OK(metadata-protocol / runtime 在 DEBT 账本内,未新增超额)。备注
loadMetaFromDb(启动水合)还有第三处内联的同规则拷贝,其 artifact 查找未按行所属包收窄(ADR-0048 视角的既有不一致),与本 issue 的写后读窗口无关,未在本 PR 扩权修改。🤖 Generated with Claude Code
https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
Generated by Claude Code