@@ -13,7 +13,6 @@ import {
1313const {
1414 mockGetTableById,
1515 mockListTables,
16- mockQueryRows,
1716 mockGetOrCreateTableSnapshot,
1817 mockDownloadFile,
1918 mockGeneratePresignedDownloadUrl,
@@ -32,12 +31,10 @@ const {
3231 mockMaterializeCopilotCodeSecrets,
3332 mockHasWorkspaceSandboxAccess,
3433 mockImportWorkspaceFileSecretProvenanceForRuntime,
35- mockLoadTableRowSecretProvenance,
3634 mockIsTableSnapshotSafeForModelMount,
3735} = vi . hoisted ( ( ) => ( {
3836 mockGetTableById : vi . fn ( ) ,
3937 mockListTables : vi . fn ( ) ,
40- mockQueryRows : vi . fn ( ) ,
4138 mockGetOrCreateTableSnapshot : vi . fn ( ) ,
4239 mockDownloadFile : vi . fn ( ) ,
4340 mockGeneratePresignedDownloadUrl : vi . fn ( ) ,
@@ -56,7 +53,6 @@ const {
5653 mockMaterializeCopilotCodeSecrets : vi . fn ( ) ,
5754 mockHasWorkspaceSandboxAccess : vi . fn ( ) ,
5855 mockImportWorkspaceFileSecretProvenanceForRuntime : vi . fn ( ) ,
59- mockLoadTableRowSecretProvenance : vi . fn ( ) ,
6056 mockIsTableSnapshotSafeForModelMount : vi . fn ( ) ,
6157} ) )
6258
@@ -65,10 +61,8 @@ vi.mock('@/lib/table/service', () => ({
6561 getTableById : mockGetTableById ,
6662 listTables : mockListTables ,
6763} ) )
68- vi . mock ( '@/lib/table/rows/service' , ( ) => ( { queryRows : mockQueryRows } ) )
6964vi . mock ( '@/lib/table/rows/secret-provenance' , ( ) => ( {
7065 isTableSnapshotSafeForModelMount : mockIsTableSnapshotSafeForModelMount ,
71- loadTableRowSecretProvenance : mockLoadTableRowSecretProvenance ,
7266} ) )
7367vi . mock ( '@/lib/table/snapshot-cache' , ( ) => ( {
7468 getOrCreateTableSnapshot : mockGetOrCreateTableSnapshot ,
@@ -125,13 +119,12 @@ vi.mock('@/lib/execution/remote-sandbox/workspace-sandboxes', () => ({
125119import { projectToolResultForCopilot } from '@/lib/copilot/request/tools/resolved-secret-result'
126120import { executeFunctionExecute } from '@/lib/copilot/tools/handlers/function-execute'
127121import { executeRunCode } from '@/lib/copilot/tools/handlers/run-code'
128- import { TABLE_LIMITS } from '@/lib/table/constants'
129122import { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
130123
131124const table = {
132125 id : 'tbl_1' ,
133126 workspaceId : 'ws_1' ,
134- rowCount : TABLE_LIMITS . DEFAULT_QUERY_LIMIT + 1 ,
127+ rowCount : 1 ,
135128 schema : { columns : [ { id : 'col_name' , name : 'name' , type : 'string' } ] } ,
136129}
137130
@@ -153,13 +146,7 @@ function resetExecutionMocks(): void {
153146 vi . clearAllMocks ( )
154147 mockExecuteTool . mockReset ( )
155148 mockMaterializeCopilotCodeSecrets . mockReset ( )
156- mockLoadTableRowSecretProvenance . mockReset ( )
157149 mockIsTableSnapshotSafeForModelMount . mockReset ( )
158- mockLoadTableRowSecretProvenance . mockResolvedValue ( {
159- version : 1 ,
160- complete : true ,
161- entries : [ ] ,
162- } )
163150 mockIsTableSnapshotSafeForModelMount . mockResolvedValue ( true )
164151 mockListWorkspaceFiles . mockResolvedValue ( [ ] )
165152 mockListWorkspaceFileFolders . mockResolvedValue ( [ ] )
@@ -572,76 +559,12 @@ describe('executeFunctionExecute table mounts', () => {
572559 resetExecutionMocks ( )
573560 mockExecuteTool . mockResolvedValue ( { success : true } )
574561 mockGetTableById . mockResolvedValue ( table )
575- // Row data is keyed by stable column id at rest, not display name.
576- mockQueryRows . mockResolvedValue ( { rows : [ { data : { col_name : 'Ada' } } ] } )
577562 mockHasCloudStorage . mockReturnValue ( true )
578563 mockGeneratePresignedDownloadUrl . mockResolvedValue ( 'https://s3.example/presigned?sig=abc' )
579564 } )
580565
581- it ( 'mounts a table at the inline row limit without truncation' , async ( ) => {
582- mockGetTableById . mockResolvedValue ( { ...table , rowCount : TABLE_LIMITS . DEFAULT_QUERY_LIMIT } )
583-
584- await executeFunctionExecute ( { inputTables : [ 'tbl_1' ] } , context as never )
585-
586- expect ( mockQueryRows ) . toHaveBeenCalledWith (
587- expect . objectContaining ( { id : 'tbl_1' } ) ,
588- { limit : TABLE_LIMITS . DEFAULT_QUERY_LIMIT } ,
589- 'copilot-fn-exec'
590- )
591- expect ( mockGetOrCreateTableSnapshot ) . not . toHaveBeenCalled ( )
592- const files = mountedFiles ( )
593- expect ( files [ 0 ] . path ) . toBe ( '/home/user/tables/tbl_1.csv' )
594- expect ( files [ 0 ] . content ) . toBe ( 'name\nAda' )
595- } )
596-
597- it ( 'mounts CSV with display-name headers and id-keyed values, never column ids' , async ( ) => {
598- mockGetTableById . mockResolvedValue ( {
599- id : 'tbl_2' ,
600- workspaceId : 'ws_1' ,
601- rowCount : 2 ,
602- schema : {
603- columns : [
604- { id : 'col_name' , name : 'name' , type : 'string' } ,
605- { id : 'col_company' , name : 'company' , type : 'string' } ,
606- ] ,
607- } ,
608- } )
609- mockQueryRows . mockResolvedValue ( {
610- rows : [
611- { data : { col_name : 'Ada' , col_company : 'Analytical Engine' } } ,
612- { data : { col_name : 'Grace' , col_company : 'Navy, Inc' } } ,
613- ] ,
614- } )
615-
616- await executeFunctionExecute ( { inputTables : [ 'tbl_2' ] } , context as never )
617-
618- const csv = mountedFiles ( ) [ 0 ] . content as string
619- const lines = csv . split ( '\n' )
620- expect ( lines [ 0 ] ) . toBe ( 'name,company' )
621- expect ( lines [ 1 ] ) . toBe ( 'Ada,Analytical Engine' )
622- // Value containing a comma is quoted.
623- expect ( lines [ 2 ] ) . toBe ( 'Grace,"Navy, Inc"' )
624- // No stable column id leaks into the mounted file.
625- expect ( csv ) . not . toContain ( 'col_name' )
626- expect ( csv ) . not . toContain ( 'col_company' )
627- } )
628-
629- it ( 'reads values by column id for legacy name-keyed rows too' , async ( ) => {
630- // Legacy column with no id: getColumnId falls back to name, so name-keyed data is correct.
631- mockGetTableById . mockResolvedValue ( {
632- id : 'tbl_legacy' ,
633- workspaceId : 'ws_1' ,
634- rowCount : 1 ,
635- schema : { columns : [ { name : 'email' , type : 'string' } ] } ,
636- } )
637- mockQueryRows . mockResolvedValue ( { rows : [ { data : { email : 'a@b.com' } } ] } )
638-
639- await executeFunctionExecute ( { inputTables : [ 'tbl_legacy' ] } , context as never )
640-
641- expect ( mountedFiles ( ) [ 0 ] . content ) . toBe ( 'email\na@b.com' )
642- } )
643-
644- it ( 'mounts a table above the inline row limit by presigned snapshot URL' , async ( ) => {
566+ it ( 'mounts every table by presigned snapshot URL' , async ( ) => {
567+ mockGetTableById . mockResolvedValue ( { ...table , rowCount : 0 } )
645568 mockGetOrCreateTableSnapshot . mockResolvedValue ( {
646569 key : 'table-snapshots/ws_1/tbl_1/v5.csv' ,
647570 size : 9 ,
@@ -651,7 +574,6 @@ describe('executeFunctionExecute table mounts', () => {
651574 await executeFunctionExecute ( { inputTables : [ 'tbl_1' ] } , context as never )
652575
653576 expect ( mockGetOrCreateTableSnapshot ) . toHaveBeenCalledTimes ( 1 )
654- expect ( mockQueryRows ) . not . toHaveBeenCalled ( )
655577 expect ( mockDownloadFile ) . not . toHaveBeenCalled ( )
656578 expect ( mockGeneratePresignedDownloadUrl ) . toHaveBeenCalledWith (
657579 'table-snapshots/ws_1/tbl_1/v5.csv' ,
@@ -715,35 +637,6 @@ describe('executeFunctionExecute table mounts', () => {
715637 expect ( projectToolResultForCopilot ( result , parentRegistry ) ) . toEqual ( { success : true } )
716638 } )
717639
718- it ( 'unknown inline row provenance still mounts and taints model egress' , async ( ) => {
719- mockGetTableById . mockResolvedValue ( { ...table , rowCount : TABLE_LIMITS . DEFAULT_QUERY_LIMIT } )
720- mockLoadTableRowSecretProvenance . mockResolvedValue ( {
721- version : 1 ,
722- complete : false ,
723- entries : [ ] ,
724- } )
725- mockExecuteTool . mockResolvedValue ( { success : true , output : { result : 'raw output' } } )
726- const parentRegistry = new ResolvedSecretTraceRegistry ( [ ] , {
727- userId : 'u1' ,
728- workspaceId : 'ws_1' ,
729- } )
730-
731- const result = await executeFunctionExecute (
732- { inputTables : [ 'tbl_1' ] } ,
733- { ...context , resolvedSecretTraceRegistry : parentRegistry }
734- )
735-
736- expect ( mountedFiles ( ) [ 0 ] . content ) . toBe ( 'name\nAda' )
737- expect ( mockExecuteTool . mock . calls [ 0 ] ?. [ 1 ] ?. [ PRIVATE_SECRET_PROVENANCE_FIELD ] ) . toEqual ( {
738- version : 1 ,
739- complete : false ,
740- selections : [ ] ,
741- } )
742- expect ( result ) . toEqual ( { success : true , output : { result : 'raw output' } } )
743- expect ( parentRegistry . isComplete ( ) ) . toBe ( false )
744- expect ( projectToolResultForCopilot ( result , parentRegistry ) ) . toEqual ( { success : true } )
745- } )
746-
747640 it ( 'throws when a cloud snapshot exceeds the table mount limit' , async ( ) => {
748641 mockGetOrCreateTableSnapshot . mockResolvedValue ( {
749642 key : 'table-snapshots/ws_1/tbl_1/v5.csv' ,
0 commit comments