Skip to content

fix(reports): allow local report commands to run without live pricing#375

Open
IvGolovach wants to merge 2 commits intojunhoyeo:mainfrom
IvGolovach:fix/offline-report-pricing
Open

fix(reports): allow local report commands to run without live pricing#375
IvGolovach wants to merge 2 commits intojunhoyeo:mainfrom
IvGolovach:fix/offline-report-pricing

Conversation

@IvGolovach
Copy link
Copy Markdown
Contributor

@IvGolovach IvGolovach commented Mar 30, 2026

Summary

  • keep local report commands usable when live pricing fetches fail by falling back to cached pricing or token-only output
  • add regression coverage for offline report paths and make affected CLI tests hermetic

Why

Local report commands currently abort when LiteLLM or OpenRouter pricing cannot be fetched, even though the underlying token and message data comes from local session files. That makes Tokscale unnecessarily fragile offline, behind strict firewalls, or during temporary network outages. This change keeps local reporting available without requiring live pricing.

Diff scope

  • reuse the existing tolerant pricing loader for local model and monthly reports
  • add a local-report graph path for CLI graph so it can degrade gracefully without live pricing
  • preserve the existing stricter graph-based paths used by submit and wrapped
  • add CLI regression tests for offline no-cache and stale-cache report behavior
  • make the affected CLI tests hermetic so they no longer depend on the real machine or network

Test proof

  • cargo test -p tokscale-core
    • 442 passed, 0 failed, 1 ignored
  • cargo test -p tokscale-cli
    • unit tests: 294 passed, 0 failed, 1 ignored
    • integration tests: 70 passed, 0 failed
  • cargo clippy -p tokscale-core --all-features -- -D warnings
    • passed
  • cargo clippy -p tokscale-cli --all-features -- -D warnings
    • passed
  • cargo fmt --all --check
    • passed
  • git diff --check
    • passed

Verification-pack proof

Not applicable - CLI/core local reporting change only.

Migration notes

Not applicable - no schema or data migration.

CI context confirmation

CI context names unchanged.

Rollback plan

  • if merged with a merge commit: git revert <merge_commit_sha>
  • if merged as a squash commit: git revert <squash_commit_sha>
  • no DB downgrade required

Known residual risks

  • this change does not introduce an explicit --offline or --no-pricing flag; it makes local report commands degrade gracefully when live pricing is unavailable
  • offline runs may still print pricing fetch warnings to stderr before falling back to cached pricing or token-only output
  • submit and wrapped intentionally keep their existing behavior in this PR scope

Related

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 30, 2026

@IvGolovach is attempting to deploy a commit to the Inevitable Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

…icing

# Conflicts:
#	crates/tokscale-cli/src/main.rs
#	crates/tokscale-cli/tests/cli_tests.rs
#	crates/tokscale-core/src/lib.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant