Add structured headers to the PHP include layer, fix monitor state paths

All 16 include/ files now carry PURPOSE / DESIGN PRINCIPLES / OPERATIONAL
SAFEGUARDS / EXPORTS / CONFIGURATION, keeping the first three section names
identical to the bash headers so retrieval can route across both languages.

monitor.php read six watchdog state files from /tmp while the watchdogs write
to STATE_DIR, so every strike set came back empty and the summary reported
healthy unconditionally. docs.php gained path containment before it is wired
to a page.
This commit is contained in:
Gmer4Lfe
2026-08-02 00:38:22 -04:00
parent 76c4ca5ccf
commit 43b5443b30
16 changed files with 811 additions and 21 deletions
+52
View File
@@ -1,4 +1,56 @@
<?php
// ═══════════════════════════════════════════════════════════════════════════════════════════════
// PURPOSE
// Watchdog page data layer. Collects what every watchdog has recorded — resource strikes,
// container restart history and the failed-container skip list, system strikes and OOM
// count, storage growth and log strikes, network/NPM strikes, and the reboot log — for
// this host and each partner.
//
// DESIGN PRINCIPLES
// Reads the strike counters; never resets them.
// Strike state belongs to the watchdog that owns it. A page that cleared strikes would
// silently undo an escalation the watchdog was deliberately building toward.
//
// One state file per watchdog, parsed independently.
// resource / container / system / storage / network each keep their own db. A watchdog
// that has never run leaves its file absent, which is a distinct and meaningful state.
//
// The skip list is surfaced, not hidden.
// docker_watchdog_failed.db records containers the docker watchdog has given up on.
// Those are exactly the ones an operator needs to see, so they are shown rather than
// filtered out of the healthy-looking list.
//
// OPERATIONAL SAFEGUARDS
// Every state read is suppressed and defaulted.
// @file_get_contents with a ?: fallback throughout — an absent or unreadable db yields
// empty/zero and that watchdog's card renders as "no data", never as a fatal.
//
// Absent counters read as zero, not as unknown-therefore-alarming.
// A watchdog that has not yet written state is reported quiet rather than as a
// problem, so a fresh boot does not light up the page with false strikes.
//
// Remote collection failures are per-node.
// One unreachable partner drops that node's card; the local host and every other
// partner still render.
//
// Read-only. Nothing here restarts a container, clears a strike, or triggers a reboot.
//
// EXPORTS
// Local vv_wd_local_system(), vv_wd_local_states()
// Remote vv_wd_remote_data(), vv_wd_node_config()
// Assembly vv_wd_all()
// Parsing vv_wd_bash_array(), vv_wd_bash_assoc(), vv_wd_scalar(), vv_wd_parse_kv(),
// vv_wd_parse_restart_log(), vv_wd_parse_skiplist(), vv_wd_parse_reboot_log(),
// vv_wd_parse_storage_state(), vv_wd_parse_network_state()
//
// CONFIGURATION
// STATE_DIR resource_watchdog_state.db, container_watchdog_state.db,
// docker_watchdog_failed.db, system_watchdog_state.db,
// system_watchdog_oom.db, storage/network watchdog state
// RW_CRITICAL_CONTAINERS containers the resource watchdog treats as critical
// HOST*_SSH_KEY used to collect partner watchdog state
// ═══════════════════════════════════════════════════════════════════════════════════════════════
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/partnership.php';