Conversation
zzylol
force-pushed
the
stack/509-w6-counter-proof
branch
from
October 4, 2026 18:25
f14bf7a to
ee6f881
Compare
zzylol
added a commit
that referenced
this pull request
Oct 4, 2026
zzylol
added a commit
that referenced
this pull request
Oct 4, 2026
Pass 1 takes the declared metric types since #593. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
Oct 4, 2026
zzylol
changed the base branch from
stack/509-e2-keyed-additive-topk
to
stack/509-w1-stage3-cost
October 4, 2026 18:25
This was referenced Oct 4, 2026
Draft
Share one UnivMon across distinct, L2 and entropy; document why those readouts stay uncertified
#596
Draft
…tive weights DataWorkload gains `metric_types` (metric name -> Counter | Gauge, the Prometheus TYPE metadata). plan_stages passes it to Stage 1, and Pass 1 attaches the new `CounterSamples` non-negativity proof to a keyed summary update weighted by the sample value when the target's input is samples of a declared counter, through a time range and plain sums (sum_over_time). Any other operator, a gauge or an undeclared metric (whatever its suffix) gets no proof. Stage 3 and the runtime already accept any NonNegative proof for Count-Min, so their rule is unchanged. Example 1 declares http_requests_total a counter: all 64 candidates are valid and compile (24 Count-Min + heap were invalid). Stage 3 now selects P60 (Count-Min + heap over the exact sum_over_time accumulator, shared input) at 46.201 against P58 (all exact) at 52.201, now 8th. Refs #509, #580. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Example 1 declares http_requests_total a counter, so Stage 3 selects P60 at 46.201 × 0.1 = 4.620 cost per second. Update the per-second ranking test and the Stage 3 cost model's worked example to P60. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
stack/509-w6-counter-proof
branch
from
October 5, 2026 06:21
ee6f881 to
761b2ce
Compare
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.
Rebased on main d4869a7 (DF 54).
Wave 1 chain: #594 → #593 → #592 → #591 → #595 → #596 → #597 → #598 → #599 (on #589)
Part of #509 (Example 1), decision X1 from #580's planning: a metric-type declaration plus a non-negativity proof, so Count-Min + heap is valid over raw counter samples.
Why
Example 1's Q2 is
topk by (job) (10, sum_over_time(http_requests_total[1m])). Every Count-Min + heap candidate for it, including #589's whole-expression heap over raw samples, was rejected by Stage 3 and by the runtime, because nothing proved the update weights (raw sample values, or their sums) non-negative. Neither the workload nor the catalog carried a metric type, and the_totalsuffix is only a naming convention.What
DataWorkload.metric_types: BTreeMap<String, MetricType>withMetricType::{Counter, Gauge}(Prometheus# TYPE). It defaults to empty.DataWorkloadbecause that struct already holds the facts about the queried data, the PromQL frontend already reads its ingestion interval, andplan_stagesalready receives it, so Stage 1 can read it without a new input layer.HistogramCatalogwas not used: it is histogram-specific and lowering-only, and the IR has no place to carry the declaration on to Stage 1.NonNegativeWeightProof::CounterSamplesvariant.WeightDomain::NonNegativeproof, so they apply the same rule.How
plan_stagespasses&data.metric_typestostage1_logical_candidates, which passes it toenumerate_local_logical_candidates. This is a plain parameter.counter_inputon each target. It is true when the target's input is samples of a metric declared a counter, reached only throughTimeRangeand plainSumaggregates (sum_over_time,sum by).SampleValueover such an input getsCounterSamples. This covers both the heap over per-series sums and the whole-expression heap over raw samples.http_requests_totala counter in thestage_pipelinedevtool and in the acceptance test. The fixture and acceptance doc are regenerated, and the workflow doc lists the field. The integration commit updates Stage 3 per-second cost model, memory pricing and calibration #594's per-second ranking test and the Stage 3 cost model's worked example to P60.Before / After (Example 1, built-in models, no cost tuning)
Costs are per second (#594): per-evaluation CPU-ms × 0.1 evaluations/s.
sum_over_timeaccumulator; shared input), 4.620/s (46.201 per evaluation)Without the declaration, or with
http_requests_totaldeclared a gauge, the 24 Count-Min + heap candidates stay invalid and the runtime still rejects them. This is today's behavior, and a test covers it.Tests
CounterSampleson all 6 heap updates. An undeclaredm_total, a gauge, or a different declared counter gives none.counter_samplesstops at arithmetic (- 100, unary minus).Gate
cargo fmt --all --check: passes.cargo clippy --workspace --all-targets --all-features -- -D warnings: passes.cargo test --workspace: 1,522 passed / 10 ignored (feat(planner): whole-expression top-k heap sketch over raw samples #589: 1,517 / 10).Refs #509, #580.
🤖 Generated with Claude Code