Skip to content

feat(sidecar): serialise per-file metadata as JSON (D4-B part 1) - #16

Merged
wt159 merged 3 commits into
mainfrom
feat/sidecar-json
Nov 9, 2026
Merged

wt159 merged 3 commits into
mainfrom
feat/sidecar-json

Conversation

@wt159

@wt159 wt159 commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

D4-B 的前半段:只做序列化器,不接 file_mgr,无行为变化。

内容

  • src/sidecar.h/.c:sidecar_build_json() 纯函数,两种形态
    • complete=true:带 end_time_unix_ms + total_bytes
    • complete=false:进程被杀时留下的那一版
  • sidecar_is_valid_utf8():手写校验,覆盖过长编码、孤立续字节、截断、代理区
  • 转义:\" \\ \b \f \n \r \t,其余 <0x20 走 \u%04x
  • dump_pcm_file_meta_t 自包含(keys + 格式 + generation/split_index + 起始时间),供后续让 file_info_t 持副本,避免悬垂引用
  • 三个构建文件都加了 sidecar.c;MinGW job 改为编译 src/*.c,以后新增源文件不会漏

测试

  • sidecar utf8 validation:合法 ASCII/中文 + 四类非法序列
  • sidecar json builder:完整/partial 两种输出、关键字段、引号与反斜杠转义、缓冲区不足、UNKNOWN 格式、非法 UTF-8 key 均返回 -1

这一步没有任何调用点,.pcm 与现有行为完全不受影响。下一步接 file_mgr_close 钩子 + 开关。

wt159 added 3 commits November 9, 2026 18:07
First half of D4-B. Adds the sidecar module with a pure builder: UTF-8
validation (JSON string values require it), escaping for quotes, backslashes
and control characters, and two shapes - complete with end time and total
bytes, or partial for a file that was never closed.

The metadata struct is self-contained so an open file can hold a copy instead
of pointing at a session that may be destroyed first. Wired into all three
build files; the MinGW job now compiles src/*.c so new sources cannot be
forgotten.

Not wired to file_mgr yet: this commit adds no behaviour change.
Editing Makefile, Android.mk and CMakeLists.txt through Python's text mode on
Windows rewrote them with CRLF, which broke check-verification-flow: its
anchored grep patterns never match past a trailing CR.
@wt159
wt159 merged commit a675250 into main Nov 9, 2026
2 checks passed
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