@@ -215,7 +215,10 @@ describe('the write guard', () => {
215215} )
216216
217217describe ( 'the real rooted filesystem passed to SDK tools' , ( ) => {
218- test ( 'reads inside the worktree only when OS containment is available' , async ( ) => {
218+ // Since COD-642 the file layer runs no shell and needs no broker, so these
219+ // work with or without an OS sandbox on the host. They used to answer
220+ // `[FILE_READ_ERROR]` wherever no sandbox could start.
221+ test ( 'reads inside the worktree without a shell or OS containment' , async ( ) => {
219222 const parent = mkdtempSync ( join ( tmpdir ( ) , 'sponsored-cli-fs-' ) )
220223 const root = join ( parent , 'worktree' )
221224 mkdirSync ( join ( root , 'src' ) , { recursive : true } )
@@ -224,71 +227,60 @@ describe('the real rooted filesystem passed to SDK tools', () => {
224227 const tools = sponsoredOverrideTools ( isolatedContext ( root , parent ) )
225228
226229 const read = await tools . read_files ( { filePaths : [ 'src/inside.ts' ] } )
227- if ( containmentUsable ( ) ) {
228- expect ( read [ 'src/inside.ts' ] ) . toContain ( 'export const before = 1' )
229- } else {
230- expect ( read [ 'src/inside.ts' ] ) . toBe ( '[FILE_READ_ERROR]' )
231- expect ( read [ 'src/inside.ts' ] ) . not . toContain ( 'export const before = 1' )
232- }
230+ expect ( read [ 'src/inside.ts' ] ) . toContain ( 'export const before = 1' )
233231 } finally {
234232 rmSync ( parent , { recursive : true , force : true } )
235233 }
236234 } )
237235
238- test . skipIf ( ! containmentUsable ( ) ) (
239- 'lists and globs inside the worktree through OS containment' ,
240- async ( ) => {
241- const parent = mkdtempSync ( join ( tmpdir ( ) , 'sponsored-cli-list-' ) )
242- const root = join ( parent , 'worktree' )
243- mkdirSync ( join ( root , 'src' ) , { recursive : true } )
244- writeFileSync ( join ( root , 'src' , 'inside.ts' ) , 'export const before = 1\n' )
245- try {
246- const tools = sponsoredOverrideTools ( isolatedContext ( root , parent ) )
247- const listed = await tools . list_directory ( { path : 'src' } )
248- expect ( JSON . stringify ( listed ) ) . toContain ( 'inside.ts' )
236+ test ( 'lists and globs inside the worktree without a shell' , async ( ) => {
237+ const parent = mkdtempSync ( join ( tmpdir ( ) , 'sponsored-cli-list-' ) )
238+ const root = join ( parent , 'worktree' )
239+ mkdirSync ( join ( root , 'src' ) , { recursive : true } )
240+ writeFileSync ( join ( root , 'src' , 'inside.ts' ) , 'export const before = 1\n' )
241+ try {
242+ const tools = sponsoredOverrideTools ( isolatedContext ( root , parent ) )
243+ const listed = await tools . list_directory ( { path : 'src' } )
244+ expect ( JSON . stringify ( listed ) ) . toContain ( 'inside.ts' )
249245
250- const globbed = await tools . glob ( { pattern : '**/*.ts' } )
251- expect ( JSON . stringify ( globbed ) ) . toContain ( 'src/inside.ts' )
252- } finally {
253- rmSync ( parent , { recursive : true , force : true } )
254- }
255- } ,
256- )
246+ const globbed = await tools . glob ( { pattern : '**/*.ts' } )
247+ expect ( JSON . stringify ( globbed ) ) . toContain ( 'src/inside.ts' )
248+ } finally {
249+ rmSync ( parent , { recursive : true , force : true } )
250+ }
251+ } )
257252
258- test . skipIf ( ! containmentUsable ( ) ) (
259- 'writes and patches inside the worktree through OS containment' ,
260- async ( ) => {
261- const parent = mkdtempSync ( join ( tmpdir ( ) , 'sponsored-cli-write-' ) )
262- const root = join ( parent , 'worktree' )
263- mkdirSync ( join ( root , 'src' ) , { recursive : true } )
264- try {
265- const tools = sponsoredOverrideTools ( isolatedContext ( root , parent ) )
266- const written = await tools . write_file ( {
267- type : 'file' ,
268- path : 'src/written.ts' ,
269- content : 'export const written = true\n' ,
270- } )
271- expect ( JSON . stringify ( written ) ) . toContain ( 'Created file successfully' )
272-
273- const patched = await tools . apply_patch ( {
274- operation : {
275- type : 'create_file' ,
276- path : 'src/patched.ts' ,
277- diff : '@@ -0,0 +1 @@\n+export const patched = true\n' ,
278- } ,
279- } )
280- expect ( JSON . stringify ( patched ) ) . toContain ( 'Applied 1 patch operation' )
281- expect ( readFileSync ( join ( root , 'src' , 'written.ts' ) , 'utf8' ) ) . toContain (
282- 'written = true' ,
283- )
284- expect ( readFileSync ( join ( root , 'src' , 'patched.ts' ) , 'utf8' ) ) . toContain (
285- 'patched = true' ,
286- )
287- } finally {
288- rmSync ( parent , { recursive : true , force : true } )
289- }
290- } ,
291- )
253+ test ( 'writes and patches inside the worktree without a shell' , async ( ) => {
254+ const parent = mkdtempSync ( join ( tmpdir ( ) , 'sponsored-cli-write-' ) )
255+ const root = join ( parent , 'worktree' )
256+ mkdirSync ( join ( root , 'src' ) , { recursive : true } )
257+ try {
258+ const tools = sponsoredOverrideTools ( isolatedContext ( root , parent ) )
259+ const written = await tools . write_file ( {
260+ type : 'file' ,
261+ path : 'src/written.ts' ,
262+ content : 'export const written = true\n' ,
263+ } )
264+ expect ( JSON . stringify ( written ) ) . toContain ( 'Created file successfully' )
265+
266+ const patched = await tools . apply_patch ( {
267+ operation : {
268+ type : 'create_file' ,
269+ path : 'src/patched.ts' ,
270+ diff : '@@ -0,0 +1 @@\n+export const patched = true\n' ,
271+ } ,
272+ } )
273+ expect ( JSON . stringify ( patched ) ) . toContain ( 'Applied 1 patch operation' )
274+ expect ( readFileSync ( join ( root , 'src' , 'written.ts' ) , 'utf8' ) ) . toContain (
275+ 'written = true' ,
276+ )
277+ expect ( readFileSync ( join ( root , 'src' , 'patched.ts' ) , 'utf8' ) ) . toContain (
278+ 'patched = true' ,
279+ )
280+ } finally {
281+ rmSync ( parent , { recursive : true , force : true } )
282+ }
283+ } )
292284
293285 test ( 'refuses dangling links and a link introduced after the surface guard' , async ( ) => {
294286 const parent = mkdtempSync ( join ( tmpdir ( ) , 'sponsored-cli-links-' ) )
0 commit comments