mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-27 07:26:51 +00:00
Every existing rule in this checker runs one way: take a consumer -- a collector dimension, a Tempo tag, a dashboard label, a doc, an asserted metric name -- and require it to resolve to the *SpanNames.h constants. Rule H looks closest to the reverse but is still consumer-side: a constant USED at a call site that no header defines. Nothing looked the other way. So deleting a setAttribute from a .cpp and leaving its constant in the header passed every rule and every compiler, while the telemetry it described stopped being emitted. The workload validation job would eventually notice, but only when it happens to run, and its path filter deliberately does not watch daemon .cpp files -- widening it to 1827 C++ files to catch this would fire a twenty-minute Docker job on nearly every commit. Rule M closes that: an L1 constant no code under src/ or include/ references. It searches all references, not just telemetry call sites, because constants are passed to helpers, stored in locals and used as attribute VALUES -- a call-site-only scan would report false positives. Constants referenced only by test code are reported separately, since a constant exercised by a test but by no production path is still dead in production. A WARNING, not a failure, for two reasons that are both real here. Six constants in this tree are already dead, so failing would redden the branch immediately. And in a stacked chain a constant legitimately lands one commit before its call site, so a failing rule would break intermediate branches for a condition that resolves downstream. What it reports today, all verified unreferenced across the whole repository and not just src/include: ConsensusSpanNames.h val::increased, val::decreased and val::unchanged; SpanNames.h seg::link, attr_val::success and attr_val::error. Placed here rather than upstream on phase-1c, where the checker was introduced, because the gap it closes is a workload-harness concern -- the contract asserting a name nothing emits -- and the harness is this branch's. Putting it on 1c would also mean union-resolving a 1900-line file across ten merge hops, each an opportunity to silently drop the metric rules that live downstream. Ported from a patch written against the sync-diagnostics copy, which carries the metric-side rules I/J/K/L that this branch does not. The rule itself is purely span-side; the only shared dependency it needed was iter_sources, which arrived with those metric rules, so that helper is added here on its own. The rule-L docstring entry and README row that came with the patch context were dropped -- this branch has no rule L. Verification: rule M reports 262 constants checked and 6 unreferenced, exit code still 0 because warnings do not change it; 169 unittest cases pass; the checker compiles; no metric-rule content leaked in from the patch context (0 occurrences of METRIC_MACRO_CALL or run_rule_i_metric_literals). Proven non-vacuous by blanking all three call sites of attr::rpcStatus -- the count went 6 to 7 and named that constant -- then restoring them and watching it return to 6.