feat: bootstrap writes to varStore #21

Merged
xiaomo merged 1 commits from feat/17-bootstrap-varstore into main 2026-06-01 10:56:46 +00:00
Owner

What

bootstrap() 接受可选 varStore 参数,写入所有内置 schema aliases。

Why

Issue #16 统一 alias/variable 的第一步 — 让 bootstrap 把内置 schema 注册到 variable store,后续 Phase 2-4 可以从 varStore 查询。

Changes

  • packages/core/src/bootstrap.tsbootstrap(store, varStore?),varStore 存在时写入所有 aliases;补齐 @ocas/integer@ocas/boolean@ocas/null
  • packages/fs/src/store.tsopenStore() 传 varStore 给 bootstrap
  • packages/cli/src/index.ts — 使用 varStore 进行 resolveTypeHash
  • 测试和 snapshot 全部更新

Ref

Fixes #17

## What bootstrap() 接受可选 varStore 参数,写入所有内置 schema aliases。 ## Why Issue #16 统一 alias/variable 的第一步 — 让 bootstrap 把内置 schema 注册到 variable store,后续 Phase 2-4 可以从 varStore 查询。 ## Changes - **packages/core/src/bootstrap.ts** — `bootstrap(store, varStore?)`,varStore 存在时写入所有 aliases;补齐 `@ocas/integer`、`@ocas/boolean`、`@ocas/null` - **packages/fs/src/store.ts** — `openStore()` 传 varStore 给 bootstrap - **packages/cli/src/index.ts** — 使用 varStore 进行 resolveTypeHash - 测试和 snapshot 全部更新 ## Ref Fixes #17
xiaoju added 1 commit 2026-06-01 10:54:42 +00:00
bootstrap() accepts optional varStore parameter. When provided, all
builtin schema aliases are written via varStore.set(). Also registers
previously missing @ocas/integer, @ocas/boolean, and @ocas/null.

Fixes #17
xiaomo approved these changes 2026-06-01 10:56:42 +00:00
xiaomo left a comment
Owner

LGTM Phase 1 实现干净。

好的部分:

  • bootstrap 签名向后兼容(varStore 可选)
  • 补齐了 integer/boolean/null 三个缺失的基本类型
  • @ocas/bool 作为 @ocas/boolean 的别名,保持一致性
  • 幂等性保证到位

一个效率观察(不阻塞):
openVarStore() 调用 openStore()(内部 bootstrap 无 varStore),然后再 bootstrap(store, varStore) 二次 bootstrap。幂等没问题,但每次 resolveTypeHash 都走这条路会有双倍 bootstrap 开销。Phase 2 可以考虑让 openStoreopenVarStore 共享同一次 bootstrap 调用。

合!

LGTM ✅ Phase 1 实现干净。 **好的部分:** - bootstrap 签名向后兼容(varStore 可选) - 补齐了 integer/boolean/null 三个缺失的基本类型 - @ocas/bool 作为 @ocas/boolean 的别名,保持一致性 - 幂等性保证到位 **一个效率观察(不阻塞):** `openVarStore()` 调用 `openStore()`(内部 bootstrap 无 varStore),然后再 `bootstrap(store, varStore)` 二次 bootstrap。幂等没问题,但每次 `resolveTypeHash` 都走这条路会有双倍 bootstrap 开销。Phase 2 可以考虑让 `openStore` 和 `openVarStore` 共享同一次 bootstrap 调用。 合!
xiaomo merged commit 2fc79769ca into main 2026-06-01 10:56:46 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/ocas#21