@zq-silk/yui 0.15.7 → 0.15.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/ARCHITECTURE.md +194 -399
  2. package/ARCHITECTURE.zh-CN.md +151 -0
  3. package/README.md +306 -1131
  4. package/dist/agent/adapterCatalog.js +15 -2
  5. package/dist/agent/agent.js +23 -3
  6. package/dist/agent/argumentPolicy.js +7 -1
  7. package/dist/agent/connectionPlan.js +62 -0
  8. package/dist/agent/executionComponents.js +158 -0
  9. package/dist/agent/launchEnvironment.js +31 -3
  10. package/dist/agent/managedRuntimeEnvironment.js +3 -5
  11. package/dist/{turn/turn.js → agentRun/agentRun.js} +166 -109
  12. package/dist/{turn/turnIdentity.js → agentRun/runIdentity.js} +4 -4
  13. package/dist/artifacts/artifactCapability.js +74 -0
  14. package/dist/artifacts/artifactCommitLock.js +249 -0
  15. package/dist/artifacts/artifactPaths.js +151 -0
  16. package/dist/artifacts/gitArtifactRef.js +146 -0
  17. package/dist/artifacts/managedGit.js +332 -0
  18. package/dist/artifacts/taskArtifactRepository.js +277 -0
  19. package/dist/brief/taskBrief.js +12 -0
  20. package/dist/cli/agentConfigurationPicker.js +13 -0
  21. package/dist/cli/commandCatalog.js +165 -74
  22. package/dist/cli/interactionCandidates.js +5 -5
  23. package/dist/cli/interactionPolicy.js +38 -8
  24. package/dist/cli/invocationRouter.js +1 -1
  25. package/dist/cli/managedDiagnostics.js +28 -0
  26. package/dist/cli/operatorWizard.js +1 -7
  27. package/dist/cli/roleOptionOrder.js +27 -0
  28. package/dist/cli/roleWizard.js +50 -14
  29. package/dist/cli/updateOrchestrator.js +1 -1
  30. package/dist/cli/updatePorts.js +3 -4
  31. package/dist/cli.js +245 -95
  32. package/dist/commands/agentCommands.js +72 -14
  33. package/dist/commands/capabilityCommands.js +9 -6
  34. package/dist/commands/configCommands.js +20 -20
  35. package/dist/commands/deliveryGuardPreflight.js +2 -2
  36. package/dist/commands/executionAuditCommands.js +24 -24
  37. package/dist/commands/globalRoleCommands.js +1 -1
  38. package/dist/commands/grantCommands.js +4 -4
  39. package/dist/commands/operatorCommands.js +34 -9
  40. package/dist/commands/projectCommands.js +4 -4
  41. package/dist/commands/resourcesCommands.js +2 -2
  42. package/dist/commands/roleConfiguration.js +25 -5
  43. package/dist/commands/roleRuntimeGuard.js +4 -5
  44. package/dist/commands/sessionCommands.js +3 -7
  45. package/dist/commands/taskActivationCommands.js +281 -0
  46. package/dist/commands/taskActor.js +28 -49
  47. package/dist/commands/taskCommands.js +1461 -720
  48. package/dist/commands/taskContextCommand.js +39 -583
  49. package/dist/commands/taskExecutionCommands.js +32 -32
  50. package/dist/commands/taskInputCommands.js +40 -104
  51. package/dist/commands/taskIntegrationCommands.js +3 -2
  52. package/dist/commands/taskIntegrationQueueCommands.js +1 -1
  53. package/dist/commands/taskNextActionCommand.js +8 -8
  54. package/dist/commands/taskOverviewCommand.js +33 -45
  55. package/dist/commands/taskRemoteDeliveryCommand.js +2 -2
  56. package/dist/commands/taskRoleRuntimeStatus.js +133 -102
  57. package/dist/commands/telemetryCommands.js +36 -38
  58. package/dist/config/configCatalog.js +4 -4
  59. package/dist/config/yuiConfig.js +8 -8
  60. package/dist/context/contextSnapshot.js +10 -10
  61. package/dist/context/dispatchContext.js +11 -11
  62. package/dist/context/roleSessionContext.js +6 -3
  63. package/dist/context/{turnContextPack.js → runContextPack.js} +158 -81
  64. package/dist/context/{turnInputContract.js → runInputContract.js} +73 -60
  65. package/dist/context/sessionBootstrapManifest.js +21 -2
  66. package/dist/context/sourceRunContext.js +30 -0
  67. package/dist/context/taskContext.js +481 -0
  68. package/dist/context/wakeNotification.js +27 -27
  69. package/dist/controller/agentRuntimeObserver.js +21 -24
  70. package/dist/controller/capabilityBridge.js +17 -6
  71. package/dist/controller/clientRuntime.js +65 -92
  72. package/dist/controller/controller.js +120 -188
  73. package/dist/controller/fileSchedulerStoreAdapter.js +787 -887
  74. package/dist/controller/jobControl.js +54 -85
  75. package/dist/controller/resourceInventory.js +8 -27
  76. package/dist/controller/resourceInventoryLinux.js +12 -13
  77. package/dist/controller/runtime.js +529 -479
  78. package/dist/controller/runtimeEventInbox.js +55 -25
  79. package/dist/controller/runtimeEventProcessor.js +22 -31
  80. package/dist/controller/{runtimeHookTurnFence.js → runtimeHookRunFence.js} +91 -115
  81. package/dist/controller/runtimeLaunchCoordinator.js +80 -426
  82. package/dist/controller/runtimeObservationHook.js +14 -18
  83. package/dist/controller/sessionNotify.js +16 -24
  84. package/dist/controller/sessionOwnerReconciliation.js +168 -50
  85. package/dist/controller/structuredProviderObservation.js +138 -99
  86. package/dist/coordination/workMailbox.js +3 -3
  87. package/dist/coordination/workMailboxQueue.js +36 -33
  88. package/dist/core/boundedRpc.js +8 -1
  89. package/dist/core/controllerClient.js +20 -1
  90. package/dist/core/controllerServer.js +4 -4
  91. package/dist/doctor/doctor.js +13 -2
  92. package/dist/domain/agentResultTransport.js +9 -9
  93. package/dist/execution/codexThreadNaming.js +2 -8
  94. package/dist/execution/executionHealth.js +51 -63
  95. package/dist/execution/reviewMainRun.js +137 -0
  96. package/dist/execution/workItemExecution.js +28 -29
  97. package/dist/execution/workItemExecutionProjection.js +99 -107
  98. package/dist/execution/workItemMainRun.js +141 -0
  99. package/dist/executor/agentAdapter.js +227 -20
  100. package/dist/executor/agentConfigurationCatalog.js +126 -4
  101. package/dist/executor/agentConfigurationProbe.js +162 -4
  102. package/dist/executor/agentExecutor.js +79 -78
  103. package/dist/executor/effectiveLaunch.js +105 -18
  104. package/dist/executor/executorRegistry.js +29 -44
  105. package/dist/executor/fileRoleLaunchPlanner.js +229 -154
  106. package/dist/executor/workspacePreflightClassification.js +16 -16
  107. package/dist/grant/capabilityGrant.js +6 -3
  108. package/dist/input/inputRequest.js +12 -10
  109. package/dist/integration/gitIntegrationService.js +4 -11
  110. package/dist/integration/integrationQueueService.js +4 -4
  111. package/dist/interaction/operatorPresentation.js +1 -1
  112. package/dist/kernel/builtinCapabilities.js +255 -12
  113. package/dist/kernel/capabilityRegistry.js +64 -18
  114. package/dist/kernel/instanceHost.js +12 -1
  115. package/dist/kernel/kernelPorts.js +2 -2
  116. package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
  117. package/dist/lifecycle/exactRunTerminalization.js +449 -0
  118. package/dist/message/message.js +118 -6
  119. package/dist/message/messageContinuation.js +204 -0
  120. package/dist/observability/executionAudit.js +70 -72
  121. package/dist/observability/faultClassification.js +2 -2
  122. package/dist/observability/orchestrationMetrics.js +8 -8
  123. package/dist/operator/operatorSessionHistory.js +1 -7
  124. package/dist/output/agentConfigurationPresentation.js +8 -3
  125. package/dist/output/agentRunConfigurationPresentation.js +128 -0
  126. package/dist/output/rolePresentation.js +54 -3
  127. package/dist/plugins/pluginChild.js +104 -0
  128. package/dist/plugins/pluginIntent.js +26 -0
  129. package/dist/plugins/pluginInterpreter.js +43 -0
  130. package/dist/plugins/pluginPackage.js +101 -0
  131. package/dist/plugins/pluginProcess.js +112 -0
  132. package/dist/plugins/pluginService.js +388 -0
  133. package/dist/profile/agentProfile.js +1 -1
  134. package/dist/repository/gitWorkspace.js +26 -4
  135. package/dist/repository/project.js +19 -4
  136. package/dist/repository/taskBaseFreshness.js +13 -13
  137. package/dist/repository/taskWorkspaceCoordinator.js +20 -27
  138. package/dist/repository/taskWorkspacePreparer.js +344 -83
  139. package/dist/resources/autoResourceGc.js +3 -3
  140. package/dist/resources/liveReferences.js +3 -3
  141. package/dist/resources/projectResource.js +75 -0
  142. package/dist/resources/projectResourceService.js +343 -0
  143. package/dist/resources/resourceDiscovery.js +6 -6
  144. package/dist/resources/resourceGc.js +1 -1
  145. package/dist/resources/resourceRegistrar.js +1 -1
  146. package/dist/resources/resourceTypes.js +1 -1
  147. package/dist/review/deltaRecheck.js +3 -3
  148. package/dist/review/reviewAcceptance.js +16 -16
  149. package/dist/review/reviewDecision.js +7 -7
  150. package/dist/review/reviewRound.js +21 -20
  151. package/dist/review/reviewerAvailability.js +2 -2
  152. package/dist/role/role.js +51 -7
  153. package/dist/role/taskRoleUpdate.js +30 -0
  154. package/dist/runtime/acpProtocol.js +425 -0
  155. package/dist/runtime/acpSession.js +731 -0
  156. package/dist/runtime/acpSessionConfiguration.js +260 -0
  157. package/dist/runtime/agentDriver.js +30 -11
  158. package/dist/runtime/agentEndpoint.js +278 -0
  159. package/dist/runtime/agentEndpointIdentity.js +86 -0
  160. package/dist/runtime/agentEndpointOwnership.js +239 -0
  161. package/dist/runtime/agentError.js +2 -10
  162. package/dist/runtime/agentHost.js +565 -314
  163. package/dist/runtime/agentRunConfiguration.js +258 -0
  164. package/dist/runtime/builtinAgentDrivers.js +134 -18
  165. package/dist/runtime/builtinAgentErrorMappers.js +55 -3
  166. package/dist/runtime/builtinTranscriptUsage.js +1 -1
  167. package/dist/runtime/claude-process-owner +0 -0
  168. package/dist/runtime/codexAppServerRuntime.js +38 -30
  169. package/dist/runtime/codexInteractiveHost.js +41 -6
  170. package/dist/runtime/continuationManager.js +2 -6
  171. package/dist/runtime/executionEnvironment.js +30 -0
  172. package/dist/runtime/firstProgressAdvisory.js +11 -11
  173. package/dist/runtime/index.js +4 -3
  174. package/dist/runtime/jsonLineChannel.js +109 -0
  175. package/dist/runtime/launchBroker.js +91 -16
  176. package/dist/runtime/launchDiagnostics.js +2 -2
  177. package/dist/runtime/lifecycleReservation.js +10 -18
  178. package/dist/runtime/managedCaller.js +61 -17
  179. package/dist/runtime/nativeSessionControl.js +102 -0
  180. package/dist/runtime/ports.js +6 -21
  181. package/dist/runtime/processExitObservation.js +8 -7
  182. package/dist/runtime/promptEnvelope.js +17 -6
  183. package/dist/runtime/providerContinuation.js +3 -9
  184. package/dist/runtime/providerContinuationReconciliationService.js +4 -13
  185. package/dist/runtime/providerControl.js +2 -7
  186. package/dist/runtime/providerRuntimeIdentity.js +110 -222
  187. package/dist/runtime/providerRuntimeReconciler.js +5 -9
  188. package/dist/runtime/runtimeBinding.js +0 -1
  189. package/dist/runtime/runtimeContinuationProjection.js +4 -7
  190. package/dist/runtime/runtimeDeadlines.js +9 -0
  191. package/dist/runtime/runtimeHealthPolicy.js +1 -1
  192. package/dist/runtime/runtimeObservation.js +29 -65
  193. package/dist/runtime/runtimeProjection.js +43 -51
  194. package/dist/runtime/runtimeSessionCandidate.js +1 -3
  195. package/dist/runtime/sessionLaunchRequest.js +3 -7
  196. package/dist/runtime/sessionOwnerIdentity.js +7 -54
  197. package/dist/runtime/sessionOwnerRegistry.js +22 -17
  198. package/dist/runtime/sessionReconciliation.js +4 -8
  199. package/dist/runtime/sessionTerminationGuard.js +70 -259
  200. package/dist/runtime/sessionTokenMetrics.js +5 -16
  201. package/dist/runtime/structuredProviderHost.js +237 -117
  202. package/dist/runtime/taskRuntimeIsolation.js +39 -122
  203. package/dist/runtime/tmuxAdapters.js +39 -86
  204. package/dist/scheduler/activeRoleRunDelivery.js +354 -0
  205. package/dist/scheduler/leaderWakeupProcessor.js +75 -266
  206. package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
  207. package/dist/scheduler/ports.js +80 -9
  208. package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
  209. package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
  210. package/dist/scheduler/taskExecutionProjection.js +120 -124
  211. package/dist/scheduler/taskObservabilityProjection.js +29 -29
  212. package/dist/scheduler/taskWake.js +11 -4
  213. package/dist/scheduler/wakeReason.js +9 -1
  214. package/dist/setup/setupCommand.js +3 -7
  215. package/dist/storage/migrations/agentRunContract.js +159 -0
  216. package/dist/storage/migrations/artifactsToGit.js +338 -0
  217. package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
  218. package/dist/storage/migrations/submitIntent.js +126 -0
  219. package/dist/storage/sqliteSchema.js +467 -7
  220. package/dist/storage/sqliteStore.js +355 -220
  221. package/dist/storage/storageVersions.js +1 -1
  222. package/dist/storage/storeRpc.js +10 -5
  223. package/dist/storage/taskStore.js +13 -11
  224. package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
  225. package/dist/surface/surfaceContributions.js +102 -0
  226. package/dist/task/completionReadiness.js +32 -6
  227. package/dist/task/deliveryGuard.js +16 -16
  228. package/dist/task/draftPlan.js +72 -12
  229. package/dist/task/nextAction.js +144 -128
  230. package/dist/task/remoteDelivery.js +6 -6
  231. package/dist/task/task.js +184 -18
  232. package/dist/task/taskActivation.js +327 -0
  233. package/dist/task/taskActivationService.js +408 -0
  234. package/dist/task/taskRecordReference.js +5 -4
  235. package/dist/task/taskRecordRetirement.js +1 -1
  236. package/dist/task/taskSubmission.js +236 -0
  237. package/dist/telemetry/sqliteTelemetryStore.js +55 -68
  238. package/dist/telemetry/telemetryConfig.js +14 -14
  239. package/dist/telemetry/telemetryWiring.js +2 -2
  240. package/dist/web/assets/assetManifest.js +2 -0
  241. package/dist/web/assets/client/app.js +121 -20
  242. package/dist/web/assets/client/components.js +87 -54
  243. package/dist/web/assets/client/i18n.js +83 -41
  244. package/dist/web/assets/client/markdown.js +1 -1
  245. package/dist/web/assets/client/taskSurface.js +442 -0
  246. package/dist/web/assets/client/view.js +49 -44
  247. package/dist/web/assets/shell.js +1 -1
  248. package/dist/web/assets/styles/cards.js +22 -4
  249. package/dist/web/controllerWeb.js +60 -0
  250. package/dist/web/webMutation.js +28 -0
  251. package/dist/web/webServer.js +133 -8
  252. package/dist/web/webSnapshot.js +81 -74
  253. package/dist/web/webTaskSurface.js +64 -0
  254. package/dist/workItem/dependencyGate.js +1 -1
  255. package/dist/workItem/workItem.js +84 -48
  256. package/dist/workspace/workItemChangeSetManager.js +16 -9
  257. package/docs/agent-result-consumption.md +96 -0
  258. package/docs/agent-result-consumption.zh-CN.md +81 -0
  259. package/docs/agent-runtime-drivers.md +93 -0
  260. package/docs/agent-runtime-drivers.zh-CN.md +77 -0
  261. package/docs/architecture/README.md +50 -0
  262. package/docs/architecture/README.zh-CN.md +43 -0
  263. package/docs/architecture/capabilities-and-resources.md +118 -0
  264. package/docs/architecture/capabilities-and-resources.zh-CN.md +83 -0
  265. package/docs/managed-turn-and-session-runtime.md +224 -0
  266. package/docs/managed-turn-and-session-runtime.zh-CN.md +180 -0
  267. package/docs/observability/README.md +83 -0
  268. package/docs/observability/README.zh-CN.md +71 -0
  269. package/docs/plugin-sdk.md +393 -0
  270. package/docs/plugin-sdk.zh-CN.md +293 -0
  271. package/docs/provider-runtime.md +165 -0
  272. package/docs/provider-runtime.zh-CN.md +132 -0
  273. package/docs/release-workflow.md +305 -0
  274. package/docs/release-workflow.zh-CN.md +237 -0
  275. package/docs/roles-and-configuration.md +115 -0
  276. package/docs/roles-and-configuration.zh-CN.md +96 -0
  277. package/docs/sqlite-control-plane-design.md +78 -0
  278. package/docs/sqlite-control-plane-design.zh-CN.md +62 -0
  279. package/docs/task-dag-semantics.md +80 -0
  280. package/docs/task-dag-semantics.zh-CN.md +59 -0
  281. package/docs/task-delivery.md +105 -0
  282. package/docs/task-delivery.zh-CN.md +82 -0
  283. package/docs/task-local-identity.md +8 -6
  284. package/docs/task-local-identity.zh-CN.md +58 -0
  285. package/docs/testing/verification-levels.md +88 -0
  286. package/docs/testing/verification-levels.zh-CN.md +69 -0
  287. package/i18n/README.zh-CN.md +270 -722
  288. package/package.json +3 -2
  289. package/skills/yui-leader/SKILL.md +88 -304
  290. package/skills/yui-leader/references/execution.md +303 -0
  291. package/skills/yui-leader/references/integration.md +39 -0
  292. package/skills/yui-leader/references/planning.md +109 -0
  293. package/skills/yui-leader/references/replicated-execution.md +42 -0
  294. package/skills/yui-leader/references/task-plugins.md +37 -0
  295. package/skills/yui-operator/SKILL.md +46 -62
  296. package/skills/yui-reviewer/SKILL.md +35 -36
  297. package/skills/yui-runtime/SKILL.md +88 -24
  298. package/skills/yui-runtime/references/publication.md +22 -0
  299. package/skills/yui-runtime/references/recovery.md +64 -0
  300. package/skills/yui-worker/SKILL.md +37 -39
  301. package/dist/cli/roleOptionCatalog.js +0 -68
  302. package/dist/context/sourceTurnContext.js +0 -30
  303. package/dist/execution/reviewMainTurn.js +0 -161
  304. package/dist/execution/workItemMainTurn.js +0 -164
  305. package/dist/lifecycle/exactTurnTerminalization.js +0 -407
  306. package/dist/runtime/preallocatedNativeSession.js +0 -13
  307. package/dist/runtime/runtimeStopReceipt.js +0 -42
  308. package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
@@ -1,9 +1,11 @@
1
1
  import { operationalTaskRecords } from "../task/taskRecordRetirement.js";
2
+ import { runtimeObservationFromTaskEvent } from "../runtime/runtimeObservation.js";
3
+ import { taskOwnsManagedWorkspace } from "../task/task.js";
2
4
  import { currentWorkItemExecutionGroup } from "../workItem/workItem.js";
3
5
  import { mailboxBatches } from "../coordination/workMailbox.js";
4
6
  import { actionableExecutionLaneRecoveries, summarizeExecutionGroupHealth } from "../execution/executionHealth.js";
5
7
  import { buildTaskObservabilityProjection } from "./taskObservabilityProjection.js";
6
- import { isRoleTurnStalled, latestStallProgressAt } from "./roleTurnStall.js";
8
+ import { isRoleRunStalled, latestStallProgressAt } from "./roleRunStall.js";
7
9
  import { resolveRuntimeHealth } from "../config/yuiConfig.js";
8
10
  import { projectSessionTokenMetrics, resolveSessionTokenIdentity } from "../runtime/sessionTokenMetrics.js";
9
11
  /**
@@ -17,7 +19,7 @@ export function buildTaskExecutionProjection(store, taskId, taskOverride, now =
17
19
  return null;
18
20
  const roles = store.listRoles?.(taskId) ?? [];
19
21
  const events = store.listEvents?.(taskId) ?? [];
20
- const turns = operationalTaskRecords(store.listTurns?.(taskId) ?? [], events, "turn");
22
+ const runs = operationalTaskRecords(store.listRuns?.(taskId) ?? [], events, "run");
21
23
  const leaderMailbox = store.getWorkMailbox?.({
22
24
  kind: "role",
23
25
  taskId,
@@ -32,10 +34,14 @@ export function buildTaskExecutionProjection(store, taskId, taskOverride, now =
32
34
  return projectTaskExecution({
33
35
  task,
34
36
  roles,
35
- turns,
37
+ runs,
38
+ runDelivery: Object.fromEntries(runs.map((run) => {
39
+ const observed = store.getTaskRoleSessionSet?.(taskId, run.roleName)?.providerBinding?.run;
40
+ return [run.id, observed?.runId === run.id ? observed.status : "unobserved"];
41
+ })),
36
42
  executionGroups: store.listWorkItems === undefined && store.listReviewRounds === undefined
37
43
  ? []
38
- : collectExecutionGroups(store.listWorkItems?.(taskId) ?? [], store.listReviewRounds?.(taskId) ?? [], turns),
44
+ : collectExecutionGroups(store.listWorkItems?.(taskId) ?? [], store.listReviewRounds?.(taskId) ?? [], runs),
39
45
  workItems: store.listWorkItems?.(taskId) ?? [],
40
46
  ...(store.listContextSnapshots === undefined
41
47
  ? {}
@@ -67,22 +73,22 @@ export function buildTaskExecutionProjection(store, taskId, taskOverride, now =
67
73
  * unchanged revision.
68
74
  */
69
75
  export function projectTaskExecutionFromFacts(facts) {
70
- const turns = operationalTaskRecords(facts.turns, facts.events ?? [], "turn");
76
+ const runs = operationalTaskRecords(facts.runs, facts.events ?? [], "run");
71
77
  const executionGroups = facts.executionGroups
72
- ?? collectExecutionGroups(facts.workItems ?? [], facts.reviewRounds ?? [], turns);
78
+ ?? collectExecutionGroups(facts.workItems ?? [], facts.reviewRounds ?? [], runs);
73
79
  return projectTaskExecution({
74
80
  ...facts,
75
- turns,
81
+ runs,
76
82
  executionGroups
77
83
  });
78
84
  }
79
85
  export function projectTaskExecution(facts) {
80
- const { task, roles, turns, workItems = [], inputRequests = [], reviewRounds = [], integrations = [], events = [], pendingWakeup = null, leaderMailbox = null, leaderFailure = null, roleSessions = [], executionGroups = [] } = facts;
86
+ const { task, roles, runs, workItems = [], inputRequests = [], reviewRounds = [], integrations = [], events = [], pendingWakeup = null, leaderMailbox = null, leaderFailure = null, roleSessions = [], executionGroups = [] } = facts;
81
87
  const now = facts.now ?? new Date();
82
88
  const groupSummaries = executionGroups.map((group) => {
83
89
  return summarizeExecutionGroupHealth({
84
90
  group,
85
- turns,
91
+ runs,
86
92
  sessions: roleSessions,
87
93
  events,
88
94
  now,
@@ -103,7 +109,7 @@ export function projectTaskExecution(facts) {
103
109
  const observability = buildTaskObservabilityProjection({
104
110
  workItems,
105
111
  executionGroups: observabilityGroups,
106
- turns,
112
+ runs,
107
113
  events,
108
114
  contextSnapshots: facts.contextSnapshots,
109
115
  sessionTokens,
@@ -115,24 +121,34 @@ export function projectTaskExecution(facts) {
115
121
  executionGroups: groupSummaries,
116
122
  observability
117
123
  });
118
- const activeTurns = turns.filter((turn) => turn.status === "active");
119
- const turnHasSession = (turn) => roleSessions.some((session) => (session.roleName === turn.roleName
120
- && session.agentId === turn.effective.agentId
124
+ const activeRuns = runs.filter((run) => run.status === "active");
125
+ const deliveryOf = (run) => {
126
+ const known = facts.runDelivery?.[run.id];
127
+ if (known !== undefined && known !== "unobserved")
128
+ return known;
129
+ const observed = events.map(runtimeObservationFromTaskEvent).filter((event) => event?.fence.runId === run.id && event.authority !== "transport"
130
+ && ["turn.accepted", "turn.completed", "turn.failed", "turn.cancelled"].includes(event.kind)).at(-1);
131
+ return observed === undefined || observed === null ? "unobserved"
132
+ : observed.kind.slice("run.".length);
133
+ };
134
+ const runHasSession = (run) => roleSessions.some((session) => (session.roleName === run.roleName
135
+ && session.agentId === run.effective.agentId
121
136
  && session.status !== "ended"));
122
- const activeTurnViews = activeTurns.map((turn) => ({
123
- id: turn.id,
124
- roleName: turn.roleName,
125
- purpose: turn.purpose,
126
- providerSession: turnHasSession(turn) ? "active" : "starting",
127
- status: turn.status,
128
- ...(turn.workItemId === undefined ? {} : { workItemId: turn.workItemId }),
129
- ...(turn.reviewRoundId === undefined ? {} : { reviewRoundId: turn.reviewRoundId }),
130
- ...(turn.executionGroupId === undefined ? {} : { executionGroupId: turn.executionGroupId }),
131
- ...(turn.executionLaneId === undefined ? {} : { executionLaneId: turn.executionLaneId })
137
+ const activeRunViews = activeRuns.map((run) => ({
138
+ id: run.id,
139
+ roleName: run.roleName,
140
+ purpose: run.purpose,
141
+ providerSession: runHasSession(run) ? "active" : "starting",
142
+ status: run.status,
143
+ delivery: deliveryOf(run),
144
+ ...(run.workItemId === undefined ? {} : { workItemId: run.workItemId }),
145
+ ...(run.reviewRoundId === undefined ? {} : { reviewRoundId: run.reviewRoundId }),
146
+ ...(run.executionGroupId === undefined ? {} : { executionGroupId: run.executionGroupId }),
147
+ ...(run.executionLaneId === undefined ? {} : { executionLaneId: run.executionLaneId })
132
148
  }));
133
149
  const monitoring = task.executionGate.state === "stopped"
134
150
  || task.status === "completed"
135
- || task.status === "retired"
151
+ || task.status === "cancelled"
136
152
  || task.status === "archived"
137
153
  ? "stopped"
138
154
  : "active";
@@ -147,7 +163,7 @@ export function projectTaskExecution(facts) {
147
163
  reason: "execution-stopped",
148
164
  monitoring,
149
165
  failClosed: false,
150
- activeTurns: activeTurnViews,
166
+ activeRuns: activeRunViews,
151
167
  attention: [],
152
168
  blockers: [],
153
169
  pendingWakeup
@@ -163,7 +179,7 @@ export function projectTaskExecution(facts) {
163
179
  reason: "task-terminal",
164
180
  monitoring,
165
181
  failClosed: false,
166
- activeTurns: activeTurnViews,
182
+ activeRuns: activeRunViews,
167
183
  attention: [],
168
184
  blockers: [],
169
185
  pendingWakeup
@@ -172,7 +188,7 @@ export function projectTaskExecution(facts) {
172
188
  const attention = collectAttention({
173
189
  task,
174
190
  roles,
175
- activeTurns,
191
+ activeRuns,
176
192
  events,
177
193
  leaderFailure,
178
194
  roleSessions,
@@ -180,18 +196,19 @@ export function projectTaskExecution(facts) {
180
196
  });
181
197
  const openInputs = inputRequests.filter((request) => request.status === "open");
182
198
  const blockers = collectBlockers(workItems, reviewRounds, integrations, openInputs, task);
183
- const activeExecutionTurns = activeTurns.filter((turn) => turn.purpose === "execution");
184
- const activeReviewTurns = activeTurns.filter((turn) => turn.purpose === "review");
185
- const activeDelegatedExecutions = activeExecutionTurns.filter((turn) => (turn.roleName !== "leader"));
186
- const healthyActiveTurns = activeTurns.filter((turn) => (turnHasSession(turn)
187
- && !attention.some((item) => item.turnId === turn.id)));
188
- const activeLeader = activeTurns.find((turn) => turn.roleName === "leader");
189
- const pendingDeliveryTurns = activeTurns.filter((turn) => !turnHasSession(turn));
199
+ const activeExecutionRuns = activeRuns.filter((run) => run.purpose === "execution");
200
+ const activeReviewRuns = activeRuns.filter((run) => run.purpose === "review");
201
+ const activeDelegatedExecutions = activeExecutionRuns.filter((run) => (run.roleName !== "leader"));
202
+ const healthyActiveRuns = activeRuns.filter((run) => (deliveryOf(run) === "accepted"
203
+ && !attention.some((item) => item.runId === run.id)));
204
+ const activeLeader = activeRuns.find((run) => run.roleName === "leader");
205
+ const pendingDeliveryRuns = activeRuns.filter((run) => deliveryOf(run) !== "accepted");
190
206
  const hasPendingLeaderWork = pendingWakeup !== null
191
207
  || leaderMailbox?.pending !== null;
192
208
  const recoveryPending = isRecoveryPending(pendingWakeup, leaderMailbox, leaderFailure);
193
- const failedWork = workItems.some((item) => item.status === "failed");
194
- const candidateReady = workItems.some((item) => item.status === "awaiting_acceptance");
209
+ const failedWork = workItems.some((item) => item.status === "open"
210
+ && runs.filter((run) => run.workItemId === item.id).at(-1)?.status === "failed");
211
+ const candidateReady = workItems.some((item) => (item.status === "open" && item.currentCandidateId !== undefined));
195
212
  const blockedIntegration = integrations.some((attempt) => attempt.status === "blocked");
196
213
  const unresolvedIntegration = integrations.some((attempt) => (attempt.status === "running"
197
214
  || attempt.status === "validating"
@@ -202,19 +219,19 @@ export function projectTaskExecution(facts) {
202
219
  if (first === undefined)
203
220
  throw new Error("Task execution attention disappeared.");
204
221
  const progressingWithAttention = first.kind === "checkpoint-overdue"
205
- && healthyActiveTurns.length > 0;
222
+ && healthyActiveRuns.length > 0;
206
223
  return render({
207
224
  task,
208
225
  status: progressingWithAttention ? "progressing-with-attention" : "attention",
209
226
  owner: first.owner,
210
227
  action: "inspect-attention",
211
228
  summary: progressingWithAttention
212
- ? `${healthyActiveTurns.length} healthy active Turn(s) remain while ${first.summary}`
229
+ ? `${healthyActiveRuns.length} healthy active AgentRun(s) remain while ${first.summary}`
213
230
  : first.summary,
214
231
  reason: progressingWithAttention ? "progressing-with-attention" : first.kind,
215
232
  monitoring,
216
233
  failClosed: hasLeaderMismatch || attention.some((item) => item.failClosed === true),
217
- activeTurns: activeTurnViews,
234
+ activeRuns: activeRunViews,
218
235
  attention,
219
236
  blockers,
220
237
  pendingWakeup
@@ -233,7 +250,7 @@ export function projectTaskExecution(facts) {
233
250
  reason: "open-input-request",
234
251
  monitoring,
235
252
  failClosed: false,
236
- activeTurns: activeTurnViews,
253
+ activeRuns: activeRunViews,
237
254
  attention,
238
255
  blockers,
239
256
  pendingWakeup
@@ -249,11 +266,11 @@ export function projectTaskExecution(facts) {
249
266
  action: "recover-execution",
250
267
  summary: `Execution Lane ${laneRecovery.laneId} in ${laneRecovery.groupId}`
251
268
  + ` requires ${laneRecovery.recovery}`
252
- + (laneRecovery.turnId === undefined ? "." : ` for exact Turn ${laneRecovery.turnId}.`),
269
+ + (laneRecovery.runId === undefined ? "." : ` for exact AgentRun ${laneRecovery.runId}.`),
253
270
  reason: `execution-lane-${laneRecovery.recovery}`,
254
271
  monitoring,
255
272
  failClosed: false,
256
- activeTurns: activeTurnViews,
273
+ activeRuns: activeRunViews,
257
274
  attention,
258
275
  blockers,
259
276
  pendingWakeup
@@ -272,7 +289,7 @@ export function projectTaskExecution(facts) {
272
289
  reason: blockedIntegration ? "integration-blocked" : failedWork ? "work-failed" : "identity-mismatch",
273
290
  monitoring,
274
291
  failClosed: hasLeaderMismatch,
275
- activeTurns: activeTurnViews,
292
+ activeRuns: activeRunViews,
276
293
  attention,
277
294
  blockers,
278
295
  pendingWakeup
@@ -289,24 +306,24 @@ export function projectTaskExecution(facts) {
289
306
  reason: leaderFailure === null ? "recovery-pending" : "leader-recovery-failed",
290
307
  monitoring,
291
308
  failClosed: leaderFailure !== null,
292
- activeTurns: activeTurnViews,
309
+ activeRuns: activeRunViews,
293
310
  attention,
294
311
  blockers,
295
312
  pendingWakeup
296
313
  });
297
314
  }
298
- const leaderDeliveryPending = pendingDeliveryTurns.some((turn) => turn.roleName === "leader");
315
+ const leaderDeliveryPending = pendingDeliveryRuns.some((run) => run.roleName === "leader");
299
316
  if (leaderDeliveryPending) {
300
317
  return render({
301
318
  task,
302
- status: "recovering",
319
+ status: "waiting-on-agents",
303
320
  owner: "leader",
304
321
  action: "recover-leader",
305
- summary: "The active Leader Turn is awaiting provider acceptance; delivery remains fail-closed.",
322
+ summary: `Leader execution record is open; admission is ${activeLeader === undefined ? "unobserved" : deliveryOf(activeLeader)}. This is not proof of Agent progress.`,
306
323
  reason: "delivery-pending",
307
324
  monitoring,
308
325
  failClosed: false,
309
- activeTurns: activeTurnViews,
326
+ activeRuns: activeRunViews,
310
327
  attention,
311
328
  blockers,
312
329
  pendingWakeup
@@ -314,14 +331,14 @@ export function projectTaskExecution(facts) {
314
331
  }
315
332
  if (activeLeader !== undefined) {
316
333
  const concurrentExecutionCount = activeDelegatedExecutions.length;
317
- const concurrentReviewCount = activeReviewTurns.length;
334
+ const concurrentReviewCount = activeReviewRuns.length;
318
335
  const concurrentSummary = [
319
336
  concurrentExecutionCount === 0
320
337
  ? null
321
- : `${concurrentExecutionCount} delegated execution Turn(s)`,
338
+ : `${concurrentExecutionCount} delegated execution AgentRun(s)`,
322
339
  concurrentReviewCount === 0
323
340
  ? null
324
- : `${concurrentReviewCount} Review Turn(s)`
341
+ : `${concurrentReviewCount} Review AgentRun(s)`
325
342
  ].filter((value) => value !== null).join(" and ");
326
343
  return render({
327
344
  task,
@@ -329,12 +346,12 @@ export function projectTaskExecution(facts) {
329
346
  owner: "leader",
330
347
  action: "advance-task",
331
348
  summary: concurrentSummary.length === 0
332
- ? "Leader Turn is actively advancing the Task."
333
- : `Leader Turn is actively advancing the Task alongside ${concurrentSummary}.`,
349
+ ? "Leader execution was accepted; its result and Task progress remain separate facts."
350
+ : `Leader execution was accepted alongside ${concurrentSummary}; Task progress remains a separate fact.`,
334
351
  reason: concurrentSummary.length === 0 ? "leader-turn-active" : "leader-and-agents-active",
335
352
  monitoring,
336
353
  failClosed: false,
337
- activeTurns: activeTurnViews,
354
+ activeRuns: activeRunViews,
338
355
  attention,
339
356
  blockers,
340
357
  pendingWakeup
@@ -346,62 +363,62 @@ export function projectTaskExecution(facts) {
346
363
  status: "needs-leader-action",
347
364
  owner: "leader",
348
365
  action: "advance-task",
349
- summary: "A durable Leader wake is pending; concurrent Turns remain visible but do not suppress it.",
366
+ summary: "A durable Leader wake is pending; concurrent AgentRuns remain visible but do not suppress it.",
350
367
  reason: "leader-wake-pending",
351
368
  monitoring,
352
369
  failClosed: false,
353
- activeTurns: activeTurnViews,
370
+ activeRuns: activeRunViews,
354
371
  attention,
355
372
  blockers,
356
373
  pendingWakeup
357
374
  });
358
375
  }
359
- if (pendingDeliveryTurns.length > 0) {
376
+ if (pendingDeliveryRuns.length > 0) {
360
377
  return render({
361
378
  task,
362
379
  status: "recovering",
363
380
  owner: "leader",
364
381
  action: "recover-execution",
365
- summary: `${pendingDeliveryTurns.length} active delegated Turn(s) are awaiting provider acceptance; delivery remains fail-closed.`,
382
+ summary: `${pendingDeliveryRuns.length} active delegated AgentRun(s) are awaiting provider acceptance; delivery remains fail-closed.`,
366
383
  reason: "delivery-pending",
367
384
  monitoring,
368
385
  failClosed: false,
369
- activeTurns: activeTurnViews,
386
+ activeRuns: activeRunViews,
370
387
  attention,
371
388
  blockers,
372
389
  pendingWakeup
373
390
  });
374
391
  }
375
392
  if (activeDelegatedExecutions.length > 0) {
376
- const reviewSuffix = activeReviewTurns.length === 0
393
+ const reviewSuffix = activeReviewRuns.length === 0
377
394
  ? ""
378
- : `; ${activeReviewTurns.length} Review Turn(s) are also active`;
395
+ : `; ${activeReviewRuns.length} Review AgentRun(s) are also active`;
379
396
  return render({
380
397
  task,
381
398
  status: "waiting-on-agents",
382
399
  owner: roleOwner(activeDelegatedExecutions[0].roleName),
383
400
  action: "wait-for-agents",
384
- summary: `${activeDelegatedExecutions.length} delegated execution Turn(s) are active${reviewSuffix}.`,
401
+ summary: `${activeDelegatedExecutions.length} delegated execution AgentRun(s) are active${reviewSuffix}.`,
385
402
  reason: "delegated-work-active",
386
403
  monitoring,
387
404
  failClosed: false,
388
- activeTurns: activeTurnViews,
405
+ activeRuns: activeRunViews,
389
406
  attention,
390
407
  blockers,
391
408
  pendingWakeup
392
409
  });
393
410
  }
394
- if (activeReviewTurns.length > 0) {
411
+ if (activeReviewRuns.length > 0) {
395
412
  return render({
396
413
  task,
397
414
  status: "waiting-on-agents",
398
415
  owner: "reviewer",
399
416
  action: "wait-for-agents",
400
- summary: `${activeReviewTurns.length} Review Turn(s) are evaluating frozen candidates; newer facts can still wake the Leader.`,
417
+ summary: `${activeReviewRuns.length} Review AgentRun(s) are evaluating frozen candidates; newer facts can still wake the Leader.`,
401
418
  reason: "review-active",
402
419
  monitoring,
403
420
  failClosed: false,
404
- activeTurns: activeTurnViews,
421
+ activeRuns: activeRunViews,
405
422
  attention,
406
423
  blockers,
407
424
  pendingWakeup
@@ -421,7 +438,7 @@ export function projectTaskExecution(facts) {
421
438
  : "integration-pending",
422
439
  monitoring,
423
440
  failClosed: false,
424
- activeTurns: activeTurnViews,
441
+ activeRuns: activeRunViews,
425
442
  attention,
426
443
  blockers,
427
444
  pendingWakeup
@@ -436,7 +453,7 @@ export function projectTaskExecution(facts) {
436
453
  reason: "no-executor",
437
454
  monitoring,
438
455
  failClosed: false,
439
- activeTurns: activeTurnViews,
456
+ activeRuns: activeRunViews,
440
457
  attention,
441
458
  blockers,
442
459
  pendingWakeup
@@ -453,7 +470,7 @@ function projection(input) {
453
470
  reason: input.reason,
454
471
  monitoring: input.monitoring,
455
472
  failClosed: input.failClosed,
456
- activeTurns: input.activeTurns,
473
+ activeRuns: input.activeRuns,
457
474
  executionGroups: input.executionGroups ?? [],
458
475
  observability: input.observability,
459
476
  attention: input.attention,
@@ -494,7 +511,7 @@ function collectExecutionGroups(workItems, reviewRounds, _turns) {
494
511
  }
495
512
  function collectAttention(input) {
496
513
  const result = [];
497
- const { task, activeTurns, events, leaderFailure } = input;
514
+ const { task, activeRuns, events, leaderFailure } = input;
498
515
  if (leaderFailure !== null) {
499
516
  result.push({
500
517
  kind: "leader-recovery",
@@ -504,82 +521,57 @@ function collectAttention(input) {
504
521
  failClosed: true
505
522
  });
506
523
  }
507
- for (const turn of activeTurns) {
508
- const role = input.roles.find((candidate) => candidate.name === turn.roleName);
509
- const session = input.roleSessions.find((candidate) => candidate.roleName === turn.roleName);
510
- if (role !== undefined
511
- && ((role.activeAgentId !== undefined && role.activeAgentId !== turn.effective?.agentId)
512
- || (role.adapterId !== undefined && role.adapterId !== turn.effective?.adapterId))) {
513
- result.push({
514
- kind: "identity-mismatch",
515
- id: `identity:${turn.id}`,
516
- owner: "leader",
517
- summary: `Turn ${turn.id} does not match the current ${turn.roleName} Agent/adapter fence.`,
518
- turnId: turn.id,
519
- roleName: turn.roleName,
520
- failClosed: true
521
- });
522
- }
524
+ for (const run of activeRuns) {
525
+ const session = input.roleSessions.find((candidate) => candidate.roleName === run.roleName);
526
+ // Current Role selection is desired configuration, not the identity fence
527
+ // of a AgentRun already assigned. Only actual execution evidence can mismatch.
523
528
  if (session !== undefined
524
- && (session.agentId !== turn.effective?.agentId || session.adapterId !== turn.effective?.adapterId)) {
529
+ && (session.agentId !== run.effective?.agentId || session.adapterId !== run.effective?.adapterId)) {
525
530
  result.push({
526
531
  kind: "identity-mismatch",
527
- id: `session:${turn.id}`,
532
+ id: `session:${run.id}`,
528
533
  owner: "leader",
529
- summary: `Turn ${turn.id} has a provider/session identity mismatch; monitoring fails closed.`,
530
- turnId: turn.id,
531
- roleName: turn.roleName,
534
+ summary: `AgentRun ${run.id} has a provider/session identity mismatch; monitoring fails closed.`,
535
+ runId: run.id,
536
+ roleName: run.roleName,
532
537
  failClosed: true
533
538
  });
534
539
  }
535
- if (isRoleTurnStalled(events, turn.id)) {
536
- if (turn.roleName === "leader") {
537
- const progressAt = latestStallProgressAt(events, turn.id) ?? "unknown";
540
+ if (isRoleRunStalled(events, run.id)) {
541
+ if (run.roleName === "leader") {
542
+ const progressAt = latestStallProgressAt(events, run.id) ?? "unknown";
538
543
  result.push({
539
544
  kind: "leader-stalled",
540
- id: `leader-stall:${turn.id}:${progressAt}`,
545
+ id: `leader-stall:${run.id}:${progressAt}`,
541
546
  owner: "operator",
542
- summary: `Leader Turn ${turn.id} has an unresolved no-progress attention.`,
543
- turnId: turn.id,
544
- roleName: turn.roleName
547
+ summary: `Leader AgentRun ${run.id} has an unresolved no-progress attention.`,
548
+ runId: run.id,
549
+ roleName: run.roleName
545
550
  });
546
551
  }
547
552
  else {
548
553
  result.push({
549
554
  kind: "checkpoint-overdue",
550
- id: `checkpoint-overdue:${turn.id}`,
555
+ id: `checkpoint-overdue:${run.id}`,
551
556
  owner: "leader",
552
- summary: `Delegated Turn ${turn.id} has an unresolved checkpoint-overdue signal.`,
553
- turnId: turn.id,
554
- roleName: turn.roleName
557
+ summary: `Delegated AgentRun ${run.id} has an unresolved checkpoint-overdue signal.`,
558
+ runId: run.id,
559
+ roleName: run.roleName
555
560
  });
556
561
  }
557
562
  }
558
563
  }
559
564
  for (const request of input.inputRequests.filter(({ status }) => status === "open")) {
560
565
  const requester = request.requester;
561
- const turn = requester === undefined
562
- ? undefined
563
- : activeTurns.find(({ id }) => id === requester.turnId);
564
- const role = requester === undefined
565
- ? undefined
566
- : input.roles.find(({ name }) => name === requester.roleName);
567
- const session = requester === undefined
568
- ? undefined
569
- : input.roleSessions.find(({ roleName }) => roleName === requester.roleName);
570
- if (turn === undefined
571
- || turn.roleName !== "leader"
572
- || requester === undefined
573
- || turn.effective?.agentId !== requester.agentId
574
- || (role?.adapterId !== undefined && role.adapterId !== turn.effective?.adapterId)
575
- || (requester.nativeSessionId !== undefined
576
- && session?.nativeSessionId !== requester.nativeSessionId)) {
566
+ // Origin is durable provenance, not a live execution lease. Questions
567
+ // remain answerable after their originating Run ends or Session changes.
568
+ if (requester === undefined || requester.taskId !== task.id || requester.roleName !== "leader") {
577
569
  result.push({
578
570
  kind: "identity-mismatch",
579
571
  id: `input:${request.id}`,
580
572
  owner: "leader",
581
- summary: `InputRequest ${request.id} does not match the active Leader Turn/session; it is held fail-closed.`,
582
- ...(requester?.turnId === undefined ? {} : { turnId: requester.turnId }),
573
+ summary: `InputRequest ${request.id} has an invalid Task/Leader origin; it is held fail-closed.`,
574
+ ...(requester?.runId === undefined ? {} : { runId: requester.runId }),
583
575
  roleName: "leader",
584
576
  failClosed: true
585
577
  });
@@ -591,7 +583,7 @@ function collectBlockers(workItems, reviewRounds, integrations, openInputs, task
591
583
  const blockers = [];
592
584
  const byId = new Map(workItems.map((item) => [item.id, item]));
593
585
  for (const item of workItems) {
594
- if (item.status === "failed" || item.status === "awaiting_acceptance") {
586
+ if (item.status === "open" && item.currentCandidateId !== undefined) {
595
587
  blockers.push({
596
588
  kind: "work",
597
589
  id: item.id,
@@ -599,9 +591,9 @@ function collectBlockers(workItems, reviewRounds, integrations, openInputs, task
599
591
  summary: item.outcome ?? `WorkItem ${item.id} is ${item.status}.`
600
592
  });
601
593
  }
602
- if (item.status === "pending" && (item.dependsOn ?? []).some((id) => {
594
+ if (item.status === "open" && (item.dependsOn ?? []).some((id) => {
603
595
  const status = byId.get(id)?.status;
604
- return status !== "completed";
596
+ return status !== "accepted";
605
597
  })) {
606
598
  blockers.push({
607
599
  kind: "work",
@@ -635,7 +627,11 @@ function collectBlockers(workItems, reviewRounds, integrations, openInputs, task
635
627
  summary: request.question
636
628
  });
637
629
  }
638
- if (task.status === "active" && task.cwd === undefined) {
630
+ // A Task activated with an empty environment plan owns no workspace and no
631
+ // cwd by design; only a Task that should own one is blocked by its absence.
632
+ if (task.status === "active"
633
+ && taskOwnsManagedWorkspace(task)
634
+ && task.cwd === undefined) {
639
635
  blockers.push({
640
636
  kind: "identity",
641
637
  id: `workspace:${task.id}`,