From 55967e8ff691f8b0b1c2d5432a630081cf4404ac Mon Sep 17 00:00:00 2001 From: "r4yharris-agent-coder[bot]" <334673250+r4yharris-agent-coder[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2026 13:33:48 -0500 Subject: [PATCH] feat(execution,start): scale large OSS tree caps, Maven offline self-recovery, and Vitest ESM shim (FEATURE_SPEC 5.2, 5.4, 5.5) AI-Agent: r4yharris-agent-coder AI-Model: GPT-6.1-Sol AI-Run: 1|github-copilot|GPT-6.1-Sol@-|x|-/1000000|-|ghcp-20261202-r8|simplified-reporting-and-roster-testing --- rust/execution/mod.rs | 1 + rust/execution/policy.rs | 13 +++++- rust/execution/scratch.rs | 4 +- rust/execution/tests.rs | 48 ++++++++++++++++++++++ rust/execution/tools.rs | 86 ++++++++++++++++++++++++++++++--------- rust/start.rs | 6 ++- 6 files changed, 134 insertions(+), 24 deletions(-) diff --git a/rust/execution/mod.rs b/rust/execution/mod.rs index 07682b3..d0685d0 100644 --- a/rust/execution/mod.rs +++ b/rust/execution/mod.rs @@ -39,6 +39,7 @@ use crate::text::Text; pub const MAX_FILE_BYTES: u64 = 16 * 1024 * 1024; pub const MAX_FILES: usize = 2048; +pub const MAX_TREE_ENTRIES: usize = 32_768; pub const MAX_SCOPE_ENTRIES: usize = 64; pub const MAX_SNAPSHOT_BYTES: u64 = 128 * 1024 * 1024; diff --git a/rust/execution/policy.rs b/rust/execution/policy.rs index a8ea3a6..2aad3ee 100644 --- a/rust/execution/policy.rs +++ b/rust/execution/policy.rs @@ -120,6 +120,17 @@ pub fn consumer_requires_modern_node(root: &std::path::Path) -> bool { if root.join("tsconfig.json").is_file() { return true; } + if pkg + .get("devDependencies") + .and_then(|deps| deps.get("typescript")) + .is_some() + || pkg + .get("dependencies") + .and_then(|deps| deps.get("typescript")) + .is_some() + { + return true; + } let Some(engine_str) = pkg .get("engines") .and_then(|e| e.get("node")) @@ -147,7 +158,7 @@ pub fn relevant_tests(files: &[String]) -> Result, Error> { } let base = file.rsplit('/').next().unwrap_or(""); let base = extension.replace(base, ""); - if !base.is_empty() && file.starts_with("src/") { + if !base.is_empty() && (file.starts_with("src/") || file.contains("/src/")) { if file.ends_with(".ts") || file.ends_with(".mts") || file.ends_with(".cts") { let mut candidates = vec![ format!("src/test/{base}.test.ts"), diff --git a/rust/execution/scratch.rs b/rust/execution/scratch.rs index 1ce7b5d..60519cc 100644 --- a/rust/execution/scratch.rs +++ b/rust/execution/scratch.rs @@ -221,8 +221,8 @@ impl<'a> Scratch<'a> { .split('\0') .filter(|entry| !entry.is_empty()) .collect::>(); - if entries.len() > MAX_FILES { - return Err(denied("Base revision exceeds 2048 tree entries")); + if entries.len() > MAX_TREE_ENTRIES { + return Err(denied("Base revision exceeds 32768 tree entries")); } for entry in &entries { let Some((metadata, path)) = entry.split_once('\t') else { diff --git a/rust/execution/tests.rs b/rust/execution/tests.rs index 3f72dab..f184721 100644 --- a/rust/execution/tests.rs +++ b/rust/execution/tests.rs @@ -2377,5 +2377,53 @@ fn polyglot_intake_extracts_csharp_java_and_typescript_paths() -> Result<(), Err assert!(ts_tests.contains(&"src/test/v35.test.ts".to_owned())); assert!(ts_tests.contains(&"src/test/v35.spec.ts".to_owned())); assert!(ts_tests.contains(&"src/utils/mime.test.ts".to_owned())); + let monorepo_ts = policy::relevant_tests(&["library/src/actions/ip/ip.ts".to_owned()])?; + assert!(monorepo_ts.contains(&"library/src/actions/ip/ip.test.ts".to_owned())); + assert!(monorepo_ts.contains(&"library/src/actions/ip/ip.spec.ts".to_owned())); Ok(()) } + +#[test] +fn monorepo_typescript_dev_dependency_enables_modern_node() -> Result<(), Error> { + let base = std::env::temp_dir().join(format!( + "roster-ts-monorepo-{}-{}", + std::process::id(), + SEQUENCE.fetch_add(1, Ordering::Relaxed) + )); + let valibot_dir = base.join("valibot"); + let self_dir = base.join("self"); + fs::create_dir_all(&valibot_dir).map_err(io)?; + fs::create_dir_all(&self_dir).map_err(io)?; + fs::write( + valibot_dir.join("package.json"), + r#"{"name":"valibot","private":true,"devDependencies":{"typescript":"^5.9.3"}}"#, + ) + .map_err(io)?; + fs::write( + self_dir.join("package.json"), + r#"{"name":"github-agent-roster","devDependencies":{"typescript":"^5.9.3"}}"#, + ) + .map_err(io)?; + let valibot_modern = policy::consumer_requires_modern_node(&valibot_dir); + let self_modern = policy::consumer_requires_modern_node(&self_dir); + let _ = fs::remove_dir_all(&base); + assert!(valibot_modern); + assert!(!self_modern); + Ok(()) +} + +#[test] +fn maven_offline_and_resolution_error_detection_separates_cache_miss_from_test_failure() { + let offline_miss = "[ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:3.6.0 or one of its dependencies could not be resolved:\n[ERROR] Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-surefire-plugin:jar:3.6.0 has not been downloaded from it before."; + assert!(tools::Boundary::is_maven_offline_resolution_error( + offline_miss + )); + assert!(tools::Boundary::is_maven_resolution_error( + "[ERROR] PluginResolutionException: Could not transfer artifact" + )); + let test_failure = "[ERROR] Tests run: 5, Failures: 1, Errors: 0, Skipped: 0"; + assert!(!tools::Boundary::is_maven_offline_resolution_error( + test_failure + )); + assert!(!tools::Boundary::is_maven_resolution_error(test_failure)); +} diff --git a/rust/execution/tools.rs b/rust/execution/tools.rs index 1190e76..5ffeaf0 100644 --- a/rust/execution/tools.rs +++ b/rust/execution/tools.rs @@ -119,7 +119,7 @@ fn environment_allowed(name: &str) -> bool { .contains(&name.to_ascii_lowercase().as_str()) } -pub(crate) const TS_IMPORT_HOOK: &str = r#"data:text/javascript,import{registerHooks}from"node:module";import*as T from"node:test";import*as A from"node:assert/strict";registerHooks({resolve(s,c,n){try{return n(s,c);}catch(e){if(c.parentURL&&c.parentURL.startsWith("file:")){const xs=s.endsWith(".js")?[s.slice(0,-3)+".ts"]:(s.startsWith(".")&&!/\.[cm]?[jt]s$/.test(s)?[s+".ts",s+"/index.ts"]:[]);for(const x of xs){try{return n(x,c);}catch{}}}throw e;}}});if(!globalThis.describe){const m=(a,neg)=>({toBe:b=>neg?A.notStrictEqual(a,b):A.strictEqual(a,b),toEqual:b=>neg?A.notDeepStrictEqual(a,b):A.deepStrictEqual(a,b),toStrictEqual:b=>neg?A.notDeepStrictEqual(a,b):A.deepStrictEqual(a,b),toBeUndefined:()=>neg?A.notStrictEqual(a,undefined):A.strictEqual(a,undefined),toBeNull:()=>neg?A.notStrictEqual(a,null):A.strictEqual(a,null),toBeTruthy:()=>A.ok(neg?!a:Boolean(a)),toBeFalsy:()=>A.ok(neg?Boolean(a):!a),toContain:b=>{const ok=typeof a==="string"?a.includes(b):Array.isArray(a)&&a.includes(b);A.ok(neg?!ok:ok);},toHaveLength:b=>neg?A.notStrictEqual(a.length,b):A.strictEqual(a.length,b),toMatch:b=>{const ok=b instanceof RegExp?b.test(String(a)):String(a).includes(String(b));A.ok(neg?!ok:ok);},toThrow:b=>neg?A.doesNotThrow(a,b):A.throws(a,b)});Object.assign(globalThis,{describe:T.describe,it:T.it,test:T.test,beforeEach:T.beforeEach,afterEach:T.afterEach,beforeAll:T.before,afterAll:T.after,expect:a=>Object.assign(m(a,false),{not:m(a,true)})});}"#; +pub(crate) const TS_IMPORT_HOOK: &str = r#"data:text/javascript,import{registerHooks}from"node:module";import*as T from"node:test";import*as A from"node:assert/strict";import{inspect}from"node:util";const S=Symbol("m");const mk=f=>({[S]:f});const eq=(a,b,st)=>{if(b&&typeof b==="object"&&typeof b[S]==="function")return b[S](a);if(Object.is(a,b))return true;if(!a||!b||typeof a!=="object"||typeof b!=="object")return false;if(a instanceof RegExp&&b instanceof RegExp)return a.source===b.source&&a.flags===b.flags;if(a instanceof Date&&b instanceof Date)return Object.is(a.getTime(),b.getTime());if(Array.isArray(a)!==Array.isArray(b))return false;if(Array.isArray(a))return a.length===b.length&&a.every((v,i)=>eq(v,b[i],st));if(st&&Object.getPrototypeOf(a)!==Object.getPrototypeOf(b))return false;const ka=Object.keys(a),kb=Object.keys(b);const ea=st?ka:ka.filter(k=>a[k]!==undefined),eb=st?kb:kb.filter(k=>b[k]!==undefined);if(ea.length!==eb.length)return false;return eb.every(k=>Object.prototype.hasOwnProperty.call(a,k)&&eq(a[k],b[k],st));};const cmp=(a,b,st,neg)=>{const ok=eq(a,b,st);if(neg?ok:!ok)A.fail(`Expected ${inspect(a,{depth:6})} ${neg?"not ":""}to equal ${inspect(b,{depth:6})}`);};const m=(a,neg)=>({toBe:b=>neg?A.notStrictEqual(a,b):A.strictEqual(a,b),toEqual:b=>cmp(a,b,false,neg),toStrictEqual:b=>cmp(a,b,true,neg),toBeUndefined:()=>neg?A.notStrictEqual(a,undefined):A.strictEqual(a,undefined),toBeNull:()=>neg?A.notStrictEqual(a,null):A.strictEqual(a,null),toBeTruthy:()=>A.ok(neg?!a:Boolean(a)),toBeFalsy:()=>A.ok(neg?Boolean(a):!a),toBeNaN:()=>A.ok(neg?!Number.isNaN(a):Number.isNaN(a)),toBeGreaterThan:b=>A.ok(neg?!(a>b):a>b),toBeGreaterThanOrEqual:b=>A.ok(neg?!(a>=b):a>=b),toBeLessThan:b=>A.ok(neg?!(aA.ok(neg?!(a<=b):a<=b),toBeCloseTo:(b,p=2)=>{const ok=Math.abs(a-b)A.ok(neg?!(a instanceof c):a instanceof c),toContain:b=>{const ok=typeof a==="string"?a.includes(b):Array.isArray(a)&&a.includes(b);A.ok(neg?!ok:ok);},toHaveLength:b=>neg?A.notStrictEqual(a.length,b):A.strictEqual(a.length,b),toMatch:b=>{const ok=b instanceof RegExp?b.test(String(a)):String(a).includes(String(b));A.ok(neg?!ok:ok);},toHaveProperty:(k,v)=>{const parts=Array.isArray(k)?k:String(k).split(".");let cur=a,has=true;for(const p of parts){if(cur!=null&&Object.prototype.hasOwnProperty.call(Object(cur),p))cur=cur[p];else{has=false;break;}}const ok=arguments.length>1?has&&eq(cur,v,false):has;A.ok(neg?!ok:ok);},toThrow:b=>neg?A.doesNotThrow(a,b):A.throws(a,b)});const expect=Object.assign(a=>Object.assign(m(a,false),{not:m(a,true)}),{any:c=>mk(v=>c===String?typeof v==="string"||v instanceof String:c===Number?typeof v==="number"||v instanceof Number:c===Boolean?typeof v==="boolean"||v instanceof Boolean:c===Function?typeof v==="function":c===Object?v!==null&&typeof v==="object":c===Symbol?typeof v==="symbol":c===BigInt?typeof v==="bigint":v instanceof c),anything:()=>mk(v=>v!==null&&v!==undefined),objectContaining:o=>mk(v=>v!==null&&typeof v==="object"&&Object.keys(o).every(k=>k in v&&eq(v[k],o[k],false))),arrayContaining:arr=>mk(v=>Array.isArray(v)&&arr.every(x=>v.some(y=>eq(y,x,false)))),stringContaining:s=>mk(v=>typeof v==="string"&&v.includes(s))});const api={describe:T.describe,it:T.it,test:T.test,beforeEach:T.beforeEach,afterEach:T.afterEach,beforeAll:T.before,afterAll:T.after,expect};globalThis.__rosterTestApi=api;if(!globalThis.describe)Object.assign(globalThis,api);registerHooks({resolve(s,c,n){try{return n(s,c);}catch(e){if(s==="vitest"||s==="@jest/globals")return{shortCircuit:true,url:"data:text/javascript,export const{describe,it,test,beforeEach,afterEach,beforeAll,afterAll,expect}=globalThis.__rosterTestApi;"};if(c.parentURL&&c.parentURL.startsWith("file:")){const xs=s.endsWith(".js")?[s.slice(0,-3)+".ts"]:(s.startsWith(".")&&!/\.[cm]?[jt]s$/.test(s)?[s+".ts",s+"/index.ts"]:[]);for(const x of xs){try{return n(x,c);}catch{}}}throw e;}}});"#; pub(crate) fn unverified_cleanup(failure: &process::Failure, descendants_possible: bool) -> bool { !failure.cleanup_complete @@ -540,8 +540,8 @@ impl ReadOnly<'_> { while let Some(path) = queue.pop() { self.boundary.check()?; visited += 1; - if visited > MAX_FILES { - return Err(usage("Reviewer search exceeds 2048 entries")); + if visited > MAX_TREE_ENTRIES { + return Err(usage("Reviewer search exceeds 32768 entries")); } let target = self.boundary.root.join(&path); secure::check_components(&target)?; @@ -559,8 +559,8 @@ impl ReadOnly<'_> { entry.map_err(|error| secure::io_error("Read review entry", &target, error)) }) .collect::, _>>()?; - if entries.len() > MAX_FILES { - return Err(usage("Reviewer directory exceeds 2048 entries")); + if entries.len() > MAX_TREE_ENTRIES { + return Err(usage("Reviewer directory exceeds 32768 entries")); } entries.sort_by_key(|entry| entry.file_name()); for entry in entries.into_iter().rev() { @@ -582,8 +582,8 @@ impl ReadOnly<'_> { if self.boundary.normalized(&file, true).is_ok() { queue.push(file); } - if queue.len() + visited > MAX_FILES { - return Err(usage("Reviewer search exceeds 2048 entries")); + if queue.len() + visited > MAX_TREE_ENTRIES { + return Err(usage("Reviewer search exceeds 32768 entries")); } } } else if metadata.is_file() { @@ -1984,8 +1984,8 @@ impl Boundary { while let Some(directory) = queue.pop() { self.check()?; directories += 1; - if directories > MAX_FILES { - return Err(usage("Tool traversal exceeds 2048 directories")); + if directories > MAX_TREE_ENTRIES { + return Err(usage("Tool traversal exceeds 32768 directories")); } for (_, file, directory) in self.list(&directory)? { if directory { @@ -1993,8 +1993,8 @@ impl Boundary { } else { files.push(file); } - if files.len() > MAX_FILES { - return Err(usage("Tool traversal exceeds 2048 files")); + if files.len() > MAX_TREE_ENTRIES { + return Err(usage("Tool traversal exceeds 32768 files")); } } } @@ -2522,8 +2522,8 @@ impl Boundary { let mut directories = 0; while let Some(directory) = queue.pop() { directories += 1; - if directories > MAX_FILES { - return Err(denied("Checkpoint traversal exceeds 2048 directories")); + if directories > MAX_TREE_ENTRIES { + return Err(denied("Checkpoint traversal exceeds 32768 directories")); } let target = if directory == "." { self.root.clone() @@ -3660,16 +3660,17 @@ impl Boundary { filters.push(stem.to_owned()); } } - let mut args = vec![ + let mut online_args = vec![ "-B".to_owned(), - "-o".to_owned(), "test".to_owned(), "-DfailIfNoTests=false".to_owned(), "-Drat.skip=true".to_owned(), ]; if !filters.is_empty() { - args.push(format!("-Dtest={}", filters.join(","))); + online_args.push(format!("-Dtest={}", filters.join(","))); } + let mut offline_args = vec!["-B".to_owned(), "-o".to_owned()]; + offline_args.extend(online_args.iter().skip(1).cloned()); let mut environment = BTreeMap::from([("ROSTER_SEAT".to_owned(), "coder".to_owned())]); for var in ["HOME", "USERPROFILE", "JAVA_HOME", "M2_HOME"] { if let Ok(val) = std::env::var(var) { @@ -3685,24 +3686,71 @@ impl Boundary { format!("{}{sep}{current_path}", java_bin.display()), ); } - let command_str = format!("mvn {}", args.join(" ")); + let offline_cmd = format!("mvn {}", offline_args.join(" ")); let output = self .process( &mvn, - &args, + &offline_args, &environment, policy::FULL_TEST_TIMEOUT_MS, 4 * 1024 * 1024, ) .await?; + let combined = format!( + "{}\n{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + if output.exit != 0 && Self::is_maven_offline_resolution_error(&combined) { + let online_cmd = format!("mvn {}", online_args.join(" ")); + let retry = self + .process( + &mvn, + &online_args, + &environment, + policy::FULL_TEST_TIMEOUT_MS, + 4 * 1024 * 1024, + ) + .await?; + let retry_combined = format!( + "{}\n{}", + String::from_utf8_lossy(&retry.stdout), + String::from_utf8_lossy(&retry.stderr) + ); + if retry.exit != 0 && Self::is_maven_resolution_error(&retry_combined) { + return Err(unsupported( + "Java Maven test runner could not resolve required Maven plugins or dependencies", + )); + } + return Ok(NodeChecks { + output: retry, + skipped: false, + commands: vec![offline_cmd, online_cmd], + syntax_file: None, + }); + } Ok(NodeChecks { output, skipped: false, - commands: vec![command_str], + commands: vec![offline_cmd], syntax_file: None, }) } + pub(crate) fn is_maven_offline_resolution_error(output: &str) -> bool { + output.contains("in offline mode") + || output.contains("has not been downloaded from it before") + || (output.contains("PluginResolutionException") && output.contains("offline")) + } + + pub(crate) fn is_maven_resolution_error(output: &str) -> bool { + output.contains("PluginResolutionException") + || output.contains("DependencyResolutionException") + || output.contains("Could not transfer artifact") + || output.contains("Non-resolvable parent POM") + || output.contains("Unresolveable build extension") + } + async fn node_checks(&self, scope: &[String], full: bool) -> Result { if !self.root.join("package.json").is_file() && scope diff --git a/rust/start.rs b/rust/start.rs index c13db97..a48c8c4 100644 --- a/rust/start.rs +++ b/rust/start.rs @@ -2286,9 +2286,11 @@ async fn modules( let tree = git .text(&source, &["ls-tree", "-r", "-l", "-z", &commit], token) .await?; - if tree.split('\0').filter(|entry| !entry.is_empty()).count() > 2048 { + if tree.split('\0').filter(|entry| !entry.is_empty()).count() + > crate::execution::MAX_TREE_ENTRIES + { return Err(Error::type_error( - "Selected Git base exceeds 2048 tracked entries", + "Selected Git base exceeds 32768 tracked entries", )); } for entry in tree.split('\0').filter(|entry| !entry.is_empty()) {