@@ -1048,6 +1048,38 @@ describe('knowledge bases as workspace source', () => {
10481048 }
10491049 )
10501050
1051+ check (
1052+ 'a chunking change counts the replacement a stopped replace left among the documents keeping their chunks' ,
1053+ async ( ) => {
1054+ const { workspaceId, read, dir } = await setUp ( )
1055+ const edited = withDoc ( dir , REFUNDS , '# Refunds\nWithin 60 days.\n' )
1056+ const failing = vi
1057+ . spyOn ( deleteKnowledgeDocument , 'execute' )
1058+ . mockRejectedValueOnce ( new Error ( 'storage unavailable' ) )
1059+ . mockRejectedValueOnce ( new Error ( 'storage unavailable' ) )
1060+ const first = await apply ( workspaceId , edited , { base : read . base } ) . finally ( ( ) =>
1061+ failing . mockRestore ( )
1062+ )
1063+ expect ( first . failed ) . toMatchObject ( { key : 'policies' } )
1064+
1065+ const planned = await apply (
1066+ workspaceId ,
1067+ {
1068+ ...edited ,
1069+ files : {
1070+ ...edited . files ,
1071+ [ POLICIES_FILE ] : declaration ( 'Policies' , '\n chunking: { maxSize: 512 },' ) ,
1072+ } ,
1073+ } ,
1074+ { base : first . base , dryRun : true , carry : 'none' }
1075+ )
1076+
1077+ // The finished replacement and shipping.txt keep their chunks; the replaced refunds.md goes.
1078+ const chunking = planned . diagnostics . find ( ( finding ) => finding . code === 'I_KB_CHUNKING' )
1079+ expect ( chunking ?. message ) . toContain ( '2 stored document(s) keep their chunks' )
1080+ }
1081+ )
1082+
10511083 check ( 'a create that fails partway is adopted and finished by the next apply' , async ( ) => {
10521084 const workspaceId = await newWorkspace ( )
10531085 const failing = failUpload ( 2 )
0 commit comments