Phase 1.4: Blob Store (CAS) — sha256 内容寻址存储 #39

Closed
opened 2026-04-22 15:16:45 +00:00 by xiaoju · 0 comments
Owner

背景

RFC-001 §8 定义了 CAS blob store:sense 存大对象时写 blob 拿 hash,db 里只存 hash 引用。

需求

1. @uncaged/nerve-core 新增 blob-store 模块

export type BlobStore = {
  put(data: Buffer): Promise<string>;     // returns sha256 hash
  get(hash: string): Promise<Buffer | null>;
  has(hash: string): Promise<boolean>;
  path(hash: string): string;
};

export function createBlobStore(dataDir: string): BlobStore;

存储结构:data/blobs/ab/cd1234...(sha256 前 2 位为子目录)。

2. 写入幂等

同一内容多次 put 返回同一 hash,文件只写一次。

3. 后续

BlobStore 注入 compute 函数参数(不在本 issue)。

验证

  • 单元测试:put/get/has、幂等写入、hash 正确性、分片目录
  • 边界:空 buffer、大文件、并发写入

参考

  • docs/rfc-001-observation-engine.md §8
## 背景 RFC-001 §8 定义了 CAS blob store:sense 存大对象时写 blob 拿 hash,db 里只存 hash 引用。 ## 需求 ### 1. `@uncaged/nerve-core` 新增 blob-store 模块 ```typescript export type BlobStore = { put(data: Buffer): Promise<string>; // returns sha256 hash get(hash: string): Promise<Buffer | null>; has(hash: string): Promise<boolean>; path(hash: string): string; }; export function createBlobStore(dataDir: string): BlobStore; ``` 存储结构:`data/blobs/ab/cd1234...`(sha256 前 2 位为子目录)。 ### 2. 写入幂等 同一内容多次 put 返回同一 hash,文件只写一次。 ### 3. 后续 将 `BlobStore` 注入 compute 函数参数(不在本 issue)。 ### 验证 - 单元测试:put/get/has、幂等写入、hash 正确性、分片目录 - 边界:空 buffer、大文件、并发写入 ### 参考 - `docs/rfc-001-observation-engine.md` §8
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/nerve#39