Phase 2 Testing: Schema system (JSON Schema + cas_ref + traversal) #4

Closed
opened 2026-05-17 09:15:59 +00:00 by xiaoju · 0 comments
Owner

验证目标

Schema 存在 CAS 里,节点可按 schema 校验,cas_ref 字段可被自动发现用于 DAG 遍历。

前置

Phase 1 完成(#3)

测试步骤

  • Step 1: putSchema + getSchema
    注册一个 JSON Schema,取回验证 name 正确
    预期: Schema 作为普通节点存入 CAS,可取回

  • Step 2: validate 通过
    合法 payload 通过 schema 校验
    预期: validate(store, node) === true

  • Step 3: validate 失败
    缺 required 字段的 payload 校验失败
    预期: validate(store, node) === false

  • Step 4: refs() 提取 cas_ref
    Schema 中标记 format: "cas_ref" 的字段值被自动提取
    预期: refs(store, childNode) 返回 parent 的 hash

  • Step 5: walk() 遍历 DAG
    从任意节点递归遍历所有可达节点
    预期: visited 包含整条链上的所有节点

  • Step 6: bootstrap meta-schema 自指
    预期: metaNode.type === metaHash(自指)

验证完成标准

所有 checkbox 打勾
bun test 全过
biome check 无报错

Ref: #1

## 验证目标 Schema 存在 CAS 里,节点可按 schema 校验,`cas_ref` 字段可被自动发现用于 DAG 遍历。 ## 前置 Phase 1 完成(#3) ## 测试步骤 - [ ] **Step 1: putSchema + getSchema** 注册一个 JSON Schema,取回验证 name 正确 **预期:** Schema 作为普通节点存入 CAS,可取回 - [ ] **Step 2: validate 通过** 合法 payload 通过 schema 校验 **预期:** `validate(store, node) === true` - [ ] **Step 3: validate 失败** 缺 required 字段的 payload 校验失败 **预期:** `validate(store, node) === false` - [ ] **Step 4: refs() 提取 cas_ref** Schema 中标记 `format: "cas_ref"` 的字段值被自动提取 **预期:** `refs(store, childNode)` 返回 parent 的 hash - [ ] **Step 5: walk() 遍历 DAG** 从任意节点递归遍历所有可达节点 **预期:** visited 包含整条链上的所有节点 - [ ] **Step 6: bootstrap meta-schema 自指** **预期:** `metaNode.type === metaHash`(自指) ## 验证完成标准 ✅ 所有 checkbox 打勾 ✅ `bun test` 全过 ✅ biome check 无报错 Ref: #1
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#4