(
ancestorWorkspaceId: string,
taskId: string
)
| 6334 | } |
| 6335 | |
| 6336 | async isWorkflowOwnedDescendantAgentTask( |
| 6337 | ancestorWorkspaceId: string, |
| 6338 | taskId: string |
| 6339 | ): Promise<boolean> { |
| 6340 | assert( |
| 6341 | ancestorWorkspaceId.length > 0, |
| 6342 | "isWorkflowOwnedDescendantAgentTask: ancestorWorkspaceId required" |
| 6343 | ); |
| 6344 | assert(taskId.length > 0, "isWorkflowOwnedDescendantAgentTask: taskId required"); |
| 6345 | |
| 6346 | const cfg = this.config.loadConfigOrDefault(); |
| 6347 | const indexResult = this.getWorkflowOwnedDescendantAgentTaskUsingIndex( |
| 6348 | this.buildAgentTaskIndex(cfg), |
| 6349 | ancestorWorkspaceId, |
| 6350 | taskId |
| 6351 | ); |
| 6352 | if (indexResult != null) { |
| 6353 | return indexResult; |
| 6354 | } |
| 6355 | |
| 6356 | const cached = this.completedReportsByTaskId.get(taskId); |
| 6357 | if (hasWorkflowOwnedAncestorWorkspaceId(cached, ancestorWorkspaceId)) { |
| 6358 | return true; |
| 6359 | } |
| 6360 | if (hasAncestorWorkspaceId(cached, ancestorWorkspaceId)) { |
| 6361 | return false; |
| 6362 | } |
| 6363 | |
| 6364 | const sessionDir = this.config.getSessionDir(ancestorWorkspaceId); |
| 6365 | const persisted = await readSubagentReportArtifactsFile(sessionDir); |
| 6366 | const entry = persisted.artifactsByChildTaskId[taskId]; |
| 6367 | if (entry != null) { |
| 6368 | return hasWorkflowOwnedAncestorWorkspaceId(entry, ancestorWorkspaceId); |
| 6369 | } |
| 6370 | |
| 6371 | // A workflow-owned child that failed terminally leaves only a failure |
| 6372 | // artifact. It must stay excluded from direct task_await after cleanup, |
| 6373 | // matching live behavior: its failure is consumed through the workflow run. |
| 6374 | const failures = await readSubagentFailureArtifactsFile(sessionDir); |
| 6375 | return hasWorkflowOwnedAncestorWorkspaceId( |
| 6376 | failures.failuresByChildTaskId[taskId], |
| 6377 | ancestorWorkspaceId |
| 6378 | ); |
| 6379 | } |
| 6380 | |
| 6381 | private getWorkflowOwnedDescendantAgentTaskUsingIndex( |
| 6382 | index: AgentTaskIndex, |
no test coverage detected