Repository navigation
feat(sidecar): write per-file metadata on open and finalise on close (D4-B) - #19
Merged
Merged
Conversation
D4-B of the sidecar spec (#17, #18). - sidecar_write_file stages <name>.json.tmp and renames it into place, so a reader never sees a partial file; the switch is a process-wide atomic and defaults to off. - file_info_t carries a self-contained metadata copy: the writer is not told when the file manager evicts a handle, so the closing hook cannot rely on the session still being alive. - The initial version is written when a file is created; every close path (explicit stop, rollover, size split, LRU eviction, teardown) finalises it with total_bytes and end time. - A reopen after eviction keeps the completed sidecar and only refreshes it on close; the original start time survives on the session. - A failed fclose skips finalisation instead of marking a possibly truncated file as complete. Old call sites pass no format, so they never produce a sidecar and the .pcm output is unchanged.
whitebox.c includes file_mgr.c and dump_pcm_data.c, so every new external symbol needs a rename or it collides with the compiled translation units at link time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
按
implement-spec流程跑完 D4-B:工单 #17(原子落盘 + 开关)与 #18(生命周期钩子)在同一集成分支上实现、评审、合并。行为
file_info_t持有一份自包含的元数据副本——写线程不会被通知"句柄被 LRU 回收了",所以关闭钩子不能依赖 session 还活着。complete=false);所有关闭路径都 finalize:显式 stop、2 秒 rollover、1GB 分片、LRU 回收、模块销毁。评审发现并修掉的问题
attach又写了一次首版,把complete=true+total_bytes覆盖成complete=false。改为只在is_new时写首版。start_time_unix_ms变成重开时刻。改为在 session 上保留file_start_unix_ms,只有 rollover/分片才清零。fclose失败仍标记 complete:可能被截断的文件被标成完整。改为关闭失败则跳过 finalize。sidecar_write_meta内部读开关,导致"打开时开、中途关掉"的文件无法收尾。策略上移到调用点。测试
sidecar lifecycle on real file:开开关 +write_ex→.json存在、complete=true、total_bytes等于.pcm实际大小、sample_rate正确legacy write leaves no sidecar:开关开着,旧接口也不产生.jsondisabled metadata leaves no sidecar:关开关 +write_ex→ 无.jsonsidecar switch state:开关读写未覆盖(已知)
finalize_slot_meta()覆盖,静态审查过。Android HAL
旧接口不传格式 → 不 attach → 不产生任何
.json,字节输出不变。开关默认 0,Android 侧零调用零开销。Closes #17
Closes #18