Repository navigation
fix(usage): record GitHub analysis calls in the ledger - #567
Merged
Ayinkx merged 1 commit intoOct 23, 2026
Merged
Conversation
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.
Summary
Records GitHub repository/issue/PR/file analysis completions in the central
usage ledger. These calls previously went through
app/services/analysis.py::_runand never produced aUsageRecord, leaving agap in the "every LLM call records a ledger row" requirement.
Problem
Issue #366 requires every LLM call to be recorded. Chat, project chat, project
analysis, reviews and tools were instrumented, but the GitHub analysis path
(
analysis._run) called the provider directly. GitHub analysis usage wastherefore invisible to the ledger and dashboards.
Solution
analysis._runnow records oneUsageRecordafter a successful completion,with
source="analysis", the authenticated user, provider, and model.have no owner.
complete()returns text only, so token counts are recorded as estimatedzeroes rather than guessed.
tests/test_analysis_usage_ledger.pyproving one row is written withthe expected source, owner, provider and model.
Validation
python -m pytest tests/test_analysis_usage_ledger.py tests/test_stellar_analysis_github.py -q— PASS (22 passed)python -m pytest tests/test_stellar_analysis.py tests/test_stellar_analysis_extra.py tests/test_stellar_aware_analysis.py -q— PASS (23 passed)python -m ruff check app/services/analysis.py tests/test_analysis_usage_ledger.py— PASSpython -m black --check app/services/analysis.py tests/test_analysis_usage_ledger.py— PASSapp/services/invoice_export.pyandtests/test_invoice_export.pyfiles fromfeat(billing): export invoices as CSV and PDF with size bounds (#483) #535.
Risk
Adds one ledger write per successful GitHub analysis. The write is best-effort,
so a ledger failure cannot fail the analysis. Token counts for this path are
estimates (zero) until the provider surface exposes usage on
complete().Issue
Closes #366