fix(engine): split contain_node proposed/eligible metric labels - #325
Merged
thejefflarson merged 1 commit intoAug 7, 2026
Conversation
The evaluate_proposal level-triggered arm (Engine::process) was reusing the same "proposed" label as the ledger-delta edge-triggered surfacing, so a single newly-proposed rails-clean ContainNode double-incremented "proposed" in its first pass. Give the level-triggered signal its own "eligible" label (already the term the surrounding doc comments used for that state) instead of deduping — the two are genuinely distinct operator-facing signals: "surfaced in the ledger" vs. "currently armed + in-scope + rails-clean this pass". Adds a value-asserting unit test (via a local SdkMeterProvider + in-memory exporter, not the process-global one) that fails on the old double-count and passes with the label split. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
thejefflarson
enabled auto-merge (squash)
August 7, 2026 01:05
thejefflarson
deleted the
thejefflarson/jef-766-contain_node-proposed-metric-double-counts-per-pass-edge
branch
August 7, 2026 01:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
record_contain_node("proposed", …)fired twice per pass for a newly-proposed, rails-cleanContainNode: once edge-triggered overledger_delta.proposed(Engine::process's ledger-delta loop) and again level-triggered in theevaluate_proposalProposedarm. Both call sites shared the sameproposedlabel, so a fresh proposal was counted twice in that pass.Approach chosen
Distinct labels (over dedup): the two events are genuinely different operator-facing signals —
proposed(unchanged): edge-triggered, fires once, the pass the ledger first surfaces the mitigation at all (fires even undermode: audit).eligible(new): level-triggered, fires every pass the same mitigation stays armed at thenoderung, inenforceScope, and every deterministic rail passes — the stronger claim "this is currently a rails-clean, actionable proposal". This term was already used in the surrounding doc comments ("ELIGIBLE to be surfaced as an actionable proposal"), so it lines up with existing vocabulary rather than inventing a new one.Label vocabulary stays closed (
proposed/eligible/reverted/rail_refused+ fixedreasons) — no new per-node/high-cardinality dimension. No behavior change beyond the metric labels.Testing
engine/src/engine/metrics.rs::tests::a_single_pass_never_double_counts_one_label— new focused unit test. The prior test for this counter was a no-op smoke test (constructs the no-op global meter, asserts no panic), so it couldn't have caught this. This test wires a localSdkMeterProvider+InMemoryMetricExporter(not the process-global meter, to avoid racing other tests in the same binary) via a newEngineMetrics::from_meterconstructor, records oneproposed+ oneeligibleevent (mirroring one pass over a single fresh proposal), and asserts both labels read back as exactly1. Verified it fails (left: Some(2)) against the pre-fix code (both calls using"proposed") and passes after the fix.eligibleevent.cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,cargo build --all-targets,cargo test --workspaceall green (1213 passed, 0 failed, 2 ignored).Closes JEF-766