pub struct WriteBudgetLedger { /* private fields */ }Expand description
Daily write-budget ledger for one store.
Thread-safe through the caller (McpServer holds it in a Mutex);
persistence is an atomic tmp+rename of a small JSON file.
Implementations§
Source§impl WriteBudgetLedger
impl WriteBudgetLedger
Sourcepub fn paths(store_root: &Path) -> (PathBuf, PathBuf, PathBuf)
pub fn paths(store_root: &Path) -> (PathBuf, PathBuf, PathBuf)
Ledger path convention: <store-root>/write_budget.json (read by
wm doctor), with the LMDB env and Tantivy index as siblings of
the store root’s lmdb/ directory.
Sourcepub fn observe(&mut self, now: DateTime<Utc>) -> WriteBudgetDelta
pub fn observe(&mut self, now: DateTime<Utc>) -> WriteBudgetDelta
Observe current sizes, attribute positive growth to today (UTC),
prune history beyond retention, and persist. Cheap when called
more often than the Tantivy walk interval — only a stat runs.
Sourcepub fn fresh_report(&mut self) -> WriteBudgetReport
pub fn fresh_report(&mut self) -> WriteBudgetReport
Refresh the size sample WITHOUT persisting — the read-only surface
for wm doctor and /status (a status probe must not write).
Sourcepub fn report(&self) -> WriteBudgetReport
pub fn report(&self) -> WriteBudgetReport
Operational summary for wm doctor and /status (as of now).
Sourcepub fn report_as_of(&self, now: DateTime<Utc>) -> WriteBudgetReport
pub fn report_as_of(&self, now: DateTime<Utc>) -> WriteBudgetReport
Operational summary relative to an explicit instant (tests, replay).
Sourcepub fn report_json(&self) -> Value
pub fn report_json(&self) -> Value
JSON rendering for /status.
Sourcepub fn ledger_path(&self) -> &Path
pub fn ledger_path(&self) -> &Path
Current ledger size on disk (diagnostics).