@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
@@ -0,0 +1,79 @@
1
+ # 能力、资源与 Surface
2
+
3
+ ## 唯一入口与原始事实
4
+
5
+ Controller 承载 CapabilityRegistry 和 InstanceHost。`capability search`、
6
+ `describe`、`call` 使用同一认证入口,先解析当前 Session 身份和 Task 范围,
7
+ 再检查能力与资源权限。输入中的 actor 或自称的 user scope 不能授予权限。
8
+
9
+ 描述符包含名称、合同版本、Provider、scope、输入输出 schema、effect 和
10
+ requiredPermissions。查询只展示获授权的目录;同名 Provider 或版本有歧义时,
11
+ 调用者明确选择,不按加载顺序决定。Schema 是有界方言,未知关键词拒绝。
12
+
13
+ 当前目录覆盖 context、message、artifact、environment、resource、project、
14
+ plugin 和部分 task/job 操作。Task 生命周期与部分 CLI/Web 写入直接共享
15
+ 领域命令;这些不是另一份业务状态,也不假称已经通过 Registry 执行。
16
+
17
+ ## 效果与操作事实
18
+
19
+ 能力返回值与真实效果分开。一次调用即使输出校验失败,也可能已产生确认的
20
+ 子操作;返回结果必须保留原 owner 的 operationRef 和 receipt。Unknown
21
+ 不能解释为未执行,不进行自动 fallback。
22
+
23
+ 嵌套调用重新检查当前权限,不能扩大父调用声明的权限与效果。requestId 标识
24
+ 调用,不自动提供所有业务的通用幂等性;Job 等 owner 执行自己的精确幂等合同。
25
+ 错误后先读取原操作事实再决定下一步。
26
+
27
+ ## 实现实例
28
+
29
+ InstanceHost 管理 attach、acquire、release、detach 与实际引用。替换发布后,
30
+ 新调用选择新实现;已有引用继续绑定原实现,排空后才能 dispose。查询是观察,
31
+ 不启动或恢复代码。清理失败保留诊断,不把新发布反转为失败,也不伪造排空。
32
+
33
+ Session 的长引用由实际 AgentHost 固定到所加载实现。Controller 传递已有 pin,
34
+ 不把活 Session 静默搬到另一份代码。结束客户端与共享 Provider 物理静止分别判断。
35
+
36
+ ## Project 与工作区
37
+
38
+ Project 保存参考 checkout、Knowledge 与资源引用。稳定 checkout 只读;Task
39
+ 交付发生在受管 worktree。多 Project Task 使用独立 Git 根和明确写范围。
40
+ 工作区 owner 属于 Task、WorkItem、ReviewRound 或 IntegrationAttempt。
41
+ Role 仅选择执行配置,不独立拥有另一份工作区状态。
42
+
43
+ Git 集成捕获精确 ChangeSet,在候选 worktree 检查后 CAS 推进目标。
44
+ 冲突、检查失败、目标移动与拒绝都不更新目标,Agent 决定下一次操作。
45
+
46
+ ## Artifact 与环境
47
+
48
+ - `artifact.save/read/list` 保存不可变内容、外部版本证据、Job 回执或引用资料。
49
+ Reference 不等于固定交付成果;最终结果不能选择缺失或跨 Task Artifact。
50
+ - `environment.prepare` 准备 empty、scratch 或获授权 local 目录,不自动采用。
51
+ - `environment.adopt` 复核身份、资源意图、权限与冲突后保存所有权。
52
+ - `environment.bind` 选择 Role 下一次原生执行环境;`null` 返回 managed workspace。
53
+ - `environment.release` 检查真实引用和静止证据,不删除用户目录。
54
+
55
+ Adopted native launch 保留目录身份、access、isolation 与 preparation 引用,
56
+ 在 launch、resume 和 Yui 输入边界复核。撤权不能靠新 grant 静默重新采用旧环境。
57
+ Read-only 环境的支持取决于实现;不能将目录 access 标签视为通用 OS 沙箱。
58
+
59
+ ## 插件与自扩展
60
+
61
+ Task Leader 或 global Operator 可以管理该 Task 的插件;Worker/Reviewer 不能
62
+ 自行管理或授信。声明式插件不执行任意代码;trusted-local 插件执行还需要精确
63
+ 源码或产物摘要、环境和阶段的 grant。
64
+
65
+ Store 保存 enabled 意图及验证产物,Host 保存实际实例。重启后 enabled 仍可读,
66
+ actual 可以为空,必须显式激活。原 Task 可以发现并调用新能力,不必修改自身
67
+ 原生工具 schema。业务结果应保存为 Artifact,而不是依赖插件继续存活。
68
+
69
+ 完整作者、授权及失败合同见[插件 SDK](../plugin-sdk.md)。
70
+
71
+ ## CLI 与 Web
72
+
73
+ Surface contribution 由 Registry 当前获授权目录派生,没有第二份目录或 Host。
74
+ CLI contribution 使用能力原名称。Web panel 只接受受控 text、HTTP(S) link 或
75
+ JSON query 描述,不接受作者脚本或任意 HTML。
76
+
77
+ Web listener 由 Controller 启停,仅允许 loopback。浏览器写入通过现有领域
78
+ 事务,错误区分确定未提交与提交结果未知。查询面板不能借浏览器身份执行 mutation
79
+ 或插件管理。终端连接只 attach 客户端,不接管原生对话的持久所有权。
@@ -0,0 +1,222 @@
1
+ # Session, AgentRun and notifications
2
+
3
+ ## Authority
4
+
5
+ Task, WorkItem, Message, Decision, Artifact and Project Knowledge preserve
6
+ durable work. Session identifies a native conversation and its captured
7
+ authority. AgentRun records an explicitly requested execution and original
8
+ result. AgentHost is a disposable attachment, not the owner of Task truth.
9
+
10
+ A current, non-revoked Leader Session can read Context and save scoped Task
11
+ facts, including a formal InputRequest, without an active Run. Its exact
12
+ Session is the request's origin; an actual Run is included when present.
13
+ The question survives that execution ending and remains open until answered
14
+ or cancelled. Worker and Reviewer commands retain exact
15
+ Assignment checks. Session replacement, Role binding, Task scope and resource
16
+ grants are checked at their respective boundaries. An active Run pointer is not
17
+ proof that an unrelated command in the same Session came from that Run.
18
+
19
+ Native chat, Goal continuations and ordinary Leader notifications do not
20
+ automatically create Runs. Explicit dispatch loads one exact Run Context Pack.
21
+
22
+ ## Context
23
+
24
+ ```sh
25
+ yui task context <task> --json
26
+ yui task context delta <task> --after <coreCursor>
27
+ yui task context inspect <task> --store <store> --ref <id>
28
+ yui task run context <task/run> --json
29
+ ```
30
+
31
+ Task Context is a bounded authorized working set with a current core cursor.
32
+ Delta pages immutable events through a fixed upper bound; inspect expands a
33
+ current record and can require an exact digest. Runtime observations state their
34
+ own coverage and do not become another durable snapshot.
35
+
36
+ Run Context freezes Assignment, source references, effective configuration and
37
+ workspace boundaries. A Role edit does not rewrite an existing Assignment.
38
+ Reading either Context does not acknowledge input or create execution authority.
39
+ Every managed input points to the exact Session Manifest and CLI entry. The
40
+ Run Pack is a reference directory: read the relevant requirement and message
41
+ bodies before acting, rather than treating a successful load as the deliverable.
42
+ Planning Packs expose no Project write scope or Task-completion permission.
43
+
44
+ Current Task reads also expose untargeted user/Operator messages to the Task's
45
+ current Worker and Reviewer Sessions, including requirements added after their
46
+ Run snapshot was frozen. Use `task message list/show` or Task Context inspect
47
+ to read those original records. This does not rewrite the frozen Assignment or
48
+ grant delivery authority. Directed messages, other Roles' results and other
49
+ Tasks remain outside the caller's scope unless its Assignment authorizes them.
50
+
51
+ ## Dispatch and notification
52
+
53
+ An explicit dispatch persists execution intent before native submission.
54
+ Ordinary Leader wake instead claims a fixed TaskWake/mailbox batch and submits
55
+ a notification through the same Host/Endpoint. Confirmed acceptance consumes
56
+ only that batch; later input remains pending. A notification requires no final
57
+ execution report and does not force steer into a busy native conversation.
58
+
59
+ Leader-local edits preserve durable events but do not create self-wakes.
60
+ Other sources' input remains durable while the Leader is busy or unavailable.
61
+ Operator notifications likewise carry TaskEvent/InputRequest read pointers,
62
+ not duplicated Task narrative.
63
+ Human input, explicit execution entry and activation failure are delivered
64
+ promptly through the existing wake mechanism. Worker results retain their
65
+ aggregation window. Busy native input still preserves pending messages.
66
+
67
+ | Evidence | Disposition |
68
+ | --- | --- |
69
+ | Busy with proven non-acceptance | Preserve input; a new transport attempt may use the same Session |
70
+ | Native acceptance | Never resend; wait for the exact terminal if this is an execution |
71
+ | Transport write only | Retain transport evidence; do not claim native acceptance |
72
+ | Explicit rejection | Retain the original cause and settle the corresponding admission |
73
+ | Unknown acceptance/effect | Retain the attempt and conflicting-resource fences; do not replay or switch Session |
74
+
75
+ Missing receipt after a crash is not proof of non-acceptance. Structured
76
+ `SESSION_BUSY` is evidence; text containing “busy” is not a retry contract.
77
+
78
+ ## Continue existing work
79
+
80
+ ```sh
81
+ yui task message send <task> "Continue with the clarified requirement" \
82
+ --to <role> --work-item <work-item>
83
+ yui task message handoff <task/message> --to <successor-role>
84
+ ```
85
+
86
+ Review clarification uses `--review-round` instead of `--work-item`.
87
+ Message retains recipient, work association and owner Run. When the Role is
88
+ busy, saving returns without interrupting it. Once it becomes available, a
89
+ bounded ordered batch can create a continuation Run atomically associated with
90
+ those messages. The existing Assignment, effective permissions, workspace and
91
+ unfinished files remain; the snapshot adds authorized messages and the preceding
92
+ original result. Duplicate terminals cannot assign the messages twice.
93
+
94
+ Ownership changes, incompatible Sessions, terminal work and obsolete Review
95
+ candidates retain visible nondelivery reasons. Explicit handoff only targets an
96
+ already-dispatched successor for the same work. Replicated Producer/synthesis
97
+ lineage is not silently rewritten by a message.
98
+
99
+ Unknown Leader notifications preserve their wake and input window:
100
+
101
+ ```sh
102
+ yui task wake show <task> <wake>
103
+ yui task wake resolve <task> <wake> --reason <quiescence-evidence>
104
+ ```
105
+
106
+ Resolve releases the claim after native-effect fences are clear. It neither
107
+ replays the notification nor invents acceptance or completion. Independent
108
+ Role work and legal local facts are not a Task-wide recovery lock.
109
+
110
+ ## Exact results
111
+
112
+ The native terminal settles only the matching execution. Known native Turn IDs
113
+ must match; a serialized stream may use proven local attempt correlation.
114
+ Message UUIDs are not native Turn IDs. Unrelated native chat in the same Session
115
+ cannot complete the pending Yui request.
116
+
117
+ The terminal transaction saves one AgentRunResult and a reference Message.
118
+ `resultRef: { type: "agent-run-result", runId: "run-12" }` expands the original
119
+ report rather than copying it. Candidate and ReviewRound retain provenance;
120
+ Core does not derive semantic acceptance from prose.
121
+
122
+ Cancellation requests do not prove physical quiescence. Exact terminal evidence
123
+ preserves partial output and settles the original execution only. Host exit
124
+ does not imply shared Provider or descendant processes have stopped.
125
+
126
+ ## Draft planning and activation
127
+
128
+ `EffectiveLaunchSnapshot.executionAuthority` captures `planning | delivery`.
129
+ It is not recalculated from the Task's current lifecycle. Planning permits
130
+ local planning facts, not delivery dispatch, candidate adoption, integration or
131
+ delivery workspace Jobs.
132
+
133
+ The initial Draft planning dispatch creates a planning Run and binds only its
134
+ initial message batch. Acceptance or an exact terminal consumes that batch;
135
+ failure does not repeatedly recreate the same planning execution. Subsequent ordinary
136
+ messages in the existing planning Session remain notifications. Operator submit
137
+ and direct Task messages both reach that Session. Draft plan/WorkItem edits
138
+ preserve execution history; external edits notify the Leader, while its own
139
+ planning edits do not create a self-wake.
140
+
141
+ New Draft Roles use a Task-specific planning directory under
142
+ `<YUI_HOME>.task-runtimes/planning`, outside the control Home and delivery trees.
143
+ A planning Run can use `task activation request` to persist intent and return an
144
+ `afterPlanningRun` reference immediately. Its terminal releases the request for
145
+ Controller admission; cancelled intent is not resurrected.
146
+ The Leader can also request activation during ordinary discussion without an
147
+ AgentRun: the Controller adopts its durable intent once the native input is
148
+ settled. No synthetic Run or extra user “continue” is required.
149
+
150
+ For bound Git Projects, `--environment empty` means no additional environment:
151
+ the Projects still receive managed worktrees. `scratch` selects a Task-owned
152
+ directory. `local` requires a registered local Resource and its grant; a Project
153
+ ID is not a local Resource ID.
154
+
155
+ Resource preparation precedes the atomic adoption of Task status and workspace
156
+ ownership. A failed adoption records a failed request and notifies the Leader
157
+ with durable facts; it does not repeatedly prepare resources on unchanged
158
+ failure. The Leader chooses an explicit retry or corrected request. Successful
159
+ activation likewise leaves a delivery notification for the Leader.
160
+ Activation never mutates the live Session into delivery authority. A changed
161
+ launch must pass the existing Session replacement/environment boundary.
162
+ Planning authority is a CLI guarantee, not a hostile-code filesystem sandbox.
163
+
164
+ ## Inspection and lifecycle
165
+
166
+ ```sh
167
+ yui task run list <task>
168
+ yui task run show <task/run> --json
169
+ yui task message show <task/message>
170
+ yui task role session inspect <task> <role>
171
+ yui task execution start <task>
172
+ yui task execution stop <task> --force --reason <reason>
173
+ ```
174
+
175
+ Task execution start/stop controls Task admission, not Task acceptance.
176
+ Stop first fences new Yui work, then interrupts each exact owned native input
177
+ and confirms its terminal before removing the attachment. This also covers
178
+ ordinary Leader notifications without Runs. Unknown native state blocks cleanup;
179
+ stopping a proxy alone never proves a shared Turn ended. Start preserves durable
180
+ progress and admits new input after the old occupancy is settled.
181
+ Draft planning can be paused/resumed, and a failed planning Run retries with
182
+ planning authority. An authorized user/Operator can stop an idle Draft Session
183
+ through `task role session stop`; it need not activate the Task merely to recover.
184
+ `task role session new <task> <role> --reason <reason>` persists an explicit
185
+ replacement request. Reuse is a preference, not a requirement to prove the old
186
+ conversation unrecoverable. The request is legal while an AgentRun is active,
187
+ the Session is ended, or previous cleanup is pending. A Leader may also request
188
+ its own replacement and end its current turn.
189
+
190
+ `task role session stop` can also stop a running Role without first changing
191
+ its Run status. It retains the native conversation for possible reuse. Pending
192
+ Messages remain intent and may start a continuation after the stop; use Task
193
+ execution stop when the whole Task must remain paused. For self-replacement,
194
+ use the asynchronous `session new` request rather than a synchronous self-stop.
195
+
196
+ The existing runtime cleanup path stops the exact native execution, closes this
197
+ Role's remaining engineering attempts as cancelled, retains Session/Run history
198
+ and workspaces, and selects a fresh conversation. Other Roles and Task acceptance
199
+ remain unchanged. The Leader receives a new context notification; it decides
200
+ which Worker/Reviewer attempts to retry. Pending input references survive the
201
+ replacement, including records older than the new notification's time window.
202
+
203
+ An absent Host does not remove the recovery entry point. Codex can be inspected
204
+ and interrupted through a disposable native control connection without starting
205
+ a model. Dedicated Claude process custody is persisted independently of the
206
+ Host. Real unconfirmed execution still prevents conflicting resource reuse;
207
+ cleanup failure is a durable diagnostic routed to the supervisor, not a reason
208
+ to invent acceptance or delete the Task. A preallocated ID alone is not proof
209
+ a conversation exists.
210
+ Codex may retain `systemError` after a failed native Turn. That label alone
211
+ neither proves activity nor authorizes cleanup: Yui checks the latest native
212
+ Turn's terminal metadata and drains background execution before replacing the
213
+ Session. Unknown or still-running native work remains protected.
214
+
215
+ Released Leaders retain scoped diagnostic reads of their own Task and context,
216
+ but cannot mutate it or read another Task. Operator diagnostics and Controller
217
+ restart do not first require a healthy Controller; explicit restart can stop
218
+ only the exact same-Home process using PID/start identity when RPC is unavailable.
219
+ Operator storage diagnosis/upgrade also reaches the dedicated migration entry
220
+ without first requiring the Home to already have the target storage version.
221
+ Completion, cancellation and archive have distinct authority and resource
222
+ boundaries. Storage changes use the single [upgrade contract](sqlite-control-plane-design.md).
@@ -0,0 +1,81 @@
1
+ # Runtime observations and diagnostics
2
+
3
+ Read-only projections help an Agent distinguish durable intent, actual runtime
4
+ activity and unknown effects. They do not add a second scheduling or acceptance
5
+ authority.
6
+
7
+ ## Inspection
8
+
9
+ ```sh
10
+ yui controller status
11
+ yui execution audit --task <task-id> --json
12
+ yui task next-action <task-id>
13
+ yui task role session inspect <task-id> <role>
14
+ yui task run show <task-id>/<run-id> --json
15
+ ```
16
+
17
+ Controller status exposes the current process and Home identity. Session inspect
18
+ separates desired binding, effective launch, actual connection and Agent-reported
19
+ configuration. Run inspection exposes original input, disposition, exact result
20
+ and diagnostics. A status read does not start another Agent or acknowledge work.
21
+
22
+ ## Meaning of evidence
23
+
24
+ - Task and WorkItem lifecycle describe intent and acceptance.
25
+ - AgentRun lifecycle describes explicitly requested execution.
26
+ - Provider acceptance and native activity describe the actual input/connection.
27
+ - Host PID, tmux and resource inventory describe process observations.
28
+ - Runtime configuration distinguishes requested values from reported values.
29
+ - Tokens, durations and orchestration costs are advisory observations.
30
+
31
+ For a dedicated Claude stream, a main assistant response confirms processing
32
+ of the one current local input before its terminal result. Controller and Role
33
+ reads therefore show accepted/running once that response arrives. Startup,
34
+ echoed user input, child output and repeated old messages do not establish new
35
+ acceptance; message UUIDs are never used as native Turn IDs.
36
+
37
+ Ordinary Leader notifications are TaskWake/mailbox delivery, not Leader Runs.
38
+ Role status includes their native admission/activity even when no AgentRun is
39
+ open, and shows a retained Session's actual workspace rather than substituting
40
+ Task main when its WorkItem is terminal.
41
+ Unknown evidence remains unknown; process exit does not prove a shared Provider
42
+ stopped, and successful transport does not prove native acceptance.
43
+
44
+ Engineering control evidence can outlive the attached Session cache. Such a
45
+ Role reports retained native input as needing attention, not idle merely because
46
+ the cache is empty. Scoped Task/Session inspection remains available for diagnosis.
47
+ Replacement and native cleanup failures are durable events routed to the
48
+ supervisor, and pending input references remain readable after replacement.
49
+
50
+ Exact tool start/result events project `tool-active`, while model activity
51
+ projects `model-active`; quiet intervals do not imply a hung or finished Agent.
52
+ Tool failures are operation outcomes, not automatic Run failures. An owned
53
+ Claude execution process dying closes its exact input and marks its Session
54
+ failed, even while the supervising Host remains alive. A deliberately stopped
55
+ Session with settled native input is idle rather than a false runtime failure.
56
+
57
+ ## Execution audit
58
+
59
+ `execution audit` aggregates existing Task, Run, wake, Session, Review,
60
+ Integration, Publication, event, WorkItem, storage and orchestration evidence.
61
+ `--since` and `--until` bound the time window. Sections report their own read
62
+ errors without inventing values for missing data.
63
+
64
+ Fault classification uses Core-owned failure reasons or explicitly identified
65
+ Core diagnostic evidence. Agent-authored report prose is not parsed into
66
+ verdicts or severity. Native Agent errors retain their original payload and
67
+ standard category for the Agent to interpret with current Task context.
68
+
69
+ Cost and repeated-work advisories do not prevent a legal action, set a Review
70
+ budget or choose a recovery topology. `task next-action` is decision support,
71
+ not an automatically executed plan.
72
+
73
+ ## Privacy and resource boundary
74
+
75
+ Telemetry and caches are diagnostic material, not Task truth or a transcript
76
+ backup. Do not collect or publish credentials, private environment values or
77
+ raw Provider history merely to explain a status.
78
+
79
+ Start with exact read-only records. Process changes, cancellation, grant updates
80
+ and resource cleanup require the relevant explicit action and scope. A generic
81
+ diagnostic request does not authorize live-model, shared or production tests.