Skip to content

desktop/src-tauri/crates/core/src/aggregates.rs

Comment 1, line 1

desktop/src-tauri/crates/core/src/aggregates.rs:1

//! Native source intervals (source_aggregates), cumulative differences and quota snapshots.

Comment 2, line 2

desktop/src-tauri/crates/core/src/aggregates.rs:2

//!

Comment 3, line 3

desktop/src-tauri/crates/core/src/aggregates.rs:3

//! Rules:

Comment 4, line 4

desktop/src-tauri/crates/core/src/aggregates.rs:4

//! - interval_aggregate keeps native scope, fields and units without inventing individual calls.

Comment 5, line 5

desktop/src-tauri/crates/core/src/aggregates.rs:5

//! - cumulative_snapshot differences follow identity, version and reset boundaries. Keep the

Comment 6, line 6

desktop/src-tauri/crates/core/src/aggregates.rs:6

//! first native interval total; do not assign an unsampled multi-day total to one day or spread it by time.

Comment 7, line 7

desktop/src-tauri/crates/core/src/aggregates.rs:7

//! - Process repeated series/start/end values once and deduplicate differences too.

Comment 8, line 8

desktop/src-tauri/crates/core/src/aggregates.rs:8

//! - Sum verified disjoint coverage; mark verified duplicates without counting them twice.

Comment 9, line 18

desktop/src-tauri/crates/core/src/aggregates.rs:18

/// Native aggregate scope.

Comment 10, line 41

desktop/src-tauri/crates/core/src/aggregates.rs:41

/// Sum verified disjoint coverage; duplicate coverage refers to the matching original aggregate.

Comment 11, line 45

desktop/src-tauri/crates/core/src/aggregates.rs:45

/// Verified disjoint coverage.

Comment 12, line 47

desktop/src-tauri/crates/core/src/aggregates.rs:47

/// Verified duplicate coverage; retain for comparison and exclude from totals.

Comment 13, line 49

desktop/src-tauri/crates/core/src/aggregates.rs:49

/// Unknown overlap; display separately and exclude from automatic sums.

Comment 14, line 72

desktop/src-tauri/crates/core/src/aggregates.rs:72

/// A native source interval aggregate, such as a Hermes two-day total or OTel cumulative interval.

Comment 15, line 77

desktop/src-tauri/crates/core/src/aggregates.rs:77

/// Series/row key: resource, instrument, attributes, process instance and start_time, or native row identity.

Comment 16, line 79

desktop/src-tauri/crates/core/src/aggregates.rs:79

/// Interval start; the first cumulative observation may have no known series start.

Comment 17, line 82

desktop/src-tauri/crates/core/src/aggregates.rs:82

/// True when the source endpoint is inclusive, such as an instantaneous last_seen.

Comment 18, line 86

desktop/src-tauri/crates/core/src/aggregates.rs:86

/// Native aggregate call count, such as interval api_call_count; do not invent model_call records.

Comment 19, line 89

desktop/src-tauri/crates/core/src/aggregates.rs:89

/// scope_key of the matching original aggregate when coverage is duplicate.

Comment 20, line 125

desktop/src-tauri/crates/core/src/aggregates.rs:125

/// Insert or update by (instance, scope, scope_key), comparing revision and content.

Comment 21, line 126

desktop/src-tauri/crates/core/src/aggregates.rs:126

/// Return whether storage changed.

Comment 22, line 146

desktop/src-tauri/crates/core/src/aggregates.rs:146

/// Explicit parser corrections compare the complete prior input, never only token fields.

Comment 23, line 175

desktop/src-tauri/crates/core/src/aggregates.rs:175

// Repeated identical content leaves storage unchanged.

Comment 24, line 179

desktop/src-tauri/crates/core/src/aggregates.rs:179

// An older explicit revision cannot replace a newer one.

Comment 25, line 261

desktop/src-tauri/crates/core/src/aggregates.rs:261

/// Sum verified disjoint token aggregates (Hermes sample 11: 100+20=120, not 220).

Comment 26, line 262

desktop/src-tauri/crates/core/src/aggregates.rs:262

/// Exclude duplicates; exclude and separately count overlap_unknown rows.

Comment 27, line 368

desktop/src-tauri/crates/core/src/aggregates.rs:368

/// Cumulative series state, persisted in ingestion_checkpoints.parse_context.

Comment 28, line 374

desktop/src-tauri/crates/core/src/aggregates.rs:374

/// Process/series start, when known.

Comment 29, line 378

desktop/src-tauri/crates/core/src/aggregates.rs:378

/// Result of observing a cumulative value.

Comment 30, line 381

desktop/src-tauri/crates/core/src/aggregates.rs:381

/// Late or conflicting same-time observations keep the baseline; the caller records diagnostics.

Comment 31, line 383

desktop/src-tauri/crates/core/src/aggregates.rs:383

/// First cumulative observation: preserve the native interval total without assigning it to today.

Comment 32, line 385

desktop/src-tauri/crates/core/src/aggregates.rs:385

/// Interval difference, including zero.

Comment 33, line 387

desktop/src-tauri/crates/core/src/aggregates.rs:387

/// Confirmed reset, such as a new process; its baseline is the new interval total.

Comment 34, line 389

desktop/src-tauri/crates/core/src/aggregates.rs:389

/// Unconfirmed decrease: record a conflict rather than treating the new value as a zero-based total.

Comment 35, line 393

desktop/src-tauri/crates/core/src/aggregates.rs:393

/// Repeated equal values yield Delta zero; callers deduplicate the resulting observations.

Comment 36, line 469

desktop/src-tauri/crates/core/src/aggregates.rs:469

/// Quota snapshot input; keep quotas separate from recorded usage without converting units.

Comment 37, line 475

desktop/src-tauri/crates/core/src/aggregates.rs:475

/// Quota kinds: credits, subscription_window, balance or rate_limit.

Comment 38, line 477

desktop/src-tauri/crates/core/src/aggregates.rs:477

/// Integer smallest unit; unknown is None rather than zero.

Comment 39, line 482

desktop/src-tauri/crates/core/src/aggregates.rs:482

/// True only for verified usage on this device; an account-wide quota does not establish local usage.