Skip to content

kvspace: XValue head 16 字节 + layout;删除 storetype/ptr - #51

Merged
miaobyte merged 6 commits into
mainfrom
feat/622
Nov 7, 2026
Merged

miaobyte merged 6 commits into
mainfrom
feat/622

Conversation

@miaobyte

@miaobyte miaobyte commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

XValue head 从「8 字节 + storetype/ptr」换成 16 字节 + layout/padding,*/@ 移入 langtype。
本 PR 为该生态在 feat/622 上积累的整体改动。

Co-Authored-By: Claude Code noreply@anthropic.com

miaobyte and others added 6 commits November 3, 2026 13:04
- head 由 8 字节扩到 16:长度进 head,attr 去掉前缀
- 新增 wire 金标准:tests/xvalue_wire_golden.c 产出可比对文本(不做断言),
  tests/compare_wire_golden.sh 逐字节比对前端 / kvspace-c / kvspace-durable
  三处实现——同一批操作、同一顺序,输出必须完全一致;只比字节不解释字节,
  因为要验的正是三方对同一份 head 定义的理解一致
- 前端 CLI、codec 与 head 测试同步

门禁(本批提交树独立导出):CMake Release 构建 0 error;ctest 2/2 通过
(xvalue_head、codec_abi);xvalue_wire_golden 二进制产出正常(rc=0)。

Co-Authored-By: Claude Code <noreply@anthropic.com>
上一提交把 head 扩到 16 字节、把长度搬进 head、删掉 attr 的 attr_len
前缀,但注释与测试文案还停在旧世界:

- include/kvspace/kvspace.h 的 wire 说明写「head 恒 8 字节、body 偏移恒 8、
  attr 以 attr_len:u16 开头」,错误有两处:偏移是 16,attr 区没有前缀
  (attr 区大小就是 head 里的 attrslen,再加一层前缀就是第二个真相)。
- tests/test_xvalue_head.c 里三处断言文案说「没有 2 字节 attr_len」
  「attr_len < 2」,实际守的是「attrslen 放不下一个 record 头」。文案
  指错字段,红的时候会把人带到错的方向;顺带把仍用旧 10 字节 wire 的
  坏样本改成 16 字节 head 形状。

只改注释与文案,断言值、构造参数、用例集合都不动;行为零变化。

Co-Authored-By: Claude Code <noreply@anthropic.com>
storetype 4 的 bodylen 是**容量**,有效长度在 attr tag 2 的 reallen。
tag 2 的归属是排他的:storetype 4 必须带、其它 storetype 必须不带
(「有定义但在此形态下无意义」= 读写双方理解不一致,必须拒绝)。

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
- `xvalue_head.h`:删去 head 里的 storetype/ptr,只留 `[bodylen:u64][attrslen:u32][layout:u8][padding:3]`;
  存储形态与引用性改由 langtype 推导。
- `src/xvalue_head.c`:构造与解析跟随新字段;`layout` 区分「bodylen 是长度」与「bodylen 是容量」。
- `tutorial-c/`:C/C++/Python/Rust 四个示例与公共头跟随新 head(16 字节、body 偏移恒 16)。
- `tutorial-durable/`:删 `14-head-perm.sh`(旧 head 的权限演示已无对应语义);
  `test.py` 按新 CLI 与 16 字节 head 重写。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@miaobyte
miaobyte merged commit 80e6d4e into main Nov 7, 2026
3 of 4 checks passed
@miaobyte
miaobyte deleted the feat/622 branch November 7, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant