Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
severity: CRITICAL,HIGH
limit-severities-for-sarif: true
exit-code: '1'
skip-dirs: 'services/analysis-engine/.venv'
trivyignores: .trivyignore
skip-dirs: services/analysis-engine/.venv,node_modules,apps/desktop/node_modules,packages/shared-types/node_modules
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2 peeled commit; SHA pinning retained as supply-chain attack mitigation.
if: always()
Expand Down
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@
## 2025-02-15 - Replace Array.from(map.values()).map with a for...of loop
**Learning:** Using `Array.from(map.values()).map(...)` creates an unnecessary intermediate array which wastes memory allocation and garbage collection time, particularly for frequently re-rendered components handling large collections.
**Action:** Use a `for...of` loop over `map.values()` to iterate and push mapped elements directly into the final array for O(1) memory and avoiding intermediate array allocations.
## 2024-07-08 - Fast SSM Novelty Extraction Using np.diagonal
**Learning:** Extracting checkerboard kernel responses from the diagonal of a Self-Similarity Matrix (SSM) using a Python loop takes linear time but with very high constant overhead due to inner loop numpy slicing and summation. By reformulating the dot product logic to extract `np.diagonal(sub_matrix)` for each kernel coordinate, we can achieve true C-level vectorization and compute the entire novelty array at once without any intermediate N^2 size arrays like 2D summed-area tables.
**Action:** Use sub-matrix diagonal vectorization instead of python array slicing loops when performing windowed operations strictly along the diagonal of large matrices.
2 changes: 2 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ yt_dlp/extractor/go.py
yt_dlp/extractor/nbc.py
yt_dlp/extractor/tbs.py
yt_dlp/extractor/vice.py
*node_modules*
services/analysis-engine/.venv/*
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def _checkerboard_novelty(
changes (i.e., moving from one repeated section to a new one).

Iterates over valid diagonal patches while keeping the SSM frame count bounded.
Uses vectorized operations via np.diagonal to avoid slow Python loop overhead.
"""
n = ssm.shape[0]
half = kernel_size // 2
Expand All @@ -109,11 +110,16 @@ def _checkerboard_novelty(
kernel[:half, :half] = -1.0
kernel[half:, half:] = -1.0

# Extract all valid diagonal patches and compute dot products.
valid_range = range(half, n - half)
for i in valid_range:
patch = ssm[i - half : i + half, i - half : i + half]
novelty[i] = np.sum(patch * kernel)
# Compute novelty values vectorizing across the SSM diagonal
for di in range(-half, half):
for dj in range(-half, half):
kval = kernel[di + half, dj + half]
if kval != 0.0:
sub_matrix = ssm[half + di : n - half + di, half + dj : n - half + dj]
if kval == 1.0:
novelty[half : n - half] += np.diagonal(sub_matrix)
else: # kernel only contains -1.0 and 1.0 based on its construction
novelty[half : n - half] -= np.diagonal(sub_matrix)

# Normalize by peak absolute magnitude, preserving sign.
max_val = np.max(np.abs(novelty))
Expand Down
Loading