Skip to content

refactor(knowledge): simplify video-digest watch and watching code (8 of 8) - #15338

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14613-43000507664-1
Nov 11, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14613-43000507664-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14613

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified 8 of the 14 listed video-digest files without changing behavior. vision-gated-promote.js now reads its JSON through the existing readJsonFile/readLaneJson helpers. watch-state.js builds its phase map and PHASE_ORDER from the single MARKABLE_PHASES list. The watching files drop duplicated midpoint math, a duplicated anchor-tagging map, a loop-with-break and per-iteration ffmpeg argument rebuilding. The other 6 files (snapshot-bootstrap.js, validate-promotion-decisions.js, validate-triage-json.js, frame-budget.js, merge-frame-candidates.js, models.js) were reviewed and left as they are, because they are already minimal or only hold types and further edits would not make them clearer. Out of scope per the issue: moving code between files, for example the near-duplicate formatTimestampSlug (synthesis-naming.js) and formatElapsedMinutes (extract-anchor-frames.js).

Not verified

  • vitest suite for plugins/knowledge/skills/video-digest/extraction (npm test) was not run: this lane allows no test runner; left to the PR's CI
  • tsc --noEmit type check (npm run build) for the extraction package was not run: the lane allows no build tool; left to the PR's CI. The review subagent read the hunks against tsconfig (checkJs, strictNullChecks) and found no likely error
  • ci-status green is a PR CI check, left to the PR's CI
  • tidy pass 5 (ai-slop:audit fix) ran only its rubric read on the changelog fragment: detect.sh and digest-guard.sh are not among the scripts this lane may run. The rubric found nothing
  • Formatter/linter for the touched JS was not run (no formatter config at the repo root, and the lane runs no linter beyond check-affected); the new lines are kept at or under 100 columns, matching the surrounding style
  • Untracked environment files in the checkout root (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) came from the runner, not this change, and should not be part of the patch

Fix

  • plugins/knowledge/skills/video-digest/extraction/watch/vision-gated-promote.js: reads promotion-decisions.json, watch.json and selection.json through readLaneJson/readJsonFile from lib/watch-frame-index.js instead of inline JSON.parse(fs.readFileSync(...)); computes String(src) once in the copyFile…
  • plugins/knowledge/skills/video-digest/extraction/watch/watch-state.js: MARKABLE_PHASES moved up and made the single phase list; createWatchState builds phases with Object.fromEntries over it (same keys, same order) and PHASE_ORDER is MARKABLE_PHASES without companion
  • plugins/knowledge/skills/video-digest/extraction/watch/synthesis-naming.js: synthesisDestName picks a prefix once instead of two return branches
  • plugins/knowledge/skills/video-digest/extraction/watching/compute-coverage-plan.js: new private midpointSec helper shared by densificationAnchorTimestamps and cueAnchorTimestamps; cueAnchorTimestamps is filter/map instead of a push loop
  • plugins/knowledge/skills/video-digest/extraction/watching/densification.js: findDensificationWindows uses signals.find instead of an inner loop with break
  • plugins/knowledge/skills/video-digest/extraction/watching/extract-anchor-frames.js: the ffmpeg input prefix args and normalized input path are computed once before the loop; each iteration still builds a fresh, identical args array
  • plugins/knowledge/skills/video-digest/extraction/watching/orchestrate-watching.js: private asAnchorCandidates helper replaces two identical timestampSource: "anchor" maps
  • plugins/knowledge/skills/video-digest/extraction/watching/cue-normalize.js: normalizeVttCues maps with destructuring (same keys, same order)
  • .changes/knowledge/work-resolve-issue-issue-14613-43000507664-1-44c67712.md: patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against e2be315:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 3 fragments valid (run before and after tidy)
  • check-changed-skills: video-digest PASS, 0 errors, 5 pre-existing warnings about SKILL.md, which this change does not touch (run before and after tidy)
  • check-affected: 12 passed, 7 skipped over 9 changed files (run before and after tidy)
  • fresh-context review subagent over the whole diff: no behavior change and no likely tsc error in any hunk; it flagged one out-of-contract case, a null videoPath in extractAnchorFrames, which run-watch.js:414 rules out by returning early unless primary.mediaPath is truthy before calling…
  • read lib/watch-frame-index.js: readJsonFile is JSON.parse(fs.readFileSync(p, 'utf8')) and readLaneJson is readJsonFile(lanePath(...)), the same calls the replaced code made
  • read vendor/video-digestion/shared/process.js: normalizeSpawnPath is a pure replaceAll, so hoisting it out of the loop is safe
  • diff size: 8 code files plus 1 fragment, 74 added and 95 removed lines in code, within the issue's 400-line / 15-file limit
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43000507664

Left out: the items under Not verified.

Related

#14613

Merge-Risk: max=LOW demote=false head=e2be31510f5b4a4077d15bf4fe84af328ed54496 rubric=8.4.2 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed e2be31510f5b4a4077d15bf4fe84af328ed54496: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15338 (head e2be315)

I found no security issues. I read every hunk of all 9 changed files.

This is a behavior-preserving refactor of the video-digest watch/ and watching/ code, plus a changelog fragment. None of the changed files matches a trusted path. The diff touches no plugin manifest, workflow, trust control, merge hold, token request or standing instruction, so no manifest, trust-control or instruction-surface line applies.

What I checked:

  • vision-gated-promote.js. The new readLaneJson / readJsonFile calls do exactly what the inline code did. I confirmed this in lib/watch-frame-index.js:19-33 (JSON.parse(fs.readFileSync(p, "utf8")) over lanePath, which is path.join in lib/slice-lanes.js:35-37). They read the same files, through the same path construction, with no new input. In the copyFile callback, the source path is now converted to a string once and the result reused. The containment check is unchanged: if the identity lookup finds nothing, it still throws before copyCheckedFrame runs.
  • extract-anchor-frames.js. The ffmpeg arguments are still built as an argv array and passed to spawn("ffmpeg", args, {}), with no shell string. Moving normalizeSpawnPath(inputPath) and the remote-input -user_agent prefix out of the loop leaves the arguments identical. No new data reaches the command line.
  • watch-state.js, synthesis-naming.js, compute-coverage-plan.js, densification.js, cue-normalize.js, orchestrate-watching.js. These are pure restructurings: the same phase keys in the same order, the same file-name output, and the same midpoint, filter and first-match logic. None of them touches a trust boundary.
  • PR context. It contains no embedded directives aimed at the review lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed e2be31510f5b4a4077d15bf4fe84af328ed54496: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read every hunk of all 9 changed files. Each change keeps the old behavior.

  • vision-gated-promote.js: readJsonFile and readLaneJson in lib/watch-frame-index.js (L19-L33) make the same JSON.parse(fs.readFileSync(path, "utf8")) calls the removed code made. watch-frame-index.js imports only node:fs and slice-lanes.js, so the new import adds no cycle. fs is still used elsewhere in the file, so its import is not left unused. Calling String(src) once gives the same result.
  • watch-state.js: MARKABLE_PHASES now comes before its first use. createWatchState builds the phases with Object.fromEntries, giving the same keys in the same order. PHASE_ORDER is that list minus companion, which matches the old literal.
  • compute-coverage-plan.js, densification.js: the midpointSec helper, filter/map and signals.find call pattern.test in the same order and stop at the same first match. That holds even for stateful /g patterns, so the output is identical.
  • extract-anchor-frames.js: moving normalizeSpawnPath (a pure replaceAll, process.js#L19) and the argument prefix out of the loop gives the same ffmpeg argument list on every pass. One edge case changes: with a null videoPath and no timestamps, the function used to return [] and now throws. That input is outside the function's contract (@param {string} videoPath), and the PR body says run-watch.js rules it out, so I don't count it as a finding.
  • orchestrate-watching.js, cue-normalize.js, synthesis-naming.js: these are equivalent rewrites, and the types still check against the existing FrameCandidate import path.

Closing issue #14613, acceptance criteria:

  • Behavior unchanged, and exported names unchanged: met.
  • Only listed files plus a fragment are edited: met.
  • Size limit (400 lines, 15 files): met, at 8 code files and roughly 170 changed lines.
  • knowledge patch fragment containing ### Changed and "Internal simplification, no behavior change.": met.
  • "ci-status is green": left to CI. I did not check it.

The PR's test, tsc and check results are the author's claims and I did not run them. The existing extract-anchor-frames.test.js and watch-state tests cover the changed paths.

No embedded instructions were found in the PR context. There are no plugin manifest changes, and no spend or cost impact.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head e2be31510f5b4a4077d15bf4fe84af328ed54496, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for e2be315

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15338-e2be31510f5b4a4077d15bf4fe84af328ed54496, expires on 2026-12-11.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 5f4a3fe Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14613-43000507664-1 branch November 11, 2026 11:59
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 5f4a3fe3759925e7e36cb64ccd6d1df314d0d188; later checks count it verified from this comment.

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.

Simplify the video-digest knowledge plugin code (8 of 8)

0 participants