Skip to content

refactor(knowledge): simplify video-digest acquisition code without behavior change - #14870

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14603-42704477398-1
Nov 10, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14603

Summary

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

Simplified 8 of the 9 listed video-digest acquisition files with no behavior change: duplicated stat/age logic, env lookups, result-row literals and a one-call wrapper were folded into small local helpers, and redundant variables and branches were removed. acquire-retry-policy.js was reviewed and left unchanged, because its one candidate edit (an expression-bodied Promise executor in sleepMs) risks a Biome noPromiseExecutorReturn finding for no real gain. Nothing moved between files and nothing was deduplicated across files (the issue leaves both to the restructuring pass), and every exported name, return shape (including JSON key order), thrown error and env read is unchanged.

Not verified

  • Vitest suites for the acquisition folder (acquire-throttle.test.js, acquire-yt-dlp-auth.test.js, select-caption.test.js and siblings) were not run: this lane runs only the named wrappers, so the suites are left to the PR's CI.
  • Biome lint and tsc checkJs over the touched files were not run here (no runner for them in this lane); left to the PR's CI. The review subagent reasoned that no new finding is expected.
  • Tidy (code-tidying:tidy-diff) ran passes 1-4 with no edits and found nothing to propose. Pass 5 (ai-slop:audit fix on the changelog fragment) could not run its detector script, because the lane permits only the named wrappers; the rubric was read inline with no findings, and the fragment text is…
  • ci-status green is a PR CI check, left to the PR's CI.
  • Untracked dotfiles at the checkout root (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) were not created by this run; they look like sandbox mount placeholders and are not part of this change.

Fix

  • plugins/knowledge/skills/video-digest/extraction/acquisition/acquire-throttle.js: new private slotAgeMs helper shared by isStaleSlot and reclaimStaleSlot's re-stat (null when missing keeps each caller's original missing-path answer); heartbeat uses timer.unref?.() and a one-line stop.
  • plugins/knowledge/skills/video-digest/extraction/acquisition/acquire-with-retry.js: dropped the canRetry and waitMs temporaries; same retry condition and order.
  • plugins/knowledge/skills/video-digest/extraction/acquisition/acquire-yt-dlp-auth.js: private envCookiesFromBrowser helper replaces the two identical resolveEnvWithLegacy(...)?.trim() calls; same call count and short-circuit order, so legacy-env warnings are unchanged.
  • plugins/knowledge/skills/video-digest/extraction/acquisition/acquire.js: inlined the single-caller runYtDlpAcquire wrapper into runAcquirePass; video-file detection uses one anchored regex equivalent to the three endsWith checks.
  • plugins/knowledge/skills/video-digest/extraction/acquisition/build-yt-dlp-args.js: moved allowTranslatedSubs below the constant block it interrupted; js-runtimes push uses a positive condition instead of an early return.
  • plugins/knowledge/skills/video-digest/extraction/acquisition/preflight-metadata.js: private preflightResult builder fills the empty text fields in the original key order, replacing four hand-written 12-field literals; printed JSON is byte-identical.
  • plugins/knowledge/skills/video-digest/extraction/acquisition/select-caption.js: merged the byte-identical MANUAL_EN_PATTERN and PLATFORM_EN_PATTERN into EN_PATTERN; the two ladder-hit returns collapse into one with a conditional provenanceNote (autoBareEn is only stored under auto-en, so rung and…
  • plugins/knowledge/skills/video-digest/extraction/acquisition/spawn-yt-dlp-with-auth-fallback.js: removed the reassigned detail variable and merged the success/non-retryable early returns in the browser-profile loop.
  • .changes/knowledge/work-resolve-issue-issue-14603-42704477398-1-c8762b59.md: patch fragment from new-changelog-fragment, body '### Changed' / 'Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 19 fragments valid (run after the final edit).
  • check-changed-skills: video-digest PASS, 0 errors, 5 warnings that were already there (SKILL.md size/procedure warnings; not touched by this change).
  • check-affected: 12 passed, 7 skipped, over 9 changed files.
  • Fresh-context review subagent over the full diff: no behavioral difference in any file; 3 low-severity notes. Two were acted on: spawnFailureDetail is computed unconditionally again in acquire-with-retry.js, and the sleepMs executor change was reverted. The third (timer.unref?.() differing only for…
  • Diff size from git-read diff --numstat HEAD: 293 changed code lines in 8 files plus a 7-line fragment, within the issue's 400-line / 15-file cap.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42704477398

Left out: the items under Not verified.

Related

#14603

Merge-Risk: max=HIGH demote=true head=a07d0932ca89ba0a5d104983d81c063e4f40bd3a rubric=8.2.0 rater=claude-opus-5-5 checker=claude-opus-5-5

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #14870 (head a07d093)

I found no security issues.

I read every hunk of all 9 changed files in .claude-lane/pr.diff. None of them matches a trusted-path glob, and the diff changes no trust control, workflow, plugin manifest or standing instruction.

The PR says it is a no-behavior-change refactor of the video-digest acquisition helpers. I checked the parts that touch security against the base:

  • acquire.js: inlining runYtDlpAcquire keeps env = process.env. The old caller never passed env, so the default always applied. yt-dlp is still started with the same argv-array call through spawnYtDlpWithAuthFallback, with no shell string. The anchored /\.(?:mp4|mkv|webm)$/ matches the same names as the three endsWith checks, because a JS $ without the m flag matches only at the end of the input.
  • acquire-yt-dlp-auth.js / build-yt-dlp-args.js: the cookie-source lookups (--cookies / --cookies-from-browser env, with the legacy fallback) resolve the same way, in the same short-circuit order. The --js-runtimes guard was inverted but keeps the same off/0 opt-out. No new input reaches yt-dlp's arguments.
  • spawn-yt-dlp-with-auth-fallback.js / acquire-with-retry.js: the retry and browser-profile fallback loops stop under the same conditions. No retry was added and no credential is exposed.
  • preflight-metadata.js: the preflightResult builder still receives note/reason/displayTitle/displayChannel already escaped through escapeTableCell, the same as before. Its defaults are empty strings, so the escaping of untrusted text that ends up in the markdown queue table is unchanged.
  • acquire-throttle.js / select-caption.js: these only change slot-age checks, timer cleanup and caption-rung picking. Missing slots are handled the same way. None of it is security-relevant.
  • .changes/ fragment: a changelog note only.

The PR context file has no embedded instructions aimed at this lane. There were no earlier findings and no settled threads, and this was a full review, not blocking-only.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk in all 9 changed files and checked each rewrite against the base code to see if behavior changed. I found none.

  • acquire-throttle.js: slotAgeMs returns null only when fs.stat throws. isStaleSlot maps null to stale (true), as the old catch did. reclaimStaleSlot maps null to false, as the old inner catch did. The <= / > boundary is unchanged. The stop() method became an arrow function, which is safe because nothing reads this.
  • acquire-with-retry.js / spawn-yt-dlp-with-auth-fallback.js: the merged conditions follow De Morgan's laws, short-circuit in the same order, and call the same functions the same number of times.
  • acquire-yt-dlp-auth.js: envCookiesFromBrowser replaces the two identical resolveEnvWithLegacy(...)?.trim() calls. Each call site still makes one call in the same order, so legacy-env warnings are unchanged.
  • acquire.js: the old runYtDlpAcquire was called without env, so its default was process.env. The inlined const env = process.env keeps that. The anchored regex /\.(?:mp4|mkv|webm)$/ (no m flag) matches exactly what the three endsWith checks matched.
  • build-yt-dlp-args.js: allowTranslatedSubs is a hoisted function declaration that reads YT_DLP_SKIP_TRANSLATED_SUBS only when called, so moving it is safe. The --js-runtimes condition is the same logic inverted.
  • preflight-metadata.js: preflightResult builds the keys in the original order, so the printed JSON is unchanged. Its "" defaults never hide an undefined the old code would have dropped from the JSON, because parsePreflightLine always returns strings (preflight-metadata.js:131-140) and every passed note or reason comes from escapeTableCell or a literal.
  • select-caption.js: autoBareEn is only put into byRung under auto-en (select-caption.js:190-199), so the merged return gives the same rung and isAutoCaption. When it is not an autoBareEn hit, the spread of false adds no provenanceNote key. The merged EN_PATTERN is the same regex as the two patterns it replaced.

Closing issue #14603, acceptance criteria:

  • Behavior unchanged; no file renamed, moved or deleted: met, per the checks above. Test files exist for the changed modules (for example acquire-throttle.test.js, preflight-metadata.test.js, select-caption.test.js, spawn-yt-dlp-with-auth-fallback.test.js, acquire.test.js). I did not run them.
  • Diff edits only the listed files and fragments: met. 8 of the 9 listed files are edited, plus one fragment; acquire-retry-policy.js is unchanged.
  • Within 400 changed lines / 15 files: met (9 files; the diff is about 290 code lines).
  • ci-status green: not checked by me. This lane has no CI access, so it is left to the PR's CI.
  • Fragment with ### Changed and "Internal simplification, no behavior change.": met, bump: patch. The full-width ### in the PR body is only how the body displays; the fragment file itself uses ASCII ###.

The author's verification (check-changelog-fragments, check-changed-skills, check-affected) is the author's claim; I did not verify it. No plugin manifest changed, and no trusted-path file is touched.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for a07d093

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-14870-a07d0932ca89ba0a5d104983d81c063e4f40bd3a, expires on 2026-12-09.

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 10, 2026
Merged via the queue into main with commit fb62592 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14603-42704477398-1 branch November 10, 2026 01:02
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 (1 of 8)

0 participants