@zq-silk/yui 0.13.9 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/ARCHITECTURE.md +69 -428
  2. package/README.md +108 -298
  3. package/dist/agent/managedRuntimeEnvironment.js +2 -2
  4. package/dist/cli/commandCatalog.js +39 -77
  5. package/dist/cli/interactionCandidates.js +4 -4
  6. package/dist/cli/interactionPolicy.js +7 -10
  7. package/dist/cli/invocationRouter.js +1 -1
  8. package/dist/cli/updateCommand.js +6 -27
  9. package/dist/cli/updateOrchestrator.js +63 -484
  10. package/dist/cli/updatePorts.js +15 -333
  11. package/dist/cli/upgradeCommand.js +8 -65
  12. package/dist/cli.js +57 -242
  13. package/dist/commands/configCommands.js +11 -62
  14. package/dist/commands/executionAuditCommands.js +23 -23
  15. package/dist/commands/globalRoleCommands.js +2 -7
  16. package/dist/commands/jobCommands.js +1 -4
  17. package/dist/commands/projectCommands.js +5 -5
  18. package/dist/commands/releaseCommands.js +3 -10
  19. package/dist/commands/resourcesCommands.js +2 -2
  20. package/dist/commands/sessionCommands.js +2 -2
  21. package/dist/commands/taskActor.js +31 -39
  22. package/dist/commands/taskChangeSetCommands.js +5 -12
  23. package/dist/commands/taskCommands.js +464 -1249
  24. package/dist/commands/taskContextCommand.js +35 -36
  25. package/dist/commands/taskExecutionCommands.js +33 -46
  26. package/dist/commands/taskInputCommands.js +20 -42
  27. package/dist/commands/taskNextActionCommand.js +9 -9
  28. package/dist/commands/taskOverviewCommand.js +56 -95
  29. package/dist/commands/taskRoleRuntimeStatus.js +77 -107
  30. package/dist/commands/taskUpstreamCommands.js +3 -3
  31. package/dist/commands/taskWorkspaceCommands.js +7 -79
  32. package/dist/commands/telemetryCommands.js +32 -124
  33. package/dist/commands/workflowCommands.js +3 -3
  34. package/dist/completion/fileCompletionManager.js +1 -1
  35. package/dist/config/configCatalog.js +4 -6
  36. package/dist/config/yuiConfig.js +6 -43
  37. package/dist/context/dispatchContext.js +14 -30
  38. package/dist/context/roleSessionContext.js +2 -2
  39. package/dist/context/sessionBootstrapManifest.js +2 -2
  40. package/dist/context/{runContextPack.js → turnContextPack.js} +58 -73
  41. package/dist/context/turnInputContract.js +204 -0
  42. package/dist/context/wakeNotification.js +2 -2
  43. package/dist/controller/agentRuntimeObserver.js +18 -18
  44. package/dist/controller/clientRuntime.js +13 -20
  45. package/dist/controller/controller.js +89 -116
  46. package/dist/controller/fileSchedulerStoreAdapter.js +511 -742
  47. package/dist/controller/jobControl.js +17 -17
  48. package/dist/controller/resourceInventory.js +6 -6
  49. package/dist/controller/resourceInventoryLinux.js +38 -59
  50. package/dist/controller/resourceInventoryRpc.js +3 -3
  51. package/dist/controller/resourceInventoryWorker.js +1 -1
  52. package/dist/controller/runtime.js +46 -53
  53. package/dist/controller/runtimeEventInbox.js +23 -31
  54. package/dist/controller/runtimeEventProcessor.js +15 -15
  55. package/dist/controller/{runtimeHookRunFence.js → runtimeHookTurnFence.js} +87 -81
  56. package/dist/controller/runtimeLaunchCoordinator.js +3 -3
  57. package/dist/controller/runtimeObservationHook.js +11 -8
  58. package/dist/controller/sessionNotify.js +11 -11
  59. package/dist/controller/structuredProviderObservation.js +89 -16
  60. package/dist/coordination/workMailbox.js +309 -579
  61. package/dist/coordination/workMailboxQueue.js +5 -6
  62. package/dist/core/controllerClient.js +1 -91
  63. package/dist/core/controllerServer.js +3 -6
  64. package/dist/doctor/doctor.js +51 -314
  65. package/dist/execution/candidateConvergence.js +3 -3
  66. package/dist/execution/executionGroup.js +32 -33
  67. package/dist/execution/executionHealth.js +36 -38
  68. package/dist/execution/resourceBroker.js +12 -12
  69. package/dist/executor/agentExecutor.js +30 -265
  70. package/dist/executor/effectiveLaunch.js +9 -19
  71. package/dist/executor/executorRegistry.js +43 -17
  72. package/dist/executor/fileRoleLaunchPlanner.js +56 -56
  73. package/dist/executor/launchPlan.js +3 -3
  74. package/dist/executor/workspacePreflightClassification.js +16 -16
  75. package/dist/grant/capabilityGrant.js +20 -25
  76. package/dist/input/inputRequest.js +12 -12
  77. package/dist/integration/changeSet.js +9 -13
  78. package/dist/integration/changeSetManifest.js +1 -1
  79. package/dist/integration/gitIntegrationService.js +2 -2
  80. package/dist/integration/integrationQueueService.js +5 -21
  81. package/dist/integration/overlapDiagnostics.js +2 -2
  82. package/dist/interaction/operatorPresentation.js +1 -1
  83. package/dist/job/jobRunner.js +1 -1
  84. package/dist/lifecycle/canonicalLifecycleEvent.js +25 -25
  85. package/dist/lifecycle/{exactRunTerminalization.js → exactTurnTerminalization.js} +116 -232
  86. package/dist/message/message.js +6 -6
  87. package/dist/observability/executionAudit.js +74 -86
  88. package/dist/observability/faultClassification.js +7 -24
  89. package/dist/observability/orchestrationMetrics.js +5 -5
  90. package/dist/observability/runtimeIdentity.js +34 -101
  91. package/dist/profile/agentProfile.js +1 -1
  92. package/dist/release/cliHomeReleaseFence.js +3 -3
  93. package/dist/release/releaseWorkflowEngine.js +6 -10
  94. package/dist/release/releaseWorkflowPorts.js +2 -2
  95. package/dist/release/workflowFileLock.js +1 -1
  96. package/dist/repository/checkoutSwap.js +1 -1
  97. package/dist/repository/gitWorkspace.js +0 -13
  98. package/dist/repository/project.js +1 -1
  99. package/dist/repository/projectMaintenanceLock.js +1 -2
  100. package/dist/repository/taskBaseFreshness.js +13 -13
  101. package/dist/repository/taskWorkspaceCoordinator.js +21 -25
  102. package/dist/repository/taskWorkspaceIdentity.js +8 -21
  103. package/dist/repository/taskWorkspacePreparer.js +63 -620
  104. package/dist/resources/autoResourceGc.js +3 -3
  105. package/dist/resources/liveReferences.js +1 -1
  106. package/dist/resources/resourceGc.js +1 -1
  107. package/dist/resources/sqliteResourceRegistry.js +1 -1
  108. package/dist/review/reviewDecision.js +7 -7
  109. package/dist/review/reviewFindingLedger.js +1 -1
  110. package/dist/review/reviewOutcomeClassifier.js +35 -50
  111. package/dist/review/reviewRound.js +14 -25
  112. package/dist/review/reviewerAvailability.js +4 -4
  113. package/dist/review/taskFinalReviewContractResolution.js +41 -0
  114. package/dist/role/role.js +6 -3
  115. package/dist/runtime/agentDriver.js +4 -0
  116. package/dist/runtime/agentHost.js +151 -36
  117. package/dist/runtime/builtinAgentDrivers.js +79 -2
  118. package/dist/runtime/codexAppServerRuntime.js +122 -0
  119. package/dist/runtime/continuationManager.js +3 -5
  120. package/dist/runtime/exactControlPlane.js +17 -42
  121. package/dist/runtime/firstProgressAdvisory.js +1 -1
  122. package/dist/runtime/index.js +2 -2
  123. package/dist/runtime/launchDiagnostics.js +2 -2
  124. package/dist/runtime/lifecycleReservation.js +4 -4
  125. package/dist/runtime/processExitObservation.js +1 -1
  126. package/dist/runtime/processExitOutbox.js +0 -32
  127. package/dist/runtime/promptEnvelope.js +9 -9
  128. package/dist/runtime/providerContinuation.js +2 -2
  129. package/dist/runtime/providerContinuationReconciliationService.js +2 -2
  130. package/dist/runtime/providerRuntimeIdentity.js +76 -24
  131. package/dist/runtime/recentTurnIds.js +38 -0
  132. package/dist/runtime/runtimeContinuationProjection.js +2 -2
  133. package/dist/runtime/runtimeHealthPolicy.js +1 -1
  134. package/dist/runtime/runtimeObservation.js +58 -21
  135. package/dist/runtime/runtimeProjection.js +19 -27
  136. package/dist/runtime/sessionLaunchRequest.js +2 -2
  137. package/dist/runtime/structuredProviderHost.js +177 -12
  138. package/dist/runtime/tmuxAdapters.js +46 -11
  139. package/dist/scheduler/activeRoleTurnDelivery.js +245 -0
  140. package/dist/scheduler/leaderWakeupProcessor.js +147 -445
  141. package/dist/scheduler/operatorEvent.js +4 -6
  142. package/dist/scheduler/resourceQueueProjection.js +71 -0
  143. package/dist/scheduler/{roleRunLiveness.js → roleTurnLiveness.js} +24 -28
  144. package/dist/scheduler/{roleRunStall.js → roleTurnStall.js} +162 -247
  145. package/dist/scheduler/taskExecutionProjection.js +99 -99
  146. package/dist/scheduler/taskObservabilityProjection.js +10 -10
  147. package/dist/scheduler/taskWake.js +4 -4
  148. package/dist/scheduler/wakeReason.js +6 -10
  149. package/dist/scheduler/wakeupQueue.js +0 -9
  150. package/dist/setup/setupCommand.js +2 -2
  151. package/dist/storage/currentTaskStore.js +46 -0
  152. package/dist/storage/persistenceWorker.js +1 -1
  153. package/dist/storage/sqliteSchema.js +81 -485
  154. package/dist/storage/sqliteStore.js +206 -365
  155. package/dist/storage/storageSchema.js +1 -15
  156. package/dist/storage/storageVersions.js +8 -9
  157. package/dist/storage/storeRpc.js +10 -34
  158. package/dist/storage/taskStore.js +63 -3415
  159. package/dist/storage/upgrade/recordVersions.js +55 -149
  160. package/dist/storage/upgrade/upgradeOrchestrator.js +89 -1752
  161. package/dist/task/completionReadiness.js +5 -5
  162. package/dist/task/deliveryGuard.js +10 -10
  163. package/dist/task/nextAction.js +74 -77
  164. package/dist/task/task.js +2 -4
  165. package/dist/task/taskRecordReference.js +3 -3
  166. package/dist/task/taskRecordRetirement.js +1 -1
  167. package/dist/telemetry/sqliteTelemetryStore.js +53 -53
  168. package/dist/telemetry/telemetryConfig.js +14 -14
  169. package/dist/telemetry/telemetryWiring.js +8 -14
  170. package/dist/turn/turn.js +356 -0
  171. package/dist/{run/runIdentity.js → turn/turnIdentity.js} +4 -4
  172. package/dist/verification/gateArtifactStore.js +2 -2
  173. package/dist/web/assets/client/app.js +1 -1
  174. package/dist/web/assets/client/components.js +29 -54
  175. package/dist/web/assets/client/i18n.js +17 -37
  176. package/dist/web/assets/client/view.js +37 -37
  177. package/dist/web/assets/shell.js +1 -1
  178. package/dist/web/assets/styles/cards.js +5 -5
  179. package/dist/web/assets/styles/widgets.js +1 -2
  180. package/dist/web/webSnapshot.js +65 -60
  181. package/dist/workItem/workItem.js +11 -11
  182. package/dist/workspace/workItemChangeSetManager.js +1 -1
  183. package/docs/task-local-identity.md +5 -5
  184. package/i18n/README.zh-CN.md +41 -54
  185. package/package.json +1 -1
  186. package/skills/yui-leader/SKILL.md +85 -83
  187. package/skills/yui-operator/SKILL.md +16 -16
  188. package/skills/yui-reviewer/SKILL.md +10 -10
  189. package/skills/yui-runtime/SKILL.md +17 -18
  190. package/skills/yui-worker/SKILL.md +16 -18
  191. package/dist/context/runContextContract.js +0 -162
  192. package/dist/executor/turnCompletion.js +0 -126
  193. package/dist/review/taskFinalReviewContractEvent.js +0 -1
  194. package/dist/review/taskFinalReviewContractRebind.js +0 -367
  195. package/dist/run/agentRun.js +0 -356
  196. package/dist/run/rejectedYieldAttempt.js +0 -221
  197. package/dist/run/runControlRequest.js +0 -50
  198. package/dist/run/yieldReceipt.js +0 -65
  199. package/dist/runtime/turnCompletion.js +0 -3
  200. package/dist/scheduler/actionability.js +0 -323
  201. package/dist/scheduler/activeRoleRunDelivery.js +0 -868
  202. package/dist/scheduler/activeTaskProgress.js +0 -126
  203. package/dist/storage/compatibleTaskStore.js +0 -248
  204. package/dist/storage/migration/baseline.js +0 -78
  205. package/dist/storage/migration/classifier.js +0 -51
  206. package/dist/storage/migration/compatibleCodec.js +0 -53
  207. package/dist/storage/migration/engine.js +0 -147
  208. package/dist/storage/migration/index.js +0 -33
  209. package/dist/storage/migration/planner.js +0 -154
  210. package/dist/storage/migration/productionRegistry.js +0 -3931
  211. package/dist/storage/migration/registry.js +0 -169
  212. package/dist/storage/migration/report.js +0 -54
  213. package/dist/storage/migration/types.js +0 -31
  214. package/dist/storage/upgrade/homeClassification.js +0 -353
  215. package/dist/storage/upgrade/homeMigrationTarget.js +0 -595
  216. package/dist/storage/upgrade/migrationReceipt.js +0 -67
  217. package/dist/storage/upgrade/offlineUpgradeInventory.js +0 -453
  218. package/dist/storage/upgrade/productionMigrationRegistry.js +0 -6
  219. package/dist/storage/upgrade/pseudoLayoutRepair.js +0 -241
  220. package/dist/storage/upgrade/recordVersionScan.js +0 -176
  221. package/dist/storage/upgrade/sqliteFileSet.js +0 -50
  222. package/dist/storage/upgrade/sqliteMigrationTarget.js +0 -375
  223. package/dist/storage/upgrade/sqliteRecordMigrationTarget.js +0 -305
  224. package/dist/storage/upgrade/sqliteStateMigration.js +0 -918
  225. package/dist/storage/upgrade/switchProgress.js +0 -80
  226. package/dist/storage/upgrade/upgradeReceipt.js +0 -161
  227. package/dist/storage/upgradeCoordination.js +0 -187
  228. package/dist/storage/upgradeFence.js +0 -366
  229. package/dist/telemetry/telemetryCompaction.js +0 -252
package/README.md CHANGED
@@ -72,11 +72,16 @@ export YUI_HOME=/absolute/path/to/yui-home
72
72
  yui setup
73
73
  ```
74
74
 
75
- The home contains `schema.json`, the authoritative `state.json`, Project Catalog and knowledge, and Controller discovery files. Stable Project checkouts and managed worktrees live under the configured workspace, outside Yui home. Runtime storage is strict and its writer is current-only. A specifically declared, record-only older shape may be normalized into the current domain model in memory; Yui never dual-writes formats, preserves unknown old fields, or guesses an old identifier.
75
+ The home contains `schema.json`, the authoritative SQLite database `yui.db`,
76
+ Project Catalog and knowledge, and Controller discovery files. Stable Project
77
+ checkouts and managed worktrees live under the configured workspace, outside
78
+ Yui home. Runtime storage accepts only the exact current contract; it never
79
+ falls back to `state.json`, normalizes an older shape, or repairs a historical
80
+ Home in place.
76
81
 
77
82
  Every Task-owned record family allocates a monotonically increasing local ID
78
83
  inside its Task. Different Tasks may therefore both contain `work-item-1`,
79
- `agent-run-1`, or `input-1`. A managed Task session may use that short local ID
84
+ `turn-1`, or `input-1`. A managed Task session may use that short local ID
80
85
  because `YUI_TASK_ID` supplies the scope. Outside a Task session, use the
81
86
  qualified form `<task-id>/<local-id>`; Yui never searches every Task for a bare
82
87
  ID. Commands that already take a Task explicitly, such as `task work create`
@@ -84,160 +89,27 @@ and `task integration start`, keep their subordinate IDs local to that Task.
84
89
  Candidate IDs are local to their WorkItem and carry both Task and WorkItem
85
90
  provenance.
86
91
 
87
- Yui models three independent, monotonic storage version axes: the on-disk
88
- `layout` (`schema.json`, `state.json`, locks), the authoritative `aggregate`
89
- document, and the `record` axis a `recordKind -> version` map where every
90
- record family (WorkItem, AgentRun, ReviewRound, …) versions on its own. A
91
- centralized compatibility framework (registry planner loader/engine)
92
- covers all three. Every adjacent version transition must be declared explicitly:
93
- a `compatible` declaration is permitted only for one record family and must
94
- provide deterministic defaults, a strict validator for the exact old shape, and
95
- a fresh-object normalizer into the current model; an `offline-migration`
96
- declaration owns layout, aggregate, identity/reference, record-split, and other
97
- semantic changes and must also have an executable migration step. A transform
98
- without a declaration, a declaration without its required step, a future version,
99
- or structural damage fails closed. Multi-hop is compatible only when every hop
100
- is compatible; one offline hop selects the complete offline path. The production
101
- registry contains the explicit aggregate `16→17` offline transition; no
102
- historical record-family normalization is implicitly authorized. A frozen
103
- post-baseline descriptor snapshot (versions and locators) is checked against the
104
- current descriptor map through the same planner, so a version bump, locator
105
- drift, or new target family cannot ship without its complete declared path.
106
-
107
- The record axis is genuinely independent: `schema.json#/recordVersions` is the
108
- durable per-family source of truth and raw `state.json` is structurally
109
- cross-checked against it before the strict current loader. A target family that
110
- the persisted manifest does not yet name is explicit version `0`; it is usable
111
- only through a declared record-family `0->1` introduction. Absence of records in
112
- `state.json` never promotes that family to current by itself.
113
- `yui doctor`, staged `yui update` preflight, and `yui upgrade` therefore share
114
- four product states:
115
-
116
- - **current** (`USABLE`) — every axis is current.
117
- - **compatible-old** (`COMPATIBLE`) — every older hop is an explicitly declared
118
- record-only normalization; ordinary commands load the current domain model and
119
- the first write emits current records plus the matching current manifest only.
120
- - **migration-required** (`MIGRATABLE`) — at least one declared offline hop has
121
- a complete deterministic step path.
122
- - **unsupported** (`NEEDS_NEW_VERSION` or `CORRUPTED`) — a future version,
123
- missing declaration/step, invalid old shape, or real structural/reference
124
- damage. The result names the incompatible component and reason.
125
-
126
- `yui update` stages and pins the new package side by side, then lets that exact
127
- artifact run an internal path-specific read-only preflight against the target
128
- Home: classification for current, strict compatible-source/current-model
129
- validation for compatible-old, and classification plus authoritative offline
130
- inventory for migration-required. This is deliberately distinct from user-facing
131
- `upgrade --dry-run`: it creates no migration target or staged Home and claims no
132
- staged-output validation, so it remains usable while the exact old Controller is
133
- running. Current and compatible-old Homes
134
- take the fast path: Yui captures and stops the exact old Controller, promotes the
135
- same staged artifact, authenticates and starts the replacement Controller, and
136
- post-verifies through the compatible loader. It does not copy, back up, rename,
137
- or replay the Home and does not wait for Provider Sessions. Existing managed
138
- Task Sessions keep their frozen exact executable/CLI path, Home, control digest,
139
- Task/Run/launch/native-Session fence; replacement never retargets them through
140
- PATH. At that managed continuity gate, package-version drift alone is accepted
141
- because the same path now runs the activated CLI, while protocol, layout,
142
- aggregate, path, Home, digest, and runtime-identity drift still fail closed. The
143
- existing Session can therefore record progress and yield through the replacement
144
- Controller without weakening the offline path's zero-Session requirement.
145
- The first successful new write is the downgrade boundary because it is current-only.
146
-
147
- Migration-required Homes take the offline path. Before binary activation,
148
- Controller stop, admission fence, staging, or Home mutation, Yui re-reads an
149
- authoritative inventory and blocks on active or in-flight Runs, live or unknown
150
- native Sessions, pending turn completion, lifecycle mailboxes, or durable inbox
151
- events. Stopped/history-only Sessions, a Role with no native process, and an open
152
- Input by itself do not block. A blocker reports the total and exact available
153
- Task/Role/Run/native-session/launch identities and reason, leaves the scene
154
- unchanged, and tells the user to re-run `yui update` after the listed work clears;
155
- it never kills, resets, rebinds, retries, or drains on the user's behalf.
156
- After every listed Turn or Run finishes, the user can stop all idle managed
157
- Sessions from a normal shell and retry the update:
158
-
159
- ```sh
160
- yui session stop --all
161
- yui update
162
- ```
163
-
164
- `session stop --all` first checks every current Session and refuses without
165
- stopping anything while any Session still has a running Turn/Run or pending
166
- lifecycle work. Once clear, it fences new Leader dispatch, stops and drains the
167
- Controller, rechecks the runtime facts, then stops every exact idle Session. The
168
- Controller remains stopped so `yui update` can enter its offline window. When the
169
- installed version predates this command, exit every listed managed Session
170
- manually instead; a staged new CLI cannot write the older migration-required Home.
171
-
172
- Only that user re-run may enter the existing full migration. Once its preflight
173
- is clear, the update parent captures and stops the exact old Controller PID. The
174
- staged activation then runs the full migration: it places an admission fence (new
175
- writers, CLI and Controller alike, refuse to start), waits for any writer already
176
- admitted through `.state.lock`, and rechecks the offline inventory before staging,
177
- validation, and switch. It then enters one shared sibling coordination boundary.
178
- Inside it, both the runtime-lifecycle mailboxes AND the durable runtime inbox (`runtime/inbox/*`) are
179
- checked (either non-empty blocks at `drain-incomplete`, so authoritative
180
- not-yet-applied events are never dropped by a switch), followed by the revision
181
- pin, complete-home copy, validation, and two-step switch.
182
- The boundary is `<home>.upgrade-coordination.lock`, outside the Home so renames
183
- cannot move a live lock. Inbox `publish` takes that same lock, checks the fence
184
- and any unresolved switch-progress marker while holding it, writes the temp/link/
185
- fsync event, and releases it. Upgrade takes the lock after the Controller drain,
186
- proves both runtime lanes, re-pins the revision under `.state.lock`, copies the
187
- complete Home, and keeps the coordination lock through `home -> backup` and
188
- `staging -> home`. Thus a hook admitted before the fence either finishes before
189
- the final snapshot (and its event is copied) or waits and receives an explicit
190
- `UpgradeFenceError` after cutover; it can safely re-deliver and is never silently
191
- stranded only in the backup. With no fence, the normal hook path keeps the same
192
- durable behavior, only serialized at this boundary. **Fence acquisition is a
193
- single atomic file create**, so two concurrent upgraders never both acquire —
194
- exactly one wins and the other fails closed. A provably-dead owner's stale fence
195
- is reclaimed, but the reclaim is an **atomic compare-and-delete** (it removes only
196
- the exact stale bytes, under a lock), so a fresh live fence a racer created in the
197
- meantime is never clobbered — two entrants can never both end up "acquired". That
198
- reclaim lock is itself **crash-recoverable** (owner-pid + age reclaim), so a
199
- holder that crashes mid-reclaim cannot orphan it and permanently block admission;
200
- when a reclaim cannot be proven complete the writer fails closed rather than
201
- falsely reporting the home writable. The coordination lock uses the same bounded
202
- crash-recovery rule: it records an owner PID, waits only for a bounded interval,
203
- and atomically renames aside a lock whose owner is provably dead (or whose
204
- owner-less directory is older than the conservative acquisition window). A live
205
- or undeterminable holder fails closed, so a crash cannot deadlock the Home and a
206
- live writer is never evicted by a TTL. A switch-progress marker blocks hook
207
- admission when the Home is missing or uninitialized (including a malformed
208
- marker, because its recovery phase is unknowable); a stale marker beside an
209
- intact Home is ignored just as the update probe ignores it after corroborating
210
- the filesystem. The lock order is one-way — coordination
211
- lock, then `.state.lock`; inbox writers never acquire `.state.lock` — so no
212
- coordination cycle is introduced. An **uninitialized home** (never `yui setup`)
213
- returns a structured "run `yui setup`" blocker rather than a silent no-op. Quiesce
214
- **fails closed on any undeterminable signal**: a `.state.lock` that exists but
215
- whose owner is missing/empty/non-integer/unreadable (a writer may be
216
- mid-acquisition), or a malformed `runtime/controller.json`, is treated as an
217
- active runtime and blocks the upgrade; only a provably-absent lock or a
218
- clearly-dead owner is safe to proceed past.
219
-
220
- The migration only transforms `schema.json` + `state.json`, but because the
221
- atomic switch replaces the whole home directory, **staging carries a complete
222
- copy of the home** — `runtime/`, `runtime/inbox/*` (authoritative), `cache/`, and
223
- `artifacts/` are all preserved through the switch and retained in the backup, with
224
- no silent loss (the transient `.state.lock` is the sole exception; a real home
225
- entry that happens to share the staging directory's name is preserved too, and an
226
- in-home staging layout is refused outright). The switch is two renames with one
227
- non-atomic window, and **every** step after the first rename — the fsyncs and the
228
- progress-marker writes, not just the rename — is phase-aware: a failure first
229
- attempts an automatic rollback, and only if that rollback **also** fails is the
230
- home reported as partially switched (a distinct `switch-ambiguous` blocker with
231
- the exact `mv "<backup>" "<home>"` recovery) — it never falsely claims the home is
232
- unchanged. A crash mid-switch leaves a durable marker; `yui update` recovery reads
233
- that marker plus filesystem evidence (backup present, home missing) to name the
234
- exact backup restore rather than a generic retry. Any other failed or blocked step
235
- leaves the authoritative home byte-for-byte unchanged and reports the exact
236
- blocker stage and recovery action. Only explicitly registered adjacent steps
237
- can convert a real home; Yui never dual-reads an older schema or guesses an old
238
- identifier. Compatible loading remains an explicit normalization contract, not
239
- a permissive old-schema reader. See
240
- [Task-local identity](docs/task-local-identity.md) for the current reference
92
+ Yui records layout, aggregate, and per-record-family versions in `schema.json`,
93
+ but runtime admission has only two outcomes: exact current, or rejected. A
94
+ missing, older, newer, or malformed contract is never converted by the running
95
+ release. `yui doctor` and `yui upgrade [--dry-run]` are read-only diagnostics;
96
+ `yui upgrade` does not stage, repair, back up, or switch a Home.
97
+
98
+ `yui update` stages and pins one exact package, runs that staged binary's
99
+ current-contract preflight, stops the exact old Controller, activates the same
100
+ artifact, verifies the installed binary and current Home, and starts the
101
+ replacement Controller. Storage is not copied or migrated. If the staged
102
+ release cannot open the Home exactly, the update stops before activation and
103
+ leaves both the Home and current installation unchanged.
104
+
105
+ To retain an old Home, keep it byte-for-byte and open it only with its original
106
+ Yui version for read-only inspection. For unfinished work, initialize a new
107
+ Home and let the Operator create a new Task from the old Task's objective,
108
+ relevant WorkItems, current repository state, and available result summaries.
109
+ The Operator creates new identities; it does not import old runtime/session
110
+ state or pretend that the old Task continued.
111
+
112
+ See [Task-local identity](docs/task-local-identity.md) for the current reference
241
113
  contract.
242
114
 
243
115
  Schema work across Tasks is not serialized: any Task may advance a version axis
@@ -340,7 +212,7 @@ before the swap leaves only a removable staging clone).
340
212
 
341
213
  `project retire` is the auditable soft deprecation: it records who retired the Project, when, and
342
214
  why, while retaining the catalog record, checkout, and every historical
343
- Task/Run/Review/Integration/Publication reference. A retired Project cannot be refreshed,
215
+ Task/Turn/Review/Integration/Publication reference. A retired Project cannot be refreshed,
344
216
  updated, migrated, reset, replaced, maintained through Knowledge writes (add/retire/propose/
345
217
  accept/reject), or bound to new Tasks, WorkItems, or Integrations; Knowledge reads (`list`,
346
218
  `show`, `proposals list/show`) stay open so the evidence stays auditable.
@@ -352,7 +224,7 @@ then moves the checkout to a tombstone before removing the catalog record, resto
352
224
  failure so the catalog and checkout never disagree unrecoverably. `project show` and
353
225
  `project list` display the lifecycle status and retirement record.
354
226
 
355
- Use `task context` as the first detailed read of an existing Task. It combines the Task, Brief, active Decisions, recent Milestones, Roles, current and recent WorkItems with their Runs, recent Messages, open and resolved InputRequests, and recent Events. Terminal output keeps histories and long text compact; `yui --json task context <task-id>` returns the complete records in the top-level `data` field.
227
+ Use `task context` as the first detailed read of an existing Task. It combines the Task, Brief, active Decisions, recent Milestones, Roles, current and recent WorkItems with their Turns, recent Messages, open and resolved InputRequests, and recent Events. Terminal output keeps histories and long text compact; `yui --json task context <task-id>` returns the complete records in the top-level `data` field.
356
228
 
357
229
  Leader wakeups stay deliberately small: the wake envelope carries only the
358
230
  aggregated wake reasons, a delta window, and read pointers. The durable wake
@@ -364,8 +236,8 @@ yui task wake show <task-id> <wake-id>
364
236
  ```
365
237
 
366
238
  `wake list` shows the dispatch history with status, reasons, and consuming
367
- Run; `wake show` renders one wake's delta window — the Events, Messages, and
368
- Runs recorded between its cursors. A human or Agent can still force a wake
239
+ Turn; `wake show` renders one wake's delta window — the Events, Messages, and
240
+ Turns recorded between its cursors. A human or Agent can still force a wake
369
241
  with `yui task wake <task-id> --force --reason "<text>"`.
370
242
 
371
243
  Human-facing timestamps default to Beijing time (`Asia/Shanghai`) while durable
@@ -398,7 +270,7 @@ Every result entering Leader acceptance is one explicit candidate on its
398
270
  existing WorkItem. The current global rule applies to the next candidate in
399
271
  every existing or new Task; that candidate snapshots the rule, so later
400
272
  `set`/`clear` changes do not rewrite an in-flight decision.
401
- `always` starts a ReviewRound for every candidate, including a yielded Role Run
273
+ `always` starts a ReviewRound for every candidate, including a completed Role Turn
402
274
  or a Leader-managed direct result; `leader` leaves the candidate awaiting
403
275
  acceptance so the Leader can accept it directly or run
404
276
  `yui task work review <task-id>/<work-item-id>`. A configured review rule therefore keeps
@@ -409,12 +281,12 @@ contract requires one. The Round snapshots the exact Task-main Project heads
409
281
  directly, so even a Leader-owned Task with no WorkItem can be reviewed without
410
282
  locking the mutable Task workspace. A changed frozen head needs a new semantic
411
283
  Round; the same Reviewer Session continues in its
412
- stable workspace, while every Run remains bound to its exact Round and head.
284
+ stable workspace, while every Turn remains bound to its exact Round and head.
413
285
  The Reviewer follows Project Policy/Knowledge and reports reachable, material,
414
286
  actionable findings across the complete Task.
415
287
  A ReviewRound freezes the Candidate's exact Git commit and updates the
416
288
  Reviewer Role's stable writable workspace to that head while recording exact
417
- Round-owned workspace evidence. Its AgentRun may edit,
289
+ Round-owned workspace evidence. Its Turn may edit,
418
290
  test, and optionally commit diagnostic evidence there, but never changes the
419
291
  Candidate or Worker workspace and never creates another WorkItem, Candidate,
420
292
  ChangeSet, or recursive review. The result wakes the Leader, who decides whether
@@ -423,7 +295,7 @@ Worker in its existing Session, review again, or request user input.
423
295
  A failed review remains visible evidence and wakes the Leader, but does not
424
296
  take that decision away from the Leader.
425
297
  Task context and next-action expose direct Review facts: every frozen Project
426
- commit, its relation to the current candidate, the active Run, and the Reviewer
298
+ commit, its relation to the current candidate, the active Turn, and the Reviewer
427
299
  workspace. A request that fails after Round creation retains the ReviewRound
428
300
  and reports its exact reason; the Leader opens that Round and decides whether
429
301
  to retry, inspect or clean the workspace, use another Reviewer, or continue
@@ -442,8 +314,8 @@ Yui Core supplies lifecycle and exact-scope safety; generic role Skills supply
442
314
  portable collaboration behavior; Project Policy/Knowledge supplies
443
315
  project-specific build, test, migration, release, and review rules; the Task
444
316
  Contract supplies the current objective and acceptance. Project-backed Workers
445
- commit and leave the Develop workspace clean before
446
- yielding a Candidate. Yui freezes each writable Project's HEAD in the Candidate
317
+ commit and leave the Develop workspace clean before ending the Provider Turn.
318
+ Yui stores the final Turn result and freezes each writable Project's HEAD in the Candidate
447
319
  snapshot; ReviewRound worktrees are recreated from those exact commits even if
448
320
  Develop later advances during repair.
449
321
 
@@ -515,7 +387,7 @@ The delivery chain is `isolate -> Candidate -> ReviewRound -> ChangeSet capture
515
387
  Candidate commit and never become a Develop ChangeSet source.
516
388
 
517
389
  Write scope may only expand. The Leader supplies the complete old-plus-new set
518
- after a Worker yields and reports that another repository is required; an
390
+ after a Worker reports that another repository is required; an
519
391
  existing writable Project cannot be removed:
520
392
 
521
393
  ```sh
@@ -566,7 +438,7 @@ yui task execution stop <task-id> --force --reason "<why execution must be fence
566
438
  yui task execution start <task-id>
567
439
  ```
568
440
 
569
- `stop` terminates disposable Runs and Sessions while preserving WorkItems,
441
+ `stop` terminates disposable Turns and Sessions while preserving WorkItems,
570
442
  repository changes, Messages, reviews, and other Task progress. `start` admits
571
443
  one new Leader attempt from those durable records; it does not recover an old
572
444
  Agent conversation.
@@ -666,50 +538,39 @@ set. Codex options are `sandbox` and `approval`; Claude options are `mode`,
666
538
  `allowedTools`, and `disallowedTools`. Provider permission is independent from
667
539
  Profile behavior and Project write authority: only an exact WorkItem scope and
668
540
  matching managed workspace grant normal Project writes. A ReviewRound is the only non-WorkItem write
669
- purpose and must match its Run, reviewRoundId, frozen base, and
541
+ purpose and must match its Turn, reviewRoundId, frozen base, and
670
542
  ReviewRound-owned workspace; every mismatch fails closed. Its diagnostic commit
671
543
  is visible history but is
672
544
  explicitly rejected by capture, ChangeSet, Integration, and acceptance paths.
673
- Review yield keeps the same exact `--summary-file -` command, but its stdin is
674
- the Reviewer's complete free-form Markdown or JSON report. If a JSON report
545
+ The Reviewer's final Provider response is its complete free-form Markdown or
546
+ JSON report. If a JSON report
675
547
  includes known `checks` or `evidenceCommit` fields, Yui records them as
676
548
  structured evidence and verifies the reported commit against the managed
677
549
  Review branch HEAD; unknown fields remain part of the report. Dirty uncommitted
678
- diagnosis may yield without a commit; the worktree is retained and cleanup
550
+ diagnosis may end without a commit; the worktree is retained and cleanup
679
551
  refuses it until it is clean.
680
552
 
681
553
  Every Role desired launch change increments its revision and applies only to a
682
- future launch. Each AgentRun and native Role Session stores the complete actual
554
+ future launch. Each Turn and native Role Session stores the complete actual
683
555
  agent, adapter, model, effort, Profile access intent, exact writable Projects,
684
556
  permission strategy and native options, workspace, context, and source desired revision. Updating,
685
557
  switching, or clearing Role overrides never
686
- hot-mutates an existing process. `task context`, Role views, Run history,
558
+ hot-mutates an existing process. `task context`, Role views, Turn history,
687
559
  Events, and Web show desired/effective revisions, Profile intent, permission, and
688
560
  pending next-launch drift.
689
561
 
690
- Both Codex and Claude deliver a managed Run only through its exact injected
691
- stdin-yield command. A final assistant message alone is not a durable handoff;
692
- permission denial, a missing or wrong Run yield, and StopFailure fail closed.
693
-
694
- The Worker delivers its current Run explicitly:
695
-
696
- ```sh
697
- yui task run yield <task-id>/<run-id> --summary-file - <<'YUI_SUMMARY'
698
- Implemented the exporter; focused tests pass
699
- YUI_SUMMARY
700
- ```
701
-
702
- Yield completes the AgentRun, submits the WorkItem for Leader review, appends
703
- the result message, and queues the Leader. It does not accept the WorkItem. A
704
- Leader never wakes itself; any pending Operator or Worker wake remains durable
705
- until the Leader is idle.
562
+ Both Codex and Claude deliver a managed Turn through the Provider's native Turn
563
+ terminal. Yui stores the final assistant response as the exact Turn result,
564
+ submits the WorkItem for Leader review, and queues the Leader. It does not
565
+ accept the WorkItem. A Leader never wakes itself; any pending Operator or Worker
566
+ wake remains durable until the Leader is idle.
706
567
 
707
568
  If the outcome cannot be determined, label the handoff `uncertain`,
708
569
  `incomplete`, `blocked`, or `requiring Leader judgment` and submit the most
709
570
  complete truthful identities, actions, repository state, checks and errors,
710
571
  lifecycle boundary, unfinished work, open decisions, risks, confidence, and
711
- bounded next options. Yield records immutable Run/Candidate or Review evidence
712
- only; it does not imply acceptance, WorkItem completion, ChangeSet capture,
572
+ bounded next options. The Turn result is immutable execution evidence only; it
573
+ does not imply acceptance, WorkItem completion, ChangeSet capture,
713
574
  Integration, or Task completion.
714
575
 
715
576
  For one substantial feature requirement, the Leader may create a WorkItem and
@@ -742,10 +603,10 @@ yui task work update <task-id>/<work-item-id> done \
742
603
  Use `inherited` or `unknown` when the native runtime does not expose an actual
743
604
  model or effort; do not guess. The three supported paths remain deliberately
744
605
  small: Leader direct execution, a conversation-native subagent, or a Task Role
745
- AgentRun when work needs its own provider, credentials, interaction, or durable
606
+ Turn when work needs its own provider, credentials, interaction, or durable
746
607
  Session.
747
608
 
748
- For an isolated Task Role result, the Leader first reviews the yielded result.
609
+ For an isolated Task Role result, the Leader first reviews the stored Turn result.
749
610
  An insufficient result is rejected with feedback and redispatched in the same
750
611
  workspace. An acceptable result is captured and integrated in a candidate
751
612
  worktree. Checks run there, and the target advances only if its recorded HEAD
@@ -768,7 +629,7 @@ yui task integration resolve <task-id>/<integration-id> \
768
629
  yui task integration continue <task-id>/<integration-id>
769
630
  ```
770
631
 
771
- Worker yield is not WorkItem completion. The Leader accepts only after reviewing
632
+ Worker Turn completion is not WorkItem completion. The Leader accepts only after reviewing
772
633
  the result, validations, and the latest ChangeSet integration:
773
634
 
774
635
  ```sh
@@ -785,25 +646,25 @@ operational projections without deleting their audit records:
785
646
 
786
647
  ```sh
787
648
  yui task message retire <task>/<message> --reason "Superseded instruction"
788
- yui task run retire <task>/<agent-run> --reason "Invalid launch record"
649
+ yui task turn retire <task>/<turn> --reason "Invalid launch record"
789
650
  ```
790
651
 
791
652
  These commands append a retirement fact. Lists and audit views retain the
792
- original Message, WorkItem, or AgentRun and mark it retired; managed Run context,
653
+ original Message, WorkItem, or Turn and mark it retired; managed Turn context,
793
654
  actionability, recovery, review evidence, and scheduling ignore it. Retiring
794
- an active AgentRun first terminalizes that exact Run, and retirement is
795
- idempotent. Only the user or global Operator may retire Messages or AgentRuns;
655
+ an active Turn first terminalizes that exact Turn, and retirement is
656
+ idempotent. Only the user or global Operator may retire Messages or Turns;
796
657
  WorkItems may also be retired by their Task Leader.
797
658
 
798
659
  For long-running Tasks, the Leader keeps Yui—not a native transcript—as the
799
660
  recovery authority. The Task Brief owns the overall technical approach,
800
661
  including how coordinated Project changes fit together. WorkItems own the
801
662
  executable per-Project modifications and acceptance checks. The Leader updates
802
- Brief focus and Leader summary before every yield, records material choices as
663
+ Brief focus and Leader summary before ending each Provider Turn, records material choices as
803
664
  Decisions, adds phase outcomes as Milestones, and promotes only cross-Task
804
665
  stable facts to Project Knowledge.
805
666
 
806
- When an active Leader Run cannot continue without a user decision, it can create a durable InputRequest and yield its Run:
667
+ When an active Leader Turn cannot continue without a user decision, it creates a durable InputRequest and ends its Provider Turn with a truthful blocked result:
807
668
 
808
669
  ```sh
809
670
  yui task input request <task-id> --question "Which format should be the default?" \
@@ -831,7 +692,7 @@ Inspect the result:
831
692
  yui task context <task-id>
832
693
  ```
833
694
 
834
- Use the narrower `task work`, `task message`, `task run`, and Task Knowledge commands when you need one collection or record.
695
+ Use the narrower `task work`, `task message`, `task turn`, and Task Knowledge commands when you need one collection or record.
835
696
 
836
697
  When the requested outcome is finished, complete the Task to stop automatic Leader wakes without deleting its sessions or Task main worktree:
837
698
 
@@ -866,7 +727,7 @@ audit records the authorization and, on completion, the accepted Project,
866
727
  Publication, optional ReviewRound, both commits, and tree.
867
728
 
868
729
  Completed Tasks reject messages, dispatch, Provider authority changes, retry,
869
- and late yields until explicitly reopened, while retaining Task main for
730
+ and late Turn delivery until explicitly reopened, while retaining Task main for
870
731
  inspection or integration. Terminal WorkItem, Review, Integration, and Lane
871
732
  worktrees are non-blocking completion advisories, but they must be settled
872
733
  before archive. Every isolated WorkItem worktree is explicitly cleaned as
@@ -891,7 +752,7 @@ Yui's Agent Host and proxy while leaving the daemon and thread untouched; start
891
752
  creates a fresh proxy attachment.
892
753
  If the proxy disconnects, the Host may attach a bounded replacement client and
893
754
  reconcile the exact owned Turn from native history. A failed fresh attachment
894
- is released instead of becoming a cleanup prerequisite for later Runs.
755
+ is released instead of becoming a cleanup prerequisite for later Turns.
895
756
  Claude Code keeps its independent stream-json process. Agent Host is the sole
896
757
  writer to that process, so a completed stream write accepts the Turn; the
897
758
  later provider `result` event settles it. An uncertain write becomes
@@ -908,16 +769,17 @@ yui task role release <task-id> <role>
908
769
  For an independently hosted Provider such as Claude, these commands are the
909
770
  supported human-control boundary. A Codex Role uses an ordinary shared thread
910
771
  and may be operated directly in Desktop; an active Desktop Turn creates bounded
911
- backpressure for Yui rather than a failed Run.
912
-
913
- AgentRun is the only durable Role scheduling state. Conversation state does not
914
- carry a second current-Run pointer; each Provider Turn records a Run id only to
915
- correlate its receipt and terminal event. If an Agent finishes a Yui Run before
916
- the native Turn terminal arrives, the next mailbox intent remains pending until
917
- that Turn settles. Yui then claims the new AgentRun and submits it through the
918
- same Session. TaskRole itself stores identity and desired launch configuration,
919
- not runtime status; Role status shown by CLI/Web is derived from the active
920
- AgentRun plus Session/Driver lifecycle facts.
772
+ backpressure for Yui rather than a failed Turn.
773
+
774
+ Turn is the only durable Role scheduling state. Conversation state does not
775
+ carry a second current-Turn pointer. A Yui-dispatched Provider Turn carries the
776
+ durable Turn id that correlates its visible input and terminal result; a direct
777
+ Provider Turn is recorded as direct conversation history without entering the
778
+ scheduling pointer. A native Turn terminal completes that Turn, after which Yui
779
+ may claim the next Turn and submit it through the same Session.
780
+ TaskRole itself stores identity and desired launch configuration, not runtime
781
+ status; Role status shown by CLI/Web is derived from the active Turn plus
782
+ Session/Driver lifecycle facts.
921
783
 
922
784
  Global Operator and global Role sessions remain native interactive CLIs:
923
785
 
@@ -925,12 +787,10 @@ Global Operator and global Role sessions remain native interactive CLIs:
925
787
  yui session enter <global-role>
926
788
  ```
927
789
 
928
- An offline Home migration requires a short maintenance window with no managed
929
- Agent Session running. Once current Turns and Runs have finished, use
930
- `yui session stop --all` from a normal shell. The command stops Task and global
931
- Role Sessions only after every one is idle, and leaves all Sessions untouched
932
- when any Role is still busy. On success it also leaves the Controller stopped;
933
- run `yui update` next rather than resuming ordinary Task work.
790
+ `yui update` accepts only the current Home contract and never migrates storage.
791
+ For an older Home, keep its Sessions stopped, inspect it with the original Yui
792
+ version, and let the current Operator recreate unfinished intent as new Tasks in
793
+ a newly initialized Home. Runtime ids and mailbox state are not copied.
934
794
 
935
795
  tmux fixes a pane's history capacity when that pane is created. Existing panes
936
796
  retain their configured capacity; managed runtime output remains observable in
@@ -948,20 +808,20 @@ cross-Agent switch, the saved model and effort are reused unless the user
948
808
  explicitly chooses to update them.
949
809
 
950
810
  The Role's active binding is desired state for the next compatible launch. A
951
- running AgentRun and its native Session continue under their immutable
811
+ running Turn and its native Session continue under their immutable
952
812
  effective snapshot even if the Role is edited or switched. Resume is allowed
953
813
  only when the complete effective snapshot and workspace remain compatible;
954
814
  otherwise Yui starts a new Session after the old process has stopped and keeps
955
815
  the terminal Session's immutable effective snapshot in history. Managed
956
816
  Sessions invoke the ordinary `yui` command; their Manifest and durable
957
- Role/Run fences authenticate scope while protocol and storage compatibility
817
+ Role/Turn fences authenticate scope while protocol and storage compatibility
958
818
  allow a CLI package or Controller upgrade in place. Exact internal callbacks
959
819
  remain fenced to their originating runtime snapshot.
960
820
 
961
821
  Use `yui config role unbind <global-role> <agent-id>` or `yui task role unbind <task-id> <role> <agent-id>` to retire a dormant binding. The active binding and any non-stopped native session are rejected; a stopped session record is removed atomically with the binding.
962
822
 
963
823
  Claude session IDs are preallocated at launch. Codex discovers its native
964
- thread identity from App Server responses. Managed Task Runs use structured
824
+ thread identity from App Server responses. Managed Task Turns use structured
965
825
  Provider observations for both CLIs. Global interactive Codex sessions may
966
826
  still use its `notify` callback for conversation presentation.
967
827
 
@@ -972,7 +832,7 @@ parses prompt glyphs, progress text, trust dialogs, or other Agent terminal
972
832
  output to infer readiness or success. `captureRole()` remains an explicit
973
833
  human-facing transcript read and has no lifecycle authority.
974
834
 
975
- The [Agent Runtime Driver architecture](docs/agent-runtime-drivers.md) keeps
835
+ The [AgentRuntime Driver architecture](docs/agent-runtime-drivers.md) keeps
976
836
  native Codex/Claude event names at the edge. Core consumes exact-fenced
977
837
  Session, Turn, operation, waiting, host, and activity observations. A positive
978
838
  token delta is evidence of recent runtime activity; an unchanged counter is
@@ -980,9 +840,9 @@ not. A live tmux pane proves only that the host exists. Runtime activity and
980
840
  durable workflow progress use independent clocks, so token/tool/resource
981
841
  movement cannot conceal a workflow that is not advancing.
982
842
 
983
- Stable Role context never creates a separate bootstrap Turn. Task execution Runs use the generic Leader or Worker Skill, while review Runs use the generic Reviewer Skill based on durable Run purpose rather than a configured Role name. The provider either carries the Skill through a safe additive native context channel or points to it from the ordinary Task delivery. These Yui-owned Role Skills define portable orchestration only. Project Skills remain ordinary versioned files in the Project and are discovered, selected, and loaded by the Agent through its native project mechanism; Yui does not scan, parse, copy, or inject them.
843
+ Stable Role context never creates a separate bootstrap Turn. Task execution Turns use the generic Leader or Worker Skill, while review Turns use the generic Reviewer Skill based on durable Turn purpose rather than a configured Role name. The provider either carries the Skill through a safe additive native context channel or points to it from the ordinary Task delivery. These Yui-owned Role Skills define portable orchestration only. Project Skills remain ordinary versioned files in the Project and are discovered, selected, and loaded by the Agent through its native project mechanism; Yui does not scan, parse, copy, or inject them.
984
844
 
985
- Managed Codex keeps the user's native developer instructions unchanged. The ordinary Task message includes a compact absolute Session Manifest pointer, and the manifest identifies the matching Yui-owned Role Skill for Codex to read on demand. Model, effort, permission, workspace, and shell settings are supplied to `thread/start` or `thread/resume` through the shared App Server daemon; a Codex native config profile is rejected because it cannot be isolated to one shared-daemon thread. The underlying Codex config file is never mutated. App Server notifications are the managed thread's lifecycle authority; Yui installs no managed Codex Hook and does not claim `notify`. Interactive Codex Sessions may still use Yui's structured `notify` callback, and Doctor reports any effective configuration conflict. `skills.config` is not misused because it only enables or disables already-discovered Skills. Claude receives the same Yui-owned Role Skill content from a private `0600` managed context file rather than a large or sensitive argv value; retries and resumes reuse the purpose-specific Role path. Non-Operator global Roles stay neutral and receive no Task orchestration Skill. Operator therefore opens at an empty native composer, so the user's text remains its first user message. Leader wakeups and Worker or Reviewer Run assignments remain real mailbox-delivered work messages.
845
+ Managed Codex keeps the user's native developer instructions unchanged. The ordinary Task message includes a compact absolute Session Manifest pointer, and the manifest identifies the matching Yui-owned Role Skill for Codex to read on demand. Model, effort, permission, workspace, and shell settings are supplied to `thread/start` or `thread/resume` through the shared App Server daemon; a Codex native config profile is rejected because it cannot be isolated to one shared-daemon thread. The underlying Codex config file is never mutated. App Server notifications are the managed thread's lifecycle authority; Yui installs no managed Codex Hook and does not claim `notify`. Interactive Codex Sessions may still use Yui's structured `notify` callback, and Doctor reports any effective configuration conflict. `skills.config` is not misused because it only enables or disables already-discovered Skills. Claude receives the same Yui-owned Role Skill content from a private `0600` managed context file rather than a large or sensitive argv value; retries and resumes reuse the purpose-specific Role path. Non-Operator global Roles stay neutral and receive no Task orchestration Skill. Operator therefore opens at an empty native composer, so the user's text remains its first user message. Leader wakeups and Worker or Reviewer Turn assignments remain real mailbox-delivered work messages.
986
846
 
987
847
  ## Controller and failure handling
988
848
 
@@ -1018,31 +878,31 @@ Read-only commands and `upgrade --dry-run` do not start a Controller. `update`
1018
878
  also replaces an already-running Controller only after the new binary passes its
1019
879
  health checks.
1020
880
 
1021
- Its recovery reconciliation runs every 120 seconds by default. Normal durable state changes enqueue a Task, Role, or Operator key and return immediately; keys received in the same fixed 100 ms window trigger one non-overlapping targeted pass. Operator presentation has an independent lane, so a blocked Task workspace operation cannot delay a user question. Periodic Git/worktree work is limited to Tasks with durable Task-mailbox work, while active Role liveness uses one tmux inventory. Structured Agent Driver observations, whether received from native provider events or supported Hooks, are exact-fenced before they reach the durable runtime inbox. A terminal Turn observation gives a legal yield/input/completion two seconds to win before a forgotten Run fails its workflow contract. Durable mailboxes freeze the current batch while new signals merge into the next batch. Task-orchestration failures retain the exact Controller-owned processing batch for two bounded fast retries and later periodic recovery; a successful retry completes that batch before newer pending work is claimed. Recommended InputRequest and pending Turn deadlines share one nearest-deadline selector and therefore do not wait for the recovery interval. Explicit `task reconcile` still requests an immediate recovery pass. The retained loop is:
881
+ Its recovery reconciliation runs every 120 seconds by default. Normal durable state changes enqueue a Task, Role, or Operator key and return immediately; keys received in the same fixed 100 ms window trigger one non-overlapping targeted pass. Operator presentation has an independent lane, so a blocked Task workspace operation cannot delay a user question. Periodic Git/worktree work is limited to Tasks with durable Task-mailbox work, while active Role liveness uses one tmux inventory. Structured Agent Driver observations, whether received from native provider events or supported Hooks, are exact-fenced before they reach the durable runtime inbox. A terminal Turn observation atomically records the exact Turn result. Durable mailboxes freeze the current batch while new signals merge into the next batch. Task-orchestration failures retain the exact Controller-owned processing batch for two bounded fast retries and later periodic recovery; a successful retry completes that batch before newer pending work is claimed. Recommended InputRequest and pending Turn deadlines share one nearest-deadline selector and therefore do not wait for the recovery interval. Explicit `task reconcile` still requests an immediate recovery pass. The retained loop is:
1022
882
 
1023
883
  1. dispatch pending Leader wakes whose Task workspaces are already ready;
1024
884
  2. prepare active Project Task main worktrees with durable orchestration work;
1025
- 3. deliver queued Worker Runs;
885
+ 3. deliver queued Worker Turns;
1026
886
  4. resolve due Turn completions and reconcile Role liveness;
1027
887
  5. dispatch Leader work created or unblocked by the later recovery phases.
1028
888
 
1029
- Automated input is sent only through tmux. Each pass performs one non-blocking process-state readiness check; a busy startup is retried through a small bounded mailbox timer, while later busy sessions are woken by canonical Agent Driver terminal observations. A pane-local receipt prevents the same Run from being typed twice after a Controller retry.
889
+ Automated input is sent only through tmux. Each pass performs one non-blocking process-state readiness check; a busy startup is retried through a small bounded mailbox timer, while later busy sessions are woken by canonical Agent Driver terminal observations. A pane-local receipt prevents the same Turn input from being typed twice after a Controller retry.
1030
890
 
1031
- If a Role process exits before yielding, the Controller fails that Run and running WorkItem and queues the Leader. Recovery failures are exposed through the small compatibility Jobs view:
891
+ If a Role process exits without a terminal Provider result, the Controller fails that Turn and running WorkItem and queues the Leader. Recovery failures are exposed through the small Jobs view:
1032
892
 
1033
893
  ```sh
1034
894
  yui jobs list
1035
895
  yui jobs retry leader-recovery:<task-id>
1036
896
  yui task reconcile <task-id>
1037
- yui task run retry <failed-run-id>
1038
- yui task run settle <obsolete-failed-review-run-id>
897
+ yui task turn retry <failed-turn-id>
898
+ yui task turn settle <obsolete-failed-review-turn-id>
1039
899
  ```
1040
900
 
1041
901
  `jobs` is not a restored generic queue: it presents durable pending Leader wakes and Leader recovery failures only.
1042
902
 
1043
- `task run settle` is a Leader-only repair for one exact failed Reviewer Run whose
903
+ `task turn settle` is a Leader-only repair for one exact failed Reviewer Turn whose
1044
904
  matching Task-final ReviewRound was stranded running by an older lifecycle. It
1045
- closes only an obsolete frozen candidate, preserves the Run, Round, workspace,
905
+ closes only an obsolete frozen candidate, preserves the Turn, Round, workspace,
1046
906
  and evidence, and never creates a retry Round.
1047
907
 
1048
908
  Completion is the reversible execution fence. Archiving is terminal and is accepted only after active work is settled: it stops the Task's tmux session and removes clean managed worktrees. Dirty worktrees keep the Task completed and are preserved for deliberate resolution.
@@ -1058,7 +918,7 @@ yui web
1058
918
 
1059
919
  Use `--port <port>` or `--host 127.0.0.1|::1|localhost` to change the
1060
920
  listener. Yui rejects non-loopback hosts because the control room exposes Task
1061
- metadata, Briefs, Roles, WorkItems, Runs, messages, Decisions, Milestones, and
921
+ metadata, Briefs, Roles, WorkItems, Turns, messages, Decisions, Milestones, and
1062
922
  InputRequests. A random token embedded in the served page protects its write
1063
923
  and terminal endpoints.
1064
924
 
@@ -1076,12 +936,12 @@ question and urgency so you can answer without drilling in, and the list of
1076
936
  currently active tasks. Each task row carries a derived execution status
1077
937
  (progressing, needs attention, blocked, recovering) so stalled or failed
1078
938
  work is visible before you open a task. Selecting a task opens an anchored
1079
- detail view (Summary, Focus, Work items, Runs, Roles, History, Messages)
939
+ detail view (Summary, Focus, Work items, Turns, Roles, History, Messages)
1080
940
  with a sticky tab bar that tracks the visible section. The Summary tab leads
1081
941
  with an execution band that consolidates the Task's owner, current action,
1082
942
  attention list, blockers, and fail-closed indicators; Work items surface
1083
943
  their current ExecutionGroup with per-lane status, Candidates, and
1084
- retirement disposition; Runs show purpose, execution lineage, yield receipt,
944
+ retirement disposition; Turns show purpose, execution lineage, final result,
1085
945
  and Leader disposition.
1086
946
 
1087
947
  The control room supports English and Simplified Chinese, selecting an initial locale from the browser and remembering manual changes. The theme selector switches between the dark Control Room, the light Paper Ledger, and the dark-blue Atlas themes. Both choices are stored only in browser `localStorage`; they do not modify `YUI_HOME`.
@@ -1103,63 +963,16 @@ yui project add|clone|refresh|update|discover|list|show|knowledge
1103
963
  yui project reset|replace|retire|delete
1104
964
  ```
1105
965
 
1106
- `yui update` stages the newly published package **side by side** it never
1107
- replaces the current global install first then uses the staged binary to run an
1108
- internal path-specific read-only preflight against the Home. It classifies current
1109
- Homes, validates compatible-old sources into the current model in memory, and
1110
- checks the authoritative offline inventory for migration-required Homes. This
1111
- preflight does not create or validate a staged Home and is not
1112
- `upgrade --dry-run`; a full stage/validation/switch occurs only after the parent
1113
- stops the exact old Controller PID. Current and compatible-old Homes use the
1114
- no-Home-mutation fast path; migration-required Homes first require a clear
1115
- offline Run/Session/lifecycle inventory, then use the timestamped-backup switch.
1116
- Both paths run a new-binary health check before the authenticated Controller
1117
- handoff. When an old Controller exists, it is stopped with an exact PID fence;
1118
- when no old Controller existed, the same verified new Controller is started
1119
- before the update reports success.
1120
- Yui promotes the **same artifact it staged**
1121
- (binary activation pins the exact staged version, never a second bare `@latest`);
1122
- the staged version must be a **concrete semver** — a `latest`/dist-tag sentinel,
1123
- a malformed value, or a probe without a valid `{ ok:true }` envelope at exit 0 is
1124
- rejected and the stage **fails** rather than falling back to `@latest`. The health
1125
- check runs the **actually-activated** global binary and **requires** its version
1126
- to be concrete and equal to the staged one — a missing, unparseable, or mismatched
1127
- version fails closed (never skipped). Every spawned-child result must be a valid
1128
- `{ ok:true, data }` **success envelope** before its outcome is trusted (else
1129
- preflight blocks / activation is ambiguous), and a success-class outcome is
1130
- trusted **only when the process also exited 0**. The post-update health check
1131
- **parses and validates the machine-readable `yui --json doctor` envelope before
1132
- interpreting the exit status** — because `--json doctor` exits non-zero on
1133
- unhealthy storage — requires **every** expected storage check present-and-`ok`
1134
- (a missing/duplicated/malformed check fails closed), and rejects an unparseable or
1135
- self-contradictory envelope; only a valid success envelope with all storage checks
1136
- `ok` and exit 0 is healthy. On any failure it reports the exact phase and a
1137
- recovery action.
1138
-
1139
- On the offline path, if storage activation cannot be resolved — the spawned staged binary was
1140
- killed or crashed after switching but before reporting — `yui update` reports a
1141
- distinct **ambiguous** result (a dedicated non-zero exit), never a false
1142
- "unchanged/recoverable". A durable completion receipt written the instant the
1143
- switch commits (a `<home>.upgrade-receipt.json` sibling, cleared on clean
1144
- success) lets it resolve the true state from receipt + backup + current schema
1145
- and print precise manual-verification steps. The receipt is trusted only when it
1146
- genuinely corresponds: it must carry this home's `homePath` and a `backupPath`
1147
- that is the expected `<home>.backup-*` real directory, so a **legacy receipt
1148
- without those fields, or one whose backup is unrelated / missing / not a
1149
- directory** is not trusted as proof of this attempt's switch — the
1150
- tool re-probes the real on-disk state instead.
1151
-
1152
- Rollback boundary (precise): the managed Session launcher is an in-place
1153
- forwarder, not a versioned package pointer, so Yui does **not** claim binary+Home
1154
- dual-resource atomicity. It guarantees: (1) staging is isolated — a
1155
- stage/preflight failure leaves the old binary and Home byte-for-byte unchanged;
1156
- (2) the compatible fast path does not switch the Home; (3) the offline storage
1157
- switch is atomic with a timestamped backup and is recoverable by restoring that
1158
- backup until the new version resumes writes; (4) no auto-downgrade once the new
1159
- version has written. The offline path's non-atomic window — storage already
1160
- switched, binary promotion then fails — is reported with the exact
1161
- `mv <backup> <home>` recovery, and because the axes are version-gated the old
1162
- binary fail-closes on the new home rather than misreading it.
966
+ `yui update` stages the newly published package side by side and asks that exact
967
+ binary to verify that the Home already matches its current storage contract.
968
+ Only then does it stop the exact old Controller, activate the same concrete
969
+ package version, validate the actually installed binary and Home, and start the
970
+ replacement Controller. It never migrates or switches storage. An older or
971
+ otherwise unsupported Home blocks preflight and remains untouched.
972
+
973
+ `yui upgrade [--dry-run]` is retained as a read-only storage admission
974
+ diagnostic. It reports current, uninitialized, invalid, or unsupported state and
975
+ the Operator action; it never performs an upgrade.
1163
976
 
1164
977
  Agent environment bindings store process-environment variable names, never secret values. Adapter-owned lifecycle arguments cannot be overridden through raw arguments.
1165
978
 
@@ -1169,10 +982,7 @@ Yui targets one trusted local user on one machine. Its Web/API surface is
1169
982
  loopback-only and intentionally omits remote or multi-user Web access,
1170
983
  distributed coordination, backup/import/export commands, trash/restore,
1171
984
  derived indexes, recovery journals, runtime leases, inactivity TTLs,
1172
- cooldowns, and recurring schedules. (The one internal exception is the
1173
- timestamped home backup `yui upgrade`/`yui update` takes immediately before an
1174
- atomic storage switch, purely to make that single switch recoverable — it is not
1175
- a general backup/restore facility.)
985
+ cooldowns, and recurring schedules.
1176
986
 
1177
987
  See [ARCHITECTURE.md](./ARCHITECTURE.md) for persistence and scheduling details.
1178
988
  ## Development