mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
committed by
GitHub
Unverified
parent
66d5edf825
commit
9483b09ea4
@@ -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 => {
|
||||
@@ -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)
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
@@ -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?,
|
||||
));
|
||||
}
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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");
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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");
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user