Repository navigation
feat(ai): record durable usage before core inference - #343
Merged
Merged
Conversation
Commit anonymous request/session reservations before provider IO or CLI spawn. Block unrecorded sends, preserve results on final ledger failures, and retain native counters with reported, estimated and unavailable costs kept distinct. Gate runtime startup before nREPL, adapters and background loading. Add bounded snapshot-consistent timeframe aggregates while preserving the handler API and existing approximate media budgets.
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.
What changes
Add durable anonymous AI usage capture across core xAI/Gemini media, legacy text and Gemini CLI execution. Normal bot entry points require tracking before they open; every supported inference boundary must commit its pending row before sending/spawning.
Final ledger preparation or persistence failures keep the original returned result and leave uncertainty rather than retrying paid work. Native CLI summaries remain session aggregates, not fabricated HTTP traces or heuristic dollar bills. Existing approximate media budgets remain separate.
Add read-only, snapshot-consistent UTC aggregates with separate reported/estimated USD, unpriced usage, exact bounds, distinct multi-model sessions and complete global totals despite a bounded breakdown. The companion application change supplies the trusted-human command and wraps application transports.
Verification
Code review: skipped (ce-code-review unavailable). Scoped manual source/privacy/reuse/simplicity review only; no independent reviewer claimed.
Coverage limits
No provider-account reconciliation, billing credentials, historical caption/budget backfill, prompts/completions/private tool payloads or user/channel identities. Standalone library use without starting Yetibot/database retains its prior API and is outside runtime coverage. Opaque external tools are observable only through supplied provider/CLI statistics. No production ledger fixtures or paid probes.