Skip to content

Commit b274ec6

Browse files
jwiegleyclaude
andcommitted
fix: allow daemon errors in corruption-scenario tests
Three missing_attribution tests (H6d, H7a, H18) intentionally create corrupt checkpoint data to document failure modes. In daemon mode, the daemon reports errors when processing these, causing wait_for_daemon_completion_sessions to panic before the test can check the outcome. Add allow_daemon_errors flag to TestRepo so these tests can indicate that daemon errors are expected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2b452fd commit b274ec6

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

tests/integration/missing_attribution.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ fn test_h6d_ai_checkpoint_wrong_file_path() {
783783
);
784784
fs::write(cp_dir.join("checkpoints.jsonl"), &checkpoint_json).unwrap();
785785

786+
repo.set_allow_daemon_errors(true);
786787
let result = repo.stage_all_and_commit("add ai code");
787788

788789
match result {
@@ -862,6 +863,7 @@ fn test_h7a_truncated_jsonl_poisons_all_checkpoints() {
862863
let checkpoints = format!("{}\n{}\n", valid_checkpoint, corrupt_line);
863864
fs::write(cp_dir.join("checkpoints.jsonl"), &checkpoints).unwrap();
864865

866+
repo.set_allow_daemon_errors(true);
865867
let result = repo.stage_all_and_commit("add ai code");
866868

867869
// The corrupt line causes read_all_checkpoints() to fail with Err.
@@ -1643,6 +1645,7 @@ fn test_h18_append_checkpoint_on_corrupt_jsonl_overwrites_valid_data() {
16431645
// The corrupt JSONL may cause post-commit to fail entirely (no note written),
16441646
// or the note may be written but with file_a's AI data lost. Either outcome
16451647
// confirms the data-loss bug in append_checkpoint.
1648+
repo.set_allow_daemon_errors(true);
16461649
let result = repo.stage_all_and_commit("commit both");
16471650

16481651
match result {

tests/integration/repos/test_repo.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::fs;
2020
use std::io::Read;
2121
use std::path::{Path, PathBuf};
2222
use std::process::{Child, Command, Stdio};
23-
use std::sync::atomic::{AtomicUsize, Ordering};
23+
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
2424
use std::sync::{Arc, Mutex, OnceLock};
2525
use std::thread;
2626
use std::time::{Duration, Instant};
@@ -747,6 +747,7 @@ pub struct TestRepo {
747747
/// Base repo's test DB path for cleanup.
748748
_base_test_db_path: Option<PathBuf>,
749749
daemon_family_key: OnceLock<String>,
750+
allow_daemon_errors: AtomicBool,
750751
}
751752

752753
#[allow(dead_code)]
@@ -1014,6 +1015,7 @@ impl TestRepo {
10141015
_base_repo_path: Some(base_path),
10151016
_base_test_db_path: Some(base_test_db_path),
10161017
daemon_family_key: OnceLock::new(),
1018+
allow_daemon_errors: AtomicBool::new(false),
10171019
};
10181020

10191021
repo.apply_default_config_patch();
@@ -1051,6 +1053,7 @@ impl TestRepo {
10511053
_base_repo_path: None,
10521054
_base_test_db_path: None,
10531055
daemon_family_key: OnceLock::new(),
1056+
allow_daemon_errors: AtomicBool::new(false),
10541057
};
10551058

10561059
repo.apply_default_config_patch();
@@ -1133,6 +1136,7 @@ impl TestRepo {
11331136
_base_repo_path: Some(main_path),
11341137
_base_test_db_path: None,
11351138
daemon_family_key: OnceLock::new(),
1139+
allow_daemon_errors: AtomicBool::new(false),
11361140
};
11371141

11381142
repo.apply_default_config_patch();
@@ -1177,6 +1181,7 @@ impl TestRepo {
11771181
_base_repo_path: None,
11781182
_base_test_db_path: None,
11791183
daemon_family_key: OnceLock::new(),
1184+
allow_daemon_errors: AtomicBool::new(false),
11801185
};
11811186

11821187
let mut repo = repo;
@@ -1235,6 +1240,7 @@ impl TestRepo {
12351240
_base_repo_path: None,
12361241
_base_test_db_path: None,
12371242
daemon_family_key: OnceLock::new(),
1243+
allow_daemon_errors: AtomicBool::new(false),
12381244
};
12391245

12401246
// Ensure the upstream default branch is named "main" for consistency across Git versions
@@ -1278,6 +1284,7 @@ impl TestRepo {
12781284
_base_repo_path: None,
12791285
_base_test_db_path: None,
12801286
daemon_family_key: OnceLock::new(),
1287+
allow_daemon_errors: AtomicBool::new(false),
12811288
};
12821289

12831290
// Ensure the default branch is named "main" for consistency across Git versions
@@ -1334,6 +1341,7 @@ impl TestRepo {
13341341
_base_repo_path: None,
13351342
_base_test_db_path: None,
13361343
daemon_family_key: OnceLock::new(),
1344+
allow_daemon_errors: AtomicBool::new(false),
13371345
};
13381346

13391347
repo.apply_default_config_patch();
@@ -1346,6 +1354,10 @@ impl TestRepo {
13461354
self.feature_flags = feature_flags;
13471355
}
13481356

1357+
pub fn set_allow_daemon_errors(&self, allow: bool) {
1358+
self.allow_daemon_errors.store(allow, Ordering::Relaxed);
1359+
}
1360+
13491361
pub(crate) fn daemon_control_socket_path(&self) -> PathBuf {
13501362
self.daemon_process
13511363
.as_ref()
@@ -1525,6 +1537,10 @@ impl TestRepo {
15251537
continue;
15261538
}
15271539
if entry.status == "error" {
1540+
if self.allow_daemon_errors.load(Ordering::Relaxed) {
1541+
completed.insert(session);
1542+
continue;
1543+
}
15281544
panic!(
15291545
"daemon completion log reported an error for family {} session {}: {}",
15301546
family_key,

0 commit comments

Comments
 (0)