WIP fase 2b-3: rimozione sottosistemi solo-ChatGPT (plugin remoti, image gen, daybreak, cyber, attestation, cloud config, app/connettori) - test in corso
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1170,7 +1170,6 @@ fn stored_thread_from_state(
|
||||
section_position: state.section_positions.get(&thread_id).copied(),
|
||||
section_entered_at: state.section_entered_at.get(&thread_id).copied(),
|
||||
project_id: None,
|
||||
daybreak_enabled: metadata.and_then(|metadata| metadata.daybreak_enabled),
|
||||
cwd: metadata
|
||||
.and_then(|metadata| metadata.cwd.clone())
|
||||
.unwrap_or_default(),
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
//! Covers the saved Daybreak preference independently of transcript history.
|
||||
|
||||
use codex_protocol::ThreadId;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::TempDir;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::LocalThreadStore;
|
||||
use super::test_support::test_config;
|
||||
use super::test_support::write_session_file;
|
||||
use crate::ReadThreadParams;
|
||||
use crate::ThreadMetadataPatch;
|
||||
use crate::ThreadStore;
|
||||
use crate::ThreadStoreError;
|
||||
use crate::UpdateThreadMetadataParams;
|
||||
|
||||
#[tokio::test]
|
||||
async fn daybreak_preference_survives_reconciliation_and_cold_reads()
|
||||
-> Result<(), Box<dyn std::error::Error>> {
|
||||
let home = TempDir::new()?;
|
||||
let config = test_config(home.path());
|
||||
let uuid = Uuid::new_v4();
|
||||
let thread_id = ThreadId::from_string(&uuid.to_string())?;
|
||||
let rollout_path = write_session_file(home.path(), "2025-01-03T14-20-00", uuid)?;
|
||||
let original_rollout = std::fs::read(&rollout_path)?;
|
||||
let runtime = codex_state::StateRuntime::init(
|
||||
config.sqlite.clone(),
|
||||
config.default_model_provider_id.clone(),
|
||||
)
|
||||
.await?;
|
||||
let store = LocalThreadStore::new(config.clone(), Some(runtime.clone()));
|
||||
for daybreak_enabled in [true, false] {
|
||||
let updated = store
|
||||
.update_thread_metadata(UpdateThreadMetadataParams {
|
||||
thread_id,
|
||||
patch: ThreadMetadataPatch {
|
||||
daybreak_enabled: Some(daybreak_enabled),
|
||||
..Default::default()
|
||||
},
|
||||
include_archived: false,
|
||||
})
|
||||
.await?
|
||||
.expect("updated thread");
|
||||
assert_eq!(updated.daybreak_enabled, Some(daybreak_enabled));
|
||||
}
|
||||
let mut stale_metadata = runtime
|
||||
.get_thread(thread_id)
|
||||
.await?
|
||||
.expect("saved metadata");
|
||||
stale_metadata.daybreak_enabled = Some(true);
|
||||
runtime.upsert_thread(&stale_metadata).await?;
|
||||
codex_rollout::state_db::reconcile_rollout(
|
||||
Some(runtime.as_ref()),
|
||||
&rollout_path,
|
||||
&config.default_model_provider_id,
|
||||
/*builder*/ None,
|
||||
&[],
|
||||
/*archived_only*/ None,
|
||||
/*new_thread_memory_mode*/ None,
|
||||
)
|
||||
.await;
|
||||
drop(store);
|
||||
drop(runtime);
|
||||
|
||||
let runtime = codex_state::StateRuntime::init(
|
||||
config.sqlite.clone(),
|
||||
config.default_model_provider_id.clone(),
|
||||
)
|
||||
.await?;
|
||||
let store = LocalThreadStore::new(config, Some(runtime));
|
||||
for include_history in [false, true] {
|
||||
let thread = store
|
||||
.read_thread(ReadThreadParams {
|
||||
thread_id,
|
||||
include_archived: false,
|
||||
include_history,
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(thread.daybreak_enabled, Some(false));
|
||||
}
|
||||
assert_eq!(std::fs::read(rollout_path)?, original_rollout);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn daybreak_preference_requires_sqlite() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let home = TempDir::new()?;
|
||||
let uuid = Uuid::new_v4();
|
||||
let thread_id = ThreadId::from_string(&uuid.to_string())?;
|
||||
write_session_file(home.path(), "2025-01-03T14-20-00", uuid)?;
|
||||
let store = LocalThreadStore::new(test_config(home.path()), /*state_db*/ None);
|
||||
|
||||
let result = store
|
||||
.update_thread_metadata(UpdateThreadMetadataParams {
|
||||
thread_id,
|
||||
patch: ThreadMetadataPatch {
|
||||
daybreak_enabled: Some(false),
|
||||
..Default::default()
|
||||
},
|
||||
include_archived: false,
|
||||
})
|
||||
.await;
|
||||
assert!(matches!(result, Err(ThreadStoreError::Internal { .. })));
|
||||
Ok(())
|
||||
}
|
||||
@@ -164,7 +164,6 @@ pub(super) fn stored_thread_from_rollout_item(
|
||||
section_position: None,
|
||||
section_entered_at: None,
|
||||
project_id: item.project_id,
|
||||
daybreak_enabled: item.daybreak_enabled,
|
||||
cwd: item.cwd.unwrap_or_default(),
|
||||
cli_version: item.cli_version.unwrap_or_default(),
|
||||
originator: item.originator,
|
||||
|
||||
@@ -30,9 +30,6 @@ mod update_thread_metadata;
|
||||
#[path = "compression_writer_tests.rs"]
|
||||
mod compression_writer_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "daybreak_metadata_tests.rs"]
|
||||
mod daybreak_metadata_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "pending_thread_metadata_tests.rs"]
|
||||
mod pending_thread_metadata_tests;
|
||||
#[cfg(test)]
|
||||
@@ -1166,7 +1163,6 @@ mod tests {
|
||||
collaboration_mode: None,
|
||||
multi_agent_version: None,
|
||||
realtime_active: None,
|
||||
cyber_access_program: None,
|
||||
effort: None,
|
||||
summary: Some(ReasoningSummary::Auto),
|
||||
})
|
||||
|
||||
@@ -753,7 +753,6 @@ fn turn_context(root: &Path, turn_id: &str) -> RolloutItem {
|
||||
collaboration_mode: None,
|
||||
multi_agent_version: None,
|
||||
realtime_active: None,
|
||||
cyber_access_program: None,
|
||||
effort: None,
|
||||
summary: Some(ReasoningSummary::Auto),
|
||||
})
|
||||
|
||||
@@ -394,7 +394,7 @@ async fn deferred_reads_preserve_creation_metadata_and_updates() {
|
||||
let updated = live_thread
|
||||
.update_metadata(
|
||||
ThreadMetadataPatch {
|
||||
daybreak_enabled: Some(true),
|
||||
project_id: Some(None),
|
||||
..Default::default()
|
||||
},
|
||||
/*include_archived*/ false,
|
||||
@@ -417,14 +417,14 @@ async fn deferred_reads_preserve_creation_metadata_and_updates() {
|
||||
updated.parent_thread_id,
|
||||
updated.originator.clone(),
|
||||
updated.history_mode,
|
||||
updated.daybreak_enabled,
|
||||
updated.project_id.clone(),
|
||||
),
|
||||
(
|
||||
params.forked_from_id,
|
||||
params.parent_thread_id,
|
||||
Some(params.originator),
|
||||
history_mode,
|
||||
Some(true),
|
||||
None,
|
||||
)
|
||||
);
|
||||
assert!(!rollout_path.exists());
|
||||
|
||||
@@ -56,9 +56,6 @@ pub(super) async fn read_thread(
|
||||
let persisted_model_settings = sqlite_metadata
|
||||
.as_ref()
|
||||
.map(|metadata| (metadata.model.clone(), metadata.reasoning_effort.clone()));
|
||||
let daybreak_enabled = sqlite_metadata
|
||||
.as_ref()
|
||||
.and_then(|metadata| metadata.daybreak_enabled);
|
||||
if let Some(metadata) = sqlite_metadata
|
||||
&& (params.include_archived
|
||||
|| (metadata.archived_at.is_none()
|
||||
@@ -93,7 +90,6 @@ pub(super) async fn read_thread(
|
||||
rollout_thread.name = thread.name;
|
||||
}
|
||||
rollout_thread.project_id = thread.project_id;
|
||||
rollout_thread.daybreak_enabled = thread.daybreak_enabled;
|
||||
rollout_thread.model = thread.model;
|
||||
rollout_thread.reasoning_effort = thread.reasoning_effort;
|
||||
rollout_thread.git_info = thread.git_info;
|
||||
@@ -121,7 +117,6 @@ pub(super) async fn read_thread(
|
||||
})?;
|
||||
|
||||
let mut thread = read_thread_from_rollout_path(store, path).await?;
|
||||
thread.daybreak_enabled = daybreak_enabled;
|
||||
if let Some((model, reasoning_effort)) = persisted_model_settings {
|
||||
thread.model = model;
|
||||
thread.reasoning_effort = reasoning_effort;
|
||||
@@ -176,7 +171,6 @@ pub(super) async fn read_thread_by_rollout_path(
|
||||
thread.section_position = metadata.section_position;
|
||||
thread.section_entered_at = metadata.section_entered_at;
|
||||
thread.project_id = metadata.project_id;
|
||||
thread.daybreak_enabled = metadata.daybreak_enabled;
|
||||
thread.model = metadata.model;
|
||||
thread.reasoning_effort = metadata.reasoning_effort;
|
||||
if !metadata.cwd.as_os_str().is_empty()
|
||||
@@ -474,7 +468,6 @@ pub(super) fn stored_thread_from_state_metadata(
|
||||
section_position: metadata.section_position,
|
||||
section_entered_at: metadata.section_entered_at,
|
||||
project_id: metadata.project_id,
|
||||
daybreak_enabled: metadata.daybreak_enabled,
|
||||
cwd: metadata.cwd,
|
||||
cli_version: metadata.cli_version,
|
||||
originator: metadata.originator,
|
||||
@@ -579,7 +572,6 @@ fn stored_thread_from_meta_line(
|
||||
section_position: None,
|
||||
section_entered_at: None,
|
||||
project_id: None,
|
||||
daybreak_enabled: None,
|
||||
cwd: meta_line.meta.cwd,
|
||||
cli_version: meta_line.meta.cli_version,
|
||||
originator: (!meta_line.meta.originator.is_empty()).then_some(meta_line.meta.originator),
|
||||
|
||||
@@ -2232,7 +2232,6 @@ async fn migration_compacts_subagent_prefix_and_does_not_project_it() {
|
||||
collaboration_mode: None,
|
||||
multi_agent_version: None,
|
||||
realtime_active: None,
|
||||
cyber_access_program: None,
|
||||
effort: None,
|
||||
summary: Some(ReasoningSummary::Auto),
|
||||
}),
|
||||
|
||||
@@ -537,9 +537,6 @@ async fn apply_metadata_update(
|
||||
if let Some(project_id) = project_id.as_ref() {
|
||||
metadata.project_id = project_id.clone();
|
||||
}
|
||||
if let Some(daybreak_enabled) = patch.daybreak_enabled {
|
||||
metadata.daybreak_enabled = Some(daybreak_enabled);
|
||||
}
|
||||
let memory_mode = patch.memory_mode.map(memory_mode_as_str);
|
||||
let recency_at = existing.as_ref().and(advance_recency_at);
|
||||
let upsert_result = state_db
|
||||
@@ -613,22 +610,6 @@ async fn apply_metadata_update(
|
||||
});
|
||||
}
|
||||
}
|
||||
if let Some(daybreak_enabled) = patch.daybreak_enabled
|
||||
&& !state_db
|
||||
.set_thread_daybreak_enabled(thread_id, daybreak_enabled)
|
||||
.await
|
||||
.map_err(|err| ThreadStoreError::Internal {
|
||||
message: format!(
|
||||
"failed to update Daybreak preference for {thread_id}: {err}"
|
||||
),
|
||||
})?
|
||||
{
|
||||
return Err(ThreadStoreError::Internal {
|
||||
message: format!(
|
||||
"thread metadata unavailable before Daybreak update: {thread_id}"
|
||||
),
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
.await
|
||||
@@ -761,11 +742,9 @@ fn sqlite_write_failure_should_block(patch: &ThreadMetadataPatch) -> bool {
|
||||
// transcript-derived metadata, thread names, and memory-mode indexing were log-only. Keep that
|
||||
// failure isolation so a corrupted optional state DB does not make JSONL transcript durability
|
||||
// look broken. Explicit git-only updates still require SQLite because partial git patches need
|
||||
// the existing SQLite value to preserve unspecified fields. Project and Daybreak updates
|
||||
// require SQLite because those preferences only exist in the state database.
|
||||
patch.project_id.is_some()
|
||||
|| patch.daybreak_enabled.is_some()
|
||||
|| (patch.git_info.is_some() && !has_observed_metadata_facts(patch))
|
||||
// the existing SQLite value to preserve unspecified fields. Project updates
|
||||
// require SQLite because that preference only exists in the state database.
|
||||
patch.project_id.is_some() || (patch.git_info.is_some() && !has_observed_metadata_facts(patch))
|
||||
}
|
||||
|
||||
fn sqlite_write_error_is_best_effort(err: &ThreadStoreError) -> bool {
|
||||
|
||||
@@ -687,9 +687,6 @@ pub struct StoredThread {
|
||||
/// Canonical project assignment owned by app-server, if any.
|
||||
#[serde(default)]
|
||||
pub project_id: Option<String>,
|
||||
/// User-selected Daybreak preference, absent until explicitly set.
|
||||
#[serde(default)]
|
||||
pub daybreak_enabled: Option<bool>,
|
||||
/// Working directory captured for the thread.
|
||||
pub cwd: PathBuf,
|
||||
/// CLI version captured for the thread.
|
||||
@@ -863,8 +860,6 @@ pub struct ThreadMetadataPatch {
|
||||
with = "optional_option"
|
||||
)]
|
||||
pub project_id: ClearableField<String>,
|
||||
/// User-selected Daybreak preference; omission leaves it unchanged.
|
||||
pub daybreak_enabled: Option<bool>,
|
||||
}
|
||||
|
||||
impl ThreadMetadataPatch {
|
||||
@@ -957,9 +952,6 @@ impl ThreadMetadataPatch {
|
||||
if next.project_id.is_some() {
|
||||
self.project_id = next.project_id;
|
||||
}
|
||||
if next.daybreak_enabled.is_some() {
|
||||
self.daybreak_enabled = next.daybreak_enabled;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
@@ -994,7 +986,6 @@ impl ThreadMetadataPatch {
|
||||
&& self.git_info.is_none()
|
||||
&& self.memory_mode.is_none()
|
||||
&& self.project_id.is_none()
|
||||
&& self.daybreak_enabled.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user