Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 26 additions & 1 deletion rust/delivery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ impl<T: Transport, O: Observer> Driver<'_, T, O> {
domain::put(&mut event, "same_selected_model", Value::Boolean(true))?;
format!("Fresh perspective {count}: the previous coder {reason}. This fixed-profile continuation uses the same selected model, not an invented alternate route. Use a materially different approach; do not repeat earlier failed moves")
};
let facts = orchestration.attempts.iter().filter(|attempt| attempt.seat == "coder")
let mut facts = orchestration.attempts.iter().filter(|attempt| attempt.seat == "coder")
.filter_map(|attempt| attempt.failure.as_ref().map(|error| {
let model = attempt.response.as_ref().map(|response| response.model.to_utf8()).transpose()?;
Ok(continuation::safe_line(&Text::from(format!(
Expand All @@ -1701,6 +1701,31 @@ impl<T: Transport, O: Observer> Driver<'_, T, O> {
attempt.handoff.map_or("failed", seats::Handoff::as_str), error.message,
).as_str()), boundary))
})).collect::<Result<Vec<_>, Error>>()?;
let modified = boundary.written_files();
if !modified.is_empty() {
facts.push(continuation::safe_line(&Text::from(format!(
"Worktree edits already on disk (inspect with git_diff instead of re-reading from scratch): {}",
modified.join(", "),
).as_str()), boundary));
}
if let Some(last) = boundary.last_tests() {
let cmd = last.observed_commands().last().map_or("run_test", String::as_str);
if last.observed_exit() == 0 {
facts.push(continuation::safe_line(&Text::from(format!(
"Latest observed test run ({cmd}) PASSED (exit 0) on current disk edits — verify checklist and finalize without redoing passing work.",
).as_str()), boundary));
} else {
let stdout_s = last.result.get("stdout").and_then(Value::as_string).and_then(|t| t.to_utf8().ok()).unwrap_or_default();
let stderr_s = last.result.get("stderr").and_then(Value::as_string).and_then(|t| t.to_utf8().ok()).unwrap_or_default();
let excerpt = seats::coder::extract_diagnostic_excerpt(&format!("{stdout_s}\n{stderr_s}"));
let one_line = excerpt.replace(['\r', '\n'], " | ");
let truncated: String = one_line.chars().take(420).collect();
facts.push(continuation::safe_line(&Text::from(format!(
"Latest observed test failure ({cmd}, exit {}): {truncated}",
last.observed_exit(),
).as_str()), boundary));
}
}
guidance = Some(continuation::continuation(&heading, boundary, &facts, false)?);
capsule = execution::continuity::next_context(boundary, &options.loaded.config, coder.capsule(), &[], &projection)?;
orchestration.archives.push(coder.archive_continuation(boundary, None, &projection).await?);
Expand Down
35 changes: 32 additions & 3 deletions rust/execution/counterfactual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,19 @@ pub(crate) async fn run_one(
args.push("--import".to_owned());
args.push(tools::TS_IMPORT_HOOK.to_owned());
}
let name_pattern = node_test_name_pattern(&target.names);
let is_flat_file = fs::read_to_string(directory.join(&target.file))
.ok()
.is_some_and(|src| !src.contains("describe("));
args.extend([
"--test".to_owned(),
"--test-reporter=tap".to_owned(),
format!("--test-timeout={per_test_timeout}"),
target.file.clone(),
]);
if is_flat_file && let Some(ref pat) = name_pattern {
args.push(format!("--test-name-pattern={pat}"));
}
args.push(target.file.clone());
let run = owner
.run(
directory,
Expand Down Expand Up @@ -267,14 +274,18 @@ pub(crate) async fn run_one(
.map(|nm| nm.join("vitest").join("vitest.mjs"))
.find(|p| p.is_file())
{
let vargs = vec![
let mut vargs = vec![
vitest.display().to_string(),
"run".to_owned(),
"--no-file-parallelism".to_owned(),
"--no-cache".to_owned(),
"--reporter=tap-flat".to_owned(),
target.file.clone(),
];
if let Some(ref pat) = name_pattern {
vargs.push("-t".to_owned());
vargs.push(pat.clone());
}
vargs.push(target.file.clone());
return owner
.run(
directory,
Expand Down Expand Up @@ -380,6 +391,24 @@ fn observed(run: &backend::Run, name: &str, owner: backend::Owner<'_>) -> Result
]))
}

pub(crate) fn node_test_name_pattern(names: &[Text]) -> Option<String> {
let mut parts = Vec::new();
for name in names {
let Ok(raw) = name.to_utf8() else {
return None;
};
let trimmed = raw.trim();
if trimmed.is_empty() || trimmed.len() > 240 {
return None;
}
parts.push(regex_lite::escape(trimmed));
}
if parts.is_empty() {
return None;
}
Some(format!("(?:{})", parts.join("|")))
}

pub async fn run(
boundary: &tools::Boundary,
approval: &backend::Approval,
Expand Down
Loading
Loading