Phase 1 Testing: Core primitives (hash + CBOR + memory store) #3

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

验证目标

从零开始建立 monorepo,实现最小可用的 CAS:能存节点、取节点、验证 hash。

前置

  • Bun workspace monorepo,biome 2.x
  • 包:@uncaged/json-cas(core,纯计算,零平台 API)
  • CBOR deterministic encoding (RFC 8949 §4.2)
  • XXH64 → 13-char Crockford Base32

测试步骤

  • Step 1: monorepo 结构可构建

    cd ~/repos/json-cas && bun install && bun run build
    

    预期: 构建成功,无报错

  • Step 2: CBOR deterministic 编码
    相同对象不同 key 顺序 → 相同 bytes
    预期: encode({ z:1, a:2 }) === encode({ a:2, z:1 })

  • Step 3: hash 计算
    hash(typeHash, payload) → 13-char Crockford Base32
    预期: 幂等;type 参与计算(不同 type + 相同 payload → 不同 hash)

  • Step 4: memory store put/get round-trip

    const store = createMemoryStore();
    const metaHash = await bootstrap(store);
    const h = await store.put(metaHash, { name: "test" });
    const node = await store.get(h);
    

    预期: node.type === metaHashnode.payload.name === "test"node.timestamp 自动填充

  • Step 5: verify 完整性
    预期: verify(h, node) === true

  • Step 6: 幂等 put
    预期: 重复 put 返回相同 hash,timestamp 保留首次值

验证完成标准

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

Ref: #1

## 验证目标 从零开始建立 monorepo,实现最小可用的 CAS:能存节点、取节点、验证 hash。 ## 前置 - Bun workspace monorepo,biome 2.x - 包:`@uncaged/json-cas`(core,纯计算,零平台 API) - CBOR deterministic encoding (RFC 8949 §4.2) - XXH64 → 13-char Crockford Base32 ## 测试步骤 - [ ] **Step 1: monorepo 结构可构建** ```bash cd ~/repos/json-cas && bun install && bun run build ``` **预期:** 构建成功,无报错 - [ ] **Step 2: CBOR deterministic 编码** 相同对象不同 key 顺序 → 相同 bytes **预期:** `encode({ z:1, a:2 })` === `encode({ a:2, z:1 })` - [ ] **Step 3: hash 计算** `hash(typeHash, payload)` → 13-char Crockford Base32 **预期:** 幂等;type 参与计算(不同 type + 相同 payload → 不同 hash) - [ ] **Step 4: memory store put/get round-trip** ```typescript const store = createMemoryStore(); const metaHash = await bootstrap(store); const h = await store.put(metaHash, { name: "test" }); const node = await store.get(h); ``` **预期:** `node.type === metaHash`,`node.payload.name === "test"`,`node.timestamp` 自动填充 - [ ] **Step 5: verify 完整性** **预期:** `verify(h, node) === true` - [ ] **Step 6: 幂等 put** **预期:** 重复 put 返回相同 hash,timestamp 保留首次值 ## 验证完成标准 ✅ 所有 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#3