@@ -432,58 +432,67 @@ describe('content reaching Chat is admitted per item', () => {
432432 expect ( read . body ) . toContain ( fixture . files . entries )
433433 } )
434434
435- it . each ( [ 'uncached' , 'cached' , 'recovered' , 'user-error' , 'subsequent-error' ] as const ) (
436- 'keeps generated-document refusals per item (%s archive)' ,
437- async ( kind ) => {
438- const input = fixture . files . unknown
439- const read = `await getFileBase64('${ input } ');`
440- const code =
441- kind === 'recovered'
442- ? `try { ${ read } } catch {} pdf.addPage().drawText('safe fallback');`
443- : kind === 'user-error'
444- ? `const error = new Error('File cannot be sent to a model because its secret provenance is unavailable'); error.name = 'ContentRefusedError'; throw error;`
445- : kind === 'subsequent-error'
446- ? `try { ${ read } } catch {} throw new Error('fixture compiler failure');`
447- : `${ read } pdf.addPage().drawText('fixture render');`
448- const document = await uploadWorkspaceFile (
449- ws ( ) ,
450- fixture . ids . aliceId ,
451- Buffer . from ( `const archiveFixture = '${ generateId ( ) } '; ${ code } ` ) ,
452- `archive-refusal-${ generateId ( ) } .pdf` ,
453- 'text/x-python-pdf' ,
454- { notifyWorkspaceChange : false , secretProvenance : { status : 'exact' , entries : [ ] } }
455- )
456- if ( kind === 'cached' ) {
457- const warmed = await downloadWorkspaceFileItems . execute ( {
458- principal : createSessionPrincipal ( { userId : fixture . ids . aliceId } ) ,
459- input : { workspaceId : ws ( ) , fileIds : [ document . id ] , folderIds : [ ] } ,
460- } )
461- expect ( warmed . renderedDocuments . get ( document . id ) ?. subarray ( 0 , 4 ) . toString ( ) ) . toBe ( '%PDF' )
462- }
463- const route = `/api/v2/files/bulk-download?workspaceId=${ ws ( ) } &fileIds=`
464- const mixed = await cli ( 'GET' , `${ route } ${ fixture . files . clean } ,${ document . id } ` )
465- if ( kind === 'user-error' || kind === 'subsequent-error' ) {
466- expect ( mixed . status ) . toBe ( 500 )
467- expect ( mixed . body ) . toContain ( 'INTERNAL_ERROR' )
468- return
469- }
470- expect ( mixed . status , mixed . body ) . toBe ( 200 )
471- expect ( mixed . body ) . toContain ( CANARY . clean )
472- expect ( mixed . body ) . not . toContain ( CANARY . unknown )
473- expect ( mixed . registry . isPermanentlyIncomplete ( ) ) . toBe ( false )
474- if ( kind === 'recovered' ) {
475- expect ( mixed . body ) . toContain ( '%PDF' )
476- expect ( mixed . body ) . not . toContain ( 'sim-download-report.json' )
477- } else {
478- expect ( mixed . body ) . not . toContain ( '%PDF' )
479- expect ( mixed . body ) . toContain ( 'sim-download-report.json' )
480- expect ( mixed . body ) . toContain ( document . id )
481- const alone = await cli ( 'GET' , `${ route } ${ document . id } ` )
482- expect ( alone . status , alone . body ) . toBe ( 403 )
483- expect ( alone . body ) . not . toContain ( CANARY . unknown )
484- }
435+ it . each ( [
436+ 'uncached' ,
437+ 'cached' ,
438+ 'recovered' ,
439+ 'user-error' ,
440+ 'subsequent-error' ,
441+ 'copied-error' ,
442+ 'mutated-refusal' ,
443+ ] as const ) ( 'keeps generated-document refusals per item (%s archive)' , async ( kind ) => {
444+ const input = fixture . files . unknown
445+ const read = `await getFileBase64('${ input } ');`
446+ const code =
447+ kind === 'recovered'
448+ ? `try { ${ read } } catch {} pdf.addPage().drawText('safe fallback');`
449+ : kind === 'user-error'
450+ ? `const error = new Error('File cannot be sent to a model because its secret provenance is unavailable'); error.name = 'ContentRefusedError'; throw error;`
451+ : kind === 'subsequent-error'
452+ ? `try { ${ read } } catch {} throw new Error('fixture compiler failure');`
453+ : kind === 'copied-error'
454+ ? `try { ${ read } } catch (error) { throw Object.assign(new Error(error.message), error); }`
455+ : kind === 'mutated-refusal'
456+ ? `try { ${ read } } catch (error) { error.message = 'fixture reworded refusal'; throw error; }`
457+ : `${ read } pdf.addPage().drawText('fixture render');`
458+ const document = await uploadWorkspaceFile (
459+ ws ( ) ,
460+ fixture . ids . aliceId ,
461+ Buffer . from ( `const archiveFixture = '${ generateId ( ) } '; ${ code } ` ) ,
462+ `archive-refusal-${ generateId ( ) } .pdf` ,
463+ 'text/x-python-pdf' ,
464+ { notifyWorkspaceChange : false , secretProvenance : { status : 'exact' , entries : [ ] } }
465+ )
466+ if ( kind === 'cached' ) {
467+ const warmed = await downloadWorkspaceFileItems . execute ( {
468+ principal : createSessionPrincipal ( { userId : fixture . ids . aliceId } ) ,
469+ input : { workspaceId : ws ( ) , fileIds : [ document . id ] , folderIds : [ ] } ,
470+ } )
471+ expect ( warmed . renderedDocuments . get ( document . id ) ?. subarray ( 0 , 4 ) . toString ( ) ) . toBe ( '%PDF' )
485472 }
486- )
473+ const route = `/api/v2/files/bulk-download?workspaceId=${ ws ( ) } &fileIds=`
474+ const mixed = await cli ( 'GET' , `${ route } ${ fixture . files . clean } ,${ document . id } ` )
475+ if ( kind === 'user-error' || kind === 'subsequent-error' || kind === 'copied-error' ) {
476+ expect ( mixed . status ) . toBe ( 500 )
477+ expect ( mixed . body ) . toContain ( 'INTERNAL_ERROR' )
478+ return
479+ }
480+ expect ( mixed . status , mixed . body ) . toBe ( 200 )
481+ expect ( mixed . body ) . toContain ( CANARY . clean )
482+ expect ( mixed . body ) . not . toContain ( CANARY . unknown )
483+ expect ( mixed . registry . isPermanentlyIncomplete ( ) ) . toBe ( false )
484+ if ( kind === 'recovered' ) {
485+ expect ( mixed . body ) . toContain ( '%PDF' )
486+ expect ( mixed . body ) . not . toContain ( 'sim-download-report.json' )
487+ } else {
488+ expect ( mixed . body ) . not . toContain ( '%PDF' )
489+ expect ( mixed . body ) . toContain ( 'sim-download-report.json' )
490+ expect ( mixed . body ) . toContain ( document . id )
491+ const alone = await cli ( 'GET' , `${ route } ${ document . id } ` )
492+ expect ( alone . status , alone . body ) . toBe ( 403 )
493+ expect ( alone . body ) . not . toContain ( CANARY . unknown )
494+ }
495+ } )
487496
488497 it ( 'answers files search with locations and withheld unreadable previews (#5, misroute)' , async ( ) => {
489498 const read = await cli (
0 commit comments