Module: utils/staleDetector

Detect and flag stale tests (AUTO-013).

A test is considered stale when it is approved but has not been run in a configurable number of days (default 90, env STALE_TEST_DAYS).

Called by the weekly background job in scheduler.js and can also be invoked programmatically via detectStaleTests(projectIds).

When called without arguments from the cron job, scans each workspace independently so logging and counts are per-workspace (multi-tenant safe).

Source:
Example
import { detectStaleTests } from "../utils/staleDetector.js";
const result = detectStaleTests();
// { flagged: 12, cleared: 3 }

Members

(inner, constant) STALE_DAYS :number

Days since last run before a test is considered stale.

Type:
  • number
Source:

Methods

(static) detectStaleTests(projectIdsopt) → {Object}

Scan projects and flag approved tests that haven't been run recently.

  1. Clear existing stale flags (tests that have since been run).
  2. Find tests older than STALE_DAYS since their last run.
  3. Bulk-flag them as stale.

When projectIds is provided, scans only those projects (used by API triggers or tests). When omitted, discovers all workspaces and scans each independently so multi-tenant deployments get per-workspace logging.

Parameters:
Name Type Attributes Description
projectIds Array.<string> <optional>

— Scope to specific projects. If omitted, scans all workspaces.

Source:
Returns:
Type
Object