Static scan for Oban worker modules that have no compile-time call sites and are not listed in Oban (or Oban Pro) cron config.
This answers a different question from :dead_workers: not "has this worker
been enqueued in the last N days?" but "does anything in the compiled code
appear to enqueue it?" It does not need job history or a longer Pruner
max_age. Absence of a static caller is not proof the worker is unused:
jobs may still be scheduled, enqueued dynamically, or referenced from a beam
this scan could not read.
The scan needs the host project compiled (mix compile). It walks
Application.spec/2 modules (with Code.ensure_loaded/1, not
:code.all_loaded/0) and looks up callers from each compiled beam's debug
info, the same class of data mix xref callers uses. config.exs crontab
entries are not part of that graph, so crontab is parsed separately from
loaded Application env.
Workers with no static callers are classified as :review_candidate, not as
proven dead code. scan_report/1 also returns coverage: beams scanned, beams
missing debug info, empty compile paths, and whether results are complete.
Review candidates that may still be used: a worker enqueued only through
dynamic dispatch (Module.concat, apply/3 on a string or variable,
Oban.insert with a worker name built at runtime, or a name stored in the
database); a worker whose only callers live in a beam without debug info;
runtime-only cron. Those have no static call site this scan can see.
Limitations that can hide a real caller (false "no call sites"): missing
BEAM debug info, compile paths the scan did not walk, and dynamic dispatch.
A module atom still present in compiled debug info is treated as a caller,
even if that reference is apply(MyApp.Worker, :new, ...).
Runtime-only cron (Oban Pro DynamicCron / Oban.Pro.Cron rules added in the
database and not present in config) is not scanned; those workers can be
listed in :ignore. Oban Pro cron parsing beyond Application env is
unverified (no Pro license in this project's tests).
Used by mix queue_keeper.dead_code.
Summary
Functions
Same as review_candidates/1. Kept so existing call sites keep working;
the status atom returned by scan/1 is :review_candidate, not :dead.
Worker names with no static callers and not in cron.
Run the scan.
Like scan/1, plus a coverage map so callers can tell incomplete discovery
from a confident empty caller list.
Functions
Same as review_candidates/1. Kept so existing call sites keep working;
the status atom returned by scan/1 is :review_candidate, not :dead.
Worker names with no static callers and not in cron.
These are review candidates, not proven dead code. Prefer this name over
dead_workers/1.
Run the scan.
Options:
:apps— application names to search for workers (default: loaded non-OTP apps, excluding:oban,:ecto,:ecto_sqland adapter apps):ignore— worker name strings to skip:known— extra worker name strings to include even if discover misses them:cron— extra worker name strings to treat as cron (in addition to config):callers— optional%{worker_name => [file]}to inject in tests:beam_roots— directories of.beamfiles to walk for callers (default: the Mix compile path, plus each umbrella app's compile path). Intended for tests and for running the scan without Mix.Project:beam_paths— extra.beamfiles to include in the caller walk
Like scan/1, plus a coverage map so callers can tell incomplete discovery
from a confident empty caller list.
Coverage keys: :beams_scanned, :beams_ok, :beams_missing_debug_info,
:beams_unreadable, :compile_paths_empty, :apps, :complete?.
complete? is true only when at least one beam was scanned and none were
missing debug info or unreadable.