@zq-silk/yui 0.15.11 → 0.16.0

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 (280) hide show
  1. package/ARCHITECTURE.md +11 -6
  2. package/ARCHITECTURE.zh-CN.md +8 -4
  3. package/README.md +13 -5
  4. package/dist/agentRun/agentRun.js +3 -0
  5. package/dist/artifacts/artifactCommitLock.js +16 -55
  6. package/dist/artifacts/taskArtifactRepository.js +3 -3
  7. package/dist/cli/agentConfigurationPicker.js +1 -1
  8. package/dist/cli/commandCatalog.js +92 -48
  9. package/dist/cli/completion.js +18 -18
  10. package/dist/cli/completionWizard.js +1 -1
  11. package/dist/cli/dynamicCompletion.js +1 -1
  12. package/dist/cli/interactionPolicy.js +11 -3
  13. package/dist/cli/invocationAuthority.js +64 -0
  14. package/dist/cli/managedDiagnostics.js +2 -2
  15. package/dist/cli/parseRepeatable.js +35 -0
  16. package/dist/cli/updatePorts.js +26 -5
  17. package/dist/cli.js +1303 -1235
  18. package/dist/commands/agentCommands.js +4 -4
  19. package/dist/commands/capabilityCommands.js +1 -1
  20. package/dist/commands/configCommands.js +6 -57
  21. package/dist/commands/configOverview.js +2 -2
  22. package/dist/commands/durableJobCommands.js +12 -6
  23. package/dist/commands/executionAuditCommands.js +10 -0
  24. package/dist/commands/globalRoleCommands.js +78 -29
  25. package/dist/commands/grantCommands.js +0 -3
  26. package/dist/commands/jobCommands.js +1 -4
  27. package/dist/commands/operatorCommands.js +3 -3
  28. package/dist/commands/projectCommands.js +45 -25
  29. package/dist/commands/resourcesCommands.js +10 -40
  30. package/dist/commands/roleConfiguration.js +2 -6
  31. package/dist/commands/taskActivationCommands.js +4 -8
  32. package/dist/commands/taskAgentCapabilities.js +9 -0
  33. package/dist/commands/taskCommandSupport.js +155 -0
  34. package/dist/commands/taskCommandTypes.js +1 -0
  35. package/dist/commands/taskCommands.js +355 -732
  36. package/dist/commands/taskCompletionGate.js +1 -1
  37. package/dist/commands/taskExecutionCommands.js +1 -1
  38. package/dist/commands/taskFactCommands.js +325 -0
  39. package/dist/commands/taskInputCommands.js +12 -42
  40. package/dist/commands/taskIntegrationCommands.js +20 -58
  41. package/dist/commands/taskNextActionCommand.js +7 -6
  42. package/dist/commands/taskPublicationAdoptCommand.js +127 -0
  43. package/dist/commands/taskPublicationCommands.js +12 -3
  44. package/dist/commands/taskPublicationVerifyCommand.js +24 -40
  45. package/dist/commands/taskRemoteDeliveryCommand.js +5 -86
  46. package/dist/commands/taskUpstreamCommands.js +19 -8
  47. package/dist/commands/workflowCommands.js +6 -1
  48. package/dist/completion/completionInstaller.js +26 -26
  49. package/dist/completion/completionState.js +26 -26
  50. package/dist/completion/fileCompletionManager.js +6 -11
  51. package/dist/config/configCatalog.js +0 -2
  52. package/dist/config/timeZone.js +14 -0
  53. package/dist/config/yuiConfig.js +0 -29
  54. package/dist/context/runContextPack.js +5 -3
  55. package/dist/context/taskCatalog.js +185 -0
  56. package/dist/context/taskContext.js +152 -151
  57. package/dist/context/wakeRunReferences.js +11 -0
  58. package/dist/controller/agentCapabilities.js +58 -0
  59. package/dist/controller/agentRuntimeObserver.js +6 -11
  60. package/dist/controller/clientRuntime.js +22 -14
  61. package/dist/controller/controller.js +20 -24
  62. package/dist/controller/fileSchedulerStoreAdapter.js +191 -225
  63. package/dist/controller/globalInputDelivery.js +13 -0
  64. package/dist/controller/jobClient.js +4 -4
  65. package/dist/controller/jobControl.js +60 -25
  66. package/dist/controller/jobSupervisor.js +4 -4
  67. package/dist/controller/providerRetryAdmission.js +100 -0
  68. package/dist/controller/providerRetryDelivery.js +218 -0
  69. package/dist/controller/runtime.js +85 -43
  70. package/dist/controller/runtimeEventProcessor.js +0 -5
  71. package/dist/controller/sessionOwnerReconciliation.js +5 -0
  72. package/dist/controller/taskAgentError.js +35 -0
  73. package/dist/coordination/workMailboxQueue.js +2 -24
  74. package/dist/core/controllerClient.js +2 -2
  75. package/dist/core/fileLockOwner.js +74 -0
  76. package/dist/decision/decision.js +17 -0
  77. package/dist/doctor/doctor.js +18 -9
  78. package/dist/event/taskEvent.js +12 -0
  79. package/dist/execution/workItemExecutionProjection.js +2 -2
  80. package/dist/executor/agentCapabilityConfig.js +43 -0
  81. package/dist/executor/agentConfigurationCatalog.js +49 -11
  82. package/dist/executor/agentExecutor.js +5 -8
  83. package/dist/executor/fileRoleLaunchPlanner.js +11 -53
  84. package/dist/executor/taskAgentCapabilities.js +64 -0
  85. package/dist/integration/deliveryObligation.js +1 -69
  86. package/dist/integration/gitIntegrationService.js +79 -90
  87. package/dist/integration/integrationAttempt.js +3 -14
  88. package/dist/integration/integrationSourceApplication.js +4 -12
  89. package/dist/integration/manifestTags.js +2 -2
  90. package/dist/job/durableJob.js +4 -25
  91. package/dist/job/jobAssignmentScope.js +22 -0
  92. package/dist/job/jobOperation.js +16 -0
  93. package/dist/job/jobRunner.js +2 -1
  94. package/dist/job/stepDirectory.js +15 -0
  95. package/dist/kernel/builtinCapabilities.js +15 -11
  96. package/dist/kernel/kernelPorts.js +1 -17
  97. package/dist/lifecycle/exactRunTerminalization.js +5 -10
  98. package/dist/message/globalProviderRetry.js +15 -0
  99. package/dist/message/inputControlResolution.js +3 -4
  100. package/dist/message/message.js +17 -20
  101. package/dist/message/messageContinuation.js +1 -1
  102. package/dist/milestone/milestone.js +11 -0
  103. package/dist/observability/executionAudit.js +19 -0
  104. package/dist/observability/orchestrationMetrics.js +24 -1
  105. package/dist/observability/runtimeIdentity.js +1 -17
  106. package/dist/output/agentConfigurationPresentation.js +2 -0
  107. package/dist/output/timePresentation.js +1 -14
  108. package/dist/plugins/pluginService.js +12 -4
  109. package/dist/release/releaseWorkflowPorts.js +45 -96
  110. package/dist/release/runtimeRelease.js +9 -15
  111. package/dist/repository/gitWorkspace.js +371 -105
  112. package/dist/repository/projectMaintenanceLock.js +98 -82
  113. package/dist/repository/taskBaseFreshness.js +1 -1
  114. package/dist/repository/taskWorkspaceCoordinator.js +82 -144
  115. package/dist/repository/taskWorkspacePreparer.js +113 -47
  116. package/dist/repository/workspaceCleanupInspection.js +187 -0
  117. package/dist/resources/autoResourceGc.js +4 -77
  118. package/dist/resources/liveReferences.js +7 -54
  119. package/dist/resources/resourceDiscovery.js +5 -118
  120. package/dist/resources/resourceGc.js +233 -181
  121. package/dist/resources/resourceRegistrar.js +5 -4
  122. package/dist/resources/resourceRegistry.js +3 -37
  123. package/dist/resources/resourceRegistryStore.js +13 -36
  124. package/dist/resources/sqliteResourceRegistry.js +43 -26
  125. package/dist/review/deltaRecheck.js +1 -1
  126. package/dist/review/reviewAcceptance.js +1 -1
  127. package/dist/review/reviewDecision.js +1 -1
  128. package/dist/review/reviewRound.js +8 -7
  129. package/dist/review/taskFinalReviewContractResolution.js +1 -1
  130. package/dist/runtime/acpProtocol.js +4 -51
  131. package/dist/runtime/acpSession.js +10 -75
  132. package/dist/runtime/acpSessionConfiguration.js +1 -8
  133. package/dist/runtime/agentEndpoint.js +3 -2
  134. package/dist/runtime/agentError.js +5 -3
  135. package/dist/runtime/agentFailureContext.js +43 -0
  136. package/dist/runtime/agentHost.js +42 -25
  137. package/dist/runtime/builtinAgentErrorMappers.js +91 -0
  138. package/dist/runtime/codexAppServerRuntime.js +34 -3
  139. package/dist/runtime/codexInteractiveHost.js +2 -2
  140. package/dist/runtime/index.js +0 -1
  141. package/dist/runtime/managedCaller.js +21 -1
  142. package/dist/runtime/providerControl.js +5 -1
  143. package/dist/runtime/providerErrors.js +38 -0
  144. package/dist/runtime/providerRetry.js +198 -0
  145. package/dist/runtime/providerRuntimeIdentity.js +28 -2
  146. package/dist/runtime/runtimeObservation.js +0 -5
  147. package/dist/runtime/runtimeSessionCandidate.js +2 -3
  148. package/dist/runtime/sessionOwnerIdentity.js +1 -1
  149. package/dist/runtime/sessionTokenMetrics.js +15 -5
  150. package/dist/runtime/structuredProviderHost.js +10 -43
  151. package/dist/runtime/taskUsageMetrics.js +275 -0
  152. package/dist/runtime/tmuxAdapters.js +6 -8
  153. package/dist/scheduler/activeRoleRunDelivery.js +19 -7
  154. package/dist/scheduler/leaderWakeupProcessor.js +24 -6
  155. package/dist/scheduler/operatorEvent.js +12 -20
  156. package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
  157. package/dist/scheduler/ports.js +5 -8
  158. package/dist/scheduler/roleRunLiveness.js +4 -4
  159. package/dist/scheduler/roleRunStall.js +16 -23
  160. package/dist/scheduler/taskExecutionProjection.js +49 -36
  161. package/dist/scheduler/taskObservabilityProjection.js +6 -45
  162. package/dist/scheduler/taskWake.js +5 -10
  163. package/dist/scheduler/wakeReason.js +2 -0
  164. package/dist/scheduler/wakeupQueue.js +2 -4
  165. package/dist/setup/setupCommand.js +1 -1
  166. package/dist/storage/contextRecords.js +106 -0
  167. package/dist/storage/currentTaskStore.js +1 -1
  168. package/dist/storage/homeLayout.js +13 -17
  169. package/dist/storage/migrations/agentFailureContext.js +22 -0
  170. package/dist/storage/migrations/currentInputContract.js +86 -0
  171. package/dist/storage/migrations/currentRuntimeContract.js +228 -0
  172. package/dist/storage/migrations/historicalVerificationPlan.js +35 -0
  173. package/dist/storage/migrations/integrationContinuation.js +5 -4
  174. package/dist/storage/migrations/narrowAgentFailureContext.js +65 -0
  175. package/dist/storage/migrations/notificationOnlyWakes.js +74 -0
  176. package/dist/storage/migrations/verificationPlanV1.js +162 -0
  177. package/dist/storage/migrations/verificationPolicy.js +74 -0
  178. package/dist/storage/migrations/workItemHistory.js +46 -0
  179. package/dist/storage/persistenceWorker.js +12 -4
  180. package/dist/storage/recordValidation.js +87 -0
  181. package/dist/storage/sqliteSchema.js +173 -1
  182. package/dist/storage/sqliteStore.js +172 -161
  183. package/dist/storage/storageSchema.js +2 -14
  184. package/dist/storage/storageVersions.js +1 -1
  185. package/dist/storage/storeRpc.js +16 -7
  186. package/dist/storage/taskCatalog.js +123 -0
  187. package/dist/storage/taskStore.js +5 -7
  188. package/dist/storage/upgrade/upgradeOrchestrator.js +25 -37
  189. package/dist/task/archiveDiagnostics.js +1 -0
  190. package/dist/task/archivePreflight.js +124 -0
  191. package/dist/task/completionReadiness.js +5 -24
  192. package/dist/task/draftPlan.js +0 -53
  193. package/dist/task/nextAction.js +7 -13
  194. package/dist/task/publicationAdoption.js +56 -0
  195. package/dist/task/publicationReference.js +10 -0
  196. package/dist/task/remoteDelivery.js +31 -16
  197. package/dist/task/remoteDeliveryService.js +89 -0
  198. package/dist/task/taskActivation.js +2 -25
  199. package/dist/task/taskActivationService.js +0 -2
  200. package/dist/task/taskRecordReference.js +0 -1
  201. package/dist/task/taskSubmission.js +3 -14
  202. package/dist/telemetry/sqliteTelemetryBatch.js +29 -0
  203. package/dist/telemetry/sqliteTelemetryStore.js +49 -49
  204. package/dist/telemetry/telemetryWiring.js +4 -3
  205. package/dist/tmux/tmuxManager.js +29 -20
  206. package/dist/verification/gateArtifact.js +15 -24
  207. package/dist/verification/gateArtifactStore.js +14 -7
  208. package/dist/verification/verificationGateService.js +29 -88
  209. package/dist/verification/verificationPlan.js +27 -72
  210. package/dist/web/assets/client/app.js +92 -17
  211. package/dist/web/assets/client/components.js +55 -13
  212. package/dist/web/assets/client/i18n.js +72 -4
  213. package/dist/web/assets/client/taskSurface.js +6 -5
  214. package/dist/web/assets/client/view.js +35 -7
  215. package/dist/web/assets/shell.js +6 -0
  216. package/dist/web/assets/styles/layout.js +7 -0
  217. package/dist/web/webServer.js +12 -3
  218. package/dist/web/webSnapshot.js +14 -85
  219. package/dist/web/webTaskSurface.js +17 -46
  220. package/dist/workItem/workItem.js +1 -12
  221. package/dist/workspace/cleanupInspection.js +63 -0
  222. package/dist/workspace/workItemChangeSetManager.js +110 -50
  223. package/docs/agent-result-consumption.md +4 -0
  224. package/docs/agent-result-consumption.zh-CN.md +3 -0
  225. package/docs/agent-runtime-drivers.md +7 -0
  226. package/docs/agent-runtime-drivers.zh-CN.md +5 -0
  227. package/docs/architecture/README.md +2 -0
  228. package/docs/architecture/README.zh-CN.md +3 -1
  229. package/docs/architecture/capabilities-and-resources.md +42 -5
  230. package/docs/architecture/capabilities-and-resources.zh-CN.md +33 -3
  231. package/docs/managed-turn-and-session-runtime.md +121 -1
  232. package/docs/managed-turn-and-session-runtime.zh-CN.md +96 -2
  233. package/docs/observability/README.md +62 -0
  234. package/docs/observability/README.zh-CN.md +47 -0
  235. package/docs/plugin-sdk.md +4 -2
  236. package/docs/project-refresh.md +77 -0
  237. package/docs/project-refresh.zh-CN.md +59 -0
  238. package/docs/provider-retry.md +70 -0
  239. package/docs/provider-runtime.md +3 -1
  240. package/docs/provider-runtime.zh-CN.md +4 -2
  241. package/docs/release-workflow.md +190 -7
  242. package/docs/release-workflow.zh-CN.md +139 -5
  243. package/docs/roles-and-configuration.md +29 -0
  244. package/docs/roles-and-configuration.zh-CN.md +21 -0
  245. package/docs/sqlite-control-plane-design.md +16 -3
  246. package/docs/sqlite-control-plane-design.zh-CN.md +13 -2
  247. package/docs/task-dag-semantics.md +3 -3
  248. package/docs/task-dag-semantics.zh-CN.md +2 -2
  249. package/docs/task-delivery.md +223 -17
  250. package/docs/task-delivery.zh-CN.md +171 -14
  251. package/docs/task-discovery.md +101 -0
  252. package/docs/task-discovery.zh-CN.md +85 -0
  253. package/docs/testing/verification-levels.md +161 -9
  254. package/docs/testing/verification-levels.zh-CN.md +116 -9
  255. package/i18n/README.zh-CN.md +13 -7
  256. package/package.json +1 -1
  257. package/skills/yui-leader/SKILL.md +5 -0
  258. package/skills/yui-leader/references/execution.md +3 -2
  259. package/skills/yui-leader/references/integration.md +9 -5
  260. package/skills/yui-leader/references/planning.md +9 -3
  261. package/skills/yui-operator/SKILL.md +24 -8
  262. package/skills/yui-reviewer/SKILL.md +4 -0
  263. package/skills/yui-runtime/SKILL.md +17 -2
  264. package/skills/yui-runtime/references/publication.md +26 -4
  265. package/skills/yui-runtime/references/recovery.md +71 -0
  266. package/dist/agent/agentRegistry.js +0 -10
  267. package/dist/agentRun/runIdentity.js +0 -22
  268. package/dist/commands/deliveryGuardPreflight.js +0 -30
  269. package/dist/commands/taskIntegrationQueueCommands.js +0 -226
  270. package/dist/commands/taskOverviewCommand.js +0 -376
  271. package/dist/completion/completionWizard.js +0 -125
  272. package/dist/context/dispatchContext.js +0 -110
  273. package/dist/context/wakeNotification.js +0 -144
  274. package/dist/integration/integrationCheckEvidenceReuse.js +0 -53
  275. package/dist/integration/integrationQueueEntry.js +0 -191
  276. package/dist/integration/integrationQueueService.js +0 -810
  277. package/dist/release/fakeReleasePorts.js +0 -55
  278. package/dist/runtime/sessionOwnerRegistry.js +0 -137
  279. package/dist/task/deliveryGuard.js +0 -226
  280. /package/dist/{commands/taskActor.js → task/taskAuthority.js} +0 -0
@@ -2,18 +2,18 @@ import { spawn } from "node:child_process";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { findLiveControllerProcessForHome, inspectLiveControllerProcess } from "../core/controllerProcessIdentity.js";
4
4
  import { readHomeFilesystemId } from "../core/homeFilesystemIdentity.js";
5
+ import { AGENT_OPERATIONAL_ENVIRONMENT_NAMES, nativeAgentEnvironmentNames, operationalAgentEnvironment, selectEnvironment, YUI_MANAGED_RUNTIME_ENVIRONMENT_NAMES } from "../agent/launchEnvironment.js";
5
6
  import { callController, ControllerClientError, readControllerDiscovery, stopOrphanedFileTaskController } from "../core/controllerClient.js";
6
7
  import { FILE_TASK_CONTROLLER_PROTOCOL_VERSION } from "../core/protocol.js";
7
- import { AGENT_OPERATIONAL_ENVIRONMENT_NAMES, nativeAgentEnvironmentNames, operationalAgentEnvironment, selectEnvironment, YUI_MANAGED_RUNTIME_ENVIRONMENT_NAMES } from "../agent/launchEnvironment.js";
8
- import { openCurrentTaskStore } from "../storage/currentTaskStore.js";
8
+ import { isForeignHandoverLockHeld } from "../release/runtimeRelease.js";
9
+ import { WorkspaceCleanupBlockedError } from "../repository/taskWorkspacePreparer.js";
9
10
  import { hasRuntimeLifecycleWork } from "../runtime/lifecycleReservation.js";
10
11
  import { assertControllerStatusIdentity } from "../runtime/runtimeCoherence.js";
11
- import { EPHEMERAL_DOMAIN_ENVIRONMENT_NAMES } from "./domainIdentity.js";
12
+ import { CONTROLLER_SHUTDOWN_TIMEOUT_MS, LIFECYCLE_REQUEST_TIMEOUT_MS } from "../runtime/runtimeDeadlines.js";
13
+ import { openCurrentTaskStore } from "../storage/currentTaskStore.js";
12
14
  import { yuiVersionIdentity } from "../version.js";
15
+ import { EPHEMERAL_DOMAIN_ENVIRONMENT_NAMES } from "./domainIdentity.js";
13
16
  import { SessionOwnerReconciliation } from "./sessionOwnerReconciliation.js";
14
- import { WorkspaceCleanupBlockedError } from "../repository/taskWorkspacePreparer.js";
15
- import { CONTROLLER_SHUTDOWN_TIMEOUT_MS, LIFECYCLE_REQUEST_TIMEOUT_MS } from "../runtime/runtimeDeadlines.js";
16
- import { isForeignHandoverLockHeld } from "../release/runtimeRelease.js";
17
17
  const STARTUP_TIMEOUT_MS = 5_000;
18
18
  const POLL_INTERVAL_MS = 50;
19
19
  const ENVIRONMENT_REFRESH_TIMEOUT_MS = 500;
@@ -166,7 +166,7 @@ function assertCompatibleControllerStatus(status, expectedVersion) {
166
166
  });
167
167
  }
168
168
  }
169
- function spawnDetachedFileTaskController(home, environment) {
169
+ function spawnDetachedFileTaskController(_home, environment) {
170
170
  const child = spawn(process.execPath, [fileURLToPath(new URL("./controllerMain.js", import.meta.url))], {
171
171
  env: environment,
172
172
  detached: true,
@@ -439,9 +439,6 @@ export class FileTaskWorkflowRuntime {
439
439
  this.workspacePreparer = workspacePreparer;
440
440
  this.clientOptions = clientOptions;
441
441
  }
442
- notifyStateChanged(taskId) {
443
- void this.notifyMailboxChanged({ kind: "task", taskId });
444
- }
445
442
  notifyMailboxChanged(target) {
446
443
  const pending = callFileTaskController(this.home, "scheduler.signal", { key: controllerMailboxKey(target) }, this.clientOptions).then(() => { });
447
444
  void pending.catch(this.clientOptions.onError ?? (() => { }));
@@ -577,6 +574,17 @@ export class FileTaskWorkflowRuntime {
577
574
  + blockers.map((entry) => (`${entry.owner.roleName}/${entry.nativeSessionId ?? "unknown-session"}`
578
575
  + ` (pid ${entry.physical?.alive === true ? entry.physical.pid : "?"})`)).join("; "));
579
576
  }
577
+ /** Archive cleanup is stronger than a read-only proof that no process is live. */
578
+ async releaseTaskTerminals(taskId) {
579
+ await this.assertTaskPhysicalResourcesReleased(taskId);
580
+ // A Home's server is shared with other Tasks and the Operator. Remove only
581
+ // this Task's session group; exited panes still own scrollback memory.
582
+ await this.tmux.stopTaskAsync(taskId);
583
+ const remaining = this.tmux.inspectTaskRolePanes(taskId);
584
+ if (remaining.length > 0) {
585
+ throw new WorkspaceCleanupBlockedError("physical-resource-live", `task:${taskId}`, true, `Task terminals remain after cleanup: ${remaining.map(pane => pane.roleName).join(", ")}.`);
586
+ }
587
+ }
580
588
  async stopGlobalRoleSession(roleName) {
581
589
  if (this.store.getGlobalRole(roleName) === null) {
582
590
  throw new Error(`Global Role not found: ${roleName}.`);
@@ -678,11 +686,11 @@ function runtimeOwnerLabel(owner) {
678
686
  }
679
687
  const MANAGED_RUNTIME_ENVIRONMENT = new Set(YUI_MANAGED_RUNTIME_ENVIRONMENT_NAMES);
680
688
  function foregroundGlobalRoleEnvironment(store, roleName, source) {
681
- const role = store.getGlobalRole?.(roleName);
682
- if (role === null || role === undefined)
689
+ const role = store.getGlobalRole(roleName);
690
+ if (role === null)
683
691
  return undefined;
684
- const agent = store.getConfiguredAgent?.(role.activeAgentId);
685
- if (agent === null || agent === undefined)
692
+ const agent = store.getConfiguredAgent(role.activeAgentId);
693
+ if (agent === null)
686
694
  return undefined;
687
695
  const declaredSources = new Set(agent.environment.map((binding) => binding.sourceName));
688
696
  for (const name of MANAGED_RUNTIME_ENVIRONMENT)
@@ -16,7 +16,6 @@ import { nearestDeadlineBatch } from "../coordination/deadlineScheduler.js";
16
16
  import { mailboxHasWork, nextPendingBatch } from "../coordination/workMailbox.js";
17
17
  import { hasRuntimeCleanupObligation } from "../runtime/lifecycleReservation.js";
18
18
  import { formatTaskRecordReference } from "../task/taskRecordReference.js";
19
- import { activationRequestIsControllerAdoptable } from "../task/taskActivation.js";
20
19
  import { parseDurableJobAcknowledgeParams, parseDurableJobCancelParams, parseDurableJobRefParams, parseDurableJobStartParams } from "./jobControl.js";
21
20
  const DEFAULT_RECONCILIATION_INTERVAL_MS = reconciliationIntervalMilliseconds();
22
21
  const DEFAULT_SIGNAL_WINDOW_MS = 100;
@@ -217,8 +216,7 @@ async function processSelectedRoleRuntimeCleanups(store, delivery, lifecycleHost
217
216
  if (!await lifecycleHost.stopOwner(owner)) {
218
217
  throw new Error(`Role runtime cleanup could not confirm the host stopped: ${runtimeOwnerLabel(owner)}.`);
219
218
  }
220
- if (store.completeRuntimeCleanup === undefined
221
- || !store.completeRuntimeCleanup(target, now)) {
219
+ if (!store.completeRuntimeCleanup(target, now)) {
222
220
  throw new Error(`Role runtime cleanup mailbox changed: ${runtimeOwnerLabel(owner)}.`);
223
221
  }
224
222
  forgetPreparedRuntimeOwner(delivery, owner);
@@ -252,7 +250,7 @@ function selectedTaskIdsForBoundedPass(store, selection) {
252
250
  return new Set(selectedActiveSchedulerTasks(store, selection).map((task) => task.id));
253
251
  }
254
252
  function selectedReadyWorkMailboxes(store) {
255
- return store.listReadyWorkMailboxes?.() ?? store.listWorkMailboxes();
253
+ return store.listReadyWorkMailboxes();
256
254
  }
257
255
  function selectedRuntimeLifecycleTargets(store, scope, blockedTaskIds = new Set()) {
258
256
  if (scope.kind === "full") {
@@ -456,9 +454,9 @@ export function compileReconcileSelection(scope) {
456
454
  };
457
455
  }
458
456
  /**
459
- * Adopts activation requests whose deferral has been released.
457
+ * Continues admitted activation requests once their execution boundaries allow it.
460
458
  *
461
- * The deferral is only ever released by the planning Turn ending, so this phase
459
+ * A planning deferral is released only by its Turn ending. This phase therefore
462
460
  * re-reads the request instead of trusting the signal that woke it: a request
463
461
  * cancelled, or a Task retired or stopped, while the Turn was still running is
464
462
  * left alone rather than replayed as historical intent. Adoption itself belongs
@@ -475,10 +473,7 @@ async function adoptReleasedTaskActivations(store, workspace, selection, onError
475
473
  if (workspace === undefined)
476
474
  return;
477
475
  const candidates = selection.full
478
- ? (store.listPendingActivationRequestTaskIds?.()
479
- ?? store.listTasks().flatMap((task) => (task.status === "draft" && task.activationRequest?.disposition === "pending"
480
- ? [task.id]
481
- : [])))
476
+ ? store.listPendingActivationRequestTaskIds()
482
477
  : selection.taskIds;
483
478
  for (const taskId of candidates) {
484
479
  if (selection.blockedTaskIds?.has(taskId))
@@ -489,20 +484,14 @@ async function adoptReleasedTaskActivations(store, workspace, selection, onError
489
484
  const request = task.activationRequest;
490
485
  if (request?.disposition !== "pending")
491
486
  continue;
492
- // Continue only requests with a provable source: a released deferral, or an
493
- // immediate request carrying a recognised origin (explicit action, or a
494
- // develop submission accepted while unplanned). This admits legal
495
- // Operator/user immediate requests the old actor filter dropped, while
496
- // still refusing origin-less historical requests, which stay behind the
497
- // explicit `yui task activate` boundary.
498
- if (!activationRequestIsControllerAdoptable(request))
499
- continue;
487
+ // The request was authorized at admission. Recheck its current execution
488
+ // and Session boundaries without a second provenance-based workflow gate.
500
489
  // Later Draft discussion is a Session notification, not another AgentRun.
501
490
  // Its durable activation intent is sufficient once the exact native input
502
491
  // is settled. Never create a synthetic Run merely to release that intent.
503
492
  if (store.getActiveRun(taskId, "leader") !== null)
504
493
  continue;
505
- const provider = store.getTaskRoleSessionSet?.(taskId, "leader")?.providerBinding;
494
+ const provider = store.getTaskRoleSessionSet(taskId, "leader")?.providerBinding;
506
495
  if (provider?.run != null
507
496
  && ["submitting", "accepted", "delivery-unknown"].includes(provider.run.status))
508
497
  continue;
@@ -663,7 +652,6 @@ function mergeControllerSchedulerResults(results) {
663
652
  export class FileTaskController {
664
653
  store;
665
654
  delivery;
666
- #startedAt;
667
655
  #intervalMs;
668
656
  #now;
669
657
  #onError;
@@ -702,6 +690,7 @@ export class FileTaskController {
702
690
  #leaderWakeFence;
703
691
  #jobSupervisor;
704
692
  #globalInputDelivery;
693
+ #providerRetry;
705
694
  #continuationReconciler;
706
695
  #current;
707
696
  #operatorCurrent;
@@ -711,6 +700,7 @@ export class FileTaskController {
711
700
  #operatorStartupRetryArmed = false;
712
701
  #lastOperatorSignalIdentity;
713
702
  #stopped = false;
703
+ #workspaceWaitAbort = new AbortController();
714
704
  #lastRuntimeDrain;
715
705
  #runtimeDrainPasses = 0;
716
706
  #runtimeListedEvents = 0;
@@ -722,9 +712,12 @@ export class FileTaskController {
722
712
  this.delivery = delivery;
723
713
  this.#intervalMs = positiveInteger(options.intervalMs, DEFAULT_RECONCILIATION_INTERVAL_MS, "Controller reconciliation interval");
724
714
  this.#now = options.now ?? (() => new Date());
725
- this.#startedAt = this.#now();
726
715
  this.#onError = options.onError ?? (() => { });
727
- this.#workspacePreparer = options.workspacePreparer;
716
+ const workspacePreparer = options.workspacePreparer;
717
+ this.#workspacePreparer = workspacePreparer === undefined ? undefined : {
718
+ prepareTaskWorkspace: (taskId) => workspacePreparer.prepareTaskWorkspace(taskId, this.#workspaceWaitAbort.signal),
719
+ activateTaskWorkspace: (taskId, environment) => workspacePreparer.activateTaskWorkspace(taskId, environment, this.#workspaceWaitAbort.signal)
720
+ };
728
721
  this.#deliveryRetryMs = positiveInteger(options.deliveryRetryMs, DEFAULT_DELIVERY_RETRY_MS, "Controller delivery retry delay");
729
722
  this.#deliveryRetryLimit = positiveInteger(options.deliveryRetryLimit, DEFAULT_DELIVERY_RETRY_LIMIT, "Controller delivery retry limit");
730
723
  this.#deliveryTimeoutMs = positiveInteger(options.deliveryTimeoutMs, DEFAULT_DELIVERY_TIMEOUT_MS, "Controller delivery timeout");
@@ -749,6 +742,7 @@ export class FileTaskController {
749
742
  this.#jobSupervisor = options.jobSupervisor;
750
743
  this.#continuationReconciler = options.continuationReconciler;
751
744
  this.#globalInputDelivery = options.globalInputDelivery;
745
+ this.#providerRetry = options.providerRetry;
752
746
  this.#signalScheduler = new MailboxScheduler(async (keys) => { await this.#requestPass({ kind: "dirty", keys }); }, {
753
747
  windowMs: options.signalWindowMs ?? DEFAULT_SIGNAL_WINDOW_MS,
754
748
  onError: this.#onError,
@@ -846,6 +840,7 @@ export class FileTaskController {
846
840
  }
847
841
  stop() {
848
842
  this.#stopped = true;
843
+ this.#workspaceWaitAbort.abort(new Error("Controller stopped while waiting for Project maintenance."));
849
844
  this.#signalScheduler.stop();
850
845
  this.#operatorSignalScheduler.stop();
851
846
  if (this.#deadlineTimer !== undefined) {
@@ -988,6 +983,7 @@ export class FileTaskController {
988
983
  }
989
984
  }
990
985
  const firstRuntimeDrain = await this.#drainRuntimeEvents();
986
+ await this.#providerRetry?.reconcile();
991
987
  await this.#globalInputDelivery?.();
992
988
  for (const taskId of runtimeTaskFailureIds(firstRuntimeDrain)) {
993
989
  runtimeFailedTaskIds.add(taskId);
@@ -1331,7 +1327,7 @@ export class FileTaskController {
1331
1327
  at: Date.parse(request.policy.timeoutAt)
1332
1328
  }]
1333
1329
  : []);
1334
- const nearest = nearestDeadlineBatch(deadlines);
1330
+ const nearest = nearestDeadlineBatch([...deadlines, ...(this.#providerRetry?.deadlines() ?? [])]);
1335
1331
  if (nearest === null)
1336
1332
  return;
1337
1333
  const now = this.#now().getTime();
@@ -1640,7 +1636,7 @@ export async function startFileTaskController(home, store, delivery, dispatcher,
1640
1636
  }
1641
1637
  if (method === "job.get") {
1642
1638
  const ref = parseDurableJobRefParams(params);
1643
- const job = control.getJob(ref.taskId, ref.jobId);
1639
+ const job = control.getJob(ref.taskId, ref.jobId, ref.caller);
1644
1640
  if (job === null) {
1645
1641
  throw controllerApplicationError("NOT_FOUND", `DurableJob not found: ${ref.taskId}/${ref.jobId}.`);
1646
1642
  }