QueueKeeperCheck.DeadWorkerCandidates (queue_keeper_check v0.4.1)

Copy Markdown View Source

Combined, report-only classification of dead-worker review candidates.

This is a different check from :dead_workers (enqueue inactivity) and from QueueKeeperCheck.DeadCode (static reachability). A high-confidence candidate is a worker that has both:

  1. no observed enqueue for at least window_days (default 7), with observation history long enough to support that claim, and
  2. no references in compiled application code or crontab from Application env.

It never deletes code, jobs or queues, and it never claims a worker is definitely dead. Findings always include the evidence and a confidence (Finding.reason).

Window and boundary

window_days is any positive integer (the same rule as :dead_workers). When you enable the check without setting window_days (for example you only set known or discover: true), the window is 7 days.

Inactivity is age >= window_days * 86_400 whole seconds. Age is DateTime.diff(now, last_inserted_at, :second) against the now passed to QueueKeeperCheck.run/2 (default DateTime.utc_now/0). A last insert exactly seven days before now therefore counts as "at least seven days." The standalone :dead_workers check still uses a strict age > window comparison (so exactly N days does not fire there, and N days plus one second does). That difference is intentional and documented.

Confidence (Finding.reason)

  • :high_confidence — both signals agree, history covers the window, the static scan is complete, and no nonterminal (including future-scheduled) jobs remain. Still not proof: dynamic dispatch can hide callers, and a worker may legitimately run less often than the window.
  • :referenced — enqueue inactivity holds, but the worker is referenced in code or cron, so it is not a high-confidence dead candidate.
  • :pending_jobs — inactivity plus no static/cron reference, but leftover nonterminal or future-scheduled jobs remain. An old inserted_at is not proof those jobs are dead.
  • :incomplete_analysis — both signals lean that way, but BEAM debug info or compile paths were incomplete, so a hidden caller is possible.
  • :insufficient_history — a new environment, short ledger, or aggressive pruning means history is shorter than the window. That is unknown, not proof of inactivity.
  • :unknown — pending-job evidence could not be read (query error).

Workers that are still being enqueued, or that are referenced and not inactive, are omitted.

Summary

Functions

Classify one worker. Returns {:reason, message} or :omit.

Default window in days when the check is on and window_days is omitted.

True when there is no last insert, or the last insert is at least window_secs before now (inclusive).

Window length in whole seconds.

Functions

classify(attrs)

Classify one worker. Returns {:reason, message} or :omit.

attrs must include: :worker, :history_secs, :window_secs, :window_days, :now, :last_inserted_at, :pending_status (:ok or :error), :pending_count, :next_scheduled_at, :static (:referenced, :unreferenced, or :not_in_scan), :static_reason (:callers, :cron, :no_call_sites, or nil), :static_files (list of paths), and :scan_complete?.

default_window_days()

Default window in days when the check is on and window_days is omitted.

inactive?(at, now, window_secs)

True when there is no last insert, or the last insert is at least window_secs before now (inclusive).

window_seconds(days)

Window length in whole seconds.