@@ -115,7 +115,7 @@ async function workbench(fixture: ScanFixture, args: readonly string[]) {
115115}
116116
117117async function startDraftScan (
118- repositoryKind : "directory" | "clean" | "dirty" = "directory" ,
118+ repositoryKind : "directory" | "clean" | "dirty" | "nested" = "directory" ,
119119) : Promise < ScanFixture > {
120120 const root = await realpath (
121121 await mkdtemp ( join ( tmpdir ( ) , "codex-security-scan-recovery-" ) ) ,
@@ -153,6 +153,15 @@ async function startDraftScan(
153153 if ( repositoryKind === "dirty" ) {
154154 await writeFile ( join ( target , "src" , "extract.py" ) , "# changed fixture\n" ) ;
155155 }
156+ if ( repositoryKind === "nested" ) {
157+ const nested = join ( target , "nested" ) ;
158+ await mkdir ( nested ) ;
159+ await writeFile ( join ( nested , "source.py" ) , "# nested fixture\n" ) ;
160+ const initialized = spawnSync ( "git" , [ "init" , "--quiet" , nested ] , {
161+ encoding : "utf8" ,
162+ } ) ;
163+ expect ( initialized . status , initialized . stderr ) . toBe ( 0 ) ;
164+ }
156165 }
157166
158167 const fixture : ScanFixture = {
@@ -246,8 +255,8 @@ describe("malformed scan artifact recovery", () => {
246255 } ) ;
247256 } ) ;
248257
249- test ( "returns authoritative clean and dirty Git target contracts" , async ( ) => {
250- for ( const kind of [ "clean" , "dirty" ] as const ) {
258+ test ( "returns authoritative clean, dirty, and nested Git target contracts" , async ( ) => {
259+ for ( const kind of [ "clean" , "dirty" , "nested" ] as const ) {
251260 const fixture = await startDraftScan ( kind ) ;
252261 const registration = fixture . registration ;
253262 const contract = registration [ "contract" ] as {
@@ -276,6 +285,31 @@ describe("malformed scan artifact recovery", () => {
276285 / ^ c o d e x - s e c u r i t y - s n a p s h o t \/ v 1 : s h a 2 5 6 : [ a - f 0 - 9 ] { 64 } $ / ,
277286 ) ;
278287 }
288+ if ( kind === "nested" ) {
289+ const copied = spawnSync (
290+ fixture . python ,
291+ [
292+ "-I" ,
293+ "-B" ,
294+ "-c" ,
295+ [
296+ "import sys" ,
297+ "from pathlib import Path" ,
298+ "sys.path.insert(0, sys.argv[1])" ,
299+ "import workbench_target as target" ,
300+ "source = Path(sys.argv[2])" ,
301+ "checkout = target.copy_git_worktree_files(source, Path(sys.argv[3]), ())" ,
302+ "git_dir = Path(target.git_output(source, 'rev-parse', '--absolute-git-dir'))" ,
303+ "assert target.worktree_content_digest_for_context(checkout, '.', git_dir=git_dir, work_tree=checkout) == target.worktree_content_digest(source)" ,
304+ ] . join ( "\n" ) ,
305+ join ( PLUGIN_ROOT , "scripts" ) ,
306+ fixture . repository ,
307+ join ( fixture . stateDir , "checkout" ) ,
308+ ] ,
309+ { encoding : "utf8" } ,
310+ ) ;
311+ expect ( copied . status , copied . stderr ) . toBe ( 0 ) ;
312+ }
279313 }
280314 } ) ;
281315
0 commit comments