@zq-silk/yui 0.15.7 → 0.15.8

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 (281) hide show
  1. package/ARCHITECTURE.md +192 -399
  2. package/README.md +127 -1149
  3. package/dist/agent/adapterCatalog.js +15 -2
  4. package/dist/agent/agent.js +23 -3
  5. package/dist/agent/argumentPolicy.js +7 -1
  6. package/dist/agent/connectionPlan.js +62 -0
  7. package/dist/agent/executionComponents.js +158 -0
  8. package/dist/agent/launchEnvironment.js +31 -3
  9. package/dist/agent/managedRuntimeEnvironment.js +3 -5
  10. package/dist/{turn/turn.js → agentRun/agentRun.js} +166 -109
  11. package/dist/{turn/turnIdentity.js → agentRun/runIdentity.js} +4 -4
  12. package/dist/brief/taskBrief.js +12 -0
  13. package/dist/cli/agentConfigurationPicker.js +13 -0
  14. package/dist/cli/commandCatalog.js +157 -70
  15. package/dist/cli/interactionCandidates.js +5 -5
  16. package/dist/cli/interactionPolicy.js +38 -8
  17. package/dist/cli/invocationRouter.js +1 -1
  18. package/dist/cli/managedDiagnostics.js +28 -0
  19. package/dist/cli/operatorWizard.js +1 -7
  20. package/dist/cli/roleOptionOrder.js +27 -0
  21. package/dist/cli/roleWizard.js +50 -14
  22. package/dist/cli/updateOrchestrator.js +1 -1
  23. package/dist/cli/updatePorts.js +3 -4
  24. package/dist/cli.js +178 -95
  25. package/dist/commands/agentCommands.js +72 -14
  26. package/dist/commands/capabilityCommands.js +9 -6
  27. package/dist/commands/configCommands.js +20 -20
  28. package/dist/commands/deliveryGuardPreflight.js +2 -2
  29. package/dist/commands/executionAuditCommands.js +24 -24
  30. package/dist/commands/globalRoleCommands.js +1 -1
  31. package/dist/commands/grantCommands.js +4 -4
  32. package/dist/commands/operatorCommands.js +1 -7
  33. package/dist/commands/projectCommands.js +4 -4
  34. package/dist/commands/resourcesCommands.js +2 -2
  35. package/dist/commands/roleConfiguration.js +25 -5
  36. package/dist/commands/roleRuntimeGuard.js +4 -5
  37. package/dist/commands/sessionCommands.js +3 -7
  38. package/dist/commands/taskActivationCommands.js +259 -0
  39. package/dist/commands/taskActor.js +28 -49
  40. package/dist/commands/taskCommands.js +1188 -710
  41. package/dist/commands/taskContextCommand.js +39 -583
  42. package/dist/commands/taskExecutionCommands.js +32 -32
  43. package/dist/commands/taskInputCommands.js +40 -104
  44. package/dist/commands/taskIntegrationCommands.js +3 -2
  45. package/dist/commands/taskIntegrationQueueCommands.js +1 -1
  46. package/dist/commands/taskNextActionCommand.js +8 -8
  47. package/dist/commands/taskOverviewCommand.js +33 -45
  48. package/dist/commands/taskRemoteDeliveryCommand.js +2 -2
  49. package/dist/commands/taskRoleRuntimeStatus.js +133 -102
  50. package/dist/commands/telemetryCommands.js +36 -38
  51. package/dist/config/configCatalog.js +4 -4
  52. package/dist/config/yuiConfig.js +8 -8
  53. package/dist/context/contextSnapshot.js +10 -10
  54. package/dist/context/dispatchContext.js +11 -11
  55. package/dist/context/roleSessionContext.js +6 -3
  56. package/dist/context/{turnContextPack.js → runContextPack.js} +146 -81
  57. package/dist/context/{turnInputContract.js → runInputContract.js} +73 -60
  58. package/dist/context/sessionBootstrapManifest.js +21 -2
  59. package/dist/context/sourceRunContext.js +30 -0
  60. package/dist/context/taskContext.js +458 -0
  61. package/dist/context/wakeNotification.js +27 -27
  62. package/dist/controller/agentRuntimeObserver.js +21 -24
  63. package/dist/controller/capabilityBridge.js +17 -6
  64. package/dist/controller/clientRuntime.js +65 -92
  65. package/dist/controller/controller.js +114 -188
  66. package/dist/controller/fileSchedulerStoreAdapter.js +787 -887
  67. package/dist/controller/jobControl.js +54 -85
  68. package/dist/controller/resourceInventory.js +8 -27
  69. package/dist/controller/resourceInventoryLinux.js +12 -13
  70. package/dist/controller/runtime.js +529 -479
  71. package/dist/controller/runtimeEventInbox.js +55 -25
  72. package/dist/controller/runtimeEventProcessor.js +22 -31
  73. package/dist/controller/{runtimeHookTurnFence.js → runtimeHookRunFence.js} +91 -115
  74. package/dist/controller/runtimeLaunchCoordinator.js +80 -426
  75. package/dist/controller/runtimeObservationHook.js +14 -18
  76. package/dist/controller/sessionNotify.js +16 -24
  77. package/dist/controller/sessionOwnerReconciliation.js +168 -50
  78. package/dist/controller/structuredProviderObservation.js +138 -99
  79. package/dist/coordination/workMailbox.js +3 -3
  80. package/dist/coordination/workMailboxQueue.js +36 -33
  81. package/dist/core/boundedRpc.js +8 -1
  82. package/dist/core/controllerClient.js +20 -1
  83. package/dist/core/controllerServer.js +4 -4
  84. package/dist/doctor/doctor.js +13 -2
  85. package/dist/domain/agentResultTransport.js +9 -9
  86. package/dist/execution/codexThreadNaming.js +2 -8
  87. package/dist/execution/executionHealth.js +51 -63
  88. package/dist/execution/reviewMainRun.js +137 -0
  89. package/dist/execution/workItemExecution.js +28 -29
  90. package/dist/execution/workItemExecutionProjection.js +99 -107
  91. package/dist/execution/workItemMainRun.js +141 -0
  92. package/dist/executor/agentAdapter.js +227 -20
  93. package/dist/executor/agentConfigurationCatalog.js +126 -4
  94. package/dist/executor/agentConfigurationProbe.js +162 -4
  95. package/dist/executor/agentExecutor.js +79 -78
  96. package/dist/executor/effectiveLaunch.js +105 -18
  97. package/dist/executor/executorRegistry.js +29 -44
  98. package/dist/executor/fileRoleLaunchPlanner.js +229 -154
  99. package/dist/executor/workspacePreflightClassification.js +16 -16
  100. package/dist/grant/capabilityGrant.js +6 -3
  101. package/dist/input/inputRequest.js +12 -10
  102. package/dist/integration/gitIntegrationService.js +4 -11
  103. package/dist/integration/integrationQueueService.js +4 -4
  104. package/dist/interaction/operatorPresentation.js +1 -1
  105. package/dist/kernel/builtinCapabilities.js +247 -12
  106. package/dist/kernel/capabilityRegistry.js +64 -18
  107. package/dist/kernel/instanceHost.js +12 -1
  108. package/dist/kernel/kernelPorts.js +2 -2
  109. package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
  110. package/dist/lifecycle/exactRunTerminalization.js +449 -0
  111. package/dist/message/message.js +62 -6
  112. package/dist/message/messageContinuation.js +204 -0
  113. package/dist/observability/executionAudit.js +70 -72
  114. package/dist/observability/faultClassification.js +2 -2
  115. package/dist/observability/orchestrationMetrics.js +8 -8
  116. package/dist/operator/operatorSessionHistory.js +1 -7
  117. package/dist/output/agentConfigurationPresentation.js +8 -3
  118. package/dist/output/agentRunConfigurationPresentation.js +128 -0
  119. package/dist/output/rolePresentation.js +54 -3
  120. package/dist/plugins/pluginChild.js +104 -0
  121. package/dist/plugins/pluginIntent.js +26 -0
  122. package/dist/plugins/pluginInterpreter.js +43 -0
  123. package/dist/plugins/pluginPackage.js +101 -0
  124. package/dist/plugins/pluginProcess.js +112 -0
  125. package/dist/plugins/pluginService.js +380 -0
  126. package/dist/profile/agentProfile.js +1 -1
  127. package/dist/repository/gitWorkspace.js +26 -4
  128. package/dist/repository/project.js +19 -4
  129. package/dist/repository/taskBaseFreshness.js +13 -13
  130. package/dist/repository/taskWorkspaceCoordinator.js +20 -27
  131. package/dist/repository/taskWorkspacePreparer.js +344 -83
  132. package/dist/resources/autoResourceGc.js +3 -3
  133. package/dist/resources/liveReferences.js +3 -3
  134. package/dist/resources/projectResource.js +123 -0
  135. package/dist/resources/projectResourceService.js +421 -0
  136. package/dist/resources/resourceDiscovery.js +6 -6
  137. package/dist/resources/resourceGc.js +1 -1
  138. package/dist/resources/resourceRegistrar.js +1 -1
  139. package/dist/resources/resourceTypes.js +1 -1
  140. package/dist/review/deltaRecheck.js +3 -3
  141. package/dist/review/reviewAcceptance.js +16 -16
  142. package/dist/review/reviewDecision.js +7 -7
  143. package/dist/review/reviewRound.js +21 -20
  144. package/dist/review/reviewerAvailability.js +2 -2
  145. package/dist/role/role.js +51 -7
  146. package/dist/role/taskRoleUpdate.js +30 -0
  147. package/dist/runtime/acpProtocol.js +425 -0
  148. package/dist/runtime/acpSession.js +731 -0
  149. package/dist/runtime/acpSessionConfiguration.js +260 -0
  150. package/dist/runtime/agentDriver.js +30 -11
  151. package/dist/runtime/agentEndpoint.js +278 -0
  152. package/dist/runtime/agentEndpointIdentity.js +86 -0
  153. package/dist/runtime/agentEndpointOwnership.js +239 -0
  154. package/dist/runtime/agentError.js +2 -10
  155. package/dist/runtime/agentHost.js +565 -314
  156. package/dist/runtime/agentRunConfiguration.js +258 -0
  157. package/dist/runtime/builtinAgentDrivers.js +134 -18
  158. package/dist/runtime/builtinAgentErrorMappers.js +55 -3
  159. package/dist/runtime/builtinTranscriptUsage.js +1 -1
  160. package/dist/runtime/claude-process-owner +0 -0
  161. package/dist/runtime/codexAppServerRuntime.js +38 -30
  162. package/dist/runtime/codexInteractiveHost.js +41 -6
  163. package/dist/runtime/continuationManager.js +2 -6
  164. package/dist/runtime/executionEnvironment.js +30 -0
  165. package/dist/runtime/firstProgressAdvisory.js +11 -11
  166. package/dist/runtime/index.js +4 -3
  167. package/dist/runtime/jsonLineChannel.js +109 -0
  168. package/dist/runtime/launchBroker.js +91 -16
  169. package/dist/runtime/launchDiagnostics.js +2 -2
  170. package/dist/runtime/lifecycleReservation.js +10 -18
  171. package/dist/runtime/managedCaller.js +61 -17
  172. package/dist/runtime/nativeSessionControl.js +102 -0
  173. package/dist/runtime/ports.js +6 -21
  174. package/dist/runtime/processExitObservation.js +8 -7
  175. package/dist/runtime/promptEnvelope.js +17 -6
  176. package/dist/runtime/providerContinuation.js +3 -9
  177. package/dist/runtime/providerContinuationReconciliationService.js +4 -13
  178. package/dist/runtime/providerControl.js +2 -7
  179. package/dist/runtime/providerRuntimeIdentity.js +110 -222
  180. package/dist/runtime/providerRuntimeReconciler.js +5 -9
  181. package/dist/runtime/runtimeBinding.js +0 -1
  182. package/dist/runtime/runtimeContinuationProjection.js +4 -7
  183. package/dist/runtime/runtimeDeadlines.js +9 -0
  184. package/dist/runtime/runtimeHealthPolicy.js +1 -1
  185. package/dist/runtime/runtimeObservation.js +29 -65
  186. package/dist/runtime/runtimeProjection.js +43 -51
  187. package/dist/runtime/runtimeSessionCandidate.js +1 -3
  188. package/dist/runtime/sessionLaunchRequest.js +3 -7
  189. package/dist/runtime/sessionOwnerIdentity.js +7 -54
  190. package/dist/runtime/sessionOwnerRegistry.js +22 -17
  191. package/dist/runtime/sessionReconciliation.js +4 -8
  192. package/dist/runtime/sessionTerminationGuard.js +70 -259
  193. package/dist/runtime/sessionTokenMetrics.js +5 -16
  194. package/dist/runtime/structuredProviderHost.js +237 -117
  195. package/dist/runtime/taskRuntimeIsolation.js +39 -122
  196. package/dist/runtime/tmuxAdapters.js +39 -86
  197. package/dist/scheduler/activeRoleRunDelivery.js +354 -0
  198. package/dist/scheduler/leaderWakeupProcessor.js +75 -266
  199. package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
  200. package/dist/scheduler/ports.js +80 -9
  201. package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
  202. package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
  203. package/dist/scheduler/taskExecutionProjection.js +120 -124
  204. package/dist/scheduler/taskObservabilityProjection.js +29 -29
  205. package/dist/scheduler/taskWake.js +11 -4
  206. package/dist/scheduler/wakeReason.js +9 -1
  207. package/dist/setup/setupCommand.js +1 -0
  208. package/dist/storage/migrations/agentRunContract.js +159 -0
  209. package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
  210. package/dist/storage/sqliteSchema.js +431 -5
  211. package/dist/storage/sqliteStore.js +375 -220
  212. package/dist/storage/storageVersions.js +1 -1
  213. package/dist/storage/storeRpc.js +10 -5
  214. package/dist/storage/taskStore.js +13 -11
  215. package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
  216. package/dist/surface/surfaceContributions.js +102 -0
  217. package/dist/task/completionReadiness.js +32 -6
  218. package/dist/task/deliveryGuard.js +16 -16
  219. package/dist/task/draftPlan.js +72 -12
  220. package/dist/task/nextAction.js +144 -128
  221. package/dist/task/remoteDelivery.js +6 -6
  222. package/dist/task/task.js +184 -18
  223. package/dist/task/taskActivation.js +301 -0
  224. package/dist/task/taskActivationService.js +392 -0
  225. package/dist/task/taskRecordReference.js +5 -4
  226. package/dist/task/taskRecordRetirement.js +1 -1
  227. package/dist/telemetry/sqliteTelemetryStore.js +55 -68
  228. package/dist/telemetry/telemetryConfig.js +14 -14
  229. package/dist/telemetry/telemetryWiring.js +2 -2
  230. package/dist/web/assets/assetManifest.js +2 -0
  231. package/dist/web/assets/client/app.js +120 -20
  232. package/dist/web/assets/client/components.js +87 -54
  233. package/dist/web/assets/client/i18n.js +83 -41
  234. package/dist/web/assets/client/markdown.js +1 -1
  235. package/dist/web/assets/client/taskSurface.js +353 -0
  236. package/dist/web/assets/client/view.js +49 -44
  237. package/dist/web/assets/shell.js +1 -1
  238. package/dist/web/assets/styles/cards.js +22 -4
  239. package/dist/web/controllerWeb.js +60 -0
  240. package/dist/web/webMutation.js +28 -0
  241. package/dist/web/webServer.js +118 -8
  242. package/dist/web/webSnapshot.js +81 -74
  243. package/dist/web/webTaskSurface.js +64 -0
  244. package/dist/workItem/dependencyGate.js +1 -1
  245. package/dist/workItem/workItem.js +80 -48
  246. package/dist/workspace/workItemChangeSetManager.js +16 -9
  247. package/docs/agent-result-consumption.md +94 -0
  248. package/docs/agent-runtime-drivers.md +91 -0
  249. package/docs/architecture/README.md +38 -0
  250. package/docs/architecture/capabilities-and-resources.md +79 -0
  251. package/docs/managed-turn-and-session-runtime.md +222 -0
  252. package/docs/observability/README.md +81 -0
  253. package/docs/plugin-sdk.md +290 -0
  254. package/docs/provider-runtime.md +163 -0
  255. package/docs/release-workflow.md +303 -0
  256. package/docs/roles-and-configuration.md +113 -0
  257. package/docs/sqlite-control-plane-design.md +76 -0
  258. package/docs/task-dag-semantics.md +57 -0
  259. package/docs/task-delivery.md +103 -0
  260. package/docs/task-local-identity.md +6 -6
  261. package/docs/testing/verification-levels.md +86 -0
  262. package/i18n/README.zh-CN.md +98 -739
  263. package/package.json +2 -2
  264. package/skills/yui-leader/SKILL.md +130 -103
  265. package/skills/yui-leader/references/integration.md +39 -0
  266. package/skills/yui-leader/references/replicated-execution.md +42 -0
  267. package/skills/yui-leader/references/task-plugins.md +33 -0
  268. package/skills/yui-operator/SKILL.md +30 -59
  269. package/skills/yui-reviewer/SKILL.md +35 -36
  270. package/skills/yui-runtime/SKILL.md +88 -24
  271. package/skills/yui-runtime/references/publication.md +22 -0
  272. package/skills/yui-runtime/references/recovery.md +64 -0
  273. package/skills/yui-worker/SKILL.md +37 -39
  274. package/dist/cli/roleOptionCatalog.js +0 -68
  275. package/dist/context/sourceTurnContext.js +0 -30
  276. package/dist/execution/reviewMainTurn.js +0 -161
  277. package/dist/execution/workItemMainTurn.js +0 -164
  278. package/dist/lifecycle/exactTurnTerminalization.js +0 -407
  279. package/dist/runtime/preallocatedNativeSession.js +0 -13
  280. package/dist/runtime/runtimeStopReceipt.js +0 -42
  281. package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
@@ -813,10 +813,9 @@ function safeDispatcherError(error) {
813
813
  }
814
814
  return { code: "SERVICE_ERROR", message };
815
815
  }
816
- case "RuntimeLaunchStateChangedError":
817
- // The launch coordinator already stopped the exact host and bounded
818
- // the detail to its currentness/reservation contract. Surface that
819
- // actionable diagnosis instead of collapsing it to INTERNAL_ERROR.
816
+ case "RuntimeLaunchFailure":
817
+ // Launch errors already carry bounded diagnostics (including redacted
818
+ // provider output). Preserve them instead of collapsing to INTERNAL_ERROR.
820
819
  return { code: "SERVICE_ERROR", message };
821
820
  default:
822
821
  return undefined;
@@ -832,6 +831,7 @@ function safeApplicationErrorCode(code) {
832
831
  case "METHOD_NOT_FOUND":
833
832
  case "NOT_FOUND":
834
833
  case "UNAUTHORIZED":
834
+ case "SESSION_BUSY":
835
835
  case "CONTROLLER_DRAINING":
836
836
  return code;
837
837
  default:
@@ -424,7 +424,7 @@ function inspectReview(source, agentChecks, environment) {
424
424
  checks.push({
425
425
  name: "reviewer binding",
426
426
  status: "ok",
427
- detail: `agent=${binding.agentId} adapter=${binding.adapterId}`
427
+ detail: `agent=${binding.agentId} component=${binding.component} adapter=${binding.adapterId}`
428
428
  });
429
429
  const agent = source.agent ?? null;
430
430
  if (agent === null) {
@@ -438,8 +438,19 @@ function inspectReview(source, agentChecks, environment) {
438
438
  checks.push({
439
439
  name: "reviewer agent",
440
440
  status: "ok",
441
- detail: `id=${agent.id} adapter=${agent.adapterId} command=${agent.command}`
441
+ detail: `id=${agent.id} component=${agent.component} adapter=${agent.adapterId} command=${agent.command}`
442
442
  });
443
+ // Two products can share one connection plan, so a matching adapter is not
444
+ // enough: a binding naming the SDK against an Agent recorded as the CLI is a
445
+ // real mismatch, and launching either one would contradict the other record.
446
+ if (agent.component !== binding.component) {
447
+ checks.push({
448
+ name: "reviewer component",
449
+ status: "invalid",
450
+ detail: `binding component=${binding.component} does not match Agent component=${agent.component}.`
451
+ });
452
+ return reviewMisconfigured(policy, checks, "Reviewer execution component does not match its Agent binding.", role, agent.id, agent.adapterId, agent.command);
453
+ }
443
454
  if (agent.adapterId !== binding.adapterId) {
444
455
  checks.push({
445
456
  name: "reviewer adapter",
@@ -1,9 +1,9 @@
1
- export const MAX_TURN_RESULT_OUTPUT_BYTES = 512 * 1024;
2
- export const MAX_TURN_FAILURE_DIAGNOSTIC_BYTES = 16 * 1024;
1
+ export const MAX_RUN_RESULT_OUTPUT_BYTES = 512 * 1024;
2
+ export const MAX_RUN_FAILURE_DIAGNOSTIC_BYTES = 16 * 1024;
3
3
  /**
4
4
  * Validate only the transport envelope of an Agent result. The accepted text
5
5
  * remains byte-for-byte unchanged; missing or untransportable text becomes a
6
- * Core-owned failed outcome so the exact Turn can still terminalize.
6
+ * Core-owned failed outcome so the exact AgentRun can still terminalize.
7
7
  */
8
8
  export function transportAgentResult(value) {
9
9
  if (typeof value !== "string") {
@@ -28,10 +28,10 @@ export function transportAgentResult(value) {
28
28
  };
29
29
  }
30
30
  const bytes = Buffer.byteLength(value, "utf8");
31
- if (bytes > MAX_TURN_RESULT_OUTPUT_BYTES) {
31
+ if (bytes > MAX_RUN_RESULT_OUTPUT_BYTES) {
32
32
  return {
33
33
  status: "failed",
34
- diagnostic: `Provider Agent result is ${bytes} bytes and exceeds the ${MAX_TURN_RESULT_OUTPUT_BYTES}-byte durable result limit; the result was not stored.`,
34
+ diagnostic: `Provider Agent result is ${bytes} bytes and exceeds the ${MAX_RUN_RESULT_OUTPUT_BYTES}-byte durable result limit; the result was not stored.`,
35
35
  failureReason: "runtime-failed"
36
36
  };
37
37
  }
@@ -42,19 +42,19 @@ export function transportAgentResult(value) {
42
42
  * This is intentionally separate from Agent result transport: successful
43
43
  * Agent text is either retained exactly or rejected as a whole, never
44
44
  * truncated. Provider/Core diagnostics may be clipped because they are only
45
- * operational context for a failed Turn.
45
+ * operational context for a failed AgentRun.
46
46
  */
47
- export function boundedTurnFailureDiagnostic(value, fallback = "Provider reported a failed Agent Turn.") {
47
+ export function boundedRunFailureDiagnostic(value, fallback = "Provider reported a failed Agent AgentRun.") {
48
48
  const candidate = typeof value === "string" && value.trim().length > 0
49
49
  ? value
50
50
  : fallback;
51
51
  const safe = candidate.replaceAll("\0", "\uFFFD");
52
- if (Buffer.byteLength(safe, "utf8") <= MAX_TURN_FAILURE_DIAGNOSTIC_BYTES) {
52
+ if (Buffer.byteLength(safe, "utf8") <= MAX_RUN_FAILURE_DIAGNOSTIC_BYTES) {
53
53
  return safe;
54
54
  }
55
55
  const prefix = Buffer
56
56
  .from(safe, "utf8")
57
- .subarray(0, MAX_TURN_FAILURE_DIAGNOSTIC_BYTES)
57
+ .subarray(0, MAX_RUN_FAILURE_DIAGNOSTIC_BYTES)
58
58
  .toString("utf8");
59
59
  return prefix.endsWith("\uFFFD") ? prefix.slice(0, -1) : prefix;
60
60
  }
@@ -1,6 +1,6 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { createInterface } from "node:readline";
3
- import { YUI_VERSION } from "../version.js";
3
+ import { codexClientInitialization } from "../runtime/codexAppServerRuntime.js";
4
4
  const DEFAULT_TIMEOUT_MS = 1_000;
5
5
  export async function setCodexThreadName(request) {
6
6
  const timeoutMs = threadNameTimeout(request.timeoutMs);
@@ -42,13 +42,7 @@ class CodexNamingClient {
42
42
  static async start(command, environment, baseArgs, timeoutMs) {
43
43
  const client = new CodexNamingClient(spawn(command, [...baseArgs, "app-server", "--stdio"], { env: environment, stdio: ["pipe", "pipe", "pipe"] }));
44
44
  try {
45
- await withTimeout(client.request("initialize", {
46
- clientInfo: { name: "yui", title: "Yui", version: YUI_VERSION },
47
- capabilities: {
48
- experimentalApi: true,
49
- requestAttestation: false
50
- }
51
- }), timeoutMs, "Timed out initializing Codex App Server for thread naming.");
45
+ await withTimeout(client.request("initialize", codexClientInitialization()), timeoutMs, "Timed out initializing Codex App Server for thread naming.");
52
46
  client.notify("initialized", {});
53
47
  return client;
54
48
  }
@@ -1,4 +1,4 @@
1
- import { isRoleTurnStalled, latestStallProgressAt } from "../scheduler/roleTurnStall.js";
1
+ import { isRoleRunStalled, latestStallProgressAt } from "../scheduler/roleRunStall.js";
2
2
  import { validateRuntimeProcessExitObservation } from "../runtime/processExitObservation.js";
3
3
  import { runtimeObservationFromTaskEvent } from "../runtime/runtimeObservation.js";
4
4
  import { projectRuntimeTaskEvents } from "../runtime/runtimeProjection.js";
@@ -23,15 +23,15 @@ export function summarizeExecutionGroupHealth(input) {
23
23
  const healthByLane = new Map(health.lanes.map((lane) => [lane.laneId, lane]));
24
24
  const laneSummaries = input.group.lanes.map((lane) => {
25
25
  const projected = healthByLane.get(lane.id);
26
- const turn = exactLaneTurn(input, lane);
26
+ const run = exactLaneRun(input, lane);
27
27
  return Object.freeze({
28
28
  roleName: lane.roleName,
29
29
  ordinal: lane.ordinal,
30
- ...(lane.currentTurnId === undefined ? {} : { turnId: lane.currentTurnId }),
31
- ...(lane.successfulTurnId === undefined
30
+ ...(lane.currentRunId === undefined ? {} : { runId: lane.currentRunId }),
31
+ ...(lane.successfulRunId === undefined
32
32
  ? {}
33
- : { successfulTurnId: lane.successfulTurnId }),
34
- status: projectedStatus(lane, turn),
33
+ : { successfulRunId: lane.successfulRunId }),
34
+ status: projectedStatus(lane, run),
35
35
  ...(lane.effective === undefined ? {} : { effective: lane.effective }),
36
36
  ...projected
37
37
  });
@@ -62,28 +62,28 @@ export function actionableExecutionLaneRecoveries(groups) {
62
62
  : [{
63
63
  groupId: group.groupId,
64
64
  laneId: lane.laneId,
65
- ...(lane.turnId === undefined ? {} : { turnId: lane.turnId }),
65
+ ...(lane.runId === undefined ? {} : { runId: lane.runId }),
66
66
  ...(lane.runtimeHealth === undefined ? {} : { runtimeHealth: lane.runtimeHealth }),
67
67
  recovery: "retry-new-turn"
68
68
  }]));
69
69
  }
70
70
  function projectExecutionLaneHealth(lane, input, policy) {
71
- const turn = exactLaneTurn(input, lane);
72
- const continuationAgentId = turn?.effective.agentId ?? lane.effective?.agentId;
71
+ const run = exactLaneRun(input, lane);
72
+ const continuationAgentId = run?.effective.agentId ?? lane.effective?.agentId;
73
73
  if (lane.disposition === "open"
74
- && lane.currentTurnId !== undefined
74
+ && lane.currentRunId !== undefined
75
75
  && continuationAgentId !== undefined
76
76
  && runOwnsBlockingProviderContinuation(input.events, {
77
77
  taskId: input.group.taskId,
78
78
  roleName: lane.roleName,
79
- turnId: lane.currentTurnId,
79
+ runId: lane.currentRunId,
80
80
  agentId: continuationAgentId
81
81
  })) {
82
82
  return projection(lane, {
83
83
  runtimeHealth: "active",
84
84
  recovery: "none",
85
85
  resultReusable: false,
86
- reason: "the exact Turn still owns an unsettled Provider continuation writer",
86
+ reason: "the exact AgentRun still owns an unsettled Provider continuation writer",
87
87
  evidence: ["runtime-continuation-writer-owned"]
88
88
  });
89
89
  }
@@ -104,7 +104,7 @@ function projectExecutionLaneHealth(lane, input, policy) {
104
104
  evidence: ["execution-lane-settled-failure"]
105
105
  });
106
106
  }
107
- if (lane.currentTurnId === undefined) {
107
+ if (lane.currentRunId === undefined) {
108
108
  return projection(lane, {
109
109
  recovery: "none",
110
110
  resultReusable: false,
@@ -112,38 +112,38 @@ function projectExecutionLaneHealth(lane, input, policy) {
112
112
  evidence: []
113
113
  });
114
114
  }
115
- if (turn === undefined) {
115
+ if (run === undefined) {
116
116
  return projection(lane, {
117
117
  runtimeHealth: "suspected-stalled",
118
118
  recovery: "inspect",
119
119
  resultReusable: false,
120
- reason: "the open Lane has no exact current Turn",
120
+ reason: "the open Lane has no exact current AgentRun",
121
121
  evidence: ["execution-lineage-missing"]
122
122
  });
123
123
  }
124
- if (turn.status === "failed") {
124
+ if (run.status === "failed") {
125
125
  return projection(lane, {
126
126
  runtimeHealth: "confirmed-dead",
127
127
  recovery: "retry-new-turn",
128
128
  resultReusable: false,
129
- reason: "the exact current Turn is durably failed",
129
+ reason: "the exact current AgentRun is durably failed",
130
130
  evidence: ["turn-terminal-failure"]
131
131
  });
132
132
  }
133
- if (turn.status === "completed") {
133
+ if (run.status === "completed") {
134
134
  return projection(lane, {
135
135
  runtimeHealth: "suspected-stalled",
136
136
  recovery: "inspect",
137
137
  resultReusable: false,
138
- reason: "the current Turn completed without settling its logical Lane",
138
+ reason: "the current AgentRun completed without settling its logical Lane",
139
139
  evidence: ["execution-lineage-inconsistent"]
140
140
  });
141
141
  }
142
- const session = input.sessions.find((candidate) => (candidate.roleName === turn.roleName
143
- && candidate.agentId === turn.effective.agentId
144
- && candidate.adapterId === turn.effective.adapterId));
145
- const observations = exactTurnObservations(input.events, turn, session);
146
- const runtime = runtimeProjection(observations, input.events, turn);
142
+ const session = input.sessions.find((candidate) => (candidate.roleName === run.roleName
143
+ && candidate.agentId === run.effective.agentId
144
+ && candidate.adapterId === run.effective.adapterId));
145
+ const observations = exactRunObservations(input.events, run, session);
146
+ const runtime = runtimeProjection(observations, input.events, run);
147
147
  const unsettledContinuation = runtime !== null
148
148
  && Object.values(runtime.continuations).some((continuation) => (continuation.execution === "active"
149
149
  || continuation.execution === "unknown"
@@ -152,12 +152,12 @@ function projectExecutionLaneHealth(lane, input, policy) {
152
152
  && (Object.values(runtime.operations).some(({ kind }) => kind === "subagent")
153
153
  || unsettledContinuation);
154
154
  if (observations.some((observation) => (observation.kind === "turn.failed"
155
- && observation.payload.failure?.turnTerminal === true)) && !unsettledChildWork) {
155
+ && observation.payload.failure?.runTerminal === true)) && !unsettledChildWork) {
156
156
  return projection(lane, {
157
157
  runtimeHealth: "confirmed-dead",
158
158
  recovery: "inspect",
159
159
  resultReusable: false,
160
- reason: "the Provider reported an exact Turn-terminal failure",
160
+ reason: "the Provider reported an exact AgentRun-terminal failure",
161
161
  evidence: ["provider-turn-terminal"]
162
162
  });
163
163
  }
@@ -178,7 +178,7 @@ function projectExecutionLaneHealth(lane, input, policy) {
178
178
  evidence: runtimeTerminalEvidence
179
179
  });
180
180
  }
181
- const exit = latestExactProcessExit(input.events, turn, session);
181
+ const exit = latestExactProcessExit(input.events, run, session);
182
182
  if (session?.status === "ended"
183
183
  && exit !== null
184
184
  && isAbnormalExit(exit.classification)
@@ -191,20 +191,20 @@ function projectExecutionLaneHealth(lane, input, policy) {
191
191
  evidence: ["native-session-terminal", `process-exit:${exit.classification}`]
192
192
  });
193
193
  }
194
- if (isRoleTurnStalled(input.events, turn.id)) {
194
+ if (isRoleRunStalled(input.events, run.id)) {
195
195
  return projection(lane, {
196
196
  runtimeHealth: "suspected-stalled",
197
197
  recovery: "inspect",
198
198
  resultReusable: false,
199
- reason: `the durable progress clock has not advanced since ${latestStallProgressAt(input.events, turn.id) ?? turn.updatedAt}; no death proof exists`,
199
+ reason: `the durable progress clock has not advanced since ${latestStallProgressAt(input.events, run.id) ?? run.updatedAt}; no death proof exists`,
200
200
  evidence: ["turn-stalled"]
201
201
  });
202
202
  }
203
203
  const activeOperation = runtime !== null
204
204
  && (Object.keys(runtime.operations).length > 0 || unsettledContinuation);
205
205
  const lastActivityAt = runtime?.lastRuntimeActivityAt
206
- ?? turn.updatedAt
207
- ?? turn.createdAt;
206
+ ?? run.updatedAt
207
+ ?? run.createdAt;
208
208
  const recentActivity = input.now.getTime() - Date.parse(lastActivityAt) < policy.quietAfterMs;
209
209
  if (activeOperation || recentActivity) {
210
210
  return projection(lane, {
@@ -215,7 +215,7 @@ function projectExecutionLaneHealth(lane, input, policy) {
215
215
  ? "the exact runtime reports unsettled continuation work"
216
216
  : activeOperation
217
217
  ? "the exact runtime reports an active operation"
218
- : "the exact Turn has recent structured runtime activity",
218
+ : "the exact AgentRun has recent structured runtime activity",
219
219
  evidence: unsettledContinuation
220
220
  ? ["runtime-continuation-unsettled"]
221
221
  : activeOperation
@@ -227,48 +227,36 @@ function projectExecutionLaneHealth(lane, input, policy) {
227
227
  runtimeHealth: "silent",
228
228
  recovery: "none",
229
229
  resultReusable: false,
230
- reason: "the exact Turn remains active without recent structured activity; silence alone is not death",
230
+ reason: "the exact AgentRun remains active without recent structured activity; silence alone is not death",
231
231
  evidence: ["turn-active"]
232
232
  });
233
233
  }
234
- function exactLaneTurn(input, lane) {
235
- return lane.currentTurnId === undefined
234
+ function exactLaneRun(input, lane) {
235
+ return lane.currentRunId === undefined
236
236
  ? undefined
237
- : input.turns.find((turn) => (turn.taskId === input.group.taskId
238
- && turn.id === lane.currentTurnId
239
- && turn.executionGroupId === input.group.id
240
- && turn.executionLaneId === lane.id
241
- && turn.roleName === lane.roleName));
237
+ : input.runs.find((run) => (run.taskId === input.group.taskId
238
+ && run.id === lane.currentRunId
239
+ && run.executionGroupId === input.group.id
240
+ && run.executionLaneId === lane.id
241
+ && run.roleName === lane.roleName));
242
242
  }
243
- function exactTurnObservations(events, turn, session) {
243
+ function exactRunObservations(events, run, session) {
244
244
  return events.map(runtimeObservationFromTaskEvent)
245
- .filter((observation) => (observation !== null
246
- && observation.fence.taskId === turn.taskId
247
- && observation.fence.turnId === turn.id
248
- && observation.fence.roleName === turn.roleName
249
- && observation.fence.agentId === turn.effective.agentId
250
- && (session?.runtimeGenerationId === undefined || observation.fence.runtimeGenerationId === session.runtimeGenerationId)
251
- && (session?.nativeSessionId === undefined
252
- || observation.fence.nativeSessionId === session.nativeSessionId)));
245
+ .filter((observation) => (observation !== null && observation.fence.taskId === run.taskId && observation.fence.runId === run.id && observation.fence.roleName === run.roleName && observation.fence.agentId === run.effective.agentId && (session?.nativeSessionId === undefined || observation.fence.nativeSessionId === session.nativeSessionId)));
253
246
  }
254
- function runtimeProjection(observations, events, turn) {
247
+ function runtimeProjection(observations, events, run) {
255
248
  const first = observations[0];
256
249
  return first === undefined
257
250
  ? null
258
- : projectRuntimeTaskEvents(first.fence, turn.createdAt, events);
251
+ : projectRuntimeTaskEvents(first.fence, run.createdAt, events);
259
252
  }
260
- function latestExactProcessExit(events, turn, session) {
253
+ function latestExactProcessExit(events, run, session) {
261
254
  const matching = events.flatMap((event) => {
262
255
  if (event.type !== "runtime.process-exit-observed")
263
256
  return [];
264
257
  try {
265
258
  const observation = validateRuntimeProcessExitObservation(JSON.parse(event.payload.observation ?? ""));
266
- if (observation.taskId !== turn.taskId
267
- || observation.turnId !== turn.id
268
- || observation.roleName !== turn.roleName
269
- || (session?.runtimeGenerationId !== undefined && observation.runtimeGenerationId !== session.runtimeGenerationId)
270
- || (session?.nativeSessionId !== undefined
271
- && observation.nativeSessionId !== session.nativeSessionId))
259
+ if (observation.taskId !== run.taskId || observation.runId !== run.id || observation.roleName !== run.roleName || (session?.nativeSessionId !== undefined && observation.nativeSessionId !== session.nativeSessionId))
272
260
  return [];
273
261
  return [{
274
262
  observation,
@@ -284,18 +272,18 @@ function latestExactProcessExit(events, turn, session) {
284
272
  function isAbnormalExit(classification) {
285
273
  return classification === "host-abnormal" || classification === "provider-turn-failed";
286
274
  }
287
- function projectedStatus(lane, turn) {
275
+ function projectedStatus(lane, run) {
288
276
  if (lane.disposition === "succeeded")
289
277
  return "succeeded";
290
278
  if (lane.disposition === "failed")
291
279
  return "failed";
292
- if (lane.currentTurnId === undefined)
280
+ if (lane.currentRunId === undefined)
293
281
  return "pending";
294
- if (turn === undefined)
282
+ if (run === undefined)
295
283
  return "unknown";
296
- if (turn.status === "active")
284
+ if (run.status === "active")
297
285
  return "running";
298
- if (turn.status === "failed")
286
+ if (run.status === "failed")
299
287
  return "needs-attention";
300
288
  return "unknown";
301
289
  }
@@ -0,0 +1,137 @@
1
+ import { enqueueRoleRunDispatch } from "../coordination/workMailboxQueue.js";
2
+ import { createRunInput } from "../context/runInputContract.js";
3
+ import { contextSnapshotDeltaRefIds, freezeRunContextSnapshot } from "../context/runContextPack.js";
4
+ import { contextSnapshotRef } from "../context/contextSnapshot.js";
5
+ import { roleAgentSessionResumeMode } from "../executor/agentExecutor.js";
6
+ import { resolveEffectiveLaunch } from "../executor/effectiveLaunch.js";
7
+ import { createTaskEvent } from "../event/taskEvent.js";
8
+ import { startReviewRound } from "../review/reviewRound.js";
9
+ import { createRun } from "../agentRun/agentRun.js";
10
+ export function selectedReviewSynthesisProducers(store, round, group, sourceRunIds) {
11
+ if (sourceRunIds.length === 0 || new Set(sourceRunIds).size !== sourceRunIds.length) {
12
+ throw new Error("Synthesis requires explicit, distinct source AgentRun references.");
13
+ }
14
+ return sourceRunIds.map((runId) => {
15
+ const run = store.getRun(round.taskId, runId);
16
+ const lane = group.lanes.find(({ id }) => id === run?.executionLaneId);
17
+ if (run === null
18
+ || lane === undefined
19
+ || !["completed", "failed"].includes(run.status)
20
+ || run.purpose !== "review"
21
+ || run.reviewRoundId !== round.id
22
+ || run.executionGroupId !== group.id
23
+ || run.executionLaneId !== lane.id
24
+ || run.roleName !== lane.roleName
25
+ || run.result === undefined) {
26
+ throw new Error(`Synthesis source is not an exact terminal Review Producer result: `
27
+ + `${group.id}/${runId}.`);
28
+ }
29
+ return {
30
+ laneId: lane.id,
31
+ roleName: lane.roleName,
32
+ runId: run.id
33
+ };
34
+ });
35
+ }
36
+ /** Called within the caller's transaction after Task authority is checked. */
37
+ export function dispatchReviewSynthesis(store, taskId, reviewRoundId, sourceRunIds, now) {
38
+ const task = store.getTask(taskId);
39
+ if (task === null || task.status !== "active" || task.executionGate.state !== "enabled") {
40
+ throw new Error(`Task execution is not enabled: ${taskId}.`);
41
+ }
42
+ const round = store.getReviewRound(taskId, reviewRoundId);
43
+ if (round === null || round.status !== "running") {
44
+ throw new Error(`ReviewRound is not running: ${taskId}/${reviewRoundId}.`);
45
+ }
46
+ const group = round.executionGroup;
47
+ if (group === undefined)
48
+ throw new Error(`ReviewRound has no ExecutionGroup: ${round.id}.`);
49
+ const producers = selectedReviewSynthesisProducers(store, round, group, sourceRunIds);
50
+ const existing = store.listRuns(taskId).filter((run) => (run.purpose === "review"
51
+ && run.reviewRoundId === round.id
52
+ && run.sourceExecutionGroupId === group.id));
53
+ if (existing.length > 0 || round.reviewerRunId !== undefined) {
54
+ throw new Error(`Synthesis already exists for ${group.id}; retry its AgentRun explicitly.`);
55
+ }
56
+ const role = store.getRole(taskId, round.reviewerRoleName);
57
+ if (role === null) {
58
+ throw new Error(`Review main Role is missing: ${taskId}/${round.reviewerRoleName}.`);
59
+ }
60
+ if (store.getActiveRun(taskId, role.name) !== null) {
61
+ throw new Error(`Review main Role already has an active AgentRun: ${role.name}.`);
62
+ }
63
+ const workspace = store.getReviewRoundWorkspace(taskId, round.id);
64
+ if (workspace === null) {
65
+ throw new Error(`Review main workspace is missing: ${taskId}/${round.id}.`);
66
+ }
67
+ const effective = resolveEffectiveLaunch({
68
+ role,
69
+ purpose: "review",
70
+ workspace,
71
+ reviewRoundId: round.id,
72
+ reviewBaseCommit: round.reviewBaseCommit
73
+ });
74
+ const snapshot = freezeRunContextSnapshot(store, {
75
+ taskId,
76
+ roleName: role.name,
77
+ purpose: "review",
78
+ ...(round.workItemId === undefined ? {} : { workItemId: round.workItemId }),
79
+ reviewRoundId: round.id,
80
+ sourceExecutionGroupId: group.id,
81
+ workspace
82
+ }, now, "leader", group.assignment.contextSnapshotRef, sourceRunIds);
83
+ const run = createRun(store.nextRunId(taskId), taskId, role.name, roleAgentSessionResumeMode(store.getTaskRoleSessionSet(taskId, role.name), effective.agentId, effective), createRunInput({
84
+ source: {
85
+ type: "yui",
86
+ channel: round.workItemId === undefined ? "task-dispatch" : "workitem-dispatch"
87
+ },
88
+ directive: synthesisDirective(group, producers),
89
+ contextSnapshotRef: contextSnapshotRef(snapshot),
90
+ deltaRefIds: contextSnapshotDeltaRefIds(store, snapshot)
91
+ }), now, {
92
+ ...(round.workItemId === undefined ? {} : { workItemId: round.workItemId }),
93
+ purpose: "review",
94
+ reviewRoundId: round.id,
95
+ sourceExecutionGroupId: group.id,
96
+ workspace,
97
+ effective
98
+ });
99
+ store.saveRun(run);
100
+ store.saveReviewRound(taskId, startReviewRound(round, run.id));
101
+ store.saveActiveRun(run);
102
+ enqueueRoleRunDispatch(store, {
103
+ taskId,
104
+ roleName: role.name,
105
+ runId: run.id,
106
+ reason: "review-synthesis-ready",
107
+ occurredAt: now
108
+ });
109
+ store.saveEvent(taskId, createTaskEvent(store.nextEventId(taskId), taskId, "run.review-dispatched", {
110
+ runId: run.id,
111
+ role: run.roleName,
112
+ purpose: run.purpose,
113
+ mode: run.mode,
114
+ agent: `${run.effective.agentId}/${run.effective.adapterId}`,
115
+ component: run.effective.component,
116
+ effectiveRevision: String(run.effective.sourceDesiredRevision),
117
+ profileAccess: run.effective.profileAccess,
118
+ effectivePermission: run.effective.permission.strategy,
119
+ writeProjectIds: run.effective.writeProjectIds.join(",") || "none",
120
+ reviewRoundId: round.id,
121
+ sourceExecutionGroupId: group.id
122
+ }, now));
123
+ return run;
124
+ }
125
+ function synthesisDirective(group, producers) {
126
+ return [
127
+ "Act as the main Reviewer over the explicitly selected Producer results in the supplied order.",
128
+ "Expand each exact source AgentRun from the frozen Context Snapshot and consume its original result text plus Core-authored system evidence.",
129
+ "Resolve disagreements through review judgment against the frozen candidate. Do not rerun, retry, append, select, or abandon Lanes.",
130
+ "Return one complete original review result for the Leader; Yui Core does not parse or validate its semantic structure.",
131
+ JSON.stringify({
132
+ schemaVersion: 1,
133
+ sourceExecutionGroupId: group.id,
134
+ producers
135
+ }, null, 2)
136
+ ].join("\n\n");
137
+ }