Add an injectable attachment store to ThreadManager (#42634)

## What changed

- Add the `codex-attachment-store` crate with storage-neutral attachment metadata, references, errors, and an asynchronous persistence interface.
- Provide an inline implementation that preserves attachment bytes as media-typed base64 data URLs.
- Inject the store into `ThreadManager`, expose it to consumers, and retain inline storage as the default for existing entry points.

## Testing

- Verify inline storage round-trips binary, text, PNG, and JPEG data.
- Verify attachment debug output redacts URLs while retaining file IDs.

GitOrigin-RevId: 7688dcd3c89d7540ed2398f3e7c63881fbfcda97
This commit is contained in:
Krish Chainani authored and copyberry committed 2026-09-03 23:20:54 +00:00
1 parent d979df154c
commit 03467026f2
20 files changed
+249

No files matched your search

+15
View File
@@ -805,6 +805,7 @@ async fn mcp_invalidation_refreshes_threads_that_are_still_starting() {
Arc::new(extensions.build()),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, /*state_db*/ None),
/*agent_graph_store*/ None,
TEST_INSTALLATION_ID.to_string(),
@@ -1303,6 +1304,7 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
Arc::new(extensions.build()),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, /*state_db*/ None),
/*agent_graph_store*/ None,
TEST_INSTALLATION_ID.to_string(),
@@ -1510,6 +1512,7 @@ async fn resume_and_fork_do_not_restore_thread_environments_from_rollout() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, /*state_db*/ None),
/*agent_graph_store*/ None,
TEST_INSTALLATION_ID.to_string(),
@@ -1654,6 +1657,7 @@ async fn explicit_installation_id_skips_codex_home_file() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store,
local_agent_graph_store_from_state_db(state_db.as_ref()),
installation_id.clone(),
@@ -1697,6 +1701,7 @@ async fn resume_active_thread_from_rollout_returns_running_thread() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, /*state_db*/ None),
/*agent_graph_store*/ None,
TEST_INSTALLATION_ID.to_string(),
@@ -1759,6 +1764,7 @@ async fn resume_stopped_thread_from_rollout_spawns_new_thread() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, /*state_db*/ None),
/*agent_graph_store*/ None,
TEST_INSTALLATION_ID.to_string(),
@@ -1828,6 +1834,7 @@ async fn resume_stopped_thread_from_rollout_preserves_thread_source() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store,
local_agent_graph_store_from_state_db(state_db.as_ref()),
TEST_INSTALLATION_ID.to_string(),
@@ -1913,6 +1920,7 @@ async fn subtree_listing_uses_injected_graph_store_without_state_db() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, /*state_db*/ None),
Some(agent_graph_store),
TEST_INSTALLATION_ID.to_string(),
@@ -1960,6 +1968,7 @@ async fn rollout_path_resume_and_fork_read_history_through_thread_store() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store.clone(),
local_agent_graph_store_from_state_db(state_db.as_ref()),
TEST_INSTALLATION_ID.to_string(),
@@ -2070,6 +2079,7 @@ async fn metadata_update_without_result_reads_only_when_the_caller_needs_the_thr
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store.clone(),
/*agent_graph_store*/ None,
TEST_INSTALLATION_ID.to_string(),
@@ -2196,6 +2206,7 @@ async fn new_uses_active_provider_for_model_refresh() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, /*state_db*/ None),
/*agent_graph_store*/ None,
TEST_INSTALLATION_ID.to_string(),
@@ -2243,6 +2254,7 @@ async fn injected_models_manager_controls_refresh_policy() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, /*state_db*/ None),
/*agent_graph_store*/ None,
TEST_INSTALLATION_ID.to_string(),
@@ -2503,6 +2515,7 @@ async fn interrupted_fork_snapshot_does_not_synthesize_turn_id_for_legacy_histor
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, state_db.clone()),
local_agent_graph_store_from_state_db(state_db.as_ref()),
TEST_INSTALLATION_ID.to_string(),
@@ -2616,6 +2629,7 @@ async fn interrupted_fork_snapshot_preserves_explicit_turn_id() {
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, state_db.clone()),
local_agent_graph_store_from_state_db(state_db.as_ref()),
TEST_INSTALLATION_ID.to_string(),
@@ -2719,6 +2733,7 @@ async fn interrupted_fork_snapshot_uses_persisted_mid_turn_history_without_live_
empty_extension_registry(),
Arc::new(crate::test_support::EmptyUserInstructionsProvider),
/*analytics_events_client*/ None,
passthrough_image_store(),
thread_store_from_config(&config, state_db.clone()),
local_agent_graph_store_from_state_db(state_db.as_ref()),
TEST_INSTALLATION_ID.to_string(),