Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions codex-rs/core/src/goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ impl Session {
.is_some_and(|goal_id| reported_goal_id.as_deref() == Some(goal_id))
};
let goal = match outcome {
codex_state::ThreadGoalAccountingOutcome::Updated(goal) => {
codex_state::GoalAccountingOutcome::Updated(goal) => {
let clear_active_goal = match goal.status {
codex_state::ThreadGoalStatus::Active => false,
codex_state::ThreadGoalStatus::BudgetLimited => {
Expand Down Expand Up @@ -1072,7 +1072,7 @@ impl Session {
}
goal
}
codex_state::ThreadGoalAccountingOutcome::Unchanged(_) => return Ok(()),
codex_state::GoalAccountingOutcome::Unchanged(_) => return Ok(()),
};
let should_steer_budget_limit =
matches!(budget_limit_steering, BudgetLimitSteering::Allowed)
Expand Down Expand Up @@ -1158,7 +1158,7 @@ impl Session {
)
.await?
{
codex_state::ThreadGoalAccountingOutcome::Updated(goal) => {
codex_state::GoalAccountingOutcome::Updated(goal) => {
if matches!(terminal_metric_emission, TerminalMetricEmission::Emit) {
self.emit_goal_terminal_metrics_if_status_changed(previous_status, &goal);
}
Expand All @@ -1171,7 +1171,7 @@ impl Session {
let goal = protocol_goal_from_state(goal);
Ok(Some(goal))
}
codex_state::ThreadGoalAccountingOutcome::Unchanged(goal) => {
codex_state::GoalAccountingOutcome::Unchanged(goal) => {
{
let mut accounting = self.goal_runtime.accounting.lock().await;
accounting.wall_clock.reset_baseline();
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ pub use model::ThreadMetadata;
pub use model::ThreadMetadataBuilder;
pub use model::ThreadsPage;
pub use runtime::GoalAccountingMode;
pub use runtime::GoalAccountingOutcome;
pub use runtime::GoalStore;
pub use runtime::GoalUpdate;
pub use runtime::RemoteControlEnrollmentRecord;
pub use runtime::RuntimeDbPath;
pub use runtime::ThreadFilterOptions;
pub use runtime::ThreadGoalAccountingOutcome;
pub use runtime::goals_db_filename;
pub use runtime::goals_db_path;
pub use runtime::logs_db_filename;
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/state/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ mod test_support;
mod threads;

pub use goals::GoalAccountingMode;
pub use goals::GoalAccountingOutcome;
pub use goals::GoalStore;
pub use goals::GoalUpdate;
pub use goals::ThreadGoalAccountingMode;
pub use goals::ThreadGoalAccountingOutcome;
pub use remote_control::RemoteControlEnrollmentRecord;
pub use threads::ThreadFilterOptions;

Expand Down
34 changes: 17 additions & 17 deletions codex-rs/state/src/runtime/goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct GoalUpdate {
pub expected_goal_id: Option<String>,
}

pub enum ThreadGoalAccountingOutcome {
pub enum GoalAccountingOutcome {
Unchanged(Option<crate::ThreadGoal>),
Updated(crate::ThreadGoal),
}
Expand Down Expand Up @@ -389,11 +389,11 @@ WHERE thread_id = ?
token_delta: i64,
mode: GoalAccountingMode,
expected_goal_id: Option<&str>,
) -> anyhow::Result<ThreadGoalAccountingOutcome> {
) -> anyhow::Result<GoalAccountingOutcome> {
let time_delta_seconds = time_delta_seconds.max(0);
let token_delta = token_delta.max(0);
if time_delta_seconds == 0 && token_delta == 0 {
return Ok(ThreadGoalAccountingOutcome::Unchanged(
return Ok(GoalAccountingOutcome::Unchanged(
self.get_thread_goal(thread_id).await?,
));
}
Expand Down Expand Up @@ -464,13 +464,13 @@ RETURNING
let row = query.fetch_optional(self.pool.as_ref()).await?;

let Some(row) = row else {
return Ok(ThreadGoalAccountingOutcome::Unchanged(
return Ok(GoalAccountingOutcome::Unchanged(
self.get_thread_goal(thread_id).await?,
));
};

let updated = thread_goal_from_row(&row)?;
Ok(ThreadGoalAccountingOutcome::Updated(updated))
Ok(GoalAccountingOutcome::Updated(updated))
}
}

Expand Down Expand Up @@ -808,7 +808,7 @@ mod tests {
.await
.expect("usage accounting should succeed");

let ThreadGoalAccountingOutcome::Unchanged(Some(goal)) = outcome else {
let GoalAccountingOutcome::Unchanged(Some(goal)) = outcome else {
panic!("stale goal version should not be updated");
};
assert_ne!(replacement.goal_id, original.goal_id);
Expand Down Expand Up @@ -845,7 +845,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Updated(accounted) = outcome else {
let GoalAccountingOutcome::Updated(accounted) = outcome else {
panic!("active goal should account usage");
};

Expand Down Expand Up @@ -1067,7 +1067,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Updated(goal) = outcome else {
let GoalAccountingOutcome::Updated(goal) = outcome else {
panic!("active goal should be updated");
};
assert_eq!(crate::ThreadGoalStatus::Active, goal.status);
Expand All @@ -1085,7 +1085,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Updated(goal) = outcome else {
let GoalAccountingOutcome::Updated(goal) = outcome else {
panic!("budget crossing should update the goal");
};
assert_eq!(crate::ThreadGoalStatus::BudgetLimited, goal.status);
Expand All @@ -1103,7 +1103,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Updated(goal) = outcome else {
let GoalAccountingOutcome::Updated(goal) = outcome else {
panic!("budget-limited goal should still account in-flight active usage");
};
assert_eq!(crate::ThreadGoalStatus::BudgetLimited, goal.status);
Expand Down Expand Up @@ -1138,7 +1138,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Unchanged(Some(goal)) = outcome else {
let GoalAccountingOutcome::Unchanged(Some(goal)) = outcome else {
panic!("budget-limited goal should not be updated");
};
assert_eq!(crate::ThreadGoalStatus::BudgetLimited, goal.status);
Expand Down Expand Up @@ -1186,7 +1186,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Updated(goal) = outcome else {
let GoalAccountingOutcome::Updated(goal) = outcome else {
panic!("stopped goal should account final usage");
};
assert_eq!(crate::ThreadGoalStatus::BudgetLimited, goal.status);
Expand Down Expand Up @@ -1365,7 +1365,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Updated(budget_limited) = outcome else {
let GoalAccountingOutcome::Updated(budget_limited) = outcome else {
panic!("budget crossing should update the goal");
};

Expand Down Expand Up @@ -1418,7 +1418,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Unchanged(Some(goal)) = active_only else {
let GoalAccountingOutcome::Unchanged(Some(goal)) = active_only else {
panic!("completed goal should not be updated by active-only accounting");
};
assert_eq!(crate::ThreadGoalStatus::Complete, goal.status);
Expand All @@ -1436,7 +1436,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Updated(goal) = completing_turn else {
let GoalAccountingOutcome::Updated(goal) = completing_turn else {
panic!("completed goal should be updated for final accounting");
};
assert_eq!(crate::ThreadGoalStatus::Complete, goal.status);
Expand Down Expand Up @@ -1485,7 +1485,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Unchanged(Some(goal)) = active_only else {
let GoalAccountingOutcome::Unchanged(Some(goal)) = active_only else {
panic!("paused goal should not be updated by active-only accounting");
};
assert_eq!(crate::ThreadGoalStatus::Paused, goal.status);
Expand All @@ -1503,7 +1503,7 @@ mod tests {
)
.await
.expect("usage accounting should succeed");
let ThreadGoalAccountingOutcome::Updated(goal) = in_flight_turn else {
let GoalAccountingOutcome::Updated(goal) = in_flight_turn else {
panic!("stopped goal should be updated for in-flight accounting");
};
assert_eq!(crate::ThreadGoalStatus::Paused, goal.status);
Expand Down
Loading