1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// githttp-fs
//
// Git-based Content Management System
// Copyright: 2026, Valerian Saliou <valerian@valeriansaliou.name>
// License: Mozilla Public License v2.0 (MPL v2.0)
//! The public health surface: `/v1/_health/*`.
//!
//! Two routes, and they are the **only** unauthenticated routes on the
//! content API:
//!
//! | Route | Answers |
//! |-------|---------|
//! | `GET /v1/_health/status` | what this process is: name, version, role, whether it takes writes |
//! | `GET /v1/_health/replication` | the replication picture, identical to what peers read from `/_replication/health` |
//!
//! **Why no API key.** These answer questions a caller has to be able to ask
//! *before* it holds a credential, or when the credential is exactly what is
//! in doubt: a load balancer deciding whether to route to this node, a
//! deployment probe waiting for a rollout to come up, a client discovering
//! which node of a set accepts writes, an operator's dashboard covering a
//! whole deployment. Requiring the content key for that turns a health probe
//! into a secret-distribution problem, and puts the product's key into every
//! monitor. `GET /v1` remains the *authenticated* probe, and it is the one to
//! use to verify a key; these two never look at one.
//!
//! **What that costs, and why it is bounded.** Nothing here touches tenant
//! content: no repository is opened, no path is resolved, no tenant is named
//! in a request or a response. `status` reads process-level facts only, so it
//! cannot be used to make this node do work. `replication` is the operator's
//! view of the node set, which does name peers and count repositories — see
//! [`health_replication`] for what that means for an operator who considers
//! their topology sensitive.
//!
//! They live under a `_health` prefix, which makes `_health` the one
//! collection id this API reserves — and it reserves it narrowly. Only these
//! two exact paths are static routes, so `/v1/_health/{tenant_id}/files` and
//! every other deeper tenant route still resolve normally; the sole collision
//! is a collection named `_health` holding a tenant named `status` or
//! `replication`, whose two-segment tenant route (`DELETE`) these shadow.
use ;
use json;
use crate::;
/// GET /v1/_health/status
///
/// What this process is, in the smallest honest terms: which build is
/// running, which role it plays in a replicated set, whether it accepts
/// writes, and how long it has been up.
///
/// Deliberately **free of I/O**. Every field is read from the config or from
/// an atomic already in memory — no repository is opened, no directory is
/// walked, nothing is scheduled on the blocking pool. That is what makes it
/// safe to leave unauthenticated and safe to poll at whatever interval a
/// monitor likes: an anonymous caller cannot make this node do work by
/// asking.
///
/// It always answers `200`, including on a replica that is still
/// bootstrapping. The status code is about the process being alive enough to
/// answer; *what* it can serve is the body's job to say, via `status` and
/// `writable`. Collapsing the two into a status code would force a caller
/// that just wants the version to interpret a `503`, and would hide the one
/// state a bootstrapping node most needs to be able to report.
pub async
/// GET /v1/_health/replication
///
/// The replication picture as this node sees it: its own role and identity,
/// the master's reachability, and every replica following it. Byte-identical
/// to what peers read from `/_replication/health` with the replication key —
/// one struct and one builder behind two doors, differing only in who may
/// open them.
///
/// It answers on **every** node, whatever its role, including a standalone
/// one (as `role: "standalone"`). One probe then works against a whole
/// deployment without the prober knowing which node is which — a `404` here
/// would force exactly that knowledge into the monitoring config.
///
/// Unauthenticated, like its sibling, because the audience is monitoring
/// rather than the application. The trade is worth stating plainly: this body
/// names peer node ids, the master's URL (credentials stripped), the data-set
/// identity, and a repository count, so it describes a deployment's topology
/// to anyone who can reach the port. None of it is a credential — pulling
/// from a peer needs `replication.secret`, which appears nowhere here — but
/// an operator who treats internal hostnames as sensitive should keep this
/// port off the public internet, which is the same decision they already make
/// for the replication listener.
///
/// Unlike [`health_status`] it does touch the filesystem, through the
/// repository index (only on its first use, which is a directory scan), so it
/// goes through the blocking pool.
pub async