#!/bin/bash # ============================================================================================== # ============================== AI Log Pattern Check ======================================= # ============================================================================================== # PURPOSE # ───────────────────────────────────────────────────────────────────────────── # Checks the repair sweep's syslog triage two ways, because the two failure modes are opposite # and a single test catches only one of them: # # RECALL — every line in ai_log_fixtures.txt is recognised, with the right subject and # the right level. Faults this host has never had, which is most of them. # PRECISION — replays this machine's entire real syslog history and reports everything the # patterns fire on. A pattern that matches normal operation fills the findings # store with noise and teaches the operator to ignore the notification. # # Run it after touching VV_AI_SYSLOG_PATTERNS. Nothing here writes: no findings are filed, no # conf is read for anything but the enable flag, and the sweep is never invoked. # # ============================================================================================== # OPERATIONAL MODEL # ============================================================================================== # # A wrapper. The work is in ai_log_check.php, next to the sweep's own matcher — the patterns and # vv_ai_syslog_findings() live in include/ai_repair.php, and a bash reimplementation of the # matching would be a second set of regexes to keep in step with the first. # # Flags are forwarded verbatim; nothing is interpreted here. # # Not scheduled and in no orchestrator. This is a development check that runs when the patterns # change, not on a timer — nothing on the running system depends on it. # # ============================================================================================== # DESIGN PRINCIPLES # ============================================================================================== # # Two checks, because the failure modes are opposite. # Recall catches a pattern that stopped matching; precision catches one that matches too much. # A single test would catch one and silently permit the other, and the second is the one that # fills the findings store with noise until the operator stops reading it. # # Precision is measured against this machine's real history. # A hand-written fixture file can show that a pattern matches what it should. Only a real # syslog can show what it also matches when nothing is wrong. # # Only recall fails the run. # What a real syslog contains is a fact about the machine, not about the patterns. A genuinely # failing disk should not turn this red. # # ============================================================================================== # OPERATIONAL SAFEGUARDS # ============================================================================================== # # Read-only. No finding is filed, no store is written, and the repair sweep itself is never run # — only its matcher, on lines this check supplies. # # Safe to run on a live host at any time, including one that is currently faulting. It observes # the syslog it replays and changes nothing about it. # # ============================================================================================== # RUNTIME MODES # ============================================================================================== # # ai_log_check.sh both checks # ai_log_check.sh --precision replay the host's syslogs only, and list what matched # ai_log_check.sh --recall fixtures only # # ============================================================================================== SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" php "$SCRIPT_DIR/ai_log_check.php" "$@"