Skip to content

feat(spec,runtime): make seed a first-class, publish-applied metadata type#1611

Merged
xuyushun441-sys merged 1 commit into
mainfrom
feat/seed-metadata-type
Jun 6, 2026
Merged

feat(spec,runtime): make seed a first-class, publish-applied metadata type#1611
xuyushun441-sys merged 1 commit into
mainfrom
feat/seed-metadata-type

Conversation

@xuyushun441-sys
Copy link
Copy Markdown
Contributor

动机

初始化/示例数据应当是平台一等公民,而不是旁路 insert。本 PR 把 seed 做成运行时可草拟、发布即落数据的元数据类型——和 object/view/app 一样走 stageDraft → 发布(ADR-0033)。发布一条 seed 草稿 = 把它的记录真正写入目标对象。

这样 AI 元数据助手(或任何作者)可以把示例/种子数据当作可审阅的草稿暂存,一键发布即生效。机制开源、智能闭源:生成 seed 行的 AI 在私有 studio 包,这里只放类型 + 应用路径。

dataset 名保留给未来的数据分析能力,故新类型独立命名为 seed(当前复用 Dataset 形状)。

改动

spec

  • MetadataTypeSchema + DEFAULT_METADATA_TYPE_REGISTRY 注册 seed(domain: data、allowRuntimeCreate、loadOrder 95 使被引用对象先就绪),在 type→schema 映射绑定 SeedSchema
  • 新增 SeedSchema/Seed(复用 Dataset 形状,独立命名以便 seed 与分析向的 dataset 各自演进)。

runtime

  • publish-drafts handler 对每个刚发布的 seed 调用既有 SeedLoaderService 落数据(best-effort、幂等 upsert、绝不因 seed 失败而让发布失败,结果并入响应的 seedApplied)。放在 runtime 层是因为 loader 需要 data engine + metadata service,objectql 不能反向依赖 runtime。

验证

  • spec 单测 45 通过(含新增 seed 注册契约测试)。
  • runtime tsc --noEmit 0 错误。
  • SeedLoaderService 自身已有充分单测,本 PR 复用之。

后续(分开 PR)

  • cloud service-ai-studio:create_seed 工具,AI 用 ai.generateObject 生成符合对象 schema 的行 → stageDraft(type:'seed');skill 指示"建完→提议填充示例数据"。

…ta type

Initialization / fixture data becomes a runtime-draftable metadata type
(`seed`), authored and published through the same draft → publish flow as
object/view/app (ADR-0033). Publishing a seed draft is what actually loads
its rows — so an author (or the AI metadata assistant) can stage sample/
seed data as a reviewable draft and make it live with one publish.

Mechanism only (open-core): the AI that *generates* seed rows lives in the
private studio package; this is just the type + apply path.

spec:
- register `seed` in MetadataTypeSchema + DEFAULT_METADATA_TYPE_REGISTRY
  (domain: data, allowRuntimeCreate, loadOrder 95 so referenced objects
  already exist), bind it to SeedSchema in the type→schema map.
- add SeedSchema/Seed (shares the Dataset shape today, named separately so
  the `seed` type can evolve independently of the analytics-bound `dataset`).

runtime:
- publish-drafts handler applies every just-published `seed` via the existing
  SeedLoaderService (best-effort, idempotent upsert, never fails the publish;
  result surfaced under `seedApplied`). Lives at the runtime layer because the
  loader needs the data engine + metadata service, which objectql cannot
  depend on without a cycle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 6, 2026 10:49am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants