Skip to main content

Red Flags

Red flags are policy violations attached to an attendance record. Each flag has a code, a severity, and the unit's configured action.

Codes

CodeTrigger
LATE_CHECK_INFirst punch after start.
EARLY_CHECK_OUTLast punch before end.
GEO_VIOLATIONDistance > geo_radius_m while geo is enabled.
MULTIPLE_PUNCHESMore than one in or out inside a shift.
MISSING_CHECK_OUTfirst_in_at present but no last_out_at within window.
MISSING_CHECK_INlast_out_at present but no first_in_at.
DEVICE_MISMATCHPunch from a fingerprint not in devices(approved).
SHIFT_WINDOW_VIOLATIONPunch outside [earliest_in, latest_out] after manual insertion.
MANUAL_PUNCHA manager recorded the punch on behalf of an employee.

Actions

Per-unit policy in red_flag_policies:

ActionBehavior
allow_flagAccept the punch, attach the flag, continue.
blockReject the punch with 400.
require_approvalAccept the punch but hold the attendance row in pending_approval until HR decides.

Severity

  • info — advisory, no side effects (MANUAL_PUNCH).
  • warn — visible in reports (LATE_CHECK_IN, EARLY_CHECK_OUT).
  • critical — gates payroll export (GEO_VIOLATION, DEVICE_MISMATCH, SHIFT_WINDOW_VIOLATION).

Report Filters

GET /api/v1/attendance?flag=LATE_CHECK_IN&since=2026-04-01 — every flag is a first-class filter for HR dashboards.

Testing Strategy

The RedFlagEngine has a deterministic test matrix. Every pair of (code × action) × (permutation of punches) is asserted in Pest.