@@ -104,6 +104,7 @@ describe('execution state lookup', () => {
104104 executionId : 'execution-1' ,
105105 workflowId : 'workflow-1' ,
106106 status : 'completed' ,
107+ contentAvailable : true ,
107108 finalOutput : { token : 'raw-secret' } ,
108109 blockLogs : [ ] ,
109110 provenance,
@@ -157,7 +158,7 @@ describe('execution state lookup', () => {
157158 } )
158159 } )
159160
160- it ( 'rejects mismatched bindings, malformed provenance, and nonterminal rows ' , async ( ) => {
161+ it ( 'trusts compacted terminal status while withholding unavailable execution content ' , async ( ) => {
161162 queueTableRows ( schemaMock . workflowExecutionLogs , [
162163 {
163164 executionId : 'execution-1' ,
@@ -168,20 +169,31 @@ describe('execution state lookup', () => {
168169 } ,
169170 ] )
170171 mockMaterializeExecutionData . mockResolvedValueOnce ( {
171- correlation : { copilotToolCallId : 'another-tool-call' } ,
172- executionState : {
173- ...EXECUTION_STATE ,
174- resolvedSecretTraceProvenance : { version : 1 , complete : true , entries : [ ] } ,
172+ correlation : { copilotToolCallId : 'tool-call-1' } ,
173+ executionStateSummary : {
174+ executedBlockCount : 1 ,
175+ blockLogCount : 1 ,
176+ completedLoopCount : 0 ,
177+ activeExecutionPathLength : 0 ,
178+ pendingQueueLength : 0 ,
175179 } ,
180+ finalOutput : { token : 'must-not-cross' } ,
176181 } )
177182
178183 await expect (
179184 getTrustedWorkflowToolExecution ( 'execution-1' , 'workflow-1' , 'tool-call-1' )
180- ) . resolves . toBeNull ( )
185+ ) . resolves . toEqual ( {
186+ executionId : 'execution-1' ,
187+ workflowId : 'workflow-1' ,
188+ status : 'completed' ,
189+ contentAvailable : false ,
190+ } )
191+ } )
181192
193+ it ( 'withholds execution content when persisted provenance is malformed' , async ( ) => {
182194 queueTableRows ( schemaMock . workflowExecutionLogs , [
183195 {
184- executionId : 'execution-2 ' ,
196+ executionId : 'execution-1 ' ,
185197 workflowId : 'workflow-1' ,
186198 workspaceId : 'workspace-1' ,
187199 status : 'completed' ,
@@ -190,19 +202,48 @@ describe('execution state lookup', () => {
190202 ] )
191203 mockMaterializeExecutionData . mockResolvedValueOnce ( {
192204 correlation : { copilotToolCallId : 'tool-call-1' } ,
205+ finalOutput : { token : 'must-not-cross' } ,
193206 executionState : {
194207 ...EXECUTION_STATE ,
195208 resolvedSecretTraceProvenance : { version : 2 , complete : true , entries : [ ] } ,
196209 } ,
197210 } )
198211
199212 await expect (
200- getTrustedWorkflowToolExecution ( 'execution-2' , 'workflow-1' , 'tool-call-1' )
213+ getTrustedWorkflowToolExecution ( 'execution-1' , 'workflow-1' , 'tool-call-1' )
214+ ) . resolves . toEqual ( {
215+ executionId : 'execution-1' ,
216+ workflowId : 'workflow-1' ,
217+ status : 'completed' ,
218+ contentAvailable : false ,
219+ } )
220+ } )
221+
222+ it ( 'rejects mismatched bindings and nonterminal rows' , async ( ) => {
223+ queueTableRows ( schemaMock . workflowExecutionLogs , [
224+ {
225+ executionId : 'execution-1' ,
226+ workflowId : 'workflow-1' ,
227+ workspaceId : 'workspace-1' ,
228+ status : 'completed' ,
229+ executionData : { } ,
230+ } ,
231+ ] )
232+ mockMaterializeExecutionData . mockResolvedValueOnce ( {
233+ correlation : { copilotToolCallId : 'another-tool-call' } ,
234+ executionState : {
235+ ...EXECUTION_STATE ,
236+ resolvedSecretTraceProvenance : { version : 1 , complete : true , entries : [ ] } ,
237+ } ,
238+ } )
239+
240+ await expect (
241+ getTrustedWorkflowToolExecution ( 'execution-1' , 'workflow-1' , 'tool-call-1' )
201242 ) . resolves . toBeNull ( )
202243
203244 queueTableRows ( schemaMock . workflowExecutionLogs , [
204245 {
205- executionId : 'execution-3 ' ,
246+ executionId : 'execution-2 ' ,
206247 workflowId : 'workflow-1' ,
207248 workspaceId : 'workspace-1' ,
208249 status : 'running' ,
@@ -211,7 +252,7 @@ describe('execution state lookup', () => {
211252 ] )
212253
213254 await expect (
214- getTrustedWorkflowToolExecution ( 'execution-3 ' , 'workflow-1' , 'tool-call-1' )
255+ getTrustedWorkflowToolExecution ( 'execution-2 ' , 'workflow-1' , 'tool-call-1' )
215256 ) . resolves . toBeNull ( )
216257 } )
217258
0 commit comments