Skip to content

feat(ai): record durable usage before core inference - #343

Merged
devth merged 1 commit into
masterfrom
feat/ai-usage-ledger
Nov 6, 2026
Merged

devth merged 1 commit into
masterfrom
feat/ai-usage-ledger

Conversation

@devth

@devth devth commented Nov 6, 2026

Copy link
Copy Markdown
Member

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

  • 240 focused checks green on Java21 with isolated PostgreSQL; no live model calls.
  • Pending-before-send/spawn, blocked missing reservations, final-write/normalization answer preservation, anonymous parent/child links and idempotence.
  • Concurrent capture, nanosecond boundaries, a 205-model breakdown and finalization between snapshot queries.
  • Known-origin costs, native counters, unknown CLI counts/costs, credential labels and unknown-model pricing.
  • Existing core xAI/Gemini/agent/handler/interpreter checks included.

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.

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.
@devth
devth merged commit b6234f6 into master Nov 6, 2026
1 check passed
@devth
devth deleted the feat/ai-usage-ledger branch November 6, 2026 16:12
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