@zq-silk/yui 0.15.7 → 0.15.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/ARCHITECTURE.md +194 -399
  2. package/ARCHITECTURE.zh-CN.md +151 -0
  3. package/README.md +306 -1131
  4. package/dist/agent/adapterCatalog.js +15 -2
  5. package/dist/agent/agent.js +23 -3
  6. package/dist/agent/argumentPolicy.js +7 -1
  7. package/dist/agent/connectionPlan.js +62 -0
  8. package/dist/agent/executionComponents.js +158 -0
  9. package/dist/agent/launchEnvironment.js +31 -3
  10. package/dist/agent/managedRuntimeEnvironment.js +3 -5
  11. package/dist/{turn/turn.js → agentRun/agentRun.js} +166 -109
  12. package/dist/{turn/turnIdentity.js → agentRun/runIdentity.js} +4 -4
  13. package/dist/artifacts/artifactCapability.js +74 -0
  14. package/dist/artifacts/artifactCommitLock.js +249 -0
  15. package/dist/artifacts/artifactPaths.js +151 -0
  16. package/dist/artifacts/gitArtifactRef.js +146 -0
  17. package/dist/artifacts/managedGit.js +332 -0
  18. package/dist/artifacts/taskArtifactRepository.js +277 -0
  19. package/dist/brief/taskBrief.js +12 -0
  20. package/dist/cli/agentConfigurationPicker.js +13 -0
  21. package/dist/cli/commandCatalog.js +165 -74
  22. package/dist/cli/interactionCandidates.js +5 -5
  23. package/dist/cli/interactionPolicy.js +38 -8
  24. package/dist/cli/invocationRouter.js +1 -1
  25. package/dist/cli/managedDiagnostics.js +28 -0
  26. package/dist/cli/operatorWizard.js +1 -7
  27. package/dist/cli/roleOptionOrder.js +27 -0
  28. package/dist/cli/roleWizard.js +50 -14
  29. package/dist/cli/updateOrchestrator.js +1 -1
  30. package/dist/cli/updatePorts.js +3 -4
  31. package/dist/cli.js +245 -95
  32. package/dist/commands/agentCommands.js +72 -14
  33. package/dist/commands/capabilityCommands.js +9 -6
  34. package/dist/commands/configCommands.js +20 -20
  35. package/dist/commands/deliveryGuardPreflight.js +2 -2
  36. package/dist/commands/executionAuditCommands.js +24 -24
  37. package/dist/commands/globalRoleCommands.js +1 -1
  38. package/dist/commands/grantCommands.js +4 -4
  39. package/dist/commands/operatorCommands.js +34 -9
  40. package/dist/commands/projectCommands.js +4 -4
  41. package/dist/commands/resourcesCommands.js +2 -2
  42. package/dist/commands/roleConfiguration.js +25 -5
  43. package/dist/commands/roleRuntimeGuard.js +4 -5
  44. package/dist/commands/sessionCommands.js +3 -7
  45. package/dist/commands/taskActivationCommands.js +281 -0
  46. package/dist/commands/taskActor.js +28 -49
  47. package/dist/commands/taskCommands.js +1461 -720
  48. package/dist/commands/taskContextCommand.js +39 -583
  49. package/dist/commands/taskExecutionCommands.js +32 -32
  50. package/dist/commands/taskInputCommands.js +40 -104
  51. package/dist/commands/taskIntegrationCommands.js +3 -2
  52. package/dist/commands/taskIntegrationQueueCommands.js +1 -1
  53. package/dist/commands/taskNextActionCommand.js +8 -8
  54. package/dist/commands/taskOverviewCommand.js +33 -45
  55. package/dist/commands/taskRemoteDeliveryCommand.js +2 -2
  56. package/dist/commands/taskRoleRuntimeStatus.js +133 -102
  57. package/dist/commands/telemetryCommands.js +36 -38
  58. package/dist/config/configCatalog.js +4 -4
  59. package/dist/config/yuiConfig.js +8 -8
  60. package/dist/context/contextSnapshot.js +10 -10
  61. package/dist/context/dispatchContext.js +11 -11
  62. package/dist/context/roleSessionContext.js +6 -3
  63. package/dist/context/{turnContextPack.js → runContextPack.js} +158 -81
  64. package/dist/context/{turnInputContract.js → runInputContract.js} +73 -60
  65. package/dist/context/sessionBootstrapManifest.js +21 -2
  66. package/dist/context/sourceRunContext.js +30 -0
  67. package/dist/context/taskContext.js +481 -0
  68. package/dist/context/wakeNotification.js +27 -27
  69. package/dist/controller/agentRuntimeObserver.js +21 -24
  70. package/dist/controller/capabilityBridge.js +17 -6
  71. package/dist/controller/clientRuntime.js +65 -92
  72. package/dist/controller/controller.js +120 -188
  73. package/dist/controller/fileSchedulerStoreAdapter.js +787 -887
  74. package/dist/controller/jobControl.js +54 -85
  75. package/dist/controller/resourceInventory.js +8 -27
  76. package/dist/controller/resourceInventoryLinux.js +12 -13
  77. package/dist/controller/runtime.js +529 -479
  78. package/dist/controller/runtimeEventInbox.js +55 -25
  79. package/dist/controller/runtimeEventProcessor.js +22 -31
  80. package/dist/controller/{runtimeHookTurnFence.js → runtimeHookRunFence.js} +91 -115
  81. package/dist/controller/runtimeLaunchCoordinator.js +80 -426
  82. package/dist/controller/runtimeObservationHook.js +14 -18
  83. package/dist/controller/sessionNotify.js +16 -24
  84. package/dist/controller/sessionOwnerReconciliation.js +168 -50
  85. package/dist/controller/structuredProviderObservation.js +138 -99
  86. package/dist/coordination/workMailbox.js +3 -3
  87. package/dist/coordination/workMailboxQueue.js +36 -33
  88. package/dist/core/boundedRpc.js +8 -1
  89. package/dist/core/controllerClient.js +20 -1
  90. package/dist/core/controllerServer.js +4 -4
  91. package/dist/doctor/doctor.js +13 -2
  92. package/dist/domain/agentResultTransport.js +9 -9
  93. package/dist/execution/codexThreadNaming.js +2 -8
  94. package/dist/execution/executionHealth.js +51 -63
  95. package/dist/execution/reviewMainRun.js +137 -0
  96. package/dist/execution/workItemExecution.js +28 -29
  97. package/dist/execution/workItemExecutionProjection.js +99 -107
  98. package/dist/execution/workItemMainRun.js +141 -0
  99. package/dist/executor/agentAdapter.js +227 -20
  100. package/dist/executor/agentConfigurationCatalog.js +126 -4
  101. package/dist/executor/agentConfigurationProbe.js +162 -4
  102. package/dist/executor/agentExecutor.js +79 -78
  103. package/dist/executor/effectiveLaunch.js +105 -18
  104. package/dist/executor/executorRegistry.js +29 -44
  105. package/dist/executor/fileRoleLaunchPlanner.js +229 -154
  106. package/dist/executor/workspacePreflightClassification.js +16 -16
  107. package/dist/grant/capabilityGrant.js +6 -3
  108. package/dist/input/inputRequest.js +12 -10
  109. package/dist/integration/gitIntegrationService.js +4 -11
  110. package/dist/integration/integrationQueueService.js +4 -4
  111. package/dist/interaction/operatorPresentation.js +1 -1
  112. package/dist/kernel/builtinCapabilities.js +255 -12
  113. package/dist/kernel/capabilityRegistry.js +64 -18
  114. package/dist/kernel/instanceHost.js +12 -1
  115. package/dist/kernel/kernelPorts.js +2 -2
  116. package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
  117. package/dist/lifecycle/exactRunTerminalization.js +449 -0
  118. package/dist/message/message.js +118 -6
  119. package/dist/message/messageContinuation.js +204 -0
  120. package/dist/observability/executionAudit.js +70 -72
  121. package/dist/observability/faultClassification.js +2 -2
  122. package/dist/observability/orchestrationMetrics.js +8 -8
  123. package/dist/operator/operatorSessionHistory.js +1 -7
  124. package/dist/output/agentConfigurationPresentation.js +8 -3
  125. package/dist/output/agentRunConfigurationPresentation.js +128 -0
  126. package/dist/output/rolePresentation.js +54 -3
  127. package/dist/plugins/pluginChild.js +104 -0
  128. package/dist/plugins/pluginIntent.js +26 -0
  129. package/dist/plugins/pluginInterpreter.js +43 -0
  130. package/dist/plugins/pluginPackage.js +101 -0
  131. package/dist/plugins/pluginProcess.js +112 -0
  132. package/dist/plugins/pluginService.js +388 -0
  133. package/dist/profile/agentProfile.js +1 -1
  134. package/dist/repository/gitWorkspace.js +26 -4
  135. package/dist/repository/project.js +19 -4
  136. package/dist/repository/taskBaseFreshness.js +13 -13
  137. package/dist/repository/taskWorkspaceCoordinator.js +20 -27
  138. package/dist/repository/taskWorkspacePreparer.js +344 -83
  139. package/dist/resources/autoResourceGc.js +3 -3
  140. package/dist/resources/liveReferences.js +3 -3
  141. package/dist/resources/projectResource.js +75 -0
  142. package/dist/resources/projectResourceService.js +343 -0
  143. package/dist/resources/resourceDiscovery.js +6 -6
  144. package/dist/resources/resourceGc.js +1 -1
  145. package/dist/resources/resourceRegistrar.js +1 -1
  146. package/dist/resources/resourceTypes.js +1 -1
  147. package/dist/review/deltaRecheck.js +3 -3
  148. package/dist/review/reviewAcceptance.js +16 -16
  149. package/dist/review/reviewDecision.js +7 -7
  150. package/dist/review/reviewRound.js +21 -20
  151. package/dist/review/reviewerAvailability.js +2 -2
  152. package/dist/role/role.js +51 -7
  153. package/dist/role/taskRoleUpdate.js +30 -0
  154. package/dist/runtime/acpProtocol.js +425 -0
  155. package/dist/runtime/acpSession.js +731 -0
  156. package/dist/runtime/acpSessionConfiguration.js +260 -0
  157. package/dist/runtime/agentDriver.js +30 -11
  158. package/dist/runtime/agentEndpoint.js +278 -0
  159. package/dist/runtime/agentEndpointIdentity.js +86 -0
  160. package/dist/runtime/agentEndpointOwnership.js +239 -0
  161. package/dist/runtime/agentError.js +2 -10
  162. package/dist/runtime/agentHost.js +565 -314
  163. package/dist/runtime/agentRunConfiguration.js +258 -0
  164. package/dist/runtime/builtinAgentDrivers.js +134 -18
  165. package/dist/runtime/builtinAgentErrorMappers.js +55 -3
  166. package/dist/runtime/builtinTranscriptUsage.js +1 -1
  167. package/dist/runtime/claude-process-owner +0 -0
  168. package/dist/runtime/codexAppServerRuntime.js +38 -30
  169. package/dist/runtime/codexInteractiveHost.js +41 -6
  170. package/dist/runtime/continuationManager.js +2 -6
  171. package/dist/runtime/executionEnvironment.js +30 -0
  172. package/dist/runtime/firstProgressAdvisory.js +11 -11
  173. package/dist/runtime/index.js +4 -3
  174. package/dist/runtime/jsonLineChannel.js +109 -0
  175. package/dist/runtime/launchBroker.js +91 -16
  176. package/dist/runtime/launchDiagnostics.js +2 -2
  177. package/dist/runtime/lifecycleReservation.js +10 -18
  178. package/dist/runtime/managedCaller.js +61 -17
  179. package/dist/runtime/nativeSessionControl.js +102 -0
  180. package/dist/runtime/ports.js +6 -21
  181. package/dist/runtime/processExitObservation.js +8 -7
  182. package/dist/runtime/promptEnvelope.js +17 -6
  183. package/dist/runtime/providerContinuation.js +3 -9
  184. package/dist/runtime/providerContinuationReconciliationService.js +4 -13
  185. package/dist/runtime/providerControl.js +2 -7
  186. package/dist/runtime/providerRuntimeIdentity.js +110 -222
  187. package/dist/runtime/providerRuntimeReconciler.js +5 -9
  188. package/dist/runtime/runtimeBinding.js +0 -1
  189. package/dist/runtime/runtimeContinuationProjection.js +4 -7
  190. package/dist/runtime/runtimeDeadlines.js +9 -0
  191. package/dist/runtime/runtimeHealthPolicy.js +1 -1
  192. package/dist/runtime/runtimeObservation.js +29 -65
  193. package/dist/runtime/runtimeProjection.js +43 -51
  194. package/dist/runtime/runtimeSessionCandidate.js +1 -3
  195. package/dist/runtime/sessionLaunchRequest.js +3 -7
  196. package/dist/runtime/sessionOwnerIdentity.js +7 -54
  197. package/dist/runtime/sessionOwnerRegistry.js +22 -17
  198. package/dist/runtime/sessionReconciliation.js +4 -8
  199. package/dist/runtime/sessionTerminationGuard.js +70 -259
  200. package/dist/runtime/sessionTokenMetrics.js +5 -16
  201. package/dist/runtime/structuredProviderHost.js +237 -117
  202. package/dist/runtime/taskRuntimeIsolation.js +39 -122
  203. package/dist/runtime/tmuxAdapters.js +39 -86
  204. package/dist/scheduler/activeRoleRunDelivery.js +354 -0
  205. package/dist/scheduler/leaderWakeupProcessor.js +75 -266
  206. package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
  207. package/dist/scheduler/ports.js +80 -9
  208. package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
  209. package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
  210. package/dist/scheduler/taskExecutionProjection.js +120 -124
  211. package/dist/scheduler/taskObservabilityProjection.js +29 -29
  212. package/dist/scheduler/taskWake.js +11 -4
  213. package/dist/scheduler/wakeReason.js +9 -1
  214. package/dist/setup/setupCommand.js +3 -7
  215. package/dist/storage/migrations/agentRunContract.js +159 -0
  216. package/dist/storage/migrations/artifactsToGit.js +338 -0
  217. package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
  218. package/dist/storage/migrations/submitIntent.js +126 -0
  219. package/dist/storage/sqliteSchema.js +467 -7
  220. package/dist/storage/sqliteStore.js +355 -220
  221. package/dist/storage/storageVersions.js +1 -1
  222. package/dist/storage/storeRpc.js +10 -5
  223. package/dist/storage/taskStore.js +13 -11
  224. package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
  225. package/dist/surface/surfaceContributions.js +102 -0
  226. package/dist/task/completionReadiness.js +32 -6
  227. package/dist/task/deliveryGuard.js +16 -16
  228. package/dist/task/draftPlan.js +72 -12
  229. package/dist/task/nextAction.js +144 -128
  230. package/dist/task/remoteDelivery.js +6 -6
  231. package/dist/task/task.js +184 -18
  232. package/dist/task/taskActivation.js +327 -0
  233. package/dist/task/taskActivationService.js +408 -0
  234. package/dist/task/taskRecordReference.js +5 -4
  235. package/dist/task/taskRecordRetirement.js +1 -1
  236. package/dist/task/taskSubmission.js +236 -0
  237. package/dist/telemetry/sqliteTelemetryStore.js +55 -68
  238. package/dist/telemetry/telemetryConfig.js +14 -14
  239. package/dist/telemetry/telemetryWiring.js +2 -2
  240. package/dist/web/assets/assetManifest.js +2 -0
  241. package/dist/web/assets/client/app.js +121 -20
  242. package/dist/web/assets/client/components.js +87 -54
  243. package/dist/web/assets/client/i18n.js +83 -41
  244. package/dist/web/assets/client/markdown.js +1 -1
  245. package/dist/web/assets/client/taskSurface.js +442 -0
  246. package/dist/web/assets/client/view.js +49 -44
  247. package/dist/web/assets/shell.js +1 -1
  248. package/dist/web/assets/styles/cards.js +22 -4
  249. package/dist/web/controllerWeb.js +60 -0
  250. package/dist/web/webMutation.js +28 -0
  251. package/dist/web/webServer.js +133 -8
  252. package/dist/web/webSnapshot.js +81 -74
  253. package/dist/web/webTaskSurface.js +64 -0
  254. package/dist/workItem/dependencyGate.js +1 -1
  255. package/dist/workItem/workItem.js +84 -48
  256. package/dist/workspace/workItemChangeSetManager.js +16 -9
  257. package/docs/agent-result-consumption.md +96 -0
  258. package/docs/agent-result-consumption.zh-CN.md +81 -0
  259. package/docs/agent-runtime-drivers.md +93 -0
  260. package/docs/agent-runtime-drivers.zh-CN.md +77 -0
  261. package/docs/architecture/README.md +50 -0
  262. package/docs/architecture/README.zh-CN.md +43 -0
  263. package/docs/architecture/capabilities-and-resources.md +118 -0
  264. package/docs/architecture/capabilities-and-resources.zh-CN.md +83 -0
  265. package/docs/managed-turn-and-session-runtime.md +224 -0
  266. package/docs/managed-turn-and-session-runtime.zh-CN.md +180 -0
  267. package/docs/observability/README.md +83 -0
  268. package/docs/observability/README.zh-CN.md +71 -0
  269. package/docs/plugin-sdk.md +393 -0
  270. package/docs/plugin-sdk.zh-CN.md +293 -0
  271. package/docs/provider-runtime.md +165 -0
  272. package/docs/provider-runtime.zh-CN.md +132 -0
  273. package/docs/release-workflow.md +305 -0
  274. package/docs/release-workflow.zh-CN.md +237 -0
  275. package/docs/roles-and-configuration.md +115 -0
  276. package/docs/roles-and-configuration.zh-CN.md +96 -0
  277. package/docs/sqlite-control-plane-design.md +78 -0
  278. package/docs/sqlite-control-plane-design.zh-CN.md +62 -0
  279. package/docs/task-dag-semantics.md +80 -0
  280. package/docs/task-dag-semantics.zh-CN.md +59 -0
  281. package/docs/task-delivery.md +105 -0
  282. package/docs/task-delivery.zh-CN.md +82 -0
  283. package/docs/task-local-identity.md +8 -6
  284. package/docs/task-local-identity.zh-CN.md +58 -0
  285. package/docs/testing/verification-levels.md +88 -0
  286. package/docs/testing/verification-levels.zh-CN.md +69 -0
  287. package/i18n/README.zh-CN.md +270 -722
  288. package/package.json +3 -2
  289. package/skills/yui-leader/SKILL.md +88 -304
  290. package/skills/yui-leader/references/execution.md +303 -0
  291. package/skills/yui-leader/references/integration.md +39 -0
  292. package/skills/yui-leader/references/planning.md +109 -0
  293. package/skills/yui-leader/references/replicated-execution.md +42 -0
  294. package/skills/yui-leader/references/task-plugins.md +37 -0
  295. package/skills/yui-operator/SKILL.md +46 -62
  296. package/skills/yui-reviewer/SKILL.md +35 -36
  297. package/skills/yui-runtime/SKILL.md +88 -24
  298. package/skills/yui-runtime/references/publication.md +22 -0
  299. package/skills/yui-runtime/references/recovery.md +64 -0
  300. package/skills/yui-worker/SKILL.md +37 -39
  301. package/dist/cli/roleOptionCatalog.js +0 -68
  302. package/dist/context/sourceTurnContext.js +0 -30
  303. package/dist/execution/reviewMainTurn.js +0 -161
  304. package/dist/execution/workItemMainTurn.js +0 -164
  305. package/dist/lifecycle/exactTurnTerminalization.js +0 -407
  306. package/dist/runtime/preallocatedNativeSession.js +0 -13
  307. package/dist/runtime/runtimeStopReceipt.js +0 -42
  308. package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
@@ -0,0 +1,96 @@
1
+ <p align="right"><a href="./roles-and-configuration.md">English</a> | <strong>简体中文</strong></p>
2
+
3
+ # Role、Profile 与执行配置
4
+
5
+ ## 职责
6
+
7
+ Agent 选择一个执行组件、连接方案和启动环境。Role 选择一个活动的 Agent 绑定和
8
+ 可移植行为。每个绑定保留独立的运行时选项。一个 Role 可以持有多个绑定,而不产生
9
+ 并行写者,也不把一个绑定的凭据/配置共享给另一个。
10
+
11
+ Task Role 是 Task 局部的;global Role 提供已配置的默认值和全局对话。Role
12
+ 身份/配置不是可写的运行时状态。Session 与 Provider 观察描述实际活动。
13
+
14
+ 一次显式的 Task-final Review 使用既有的 Task 局部 Reviewer Role,不要求存在同名
15
+ 的 global Role。只有当请求的 Task Role 不存在时,global Role 才作为创建模板。
16
+ 可用性、producer 分离和冻结的审查候选仍然适用。
17
+
18
+ ## Profile
19
+
20
+ Agent Profile 把可移植行为(指令、Skill 和访问意图)与运行时意图组合在一起。
21
+ 运行时要么沿用当前 Global Worker 绑定,要么显式选择一个 Agent 并可选 model 和
22
+ effort。`config profile reset` 提供 `worker`、`explorer`、`implementer` 和
23
+ `reviewer`。
24
+
25
+ 从 Profile 创建 Task Role 会冻结其解析后的行为和绑定。之后对 Profile 或 Global
26
+ Worker 的编辑不会改写既有的 Task Role。重新套用一个 Profile 是一次显式配置变更。
27
+ 所选 Agent 必须与目标绑定匹配;显式的 Role 选项覆盖对应的模板字段。Profile
28
+ 不是 Session、工作区 owner 或资源 grant。
29
+
30
+ 原生子代继承其父 Agent 和权限。Profile 可以引导它们的行为;model/effort 覆盖
31
+ 需要真实的原生工具支持。它们不获得 Yui Role、独立 Assignment 或更大范围。
32
+
33
+ ## 期望、生效与观察
34
+
35
+ 期望设置是下一次启动的意图。AgentRun 和 Session 捕获生效启动:Agent/组件、
36
+ 协议、model、effort、权限策略、工作区/环境、Role 上下文以及 planning/delivery
37
+ 权限。
38
+
39
+ 对运行中配置的检查单独报告 Agent 实际声明的内容。unsupported 和 unknown 都是
40
+ 显式的;一个被接受的 setter 若没有回报当前值,并不算已观察到的匹配。读取配置
41
+ 不会修改 Agent 以让观察与期望一致。
42
+
43
+ Worker 绑定变更保留活动 Assignment 的 Agent 和生效快照;之后的显式派发使用当前
44
+ 选择。Leader 替换撤销上一条管理入口,但不改写 Worker Assignment。更改期望配置
45
+ 不会热改原生 Session。一次显式的 `task role session new` 请求会在选择新 Session
46
+ 之前处理旧运行时清理;它不要求先手动结算 Run 状态。一个有用的 Session 可以复用,
47
+ 但它绝不是 Task 上下文的唯一持有者。
48
+
49
+ ## 权限与 Project 上下文
50
+
51
+ Provider 权限策略、Profile 访问意图和 Project 写范围是不同的合同。Provider 旁路
52
+ 不授予对另一个 Project 的写入。受管工作区 owner、精确 Assignment 和资源 grant
53
+ 落实 Yui 操作;宽泛的原生权限不是 OS 沙箱。
54
+
55
+ Yui 提供其通用 Role Skill 和 Context 指针。Project Skill 仍是由 Agent 原生发现的
56
+ 普通 Project 文件。Project Knowledge 维护在 `YUI_HOME` 下;把仓库材料复制进 prompt
57
+ 并不使其成为权威 Knowledge。
58
+
59
+ ## 原生认证
60
+
61
+ 账号配置比 Session 活得更久。Yui 保留 `HOME` 和所选的 `CLAUDE_CONFIG_DIR`;
62
+ 新建/恢复的 Session 不会复制、清除或伪造原生登录、key 批准或 onboarding 记录。
63
+
64
+ 对 Claude Code,标准的 API-key、base-URL、bearer/OAuth、model-alias 以及原生
65
+ provider 选择相关环境变量只转发给 Claude。这些值留在 Controller 可替换的运行时
66
+ 环境和子进程中,不进入 Task/Role 记录。取消某个来源并刷新 Controller 环境,即可
67
+ 在后续启动中移除它。其他自定义凭据变量仍使用显式的 Agent 环境绑定或原生用户设置;
68
+ Yui 不继承整个 shell 环境,也不推断云凭据。
69
+
70
+ Claude 自身加载原生设置,并按其生效配置在 API key、既有 helper、登录凭据、profile
71
+ 和云认证之间做选择。Yui 不注入 `apiKeyHelper`、不复制凭据文件,也不覆盖原生认证
72
+ 优先级。显式的 `--settings` 路径和 settings 来源选择被原样透传。
73
+
74
+ 全新的原生配置仍可能需要 Claude 的初始化、key、工作区和安全确认,包括访问初始化
75
+ 服务。隔离 `YUI_HOME` 或替换 Session 都不要求一个全新的原生账号目录。受管的 Task
76
+ 执行使用 Claude 的非交互 stream-json 路径,并沿用同样的原生配置归属。
77
+
78
+ ## 命令
79
+
80
+ ```sh
81
+ yui config agent capabilities <agent-id>
82
+ yui config role show <global-role>
83
+ yui config profile show <profile>
84
+ yui task role add <task> <role> --profile <profile>
85
+ yui task role show <task> <role>
86
+ yui task role update <task> <role> --environment <preparation-id>
87
+ yui task role update <task> <role> --managed-environment
88
+ yui task role session inspect <task> <role>
89
+ yui task role session new <task> <role> --reason "<why a fresh Session is useful>"
90
+ ```
91
+
92
+ 创建 Role 时,显式的 Agent 设置需要 `--agent`。更新时,省略 `--agent` 针对活动
93
+ 绑定;一个具名绑定会被更新但不被激活。`task role bind` 更改选择。在更改期望设置
94
+ 之前,活动 Session 需要该命令的显式确认。
95
+
96
+ 关于原生配置和实现限制,参见 [Provider Runtime](provider-runtime.zh-CN.md)。
@@ -0,0 +1,78 @@
1
+ <p align="right"><strong>English</strong> | <a href="./sqlite-control-plane-design.zh-CN.md">简体中文</a></p>
2
+
3
+ # SQLite control-plane storage
4
+
5
+ Yui has one authoritative product Store: `YUI_HOME/yui.db` in WAL mode. The
6
+ highest contiguous, checksummed row in `schema_migrations` is the one Home
7
+ storage version accepted by the running release.
8
+
9
+ ## Authority
10
+
11
+ - `yui.db` owns Tasks, WorkItems, AgentRuns, Messages, Decisions, results, Project
12
+ Knowledge references, managed workspace records, runtime bindings, mailboxes,
13
+ durable events, and configuration.
14
+ - Provider Sessions, transcripts, processes, caches, telemetry, and runtime
15
+ observations support execution and diagnosis; they do not replace durable
16
+ Task facts.
17
+ - Configuration and diagnostics outside the database do not define another
18
+ storage version or permit rebuilding Task truth heuristically.
19
+
20
+ ## Admission
21
+
22
+ Ordinary commands open a Home only when all of these are true:
23
+
24
+ 1. `yui.db` exists and its migration ledger is a valid immutable prefix.
25
+ 2. The ledger head exactly matches the running CLI's current storage version.
26
+ 3. Current record validation and reference integrity succeed.
27
+
28
+ An older Home inside the CLI's supported range fails ordinary admission but is
29
+ classified as upgradeable. `yui doctor` and `yui upgrade --dry-run` report the
30
+ ordered path without changing the Home. Explicit `yui upgrade` is the only
31
+ standalone mutation boundary: it quiesces the Controller, backs up `yui.db`,
32
+ applies all missing migrations transactionally, and validates the current
33
+ model. A newer, below-minimum, incomplete, or malformed Home fails closed.
34
+ There is no runtime normalization, repair worker, file-Store fallback, dual
35
+ read/write path, or second migration authority.
36
+
37
+ ## Write and concurrency contract
38
+
39
+ - Each mutation is one SQLite transaction.
40
+ - WAL plus `synchronous=FULL` provides the durable commit boundary.
41
+ - `home_meta.revision` is the Home-wide CAS/revision used by callers that need
42
+ a frozen read/modify/write boundary.
43
+ - Typed columns support indexed identity and status queries; the full validated
44
+ record payload remains the durable domain representation.
45
+ - Mailbox claim, exact AgentRun terminalization, active-pointer removal, result
46
+ persistence, and downstream wake creation are transactionally coupled where
47
+ they form one product fact.
48
+ - Idempotency keys and unique constraints protect repeatable external-effect
49
+ acknowledgements; they do not form a second workflow state machine.
50
+
51
+ ## AgentRun and Session boundary
52
+
53
+ An AgentRun is an explicitly requested execution. It records associated visible
54
+ inputs and the original result, not hidden reasoning or the full tool trace.
55
+ A Provider Session can contain multiple Runs, ordinary native chat and
56
+ notifications. Native chat and notifications do not automatically create Runs.
57
+ Only an exactly correlated native terminal settles the Run; the Leader remains
58
+ the authority for WorkItem and Task acceptance.
59
+
60
+ ## Update behavior
61
+
62
+ `yui update` stages an exact package and asks that staged binary to classify the
63
+ Home as current, migration-ready, or blocked. It then stops the exact
64
+ Controller, activates the same package, runs the staged release's complete
65
+ migration chain when required, verifies the installed binary and current Home,
66
+ and starts the replacement Controller.
67
+
68
+ Every persistent schema or payload change appends one immutable, contiguous
69
+ storage migration. The CLI publishes both `storageVersion` and
70
+ `minimumStorageVersion`; every valid Home in that inclusive range can upgrade
71
+ directly to the current version without installing intermediate releases.
72
+ The current source declares storage version **18**, with minimum supported
73
+ migration version **1**, in `src/storage/storageVersions.ts`. Homes below that
74
+ floor are not migration inputs and remain untouched.
75
+ The target binary's `upgrade --update-preflight` and `--update-apply` result
76
+ shapes and parent-owned handover-lock proof remain backward compatible with
77
+ every updater released from storage version 1 onward, so an old source CLI can
78
+ still drive a much newer target's complete migration chain.
@@ -0,0 +1,62 @@
1
+ <p align="right"><a href="./sqlite-control-plane-design.md">English</a> | <strong>简体中文</strong></p>
2
+
3
+ # SQLite 控制面存储
4
+
5
+ Yui 只有一个权威产品 Store:WAL 模式下的 `YUI_HOME/yui.db`。`schema_migrations`
6
+ 中连续且带校验和的最高一行,就是当前发行版接受的那一个 Home 存储版本。
7
+
8
+ ## 权威
9
+
10
+ - `yui.db` 拥有 Task、WorkItem、AgentRun、Message、Decision、结果、Project
11
+ Knowledge 引用、受管工作区记录、运行时绑定、mailbox、持久事件和配置。
12
+ - Provider Session、transcript、进程、缓存、telemetry 和运行时观察服务于执行
13
+ 与诊断,不替代持久的 Task 事实。
14
+ - 数据库之外的配置和诊断不定义另一个存储版本,也不允许启发式地重建 Task 真相。
15
+
16
+ ## 准入
17
+
18
+ 普通命令只有在同时满足以下条件时才打开 Home:
19
+
20
+ 1. `yui.db` 存在,且其迁移账本是一个有效的不可变前缀。
21
+ 2. 账本头恰好等于运行中 CLI 的当前存储版本。
22
+ 3. 当前记录校验与引用完整性均通过。
23
+
24
+ 落在 CLI 支持区间内的更旧 Home 无法通过普通准入,但被归类为可升级。
25
+ `yui doctor` 和 `yui upgrade --dry-run` 会报告有序的升级路径而不改动 Home。
26
+ 显式的 `yui upgrade` 是唯一的独立变更边界:它让 Controller 静止、备份
27
+ `yui.db`、以事务方式套用所有缺失迁移,并校验当前模型。更新的、低于最低版本的、
28
+ 不完整的或损坏的 Home 一律 fail closed。不存在运行时归一化、修复 worker、
29
+ 文件 Store 回退、双读写路径或第二套迁移权威。
30
+
31
+ ## 写入与并发合同
32
+
33
+ - 每次修改是一个 SQLite 事务。
34
+ - WAL 加 `synchronous=FULL` 提供持久提交边界。
35
+ - `home_meta.revision` 是全 Home 范围的 CAS/revision,供需要冻结
36
+ read/modify/write 边界的调用者使用。
37
+ - 类型化列支持按身份和状态建索引查询;完整且经校验的记录负载仍是持久的领域表示。
38
+ - mailbox 认领、精确的 AgentRun 终结、活动指针移除、结果持久化以及下游唤醒创建,
39
+ 在它们构成同一条产品事实时以事务方式耦合。
40
+ - 幂等键与唯一约束保护可重复的外部效果确认,不构成第二套工作流状态机。
41
+
42
+ ## AgentRun 与 Session 边界
43
+
44
+ AgentRun 是一次明确请求的执行。它记录相关的可见输入和原始结果,而不是隐藏的
45
+ 推理过程或完整工具轨迹。一个 Provider Session 可以包含多个 Run、普通原生对话
46
+ 和通知。原生对话和通知不会自动创建 Run。只有精确关联的原生终态才结算该 Run;
47
+ WorkItem 与 Task 的验收权威仍归 Leader。
48
+
49
+ ## 更新行为
50
+
51
+ `yui update` 暂存一个确切的包,并要求那个暂存二进制把 Home 判定为当前、可迁移
52
+ 或受阻。随后它停止那个确切的 Controller、激活同一个包、在需要时运行暂存发行版
53
+ 的完整迁移链、校验已安装二进制与当前 Home,再启动替换后的 Controller。
54
+
55
+ 每次持久 schema 或负载变更都追加一条不可变、连续的存储迁移。CLI 同时发布
56
+ `storageVersion` 与 `minimumStorageVersion`;处在该闭区间内的每个有效 Home 都能
57
+ 直接升级到当前版本,无需安装中间发行版。当前源码在
58
+ `src/storage/storageVersions.ts` 中声明存储版本 **18**、最低支持迁移版本 **1**。
59
+ 低于该下限的 Home 不是迁移输入,保持原样不动。目标二进制的
60
+ `upgrade --update-preflight` 与 `--update-apply` 结果形态,以及由父进程持有的
61
+ 交接锁证明,对从存储版本 1 起发布的每个 updater 都保持向后兼容,因此一个旧的
62
+ 源码 CLI 仍能驱动一个新得多的目标的完整迁移链。
@@ -0,0 +1,80 @@
1
+ <p align="right"><strong>English</strong> | <a href="./task-dag-semantics.zh-CN.md">简体中文</a></p>
2
+
3
+ # Task dependencies and WorkItem semantics
4
+
5
+ ## Requirement and execution are separate
6
+
7
+ A Task is one bounded outcome; a WorkItem is an independently acceptable
8
+ requirement within it. Task type does not dictate execution topology: the Leader
9
+ can work directly or create WorkItems delivered by separate owners. An
10
+ implementation step, a single test, a review finding or a small fix does not
11
+ become a new WorkItem on its own.
12
+
13
+ The persistent WorkItem status is only `open / accepted / retired`:
14
+
15
+ - `open`: the requirement is still in progress — not yet executed, executing,
16
+ awaiting acceptance or needing another attempt.
17
+ - `accepted`: the Leader has explicitly accepted the current delivery.
18
+ - `retired`: the requirement is explicitly retired, with its record and reason
19
+ preserved.
20
+
21
+ Execution status belongs to AgentRun, and a Candidate records the result
22
+ currently awaiting acceptance. Submission, rejection or execution failure does
23
+ not turn a WorkItem into a second runtime state machine. Withdrawing acceptance
24
+ is an explicit action.
25
+
26
+ ## One dependency authority
27
+
28
+ `WorkItem.dependsOn` is the list of direct dependencies within the same Task. A
29
+ prerequisite A → downstream B means B's `dependsOn` contains A. Saving checks
30
+ same-Task references, existence and the acyclic constraint. It does not express
31
+ Provider concurrency, Session occupancy or file locks.
32
+
33
+ At dispatch, every direct dependency must exist and be `accepted`. An open,
34
+ retired or missing dependency cannot satisfy it, and the error returns the exact
35
+ ID and current status. A successful Run, an existing Candidate, a completed
36
+ Review or an integrated Git change does not substitute for WorkItem acceptance.
37
+
38
+ A retired WorkItem's replacement field only explains the substitution; it does
39
+ not redirect or rewrite dependencies. The Leader must explicitly revise the
40
+ requirement or its dependencies. The Controller does not release downstream work
41
+ along a replacement chain, cascade cancellation, auto-skip, or turn the
42
+ dependency list into a scheduling plan.
43
+
44
+ ## Editing and recovery
45
+
46
+ A legal edit to an open WorkItem definition preserves the before/after values and
47
+ keeps its identity and execution evidence. An already-started Run keeps its
48
+ frozen Assignment; editing the current requirement does not retroactively rewrite
49
+ that Run's Context or permissions. Accepted and retired definitions cannot be
50
+ overwritten by an ordinary edit. Owner and resource-scope changes are checked at
51
+ their own boundaries.
52
+
53
+ On execution failure, the Leader inspects the original result, Session,
54
+ dependencies and workspace, then decides to continue, retry, retire or revise the
55
+ plan. After retirement, a late message keeps its source and non-delivery reason
56
+ and does not auto-reopen. An InputRequest represents an open question; answering
57
+ it does not accept a WorkItem or rewrite dependencies.
58
+
59
+ ## Acceptance, integration and Task completion
60
+
61
+ Direct and replicated execution share one Leader acceptance boundary. A
62
+ replicated Producer does not form a Candidate; only the explicitly synthesized
63
+ main Run result enters the candidate path. Delivery the Leader manages directly
64
+ must also satisfy the applicable Candidate, ChangeSet and Integration boundaries.
65
+
66
+ An isolated code result captures a fixed per-Project ChangeSet and integrates via
67
+ compare-and-swap after its checks; an uncaptured, unintegrated or stale latest
68
+ result cannot satisfy delivery. Review is checked against the applicable rule and
69
+ the Task contract. A Task main the Leader delivers itself needs a clean,
70
+ committed, exact snapshot.
71
+
72
+ The Task lifecycle is `draft / active / completed / cancelled / archived`. A
73
+ Draft plans first and then explicitly adopts a workspace; completed and cancelled
74
+ Tasks do not accept implicit new execution, and a reopen never replays old
75
+ requests; an archived Task cannot reopen. Archive also requires resources to be
76
+ quiescent, clean and removable, and never deletes a workspace merely because of
77
+ the dependency graph or a completion status.
78
+
79
+ CLI and Web derive their views and suggestions from these facts; they do not
80
+ maintain a second writable DAG, acceptance state or plan.
@@ -0,0 +1,59 @@
1
+ <p align="right"><a href="./task-dag-semantics.md">English</a> | <strong>简体中文</strong></p>
2
+
3
+ # Task 依赖与 WorkItem 语义
4
+
5
+ ## 需求与执行分离
6
+
7
+ Task 是一个有界结果,WorkItem 是其中可独立验收的需求。Task type 不决定
8
+ 执行拓扑;Leader 可以直接工作,也可以创建独立负责人交付的 WorkItem。
9
+ 实现步骤、一次测试、审查发现或小修补不因此成为新 WorkItem。
10
+
11
+ WorkItem 持久状态仅为 `open / accepted / retired`:
12
+
13
+ - `open`:需求仍在处理;可能尚未执行、正在执行、等待验收或需要重试。
14
+ - `accepted`:Leader 已显式接受当前交付。
15
+ - `retired`:需求已显式退役,保留记录和原因。
16
+
17
+ 执行状态归 AgentRun,Candidate 记录当前待接受的结果。提交、拒绝或执行失败
18
+ 不把 WorkItem 变成另一套运行状态。接受撤回是显式动作。
19
+
20
+ ## 唯一依赖权威
21
+
22
+ `WorkItem.dependsOn` 是同一 Task 内的直接依赖列表。前置项 A → 下游 B
23
+ 表示 B 的 `dependsOn` 包含 A。保存时检查同 Task 引用、存在性和无环约束。
24
+ 它不表达 Provider 并发、Session 占用或文件锁。
25
+
26
+ 派发时,每个直接依赖必须存在且为 `accepted`。Open、retired 或 missing
27
+ 均不能满足依赖,错误返回具体 ID 和当前状态。Run 成功、Candidate 存在、
28
+ Review 完成或 Git 已集成都不能代替 WorkItem 接受。
29
+
30
+ 退役的 replacement 字段只解释替代关系,不重定向或重写依赖。
31
+ Leader 必须显式修订需求或依赖;Controller 不沿替换链自动释放下游,
32
+ 不级联取消、不自动跳过,也不把依赖列表变成调度计划。
33
+
34
+ ## 修改与恢复
35
+
36
+ Open WorkItem 的合法定义编辑保存前后值,保留身份和执行证据。已经启动的
37
+ Run 仍使用冻结 Assignment;修改当前需求不追溯改写其 Context 或权限。
38
+ 已接受和退役的定义不能借普通编辑覆盖。负责人与资源范围变更受各自边界检查。
39
+
40
+ 执行失败时,Leader 检查原始结果、Session、依赖与工作区,决定续作、重试、
41
+ 退役或修改计划。退役后迟到消息保留来源和未投递原因,不自动重开。
42
+ InputRequest 表示待决问题;回答不自动接受 WorkItem 或改写依赖。
43
+
44
+ ## 接受、集成与 Task 完成
45
+
46
+ Direct 和 replicated 共享一个 Leader 接受边界。Replicated Producer 不形成
47
+ Candidate;只有显式综合的 main Run 结果进入候选路径。Leader 直接管理的
48
+ 交付也必须满足适用的 Candidate、ChangeSet 和 Integration 边界。
49
+
50
+ 隔离代码结果按 Project 捕获固定 ChangeSet,检查后 CAS 集成;未捕获、未集成
51
+ 或失效的最新结果不能满足交付。Review 依适用规则和 Task 合同检查。
52
+ Leader 自己交付的 Task main 需要干净、已提交的精确快照。
53
+
54
+ Task lifecycle 是 `draft / active / completed / cancelled / archived`。
55
+ Draft 先规划再显式采用工作区;completed/cancelled 不接收隐式新执行,
56
+ reopen 不重放旧请求;archived 不可重开。Archive 还要求资源静止、干净可移除,
57
+ 不因依赖图或完成状态自动删除工作区。
58
+
59
+ CLI/Web 从这些事实派生展示和建议,不维护第二套可写 DAG、验收状态或计划。
@@ -0,0 +1,105 @@
1
+ <p align="right"><strong>English</strong> | <a href="./task-delivery.zh-CN.md">简体中文</a></p>
2
+
3
+ # Task delivery and resource lifecycle
4
+
5
+ ## Lifecycle and planning
6
+
7
+ Task lifecycle is `draft / active / completed / cancelled / archived`. A Draft
8
+ stores intent, Project bindings, planning discussion and mutable requirements.
9
+ It does not adopt a writable delivery workspace at creation.
10
+
11
+ Activation validates current Roles, dependencies, Project scope and resources,
12
+ prepares physical workspaces, and adopts status/ownership atomically. Failed
13
+ preparation leaves the Task Draft with a failed request and a diagnosis delivered
14
+ to the Leader. Deferred activation retains the exact intent and waits for native
15
+ quiescence, whether requested in a planning Run or subsequent discussion.
16
+
17
+ Task type describes the requested outcome, not the mandatory executor.
18
+ Leader owns bounded work directly or assigns substantial independent WorkItems.
19
+ Direct execution has no Group. Replication is explicitly requested for independent
20
+ attempts at the same frozen Assignment, followed by Leader-selected synthesis.
21
+
22
+ ## Managed workspaces
23
+
24
+ Stable Project checkouts are read-only references. Task main is a logical
25
+ multi-Project root with per-Project Git worktrees. For one Project, the Agent's
26
+ normal cwd is its managed Git root; for multiple Projects, the root and native
27
+ additional-directory mechanism expose the explicit Project set.
28
+
29
+ An isolated WorkItem has independent worktrees for writable Projects and
30
+ Task-main context for the others. Write scope is explicit and can only be
31
+ expanded by the authorized owner. Review owns a separate frozen workspace and
32
+ cannot become a Develop or Integration source.
33
+ Acceptance or retirement does not release a WorkItem's durable workspace.
34
+ Task-main preparation preserves a Role's retained WorkItem/Review cwd until
35
+ explicit cleanup or reassignment. Decision-support reads observe current Git
36
+ heads without preparing workspaces or migrating Sessions.
37
+
38
+ Before launch, actual Git lineage must descend from the recorded base. A reset
39
+ outside that lineage is physical drift, not a reason to guess or repair ownership.
40
+ An explicitly adopted environment can select a different native cwd while the
41
+ managed workspace remains the Git/control ownership record.
42
+
43
+ ## Candidate, Review and Integration
44
+
45
+ Provider terminal saves the exact original Run result. It does not accept the
46
+ WorkItem. The Leader evaluates the result and captures immutable per-Project
47
+ ChangeSets for isolated code. The governing Candidate supplies provenance for
48
+ Review and Integration; Producers do not independently enter either path.
49
+
50
+ Integration applies the fixed ChangeSet in a candidate worktree, runs configured
51
+ checks, then advances the target only if its head still matches. Conflict,
52
+ failed checks, target movement or rejection retain evidence and never advance
53
+ the target. The Agent chooses retry or manual resolution within the retained
54
+ workspace.
55
+
56
+ When checks are a DurableJob, the Integration retains that exact jobId while
57
+ running. Once the Job settles, `task integration continue <task>/<integration>`
58
+ consumes its result and performs the guarded finalization. The direct operation
59
+ does not depend on entries in the separate integration queue.
60
+
61
+ Review follows the applicable Candidate rule or Task-final contract and frozen
62
+ heads. The exact main Reviewer Run holds the report; successful execution is
63
+ not a semantic pass. Acceptance belongs to the Leader.
64
+ An explicit user requirement to delegate or obtain independent Review remains
65
+ part of acceptance even if the default review policy is disabled. `next-action`
66
+ reports stored facts and alternatives; it cannot weaken the Task Contract or
67
+ infer that unrecorded WorkItems mean direct execution was requested.
68
+
69
+ ## Completion and remote delivery
70
+
71
+ Completion checks the current WorkItems, latest captured/integrated results,
72
+ applicable Review contract and exact clean committed Task-main snapshot.
73
+ It also refuses completion while a new user/Operator message is still awaiting
74
+ Leader delivery. The current native turn must end so the pending notification
75
+ can arrive; the Leader then reads the original message and reassesses completion.
76
+ This derives from existing Messages and mailbox delivery, not a second
77
+ acknowledgement or workflow state.
78
+ Terminal workspace cleanup can remain an advisory at completion, but not at
79
+ archive. Artifacts selected as results must be fixed, present and Task-local.
80
+
81
+ Publication records a remote PR/MR reference. Reported merge, independently
82
+ verified merge and exact Task-head coverage are separate facts. Task completion
83
+ does not prove any of them. Remote delivery is read from exact publication/head
84
+ evidence, not inferred from a title or branch name.
85
+
86
+ Cancelled intent does not prove the runtime stopped. User/Operator may reopen
87
+ cancelled Tasks; Leader may reopen completed Tasks. Reopening requires fresh
88
+ explicit input/work selection and never replays previous delivery requests.
89
+
90
+ ## Archive
91
+
92
+ Archive is a separate authorized action after active work is settled and
93
+ resources are clean and removable. Choose integrated delivery or deliberate
94
+ abandonment explicitly. Integrated archive requires exact merged heads and
95
+ verified publication evidence. An explicitly authorized verification override
96
+ cannot bypass missing or stale heads or an unmerged result.
97
+
98
+ Managed WorkItem resources must be integrated or deliberately abandoned before
99
+ cleanup. Review, Lane and Integration resources must be settled. Dirty worktrees
100
+ remain for the Agent to resolve; no implicit reset or force deletion occurs.
101
+ Task main branches and durable Task records retain recovery information.
102
+ Archived Tasks cannot reopen.
103
+
104
+ Use each command's `--help` to inspect its exact authority and options before
105
+ cleanup; reading a lifecycle document does not authorize an external write.
@@ -0,0 +1,82 @@
1
+ <p align="right"><a href="./task-delivery.md">English</a> | <strong>简体中文</strong></p>
2
+
3
+ # Task 交付与资源生命周期
4
+
5
+ ## 生命周期与规划
6
+
7
+ Task 生命周期是 `draft / active / completed / cancelled / archived`。Draft 保存
8
+ 意图、Project 绑定、规划讨论和可变需求。它在创建时不采用可写的交付工作区。
9
+
10
+ 激活会校验当前 Role、依赖、Project 范围和资源,准备物理工作区,并原子地采用
11
+ 状态/所有权。准备失败会让 Task 停在 Draft,附带一个失败请求和投递给 Leader 的
12
+ 诊断。延迟激活保留确切意图并等待原生静止,无论它是在规划 Run 中还是在后续讨论中
13
+ 被请求的。
14
+
15
+ Task type 描述被请求的结果,而不是强制的执行者。Leader 直接负责有界工作,或分派
16
+ 有独立价值的 WorkItem。直接执行没有 Group。复制是为了在同一个冻结 Assignment 上
17
+ 进行独立尝试而被显式请求的,随后由 Leader 选择综合。
18
+
19
+ ## 受管工作区
20
+
21
+ 稳定的 Project checkout 是只读参考。Task main 是一个逻辑上的多 Project 根,带有
22
+ 按 Project 划分的 Git worktree。对单个 Project,Agent 的正常 cwd 是其受管 Git 根;
23
+ 对多个 Project,根加上原生的附加目录机制暴露明确的 Project 集合。
24
+
25
+ 一个隔离的 WorkItem 为可写 Project 拥有独立 worktree,为其余 Project 提供 Task-main
26
+ 上下文。写范围是显式的,且只能由获授权的 owner 扩大。Review 拥有一个单独的冻结
27
+ 工作区,不能变成 Develop 或 Integration 来源。验收或退役不释放 WorkItem 的持久
28
+ 工作区。Task-main 准备会保留一个 Role 保留的 WorkItem/Review cwd,直到显式清理或
29
+ 重新分派。决策支持类读取观察当前 Git head,而不准备工作区或迁移 Session。
30
+
31
+ 启动前,实际 Git 血缘必须由已记录的基线派生而来。落在该血缘之外的 reset 是物理
32
+ 漂移,而不是猜测或修复所有权的理由。一个显式采用的环境可以选择不同的原生 cwd,
33
+ 而受管工作区仍是 Git/控制所有权记录。
34
+
35
+ ## Candidate、Review 与 Integration
36
+
37
+ Provider 终态保存确切的原始 Run 结果。它不验收 WorkItem。Leader 评估结果,并为
38
+ 隔离代码捕获不可变的、按 Project 划分的 ChangeSet。治理 Candidate 为 Review 和
39
+ Integration 提供来源;Producer 不独立进入这两条路径中的任何一条。
40
+
41
+ Integration 在候选 worktree 中套用固定 ChangeSet,运行已配置的检查,然后只有在
42
+ 目标 head 仍匹配时才推进目标。冲突、检查失败、目标移动或拒绝都保留证据,绝不推进
43
+ 目标。Agent 在保留的工作区内选择重试或手动解决。
44
+
45
+ 当检查是一个 DurableJob 时,Integration 在运行期间保留那个确切的 jobId。Job 结算
46
+ 后,`task integration continue <task>/<integration>` 消费其结果并执行带守卫的收尾。
47
+ 这个直接操作不依赖单独 integration 队列中的条目。
48
+
49
+ Review 遵循适用的 Candidate 规则或 Task-final 合同以及冻结的 head。确切的 main
50
+ Reviewer Run 持有报告;执行成功不等于语义通过。验收归 Leader。即使默认审查策略
51
+ 被关闭,用户明确要求委派或获取独立 Review 仍是验收的一部分。`next-action` 报告已
52
+ 存储的事实和备选项;它不能削弱 Task Contract,也不能推断“没有记录 WorkItem”就
53
+ 意味着请求了直接执行。
54
+
55
+ ## 完成与远程交付
56
+
57
+ 完成会检查当前的 WorkItem、最新捕获/集成的结果、适用的 Review 合同以及确切的、
58
+ 干净且已提交的 Task-main 快照。当有一条新的 user/Operator 消息仍在等待 Leader
59
+ 投递时,它也会拒绝完成。当前原生轮次必须结束,待处理的通知才能到达;随后 Leader
60
+ 读取原始消息并重新评估完成。这派生自既有的 Message 和 mailbox 投递,而不是第二套
61
+ 确认或工作流状态。终态工作区清理在完成时可以只是建议,但在归档时不行。被选作
62
+ 结果的 Artifact 必须是固定的、存在的且 Task 局部的。
63
+
64
+ 发布记录一个远程 PR/MR 引用。被报告的合并、独立验证的合并以及确切的 Task-head
65
+ 覆盖是彼此独立的事实。Task 完成不证明其中任何一项。远程交付从确切的发布/head
66
+ 证据读取,而不从标题或分支名推断。
67
+
68
+ 取消意图不证明运行时已停止。user/Operator 可以重开已取消的 Task;Leader 可以重开
69
+ 已完成的 Task。重开需要全新的显式输入/工作选择,绝不重放先前的交付请求。
70
+
71
+ ## 归档
72
+
73
+ 归档是一次单独的授权动作,发生在活动工作已了结、资源干净可移除之后。显式选择
74
+ 集成交付或有意放弃。集成归档要求确切的已合并 head 和已验证的发布证据。一次显式
75
+ 授权的验证覆盖不能绕过缺失或陈旧的 head,也不能绕过一个未合并的结果。
76
+
77
+ 受管的 WorkItem 资源必须在清理前被集成或有意放弃。Review、Lane 和 Integration
78
+ 资源必须已结算。脏 worktree 留给 Agent 解决;不发生隐式 reset 或强制删除。Task
79
+ main 分支和持久 Task 记录保留恢复信息。已归档的 Task 不能重开。
80
+
81
+ 清理前用每个命令的 `--help` 查看它确切的权限和选项;阅读一份生命周期文档不授权
82
+ 一次外部写入。
@@ -1,3 +1,5 @@
1
+ <p align="right"><strong>English</strong> | <a href="./task-local-identity.zh-CN.md">简体中文</a></p>
2
+
1
3
  # Task-local identity
2
4
 
3
5
  Yui treats a Task as the aggregate boundary for durable workflow records. Each
@@ -5,7 +7,7 @@ Task owns an independent, monotonically increasing sequence for every record
5
7
  family:
6
8
 
7
9
  - WorkItem
8
- - Turn
10
+ - AgentRun
9
11
  - ReviewRound
10
12
  - ChangeSet
11
13
  - IntegrationAttempt
@@ -18,11 +20,11 @@ family:
18
20
  The first record of each family in each Task is therefore local `-1`. Deleted,
19
21
  cancelled, completed, reopened, and archived records never lower the persisted
20
22
  high-water mark, so a local ID is never reused inside its Task. Each allocation
21
- advances that aggregate high-water mark under the storage process lock.
23
+ advances that aggregate high-water mark inside the Store transaction.
22
24
 
23
25
  Candidate identity is narrower: `candidate-N` is a WorkItem-local sequence.
24
26
  Every Candidate stores its `taskId` and `workItemId`, in addition to the source
25
- Turn when one exists.
27
+ AgentRun when one exists.
26
28
 
27
29
  ## Reference contract
28
30
 
@@ -37,13 +39,13 @@ JSON, mailbox, Controller, Hook, receipt, Web, and error paths retain the Task
37
39
  scope. Context-free commands reject a bare local ID instead of searching all
38
40
  Tasks, even if that ID currently happens to be unique.
39
41
 
40
- A managed Task session may use `work-item-1` or `turn-1` because its
42
+ A managed Task session may use `work-item-1` or `run-1` because its
41
43
  `YUI_TASK_ID` is explicit. A command that already receives the Task as another
42
44
  argument may also use a subordinate local ID. Outside those two cases, use the
43
45
  qualified form. Delivery receipts use the same provenance, for example:
44
46
 
45
47
  ```text
46
- turn:task-7/turn-1
48
+ run:task-7/run-1
47
49
  input-request:task-7/input-1
48
50
  ```
49
51
 
@@ -58,5 +60,5 @@ boundary and the migration phase of `yui update`; every valid Home at or above
58
60
  the CLI's minimum supported storage version can advance directly to current.
59
61
 
60
62
  This boundary keeps Task-local references, Role desired configuration, and
61
- immutable Turn/RoleSession effective snapshots under one unambiguous runtime
63
+ immutable AgentRun/RoleSession effective snapshots under one unambiguous runtime
62
64
  contract while the append-only migration chain preserves supported history.