Repository navigation
fix(admin): count each session's own spend from pi-durable's usage ledger - #162
Merged
Merged
Conversation
…dger The Admin portal summed usage over every entry a session's conversation shows, and a thread started from the run that caused it shows the history it forked from, so its parent's spend was counted again. Session totals now read pi-durable's per-conversation usage ledger, which also holds failed attempts and compaction, and the daily chart counts only a session's own answers. The ledger is written by generation only, so sessions imported from 0.5.3 have none. Migration 0013-session-usage records their imported answers in the ledger once per conversation.
geminixiang
force-pushed
the
fix/admin-usage-ledger
branch
from
October 9, 2026 14:37
4fa3aea to
b3c194a
Compare
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.
Problem
The Admin portal summed usage over every entry a session's conversation shows. A thread started from the run that caused it is a fork, and its entries include the history it inherited, so the parent's spend was counted again in every such thread (session totals and the 14-day chart).
Change
/admin/api/session-usage)pi.usage) throughSessionStore.spend/admin/api/conversation-usage)SessionStore.ownResponseUsage)0013-session-usagemikan.sessionOperators must run
mikan migrateafter upgrading; the daemon refuses to start while a step is pending.Eval (
.workspace/usage-eval; state written bymain, then migrated and read by each checkout)mikan migrateruns on upgrade0013-session-usagemikan migrateVerification
mikan migrate(dry run, then real) on a copy of a local test state: the step is pending, then applied; that state has no imported sessions.