Repository navigation
Description
Summary
#255 moved the index sidecar to <file>.index.json, but events, markers, perf, logs and .srt paths still strip the extension, each with its own copy of the regex (11 copies, and they differ). Recordings that share a stem share those sidecars, and pipeline outputs that share the input's stem overwrite them.
Where
src/utils/events.ts:645-648src/utils/chapters.ts:61-63src/utils/perf.ts:136-138src/utils/logTail.ts:105src/utils/recordingIndex.ts:110-121src/utils/sidecarRetime.ts:73-108src/utils/pipelineRun.ts:460-467src/utils/recordingFiles.ts:20-37src/tools/narrate.ts:6890src/tools/cutByTranscript.ts:71src/utils/pipelineRun.ts:124
Details
#255 rekeyed the index sidecar to the full file name because same-stem recordings shared one file: indexSidecarPath(video) => \${video}.index.json`(recordingIndex.ts:113-115), and the old name is kept aslegacyIndexSidecarPath. Every other sidecar still strips the extension with its own copy of the same regex: eventPaths recording.replace(/.[^./\]+$/, "")+.events.jsonl(events.ts:646),markersPath(chapters.ts:62),perfPath(perf.ts:137),logsPath(logTail.ts:105). Three more copies build.srtpaths (narrate.ts:68, cutByTranscript.ts:71 with a different character class, pipelineRun.ts:124). That makes 11 inline extension strips and no shared helper. Two paths depend on this naming. First,writeRetimedSidecars(req.input, req.output, plan)(sidecarRetime.ts:86-102) writeseventPaths(output).jsonl, logsPath(output)andperfPath(output), and writeMarkers(req.output, ...)(pipelineRun.ts:461) writes the markers. When the output shares the input's folder and stem, these are the input's own files, and they are overwritten unconditionally.resolveOutput(paths.ts:223-244) checks only the video path. Second,recordingSidecars (recordingFiles.ts:20-37) runs a sibling-ownership check (siblings) only for the transcript. It deletes demo.events.jsonl, demo.markers.json, demo.perf.jsonlanddemo.logs.jsonlfor anydemo.`.
Impact
An edit or export placed next to its source corrupts the source's event log, markers, perf and app-log sidecars: they are replaced by trimmed and retimed copies. Deleting such an export with delete_recording also removes the source recording's sidecars, which breaks read_events, zoom (events mode), step_guide, bug_report and chapters for the original. Each new sidecar type adds one more copy of the regex and one more name the pipeline and delete paths must handle in sync. #255 fixed this for the index only.
Steps to reproduce
(1) Record C:\work\demo.mp4 with events: true and add a marker. (2) Run pipeline { input: "C:\\work\\demo.mp4", steps: [{op:"trim", start:5, end:10}], output: "C:\\work\\demo.mkv" }. demo.events.jsonl and demo.markers.json now hold the 5-second retimed copy, and the original timing is lost. (3) Or run export_gif { input: demo.mp4, output: "C:\\work\\demo.gif" }, then delete_recording { path: "C:\\work\\demo.gif" }. The confirmation counts demo.mp4's sidecars, and on yes they are deleted.
Suggested fix
Incremental plan. Step 1: add sidecarPath(video, kind) in a new src/utils/sidecars.ts that returns today's names, and point eventPaths, markersPath, perfPath, logsPath and the three .srt builders at it. No behavior change. Step 2: in recordingSidecars, run the existing siblings check for every stem-keyed sidecar: skip it when another media file with the same stem exists, as defaultTranscriptPath already does for transcripts. Step 3: in writeSidecars/writeRetimedSidecars, skip a sidecar (with a warning) when its path equals the input's sidecar path. Step 4: optional, the #255 approach: switch sidecarPath to full-name keys (demo.mp4.events.jsonl) and add a legacy read fallback in the readers (resolveRecording, resolveSource, readEvents, readMarkers). Tests first: unit tests for recordingSidecars(".../demo.gif", ["demo.mp4","demo.gif","demo.events.jsonl"], ...), which must not list demo.events.jsonl, and for writeRetimedSidecars("a/demo.mp4", "a/demo.mkv", plan), which must leave the input's events, perf and logs byte-identical. Also add a snapshot of every current sidecar name, so step 1 can be shown to change nothing.
Acceptance criteria
- One helper builds every sidecar path
- Same-stem files (
demo.mp4anddemo.mkv) no longer share events, markers, perf or logs sidecars, with a read fallback for the legacy names - Tests for the collision case
Getting started
- Relevant files:
src/utils/events.ts,src/utils/chapters.ts,src/utils/perf.ts,src/utils/logTail.ts - Run tests:
npm test(alsonpm run typecheckandnpm run lint); see CONTRIBUTING.md - If you change a tool's schema or description, run
npm run docs
Filed by repo-audit/full-audit at f0e5ebd. Severity: medium. Effort: M. audit-key: tech-debt|src/utils/recordingFiles.ts|recordingSidecars
Activity