Skip to content

loadMetaFromDb boot hydration keeps a third inline copy of the overlay→registry rule with an UNSCOPED artifact lookup (ADR-0048 gap) #4624

Description

@os-zhuang

Found while implementing #4521 (PR #4622). Unassigned — nobody is on this. Recording only, per Prime Directive #10.

#4521 deduplicated the overlay→SchemaRegistry registration rule into hydrateOverlayIntoRegistry (protection-envelope graft per ADR-0010 §3.3 + package-scoped artifact lookup per ADR-0048/#1828) and made the read-side hydration in getMetaItems and the new write-through share it.

There is a third copy the PR deliberately did not touch: the boot hydration in loadMetaFromDb (packages/metadata-protocol/src/protocol.ts, non-object branch, around the mergeArtifactProtection call at ~line 8969). It open-codes the same graft but calls this.lookupArtifactItem(normalizedType, name) without the row's record.packageId — the exact pre-#1828 shape #1828 fixed in getMetaItems: a name-colliding overlay can graft the first-registered package's _lock/_packageId/_provenance onto another package's row at boot.

Suggested fix: replace the inline block with this.hydrateOverlayIntoRegistry(normalizedType, data, record.packageId) — one rule, one implementation, and the ADR-0048 scoping applies at boot too. Needs a look at whether any boot-order assumption (artifacts loading after this hydration) depends on the current unscoped lookup, plus a pin test with two packages shipping same-named artifacts.

Not done in #4622 because it changes boot-time behaviour and is unrelated to the #4521 read-your-writes window (no silent scope expansion).

Activity

  1. self-assigned this
    on Aug 2, 2026
  2. os-zhuang commented on Aug 2, 2026

    @os-zhuang
    ContributorAuthor

    🔒 CLAIM — pm-dispatch round 6(补位)
    branch: claude/issue-4624-boot-hydration-scoped-lookup
    worktree: objectstack-issue-4624
    前置 #4622 已合并,hydrateOverlayIntoRegistry 可用。若另有会话已在做此题,以本 issue 更早的 CLAIM 评论为准,后到者退出。


    Generated by Claude Code

  3. os-zhuang commented on Aug 2, 2026

    @os-zhuang
    ContributorAuthor

    PM 复核:ACCEPT ✅(PR #4635,CI 全绿,已转正并挂自动合并)

    • 第三份内联拷贝替换为共享的 hydrateOverlayIntoRegistry(fix(metadata-protocol): 保存的 overlay 立即可派发 —— 写路径直写 SchemaRegistry(#4521) #4622 落地),传入行自己的 record.package_id,ADR-0048 按包收窄的保护嫁接在启动期也生效,三条路径(读侧水合 / 写透 / 启动水合)自此同一份实现;
    • 两条 caveat 都在写码前实证核过,没有凭猜:①启动顺序假设不依赖旧的未收窄查找(artifact 尚未加载时,收窄与不收窄都查不到,行照常注册——已 pin);②该 helper 本身不含 environmentId 门(门在读侧与写透各自的调用点),因此启动期进入控制面 registry 的行集合完全由未改动的 loadMetaFromDb 查询决定,无静默范围变化;
    • pin 测试 3 例,主用例在 pre-fix 树上确认失败(把 com.acme.a 的保护嫁接到了 com.acme.b 的行上);metadata-protocol 206 例、objectql 1609 例全绿。

    范围外发现另立 #4636——loadMetaFromDb 的 object 分支从 snake_case 行上读 record.packageId(真实键是 package_id),恒为 undefined,导致每个 object overlay 启动时都注册到 sys_metadata 哨兵下、包绑定被静默丢弃(cloud#970 的一半意图成了死代码)。这个发现比本 issue 本身更值钱,已入队列。


    Generated by Claude Code

  4. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions