Skip to content

ADR-0049:两份 activationEvents 声明四仓零 reader —— declared-but-unenforced,且 studio 侧 z.string() 零校验 #4657

Description

@os-zhuang

#4653(双源清账 C5)的三仓 import 扫描里掉出来的范围外发现,不在 #4653 的 PR 里修,单独立案。

事实

packages/spec 有两份 ActivationEventSchema,分别嵌在两个父 schema 的 activationEvents: 上:

声明 父 schema
kernel/plugin-runtime.zod.ts:74 z.object({ type: z.enum([...7 项]), pattern: z.string() }) DynamicLoadRequestSchema.activationEvents(.optional())
studio/plugin.zod.ts:285 z.string() StudioPluginManifestSchema.activationEvents(.default(['*']))

四仓(objectstack / cloud / cloud-v1 / objectui)全量扫描:没有任何运行时读取 activationEvents 命中的只有 spec 自身的源码与测试、生成文档,以及三个 VS Code 扩展自己的 package.json(packages/vscode-objectstackobjectui/packages/vscode-extensionobjectql/packages/tools/vscode-objectql)—— 那是 VS Code 的字段,与本平台无关。

外部佐证 —— cloud-v1/docs/ROADMAP.md:641 自己记着这条没实现:

| `plugin-runtime.zod.ts` -> `ActivationEventSchema` | Lazy activation triggers (onCommand, etc.) | ❌ | All plugins activated immediately on install | v0.4.0 |

即:所有插件安装即激活,惰性激活是 v0.4.0 的计划,不是今天的行为。

两重问题

  1. declared ≠ enforced(ADR-0049)。 作者在 studio plugin manifest 里写 activationEvents: ['onMetadataType:flow'](content/docs/plugins/development.mdx:387,带 os:check 标记的示例),期待插件被延迟到该事件才加载;实际它立即加载。这不是惰性 no-op,是一个语义上撒谎的键。

  2. studio 侧零校验。 z.string() 接受任何字符串:'''banana''onMetadatType:flow'(拼写错误)全部通过,作者拿不到任何反馈。文档里列的词表(*onMetadataType:onCommand:onView:)完全不被 schema 表达 —— 这正是 AI 生成的元数据出错后能长期潜伏的地方。对比 kernel 侧的 z.enum([...]) 至少挡得住 trigger 类型拼错。

建议处置(需维护者裁决,故不自行动手)

按 enforce-or-remove:要么在 v0.4.0 实现惰性激活并把词表收进 schema,要么按 ADR-0087 tombstone 掉这两处 activationEvents注意:ActivationEventSchema双源问题正由 #4653 处理,而「选哪个编码」的裁决与本单强耦合 —— 如果这个键最终要被 retire,#4653 就不该先为它挑一个编码。建议两单一起裁。

关联:#4653#4535、ADR-0049、ADR-0087

Activity

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