docs(07-10): WR-03 录像参数格式改为类型码只增不改的追加式约定

- 按 Q6=B 不加格式版本字段:array.ts 的类型码表注释写明只增不改约定(新语义必须分配新码,禁止复用),并记录 5/6/7/8 与短字符串基址的一次性重新分配
- types.ts 的 IReplaySystemSave.paramArray 与 IReplayArray.getParamArray jsDoc 同步该约定,并写明不承诺读回旧格式录像
- array.test.ts 新增类型码映射锚定用例(5/6/7/8/9/短字符串基址 9)
- system.ts 无改动(未引入版本字段)
This commit is contained in:
unanmed 2026-09-17 12:55:50 +08:00
parent 35d4ad6f1c
commit 5b26539b00
3 changed files with 39 additions and 0 deletions

View File

@ -764,6 +764,35 @@ describe('ReplayArray param codec', () => {
});
});
describe('ReplayArray param type table', () => {
// 参数类型码表只增不改:锚定 float=6、非负 bigint=7、负 bigint=8、短字符串基址 9、负 int64=5
it('keeps the param type code mapping stable', () => {
const floatArray = createArray();
floatArray.add(0, [1.5]);
expect(firstParamToken(floatArray)).toBe(6);
const bigintArray = createArray();
bigintArray.add(0, [100n]);
expect(firstParamToken(bigintArray)).toBe(7);
const negativeBigintArray = createArray();
negativeBigintArray.add(0, [-100n]);
expect(firstParamToken(negativeBigintArray)).toBe(8);
const int64Array = createArray();
int64Array.add(0, [-2147483649]);
expect(firstParamToken(int64Array)).toBe(5);
const shortStringArray = createArray();
shortStringArray.add(0, ['hi']);
expect(firstParamToken(shortStringArray)).toBe(11);
const longStringArray = createArray();
longStringArray.add(0, ['a'.repeat(300)]);
expect(firstParamToken(longStringArray)).toBe(9);
});
});
describe('ReplayArray stream and buffer combination', () => {
// 验证 createReadStream 从起始索引顺序读回多步,每参数为 number 且流索引逐次递进,末尾返回 null
it('reads a sequence of steps through a read stream', () => {

View File

@ -23,6 +23,10 @@ interface INormalizedParam {
* - 8: 负 bigint,载荷为幅值
* - 9: string,带 int32 长度前缀
* - 10 ~ 255: n - 9 长度的字符串
*
* 该类型码表属于录像参数编解码格式的一部分,遵循只增不改的约定:新语义必须分配
* 新的类型码,禁止复用既有类型码。历史上 5/6/7/8 与短字符串基址(长度 + 9)曾
* 发生一次性重新分配,项目未发布,旧录像不在兼容范围内。
*/
readonly paramType: number;

View File

@ -261,6 +261,8 @@ export interface IReplayArray {
* - 8: 负 bigint
* - 9: string
* - 10 ~ 255: n - 9 长度的字符串
*
* 参数类型码表遵循只增不改的约定:新语义必须分配新的类型码,禁止复用既有类型码。
*/
getParamArray(): ArrayBuffer;
@ -352,6 +354,10 @@ export interface IReplaySystemSave {
* - 8: 负 bigint --- n + 2 Byte, 其中 n 是 bigint 的字节数
* - 9: string --- n + 5 Byte, 其中 n 是字符串编码后的字节数
* - 10 ~ 255: n - 9 长度的字符串 --- n + 1 Byte, 其中 n 是字符串编码后的字节数
*
* 参数类型码表遵循只增不改的约定:新语义必须分配新的类型码,禁止复用既有类型码。
* 历史上 5/6/7/8 与短字符串基址曾发生一次性重新分配,且项目未发布,
* 因此本存档不承诺能被新版本读回由旧格式写出的录像。
*/
readonly paramArray: ArrayBuffer;
}