From aa5224f6f0c34e4fa260bb840923128ab982f852 Mon Sep 17 00:00:00 2001 From: "r4yharris-agent-coder[bot]" <334673250+r4yharris-agent-coder[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 16:04:09 -0500 Subject: [PATCH] fix(runtime): raise planning inventory to 32768, bypass stale dotnet global.json via temp cwd, handle PytestConfigWarning, and detect nested Cargo integration tests (FEATURE_SPEC 5.3, 5.4) AI-Agent: r4yharris-agent-coder AI-Model: GPT-6.1-Sol AI-Run: 1|github-copilot|GPT-6.1-Sol@-|x|-/1000000|-|ghcp-20261204-round16|round-16-polyglot-rca --- rust/delivery.rs | 4 +- rust/execution/tools.rs | 158 ++++++++++++++++++++++++++++++------- rust/planning/grounding.rs | 4 +- rust/planning/lifecycle.rs | 4 +- rust/seats/tests.rs | 3 + 5 files changed, 139 insertions(+), 34 deletions(-) diff --git a/rust/delivery.rs b/rust/delivery.rs index 5f5dfce..be63144 100644 --- a/rust/delivery.rs +++ b/rust/delivery.rs @@ -1368,9 +1368,9 @@ impl Driver<'_, T, O> { }) .map(str::to_owned) .collect::>(); - if inventory.len() > 4096 { + if inventory.len() > 32_768 { return Err(Error::type_error( - "Local planning inventory exceeds 4096 files; a bounded host inventory is required", + "Local planning inventory exceeds 32768 files; a bounded host inventory is required", )); } let planning = Box::pin(driver.run_planner_session_owned_after_pre_plan( diff --git a/rust/execution/tools.rs b/rust/execution/tools.rs index 86b3bee..20b3d29 100644 --- a/rust/execution/tools.rs +++ b/rust/execution/tools.rs @@ -2857,6 +2857,19 @@ impl Boundary { extra_env: &BTreeMap, timeout: u64, limit: usize, + ) -> Result { + self.process_in_dir(&self.root, executable, args, extra_env, timeout, limit) + .await + } + + pub(crate) async fn process_in_dir( + &self, + cwd: &Path, + executable: &Path, + args: &[String], + extra_env: &BTreeMap, + timeout: u64, + limit: usize, ) -> Result { self.check()?; let family = if self.host.node20.as_deref() == Some(executable) { @@ -2885,7 +2898,7 @@ impl Boundary { }; let scope = family.and_then(|label| self.span(label)); let run = backend::Owner::Execution(self) - .run(&self.root, executable, args, extra_env, timeout, limit) + .run(cwd, executable, args, extra_env, timeout, limit) .await; super::timing::finish(scope, run.as_ref().err()); pending.settled = true; @@ -2909,7 +2922,7 @@ impl Boundary { stderr: run.stderr, }); } - let mut command = self.host.command(&self.root, executable, args, extra_env); + let mut command = self.host.command(cwd, executable, args, extra_env); let scope = family.and_then(|label| self.span(label)); let output = process::execute_timed( &mut command, @@ -3431,10 +3444,12 @@ impl Boundary { "no:cacheprovider".to_owned(), "-o".to_owned(), "addopts=".to_owned(), + "-W".to_owned(), + "default".to_owned(), ]; noadd_args.extend(test_files.clone()); result.commands.push(format!( - "python3 -B -m pytest -o addopts= {}", + "python3 -B -m pytest -o addopts= -W default {}", test_files.join(" ") )); active_out = self @@ -3448,6 +3463,8 @@ impl Boundary { .await?; extra_pytest_flags.push("-o".to_owned()); extra_pytest_flags.push("addopts=".to_owned()); + extra_pytest_flags.push("-W".to_owned()); + extra_pytest_flags.push("default".to_owned()); pytest_combined = format!( "{}\n{}", String::from_utf8_lossy(&active_out.stdout), @@ -3534,6 +3551,7 @@ impl Boundary { pub(crate) fn is_pytest_addopts_plugin_error(output: &str) -> bool { output.contains("Error importing plugin \"") + || output.contains("PytestConfigWarning: Unknown config option:") || (output.contains("unrecognized arguments:") && (output.contains("--cov") || output.contains("--numprocesses") @@ -3639,8 +3657,10 @@ impl Boundary { environment.insert(var.to_owned(), val); } } - let version = self - .process( + let mut dotnet_cwd = self.root.clone(); + let mut version = self + .process_in_dir( + &dotnet_cwd, &dotnet, &["--version".to_owned()], &environment, @@ -3648,6 +3668,23 @@ impl Boundary { 4096, ) .await?; + if version.exit != 0 && self.root.join("global.json").is_file() { + let fallback_cwd = std::env::temp_dir(); + let retry_version = self + .process_in_dir( + &fallback_cwd, + &dotnet, + &["--version".to_owned()], + &environment, + 15_000, + 4096, + ) + .await?; + if retry_version.exit == 0 { + dotnet_cwd = fallback_cwd; + version = retry_version; + } + } if version.exit != 0 { let message = format!( "dotnet SDK preflight failed in worktree (check global.json): {}", @@ -3709,6 +3746,11 @@ impl Boundary { )); }; let proj_path = self.root.join(&test_proj); + let proj_arg = if dotnet_cwd == self.root { + test_proj.clone() + } else { + proj_path.display().to_string() + }; let proj_text = fs::read_to_string(&proj_path).unwrap_or_default(); let mut props_text = proj_text.clone(); let mut scan_dir = proj_path.parent(); @@ -3786,7 +3828,7 @@ impl Boundary { .map(|h| PathBuf::from(h).join(".nuget").join("packages")) }) .filter(|p| p.is_dir()); - let mut online_restore_args = vec!["restore".to_owned(), test_proj.clone()]; + let mut online_restore_args = vec!["restore".to_owned(), proj_arg.clone()]; if needs_tfm_override && let Some(framework) = tfm { online_restore_args.push(format!("-p:TargetFrameworks={framework}")); } @@ -3802,7 +3844,8 @@ impl Boundary { restore_args.push(cache.display().to_string()); } let mut restore_out = self - .process( + .process_in_dir( + &dotnet_cwd, &dotnet, &restore_args, &environment, @@ -3821,7 +3864,8 @@ impl Boundary { && restore_args != online_restore_args { let retry = self - .process( + .process_in_dir( + &dotnet_cwd, &dotnet, &online_restore_args, &environment, @@ -3847,7 +3891,7 @@ impl Boundary { let _ = fs::remove_file(&trx_path); let mut args = vec![ "test".to_owned(), - test_proj.clone(), + proj_arg.clone(), "--no-restore".to_owned(), ]; if use_artifacts { @@ -3877,7 +3921,8 @@ impl Boundary { args.push(format!("trx;LogFileName={}", trx_path.display())); commands.push(format!("dotnet {}", args.join(" "))); let mut output = self - .process( + .process_in_dir( + &dotnet_cwd, &dotnet, &args, &environment, @@ -3901,7 +3946,7 @@ impl Boundary { let _ = fs::remove_file(&trx_path); let mut unfiltered_args = vec![ "test".to_owned(), - test_proj.clone(), + proj_arg.clone(), "--no-restore".to_owned(), ]; if use_artifacts { @@ -3919,7 +3964,8 @@ impl Boundary { unfiltered_args.push(format!("trx;LogFileName={}", trx_path.display())); commands.push(format!("dotnet {}", unfiltered_args.join(" "))); output = self - .process( + .process_in_dir( + &dotnet_cwd, &dotnet, &unfiltered_args, &environment, @@ -4834,14 +4880,22 @@ impl Boundary { let mut completed = 0; let mut integration_stems = Vec::new(); for file in requirements.files.iter().chain(self.written.iter()) { - if let Some(rest) = file.strip_prefix("tests/") - && !rest.contains('/') - && let Some(stem) = rest.strip_suffix(".rs") - && !integration_stems - .iter() - .any(|existing: &String| existing == stem) - { - integration_stems.push(stem.to_owned()); + if let Some(rest) = file.strip_prefix("tests/") { + if !rest.contains('/') + && let Some(stem) = rest.strip_suffix(".rs") + && !integration_stems + .iter() + .any(|existing: &String| existing == stem) + { + integration_stems.push(stem.to_owned()); + } else if let Some((dir, _)) = rest.split_once('/') + && self.root.join("tests").join(dir).join("main.rs").is_file() + && !integration_stems + .iter() + .any(|existing: &String| existing == dir) + { + integration_stems.push(dir.to_owned()); + } } } let has_integration_test = !integration_stems.is_empty() @@ -4855,14 +4909,28 @@ impl Boundary { let sub_tests_prefix = format!("{sc}/tests/"); let mut sub_integration_stems = Vec::new(); for file in requirements.files.iter().chain(self.written.iter()) { - if let Some(rest) = file.strip_prefix(&sub_tests_prefix) - && !rest.contains('/') - && let Some(stem) = rest.strip_suffix(".rs") - && !sub_integration_stems - .iter() - .any(|existing: &String| existing == stem) - { - sub_integration_stems.push(stem.to_owned()); + if let Some(rest) = file.strip_prefix(&sub_tests_prefix) { + if !rest.contains('/') + && let Some(stem) = rest.strip_suffix(".rs") + && !sub_integration_stems + .iter() + .any(|existing: &String| existing == stem) + { + sub_integration_stems.push(stem.to_owned()); + } else if let Some((dir, _)) = rest.split_once('/') + && self + .root + .join(sc) + .join("tests") + .join(dir) + .join("main.rs") + .is_file() + && !sub_integration_stems + .iter() + .any(|existing: &String| existing == dir) + { + sub_integration_stems.push(dir.to_owned()); + } } } let target_flag = if self.root.join(sc).join("src").join("lib.rs").is_file() { @@ -5242,6 +5310,40 @@ impl Boundary { output.stdout.clear(); } } + if is_test + && !is_roster_self + && !args.iter().any(|a| a == "--all-features") + && (output.exit == 0 + && String::from_utf8_lossy(&output.stdout).contains("running 0 tests")) + { + let mut feat_args = Vec::with_capacity(args.len() + 1); + let mut inserted = false; + for a in &args { + if !inserted && a == "--" { + feat_args.push("--all-features".to_owned()); + inserted = true; + } + feat_args.push(a.clone()); + } + if !inserted { + feat_args.push("--all-features".to_owned()); + } + commands.push(format!("cargo {}", feat_args.join(" "))); + let feat_out = self + .process( + &approved.executable, + &feat_args, + &environment, + policy::FULL_TEST_TIMEOUT_MS, + 4 * 1024 * 1024, + ) + .await?; + if feat_out.exit == 0 + && !String::from_utf8_lossy(&feat_out.stdout).contains("running 0 tests") + { + output = feat_out; + } + } if !(is_metadata && output.exit == 0) { stdout.push_str(&bytes_text(&output.stdout)?); } diff --git a/rust/planning/grounding.rs b/rust/planning/grounding.rs index c93f600..9ce65a1 100644 --- a/rust/planning/grounding.rs +++ b/rust/planning/grounding.rs @@ -276,9 +276,9 @@ pub fn related_exports( } pub fn read_context(root: &Path, files: &[String], ask: &str) -> Result { - if files.len() > 4096 { + if files.len() > 32_768 { return Err(Error::type_error( - "Planning repository inventory exceeds 4096 files", + "Planning repository inventory exceeds 32768 files", )); } let mut sources = Vec::new(); diff --git a/rust/planning/lifecycle.rs b/rust/planning/lifecycle.rs index 8d66092..b26c77a 100644 --- a/rust/planning/lifecycle.rs +++ b/rust/planning/lifecycle.rs @@ -1011,9 +1011,9 @@ pub async fn tracked_files( }) .map(str::to_owned) .collect::>(); - if files.len() > 4096 { + if files.len() > 32_768 { return Err(Error::type_error( - "Planning repository inventory exceeds 4096 files; provide a bounded relevant inventory", + "Planning repository inventory exceeds 32768 files; provide a bounded relevant inventory", )); } for file in &files { diff --git a/rust/seats/tests.rs b/rust/seats/tests.rs index 2515c00..a6deb3f 100644 --- a/rust/seats/tests.rs +++ b/rust/seats/tests.rs @@ -2385,6 +2385,9 @@ fn pytest_missing_fixture_detector_distinguishes_plugin_errors_from_real_failure assert!(tools::Boundary::is_pytest_addopts_plugin_error( "ERROR: Error importing plugin \"pytest_cov\": No module named 'pytest_cov'" )); + assert!(tools::Boundary::is_pytest_addopts_plugin_error( + "pytest.PytestConfigWarning: Unknown config option: timeout" + )); assert!(!tools::Boundary::is_pytest_addopts_plugin_error( normal_fail ));