@zq-silk/yui 0.15.11 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/ARCHITECTURE.md +11 -6
  2. package/ARCHITECTURE.zh-CN.md +8 -4
  3. package/README.md +13 -5
  4. package/dist/agentRun/agentRun.js +3 -0
  5. package/dist/artifacts/artifactCommitLock.js +16 -55
  6. package/dist/artifacts/taskArtifactRepository.js +3 -3
  7. package/dist/cli/agentConfigurationPicker.js +1 -1
  8. package/dist/cli/commandCatalog.js +92 -48
  9. package/dist/cli/completion.js +18 -18
  10. package/dist/cli/completionWizard.js +1 -1
  11. package/dist/cli/dynamicCompletion.js +1 -1
  12. package/dist/cli/interactionPolicy.js +11 -3
  13. package/dist/cli/invocationAuthority.js +64 -0
  14. package/dist/cli/managedDiagnostics.js +2 -2
  15. package/dist/cli/parseRepeatable.js +35 -0
  16. package/dist/cli/updatePorts.js +26 -5
  17. package/dist/cli.js +1303 -1235
  18. package/dist/commands/agentCommands.js +4 -4
  19. package/dist/commands/capabilityCommands.js +1 -1
  20. package/dist/commands/configCommands.js +6 -57
  21. package/dist/commands/configOverview.js +2 -2
  22. package/dist/commands/durableJobCommands.js +12 -6
  23. package/dist/commands/executionAuditCommands.js +10 -0
  24. package/dist/commands/globalRoleCommands.js +78 -29
  25. package/dist/commands/grantCommands.js +0 -3
  26. package/dist/commands/jobCommands.js +1 -4
  27. package/dist/commands/operatorCommands.js +3 -3
  28. package/dist/commands/projectCommands.js +45 -25
  29. package/dist/commands/resourcesCommands.js +10 -40
  30. package/dist/commands/roleConfiguration.js +2 -6
  31. package/dist/commands/taskActivationCommands.js +4 -8
  32. package/dist/commands/taskAgentCapabilities.js +9 -0
  33. package/dist/commands/taskCommandSupport.js +155 -0
  34. package/dist/commands/taskCommandTypes.js +1 -0
  35. package/dist/commands/taskCommands.js +355 -732
  36. package/dist/commands/taskCompletionGate.js +1 -1
  37. package/dist/commands/taskExecutionCommands.js +1 -1
  38. package/dist/commands/taskFactCommands.js +325 -0
  39. package/dist/commands/taskInputCommands.js +12 -42
  40. package/dist/commands/taskIntegrationCommands.js +20 -58
  41. package/dist/commands/taskNextActionCommand.js +7 -6
  42. package/dist/commands/taskPublicationAdoptCommand.js +127 -0
  43. package/dist/commands/taskPublicationCommands.js +12 -3
  44. package/dist/commands/taskPublicationVerifyCommand.js +24 -40
  45. package/dist/commands/taskRemoteDeliveryCommand.js +5 -86
  46. package/dist/commands/taskUpstreamCommands.js +19 -8
  47. package/dist/commands/workflowCommands.js +6 -1
  48. package/dist/completion/completionInstaller.js +26 -26
  49. package/dist/completion/completionState.js +26 -26
  50. package/dist/completion/fileCompletionManager.js +6 -11
  51. package/dist/config/configCatalog.js +0 -2
  52. package/dist/config/timeZone.js +14 -0
  53. package/dist/config/yuiConfig.js +0 -29
  54. package/dist/context/runContextPack.js +5 -3
  55. package/dist/context/taskCatalog.js +185 -0
  56. package/dist/context/taskContext.js +152 -151
  57. package/dist/context/wakeRunReferences.js +11 -0
  58. package/dist/controller/agentCapabilities.js +58 -0
  59. package/dist/controller/agentRuntimeObserver.js +6 -11
  60. package/dist/controller/clientRuntime.js +22 -14
  61. package/dist/controller/controller.js +20 -24
  62. package/dist/controller/fileSchedulerStoreAdapter.js +191 -225
  63. package/dist/controller/globalInputDelivery.js +13 -0
  64. package/dist/controller/jobClient.js +4 -4
  65. package/dist/controller/jobControl.js +60 -25
  66. package/dist/controller/jobSupervisor.js +4 -4
  67. package/dist/controller/providerRetryAdmission.js +100 -0
  68. package/dist/controller/providerRetryDelivery.js +218 -0
  69. package/dist/controller/runtime.js +85 -43
  70. package/dist/controller/runtimeEventProcessor.js +0 -5
  71. package/dist/controller/sessionOwnerReconciliation.js +5 -0
  72. package/dist/controller/taskAgentError.js +35 -0
  73. package/dist/coordination/workMailboxQueue.js +2 -24
  74. package/dist/core/controllerClient.js +2 -2
  75. package/dist/core/fileLockOwner.js +74 -0
  76. package/dist/decision/decision.js +17 -0
  77. package/dist/doctor/doctor.js +18 -9
  78. package/dist/event/taskEvent.js +12 -0
  79. package/dist/execution/workItemExecutionProjection.js +2 -2
  80. package/dist/executor/agentCapabilityConfig.js +43 -0
  81. package/dist/executor/agentConfigurationCatalog.js +49 -11
  82. package/dist/executor/agentExecutor.js +5 -8
  83. package/dist/executor/fileRoleLaunchPlanner.js +11 -53
  84. package/dist/executor/taskAgentCapabilities.js +64 -0
  85. package/dist/integration/deliveryObligation.js +1 -69
  86. package/dist/integration/gitIntegrationService.js +79 -90
  87. package/dist/integration/integrationAttempt.js +3 -14
  88. package/dist/integration/integrationSourceApplication.js +4 -12
  89. package/dist/integration/manifestTags.js +2 -2
  90. package/dist/job/durableJob.js +4 -25
  91. package/dist/job/jobAssignmentScope.js +22 -0
  92. package/dist/job/jobOperation.js +16 -0
  93. package/dist/job/jobRunner.js +2 -1
  94. package/dist/job/stepDirectory.js +15 -0
  95. package/dist/kernel/builtinCapabilities.js +15 -11
  96. package/dist/kernel/kernelPorts.js +1 -17
  97. package/dist/lifecycle/exactRunTerminalization.js +5 -10
  98. package/dist/message/globalProviderRetry.js +15 -0
  99. package/dist/message/inputControlResolution.js +3 -4
  100. package/dist/message/message.js +17 -20
  101. package/dist/message/messageContinuation.js +1 -1
  102. package/dist/milestone/milestone.js +11 -0
  103. package/dist/observability/executionAudit.js +19 -0
  104. package/dist/observability/orchestrationMetrics.js +24 -1
  105. package/dist/observability/runtimeIdentity.js +1 -17
  106. package/dist/output/agentConfigurationPresentation.js +2 -0
  107. package/dist/output/timePresentation.js +1 -14
  108. package/dist/plugins/pluginService.js +12 -4
  109. package/dist/release/releaseWorkflowPorts.js +45 -96
  110. package/dist/release/runtimeRelease.js +9 -15
  111. package/dist/repository/gitWorkspace.js +371 -105
  112. package/dist/repository/projectMaintenanceLock.js +98 -82
  113. package/dist/repository/taskBaseFreshness.js +1 -1
  114. package/dist/repository/taskWorkspaceCoordinator.js +82 -144
  115. package/dist/repository/taskWorkspacePreparer.js +113 -47
  116. package/dist/repository/workspaceCleanupInspection.js +187 -0
  117. package/dist/resources/autoResourceGc.js +4 -77
  118. package/dist/resources/liveReferences.js +7 -54
  119. package/dist/resources/resourceDiscovery.js +5 -118
  120. package/dist/resources/resourceGc.js +233 -181
  121. package/dist/resources/resourceRegistrar.js +5 -4
  122. package/dist/resources/resourceRegistry.js +3 -37
  123. package/dist/resources/resourceRegistryStore.js +13 -36
  124. package/dist/resources/sqliteResourceRegistry.js +43 -26
  125. package/dist/review/deltaRecheck.js +1 -1
  126. package/dist/review/reviewAcceptance.js +1 -1
  127. package/dist/review/reviewDecision.js +1 -1
  128. package/dist/review/reviewRound.js +8 -7
  129. package/dist/review/taskFinalReviewContractResolution.js +1 -1
  130. package/dist/runtime/acpProtocol.js +4 -51
  131. package/dist/runtime/acpSession.js +10 -75
  132. package/dist/runtime/acpSessionConfiguration.js +1 -8
  133. package/dist/runtime/agentEndpoint.js +3 -2
  134. package/dist/runtime/agentError.js +5 -3
  135. package/dist/runtime/agentFailureContext.js +43 -0
  136. package/dist/runtime/agentHost.js +42 -25
  137. package/dist/runtime/builtinAgentErrorMappers.js +91 -0
  138. package/dist/runtime/codexAppServerRuntime.js +34 -3
  139. package/dist/runtime/codexInteractiveHost.js +2 -2
  140. package/dist/runtime/index.js +0 -1
  141. package/dist/runtime/managedCaller.js +21 -1
  142. package/dist/runtime/providerControl.js +5 -1
  143. package/dist/runtime/providerErrors.js +38 -0
  144. package/dist/runtime/providerRetry.js +198 -0
  145. package/dist/runtime/providerRuntimeIdentity.js +28 -2
  146. package/dist/runtime/runtimeObservation.js +0 -5
  147. package/dist/runtime/runtimeSessionCandidate.js +2 -3
  148. package/dist/runtime/sessionOwnerIdentity.js +1 -1
  149. package/dist/runtime/sessionTokenMetrics.js +15 -5
  150. package/dist/runtime/structuredProviderHost.js +10 -43
  151. package/dist/runtime/taskUsageMetrics.js +275 -0
  152. package/dist/runtime/tmuxAdapters.js +6 -8
  153. package/dist/scheduler/activeRoleRunDelivery.js +19 -7
  154. package/dist/scheduler/leaderWakeupProcessor.js +24 -6
  155. package/dist/scheduler/operatorEvent.js +12 -20
  156. package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
  157. package/dist/scheduler/ports.js +5 -8
  158. package/dist/scheduler/roleRunLiveness.js +4 -4
  159. package/dist/scheduler/roleRunStall.js +16 -23
  160. package/dist/scheduler/taskExecutionProjection.js +49 -36
  161. package/dist/scheduler/taskObservabilityProjection.js +6 -45
  162. package/dist/scheduler/taskWake.js +5 -10
  163. package/dist/scheduler/wakeReason.js +2 -0
  164. package/dist/scheduler/wakeupQueue.js +2 -4
  165. package/dist/setup/setupCommand.js +1 -1
  166. package/dist/storage/contextRecords.js +106 -0
  167. package/dist/storage/currentTaskStore.js +1 -1
  168. package/dist/storage/homeLayout.js +13 -17
  169. package/dist/storage/migrations/agentFailureContext.js +22 -0
  170. package/dist/storage/migrations/currentInputContract.js +86 -0
  171. package/dist/storage/migrations/currentRuntimeContract.js +228 -0
  172. package/dist/storage/migrations/historicalVerificationPlan.js +35 -0
  173. package/dist/storage/migrations/integrationContinuation.js +5 -4
  174. package/dist/storage/migrations/narrowAgentFailureContext.js +65 -0
  175. package/dist/storage/migrations/notificationOnlyWakes.js +74 -0
  176. package/dist/storage/migrations/verificationPlanV1.js +162 -0
  177. package/dist/storage/migrations/verificationPolicy.js +74 -0
  178. package/dist/storage/migrations/workItemHistory.js +46 -0
  179. package/dist/storage/persistenceWorker.js +12 -4
  180. package/dist/storage/recordValidation.js +87 -0
  181. package/dist/storage/sqliteSchema.js +173 -1
  182. package/dist/storage/sqliteStore.js +172 -161
  183. package/dist/storage/storageSchema.js +2 -14
  184. package/dist/storage/storageVersions.js +1 -1
  185. package/dist/storage/storeRpc.js +16 -7
  186. package/dist/storage/taskCatalog.js +123 -0
  187. package/dist/storage/taskStore.js +5 -7
  188. package/dist/storage/upgrade/upgradeOrchestrator.js +25 -37
  189. package/dist/task/archiveDiagnostics.js +1 -0
  190. package/dist/task/archivePreflight.js +124 -0
  191. package/dist/task/completionReadiness.js +5 -24
  192. package/dist/task/draftPlan.js +0 -53
  193. package/dist/task/nextAction.js +7 -13
  194. package/dist/task/publicationAdoption.js +56 -0
  195. package/dist/task/publicationReference.js +10 -0
  196. package/dist/task/remoteDelivery.js +31 -16
  197. package/dist/task/remoteDeliveryService.js +89 -0
  198. package/dist/task/taskActivation.js +2 -25
  199. package/dist/task/taskActivationService.js +0 -2
  200. package/dist/task/taskRecordReference.js +0 -1
  201. package/dist/task/taskSubmission.js +3 -14
  202. package/dist/telemetry/sqliteTelemetryBatch.js +29 -0
  203. package/dist/telemetry/sqliteTelemetryStore.js +49 -49
  204. package/dist/telemetry/telemetryWiring.js +4 -3
  205. package/dist/tmux/tmuxManager.js +29 -20
  206. package/dist/verification/gateArtifact.js +15 -24
  207. package/dist/verification/gateArtifactStore.js +14 -7
  208. package/dist/verification/verificationGateService.js +29 -88
  209. package/dist/verification/verificationPlan.js +27 -72
  210. package/dist/web/assets/client/app.js +92 -17
  211. package/dist/web/assets/client/components.js +55 -13
  212. package/dist/web/assets/client/i18n.js +72 -4
  213. package/dist/web/assets/client/taskSurface.js +6 -5
  214. package/dist/web/assets/client/view.js +35 -7
  215. package/dist/web/assets/shell.js +6 -0
  216. package/dist/web/assets/styles/layout.js +7 -0
  217. package/dist/web/webServer.js +12 -3
  218. package/dist/web/webSnapshot.js +14 -85
  219. package/dist/web/webTaskSurface.js +17 -46
  220. package/dist/workItem/workItem.js +1 -12
  221. package/dist/workspace/cleanupInspection.js +63 -0
  222. package/dist/workspace/workItemChangeSetManager.js +110 -50
  223. package/docs/agent-result-consumption.md +4 -0
  224. package/docs/agent-result-consumption.zh-CN.md +3 -0
  225. package/docs/agent-runtime-drivers.md +7 -0
  226. package/docs/agent-runtime-drivers.zh-CN.md +5 -0
  227. package/docs/architecture/README.md +2 -0
  228. package/docs/architecture/README.zh-CN.md +3 -1
  229. package/docs/architecture/capabilities-and-resources.md +42 -5
  230. package/docs/architecture/capabilities-and-resources.zh-CN.md +33 -3
  231. package/docs/managed-turn-and-session-runtime.md +121 -1
  232. package/docs/managed-turn-and-session-runtime.zh-CN.md +96 -2
  233. package/docs/observability/README.md +62 -0
  234. package/docs/observability/README.zh-CN.md +47 -0
  235. package/docs/plugin-sdk.md +4 -2
  236. package/docs/project-refresh.md +77 -0
  237. package/docs/project-refresh.zh-CN.md +59 -0
  238. package/docs/provider-retry.md +70 -0
  239. package/docs/provider-runtime.md +3 -1
  240. package/docs/provider-runtime.zh-CN.md +4 -2
  241. package/docs/release-workflow.md +190 -7
  242. package/docs/release-workflow.zh-CN.md +139 -5
  243. package/docs/roles-and-configuration.md +29 -0
  244. package/docs/roles-and-configuration.zh-CN.md +21 -0
  245. package/docs/sqlite-control-plane-design.md +16 -3
  246. package/docs/sqlite-control-plane-design.zh-CN.md +13 -2
  247. package/docs/task-dag-semantics.md +3 -3
  248. package/docs/task-dag-semantics.zh-CN.md +2 -2
  249. package/docs/task-delivery.md +223 -17
  250. package/docs/task-delivery.zh-CN.md +171 -14
  251. package/docs/task-discovery.md +101 -0
  252. package/docs/task-discovery.zh-CN.md +85 -0
  253. package/docs/testing/verification-levels.md +161 -9
  254. package/docs/testing/verification-levels.zh-CN.md +116 -9
  255. package/i18n/README.zh-CN.md +13 -7
  256. package/package.json +1 -1
  257. package/skills/yui-leader/SKILL.md +5 -0
  258. package/skills/yui-leader/references/execution.md +3 -2
  259. package/skills/yui-leader/references/integration.md +9 -5
  260. package/skills/yui-leader/references/planning.md +9 -3
  261. package/skills/yui-operator/SKILL.md +24 -8
  262. package/skills/yui-reviewer/SKILL.md +4 -0
  263. package/skills/yui-runtime/SKILL.md +17 -2
  264. package/skills/yui-runtime/references/publication.md +26 -4
  265. package/skills/yui-runtime/references/recovery.md +71 -0
  266. package/dist/agent/agentRegistry.js +0 -10
  267. package/dist/agentRun/runIdentity.js +0 -22
  268. package/dist/commands/deliveryGuardPreflight.js +0 -30
  269. package/dist/commands/taskIntegrationQueueCommands.js +0 -226
  270. package/dist/commands/taskOverviewCommand.js +0 -376
  271. package/dist/completion/completionWizard.js +0 -125
  272. package/dist/context/dispatchContext.js +0 -110
  273. package/dist/context/wakeNotification.js +0 -144
  274. package/dist/integration/integrationCheckEvidenceReuse.js +0 -53
  275. package/dist/integration/integrationQueueEntry.js +0 -191
  276. package/dist/integration/integrationQueueService.js +0 -810
  277. package/dist/release/fakeReleasePorts.js +0 -55
  278. package/dist/runtime/sessionOwnerRegistry.js +0 -137
  279. package/dist/task/deliveryGuard.js +0 -226
  280. /package/dist/{commands/taskActor.js → task/taskAuthority.js} +0 -0
@@ -8,21 +8,34 @@ Task lifecycle is `draft / active / completed / cancelled / archived`. A Draft
8
8
  stores intent, Project bindings, planning discussion and mutable requirements.
9
9
  It does not adopt a writable delivery workspace at creation.
10
10
 
11
+ Activation requires a durable request with an explicit environment plan:
12
+ use `task activation request <task> --request-id <id> --environment <plan>`.
13
+ The Controller adopts eligible requests; `task activate <task>` may consume an
14
+ existing request in the foreground but never creates implicit activation intent.
11
15
  Activation validates current Roles, dependencies, Project scope and resources,
12
16
  prepares physical workspaces, and adopts status/ownership atomically. Failed
13
17
  preparation leaves the Task Draft with a failed request and a diagnosis delivered
14
18
  to the Leader. Deferred activation retains the exact intent and waits for native
15
19
  quiescence, whether requested in a planning Run or subsequent discussion.
20
+ Project maintenance contention waits asynchronously before resource adoption.
21
+ A lock timeout or cancelled wait preserves the original activation request;
22
+ after acquiring the lock, activation rechecks current intent and authority.
16
23
 
17
24
  Task type describes the requested outcome, not the mandatory executor.
18
25
  Leader owns bounded work directly or assigns substantial independent WorkItems.
19
26
  Direct execution has no Group. Replication is explicitly requested for independent
20
27
  attempts at the same frozen Assignment, followed by Leader-selected synthesis.
21
28
 
29
+ Scope overlap is a read-only advisory in `task next-action`, not a text-matching
30
+ creation gate. The Leader inspects original requirements and decides whether
31
+ work is independent. Request identity, permissions, dependencies, workspace
32
+ isolation and acceptance checks remain enforced independently.
33
+
22
34
  ## Managed workspaces
23
35
 
24
36
  Stable Project checkouts are read-only references. Task main is a logical
25
- multi-Project root with per-Project Git worktrees. For one Project, the Agent's
37
+ multi-Project root with independent per-Project Git clones; WorkItem, Review and
38
+ Integration worktrees belong to those Task repositories. For one Project, the Agent's
26
39
  normal cwd is its managed Git root; for multiple Projects, the root and native
27
40
  additional-directory mechanism expose the explicit Project set.
28
41
 
@@ -43,20 +56,82 @@ managed workspace remains the Git/control ownership record.
43
56
  ## Candidate, Review and Integration
44
57
 
45
58
  Provider terminal saves the exact original Run result. It does not accept the
46
- WorkItem. The Leader evaluates the result and captures immutable per-Project
47
- ChangeSets for isolated code. The governing Candidate supplies provenance for
59
+ WorkItem. The Leader evaluates the result and its immutable per-Project Git
60
+ snapshot. Optional ChangeSets supply diff evidence. The governing Candidate supplies provenance for
48
61
  Review and Integration; Producers do not independently enter either path.
49
62
 
50
- Integration applies the fixed ChangeSet in a candidate worktree, runs configured
63
+ The Agent chooses the order and strategy, then starts one Integration from an
64
+ exact WorkItem Candidate. There is no separate ChangeSet integration queue.
65
+ Integration applies the fixed source commits in a candidate worktree, runs configured
51
66
  checks, then advances the target only if its head still matches. Conflict,
52
67
  failed checks, target movement or rejection retain evidence and never advance
53
68
  the target. The Agent chooses retry or manual resolution within the retained
54
69
  workspace.
55
70
 
71
+ An existing merge/rebase/cherry-pick without the attempt's own progress receipt
72
+ is not adopted from Git markers. Preserve the scene and choose explicit recovery;
73
+ normal continuation uses the original receipt and never replays a completed step.
74
+
56
75
  When checks are a DurableJob, the Integration retains that exact jobId while
57
76
  running. Once the Job settles, `task integration continue <task>/<integration>`
58
- consumes its result and performs the guarded finalization. The direct operation
59
- does not depend on entries in the separate integration queue.
77
+ consumes its result and performs the guarded finalization. Existing unsettled
78
+ Integrations, including conflicts, remain completion blockers independently of
79
+ how the Agent ordered them.
80
+
81
+ ### Verification reuse and explicit reruns
82
+
83
+ A configured VerificationPlan reuses only complete, successful, log-verified
84
+ evidence for the exact Project, commit, plan, toolchain and target/base boundary.
85
+ A plan with no reusable evidence executes normally. Plans require
86
+ `schemaVersion: 2` and contain no `l1` or `record/reuse/enforce` mode.
87
+ Storage 34→35 preserves the original Project declarations, L1 artifacts and
88
+ binary logs in migration audit storage, outside current execution and cache
89
+ lookup. Historical `historical-change-sets` Integrations must be settled and
90
+ free of execution/delivery references before their exact payloads become
91
+ `integration.source-retired` Task Events. Their IDs are never reused.
92
+
93
+ Request fresh checks when creating an operation:
94
+
95
+ ```sh
96
+ yui task integration start <task> --work-item <id> --strategy ff --rerun-checks
97
+ yui task upstream integrate <task> --project <project> --rerun-checks
98
+ ```
99
+
100
+ The flag is immutable intent on that Integration, not a global configuration
101
+ switch. `continue` consumes the same admitted Job; it cannot turn into a rerun.
102
+ Create a new attempt for another execution, and settle any equivalent unfinished
103
+ verification first. Rerun affects only cache reuse, never permissions, Job
104
+ identity, workspace checks or the final target CAS.
105
+ Explicit `--check` commands also request fresh execution. With a plan configured,
106
+ they run after its checks; they are neither ignored nor rejected by text matching.
107
+ Unstructured checks do not search historical Jobs for a substitute result.
108
+
109
+ Fresh execution withdraws the old success before starting. Failure is recorded
110
+ as failure; interruption, missing logs or a mutated candidate leave no reusable
111
+ success. Both Job and local execution verify the exact clean candidate before
112
+ publishing successful proof. The v5 L2-only execution digest excludes older proof without
113
+ deleting its history. A stale
114
+ cache consumer cannot restore an older result. Release lookup considers the
115
+ newest recorded matching proof rather than searching past a failure for an
116
+ older green result. The cache represents current reusable evidence, not Task
117
+ execution history; original Job and Integration records remain separate.
118
+
119
+ The public upstream CLI uses the same Controller Job port as other Integration
120
+ commands. `--latest` may return independent pending Jobs for several Projects;
121
+ continue each returned Integration ID rather than issuing another upstream
122
+ request to poll it.
123
+
124
+ Job admission, management and pre-spawn checks bind a non-Leader to its current
125
+ Assignment, exact WorkItem workspace and writable Project scope. The existing
126
+ Job owner contract does not represent Review/replica workspaces, so those
127
+ requests fail explicitly rather than falling back to Task main. Leader/Operator
128
+ supervision and settlement of already-running Jobs remain separate.
129
+
130
+ The identity covers declared inputs, not every external service or untracked
131
+ environment condition. Use explicit reruns for changing external inputs,
132
+ flakiness investigation or a user-requested new check. A plan does not authorize
133
+ real-model/paid/shared-resource validation. Reuse never substitutes for Review,
134
+ acceptance or publication authority.
60
135
 
61
136
  Review follows the applicable Candidate rule or Task-final contract and frozen
62
137
  heads. The exact main Reviewer Run holds the report; successful execution is
@@ -75,31 +150,162 @@ Leader delivery. The current native turn must end so the pending notification
75
150
  can arrive; the Leader then reads the original message and reassesses completion.
76
151
  This derives from existing Messages and mailbox delivery, not a second
77
152
  acknowledgement or workflow state.
78
- Terminal workspace cleanup can remain an advisory at completion, but not at
79
- archive. Artifacts selected as results must be fixed, present and Task-local.
153
+ Terminal workspace cleanup can remain an advisory at completion. Ordinary
154
+ archive requires it to be settled; explicitly authorized force archive may
155
+ retain unresolved resources as described below. Artifacts selected as results
156
+ must be fixed, present and Task-local.
80
157
 
81
158
  Publication records a remote PR/MR reference. Reported merge, independently
82
159
  verified merge and exact Task-head coverage are separate facts. Task completion
83
160
  does not prove any of them. Remote delivery is read from exact publication/head
84
161
  evidence, not inferred from a title or branch name.
85
162
 
163
+ Completion heads remain the immutable acceptance baseline. A later, authorized
164
+ integration may produce a different publication candidate (including a rebase
165
+ or merge before a remote squash). Neither ancestry nor a successful Integration
166
+ proves that the accepted behavior survived, or accepts additional changes.
167
+
168
+ For a completed, unarchived Task, record the exact candidate as the Publication's
169
+ `localCommit`, then read `task publication diff <task>/<publication>`. This reads
170
+ only Task-owned local Git objects and returns the original completion reference,
171
+ both commit/tree endpoints, the full diff (including binary changes), and a
172
+ digest binding those facts. Review removals, additions and conflict resolutions
173
+ against the original requirements. If they preserve the accepted result and all
174
+ relevant increments are accepted, use
175
+ `task publication adopt <task>/<publication> --reviewed-diff <sha256> --acceptance <text>`.
176
+ The acceptance must explain that judgment and its verification/review evidence;
177
+ Core checks fixed identity and facts, not the meaning of the code. If an existing
178
+ Task Integration produced that exact candidate, pass its local ID with
179
+ `--integration <id>` to both commands to bind its committed evidence as well.
180
+ This records one Task event, not a new delivery status, Candidate lifecycle,
181
+ Git operation, or permission to change completed work.
182
+
183
+ `task publication verify` remains the explicit, authorized provider read. It
184
+ records the remote source head, PR/MR state and merge commit independently of
185
+ Task acceptance. A mismatched head or non-merged state is saved as **reported**,
186
+ superseding earlier verification; provider errors or mismatched external identity
187
+ write nothing. A merged provider observation verifies only that Publication's
188
+ exact local candidate. A squash merge needs no fabricated commit ancestry.
189
+ Metadata/verification successors preserve adoption only through an uninterrupted
190
+ same-candidate Publication lineage. Candidate or referenced Integration changes
191
+ cannot silently reuse the decision.
192
+
193
+ CLI, current Leader Context and Web derive coverage from these same facts, with
194
+ no provider reads or evidence writes. They distinguish not delivered, merged
195
+ but uncovered, covering merge not verified, partial delivery and verified merge.
196
+ Each Project retains its own accepted head, selected candidate, adoption reference
197
+ and reason. Unknown historical heads remain unknown; old exact-SHA evidence stays
198
+ valid without inventing adoption, and archive never proves remote delivery.
199
+
86
200
  Cancelled intent does not prove the runtime stopped. User/Operator may reopen
87
201
  cancelled Tasks; Leader may reopen completed Tasks. Reopening requires fresh
88
202
  explicit input/work selection and never replays previous delivery requests.
89
203
 
90
204
  ## Archive
91
205
 
92
- Archive is a separate authorized action after active work is settled and
93
- resources are clean and removable. Choose integrated delivery or deliberate
94
- abandonment explicitly. Integrated archive requires exact merged heads and
95
- verified publication evidence. An explicitly authorized verification override
96
- cannot bypass missing or stale heads or an unmerged result.
206
+ Archive requires independent user/Operator authorization for an exact completed
207
+ or cancelled (retired) Task. Completion alone grants none, and ordinary archive
208
+ approval does not authorize force. Select one disposition explicitly:
97
209
 
98
- Managed WorkItem resources must be integrated or deliberately abandoned before
99
- cleanup. Review, Lane and Integration resources must be settled. Dirty worktrees
100
- remain for the Agent to resolve; no implicit reset or force deletion occurs.
101
- Task main branches and durable Task records retain recovery information.
210
+ ```sh
211
+ yui task archive <task> --integrated
212
+ yui task archive <task> --abandon
213
+ # Only with explicit force authorization, preserving the chosen disposition:
214
+ yui task archive <task> (--integrated|--abandon) --force
215
+ ```
216
+
217
+ ### Ordinary archive
218
+
219
+ Active work and inputs must be settled, and managed resources clean and safely
220
+ removable. WorkItem results must be integrated or deliberately abandoned;
221
+ Review, Lane and Integration resources must be settled. With `--integrated`,
222
+ each Project requiring code delivery needs a merged, verified Publication
223
+ covering its accepted head, either exactly or through valid explicit candidate
224
+ adoption. `--abandon` records deliberate non-delivery,
225
+ not verified merge.
226
+
227
+ Missing/stale coverage, unresolved execution or dirty worktrees prevent ordinary
228
+ archive. Resolve the reported facts before an explicit retry; no implicit reset
229
+ or force deletion occurs.
230
+
231
+ ### Explicit force archive
232
+
233
+ `--force` is not merely a merge-verification override. It commits the archive
234
+ and stops new Task scheduling before attempting safe foreground cleanup.
235
+ Missing or stale delivery evidence, an unmerged result, unresolved execution
236
+ and cleanup failures become warnings with retained resource references, rather
237
+ than blocking that archive commit. Authority, eligible lifecycle, exact resource
238
+ identity and mandatory audit persistence still fail closed.
239
+
240
+ Force neither verifies a merge nor accepts work, proves quiescence, discards
241
+ dirty data or implies `--abandon`. It preserves the selected disposition and
242
+ original Publication/completion evidence. Unverified local commits and resources
243
+ that cannot safely be released stay owned and traceable. A cleanup failure does
244
+ not roll back archive; late runtime events remain source evidence without
245
+ resuming the Task or settling unknown input.
246
+
247
+ ### Read the result before cleanup
248
+
249
+ `yui task show <task> --json` exposes `data.archive.warnings`,
250
+ `data.archive.retainedResources` and `data.archive.cleanupEvents`.
251
+ `yui task context <task> --json` retains the original records and events;
252
+ `yui task remote-delivery <task> --json` reports delivery separately.
253
+ Warnings include historical cleanup attempts; retained references describe
254
+ current ownership, not a second cleanup queue.
255
+
256
+ An archive result with `archived=true` proves archival, not that cleanup fully
257
+ succeeded. Even `cleanupFinished` means the foreground pass finished, not that
258
+ every resource was removed. Repeating archive reports current facts and does
259
+ not replay cleanup. After inspection, use explicit exact-owner resource
260
+ operations for safe cleanup; no background retry or broader deletion authority
261
+ is implied. Both archive paths preserve Task history and recovery information.
102
262
  Archived Tasks cannot reopen.
103
263
 
264
+ Resource GC is a separate, opt-in quarantine path. A runtime subtree moves once:
265
+ the parent receipt owns recovery of its contents, and redundant child registry
266
+ entries are removed in the same registry transaction. Independently owned Git
267
+ worktrees or retained descendants prevent moving their enclosing directory.
268
+ Task records and results are never removed by this consolidation.
269
+ Session process custody comes from SQLite `session_owners`, with live PID and
270
+ start-identity checks. The retired JSON owner directory is not a parallel source.
271
+
272
+ The plan is not cleanup authority. Apply and purge re-read Task status, managed
273
+ workspaces, active Runs and unsettled Jobs under the existing SQLite writer
274
+ fence, which spans the bounded physical mutation and registry update. A reopened
275
+ Task or new durable owner prevents quarantine/deletion; uncertainty retains the
276
+ resource with a diagnosis. Reopened quarantined resources can be restored.
277
+ This adds neither a retry worker nor another persistent ownership protocol.
278
+
279
+ `yui task archive-preflight <task> (--integrated|--abandon) [--force] [--json]`
280
+ reads current admission, delivery and exact-owner cleanup checks in one report.
281
+ It is available before and after archive, including to the Task's authorized
282
+ Leader reader. `--force` here only selects the behavior to inspect. It never
283
+ archives, prepares workspaces, refreshes Git indexes, stops Sessions, acquires
284
+ maintenance locks, fetches remote data, or writes a cleanup plan.
285
+
286
+ Each blocking/unknown check has a resource, reason code, expected and observed
287
+ values, source references and existing inspection/disposition commands. Git
288
+ paths outside the authorized Task are redacted. The report distinguishes
289
+ missing Candidate workspace, changed workspace identity/metadata/path, missing
290
+ frozen commit, moved HEAD, dirty worktree, missing/locked Git registration,
291
+ unintegrated result, uncovered delivery, unsettled owner and unknown execution.
292
+ Status inspection disables optional index writes and filesystem-monitor hooks.
293
+ If a tracked file selects a configured clean/process filter (including an
294
+ initialized submodule's), it reports `git-status-requires-filter` as unknown instead of
295
+ executing the program or bypassing normalization and guessing clean/dirty.
296
+ Historical Candidate paths remain immutable. A path difference, including one
297
+ consistent with an earlier layout migration, does not itself prove a safe
298
+ relocation: without an exact mapping the check reports the difference and
299
+ retains the resource; it does not repair history or weaken commit/owner checks.
300
+
301
+ Preflight is an observation, not a removal permit. Cleanup reloads the same
302
+ checks and Git verifies ownership/dirt again at removal. A Task-main clone's
303
+ dependent registrations are expected before child cleanup and must be absent
304
+ before clone removal. Archive preserves new dirt even in a failed Integration
305
+ workspace; the separate explicit Integration cleanup command keeps its existing
306
+ disposable-conflict behavior. A finished force cleanup means the foreground
307
+ attempt ended, not that every resource was released. Current retained references
308
+ and exact physical runtime evidence remain separate from historical diagnostics.
309
+
104
310
  Use each command's `--help` to inspect its exact authority and options before
105
311
  cleanup; reading a lifecycle document does not authorize an external write.
@@ -7,19 +7,30 @@
7
7
  Task 生命周期是 `draft / active / completed / cancelled / archived`。Draft 保存
8
8
  意图、Project 绑定、规划讨论和可变需求。它在创建时不采用可写的交付工作区。
9
9
 
10
+ 激活要求先保存带明确环境计划的请求:
11
+ `task activation request <task> --request-id <id> --environment <plan>`。
12
+ Controller 采用符合条件的请求;`task activate <task>` 可以在前台消费已有请求,
13
+ 但不会隐式创建激活意图。
10
14
  激活会校验当前 Role、依赖、Project 范围和资源,准备物理工作区,并原子地采用
11
15
  状态/所有权。准备失败会让 Task 停在 Draft,附带一个失败请求和投递给 Leader 的
12
16
  诊断。延迟激活保留确切意图并等待原生静止,无论它是在规划 Run 中还是在后续讨论中
13
17
  被请求的。
18
+ Project 维护争用会在采用资源前异步等待。锁超时或等待被取消时保留原激活请求;
19
+ 获得锁后重新检查当前意图与权限。
14
20
 
15
21
  Task type 描述被请求的结果,而不是强制的执行者。Leader 直接负责有界工作,或分派
16
22
  有独立价值的 WorkItem。直接执行没有 Group。复制是为了在同一个冻结 Assignment 上
17
23
  进行独立尝试而被显式请求的,随后由 Leader 选择综合。
18
24
 
25
+ 工作范围重叠只在 `task next-action` 中作为只读建议,不再按文本匹配拦截创建。
26
+ Leader 读取原始需求并判断是否属于独立工作。请求身份、权限、依赖、工作区隔离和
27
+ 验收校验仍独立强制执行。
28
+
19
29
  ## 受管工作区
20
30
 
21
31
  稳定的 Project checkout 是只读参考。Task main 是一个逻辑上的多 Project 根,带有
22
- 按 Project 划分的 Git worktree。对单个 Project,Agent 的正常 cwd 是其受管 Git 根;
32
+ 按 Project 划分的独立 Git clone;WorkItem、Review Integration worktree 归这些
33
+ Task 仓库所有。对单个 Project,Agent 的正常 cwd 是其受管 Git 根;
23
34
  对多个 Project,根加上原生的附加目录机制暴露明确的 Project 集合。
24
35
 
25
36
  一个隔离的 WorkItem 为可写 Project 拥有独立 worktree,为其余 Project 提供 Task-main
@@ -34,17 +45,65 @@ Task type 描述被请求的结果,而不是强制的执行者。Leader 直接
34
45
 
35
46
  ## Candidate、Review 与 Integration
36
47
 
37
- Provider 终态保存确切的原始 Run 结果。它不验收 WorkItem。Leader 评估结果,并为
38
- 隔离代码捕获不可变的、按 Project 划分的 ChangeSet。治理 Candidate 为 Review 和
48
+ Provider 终态保存确切的原始 Run 结果。它不验收 WorkItem。Leader 评估结果及其不可变的
49
+ Project 划分的 Git 快照。ChangeSet 是可选的差异证据;治理 Candidate 为 Review 和
39
50
  Integration 提供来源;Producer 不独立进入这两条路径中的任何一条。
40
51
 
41
- Integration 在候选 worktree 中套用固定 ChangeSet,运行已配置的检查,然后只有在
52
+ Agent 选择结果顺序与策略,再从精确 WorkItem Candidate 发起一次 Integration,
53
+ 不再维护单独的 ChangeSet 集成队列。
54
+ Integration 在候选 worktree 中套用固定来源提交,运行已配置的检查,然后只有在
42
55
  目标 head 仍匹配时才推进目标。冲突、检查失败、目标移动或拒绝都保留证据,绝不推进
43
56
  目标。Agent 在保留的工作区内选择重试或手动解决。
44
57
 
58
+ 已有 merge/rebase/cherry-pick 若缺少原尝试的进度回执,不根据 Git 标记接管。
59
+ 保留现场并选择显式恢复;正常续作使用原回执,不重放已完成步骤。
60
+
45
61
  当检查是一个 DurableJob 时,Integration 在运行期间保留那个确切的 jobId。Job 结算
46
62
  后,`task integration continue <task>/<integration>` 消费其结果并执行带守卫的收尾。
47
- 这个直接操作不依赖单独 integration 队列中的条目。
63
+ 未结算的 Integration(包括冲突)仍阻止完成,不依赖 Agent 采用了什么执行顺序。
64
+
65
+ ### 验证复用与显式重跑
66
+
67
+ 配置了 VerificationPlan 的项目,默认只复用完整成功、日志可校验,且 Project、
68
+ 提交、计划、工具链、目标 ref/基线都精确匹配的证据。存储 `34→35` 将原始 Project
69
+ 计划、L1 artifact 和二进制日志保存在迁移审计存档,不再进入当前执行与缓存读取。
70
+ `historical-change-sets` Integration 必须先结算且不存在执行/交付引用,才能将
71
+ 完整 payload 转为 `integration.source-retired` Task 事件;旧 ID 不会复用。
72
+ 无匹配证据时正常执行。
73
+ 计划必须提供 `schemaVersion: 2`,不再包含 `l1` 或 `record/reuse/enforce` 模式。
74
+
75
+ 新建操作时显式要求重跑:
76
+
77
+ ```sh
78
+ yui task integration start <task> --work-item <id> --strategy ff --rerun-checks
79
+ yui task upstream integrate <task> --project <project> --rerun-checks
80
+ ```
81
+
82
+ 该选项是本次 Integration 的不可变意图,不是全局配置开关。`continue` 只消费原先
83
+ 接纳的 Job,不会变成重跑。再次执行需创建新尝试,并先结算等价的未完成验证。
84
+ 重跑只跳过缓存,不绕过权限、Job 身份、工作区检查或最终目标 CAS。
85
+ 显式 `--check` 同样要求实际执行。配置了计划时,它们在计划检查后执行,
86
+ 不会被忽略,也不会因命令文本相同而被拒绝。
87
+ 非结构化检查不再搜索历史 Job 来替代本次执行。
88
+
89
+ 新执行开始前撤下旧成功。失败如实记录;中断、缺失日志或候选被改写时,
90
+ 不会保留可复用成功。Job 和本地执行在发布成功证据前,共同检查候选的精确提交、
91
+ 分支和干净状态。v5 L2-only 执行摘要隔离旧证据,不删除原有历史。
92
+ 过期的缓存使用者不能恢复旧结果。发布查询查看最新匹配证据,不跳过失败去找旧绿灯。
93
+ 缓存只表示当前可复用证据,不充当 Task 执行历史;原 Job 和 Integration 记录独立保留。
94
+
95
+ 公开 upstream CLI 与其他 Integration 命令共用 Controller Job 入口。
96
+ `--latest` 可以返回多个 Project 各自待处理的 Job;应继续返回的每个 Integration ID,
97
+ 而不是重新发起 upstream 请求来轮询进度。
98
+
99
+ Job 的准入、管理操作及启动前检查把非 Leader 限定到当前 Assignment、
100
+ 精确 WorkItem 工作区和可写 Project。现有 Job owner 不能表达 Review/replica
101
+ 工作区时会明确拒绝,不退回 Task 主工作区。Leader/Operator 管理与已运行 Job 的
102
+ 结果结算保持独立。
103
+
104
+ 这些身份只覆盖已声明输入,不是所有外部服务和未跟踪环境的完整指纹。
105
+ 外部条件变化、排查偶发失败或用户要求再次检查时,应显式重跑。
106
+ 计划不赋予真实模型、付费或共享资源测试授权;复用也不替代 Review、验收或发布权限。
48
107
 
49
108
  Review 遵循适用的 Candidate 规则或 Task-final 合同以及冻结的 head。确切的 main
50
109
  Reviewer Run 持有报告;执行成功不等于语义通过。验收归 Leader。即使默认审查策略
@@ -58,25 +117,123 @@ Reviewer Run 持有报告;执行成功不等于语义通过。验收归 Leader
58
117
  干净且已提交的 Task-main 快照。当有一条新的 user/Operator 消息仍在等待 Leader
59
118
  投递时,它也会拒绝完成。当前原生轮次必须结束,待处理的通知才能到达;随后 Leader
60
119
  读取原始消息并重新评估完成。这派生自既有的 Message 和 mailbox 投递,而不是第二套
61
- 确认或工作流状态。终态工作区清理在完成时可以只是建议,但在归档时不行。被选作
62
- 结果的 Artifact 必须是固定的、存在的且 Task 局部的。
120
+ 确认或工作流状态。终态工作区清理在完成时可以只是建议。普通归档要求清理已结算;
121
+ 明确授权的 force 归档可以保留下文所述的未解决资源。被选作结果的 Artifact 必须是
122
+ 固定的、存在的且 Task 局部的。
63
123
 
64
124
  发布记录一个远程 PR/MR 引用。被报告的合并、独立验证的合并以及确切的 Task-head
65
125
  覆盖是彼此独立的事实。Task 完成不证明其中任何一项。远程交付从确切的发布/head
66
126
  证据读取,而不从标题或分支名推断。
67
127
 
128
+ 完成 head 始终是不可变的验收基线。之后获授权的集成可能产生不同的发布候选
129
+ (例如远端 squash 前的 rebase 或 merge)。祖先关系和 Integration 成功都不能
130
+ 证明验收行为未被撤销,也不验收额外增量。
131
+
132
+ 对于已完成但未归档的 Task,先把精确候选记为 Publication 的 `localCommit`,
133
+ 再读 `task publication diff <task>/<publication>`。此命令只读取 Task 自有的
134
+ 本地 Git 对象,返回原完成记录引用、两端 commit/tree、完整差异(含二进制变更),
135
+ 以及绑定这些事实的摘要。逐项核对删除、增加和冲突处理是否仍满足原需求;仅在原成果
136
+ 保留、相关增量也已验收时,执行
137
+ `task publication adopt <task>/<publication> --reviewed-diff <sha256> --acceptance <text>`。
138
+ 验收依据应解释上述判断及其验证/审阅证据;Core 核验固定身份和事实,不裁定代码语义。
139
+ 如果已有本 Task 的 Integration 产出了该精确候选,在两个命令中都传入
140
+ `--integration <id>`,一并绑定其已提交证据。这只新增一个 Task 事件,不新增交付
141
+ 状态表、Candidate 生命周期或 Git 操作,也不授权修改已完成成果。
142
+
143
+ `task publication verify` 仍是显式且须获授权的 provider 读取。它独立于 Task
144
+ 验收,记录远端 source head、PR/MR 状态和 merge commit。head 不匹配或尚未合并时,
145
+ 保存为 **reported** 并取代旧验证;provider 错误或外部身份不匹配则不写任何证据。
146
+ 已合并的 provider 观察仅验证该 Publication 的精确本地候选;squash 不需要伪造
147
+ 提交祖先关系。元数据/验证更新只有沿连续同候选的 Publication 血缘才能继承采用;
148
+ 候选或所引用的 Integration 变化,不能悄悄复用旧决定。
149
+
150
+ CLI、当前 Leader Context 和 Web 从同一组事实推导覆盖,不联网、不写证据。展示
151
+ 区分尚未交付、PR/MR 已合并但未覆盖、已覆盖合并但未验证、部分交付、已验证合并。
152
+ 每个 Project 保留自己的验收 head、候选、采用引用和原因。缺失的历史 head 仍然
153
+ 未知;旧精确 SHA 证据无需补造采用记录,归档也不能反推已交付。
154
+
68
155
  取消意图不证明运行时已停止。user/Operator 可以重开已取消的 Task;Leader 可以重开
69
156
  已完成的 Task。重开需要全新的显式输入/工作选择,绝不重放先前的交付请求。
70
157
 
71
158
  ## 归档
72
159
 
73
- 归档是一次单独的授权动作,发生在活动工作已了结、资源干净可移除之后。显式选择
74
- 集成交付或有意放弃。集成归档要求确切的已合并 head 和已验证的发布证据。一次显式
75
- 授权的验证覆盖不能绕过缺失或陈旧的 head,也不能绕过一个未合并的结果。
76
-
77
- 受管的 WorkItem 资源必须在清理前被集成或有意放弃。Review、Lane Integration
78
- 资源必须已结算。脏 worktree 留给 Agent 解决;不发生隐式 reset 或强制删除。Task
79
- main 分支和持久 Task 记录保留恢复信息。已归档的 Task 不能重开。
160
+ 归档需要针对确切的 completed 或 cancelled(retired)Task 获得独立的 user/Operator
161
+ 授权。完成本身不授予归档权限,普通归档批准也不授权 force。显式选择一种处置:
162
+
163
+ ```sh
164
+ yui task archive <task> --integrated
165
+ yui task archive <task> --abandon
166
+ # 仅在明确授权 force 后使用,并保留所选处置:
167
+ yui task archive <task> (--integrated|--abandon) --force
168
+ ```
169
+
170
+ ### 普通归档
171
+
172
+ 活动工作与输入必须已了结,受管资源干净且可安全移除。WorkItem 结果必须已集成或
173
+ 有意放弃;Review、Lane 和 Integration 资源必须已结算。使用 `--integrated` 时,
174
+ 每个需要代码交付的 Project 都要求已合并且已验证的 Publication,通过精确匹配
175
+ 或有效显式采用候选覆盖其验收 head。`--abandon` 记录有意不交付,而不是已验证合并。
176
+
177
+ 缺失或陈旧的覆盖、未解决的执行或脏 worktree 会阻止普通归档。先解决报告的事实,
178
+ 再显式重试;不会隐式 reset 或强制删除。
179
+
180
+ ### 明确授权的 force 归档
181
+
182
+ `--force` 不只是覆盖合并验证要求。它先提交归档并停止新的 Task 调度,再尝试安全的
183
+ 前台清理。缺失或陈旧的交付证据、未合并结果、未解决的执行和清理失败会成为警告及
184
+ 保留资源引用,而不阻止这次归档提交。权限、合法生命周期、精确资源身份和强制审计
185
+ 持久化仍严格检查,失败时拒绝相应操作。
186
+
187
+ Force 不验证合并、不验收工作、不证明物理静止、不丢弃脏数据,也不隐含 `--abandon`。
188
+ 它保留所选处置及原始 Publication/完成证据。未验证的本地提交和无法安全释放的资源
189
+ 仍有明确 owner 且可追溯。清理失败不回滚归档;迟到的运行时事件仍作为来源证据,
190
+ 不恢复 Task 或结算未知输入。
191
+
192
+ ### 清理前先读结果
193
+
194
+ `yui task show <task> --json` 暴露 `data.archive.warnings`、
195
+ `data.archive.retainedResources` 和 `data.archive.cleanupEvents`。
196
+ `yui task context <task> --json` 保留原始记录与事件;
197
+ `yui task remote-delivery <task> --json` 单独报告交付。警告包含历史清理尝试;
198
+ 保留引用描述当前所有权,不是第二套清理队列。
199
+
200
+ 归档结果中的 `archived=true` 证明已归档,不证明清理全部成功。即使 `cleanupFinished`
201
+ 也只代表前台清理已走完,不代表资源全部移除。重复归档只报告当前事实,不重放清理。
202
+ 检查后通过显式的精确 owner 资源操作进行安全清理;不隐含后台重试或更广泛的删除
203
+ 权限。两条归档路径都保留 Task 历史与恢复信息。已归档的 Task 不能重开。
204
+
205
+ 资源 GC 是独立、显式启用的隔离路径。同一 runtime 子树只移动一次,由父目录
206
+ 回执负责恢复完整内容;重复的子目录 registry 记录在同一事务内移除。
207
+ 独立 Git worktree 或仍需保留的子资源会阻止移动其父目录,不删除 Task 记录或成果。
208
+ Session 进程归属只读取 SQLite `session_owners`,并校验存活 PID 和启动身份;
209
+ 旧 JSON owner 目录不再作为并行来源。
210
+
211
+ 清理计划不是执行授权。Apply 与 purge 在现有 SQLite 写锁内重读 Task 状态、
212
+ 受管工作区、active Run 和未结算 Job,并保持写锁直到有界文件操作与 registry
213
+ 更新完成。Task 重新打开或新增持久所有者会阻止隔离、删除;无法证明安全时
214
+ 保留资源并给出原因。已经隔离、随后重新打开的资源可以恢复。
215
+ 不增加后台重试 worker 或第二套持久所有权协议。
216
+
217
+ `yui task archive-preflight <task> (--integrated|--abandon) [--force] [--json]`
218
+ 一次读取归档条件、交付覆盖与各精确 owner 的清理检查。归档前后都可用,获授权的
219
+ Task Leader reader 也可读取。这里的 `--force` 仅选择要检查的行为,不会归档、
220
+ 准备工作区、刷新 Git index、停止 Session、获取维护锁、抓取远端或保存清理计划。
221
+
222
+ 每项阻断/未知检查都有资源、原因码、预期/观察值、来源引用及既有检查/处置命令。
223
+ 无权访问的 Task 外路径会脱敏。报告区分 Candidate 工作区缺失、工作区身份/元数据/
224
+ 路径变化、冻结 commit 缺失、HEAD 变化、脏 worktree、Git 注册缺失或锁定、结果未集成、
225
+ 交付未覆盖、owner 未结算和执行未知。状态检查禁用可选 index 写入及 filesystem-monitor
226
+ 钩子;若已跟踪文件的属性选择了配置中的 clean/process filter(包括已初始化的 submodule),则返回
227
+ `git-status-requires-filter` 未知诊断,不执行程序,也不绕过规范化猜测干净/脏状态。
228
+ 历史 Candidate 路径保持不可变。路径差异即使
229
+ 符合早期布局迁移的形状,也不单独证明安全迁址;没有确切映射时只报告差异并保留资源,
230
+ 不会改写历史或放宽 commit/owner 保护。
231
+
232
+ 预检是观察,不是删除凭据。清理会重新读取同一组检查,Git 删除时再验证身份和脏状态。
233
+ Task-main clone 在子工作区清理前存在关联 Git 注册是正常现象,但移除 clone 前它们必须
234
+ 已释放。归档会保留失败 Integration 工作区中新出现的脏文件;独立的显式 Integration
235
+ 清理命令保留既有的可丢弃冲突现场合同。force 清理完成只表示这次前台尝试结束,不表示
236
+ 全部资源已释放;当前保留引用、精确物理运行时证据与历史诊断仍是不同事实。
80
237
 
81
238
  清理前用每个命令的 `--help` 查看它确切的权限和选项;阅读一份生命周期文档不授权
82
239
  一次外部写入。
@@ -0,0 +1,101 @@
1
+ <p align="right"><strong>English</strong> | <a href="./task-discovery.zh-CN.md">简体中文</a></p>
2
+
3
+ # Bounded Task discovery
4
+
5
+ Agents discover candidates with `yui task list --json`, then
6
+ read the selected Task's Context and original Messages. The catalog is a
7
+ current read, not a summary database, a Context snapshot, an acknowledgement,
8
+ or an execution/acceptance decision.
9
+
10
+ The catalog is the only list contract; there is no `--view` selector or
11
+ `--verbose` full-history list. Internal interactive selectors retain their
12
+ complete `{id,title,status}` array and read only those columns. Web uses the
13
+ same query at `GET /api/dashboard`. The per-Task detail endpoint retains
14
+ execution, observability, usage and remote-delivery fields. Discovery itself
15
+ does not change persistent records.
16
+
17
+ ## Query and page contract
18
+
19
+ ```sh
20
+ yui task list --project project-1 --status active --limit 20 --json
21
+ yui task list --attention openInputs --json
22
+ yui task list --search "candidate title" --json
23
+ yui task context task-1 --json
24
+ yui task context inspect task-1 --store task --ref task-1 --digest <digest> --json
25
+ yui task message show task-1/message-1 --json
26
+ ```
27
+
28
+ `--project` accepts an exact Project ID. Search matches ID, title, tags and
29
+ Project name using SQLite substring comparison (ASCII case-insensitive;
30
+ non-ASCII characters compare literally). Default scope excludes archived
31
+ Tasks; `--all` or `--status archived` includes them. Counts declare that scope,
32
+ not an invisible global total. Status/search/Project/attention filters apply
33
+ to `total` and the returned Tasks, not the scope-wide attention summary.
34
+
35
+ The default limit is 20, maximum 100. Successful JSON responses, including the
36
+ CLI envelope, fit 32 KiB. UTF-8 summaries are at most 512 bytes; titles are
37
+ at most 256 bytes. Truncation is explicit. IDs, digests and cursors are never
38
+ truncated. Oversized mandatory metadata produces a bounded error, not a
39
+ non-progressing successful page. A missing Brief is reported as missing.
40
+
41
+ Order is ascending `(createdAt, id)` with SQLite binary ID ordering. Repeat
42
+ all filters and the limit with `--cursor <nextCursor>`. A null cursor ends the
43
+ page sequence; byte limits can end a page before its requested item limit.
44
+ The first page fixes the largest matching creation key. Newer creation keys
45
+ are excluded until refresh. Each later page reads current facts: lifecycle or
46
+ filter membership changes can affect the enumeration. This is not a frozen
47
+ snapshot, and unrelated runtime events do not invalidate a cursor.
48
+
49
+ Each Task and attention sample has a real Task Context ref
50
+ (`taskId, store, refId, revision, digest`). The digest covers the original
51
+ Task, not the clipped preview or Brief. Read Task Context for the current
52
+ Brief and use Context inspect for a digest-checked original. A changed digest
53
+ is rejected; a ref never grants authority or implies the requirement was read.
54
+
55
+ ## Attention without full history
56
+
57
+ Every page, including a filtered empty page, reports the same authorized
58
+ catalog's current attention. Each category contains a record/signal count,
59
+ affected-Task count, up to four exact Task refs, omitted-Task-ref count, and a
60
+ filter for enumerating all affected Tasks:
61
+
62
+ Start that attention query without the previous status/search/Project filters
63
+ and retain its `all` flag. This preserves the declared catalog scope, including
64
+ archived Tasks when explicitly included.
65
+
66
+ | Category | Current stored facts |
67
+ | --- | --- |
68
+ | `openInputs` | Open InputRequests |
69
+ | `pendingOperations` | Queued/running durable Jobs |
70
+ | `unknownOperations` | Jobs with `unknown-needs-attention` |
71
+ | `executionSignals` | For active/draft Tasks: live Runs, open WorkItems or accepted WorkItems retaining a current replicated group, unresolved/failed Integrations, pending/running/failed Reviews, Leader failure, and pending/processing Leader mailbox |
72
+
73
+ `executionSignals` is deliberately conservative discovery, **not** the detailed
74
+ execution-status classifier. Healthy live work is included so runtime identity,
75
+ stall, failed-work and recovery attention cannot be hidden behind pagination
76
+ or require scanning every Task's historical events. Counts must not be read as
77
+ failure counts. Open the affected Task for its precise execution state and
78
+ source records; no report text is parsed into status. Web explicitly labels
79
+ these facts and offers category navigation. Selected detail survives paging,
80
+ filtering and refresh; only the detail read can establish absence.
81
+
82
+ Task Leader Sessions see only their own Task. Assignment-scoped Workers and
83
+ Reviewers use existing authorized Run Context instead of whole-Task discovery;
84
+ the catalog rejects their request before counting. Global non-Operator and
85
+ incomplete managed identities are rejected. Historical Leader diagnostic reads
86
+ retain their original Task scope. A cursor is scope/filter-bound continuation,
87
+ not a credential. Read operations do not consume messages, acknowledge jobs,
88
+ wake Roles or query providers.
89
+
90
+ ## Cost boundary
91
+
92
+ SQLite queries existing catalog/status indexes and aggregates narrow facts
93
+ before selecting page rows. It does not decode all Task payloads, Runs,
94
+ Messages or Events into JavaScript, build all overviews and delete fields, or
95
+ construct per-Task Context. Only selected Tasks and bounded attention samples
96
+ are decoded and hashed for original refs.
97
+
98
+ Output and materialized rows are bounded. Database work still scales with
99
+ authorized Tasks and relevant index rows; search can inspect Task/Project JSON
100
+ inside SQLite. Exact refs still cost the selected original Task's payload size.
101
+ These are local cost boundaries, not constant-time or model-effect claims.