Skip to content

perf(depscan): skip a scheduled rescan when OSV answers the same - #2685

Merged
Makisuo merged 2 commits into
mainfrom
perf/dep-scan-skip-unchanged
Nov 16, 2026
Merged

Makisuo merged 2 commits into
mainfrom
perf/dep-scan-skip-unchanged

fix(depscan): never skip a scheduled scan after a newer failed one

4267722
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 16, 2026 in 2m 25s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge. Skip, fallbacks and the failed-scan regression are each pinned by call-counting tests; the residual assumption is OSV bumping modified when a record is edited.
no findings · tests covered · risk medium · 3/3 new units observable

A scheduled dependency rescan now returns Unchanged without a scan row when the commit and OSV's answer are unchanged, with the lockfile plan cached per commit and a new advisory_fingerprint column. Every skip and fallback path is pinned by new tests; safe to merge.

  • DependencyScanner.scan prechecks a scheduled head scan and skips when the OSV fingerprint matches
  • PackageAdvisoryCatalog splits into query (querybatch) and resolve (record reads), with fingerprintOf
  • dependency_scans.advisory_fingerprint stores the OSV answer only on scans that reconciled
  • Commit lockfile selection is cached as a plan keyed by provider, repo and commit sha

Before merge

Production impact

Production traffic of the changed files (last 7 days)
File Calls/day Busiest operations
packages/backend/src/services/security/PackageAdvisoryCatalog.ts 12k PackageAdvisoryCatalog.advisories 12k/day, 0.0% err
Telemetry this change adds and removes (2)
  • ➕ span name PackageAdvisoryCatalog.query · packages/backend/src/services/security/PackageAdvisoryCatalog.ts:211
  • ➕ span name PackageAdvisoryCatalog.resolve · packages/backend/src/services/security/PackageAdvisoryCatalog.ts:223
What was checked
  • Skip needs the newest any-status head scan to be completed, errorless, same commit, with a fingerprint (DependencyScanner.ts:490)
  • getOrCompute propagates the compute error, so a truncated tree is never cached as a plan (lib/cache/src/edge-cache.ts:460)
  • selectLockfiles/manifestsFor are pure and sorted, so a cached plan equals a fresh one (lockfile-selection.ts:53)
Observability coverage: 3 of 3 changes observable
Change Kind Observable Evidence
Scheduled scan precheck and skip (DependencyScanner.scan) background job step yes Runs inside the existing DependencyScanner.scan span; outcome annotated as maple.depscan.outcome=unchanged with maple.depscan.skip_reason (DependencyScanner.ts:523)
OSV querybatch advisory query outbound call yes New PackageAdvisoryCatalog.query span wrapping the existing osv.querybatch client span with peer.service=osv.dev (PackageAdvisoryCatalog.ts:219, :144)
Commit scan-plan cache read/write cache yes EdgeCacheService.getOrCompute span records bucket, hit/miss, read_ms (loadPlan, DependencyScanner.ts:331)

4267722 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.