Files

51 lines
2.9 KiB
PHP

<?php
// ═══════════════════════════════════════════════════════════════════════════════════════════════
// PURPOSE
// Partnership data endpoint. The whole partnership picture in one document — known hosts,
// reachability, SSH trust, conf-sync state and the shared-service inventory — for the
// partnership tab's poll.
//
// OPERATIONAL MODEL
// One call, one document. The endpoint holds no logic and adds no cache of its own — it
// encodes whatever vv_partnership_all() returns, so any freshness policy is the library's and
// there is only one place it can be changed.
//
// The whole picture is assembled per request rather than exposed as separate endpoints for
// hosts, trust and services. Those answers are read together and judged against each other —
// a host that is reachable but has lost SSH trust is a different state from either fact alone,
// and splitting them would let the tab render a combination that never existed at one moment.
//
// DESIGN PRINCIPLES
// Thin transport. Host enumeration, SSH probing and trust evaluation live in
// include/partnership.php; this file only sets the content type and encodes.
//
// No parameters. The partnership is defined by conf, not by the request, so there is
// nothing for a caller to select and nothing to validate.
//
// OPERATIONAL SAFEGUARDS
// Read-only. Nothing here installs a key, edits a conf, or changes a partner's state.
// Every mutating partnership operation is a separate endpoint (partnership_settings.php,
// setup.php) so that a page poll can never alter trust.
//
// An unreachable partner is a reported condition, not a failure.
// vv_partnership_all() returns each host with its own reachability result, so a dark
// node renders as unreachable while the rest of the page stays accurate. The tab has to
// stay useful precisely when a partner is down.
//
// Probes are time-boxed inside the library, so this endpoint cannot outlast them.
// vv_pt_ssh() runs with ConnectTimeout (4s default) and BatchMode=yes, so a partner
// that is powered off costs that timeout and can never sit waiting for a password.
//
// REQUEST
// GET, no parameters
//
// RESPONSE
// vv_partnership_all() verbatim — {"config":…,"nodes":…,"sync":…,"ts":epoch}
//
// DEPENDS ON
// include/partnership.php vv_partnership_all()
// ═══════════════════════════════════════════════════════════════════════════════════════════════
header('Content-Type: application/json');
require_once dirname(__DIR__) . '/include/partnership.php';
echo json_encode(vv_partnership_all());