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
+48 -1
View File
@@ -1,5 +1,52 @@
<?php
// Fallback tab data helpers
// ═══════════════════════════════════════════════════════════════════════════════════════════════
// PURPOSE
// Fallback page data layer. Reports what state each node is in (NORMAL / FALLBACK /
// NO_INTERNET / DARK), which tiers have activated, and which covered containers are
// actually running — for this host and for every partner.
//
// DESIGN PRINCIPLES
// Observes fallback.sh; never participates in it.
// State is read from the state file the running fallback process maintains. This file
// has no opinion about whether a failover should happen and cannot trigger, advance,
// or hand back one. The page is a window, not a lever.
//
// Remote state is read the same way local state is.
// vv_fb_remote_state() SSHes over and reads the partner's own fallback_state.db rather
// than inferring the partner's state from what this host can see. A node's state is
// whatever that node believes, not what its neighbour guesses.
//
// Coverage lists come from conf, tier membership from FALLBACK_<HOST>_TIER<n>.
// Named for the host being covered, not the host doing the covering — see the fallback
// section of the top-level README for why that reads backwards at first.
//
// OPERATIONAL SAFEGUARDS
// A missing state file parses as empty, not as NORMAL.
// vv_fb_local_state() hands an empty string to the parser when the file is absent, so
// the page shows unknown rather than asserting everything is fine. Reporting a healthy
// state for a fallback process that is not running would be the worst possible lie on
// this page.
//
// An unreachable partner degrades to what is locally known.
// Remote SSH failures return empty rather than propagating an error, so one dark node
// cannot blank the whole page — which is precisely the situation this page exists for.
//
// Read-only over SSH.
// The only remote commands issued are a state-file read and `docker ps`. Nothing here
// starts or stops a container on either side.
//
// EXPORTS
// State vv_fb_local_state(), vv_fb_remote_state(), vv_fb_parse_state()
// Containers vv_fb_local_running(), vv_fb_remote_running(), vv_fb_covers()
// Assembly vv_fb_known_hosts(), vv_fb_all()
// Parsing vv_fb_bash_array(), vv_fb_scalar()
//
// CONFIGURATION
// STATE_DIR fallback_state.db — written by Fallback/fallback.sh
// FALLBACK_<HOST>_TIER1..4 containers covered per tier, keyed by the covered host
// HOST*_SSH_KEY used to read partner state
// ═══════════════════════════════════════════════════════════════════════════════════════════════
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/partnership.php'; // vv_pt_ssh(), vv_pt_ts_peers()