Simplify: rename internal AggregateUsageTotals to UsageAccumulator, add TODO

Eliminates confusing alias (`ApiAggregateUsageTotals`) by giving the
internal accumulator struct a distinct name. Adds a TODO for removing
the OAS 3.1→3.0 patch when progenitor gains 3.1 support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-04-03 11:24:36 -07:00
parent a02148aacd
commit 8d2a3220f7
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View file

@ -81,6 +81,7 @@ fn main() {
let mut spec_value: serde_json::Value =
serde_yaml::from_str(&spec_text).unwrap_or_else(|e| panic!("failed to parse YAML: {e}"));
// TODO: Remove 3.1→3.0 patch when progenitor supports OpenAPI 3.1.
// Progenitor only supports OpenAPI 3.0.x; our spec uses 3.1.0 but doesn't
// rely on any 3.1-only features that affect codegen.
spec_value["openapi"] = serde_json::Value::String("3.0.3".to_string());

View file

@ -52,7 +52,7 @@ use fabro_workflow::operations::{self, CreateRunInput, WorkflowInput};
use fabro_workflow::pipeline::Persisted;
use fabro_workflow::records::Checkpoint;
use fabro_api::types::AggregateUsageTotals as ApiAggregateUsageTotals;
use fabro_api::types::AggregateUsageTotals;
pub use fabro_api::types::{
AggregateUsage, ApiQuestion, ApiQuestionOption, CompletionContentPart, CompletionMessage,
CompletionMessageRole, CompletionResponse, CompletionToolChoiceMode, CompletionUsage,
@ -116,7 +116,7 @@ struct ModelUsageTotals {
/// In-memory aggregate usage counters, reset on server restart.
#[derive(Default)]
struct AggregateUsageTotals {
struct UsageAccumulator {
total_runs: i64,
total_runtime_secs: f64,
by_model: HashMap<String, ModelUsageTotals>,
@ -127,7 +127,7 @@ type RegistryFactoryOverride = dyn Fn(Arc<dyn Interviewer>) -> HandlerRegistry +
/// Shared application state for the server.
pub struct AppState {
runs: Mutex<HashMap<RunId, ManagedRun>>,
aggregate_usage: Mutex<AggregateUsageTotals>,
aggregate_usage: Mutex<UsageAccumulator>,
store: StoreHandle,
pub db: sqlx::SqlitePool,
max_concurrent_runs: usize,
@ -394,7 +394,7 @@ async fn get_aggregate_usage(
})
.collect();
let response = AggregateUsage {
totals: ApiAggregateUsageTotals {
totals: AggregateUsageTotals {
runs: agg.total_runs,
input_tokens: by_model.iter().map(|m| m.usage.input_tokens).sum(),
output_tokens: by_model.iter().map(|m| m.usage.output_tokens).sum(),
@ -465,7 +465,7 @@ fn build_app_state(
) -> Arc<AppState> {
Arc::new(AppState {
runs: Mutex::new(HashMap::new()),
aggregate_usage: Mutex::new(AggregateUsageTotals::default()),
aggregate_usage: Mutex::new(UsageAccumulator::default()),
store,
db,
max_concurrent_runs,