@zq-silk/yui 0.15.6 → 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 (282) 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 +167 -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 +188 -95
  25. package/dist/commands/agentCommands.js +72 -14
  26. package/dist/commands/capabilityCommands.js +57 -0
  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 +1216 -730
  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 +77 -0
  64. package/dist/controller/clientRuntime.js +65 -92
  65. package/dist/controller/controller.js +127 -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 +530 -476
  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 +423 -0
  106. package/dist/kernel/capabilityRegistry.js +314 -0
  107. package/dist/kernel/capabilitySchema.js +91 -0
  108. package/dist/kernel/instanceHost.js +18 -1
  109. package/dist/kernel/kernelPorts.js +4 -1
  110. package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
  111. package/dist/lifecycle/exactRunTerminalization.js +449 -0
  112. package/dist/message/message.js +62 -6
  113. package/dist/message/messageContinuation.js +204 -0
  114. package/dist/observability/executionAudit.js +70 -72
  115. package/dist/observability/faultClassification.js +2 -2
  116. package/dist/observability/orchestrationMetrics.js +8 -8
  117. package/dist/operator/operatorSessionHistory.js +1 -7
  118. package/dist/output/agentConfigurationPresentation.js +8 -3
  119. package/dist/output/agentRunConfigurationPresentation.js +128 -0
  120. package/dist/output/rolePresentation.js +54 -3
  121. package/dist/plugins/pluginChild.js +104 -0
  122. package/dist/plugins/pluginIntent.js +26 -0
  123. package/dist/plugins/pluginInterpreter.js +43 -0
  124. package/dist/plugins/pluginPackage.js +101 -0
  125. package/dist/plugins/pluginProcess.js +112 -0
  126. package/dist/plugins/pluginService.js +380 -0
  127. package/dist/profile/agentProfile.js +1 -1
  128. package/dist/repository/gitWorkspace.js +26 -4
  129. package/dist/repository/project.js +19 -4
  130. package/dist/repository/taskBaseFreshness.js +13 -13
  131. package/dist/repository/taskWorkspaceCoordinator.js +20 -27
  132. package/dist/repository/taskWorkspacePreparer.js +344 -83
  133. package/dist/resources/autoResourceGc.js +3 -3
  134. package/dist/resources/liveReferences.js +3 -3
  135. package/dist/resources/projectResource.js +123 -0
  136. package/dist/resources/projectResourceService.js +421 -0
  137. package/dist/resources/resourceDiscovery.js +6 -6
  138. package/dist/resources/resourceGc.js +1 -1
  139. package/dist/resources/resourceRegistrar.js +1 -1
  140. package/dist/resources/resourceTypes.js +1 -1
  141. package/dist/review/deltaRecheck.js +3 -3
  142. package/dist/review/reviewAcceptance.js +16 -16
  143. package/dist/review/reviewDecision.js +7 -7
  144. package/dist/review/reviewRound.js +21 -20
  145. package/dist/review/reviewerAvailability.js +2 -2
  146. package/dist/role/role.js +51 -7
  147. package/dist/role/taskRoleUpdate.js +30 -0
  148. package/dist/runtime/acpProtocol.js +425 -0
  149. package/dist/runtime/acpSession.js +731 -0
  150. package/dist/runtime/acpSessionConfiguration.js +260 -0
  151. package/dist/runtime/agentDriver.js +30 -11
  152. package/dist/runtime/agentEndpoint.js +278 -0
  153. package/dist/runtime/agentEndpointIdentity.js +86 -0
  154. package/dist/runtime/agentEndpointOwnership.js +239 -0
  155. package/dist/runtime/agentError.js +2 -10
  156. package/dist/runtime/agentHost.js +565 -314
  157. package/dist/runtime/agentRunConfiguration.js +258 -0
  158. package/dist/runtime/builtinAgentDrivers.js +134 -18
  159. package/dist/runtime/builtinAgentErrorMappers.js +55 -3
  160. package/dist/runtime/builtinTranscriptUsage.js +1 -1
  161. package/dist/runtime/claude-process-owner +0 -0
  162. package/dist/runtime/codexAppServerRuntime.js +38 -30
  163. package/dist/runtime/codexInteractiveHost.js +41 -6
  164. package/dist/runtime/continuationManager.js +2 -6
  165. package/dist/runtime/executionEnvironment.js +30 -0
  166. package/dist/runtime/firstProgressAdvisory.js +11 -11
  167. package/dist/runtime/index.js +4 -3
  168. package/dist/runtime/jsonLineChannel.js +109 -0
  169. package/dist/runtime/launchBroker.js +91 -16
  170. package/dist/runtime/launchDiagnostics.js +2 -2
  171. package/dist/runtime/lifecycleReservation.js +10 -18
  172. package/dist/runtime/managedCaller.js +61 -17
  173. package/dist/runtime/nativeSessionControl.js +102 -0
  174. package/dist/runtime/ports.js +6 -21
  175. package/dist/runtime/processExitObservation.js +8 -7
  176. package/dist/runtime/promptEnvelope.js +17 -6
  177. package/dist/runtime/providerContinuation.js +3 -9
  178. package/dist/runtime/providerContinuationReconciliationService.js +4 -13
  179. package/dist/runtime/providerControl.js +2 -7
  180. package/dist/runtime/providerRuntimeIdentity.js +110 -222
  181. package/dist/runtime/providerRuntimeReconciler.js +5 -9
  182. package/dist/runtime/runtimeBinding.js +0 -1
  183. package/dist/runtime/runtimeContinuationProjection.js +4 -7
  184. package/dist/runtime/runtimeDeadlines.js +9 -0
  185. package/dist/runtime/runtimeHealthPolicy.js +1 -1
  186. package/dist/runtime/runtimeObservation.js +29 -65
  187. package/dist/runtime/runtimeProjection.js +43 -51
  188. package/dist/runtime/runtimeSessionCandidate.js +1 -3
  189. package/dist/runtime/sessionLaunchRequest.js +3 -7
  190. package/dist/runtime/sessionOwnerIdentity.js +7 -54
  191. package/dist/runtime/sessionOwnerRegistry.js +22 -17
  192. package/dist/runtime/sessionReconciliation.js +4 -8
  193. package/dist/runtime/sessionTerminationGuard.js +70 -259
  194. package/dist/runtime/sessionTokenMetrics.js +5 -16
  195. package/dist/runtime/structuredProviderHost.js +237 -117
  196. package/dist/runtime/taskRuntimeIsolation.js +39 -122
  197. package/dist/runtime/tmuxAdapters.js +39 -86
  198. package/dist/scheduler/activeRoleRunDelivery.js +354 -0
  199. package/dist/scheduler/leaderWakeupProcessor.js +75 -266
  200. package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
  201. package/dist/scheduler/ports.js +80 -9
  202. package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
  203. package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
  204. package/dist/scheduler/taskExecutionProjection.js +120 -124
  205. package/dist/scheduler/taskObservabilityProjection.js +29 -29
  206. package/dist/scheduler/taskWake.js +11 -4
  207. package/dist/scheduler/wakeReason.js +9 -1
  208. package/dist/setup/setupCommand.js +1 -0
  209. package/dist/storage/migrations/agentRunContract.js +159 -0
  210. package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
  211. package/dist/storage/sqliteSchema.js +431 -5
  212. package/dist/storage/sqliteStore.js +375 -220
  213. package/dist/storage/storageVersions.js +1 -1
  214. package/dist/storage/storeRpc.js +10 -5
  215. package/dist/storage/taskStore.js +13 -11
  216. package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
  217. package/dist/surface/surfaceContributions.js +102 -0
  218. package/dist/task/completionReadiness.js +32 -6
  219. package/dist/task/deliveryGuard.js +16 -16
  220. package/dist/task/draftPlan.js +72 -12
  221. package/dist/task/nextAction.js +144 -128
  222. package/dist/task/remoteDelivery.js +6 -6
  223. package/dist/task/task.js +184 -18
  224. package/dist/task/taskActivation.js +301 -0
  225. package/dist/task/taskActivationService.js +392 -0
  226. package/dist/task/taskRecordReference.js +5 -4
  227. package/dist/task/taskRecordRetirement.js +1 -1
  228. package/dist/telemetry/sqliteTelemetryStore.js +55 -68
  229. package/dist/telemetry/telemetryConfig.js +14 -14
  230. package/dist/telemetry/telemetryWiring.js +2 -2
  231. package/dist/web/assets/assetManifest.js +2 -0
  232. package/dist/web/assets/client/app.js +120 -20
  233. package/dist/web/assets/client/components.js +87 -54
  234. package/dist/web/assets/client/i18n.js +83 -41
  235. package/dist/web/assets/client/markdown.js +1 -1
  236. package/dist/web/assets/client/taskSurface.js +353 -0
  237. package/dist/web/assets/client/view.js +49 -44
  238. package/dist/web/assets/shell.js +1 -1
  239. package/dist/web/assets/styles/cards.js +22 -4
  240. package/dist/web/controllerWeb.js +60 -0
  241. package/dist/web/webMutation.js +28 -0
  242. package/dist/web/webServer.js +118 -8
  243. package/dist/web/webSnapshot.js +81 -74
  244. package/dist/web/webTaskSurface.js +64 -0
  245. package/dist/workItem/dependencyGate.js +1 -1
  246. package/dist/workItem/workItem.js +80 -48
  247. package/dist/workspace/workItemChangeSetManager.js +16 -9
  248. package/docs/agent-result-consumption.md +94 -0
  249. package/docs/agent-runtime-drivers.md +91 -0
  250. package/docs/architecture/README.md +38 -0
  251. package/docs/architecture/capabilities-and-resources.md +79 -0
  252. package/docs/managed-turn-and-session-runtime.md +222 -0
  253. package/docs/observability/README.md +81 -0
  254. package/docs/plugin-sdk.md +290 -0
  255. package/docs/provider-runtime.md +163 -0
  256. package/docs/release-workflow.md +303 -0
  257. package/docs/roles-and-configuration.md +113 -0
  258. package/docs/sqlite-control-plane-design.md +76 -0
  259. package/docs/task-dag-semantics.md +57 -0
  260. package/docs/task-delivery.md +103 -0
  261. package/docs/task-local-identity.md +6 -6
  262. package/docs/testing/verification-levels.md +86 -0
  263. package/i18n/README.zh-CN.md +98 -739
  264. package/package.json +5 -5
  265. package/skills/yui-leader/SKILL.md +130 -103
  266. package/skills/yui-leader/references/integration.md +39 -0
  267. package/skills/yui-leader/references/replicated-execution.md +42 -0
  268. package/skills/yui-leader/references/task-plugins.md +33 -0
  269. package/skills/yui-operator/SKILL.md +30 -59
  270. package/skills/yui-reviewer/SKILL.md +35 -36
  271. package/skills/yui-runtime/SKILL.md +88 -24
  272. package/skills/yui-runtime/references/publication.md +22 -0
  273. package/skills/yui-runtime/references/recovery.md +64 -0
  274. package/skills/yui-worker/SKILL.md +37 -39
  275. package/dist/cli/roleOptionCatalog.js +0 -68
  276. package/dist/context/sourceTurnContext.js +0 -30
  277. package/dist/execution/reviewMainTurn.js +0 -161
  278. package/dist/execution/workItemMainTurn.js +0 -164
  279. package/dist/lifecycle/exactTurnTerminalization.js +0 -407
  280. package/dist/runtime/preallocatedNativeSession.js +0 -13
  281. package/dist/runtime/runtimeStopReceipt.js +0 -42
  282. package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
@@ -0,0 +1,303 @@
1
+ # Authorized release operations
2
+
3
+ A release workflow is an explicitly chosen, authorized sequence of
4
+ external release effects — pull requests, CI confirmation, merges, version
5
+ tags, npm publishes, fresh-install smoke tests, CLI updates, Controller
6
+ replacements, Project migrations, and post-verification. It is a specialized
7
+ external-effect facility, not Yui's Task planning or Agent execution model.
8
+ The Agent selects a predeclared plan, and the facility drives that plan
9
+ from durable state: every transition is persisted before the next external
10
+ call, so a crash, timeout, or revoked grant never leaves the release guessing.
11
+
12
+ Two task-level record families back it:
13
+
14
+ - **CapabilityGrant** (`capability-grant-N`) — the authority. A named granter
15
+ scopes a grant to actions, parameter bounds, an expiry, a use count, and an
16
+ irreversibility ceiling.
17
+ - **ReleaseWorkflow** (`release-workflow-N`) — the plan and its progress: an
18
+ exact source (repository + pinned commit, optionally an artifact), an
19
+ immutable ordered step plan, and one persisted record per step.
20
+
21
+ The engine (`src/release/releaseWorkflowEngine.ts`) is a pure library; the
22
+ `yui task workflow` and `yui task grant` commands drive it. Every external
23
+ system sits behind `ReleaseWorkflowPorts`
24
+ (`src/release/releaseWorkflowPorts.ts`), so the whole workflow is testable
25
+ with deterministic fakes and no real GitHub, npm, git, Controller, or process
26
+ side effect.
27
+
28
+ ## Authorization model
29
+
30
+ Every (re)submission of a step passes `checkGrant(grant, request, now)`
31
+ (`src/grant/capabilityGrant.ts`) **before** the external call. The step kind
32
+ is the grant action: a grant lists the step kinds it authorizes, for example
33
+ `--action npm-publish --action version-tag`. The decision is fail-closed —
34
+ every denial carries a machine-readable reason and stops the run:
35
+
36
+ | Reason | Meaning |
37
+ | --- | --- |
38
+ | `grant-missing` | No grant record is bound to the workflow (engine-level). |
39
+ | `grant-revoked` | The grant was revoked by an operator. |
40
+ | `grant-expired` | The wall clock passed the grant's `expiresAt`. |
41
+ | `grant-uses-exhausted` | The grant's `maxUses` has been consumed. |
42
+ | `grant-action-not-allowed` | The step kind is not in the grant's actions. |
43
+ | `grant-parameter-missing` | A bounded parameter is absent from the step. |
44
+ | `grant-parameter-value-not-allowed` | A bounded parameter has an out-of-bounds value. |
45
+ | `grant-irreversibility-exceeds-ceiling` | The step is more irreversible than the grant's ceiling. |
46
+
47
+ Additional rules:
48
+
49
+ - **One use per authorized submission.** The engine records a grant use
50
+ between the successful decision and the external call, so a `maxUses` grant
51
+ fails closed on the attempt that would exceed it.
52
+ - **Irreversible steps need a confirmed prefix.** A step marked
53
+ `irreversible` additionally requires every earlier step to be `succeeded`;
54
+ otherwise the step fails with `prerequisite-not-confirmed` and the run
55
+ stops. This is what keeps an `npm-publish` from running behind a failed PR.
56
+ - **Denials are recorded.** When a pending step is denied, the engine starts
57
+ and fails the step with the denial in its log, so `workflow status` shows
58
+ exactly where authorization stopped.
59
+ - **Rebinding.** A revoked, expired, or too-narrow grant does not dead-end
60
+ the workflow. Issue a new grant and resume with
61
+ `yui task workflow resume <task> <workflow> --grant <new-grant>`; the plan,
62
+ source, and all confirmed step evidence are immutable across the rebind.
63
+
64
+ ## Stable Task-final Review contract
65
+
66
+ Compatible CLI package updates and Controller replacements do not change an
67
+ active Task's final-review capability. Managed Sessions use the ordinary
68
+ `yui` command, compatibility is checked by protocol and storage identity, and
69
+ a replacement Leader presents the contract already established by durable Task
70
+ evidence. No version-aware Operator action is required.
71
+ Candidate and Task-final ReviewRound records must all carry that one contract.
72
+ Conflicting records fail closed; there is no rebind event, recovery command, or
73
+ second contract state machine.
74
+
75
+ ## CLI and Controller release boundary
76
+
77
+ The global `yui` command is the stable user and managed-Session interface. It
78
+ does not follow `runtime/active-release.json` for ordinary commands: that
79
+ pointer selects the Controller release, not the CLI package. This keeps CLI,
80
+ Operator Session, and Controller replacement compatible without pinning every
81
+ command to one immutable build.
82
+
83
+ A source-checkout or otherwise unverified local CLI is not this published
84
+ interface. When `YUI_HOME` already names an active release, such a CLI fails
85
+ before opening storage and reports its build/source, the durable Home identity,
86
+ and its invocation class. `make install-local` continues to default to the
87
+ checkout's isolated `output/dev/home`; explicitly pointing that launcher at a
88
+ release-owned Home is rejected.
89
+
90
+ An explicit `yui release activate <release-id|build-id>` is the one exception.
91
+ The global CLI verifies the installed target release and its matching smoke
92
+ receipt, then delegates the unchanged activation arguments to that target's
93
+ `dist/cli.js`. The target release therefore owns the complete handover protocol
94
+ and timeout hierarchy. A no-target activation, help, `--json`, and every other
95
+ command remain on the global CLI. Activation does not add another ordinary CLI
96
+ routing path.
97
+
98
+ ## Step catalog
99
+
100
+ The plan is a fixed, predeclared subset of operations. Each plan entry has an
101
+ id (unique within the workflow), a kind, optional params, and an optional
102
+ irreversibility level (`none` | `reversible` | `irreversible`).
103
+
104
+ | Kind | External effect | Authoritative identity |
105
+ | --- | --- | --- |
106
+ | `pr-create-or-reuse` | Creates the release PR, or reuses an open one for the head. | `pull-request` number |
107
+ | `ci-confirm` | Reads the CI conclusion for the source ref; succeeds only on `success`. | — |
108
+ | `merge` | Merges the named PR (squash by default). | — |
109
+ | `version-tag` | Creates and pushes the annotated version tag. | `git-tag` name |
110
+ | `npm-publish` | Publishes the tarball to the registry. | `npm-package` version |
111
+ | `fresh-install-smoke` | Installs and runs the published package from the registry. | — |
112
+ | `cli-update` | Updates the Yui CLI/Controller home via the existing update orchestrator. | `controller-home` |
113
+ | `controller-replace` | Stops and restarts the file-task Controller. | — |
114
+ | `project-migrate` | Runs the Project migration through the existing project command. | — |
115
+ | `post-verify` | Runs an arbitrary verification command. | — |
116
+
117
+ Steps may reference earlier evidence: a param value of
118
+ `$externalId:<step-id>` resolves to the referenced step's confirmed external
119
+ id at run time, so a `merge` step can consume the PR number the `pr` step
120
+ produced without the operator knowing it in advance. A reference to an
121
+ unconfirmed step fails the run rather than guessing.
122
+
123
+ ## Recovery and resume semantics
124
+
125
+ A run always starts from the **resume cursor**: the first plan step whose
126
+ status is not terminal (`succeeded` or `skipped`). There is no "start over" —
127
+ confirmed steps are never re-run.
128
+
129
+ Because every state transition is persisted before the next external call, a
130
+ process exit at any point is recoverable: re-invoke `run` (or `resume`) and
131
+ the engine continues from the first unconfirmed step. `--max-steps <n>` bounds
132
+ a single run; a run that exhausts its budget mid-workflow returns
133
+ `budget-exhausted` and the next invocation continues.
134
+
135
+ In-flight steps are resolved by **authoritative identity query**, never by
136
+ blind re-submission:
137
+
138
+ - A step left `running` or `unknown` is queried first by its recorded
139
+ `externalIdentity`.
140
+ - `exists` → the step reaches `succeeded` **without a second submission**
141
+ (`unknown` is confirmed, `running` is completed).
142
+ - `unknown` → the run stops with outcome `unknown`; the step is never
143
+ re-submitted while its fate is unknowable.
144
+ - `absent` → the effect never landed, so the step is re-attempted (a
145
+ `running` step records the recovery attempt).
146
+ - A `running` step **without** an external identity crashed before recording a
147
+ submission result. An irreversible step is queried through the port anyway
148
+ (the adapter consults its durable idempotency store): `exists` confirms the
149
+ step without a second submission, `unknown` stops as `unconfirmed`, and only
150
+ an authoritative `absent` re-attempts the step exactly once. A reversible
151
+ step always falls through and re-attempts under the same idempotency key.
152
+ - A timeout **without** an external identity marks the step as `unknown`
153
+ (unconfirmed) so it is never re-submitted blindly; on resume it fails closed
154
+ as `unconfirmed`.
155
+ - A `failed` step is retried on the next run; its `attempts` counter and logs
156
+ grow per attempt.
157
+
158
+ Run outcomes: `succeeded`, `failed`, `unknown`, `unauthorized`,
159
+ `unconfirmed`, `budget-exhausted`. Each carries a machine-readable
160
+ `stopReason` (for example `unknown:publish`, `unauthorized:grant-revoked`,
161
+ `budget-exhausted:verify`) and the list of step ids attempted that run.
162
+
163
+ ## Idempotency key contract
164
+
165
+ Each step's idempotency key is **predeclared at create time** and never
166
+ changes:
167
+
168
+ ```text
169
+ <taskId>/<workflowId>/<stepId>
170
+ ```
171
+
172
+ The key is passed to every `executeStep` call for that step, including
173
+ retries after a confirmed-absent timeout. The port contract requires
174
+ `executeStep` to be idempotent under the same key: a retried attempt must not
175
+ produce a second side effect. The engine side of the contract is stricter
176
+ still — it never calls `executeStep` for a step it has marked `unknown`; it
177
+ re-queries by the recorded identity instead. The fakes record every key, so
178
+ the test suite proves at-most-once execution directly.
179
+
180
+ ## Operator guide
181
+
182
+ Session authority is checked against current durable bindings. Telemetry is
183
+ grouped by Role/AgentRun, and process owners use PID/start identity. Storage
184
+ changes follow the [single explicit upgrade boundary](sqlite-control-plane-design.md);
185
+ ordinary commands never rewrite the Home schema.
186
+
187
+ Grant issue and revoke are irreversible-authority operations. They require
188
+ the current registered global Operator conversation. Its native session ID
189
+ must match the durable live session binding: Codex commands use `CODEX_THREAD_ID`
190
+ when present, otherwise `YUI_NATIVE_SESSION_ID`; Claude uses `YUI_NATIVE_SESSION_ID`.
191
+ Host generation and launch-time Agent labels are not caller identity. Resuming
192
+ the same conversation through another entry point does not revoke its authority.
193
+ An unregistered, replaced, or ended conversation has no such authority.
194
+ A managed Task Agent cannot self-issue or
195
+ self-revoke a grant, and clearing the child-process environment does not
196
+ confer user authority. The recorded granter/revoker is bound to that
197
+ Operator session (`operator:<agent-id>`); there is no `--granter`/`--by`
198
+ label to spoof.
199
+
200
+ ```sh
201
+ # 1. The Operator session issues the authority for the release chain.
202
+ yui task grant issue task-15 \
203
+ --action pr-create-or-reuse --action npm-publish --action post-verify \
204
+ --irreversibility-ceiling irreversible
205
+
206
+ # 2. Create the workflow against an exact source and a predeclared plan.
207
+ # An npm-publish step requires a content-addressed source artifact: the
208
+ # immutable workflow source can never gain one later, so a plan without
209
+ # --source-artifact is rejected at creation.
210
+ yui task workflow create task-15 \
211
+ --grant capability-grant-1 \
212
+ --source-repo acme/widget --source-commit abc1234deadbeef0000000000000000000000000 \
213
+ --source-artifact widget-1.0.0.tgz@sha512-<base64-integrity> \
214
+ --step pr:pr-create-or-reuse \
215
+ --step publish:npm-publish --step-irreversibility publish=irreversible \
216
+ --step-param publish:tarball=./dist/widget-1.0.0.tgz \
217
+ --step verify:post-verify --step-param verify:command='yui --version'
218
+
219
+ # 3. Run (or resume) and inspect.
220
+ yui task workflow run task-15 release-workflow-1
221
+ yui task workflow resume task-15 release-workflow-1 [--grant capability-grant-2] [--max-steps 1]
222
+ yui task workflow status task-15 release-workflow-1
223
+
224
+ # 4. Revoke authority at any time; the next step stops unauthorized.
225
+ yui task grant revoke task-15 capability-grant-1
226
+ ```
227
+
228
+ `workflow status` renders each step's status, attempt count, and confirmed
229
+ external id, so an operator can see exactly where a release stopped and why.
230
+
231
+ ## Real-resource boundary
232
+
233
+ Real execution happens only through the `yui` CLI, which wires the real
234
+ adapter (`createReleaseWorkflowPorts`). The adapter is a thin shell over
235
+ existing atomic operations — `gh`, `npm`, `git`, the CLI update orchestrator,
236
+ Controller stop/restart, and `project migrate` — and it runs only when a human
237
+ granter has issued an explicit CapabilityGrant that passes `checkGrant` for
238
+ each step. A local test request never substitutes for that authority.
239
+
240
+ The tag-triggered `publish.yml` workflow is the only maintained release smoke.
241
+ It reuses the exact commit that passed core CI and adds only artifact assembly,
242
+ fresh installation, and provenance checks required to publish.
243
+
244
+ That workflow authenticates through npm Trusted Publishing (OIDC), so the
245
+ release identity lives in two places outside the tag: `repository`, `bugs`, and
246
+ `homepage` are copied verbatim from the source `package.json` into the published
247
+ manifest by `assemble-runtime-package.mjs`, and the package's npm Trusted
248
+ Publisher entry names the GitHub owner, repository, workflow file, and
249
+ environment. npm compares `repository.url` against the building repository
250
+ case-sensitively before accepting provenance. Renaming or transferring the
251
+ GitHub repository therefore has to update those URLs and the npm Trusted
252
+ Publisher entry together with the rename; otherwise the next tag reaches
253
+ `npm publish` and fails there, after the tag and the gated build already
254
+ succeeded.
255
+
256
+ ## Adapter security hardening
257
+
258
+ The real adapter (`createReleaseWorkflowPorts`) applies additional safeguards
259
+ beyond the engine's grant checks:
260
+
261
+ - **Tarball option injection.** An option-looking tarball path (one starting
262
+ with `-`) is rejected before any subprocess — both the `tar -xOf` manifest
263
+ inspection and `npm publish` — sees it, so a crafted path can never be
264
+ interpreted as a flag.
265
+ - **Tarball TOCTOU.** After the frozen `source.artifact.integrity` is verified,
266
+ the verified bytes are snapshotted to a workflow-private, read-only temp
267
+ file. Both the `tar -xOf` manifest inspection and `npm publish` read the
268
+ snapshot, never the live tarball path, so a replacement of the original file
269
+ after verification cannot change what is published. The snapshot is removed
270
+ when the step completes.
271
+ - **Pinned external commands.** The adapter resolves the external commands it
272
+ shells out to (`gh`, `git`, `npm`, `tar`, `sh`) to absolute paths at
273
+ construction time via `resolveExecutable`, walking the caller's `PATH`
274
+ once. Every subprocess invocation uses the resolved path, so a later `PATH`
275
+ change (or a manipulated working directory) cannot redirect a release effect
276
+ to a different binary. An unresolvable command returns a synthetic failure
277
+ (exit 127) without invoking any binary.
278
+ - **Pinned cli-update activation target.** Before the irreversible update
279
+ effect, the adapter persists the exact activation target — the Home plus the
280
+ global npm prefix (`bin/yui`) — to a durable file under the Home
281
+ (`release/cli-update-identity/<idempotency-key>.json`). A hard-exit recovery
282
+ query (a step with no recorded identity) reads this file and invokes that
283
+ pinned target; if the file is absent (the process exited before the
284
+ pre-effect persistence), the query returns `unknown` rather than deriving
285
+ the target from the resume caller's `npm prefix --global` or `PATH`, so a
286
+ different installation in the resume environment cannot attest the step.
287
+ - **Controller lifecycle verification.** A `cli-update` recovery query proves
288
+ the replacement Controller actually owns the target Home: it runs
289
+ `yui --json controller status` (with `YUI_HOME` pinned to the recorded Home)
290
+ and requires a `current` controller resource whose `yuiHome` resolves to
291
+ that Home, then `yui --json controller identity` and requires the
292
+ authenticated Controller identity to match the activated artifact: the
293
+ Node.js executable path, the exact Controller entrypoint derived from the
294
+ pinned global binary, and the package version. Binary health alone (doctor,
295
+ `--version`) never confirms the handoff, and any unprovable state returns
296
+ `unknown`. This applies to both the identity-bearing query and the
297
+ hard-exit query (a step with no recorded identity).
298
+ - **npm integrity comparison.** An `npm-publish` recovery query does not stop
299
+ at the published version: it fetches `dist.integrity` via
300
+ `npm view <pkg>@<version> dist.integrity` and compares it byte-for-byte with
301
+ the frozen `source.artifact.integrity`. A match confirms the step; the same
302
+ version with different bytes is a conflict and returns `unknown` (never a
303
+ confirmation, never a re-publish); a missing version is `absent`.
@@ -0,0 +1,113 @@
1
+ # Roles, Profiles and execution configuration
2
+
3
+ ## Responsibilities
4
+
5
+ Agent selects an execution component, connection plan and launch environment.
6
+ Role selects an active Agent binding and portable behavior. Each binding retains
7
+ independent runtime options. A Role can keep multiple bindings without creating
8
+ parallel writers or sharing one binding's credentials/configuration with another.
9
+
10
+ Task Roles are Task-local; global Roles provide configured defaults and global
11
+ conversations. Role identity/configuration is not a writable runtime status.
12
+ Session and Provider observations describe actual activity.
13
+
14
+ An explicit Task-final Review uses an existing Task-local Reviewer Role without
15
+ requiring a same-named global Role. A global Role is a creation template only
16
+ when the requested Task Role does not exist. Availability, producer separation
17
+ and the frozen review candidate still apply.
18
+
19
+ ## Profiles
20
+
21
+ An Agent Profile combines portable behavior—instructions, Skills and access
22
+ intent—with runtime intent. Runtime either follows the current Global Worker
23
+ binding or explicitly selects an Agent with optional model and effort.
24
+ `config profile reset` supplies `worker`, `explorer`, `implementer` and `reviewer`.
25
+
26
+ Creating a Task Role from a Profile freezes its resolved behavior and binding.
27
+ Later Profile or Global Worker edits do not rewrite existing Task Roles.
28
+ Reapplying a Profile is an explicit configuration change. The selected Agent
29
+ must match the target binding; explicit Role options override the corresponding
30
+ template fields. A Profile is not a Session, workspace owner or resource grant.
31
+
32
+ Native children inherit their parent Agent and authority. A Profile can guide
33
+ their behavior; model/effort overrides require actual native tool support.
34
+ They do not acquire Yui Roles, independent Assignments or broader scope.
35
+
36
+ ## Desired, effective and observed
37
+
38
+ Desired settings are next-launch intent. An AgentRun and Session capture the
39
+ effective launch: Agent/component, protocol, model, effort, permission strategy,
40
+ workspace/environment, Role context and planning/delivery authority.
41
+
42
+ Live run-configuration inspection separately reports what the Agent actually
43
+ states. Unsupported and unknown are explicit; an accepted setter without a
44
+ reported current value is not an observed match. Configuration reads do not
45
+ modify the Agent to make the observation agree with desired settings.
46
+
47
+ Worker binding changes preserve an active Assignment's Agent and effective
48
+ snapshot; subsequent explicit dispatch uses the current selection. Leader
49
+ replacement revokes the previous management entry without rewriting Worker
50
+ Assignments. Changing desired configuration does not hot-mutate the native
51
+ Session. An explicit `task role session new` request handles old runtime
52
+ cleanup before selecting a fresh Session; it does not require manually settling
53
+ Run status first. A useful Session may be reused, but it is never the only
54
+ holder of Task context.
55
+
56
+ ## Permissions and Project context
57
+
58
+ Provider permission strategy, Profile access intent and Project write scope are
59
+ different contracts. Provider bypass does not grant writes to another Project.
60
+ Managed workspace owner, exact Assignment and resource grants enforce Yui
61
+ operations; broad native permissions are not an OS sandbox.
62
+
63
+ Yui supplies its generic Role Skills and Context pointers. Project Skills remain
64
+ ordinary Project files discovered natively by the Agent. Project Knowledge is
65
+ maintained under `YUI_HOME`; copying repository material into a prompt does not
66
+ make it authoritative Knowledge.
67
+
68
+ ## Native authentication
69
+
70
+ Account configuration outlives a Session. Yui preserves `HOME` and the selected
71
+ `CLAUDE_CONFIG_DIR`; new/resumed Sessions do not copy, clear, or fabricate native
72
+ login, key-approval, or onboarding records.
73
+
74
+ For Claude Code, standard API-key, base-URL, bearer/OAuth, model-alias and native
75
+ provider-selection environment variables are forwarded only to Claude. Values
76
+ remain in the Controller's replaceable runtime environment and the child process,
77
+ not in Task/Role records. Unsetting a source and refreshing the Controller
78
+ environment removes it for subsequent launches. Other custom credential variables
79
+ still use explicit Agent environment bindings or native user settings; Yui does
80
+ not inherit the whole shell environment or infer cloud credentials.
81
+
82
+ Claude itself loads native settings and chooses between API keys, existing
83
+ helpers, login credentials, profiles and cloud authentication according to its
84
+ effective configuration. Yui does not inject `apiKeyHelper`, copy credential
85
+ files, or override the native authentication priority. Explicit `--settings`
86
+ paths and settings-source selections are passed through unchanged.
87
+
88
+ Fresh native configuration can still require Claude's initialization, key,
89
+ workspace and security confirmations, including access to initialization
90
+ services. Isolating `YUI_HOME` or replacing a Session does not require a fresh
91
+ native account directory. Managed Task execution uses Claude's non-interactive
92
+ stream-json path with the same native configuration ownership.
93
+
94
+ ## Commands
95
+
96
+ ```sh
97
+ yui config agent capabilities <agent-id>
98
+ yui config role show <global-role>
99
+ yui config profile show <profile>
100
+ yui task role add <task> <role> --profile <profile>
101
+ yui task role show <task> <role>
102
+ yui task role update <task> <role> --environment <preparation-id>
103
+ yui task role update <task> <role> --managed-environment
104
+ yui task role session inspect <task> <role>
105
+ yui task role session new <task> <role> --reason "<why a fresh Session is useful>"
106
+ ```
107
+
108
+ On Role creation, explicit Agent settings require `--agent`. On update, omitted
109
+ `--agent` targets the active binding; a named binding is updated without being
110
+ activated. `task role bind` changes selection. A live Session requires the
111
+ command's explicit confirmation before desired settings are changed.
112
+
113
+ For native configuration and implementation limits, see [Provider runtime](provider-runtime.md).
@@ -0,0 +1,76 @@
1
+ # SQLite control-plane storage
2
+
3
+ Yui has one authoritative product Store: `YUI_HOME/yui.db` in WAL mode. The
4
+ highest contiguous, checksummed row in `schema_migrations` is the one Home
5
+ storage version accepted by the running release.
6
+
7
+ ## Authority
8
+
9
+ - `yui.db` owns Tasks, WorkItems, AgentRuns, Messages, Decisions, results, Project
10
+ Knowledge references, managed workspace records, runtime bindings, mailboxes,
11
+ durable events, and configuration.
12
+ - Provider Sessions, transcripts, processes, caches, telemetry, and runtime
13
+ observations support execution and diagnosis; they do not replace durable
14
+ Task facts.
15
+ - Configuration and diagnostics outside the database do not define another
16
+ storage version or permit rebuilding Task truth heuristically.
17
+
18
+ ## Admission
19
+
20
+ Ordinary commands open a Home only when all of these are true:
21
+
22
+ 1. `yui.db` exists and its migration ledger is a valid immutable prefix.
23
+ 2. The ledger head exactly matches the running CLI's current storage version.
24
+ 3. Current record validation and reference integrity succeed.
25
+
26
+ An older Home inside the CLI's supported range fails ordinary admission but is
27
+ classified as upgradeable. `yui doctor` and `yui upgrade --dry-run` report the
28
+ ordered path without changing the Home. Explicit `yui upgrade` is the only
29
+ standalone mutation boundary: it quiesces the Controller, backs up `yui.db`,
30
+ applies all missing migrations transactionally, and validates the current
31
+ model. A newer, below-minimum, incomplete, or malformed Home fails closed.
32
+ There is no runtime normalization, repair worker, file-Store fallback, dual
33
+ read/write path, or second migration authority.
34
+
35
+ ## Write and concurrency contract
36
+
37
+ - Each mutation is one SQLite transaction.
38
+ - WAL plus `synchronous=FULL` provides the durable commit boundary.
39
+ - `home_meta.revision` is the Home-wide CAS/revision used by callers that need
40
+ a frozen read/modify/write boundary.
41
+ - Typed columns support indexed identity and status queries; the full validated
42
+ record payload remains the durable domain representation.
43
+ - Mailbox claim, exact AgentRun terminalization, active-pointer removal, result
44
+ persistence, and downstream wake creation are transactionally coupled where
45
+ they form one product fact.
46
+ - Idempotency keys and unique constraints protect repeatable external-effect
47
+ acknowledgements; they do not form a second workflow state machine.
48
+
49
+ ## AgentRun and Session boundary
50
+
51
+ An AgentRun is an explicitly requested execution. It records associated visible
52
+ inputs and the original result, not hidden reasoning or the full tool trace.
53
+ A Provider Session can contain multiple Runs, ordinary native chat and
54
+ notifications. Native chat and notifications do not automatically create Runs.
55
+ Only an exactly correlated native terminal settles the Run; the Leader remains
56
+ the authority for WorkItem and Task acceptance.
57
+
58
+ ## Update behavior
59
+
60
+ `yui update` stages an exact package and asks that staged binary to classify the
61
+ Home as current, migration-ready, or blocked. It then stops the exact
62
+ Controller, activates the same package, runs the staged release's complete
63
+ migration chain when required, verifies the installed binary and current Home,
64
+ and starts the replacement Controller.
65
+
66
+ Every persistent schema or payload change appends one immutable, contiguous
67
+ storage migration. The CLI publishes both `storageVersion` and
68
+ `minimumStorageVersion`; every valid Home in that inclusive range can upgrade
69
+ directly to the current version without installing intermediate releases.
70
+ The current source declares storage version **18**, with minimum supported
71
+ migration version **1**, in `src/storage/storageVersions.ts`. Homes below that
72
+ floor are not migration inputs and remain untouched.
73
+ The target binary's `upgrade --update-preflight` and `--update-apply` result
74
+ shapes and parent-owned handover-lock proof remain backward compatible with
75
+ every updater released from storage version 1 onward, so an old source CLI can
76
+ still drive a much newer target's complete migration chain.
@@ -0,0 +1,57 @@
1
+ # Task 依赖与 WorkItem 语义
2
+
3
+ ## 需求与执行分离
4
+
5
+ Task 是一个有界结果,WorkItem 是其中可独立验收的需求。Task type 不决定
6
+ 执行拓扑;Leader 可以直接工作,也可以创建独立负责人交付的 WorkItem。
7
+ 实现步骤、一次测试、审查发现或小修补不因此成为新 WorkItem。
8
+
9
+ WorkItem 持久状态仅为 `open / accepted / retired`:
10
+
11
+ - `open`:需求仍在处理;可能尚未执行、正在执行、等待验收或需要重试。
12
+ - `accepted`:Leader 已显式接受当前交付。
13
+ - `retired`:需求已显式退役,保留记录和原因。
14
+
15
+ 执行状态归 AgentRun,Candidate 记录当前待接受的结果。提交、拒绝或执行失败
16
+ 不把 WorkItem 变成另一套运行状态。接受撤回是显式动作。
17
+
18
+ ## 唯一依赖权威
19
+
20
+ `WorkItem.dependsOn` 是同一 Task 内的直接依赖列表。前置项 A → 下游 B
21
+ 表示 B 的 `dependsOn` 包含 A。保存时检查同 Task 引用、存在性和无环约束。
22
+ 它不表达 Provider 并发、Session 占用或文件锁。
23
+
24
+ 派发时,每个直接依赖必须存在且为 `accepted`。Open、retired 或 missing
25
+ 均不能满足依赖,错误返回具体 ID 和当前状态。Run 成功、Candidate 存在、
26
+ Review 完成或 Git 已集成都不能代替 WorkItem 接受。
27
+
28
+ 退役的 replacement 字段只解释替代关系,不重定向或重写依赖。
29
+ Leader 必须显式修订需求或依赖;Controller 不沿替换链自动释放下游,
30
+ 不级联取消、不自动跳过,也不把依赖列表变成调度计划。
31
+
32
+ ## 修改与恢复
33
+
34
+ Open WorkItem 的合法定义编辑保存前后值,保留身份和执行证据。已经启动的
35
+ Run 仍使用冻结 Assignment;修改当前需求不追溯改写其 Context 或权限。
36
+ 已接受和退役的定义不能借普通编辑覆盖。负责人与资源范围变更受各自边界检查。
37
+
38
+ 执行失败时,Leader 检查原始结果、Session、依赖与工作区,决定续作、重试、
39
+ 退役或修改计划。退役后迟到消息保留来源和未投递原因,不自动重开。
40
+ InputRequest 表示待决问题;回答不自动接受 WorkItem 或改写依赖。
41
+
42
+ ## 接受、集成与 Task 完成
43
+
44
+ Direct 和 replicated 共享一个 Leader 接受边界。Replicated Producer 不形成
45
+ Candidate;只有显式综合的 main Run 结果进入候选路径。Leader 直接管理的
46
+ 交付也必须满足适用的 Candidate、ChangeSet 和 Integration 边界。
47
+
48
+ 隔离代码结果按 Project 捕获固定 ChangeSet,检查后 CAS 集成;未捕获、未集成
49
+ 或失效的最新结果不能满足交付。Review 依适用规则和 Task 合同检查。
50
+ Leader 自己交付的 Task main 需要干净、已提交的精确快照。
51
+
52
+ Task lifecycle 是 `draft / active / completed / cancelled / archived`。
53
+ Draft 先规划再显式采用工作区;completed/cancelled 不接收隐式新执行,
54
+ reopen 不重放旧请求;archived 不可重开。Archive 还要求资源静止、干净可移除,
55
+ 不因依赖图或完成状态自动删除工作区。
56
+
57
+ CLI/Web 从这些事实派生展示和建议,不维护第二套可写 DAG、验收状态或计划。
@@ -0,0 +1,103 @@
1
+ # Task delivery and resource lifecycle
2
+
3
+ ## Lifecycle and planning
4
+
5
+ Task lifecycle is `draft / active / completed / cancelled / archived`. A Draft
6
+ stores intent, Project bindings, planning discussion and mutable requirements.
7
+ It does not adopt a writable delivery workspace at creation.
8
+
9
+ Activation validates current Roles, dependencies, Project scope and resources,
10
+ prepares physical workspaces, and adopts status/ownership atomically. Failed
11
+ preparation leaves the Task Draft with a failed request and a diagnosis delivered
12
+ to the Leader. Deferred activation retains the exact intent and waits for native
13
+ quiescence, whether requested in a planning Run or subsequent discussion.
14
+
15
+ Task type describes the requested outcome, not the mandatory executor.
16
+ Leader owns bounded work directly or assigns substantial independent WorkItems.
17
+ Direct execution has no Group. Replication is explicitly requested for independent
18
+ attempts at the same frozen Assignment, followed by Leader-selected synthesis.
19
+
20
+ ## Managed workspaces
21
+
22
+ Stable Project checkouts are read-only references. Task main is a logical
23
+ multi-Project root with per-Project Git worktrees. For one Project, the Agent's
24
+ normal cwd is its managed Git root; for multiple Projects, the root and native
25
+ additional-directory mechanism expose the explicit Project set.
26
+
27
+ An isolated WorkItem has independent worktrees for writable Projects and
28
+ Task-main context for the others. Write scope is explicit and can only be
29
+ expanded by the authorized owner. Review owns a separate frozen workspace and
30
+ cannot become a Develop or Integration source.
31
+ Acceptance or retirement does not release a WorkItem's durable workspace.
32
+ Task-main preparation preserves a Role's retained WorkItem/Review cwd until
33
+ explicit cleanup or reassignment. Decision-support reads observe current Git
34
+ heads without preparing workspaces or migrating Sessions.
35
+
36
+ Before launch, actual Git lineage must descend from the recorded base. A reset
37
+ outside that lineage is physical drift, not a reason to guess or repair ownership.
38
+ An explicitly adopted environment can select a different native cwd while the
39
+ managed workspace remains the Git/control ownership record.
40
+
41
+ ## Candidate, Review and Integration
42
+
43
+ Provider terminal saves the exact original Run result. It does not accept the
44
+ WorkItem. The Leader evaluates the result and captures immutable per-Project
45
+ ChangeSets for isolated code. The governing Candidate supplies provenance for
46
+ Review and Integration; Producers do not independently enter either path.
47
+
48
+ Integration applies the fixed ChangeSet in a candidate worktree, runs configured
49
+ checks, then advances the target only if its head still matches. Conflict,
50
+ failed checks, target movement or rejection retain evidence and never advance
51
+ the target. The Agent chooses retry or manual resolution within the retained
52
+ workspace.
53
+
54
+ When checks are a DurableJob, the Integration retains that exact jobId while
55
+ running. Once the Job settles, `task integration continue <task>/<integration>`
56
+ consumes its result and performs the guarded finalization. The direct operation
57
+ does not depend on entries in the separate integration queue.
58
+
59
+ Review follows the applicable Candidate rule or Task-final contract and frozen
60
+ heads. The exact main Reviewer Run holds the report; successful execution is
61
+ not a semantic pass. Acceptance belongs to the Leader.
62
+ An explicit user requirement to delegate or obtain independent Review remains
63
+ part of acceptance even if the default review policy is disabled. `next-action`
64
+ reports stored facts and alternatives; it cannot weaken the Task Contract or
65
+ infer that unrecorded WorkItems mean direct execution was requested.
66
+
67
+ ## Completion and remote delivery
68
+
69
+ Completion checks the current WorkItems, latest captured/integrated results,
70
+ applicable Review contract and exact clean committed Task-main snapshot.
71
+ It also refuses completion while a new user/Operator message is still awaiting
72
+ Leader delivery. The current native turn must end so the pending notification
73
+ can arrive; the Leader then reads the original message and reassesses completion.
74
+ This derives from existing Messages and mailbox delivery, not a second
75
+ acknowledgement or workflow state.
76
+ Terminal workspace cleanup can remain an advisory at completion, but not at
77
+ archive. Artifacts selected as results must be fixed, present and Task-local.
78
+
79
+ Publication records a remote PR/MR reference. Reported merge, independently
80
+ verified merge and exact Task-head coverage are separate facts. Task completion
81
+ does not prove any of them. Remote delivery is read from exact publication/head
82
+ evidence, not inferred from a title or branch name.
83
+
84
+ Cancelled intent does not prove the runtime stopped. User/Operator may reopen
85
+ cancelled Tasks; Leader may reopen completed Tasks. Reopening requires fresh
86
+ explicit input/work selection and never replays previous delivery requests.
87
+
88
+ ## Archive
89
+
90
+ Archive is a separate authorized action after active work is settled and
91
+ resources are clean and removable. Choose integrated delivery or deliberate
92
+ abandonment explicitly. Integrated archive requires exact merged heads and
93
+ verified publication evidence. An explicitly authorized verification override
94
+ cannot bypass missing or stale heads or an unmerged result.
95
+
96
+ Managed WorkItem resources must be integrated or deliberately abandoned before
97
+ cleanup. Review, Lane and Integration resources must be settled. Dirty worktrees
98
+ remain for the Agent to resolve; no implicit reset or force deletion occurs.
99
+ Task main branches and durable Task records retain recovery information.
100
+ Archived Tasks cannot reopen.
101
+
102
+ Use each command's `--help` to inspect its exact authority and options before
103
+ cleanup; reading a lifecycle document does not authorize an external write.