desktop/src-tauri/crates/core/src/storage/pricing.rs
Comment 1, line 1
desktop/src-tauri/crates/core/src/storage/pricing.rs:1
//! F2 price snapshot storage, daily cost rebuilding, and cost summary queries.Comment 2, line 2
desktop/src-tauri/crates/core/src/storage/pricing.rs:2
//!Comment 3, line 3
desktop/src-tauri/crates/core/src/storage/pricing.rs:3
//! Follow the daily_usage archive rules:Comment 4, line 4
desktop/src-tauri/crates/core/src/storage/pricing.rs:4
//! - Rebuild affected, unsealed daily_cost_usage rows after event batches commit.Comment 5, line 5
desktop/src-tauri/crates/core/src/storage/pricing.rs:5
//! - Mark daily costs sealed=1 when detail retention expires; keep historical amounts.Comment 6, line 6
desktop/src-tauri/crates/core/src/storage/pricing.rs:6
//! - Snapshot imports do not recalculate estimates. Event revisions or an explicitComment 7, line 7
desktop/src-tauri/crates/core/src/storage/pricing.rs:7
//! recompute_unsealed_cost_days request rebuild eligible rows and their references.Comment 8, line 20
desktop/src-tauri/crates/core/src/storage/pricing.rs:20
/// Cost kind for this application's estimate using prices at occurrence time.Comment 9, line 22
desktop/src-tauri/crates/core/src/storage/pricing.rs:22
/// Cost kind for amounts reported by the source (EventInput.cost, Reported).Comment 10, line 24
desktop/src-tauri/crates/core/src/storage/pricing.rs:24
/// Cost kind for the source's own estimates (EventInput.cost, Estimated).Comment 11, line 27
desktop/src-tauri/crates/core/src/storage/pricing.rs:27
/// Snapshot import result; identical content under the same ID is skipped (A10).Comment 12, line 35
desktop/src-tauri/crates/core/src/storage/pricing.rs:35
/// Snapshot summary for the UI: source, age, and row count.Comment 13, line 49
desktop/src-tauri/crates/core/src/storage/pricing.rs:49
/// Result of rebuilding daily costs.Comment 14, line 75
desktop/src-tauri/crates/core/src/storage/pricing.rs:75
/// Import a snapshot; identical IDs/content are skipped, differing content requires a new ID.Comment 15, line 87
desktop/src-tauri/crates/core/src/storage/pricing.rs:87
/// Import repository seed snapshots at startup without recalculating existing estimates.Comment 16, line 105
desktop/src-tauri/crates/core/src/storage/pricing.rs:105
// Preserve the original seed snapshot's public return values.Comment 17, line 109
desktop/src-tauri/crates/core/src/storage/pricing.rs:109
/// Load all price rows into the estimation price book.Comment 18, line 114
desktop/src-tauri/crates/core/src/storage/pricing.rs:114
/// List price snapshots with row counts.Comment 19, line 143
desktop/src-tauri/crates/core/src/storage/pricing.rs:143
/// Select unsealed days in this timezone with revisions greater than revision_before.Comment 20, line 144
desktop/src-tauri/crates/core/src/storage/pricing.rs:144
/// These days were rewritten by this collection batch; sealed days remain unchanged.Comment 21, line 145
desktop/src-tauri/crates/core/src/storage/pricing.rs:145
/// Capture revision_before at refresh start: retention can increment the revision afterComment 22, line 146
desktop/src-tauri/crates/core/src/storage/pricing.rs:146
/// scanning, so comparing against only the final current revision would omit changed days.Comment 23, line 165
desktop/src-tauri/crates/core/src/storage/pricing.rs:165
/// Correct retained, unsealed estimates once after a price matching rule changes.Comment 24, line 166
desktop/src-tauri/crates/core/src/storage/pricing.rs:166
/// Catalog refreshes do not change this marker or historical amounts.Comment 25, line 189
desktop/src-tauri/crates/core/src/storage/pricing.rs:189
/// Rebuild an unsealed day after an event batch or an explicit recalculation.Comment 26, line 190
desktop/src-tauri/crates/core/src/storage/pricing.rs:190
/// Keep existing costs when no detail events remain; they may represent expired details.Comment 27, line 208
desktop/src-tauri/crates/core/src/storage/pricing.rs:208
/// Explicitly rebuild all unsealed days in this timezone that still contain detail events.Comment 28, line 240
desktop/src-tauri/crates/core/src/storage/pricing.rs:240
/// Historical estimates and source amounts come from daily costs. Current reference pricesComment 29, line 241
desktop/src-tauri/crates/core/src/storage/pricing.rs:241
/// apply to the same usage view, using mutually exclusive retained details or archives.Comment 30, line 246
desktop/src-tauri/crates/core/src/storage/pricing.rs:246
/// Current references can select local hours; historical daily costs remain unchanged.Comment 31, line 299
desktop/src-tauri/crates/core/src/storage/pricing.rs:299
// 1) Daily historical estimates and source amounts.Comment 32, line 425
desktop/src-tauri/crates/core/src/storage/pricing.rs:425
// Empty-currency rows carry only unpriced event counts.Comment 33, line 461
desktop/src-tauri/crates/core/src/storage/pricing.rs:461
// Aggregate unpriced reasons from empty-currency rows.Comment 34, line 483
desktop/src-tauri/crates/core/src/storage/pricing.rs:483
// Use the maximum cost-row revision in the selected range.Comment 35, line 495
desktop/src-tauri/crates/core/src/storage/pricing.rs:495
// 2) Apply current reference prices to the same detail/archive view.Comment 36, line 586
desktop/src-tauri/crates/core/src/storage/pricing.rs:586
/// Apply current prices to either details or the sealed summaries selected by usage queries.Comment 37, line 619
desktop/src-tauri/crates/core/src/storage/pricing.rs:619
// Retained details can coexist with an imported or sealed aggregate.Comment 38, line 620
desktop/src-tauri/crates/core/src/storage/pricing.rs:620
// Match the complete source partition and count only one representation.Comment 39, line 794
desktop/src-tauri/crates/core/src/storage/pricing.rs:794
// Sum exact component numerators within each displayed day/model/currency or indivisibleComment 40, line 795
desktop/src-tauri/crates/core/src/storage/pricing.rs:795
// archive period before rounding; roll up those amounts to keep rows and totals consistent.Comment 41, line 902
desktop/src-tauri/crates/core/src/storage/pricing.rs:902
/// Import within a transaction: skip identical IDs/content and reject changed content.Comment 42, line 1000
desktop/src-tauri/crates/core/src/storage/pricing.rs:1000
/// Older stored hashes cover price fields only. Reimports must also compare source metadataComment 43, line 1001
desktop/src-tauri/crates/core/src/storage/pricing.rs:1001
/// and row notes; retain the old hash algorithm while detecting changes under the same ID.Comment 44, line 1056
desktop/src-tauri/crates/core/src/storage/pricing.rs:1056
/// Build case-insensitive SQL filters. Selecting unknown also includes empty and NULLComment 45, line 1057
desktop/src-tauri/crates/core/src/storage/pricing.rs:1057
/// values, matching query::Filters; other selections exclude those values.Comment 46, line 1058
desktop/src-tauri/crates/core/src/storage/pricing.rs:1058
/// Callers supply fixed column names; strip single quotes from selected values.Comment 47, line 1134
desktop/src-tauri/crates/core/src/storage/pricing.rs:1134
/// Filtered, time-bounded model_call or usage_observation events with verified ownership.Comment 48, line 1135
desktop/src-tauri/crates/core/src/storage/pricing.rs:1135
/// Map token fields with quality other than reported/derived to None.Comment 49, line 1144
desktop/src-tauri/crates/core/src/storage/pricing.rs:1144
/// Source amounts from cost_* columns; keep Reported and Estimated rows separate.Comment 50, line 1277
desktop/src-tauri/crates/core/src/storage/pricing.rs:1277
/// Rebuild a day in one transaction: replace unsealed costs with estimates and source amounts.Comment 51, line 1308
desktop/src-tauri/crates/core/src/storage/pricing.rs:1308
// Group by instance, agent, provider, model, currency, and cost kind.Comment 52, line 1424
desktop/src-tauri/crates/core/src/storage/pricing.rs:1424
// 1) Estimate using prices at occurrence time.Comment 53, line 1484
desktop/src-tauri/crates/core/src/storage/pricing.rs:1484
// 2) Retain reported amounts and source estimates as separate kinds.Comment 54, line 1577
desktop/src-tauri/crates/core/src/storage/pricing.rs:1577
/// Cost filters use query::Filters rules: AND across fields, OR within a field;Comment 55, line 1578
desktop/src-tauri/crates/core/src/storage/pricing.rs:1578
/// unknown matches empty values, and instances Some([]) selects no available source.Comment 56, line 1587
desktop/src-tauri/crates/core/src/storage/pricing.rs:1587
/// Cost summary request.Comment 57, line 1591
desktop/src-tauri/crates/core/src/storage/pricing.rs:1591
/// Inclusive local date in YYYY-MM-DD format.Comment 58, line 1599
desktop/src-tauri/crates/core/src/storage/pricing.rs:1599
/// Amounts by currency; currencies are never merged (E8).Comment 59, line 1603
desktop/src-tauri/crates/core/src/storage/pricing.rs:1603
/// Upper bound for the same priced components when archived request tiers are unknown.Comment 60, line 1622
desktop/src-tauri/crates/core/src/storage/pricing.rs:1622
/// Events priced with an official pay-as-you-go reference because no exact match exists.Comment 61, line 1725
desktop/src-tauri/crates/core/src/storage/pricing.rs:1725
/// One estimation mode: currency rows and unpriced reasons.Comment 62, line 1729
desktop/src-tauri/crates/core/src/storage/pricing.rs:1729
/// Counts of events by unpriced reason.Comment 63, line 1731
desktop/src-tauri/crates/core/src/storage/pricing.rs:1731
/// Reference evaluation time and detail coverage flag; unused by at_time.Comment 64, line 1736
desktop/src-tauri/crates/core/src/storage/pricing.rs:1736
/// Cost response with data_revision and the referenced price_basis snapshot set.Comment 65, line 1739
desktop/src-tauri/crates/core/src/storage/pricing.rs:1739
/// Historical estimates stored in daily cost rows.Comment 66, line 1741
desktop/src-tauri/crates/core/src/storage/pricing.rs:1741
/// Source reports and source estimates, kept separate by kind and currency.Comment 67, line 1743
desktop/src-tauri/crates/core/src/storage/pricing.rs:1743
/// Current reference estimates from mutually exclusive known detail or archive usage.Comment 68, line 1745
desktop/src-tauri/crates/core/src/storage/pricing.rs:1745
/// Price snapshots referenced by at_time.Comment 69, line 1777
desktop/src-tauri/crates/core/src/storage/pricing.rs:1777
/// Seal daily costs at detail retention expiry, preserving historical amounts.Comment 70, line 1790
desktop/src-tauri/crates/core/src/storage/pricing.rs:1790
/// Delete daily costs with daily_usage using the same daily retention cutoff.