Skip to main content

Module token_usage

Module token_usage 

Source
Expand description

Per-file usage-summary cache on the redb token_usage table.

Keyed by canonical session-file path; the value is that fileโ€™s deduped FileUsageSummary. The cache is incremental: the scan reuses a file whose mtime and size still match the cached entry rather than re-parsing a transcript that can reach 100 MB.

Re-exportsยง

use anyhow::Context; ๐Ÿ”’
use forge_agent::env::token_usage::FileUsageSummary; ๐Ÿ”’
use redb::TableDefinition; ๐Ÿ”’
use super::Db; ๐Ÿ”’

Constantsยง

TOKEN_USAGE ๐Ÿ”’

Functionsยง

decode ๐Ÿ”’
Decode a stored blob, tagging a failure with the owning path.
load
The cached summary for path, or None when absent (or the table doesnโ€™t exist yet). A decode failure is surfaced so a corrupt row is diagnosable rather than silently treated as a cache miss.
store
Store summary for path, overwriting any prior entry.