Complete M7.8 operations endpoints and region server image

ADR-0066: evo-server --ops-listen serves /livez (loop responding, never
authority), /readyz (200 only while the host holds the lease with a
verified recovered head) and /metrics (Prometheus text: 30 fixed
series for readiness, phase, lease epoch/remaining, simulated/committed
ticks, commit lag, checkpoint age, tick debt, queue use and bounds, and
counters; the only labels are a 6-value phase and 4-value drop reason).

The dependency-free OpsServer runs on the host loop with no thread:
GET on exact paths, 405/404/400/431 responses, 8 connections with excess
refused on accept, 4 KiB requests, 1 s deadlines, 16 KiB responses.
HostStatus/phase types moved to the portable evo::ops library with a
Windows-tested renderer. evo-server now refuses to start without its
required identity and connection settings.

Adds the server-runtime Docker target (evo-server + pinned libpq,
UID 10001, no credentials), a CI server-image job with smoke script and
optional publishing, and a Kubernetes example outside Argo.

Validated: Windows CTest 59/59; Linux Debug/Release/clang-tidy/ASan
CTest 59/59; PostgreSQL suites under Release, clang-tidy and ASan with
real process probes; two ops mutations caught. Docker build/smoke and
Gitea CI not executed locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-28 23:09:28 -04:00
co-authored by Claude Opus 5.5
parent 30411a83f9
commit 7aec68db8e
23 changed files with 1222 additions and 65 deletions
+104
View File
@@ -0,0 +1,104 @@
#include "evo/server/ops.hpp"
#include <string_view>
namespace evo::server {
const char* phase_name(HostPhase phase) noexcept {
switch (phase) {
case HostPhase::acquiring:
return "acquiring";
case HostPhase::running:
return "running";
case HostPhase::resolving:
return "resolving";
case HostPhase::draining:
return "draining";
case HostPhase::stopped:
return "stopped";
case HostPhase::quarantined:
return "quarantined";
}
return "unknown";
}
const char* unacknowledged_name(Unacknowledged reason) noexcept {
switch (reason) {
case Unacknowledged::refused:
return "refused";
case Unacknowledged::drained:
return "drained";
case Unacknowledged::fenced:
return "fenced";
case Unacknowledged::quarantined:
return "quarantined";
}
return "unknown";
}
namespace {
void metric(std::string& out, std::string_view name, std::string_view type, std::string_view help,
std::uint64_t value) {
out.append("# HELP ").append(name).append(" ").append(help).append("\n");
out.append("# TYPE ").append(name).append(" ").append(type).append("\n");
out.append(name).append(" ").append(std::to_string(value)).append("\n");
}
} // namespace
std::string render_metrics(const HostStatus& s, const OpsCounters& c) {
std::string out;
out.reserve(4096);
metric(out, "evo_region_ready", "gauge",
"1 only while this host holds current authority and may originate output", s.ready);
out.append("# HELP evo_region_phase Current host phase (one-hot)\n");
out.append("# TYPE evo_region_phase gauge\n");
for (std::size_t i = 0; i < host_phase_count; ++i) {
const auto phase = static_cast<HostPhase>(i);
out.append("evo_region_phase{phase=\"")
.append(phase_name(phase))
.append("\"} ")
.append(phase == s.phase ? "1" : "0")
.append("\n");
}
metric(out, "evo_region_lease_epoch", "gauge", "Lease epoch held or last held", s.epoch);
metric(out, "evo_region_lease_remaining_milliseconds", "gauge",
"Local time until this host must stop originating (0 without a lease)",
s.lease_remaining_ms);
metric(out, "evo_region_simulated_tick", "gauge", "Last simulated tick", s.simulated_tick);
metric(out, "evo_region_committed_tick", "gauge", "End tick of the committed head",
s.committed_tick);
metric(out, "evo_region_committed_sequence", "gauge", "Commit sequence of the head",
s.committed_sequence);
metric(out, "evo_region_commit_lag_ticks", "gauge",
"Simulated but not yet durably committed ticks",
s.simulated_tick >= s.committed_tick ? s.simulated_tick - s.committed_tick : 0);
metric(out, "evo_region_checkpoint_age_milliseconds", "gauge",
"Time since the last confirmed commit or recovery", c.checkpoint_age_ms);
metric(out, "evo_region_tick_debt", "gauge", "Due ticks not yet simulated", s.tick_debt);
metric(out, "evo_region_tick_debt_max", "gauge", "Largest tick debt since recovery",
s.max_tick_debt);
metric(out, "evo_region_queued_inputs", "gauge", "Admitted inputs awaiting a tick", s.queued);
metric(out, "evo_region_queued_bytes", "gauge", "Accounted bytes of queued inputs",
s.queued_bytes);
metric(out, "evo_region_queue_capacity_inputs", "gauge", "Input backlog bound",
c.queue_capacity_inputs);
metric(out, "evo_region_queue_capacity_bytes", "gauge", "Input backlog byte bound",
c.queue_capacity_bytes);
metric(out, "evo_region_commits_total", "counter", "Confirmed commits", s.commits);
metric(out, "evo_region_store_failures_total", "counter",
"Storage or database failures that paused progress", s.store_failures);
metric(out, "evo_region_unknown_outcomes_total", "counter",
"Commits whose outcome had to be resolved", s.unknown_outcomes);
metric(out, "evo_region_fences_total", "counter", "Times this host lost authority", s.fences);
metric(out, "evo_region_acknowledgements_total", "counter", "Final acknowledgements emitted",
c.acks);
metric(out, "evo_region_outcomes_total", "counter", "Final permanent outcomes emitted",
c.outcomes);
out.append("# HELP evo_region_dropped_total Accepted inputs that will never be acknowledged\n");
out.append("# TYPE evo_region_dropped_total counter\n");
for (std::size_t i = 0; i < unacknowledged_count; ++i)
out.append("evo_region_dropped_total{reason=\"")
.append(unacknowledged_name(static_cast<Unacknowledged>(i)))
.append("\"} ")
.append(std::to_string(c.dropped[i]))
.append("\n");
return out;
}
} // namespace evo::server