Table of Contents

Class BudgetTracker

Namespace
JD.AI.Core.Governance
Assembly
JD.AI.Core.dll

Persists daily and monthly spend data as JSON to ~/.jdai/budget.json and evaluates it against configured BudgetPolicy limits.

public sealed class BudgetTracker : IBudgetTracker, IDisposable
Inheritance
BudgetTracker
Implements
Inherited Members

Constructors

BudgetTracker()

public BudgetTracker()

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetStatusAsync(CancellationToken)

Returns the current spending status.

public Task<BudgetStatus> GetStatusAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<BudgetStatus>

IsWithinBudgetAsync(BudgetPolicy?, CancellationToken)

Returns true when the current spend is within the configured limits. If policy is null, always returns true.

public Task<bool> IsWithinBudgetAsync(BudgetPolicy? policy, CancellationToken ct = default)

Parameters

policy BudgetPolicy
ct CancellationToken

Returns

Task<bool>

RecordSpendAsync(decimal, string, CancellationToken)

Records spend for a provider interaction.

public Task RecordSpendAsync(decimal amountUsd, string providerName, CancellationToken ct = default)

Parameters

amountUsd decimal
providerName string
ct CancellationToken

Returns

Task