rules
Rule catalog
Entry-point plugins the rule-worker loads by RULE_CODE — each with a
manifest, config schema and golden replay cases.
Teacher:student ratio — CNT08 (too few teachers) / CNT09 (too many)
Staffing-ratio compliance for supervised rooms. Counts teachers (adults) vs students (children) per frame — persons are reclassified to adult/child via detector classes or SGIE age scores — estimates a robust per-second count by reliability-weighted mode (tolerates flickering detections), maps the student count to a required number of teachers via a configurable ratio table, and fires when the requirement is violated for >= violation_rate_threshold of a sliding window (default 10 minutes). CNT08 = too few teachers present (OVERRATIO, the safety violation); CNT09 = too many (UNDERRATIO, staffing efficiency). Accumulator rule: needs no tracker, works on raw per-frame detections + video clock, so it is robust to ID switches in crowded rooms. Fires per camera (room), not per person.
karterschool accumulator warehouse_detector CNT09v1.1.0Teacher:student ratio — CNT08 (too few teachers) / CNT09 (too many)
Staffing-ratio compliance for supervised rooms. Counts teachers (adults) vs students (children) per frame — persons are reclassified to adult/child via detector classes or SGIE age scores — estimates a robust per-second count by reliability-weighted mode (tolerates flickering detections), maps the student count to a required number of teachers via a configurable ratio table, and fires when the requirement is violated for >= violation_rate_threshold of a sliding window (default 10 minutes). CNT08 = too few teachers present (OVERRATIO, the safety violation); CNT09 = too many (UNDERRATIO, staffing efficiency). Accumulator rule: needs no tracker, works on raw per-frame detections + video clock, so it is robust to ID switches in crowded rooms. Fires per camera (room), not per person.
karterschool accumulator warehouse_detector CNT10v1.0.0CNT10 — students present with no teacher in the room
Unattended-children rule: fire when at least one student is present AND no teacher is present, sustained for >= violation_rate_threshold (default 80%) of a sliding window (default 30 s). Per-frame counts come from detector classes or SGIE age scores (persons reclassified to adult/child); inter-frame time is clamped to 5 s so stream gaps can't inflate the violation time, and the window counts committed one-second buckets only. After the initial alert the rule re-fires as a reminder every reminder_interval_seconds (default 5 min) while the violation persists; when a teacher returns the cycle resets. Room-level accumulator — no tracker.
karterschool accumulator person_detector HM05v1.0.0HM05 — person walking in a no-walk zone
Pedestrian-routing safety rule: fire when a person WALKS through a designated no-walk zone (forklift aisles, racking lanes). When a person enters a no_walking_zone polygon a 7-second monitoring window opens; the rule fires at window close only if the person actually travelled (max displacement >= distance_multiplier x their average bbox height) AND none of three worker exclusions applies over the window: overlapping/near an MHE >= 30% of frames (operating a vehicle), overlapping/near product >= 30% (handling goods), or classified as cleaner >= 30% (SGIE cleaner_scores). Leaving the zone resets the window. Per-track, fire-once.
warehouse T1 geometry track warehouse_detector HM07v1.0.0HM07 — person stationary beyond a time limit
Loitering / inactivity detection on tracked persons. Fires when a person stays effectively stationary — bbox center barely shifts vs the still-streak anchor (move_distance_threshold) — for longer than limit_time seconds (default 130s), with the detections over the streak clearing mean/median confidence + count gates to suppress flicker. Honours cam_zones polygons when configured (only fires inside monitored areas). Per-track, fire-once per still-streak; any real movement resets the streak. Pure geometry over tracking (tier 1) — no extra model beyond a person detector; a downstream VLM recheck can be layered as the evidence gate.
warehouse T1 geometry track person_detector MHE01v1.0.0MHE01 — collision warning (MHE too close to MHE / person)
Collision-warning rule in real-world metres. Each camera is calibrated with a 4-point planar homography (image_points → real_points); bbox reference points are transformed to floor coordinates and pairwise distances checked every frame: MHE↔MHE closer than min_distance_mhe_vs_mhe (default 2.0 m) while BOTH vehicles are moving, or MHE↔person closer than min_distance_mhe_vs_person (default 2.5 m) while the MHE is moving. Persons riding an MHE are excluded as drivers (bbox-overlap history); a vehicle stationary >= 3 s (with brief-movement tolerance) is exempt; near-duplicate boxes are skipped. A pair fires after violent_count consecutive illegal frames, once per pair. Confidence is a Gaussian of the measured distance blended with (1 - IoU). Cross-object rule — pure geometry + homography, no extra model.
warehouse T1 geometry track warehouse_detector MHE03v1.0.0MHE03 — MHE crossing an intersection at excessive speed
Intersection-speed rule for material handling equipment. Maintains a per-track speed history (bottom-center pixel displacement per frame); when the vehicle's recent motion segment crosses a configured intersection line, the last ~1 second of speed samples is analysed in 5-sample chunks: the rule fires when the mean approach speed exceeds medium_speed (px/frame) AND the slowest chunk is one of the last two (deceleration right at the line — the legacy "came in hot, braked at the crossing" pattern). Fire-once per track. Confidence blends mean detection confidence, speed consistency (1 - coefficient of variation of chunk sums) and a Gaussian of the minimum chunk around ideal_speed. Speeds are raw pixels/frame — thresholds are per-camera tuning values (legacy semantics, not metres/second).
warehouse T1 geometry track warehouse_detector MHE04v1.0.0MHE04 — excessive pallet stacking (oversized stack in motion)
Oversized-stack rule: fire when a cluster of max_pallet_number or more pallets is being moved as one stack. A moving seed pallet gathers vertically-stacked neighbours (horizontal overlap >= 50% of the narrower box, column split at y-gaps > 1.5x seed height); a big-enough cluster opens a pending window and is confirmed only after ~2 s of stability gates pass (count within tolerance, bounded count std-dev, enough frames at the threshold, merged bbox doesn't balloon, and the centroid actually DRIFTS >= min_centroid_disp_ratio of the cluster height — the stack must be in transport). At creation at least half the pallets must be moving — a parked warehouse stack is not a violation, the rule targets stacks in transport. Rejected seeds get a frame-count cooldown; confirmed cluster members never re-fire. Confidence blends detection confidence, cluster cohesion, motion consistency and a Gaussian of the count.
warehouse T1 geometry track warehouse_detector MHE10v1.0.0MHE10 — moving while load at height
Forklift-safety rule: detect a Material Handling Equipment unit (forklift / reach truck) TRAVELLING while its load (product package) is raised above the vehicle base — a classic tip-over / dropped-load hazard. Works purely on geometry over tracked boxes: associates the package box to its carrying MHE, measures the package's vertical offset vs the vehicle base (base_y_distance / increased_y_distance) and the vehicle's travel angle/velocity (degrees_threshold, prd_move_threshold); event confidence is a weighted blend of MHE/product confidence and geometry terms. An optional sklearn postprocess gate re-validates each candidate on the last-5 bbox features (fail-open if the service is down). Per-track, immediate emit.
warehouse T1 geometry warehouse_detector OTH02v1.0.0OTH02 — skipped the alcohol test at the checkpoint
Checkpoint-compliance rule: fire when a person's trajectory crosses BOTH the start_line and the end_line of the alcohol-test area, entering in the expected direction (y-center increasing), without ever using the test device — "using" is any frame where the person's bbox overlaps an alcohol-tool detection by more than alcohol_iou_threshold of the tool's area. Line-crossing rule built on segment-segment intersection of the track's first→last center trajectory. Fire-once per track. Confidence = 0.5·mean + 0.5·median of recent detection confidences. The legacy camera-specific truck variant (truck passing without a full stop) is not ported.
warehouse T1 geometry track checkpoint_detector PAR02v1.0.0PAR02 — person using phone while moving
Distracted-walking safety rule: detect a person who is USING A PHONE (per-frame using_phone_scores from the PAR attribute SGIE) AND MOVING (accumulated travel >= movement_ratio x average bbox width) at the same time. A confirmation window opens when the phone is first seen inside a monitored zone (cam_zones); at window close the rule decides on the accumulated evidence (deferred emission — one clean event with the full clip, not per-frame spam). Per-track, fire-once. The combination matters: phone-while-stationary is allowed (break areas), walking-without-phone is allowed — only the combination fires.
warehouse track par PAR03v1.0.0PAR03 — adult sustained phone usage
Sustained phone-usage rule for staff monitoring: flag an ADULT who is using a phone for at least phone_usage_ratio_threshold of a sliding time window (window must be >= min_duration long). Per-frame binary phone gate (using_phone_scores > threshold_phone from the attribute SGIE), ratio-over-window smoothing so brief glances don't fire, immediate emit on confirmation, fire-once per track. Unlike PAR02 there is NO motion requirement — this targets prolonged distraction (e.g. a caregiver on the phone instead of supervising), stationary or not, and it only evaluates adults (children with phones are ignored).
karterschool track person_detector PL02v1.0.0PL02 — pallet on the floor over the time limit (batched)
Housekeeping/blockage rule: fire when a pallet (or product package) stays on the floor longer than violent_count seconds (default 60 min), and re-fire every violent_count while it remains. A pallet overlapping a truck is skipped (being loaded/unloaded). Alert batching: when other pallets are within first_waiting_window_time of violating, reporting is held so several pallets land in one event instead of alert spam — held at most max_wait_time before force-fire. Zone check keeps the legacy two-point semantics (bbox center AND center-bottom inside a cam_zone). Evidence per pallet = first + last detection of each video segment. See PL03 for the hardened variant with movement resets, region-level cooldown and stricter batch FSM guards.
warehouse T1 geometry track warehouse_detector PL03v1.0.0PL03 — pallet on floor over time (hardened FSM variant)
The production-hardened successor to PL02. Same violation ("pallet on the floor longer than violent_count seconds") but with the false-positive/duplicate machinery that real deployments needed: a per-track floor timer anchored by timestamp that RESETS when the pallet moves and re-anchors after track gaps; the violation threshold separated from the re-report cooldown (report_interval); slender side-on boxes get extra confirm time; a REGION-level cooldown (centroid distance + IoU vs recently fired locations) so tracker id churn on the same physical pallet cannot re-fire; and a guarded batch FSM — one-shot post-ready hold, one-shot near-grace while near-violation pallets exist, minimum emit gap, max batch wait force-fire, and a duplicate-signature guard. Evidence is sampled (first/last per video segment + midpoints, capped). Prefer PL03 over PL02 for new deployments; PL02 stays as the faithful simple port.
warehouse T1 geometry track warehouse_detector PPE01v1.0.0PPE01 — person not wearing required PPE (helmet / safety clothes)
PPE-compliance rule: detect a tracked person NOT wearing required protective equipment (helmet and/or safety clothes). Per-frame SGIE classifier scores (not_wearing_helmet, wearing_safetyclothes_1/6) are voted across a short ppe_check_window_seconds window — small or frame-edge boxes are dropped as unreliable — and the rule fires once per track when the violating fraction clears voting_ratio_threshold. The voting window suppresses single-frame misclassifications (turned heads, brief occlusions). Which PPE items are enforced is configurable, so helmet-only or vest-only deployments reuse the same rule.
warehouse T1 geometry track person_detector cl01v1.0.0VLM periodic — scheduled full-frame VLM check
Scheduled full-frame Vision-Language-Model check — the catch-all rule for requirements that need scene UNDERSTANDING rather than object detection. On a Mon-Fri schedule (one-shot at fixed times + periodic every N seconds within a time window, in the camera's timezone) it emits a full-frame snapshot event; the downstream VLM service answers a configured natural-language question about the scene (e.g. "is the room tidy?", "are curtains closed during nap time?", "is the gate locked?"). No detector, no tracker, no model from the zoo — pure schedule. The cl01/cl02/cl03 codes are the same module with different questions/schedules per deployment. This is usually the fastest way to cover a new requirement BEFORE investing in a dedicated rule or model: write a question + schedule instead of code.
karterschool frame cl02v1.0.0VLM periodic — scheduled full-frame VLM check
Scheduled full-frame Vision-Language-Model check — the catch-all rule for requirements that need scene UNDERSTANDING rather than object detection. On a Mon-Fri schedule (one-shot at fixed times + periodic every N seconds within a time window, in the camera's timezone) it emits a full-frame snapshot event; the downstream VLM service answers a configured natural-language question about the scene (e.g. "is the room tidy?", "are curtains closed during nap time?", "is the gate locked?"). No detector, no tracker, no model from the zoo — pure schedule. The cl01/cl02/cl03 codes are the same module with different questions/schedules per deployment. This is usually the fastest way to cover a new requirement BEFORE investing in a dedicated rule or model: write a question + schedule instead of code.
karterschool frame cl03v1.0.0VLM periodic — scheduled full-frame VLM check
Scheduled full-frame Vision-Language-Model check — the catch-all rule for requirements that need scene UNDERSTANDING rather than object detection. On a Mon-Fri schedule (one-shot at fixed times + periodic every N seconds within a time window, in the camera's timezone) it emits a full-frame snapshot event; the downstream VLM service answers a configured natural-language question about the scene (e.g. "is the room tidy?", "are curtains closed during nap time?", "is the gate locked?"). No detector, no tracker, no model from the zoo — pure schedule. The cl01/cl02/cl03 codes are the same module with different questions/schedules per deployment. This is usually the fastest way to cover a new requirement BEFORE investing in a dedicated rule or model: write a question + schedule instead of code.
karterschool frame vlm_periodicv1.0.0VLM periodic — scheduled full-frame VLM check
Scheduled full-frame Vision-Language-Model check — the catch-all rule for requirements that need scene UNDERSTANDING rather than object detection. On a Mon-Fri schedule (one-shot at fixed times + periodic every N seconds within a time window, in the camera's timezone) it emits a full-frame snapshot event; the downstream VLM service answers a configured natural-language question about the scene (e.g. "is the room tidy?", "are curtains closed during nap time?", "is the gate locked?"). No detector, no tracker, no model from the zoo — pure schedule. The cl01/cl02/cl03 codes are the same module with different questions/schedules per deployment. This is usually the fastest way to cover a new requirement BEFORE investing in a dedicated rule or model: write a question + schedule instead of code.
karterschool frame