desktop/src-tauri/crates/core/tests/pricing_v29.rs
Comment 1, line 1
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1
//! V29 tests for price snapshots, cost estimation, and summaries.Comment 2, line 2
desktop/src-tauri/crates/core/tests/pricing_v29.rs:2
//!Comment 3, line 3
desktop/src-tauri/crates/core/tests/pricing_v29.rs:3
//! Fixed P1–P6 samples come from the pricing specification. Rates use hundredths of aComment 4, line 4
desktop/src-tauri/crates/core/tests/pricing_v29.rs:4
//! minor currency unit per million tokens (displayed major-unit prices multiplied by 10,000).Comment 5, line 5
desktop/src-tauri/crates/core/tests/pricing_v29.rs:5
//! Expected amounts are calculated manually. Original E2 input totals 1.3M and thereforeComment 6, line 6
desktop/src-tauri/crates/core/tests/pricing_v29.rs:6
//! selects the P3 long-context tier. This file tests the scaled 130K-input E2' under P2Comment 7, line 7
desktop/src-tauri/crates/core/tests/pricing_v29.rs:7
//! and P2/P3 threshold boundaries; do not claim a separate original-1.3M test here.Comment 8, line 19
desktop/src-tauri/crates/core/tests/pricing_v29.rs:19
/// Fixed P1–P6 samples plus A4's batch comparison row, excluded from standard matching.Comment 9, line 65
desktop/src-tauri/crates/core/tests/pricing_v29.rs:65
// Test options: moonshot cache writes use 1h (A6/E3); openai uses 5m (E2', with P2 write prices).Comment 10, line 71
desktop/src-tauri/crates/core/tests/pricing_v29.rs:71
/// Build an event with four token components; present values are Reported, occurring at 2026-09-26 12:00 UTC.Comment 11, line 97
desktop/src-tauri/crates/core/tests/pricing_v29.rs:97
// Match quality to values (None means Unknown), as required by ingest validation.Comment 12, line 296
desktop/src-tauri/crates/core/tests/pricing_v29.rs:296
/// Test import, persistence, backfill, and summaries for E1/E3/E4–E7/E8 and A1–A8.Comment 13, line 305
desktop/src-tauri/crates/core/tests/pricing_v29.rs:305
// A10: repeated import of the same snapshot is idempotent.Comment 14, line 314
desktop/src-tauri/crates/core/tests/pricing_v29.rs:314
// E1 mixed input (P1, CNY): 988+100+968=2056 fen; cache writes remain unpriced.Comment 15, line 324
desktop/src-tauri/crates/core/tests/pricing_v29.rs:324
// E2' has all four components under P2 (130K input <272K): 100+2+13+125=240 US cents.Comment 16, line 334
desktop/src-tauri/crates/core/tests/pricing_v29.rs:334
// E3 1h TTL (P4; test moonshot default 60 minutes): 120+9+360+225=714 US cents.Comment 17, line 344
desktop/src-tauri/crates/core/tests/pricing_v29.rs:344
// E4 upper-tier boundary (272,000 total input selects P3): 544+60=604 US cents.Comment 18, line 354
desktop/src-tauri/crates/core/tests/pricing_v29.rs:354
// E5 below the boundary (271,999 selects P2): 272+40=312 US cents.Comment 19, line 364
desktop/src-tauri/crates/core/tests/pricing_v29.rs:364
// E6 GLM threshold (32,768 selects P6): 26+3=29 fen.Comment 20, line 374
desktop/src-tauri/crates/core/tests/pricing_v29.rs:374
// E7 below the GLM threshold (32,767 selects P5): 20+2=22 fen.Comment 21, line 384
desktop/src-tauri/crates/core/tests/pricing_v29.rs:384
// A1: a model without pay-as-you-go prices remains unpriced.Comment 22, line 394
desktop/src-tauri/crates/core/tests/pricing_v29.rs:394
// A2: partially priced P1 usage with known input and unknown output.Comment 23, line 404
desktop/src-tauri/crates/core/tests/pricing_v29.rs:404
// A3: reasoning is a subset of output, without an additional charge (130K-input P2 tier).Comment 24, line 419
desktop/src-tauri/crates/core/tests/pricing_v29.rs:419
// A5: absent cache-read prices (NULL in P5/P6) leave reads unpriced; price other components normally.Comment 25, line 429
desktop/src-tauri/crates/core/tests/pricing_v29.rs:429
// A6: unknown TTL, no zhipuai default, and no P1 write price leave writes unpriced, as in E1.Comment 26, line 430
desktop/src-tauri/crates/core/tests/pricing_v29.rs:430
// A7: an event before snapshot effectiveness is unpriced at_time but can use current_sim.Comment 27, line 440
desktop/src-tauri/crates/core/tests/pricing_v29.rs:440
// A8: reject pricing when cache reads+writes exceed known total input.Comment 28, line 451
desktop/src-tauri/crates/core/tests/pricing_v29.rs:451
// Contradictory source fields: total input 60,000 < reads+writes 100,000.Comment 29, line 455
desktop/src-tauri/crates/core/tests/pricing_v29.rs:455
// Source-recorded amounts in Crush's shape: 1000 US cents Reported +500 US cents source-estimated.Comment 30, line 495
desktop/src-tauri/crates/core/tests/pricing_v29.rs:495
// Move A7 to 2026-09-20, before snapshot effectiveness, and a separate source instance.Comment 31, line 501
desktop/src-tauri/crates/core/tests/pricing_v29.rs:501
// Commit batches on two days to check backfill by day.Comment 32, line 514
desktop/src-tauri/crates/core/tests/pricing_v29.rs:514
// Backfill 09-20 and 09-26.Comment 33, line 523
desktop/src-tauri/crates/core/tests/pricing_v29.rs:523
// E1 (P1/CNY): 2056 fen; check E6/E7/E5 tiers, partial A2, A5, and src2 below.Comment 34, line 525
desktop/src-tauri/crates/core/tests/pricing_v29.rs:525
// Sum GLM-5.3 uncached input before rounding: 987.6536+800+0.8=1788.4536→1788 fen,Comment 35, line 526
desktop/src-tauri/crates/core/tests/pricing_v29.rs:526
// rather than 988+800+1. GLM-5.1 input is 72 fen; total CNY amount is 2939 fen.Comment 36, line 527
desktop/src-tauri/crates/core/tests/pricing_v29.rs:527
// A5 reads of 100,000 make total input 132,767≥32,768, selecting P6; NULL read prices remain unpriced.Comment 37, line 530
desktop/src-tauri/crates/core/tests/pricing_v29.rs:530
// E1's 200,000 write tokens and A5's 100,000 read tokens are unpriced: known > priced.Comment 38, line 532
desktop/src-tauri/crates/core/tests/pricing_v29.rs:532
// Partial cases: E1 unpriced writes, A2 unknown output, A5 unpriced reads.Comment 39, line 535
desktop/src-tauri/crates/core/tests/pricing_v29.rs:535
// E2'/E4/E5/E3 + A3 + src1 estimation in USD.Comment 40, line 537
desktop/src-tauri/crates/core/tests/pricing_v29.rs:537
// Total USD amount: 240+604+312+714+1100+6=2976 cents.Comment 41, line 540
desktop/src-tauri/crates/core/tests/pricing_v29.rs:540
// E8: retain separate currencies without exchange-rate conversion.Comment 42, line 551
desktop/src-tauri/crates/core/tests/pricing_v29.rs:551
// Check A1/A8 unpriced counts and reasons.Comment 43, line 555
desktop/src-tauri/crates/core/tests/pricing_v29.rs:555
// A1: no_price_row.Comment 44, line 556
desktop/src-tauri/crates/core/tests/pricing_v29.rs:556
// A8: token_anomaly.Comment 45, line 558
desktop/src-tauri/crates/core/tests/pricing_v29.rs:558
// Source amounts are separate from app estimates; Reported and source_estimate share a same-currency display total.Comment 46, line 566
desktop/src-tauri/crates/core/tests/pricing_v29.rs:566
// A7: the 09-26 range excludes its 09-20 event in both at_time and current_sim.Comment 47, line 567
desktop/src-tauri/crates/core/tests/pricing_v29.rs:567
// A4: do not use batch prices for standard service; E3 uses P4, verified by the 714-cent assertion.Comment 48, line 568
desktop/src-tauri/crates/core/tests/pricing_v29.rs:568
// A3: 100 input +1000 output cents, without charging reasoning again.Comment 49, line 570
desktop/src-tauri/crates/core/tests/pricing_v29.rs:570
// Current simulation has events in the 09-26 range, so detail_limited is false;Comment 50, line 571
desktop/src-tauri/crates/core/tests/pricing_v29.rs:571
// current rows cover now and give the same amounts as at_time in this snapshot.Comment 51, line 577
desktop/src-tauri/crates/core/tests/pricing_v29.rs:577
// A7's 09-20 range has an at_time row with reason no_price_row;Comment 52, line 578
desktop/src-tauri/crates/core/tests/pricing_v29.rs:578
// current_sim has an amount using an effective current price row.Comment 53, line 590
desktop/src-tauri/crates/core/tests/pricing_v29.rs:590
// Input 1M×80000/1e8=800 + output 1000×280000/1e8 rounds to 3 fen.Comment 54, line 599
desktop/src-tauri/crates/core/tests/pricing_v29.rs:599
// Estimation references include the sample snapshot and a positive data revision.Comment 55, line 603
desktop/src-tauri/crates/core/tests/pricing_v29.rs:603
// Repeated backfill is idempotent.Comment 56, line 618
desktop/src-tauri/crates/core/tests/pricing_v29.rs:618
/// Without a configured channel or an official rate, leave usage unpriced; do not use unofficial manual rates as references.Comment 57, line 923
desktop/src-tauri/crates/core/tests/pricing_v29.rs:923
/// After collection, select unsealed days with revisions above the pre-refresh revision;Comment 58, line 924
desktop/src-tauri/crates/core/tests/pricing_v29.rs:924
/// later retention revision increases must not hide them. Exclude sealed days.Comment 59, line 945
desktop/src-tauri/crates/core/tests/pricing_v29.rs:945
// A revision above the pre-refresh value selects the day.Comment 60, line 951
desktop/src-tauri/crates/core/tests/pricing_v29.rs:951
// A refresh with no new writes and a lower bound equal to the current revision selects nothing.Comment 61, line 957
desktop/src-tauri/crates/core/tests/pricing_v29.rs:957
// Exclude sealed days even when their revision increases.Comment 62, line 971
desktop/src-tauri/crates/core/tests/pricing_v29.rs:971
/// Import and validate the seed snapshot; pricing unit tests cover schema, interval overlap, and currency checks.Comment 63, line 1010
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1010
/// Provider/model filters match selected values; missing providers do not match any namedComment 64, line 1011
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1011
/// provider. The "unknown" filter selects missing providers, as query::Filters does.Comment 65, line 1020
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1020
// Three events: priced openai, missing provider, and priced zhipuai.Comment 66, line 1072
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1072
// Filter openai only, excluding missing-provider events. Total input 1M≥272K selects P3:Comment 67, line 1073
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1073
// input 1M×200000/1e8=2000 + output 1M×750000/1e8=7500 gives 9500 US cents.Comment 68, line 1087
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1087
// The "unknown" filter selects only missing-provider events, unpriced with channel_unknown.Comment 69, line 1106
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1106
// Model filtering selects glm-5.3 only: P1 input 800 + output 2800=3600 fen, excluding GPT events.Comment 70, line 1120
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1120
/// Test official-provider fallback when the event provider has no exact price row:Comment 71, line 1121
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1121
/// use the official pay-as-you-go rate and retain fallback_event_count in daily costs and summaries.Comment 72, line 1122
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1122
/// Unconfigured channels may use an explicitly official same-model reference; actual channel remains unknown.Comment 73, line 1126
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1126
// Synthetic community snapshot: official vendorA m-one; official_vendor defaults true, with $10/$50 USD rates.Comment 74, line 1142
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1142
// relay-x lacks an exact row; vendorA's official reference gives 1M×$10 +1M×$50=$60, or 6000 US cents.Comment 75, line 1152
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1152
// An unconfigured channel may also use this model's explicitly official reference price.Comment 76, line 1191
desktop/src-tauri/crates/core/tests/pricing_v29.rs:1191
// Current simulation also uses and counts official-provider fallback.