Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
test(codex): cover hidden Goal handoff recovery
  • Loading branch information
yyjeqhc committed Sep 28, 2026
commit 374fb79e7412fdcb441cc7cf32ec5b834d64de55
54 changes: 53 additions & 1 deletion src/tool_runtime/tests/goal_workflow.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::db::{GoalCheckpoint, NewAgentEndpoint, NewGoal, NewGoalStep};
use crate::tool_runtime::{AgentWaitEventSelectorCall, AgentWaitModeCall, ToolResult};
use crate::tool_runtime::{AgentWaitEventSelectorCall, AgentWaitModeCall, ToolCall, ToolResult};

const T0: i64 = 100_000_000;
const THRESHOLD: i64 = crate::db::GOAL_ACTIVITY_ATTENTION_AFTER_MS;
Expand Down Expand Up @@ -1936,6 +1936,58 @@ async fn session_handoff_goal_context_is_read_only_exact_and_preserves_ambiguity
);
assert_eq!(after_session.events_total, before_session.events_total);
assert_eq!(after_session.updated_at, before_session.updated_at);

// Codex recovery uses the hidden adapter-only handoff tool, not the public
// model-facing summary. Prove that the hidden route carries the same exact
// Goal context without turning the read into business-Session activity.
let hidden_before_goal = fixture
.db
.read_goal(&fixture.principal(), &fixture.goal_id)
.unwrap();
let hidden_before_session = fixture
.runtime
.sessions
.summary(&fixture.session_id, Some(200))
.unwrap();
let hidden = fixture
.runtime
.dispatch_with_auth(
ToolCall::SessionHandoffState {
project: fixture.project.clone(),
session_id: fixture.session_id.clone(),
},
Some(&fixture.auth),
)
.await;
assert!(hidden.success, "{:?}", hidden.output);
assert_eq!(hidden.output["project"], fixture.project);
assert_eq!(hidden.output["session_id"], fixture.session_id);
assert_eq!(hidden.output["goal_context"]["status"], "available");
assert_eq!(
hidden.output["goal_context"]["goal"]["goal_id"],
fixture.goal_id
);
assert_eq!(hidden.output["goal_context"]["goal"]["revision"], 3);
assert_eq!(
fixture
.db
.read_goal(&fixture.principal(), &fixture.goal_id)
.unwrap(),
hidden_before_goal
);
let hidden_after_session = fixture
.runtime
.sessions
.summary(&fixture.session_id, Some(200))
.unwrap();
assert_eq!(
hidden_after_session.events_total,
hidden_before_session.events_total
);
assert_eq!(
hidden_after_session.updated_at,
hidden_before_session.updated_at
);
let mut unavailable_runtime = fixture.runtime.clone();
unavailable_runtime.communication_db = None;
let unavailable = unavailable_runtime
Expand Down
8 changes: 7 additions & 1 deletion src/tool_runtime/tests/handoff_brief.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,13 @@ async fn internal_handoff_projection_does_not_append_events_or_enqueue_agent_req
async fn hidden_handoff_state_is_non_recording_exact_recovery_read() {
let root = tempfile::tempdir().unwrap();
init_git_repo(root.path());
let runtime = ToolRuntime::new_for_tests();
// This case specifically proves the available-store/zero-Goal contract.
// A missing Goal store has distinct explicit `unavailable` semantics and
// is covered by the Goal workflow recovery test.
let goal_store = tempfile::tempdir().unwrap();
let goal_db =
Arc::new(crate::db::Database::open(&goal_store.path().join("handoff-goals.db")).unwrap());
let runtime = ToolRuntime::new_for_tests().with_communication_database(goal_db);
let auth = bootstrap_auth_context();
let client_id = "handoff-state-hidden-read";
let project =
Expand Down
Loading