@zq-silk/yui 0.15.9 → 0.15.12

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 (160) hide show
  1. package/ARCHITECTURE.md +8 -4
  2. package/ARCHITECTURE.zh-CN.md +5 -2
  3. package/README.md +13 -5
  4. package/dist/agent/launchEnvironment.js +7 -0
  5. package/dist/agentRun/agentRun.js +3 -0
  6. package/dist/cli/commandCatalog.js +64 -16
  7. package/dist/cli/interactionPolicy.js +7 -3
  8. package/dist/cli/managedDiagnostics.js +1 -1
  9. package/dist/cli/updateOrchestrator.js +24 -1
  10. package/dist/cli/updatePorts.js +7 -3
  11. package/dist/cli/upgradeCommand.js +42 -2
  12. package/dist/cli.js +381 -107
  13. package/dist/commands/executionAuditCommands.js +10 -0
  14. package/dist/commands/globalRoleCommands.js +339 -4
  15. package/dist/commands/projectCommands.js +50 -22
  16. package/dist/commands/releaseCommands.js +18 -0
  17. package/dist/commands/taskActor.js +25 -0
  18. package/dist/commands/taskCommands.js +586 -96
  19. package/dist/commands/taskIntegrationCommands.js +19 -39
  20. package/dist/commands/taskIntegrationQueueCommands.js +1 -1
  21. package/dist/commands/taskOverviewCommand.js +4 -3
  22. package/dist/commands/taskPublicationAdoptCommand.js +127 -0
  23. package/dist/commands/taskPublicationCommands.js +11 -2
  24. package/dist/commands/taskPublicationVerifyCommand.js +23 -39
  25. package/dist/commands/taskRemoteDeliveryCommand.js +22 -11
  26. package/dist/commands/taskRoleRuntimeStatus.js +35 -0
  27. package/dist/context/runContextPack.js +3 -0
  28. package/dist/context/taskCatalog.js +187 -0
  29. package/dist/context/taskContext.js +55 -6
  30. package/dist/controller/agentHostObservation.js +155 -0
  31. package/dist/controller/clientRuntime.js +17 -2
  32. package/dist/controller/controller.js +14 -2
  33. package/dist/controller/fileSchedulerStoreAdapter.js +519 -25
  34. package/dist/controller/globalInputDelivery.js +132 -0
  35. package/dist/controller/jobControl.js +6 -2
  36. package/dist/controller/providerRetryAdmission.js +100 -0
  37. package/dist/controller/providerRetryDelivery.js +218 -0
  38. package/dist/controller/resourceInventory.js +14 -4
  39. package/dist/controller/resourceInventoryLinux.js +2 -6
  40. package/dist/controller/runtime.js +117 -7
  41. package/dist/controller/runtimeEventInbox.js +32 -3
  42. package/dist/controller/runtimeEventProcessor.js +26 -6
  43. package/dist/controller/runtimeHookRunFence.js +75 -19
  44. package/dist/controller/structuredProviderObservation.js +133 -70
  45. package/dist/coordination/workMailboxQueue.js +5 -0
  46. package/dist/execution/workItemExecutionProjection.js +1 -1
  47. package/dist/executor/agentExecutor.js +64 -4
  48. package/dist/executor/executorRegistry.js +3 -0
  49. package/dist/executor/fileRoleLaunchPlanner.js +78 -118
  50. package/dist/integration/deliveryObligation.js +2 -1
  51. package/dist/integration/gitIntegrationService.js +329 -386
  52. package/dist/integration/integrationAttempt.js +30 -4
  53. package/dist/integration/integrationQueueService.js +7 -7
  54. package/dist/integration/integrationSourceApplication.js +323 -0
  55. package/dist/lifecycle/exactRunTerminalization.js +4 -1
  56. package/dist/message/globalInterrupt.js +33 -0
  57. package/dist/message/globalProviderRetry.js +15 -0
  58. package/dist/message/inputControlResolution.js +106 -0
  59. package/dist/message/message.js +367 -0
  60. package/dist/message/messageContinuation.js +126 -3
  61. package/dist/message/taskInterrupt.js +34 -0
  62. package/dist/observability/executionAudit.js +19 -0
  63. package/dist/observability/orchestrationMetrics.js +1 -1
  64. package/dist/release/releaseHandover.js +22 -0
  65. package/dist/release/releaseWorkflowPorts.js +15 -7
  66. package/dist/repository/gitWorkspace.js +430 -107
  67. package/dist/repository/projectMaintenanceLock.js +75 -18
  68. package/dist/repository/taskWorkspaceCoordinator.js +182 -101
  69. package/dist/repository/taskWorkspacePreparer.js +205 -72
  70. package/dist/repository/workItemCandidateSnapshot.js +34 -0
  71. package/dist/repository/workspaceCleanupInspection.js +187 -0
  72. package/dist/resources/resourceDiscovery.js +3 -2
  73. package/dist/runtime/agentError.js +5 -3
  74. package/dist/runtime/agentHost.js +179 -82
  75. package/dist/runtime/agentHostCompatibility.js +127 -0
  76. package/dist/runtime/agentHostProtocol.js +53 -0
  77. package/dist/runtime/builtinAgentErrorMappers.js +91 -0
  78. package/dist/runtime/codexAppServerRuntime.js +34 -3
  79. package/dist/runtime/executionEnvironment.js +0 -19
  80. package/dist/runtime/launchBroker.js +6 -0
  81. package/dist/runtime/providerControl.js +5 -1
  82. package/dist/runtime/providerRetry.js +198 -0
  83. package/dist/runtime/providerRuntimeIdentity.js +28 -2
  84. package/dist/runtime/sessionReconciliation.js +4 -4
  85. package/dist/runtime/sessionTokenMetrics.js +15 -5
  86. package/dist/runtime/structuredProviderHost.js +6 -2
  87. package/dist/runtime/taskRuntimeIsolation.js +30 -6
  88. package/dist/runtime/taskUsageMetrics.js +275 -0
  89. package/dist/runtime/tmuxAdapters.js +5 -3
  90. package/dist/scheduler/activeRoleRunDelivery.js +12 -0
  91. package/dist/scheduler/leaderWakeupProcessor.js +5 -0
  92. package/dist/scheduler/operatorEvent.js +4 -0
  93. package/dist/scheduler/taskExecutionProjection.js +38 -6
  94. package/dist/scheduler/taskObservabilityProjection.js +6 -44
  95. package/dist/scheduler/wakeReason.js +7 -1
  96. package/dist/scheduler/wakeupQueue.js +2 -0
  97. package/dist/setup/setupCommand.js +26 -8
  98. package/dist/storage/homeLayout.js +130 -0
  99. package/dist/storage/migrations/collapseWorktreeLayout.js +963 -0
  100. package/dist/storage/migrations/integrationContinuation.js +104 -0
  101. package/dist/storage/migrations/unifyHomeLayout.js +925 -0
  102. package/dist/storage/sqliteSchema.js +167 -4
  103. package/dist/storage/sqliteStore.js +57 -1
  104. package/dist/storage/storageVersions.js +1 -1
  105. package/dist/storage/storeRpc.js +2 -0
  106. package/dist/storage/taskCatalog.js +123 -0
  107. package/dist/storage/taskStore.js +2 -0
  108. package/dist/storage/upgrade/upgradeOrchestrator.js +95 -2
  109. package/dist/task/archiveDiagnostics.js +129 -0
  110. package/dist/task/archivePreflight.js +124 -0
  111. package/dist/task/nextAction.js +44 -11
  112. package/dist/task/publicationAdoption.js +56 -0
  113. package/dist/task/publicationReference.js +10 -0
  114. package/dist/task/remoteDelivery.js +31 -16
  115. package/dist/web/assets/client/app.js +147 -17
  116. package/dist/web/assets/client/components.js +56 -13
  117. package/dist/web/assets/client/i18n.js +78 -4
  118. package/dist/web/assets/client/taskSurface.js +108 -1
  119. package/dist/web/assets/client/view.js +39 -8
  120. package/dist/web/assets/shell.js +29 -0
  121. package/dist/web/assets/styles/layout.js +8 -1
  122. package/dist/web/assets/styles/widgets.js +12 -0
  123. package/dist/web/webServer.js +131 -4
  124. package/dist/web/webSnapshot.js +16 -6
  125. package/dist/web/webTaskSurface.js +222 -5
  126. package/dist/workspace/cleanupInspection.js +63 -0
  127. package/dist/workspace/workItemChangeSetManager.js +111 -35
  128. package/docs/agent-result-consumption.md +4 -0
  129. package/docs/agent-result-consumption.zh-CN.md +3 -0
  130. package/docs/agent-runtime-drivers.md +7 -0
  131. package/docs/agent-runtime-drivers.zh-CN.md +5 -0
  132. package/docs/architecture/README.md +2 -0
  133. package/docs/architecture/README.zh-CN.md +3 -1
  134. package/docs/architecture/capabilities-and-resources.md +30 -5
  135. package/docs/architecture/capabilities-and-resources.zh-CN.md +23 -3
  136. package/docs/managed-turn-and-session-runtime.md +47 -0
  137. package/docs/managed-turn-and-session-runtime.zh-CN.md +40 -0
  138. package/docs/observability/README.md +62 -0
  139. package/docs/observability/README.zh-CN.md +47 -0
  140. package/docs/project-refresh.md +77 -0
  141. package/docs/project-refresh.zh-CN.md +59 -0
  142. package/docs/provider-retry.md +70 -0
  143. package/docs/release-workflow.md +39 -0
  144. package/docs/release-workflow.zh-CN.md +29 -0
  145. package/docs/sqlite-control-plane-design.md +223 -1
  146. package/docs/task-delivery.md +133 -13
  147. package/docs/task-delivery.zh-CN.md +99 -10
  148. package/docs/task-discovery.md +102 -0
  149. package/docs/task-discovery.zh-CN.md +86 -0
  150. package/docs/testing/verification-levels.md +40 -0
  151. package/docs/testing/verification-levels.zh-CN.md +23 -0
  152. package/i18n/README.zh-CN.md +13 -7
  153. package/package.json +1 -1
  154. package/skills/yui-leader/references/execution.md +154 -51
  155. package/skills/yui-leader/references/integration.md +52 -2
  156. package/skills/yui-operator/SKILL.md +19 -3
  157. package/skills/yui-reviewer/SKILL.md +4 -0
  158. package/skills/yui-runtime/SKILL.md +42 -0
  159. package/skills/yui-runtime/references/publication.md +42 -0
  160. package/skills/yui-runtime/references/recovery.md +24 -0
@@ -78,6 +78,26 @@ Surface contribution 由 Registry 当前获授权目录派生,没有第二份
78
78
  CLI contribution 使用能力原名称。Web panel 只接受受控 text、HTTP(S) link 或
79
79
  JSON query 描述,不接受作者脚本或任意 HTML。
80
80
 
81
- Web listener 由 Controller 启停,仅允许 loopback。浏览器写入通过现有领域
82
- 事务,错误区分确定未提交与提交结果未知。查询面板不能借浏览器身份执行 mutation
83
- 或插件管理。终端连接只 attach 客户端,不接管原生对话的持久所有权。
81
+ Web listener 由 Controller 启停,仅允许 loopback(`127.0.0.1`、`::1` 或
82
+ `localhost`;默认端口 4173)。`yui web` 打开的是本地 Surface,不是远程多用户
83
+ 服务或 OS 沙箱。
84
+
85
+ 页面提供 token,通过 `x-yui-web-token` 认证所有 HTTP API 读取与写入;服务端
86
+ 也检查 loopback Host。这些控制使用受信任本地用户身份,不由请求正文选择 Role。
87
+ 它们支持修改 Task 元数据、发送消息、回答 InputRequest,以及对 Task 或 Global
88
+ Role 显式 `queue / steer / interrupt`。受管 Agent 的能力 RPC 仍使用自身 Session
89
+ 认证与范围;浏览器 token 不是 Agent 或插件绕过这些边界的途径。
90
+
91
+ 只读 dashboard、Context 和查询面板投影与这些修改分开。查询面板不能借浏览器的
92
+ 用户权限修改状态或管理插件。Task 控制复用公开 CLI 领域命令;Global Role 控制复用
93
+ Global 处理器,但目前缺少已注册的顶层 CLI 路径。消息提交意图
94
+ (`record / discuss / develop`,默认 `discuss`)与
95
+ [输入时机](../managed-turn-and-session-runtime.zh-CN.md#输入时机queuesteer-与-interrupt)
96
+ 分开。传输接受不证明需求已实施或 Task 已验收。
97
+
98
+ 浏览器写入使用现有领域事务。错误区分已证明的 `not-submitted` 与 `unknown`;
99
+ 后者可能包含已经提交、但原生投递失败或未确认的 Message。选择恢复动作前先读
100
+ 原始 Message、控制回执和当前 Session,不盲目换 request ID 重发或切换动作。
101
+
102
+ 终端 WebSocket 校验 token 和同源握手。它只 attach 客户端,不接管对话的持久
103
+ 所有权,并遵守连接的 `readOnly` 标记。附着终端不授予控制其他 Session 的权限。
@@ -109,6 +109,53 @@ Resolve releases the claim after native-effect fences are clear. It neither
109
109
  replays the notification nor invents acceptance or completion. Independent
110
110
  Role work and legal local facts are not a Task-wide recovery lock.
111
111
 
112
+ ## Input timing: queue, steer and interrupt
113
+
114
+ Submission intent (`record / discuss / develop`) decides how a requirement is
115
+ routed. Input timing decides when an already-authorized input reaches a Role;
116
+ it does not activate a Task, expand an Assignment or upgrade planning authority.
117
+ The [authenticated Web controls](architecture/capabilities-and-resources.md#cli-and-web)
118
+ use the same three operations as the CLI.
119
+
120
+ | Action | Effect | What it does not prove |
121
+ | --- | --- | --- |
122
+ | `queue` | Saves a Message for the recipient's next legal opportunity, idempotently by request ID | Reading Context or accepting delivery is not implementation |
123
+ | `steer` | Saves a Message and attempts native steering of the exact current Turn | Unsupported, stale or unconfirmed steering is not a queued continuation |
124
+ | `interrupt` | Records a control request and asks the Provider to cancel the exact current Turn | A stop request is not a terminal or proof that background resources stopped |
125
+
126
+ Inspect the Session before selecting a live target:
127
+
128
+ ```sh
129
+ yui task role session inspect <task> <role>
130
+ yui task message queue <task> "<continuation>" --request-id <id> --to leader
131
+ yui task message steer <task> "<correction>" --request-id <id> --to leader --expected-target <turn>
132
+ yui task role interrupt <task> <role> --expected-target <turn> --request-id <id> [--then-message <task/message>]
133
+ ```
134
+
135
+ Worker/Reviewer messages retain their existing `--work-item` or `--review-round`
136
+ association. Reusing a request ID with different content or a different target
137
+ is a conflict. `steer` and `interrupt` never silently retarget, replace a Session,
138
+ kill a process or fall back to another action. No live managed Turn yields
139
+ `NO_ACTIVE_TURN`; stale targets and unsupported control remain explicit outcomes.
140
+
141
+ Bare interrupt creates no Message. Optional `--then-message` names an already-saved,
142
+ eligible input and reserves its next opportunity only after an exact terminal,
143
+ within the original Session/writer boundary. It is not a fourth action or a way
144
+ to replay accepted, pending or unknown steering. A conclusive non-delivery can
145
+ permit an explicit new control choice when the user's intent authorizes it;
146
+ uncertainty cannot.
147
+
148
+ Global Roles use the same three actions with their own owner and Session,
149
+ without inventing a Task or Run. The local-user Web surface exposes them through
150
+ the shared Global Role handler. There is a current CLI availability gap:
151
+ `src/cli.ts` implements `yui role message queue|steer` and `yui role interrupt`,
152
+ but `src/cli/commandCatalog.ts` does not register the top-level `role` command,
153
+ so public CLI routing rejects these paths as unknown. They are not usable CLI
154
+ examples; report this gap rather than fabricating a Task/Run or borrowing the
155
+ browser's user authority. New controlled Global Sessions use the Host console.
156
+ A live unmanaged Session is not silently adopted; an explicit Session lifecycle
157
+ action is needed first.
158
+
112
159
  ## Exact results
113
160
 
114
161
  The native terminal settles only the matching execution. Known native Turn IDs
@@ -94,6 +94,46 @@ yui task wake resolve <task> <wake> --reason <quiescence-evidence>
94
94
  resolve 在原生效果围栏清除后释放该认领。它既不重放通知,也不编造接受或完成。独立的
95
95
  Role 工作和合法的本地事实不是一把 Task 范围的恢复锁。
96
96
 
97
+ ## 输入时机:queue、steer 与 interrupt
98
+
99
+ 提交意图(`record / discuss / develop`)决定需求如何路由。输入时机决定一条已经
100
+ 获授权的输入何时到达 Role;它不激活 Task、不扩大 Assignment,也不提升 planning
101
+ 权限。[经认证的 Web 控制](architecture/capabilities-and-resources.zh-CN.md#cli-与-web)
102
+ 与 CLI 使用同样的三种操作。
103
+
104
+ | 动作 | 效果 | 不证明什么 |
105
+ | --- | --- | --- |
106
+ | `queue` | 保存 Message,等待收件人的下一个合法机会,按 request ID 幂等 | 读取 Context 或接受投递不等于实施 |
107
+ | `steer` | 保存 Message,并尝试原生 steer 精确的当前 Turn | 不受支持、目标陈旧或未确认的 steer 不等于排队延续 |
108
+ | `interrupt` | 记录控制请求,请 Provider 取消精确的当前 Turn | 停止请求不等于终态,也不证明后台资源已停止 |
109
+
110
+ 选择实时目标前先检查 Session:
111
+
112
+ ```sh
113
+ yui task role session inspect <task> <role>
114
+ yui task message queue <task> "<continuation>" --request-id <id> --to leader
115
+ yui task message steer <task> "<correction>" --request-id <id> --to leader --expected-target <turn>
116
+ yui task role interrupt <task> <role> --expected-target <turn> --request-id <id> [--then-message <task/message>]
117
+ ```
118
+
119
+ Worker/Reviewer 消息保留既有的 `--work-item` 或 `--review-round` 关联。同一个
120
+ request ID 若换正文或目标会产生冲突。`steer` 与 `interrupt` 不会静默改目标、
121
+ 替换 Session、杀进程或回退到另一动作。没有活动受管 Turn 时返回 `NO_ACTIVE_TURN`;
122
+ 陈旧目标与不受支持的控制也保持为显式结果。
123
+
124
+ 裸 interrupt 不创建 Message。可选的 `--then-message` 引用一条已保存且符合交接条件
125
+ 的输入,只在精确终态之后、原 Session/writer 边界内保留下一次机会。它不是第四种动作,
126
+ 也不能用来重放已接受、待确认或未知的 steer。明确证明未投递时,若用户意图允许,
127
+ 可以显式选择新的控制;不确定性不允许重放。
128
+
129
+ Global Role 使用同样的三种动作和自己的 owner、Session,不虚构 Task 或 Run。
130
+ 本地用户 Web Surface 通过共享 Global Role 处理器暴露这些动作。目前 CLI 存在可用性
131
+ 缺口:`src/cli.ts` 实现了 `yui role message queue|steer` 和 `yui role interrupt`,
132
+ 但 `src/cli/commandCatalog.ts` 没有注册顶层 `role`,因此公开 CLI 路由会拒绝这些路径,
133
+ 报告 unknown command。它们不是可用的 CLI 示例;应报告该缺口,不虚构 Task/Run 或
134
+ 借用浏览器用户权限。新的受控 Global Session 使用 Host console。活动的非受管 Session
135
+ 不会被静默采用,需要先执行显式的 Session 生命周期操作。
136
+
97
137
  ## 精确结果
98
138
 
99
139
  原生终态只结算相匹配的那次执行。已知的原生 Turn ID 必须匹配;串行流可以使用已证明的
@@ -81,3 +81,65 @@ raw Provider history merely to explain a status.
81
81
  Start with exact read-only records. Process changes, cancellation, grant updates
82
82
  and resource cleanup require the relevant explicit action and scope. A generic
83
83
  diagnostic request does not authorize live-model, shared or production tests.
84
+
85
+ ## Task usage and time
86
+
87
+ Task overview, Web Task/WorkItem cards and `execution audit` use the same pure
88
+ projection of authorized Task events. Reading never samples a Provider or opens
89
+ raw transcripts. There is no new metric store, migration, price table or budget
90
+ policy. Existing history remains readable.
91
+
92
+ Each metric has `value`, `status` (`known`, `partial`, `unknown`) and `reasons`.
93
+ Unknown is `null`, not zero. A known zero requires actual numeric evidence.
94
+ Partial is an observed subtotal, not a complete bill or guaranteed monotonic
95
+ lower bound. Coverage names the observed Session identities, source/semantics
96
+ and evidence cutoff; it is not a percentage of an unknowable Provider total.
97
+ The declared basis is Task-fenced, observed sources only.
98
+ JSON consumers read `cost.tokens.value` and `cost.toolCalls.value` with their
99
+ status/reasons, replacing the numeric placeholders and observable flags.
100
+ `elapsedSeconds` and `executionSeconds` replace the misleading Group-sum
101
+ `wallClockSeconds`; this changes a read projection, not persistent storage.
102
+
103
+ - Request usage reuses the Session reducer: stable request identity, latest
104
+ received revision, input plus output, no extra addition of cache/reasoning
105
+ subsets. Missing boundaries, mixed semantics and cumulative rollback are not
106
+ guessed. Remaining context is capacity, never consumption.
107
+ - Replaced Sessions remain in the lifetime view. A nonzero first cumulative
108
+ snapshot is an excluded baseline: it may predate the Task. Later comparable
109
+ increments are partial; one nonzero snapshot alone yields unknown Task usage.
110
+ A zero baseline supports the subsequent counter. JSON also exposes raw
111
+ Session counters separately; they are not additional Task consumption.
112
+ - Direct Leader chat can contribute without a Run or WorkItem. WorkItems
113
+ receive only request usage whose revisions share one exact, matching Run
114
+ binding. Cumulative counters are not apportioned. Raw whole-Session totals
115
+ are not exposed as WorkItem usage. Task totals need not equal WorkItem sums.
116
+ - Child counters are excluded because the current contract cannot prove they
117
+ are additional to the parent. Child evidence marks coverage partial. Conflicting
118
+ Role ownership of one native counter is unknown, not two independent totals.
119
+ - Tool counts deduplicate retained exact native Session/Turn/operation identities,
120
+ including failures. Operation history is compacted, so this is always partial
121
+ when evidence exists and unknown otherwise. Absence never proves zero tools.
122
+
123
+ **Task elapsed** runs from Task creation (including planning and waiting) to its
124
+ recorded completion, retirement or cancellation, or to the read time if active.
125
+ An archived Task keeps its original endpoint; missing terminal evidence is
126
+ unknown. Group count is irrelevant.
127
+
128
+ **Observed native execution sum** merges overlapping complete Turn intervals
129
+ within one native resource and adds independent parallel resources. Two
130
+ independent ten-second intervals can total twenty seconds during ten seconds of
131
+ elapsed time. It is not CPU/GPU time. Since Turn history is compacted, this is
132
+ partial; missing start/end and live Turns are excluded, never extended indefinitely.
133
+ Subsecond precision is retained. WorkItem cards do not substitute Group duration
134
+ for either measure.
135
+
136
+ The audit `usage` section is explicitly **Task lifetime** even when `--since` or
137
+ `--until` filters other sections. It does not offer window consumption; filtering
138
+ cumulative snapshots first would mislabel historical usage as window usage.
139
+ Its existing AgentRun-duration section remains a separately labeled Run metric.
140
+
141
+ Deterministic fixtures cover the shared reducer and CLI/Web/audit semantics.
142
+ They do not establish live Provider completeness. Built-in normalization supports
143
+ Codex cumulative and Claude request observations when supplied; this delivery
144
+ does not collect real-model billing evidence or assert Provider behavior was
145
+ live-tested.
@@ -69,3 +69,50 @@ Telemetry 和缓存是诊断材料,不是 Task 真相,也不是 transcript
69
69
 
70
70
  从精确的只读记录开始。进程变更、取消、grant 更新和资源清理都需要相应的显式动作
71
71
  与范围。一个笼统的诊断请求不授权真实模型、共享或生产环境的测试。
72
+
73
+ ## Task 用量与耗时
74
+
75
+ Task overview、Web Task/WorkItem 卡片和 `execution audit` 共用授权 Task
76
+ 事件的纯读投影。读取不采样 Provider、不打开原始 transcript;没有新增指标存储、
77
+ 迁移、价格表或预算策略,既有历史仍可读。
78
+
79
+ 每项指标带 `value`、`status`(`known`、`partial`、`unknown`)和 `reasons`。
80
+ 未知为 `null`,不是零;真实零必须有数值证据。部分值是已观测小计,不是完整账单,
81
+ 也不保证是单调增长的下界。覆盖说明包括已观测 Session 身份、来源/计数语义和
82
+ 证据截止点,不对不可知的 Provider 总量伪造覆盖百分比。口径是 Task 围栏内的
83
+ 已观测来源。
84
+ JSON 使用方改读 `cost.tokens.value`、`cost.toolCalls.value` 及其状态/原因,
85
+ 不再读取数字占位和 observable 标志。`elapsedSeconds`、`executionSeconds`
86
+ 替代含义错误的 Group 求和 `wallClockSeconds`;这是读投影变更,不是持久存储变更。
87
+
88
+ - 请求用量复用 Session reducer:按稳定请求身份取最后收到的修订,累加输入与
89
+ 输出,缓存/推理子项不重复增加。缺失边界、混合语义、累计回退不猜测;剩余
90
+ 上下文是容量,不是消费。
91
+ - Session 替换不抹去历史。首次非零累计快照可能早于 Task,因此作为排除基线;
92
+ 后续可比增量为部分值,仅一个非零快照时 Task 用量未知。零基线可支持后续
93
+ 累计值。JSON 单独暴露原始 Session 计数,它不是额外的 Task 消费。
94
+ - Leader 直聊不需要伪造 Run/WorkItem。WorkItem 仅接收各次修订均绑定同一
95
+ 精确、匹配 Run 的请求用量;累计值不摊派,整个 Session 的原始计数不冒充
96
+ WorkItem 用量。Task 总量不必等于 WorkItem 小计之和。
97
+ - 当前合同无法证明子执行计数在父统计之外,因此排除子计数并将覆盖标为部分。
98
+ 多个 Role 对同一原生计数器的归属冲突为未知,不当成两份独立总量。
99
+ - 工具次数按保留的精确原生 Session/Turn/operation 身份去重,失败调用也计一次。
100
+ 工具历史已压缩,有证据时只能是部分次数;无证据为未知,不能推出零调用。
101
+
102
+ **任务历时**从 Task 创建(含规划和等待)到记录的完成、退役或取消时间;
103
+ 活动 Task 截止本次读取时间。归档保留原终点,终态证据缺失则未知,与 Group
104
+ 数量无关。
105
+
106
+ **已观测原生执行累计**合并同一原生资源上起止完整、彼此重叠的 Turn 区间,
107
+ 再相加独立并行资源。两个独立执行各十秒,可以在十秒自然时间内累计二十秒。
108
+ 它不是 CPU/GPU 时间。由于 Turn 历史已压缩,该指标为部分值;缺少起止证据和
109
+ 运行中的 Turn 不计入,不无限延长。保留不足一秒的精度,WorkItem 卡片不再用
110
+ Group 时长替代上述含义。
111
+
112
+ 即使 `--since`、`--until` 过滤其他审计部分,`usage` 部分仍明确为 **Task 全生命周期**。
113
+ 首版不提供窗口消费,不能先过滤累计快照,再把历史消费称为窗口用量。
114
+ 既有 AgentRun 时长部分保留为单独标明的 Run 指标。
115
+
116
+ 确定性 fixture 验证共享 reducer 和 CLI/Web/audit 语义,不证明真实 Provider 的
117
+ 覆盖完整性。内置归一化支持来源所提供的 Codex 累计观察和 Claude 请求观察;
118
+ 本次交付不采集真实模型账单证据,也不声称已实测真实 Provider 行为。
@@ -0,0 +1,77 @@
1
+ <p align="right"><strong>English</strong> | <a href="./project-refresh.zh-CN.md">简体中文</a></p>
2
+
3
+ # Project refresh
4
+
5
+ `yui project refresh <project>` refreshes the canonical Project checkout from
6
+ the Project's configured remote and stable branch. Stable and development
7
+ branches must match. The per-Project maintenance fence covers the operation;
8
+ Task workspaces and their recorded bases are not refreshed by this command.
9
+
10
+ ## Two separate facts
11
+
12
+ The checkout HEAD and a local remote-tracking ref are distinct observations.
13
+ Refresh fetches the exact branch into a unique temporary ref, compares its
14
+ commit with the remote's advertised commit, and permits only a clean
15
+ fast-forward from the original HEAD on the stable branch. Configured `HEAD`
16
+ is resolved through the remote's symbolic HEAD, never a guessed default branch.
17
+
18
+ When exactly one existing Git remote and fetch mapping manages a safe tracking
19
+ destination, refresh also updates that destination to the verified commit.
20
+ This runs even when HEAD is already current, repairing stale tracking refs
21
+ that would otherwise make ordinary Git show a false `ahead` count.
22
+
23
+ The mapping uses Git's effective fetch URL, including `insteadOf` resolution,
24
+ and full-ref exact or one-star fetch refspecs with negative exclusions. It
25
+ does not assume `origin` or `refs/remotes/<remote>/<branch>`. A configured
26
+ destination under `refs/remotes/` can be created if absent. Multiple matching
27
+ remotes/URLs, multiple destinations, another source managing the same target,
28
+ unsupported refspecs, local-branch/tag destinations and symbolic destinations
29
+ are explicitly unmanaged. Push URLs never establish fetch identity.
30
+
31
+ Only the unique mapped ref can change. Fetch does not opportunistically update
32
+ other tracking refs, fetch/prune tags, recurse into submodules, or write
33
+ `FETCH_HEAD`. Remote/upstream configuration is never rewritten. Read-only
34
+ tracking observations use the same mapping proof and return no tracking match
35
+ when it is not uniquely established.
36
+
37
+ ## Results and concurrent changes
38
+
39
+ - `fromCommit`, `toCommit` and `changed` describe HEAD; `changed: false` does
40
+ not imply that no tracking repair occurred.
41
+ - `tracking.status` is `updated` or `current` for a synchronized target,
42
+ with its exact ref and old/new object IDs.
43
+ - `tracking.status: unmanaged` includes a reason. HEAD can still refresh
44
+ successfully, but this is not a claim of tracking consistency.
45
+ - Once work has started, a failed refresh uses the existing nonzero
46
+ `RUNTIME_ERROR` channel. JSON `details.refresh` retains observed HEAD,
47
+ the verified commit when available, and the tracking result (`failed` for
48
+ a managed target). Missing/unreadable observations are nullable. Text
49
+ errors also state the actual partial result. Preconditions can fail
50
+ before any mutation without a partial-result record.
51
+
52
+ Refresh rechecks the mapping, cleanliness, branch and HEAD around the update.
53
+ A Git ref transaction verifies the stable branch and compares the tracking
54
+ target against its captured old value (or absence) before writing it. A local
55
+ ref race, changed mapping, divergent checkout or fetched/advertised mismatch
56
+ fails visibly. After a fast-forward, a failed tracking update leaves HEAD at
57
+ its actual new commit; it never rolls back or overwrites a competing ref.
58
+ There is no automatic retry, replay or background synchronizer.
59
+
60
+ Temporary-ref cleanup compares the known fetched object before deletion.
61
+ An unsuccessful cleanup reports the retained ref; an interrupted/failed fetch
62
+ can report the exact temporary namespace to inspect. These are Git diagnostics,
63
+ not durable Task progress or a new recovery protocol.
64
+
65
+ The maintenance fence serializes Yui maintenance, not arbitrary external Git
66
+ commands or user edits. Checks and Git locks bound the observed operation;
67
+ they do not promise that local or remote state cannot change after observation.
68
+ Ordinary `git status` loses the false `ahead` count only when the current
69
+ branch's upstream is the tracking ref refreshed here. A different/missing
70
+ upstream is left untouched and carries no such promise.
71
+
72
+ ## Scope of adoption
73
+
74
+ This operation adds no persistent Yui schema or migration. Installing code
75
+ that implements it does not itself refresh a real Project. A normal authorized
76
+ refresh applies the behavior; Task completion, integration, publication and
77
+ archive remain separate operations.
@@ -0,0 +1,59 @@
1
+ <p align="right"><a href="./project-refresh.md">English</a> | <strong>简体中文</strong></p>
2
+
3
+ # Project refresh
4
+
5
+ `yui project refresh <project>` 按 Project 配置的 remote 和 stable branch 刷新
6
+ 规范 checkout。stable 与 development branch 必须一致。操作全程持有 per-Project
7
+ maintenance fence;不会刷新 Task 工作区或改写其记录的基线。
8
+
9
+ ## 两个独立事实
10
+
11
+ checkout HEAD 与本地 remote-tracking ref 是不同的观察。refresh 将精确分支获取到
12
+ 唯一临时 ref,比较获取到的提交与远端 advertised commit,仅允许从原 HEAD 在干净的
13
+ 稳定分支上 fast-forward。配置为 `HEAD` 时解析远端 symbolic HEAD,不猜默认分支。
14
+
15
+ 当且仅当一个既有 Git remote 及其 fetch 映射管理安全的 tracking 目标时,refresh
16
+ 同时将该目标更新到已验证的提交。HEAD 已最新也执行这一检查,修复会让普通 Git
17
+ 错误显示 `ahead` 的陈旧 tracking ref。
18
+
19
+ 映射使用 Git 生效的 fetch URL(包括 `insteadOf` 解析),支持完整 ref 名称的
20
+ 精确或单星号 fetch refspec,并处理负向排除。不假定 `origin` 或
21
+ `refs/remotes/<remote>/<branch>`。已配置的 `refs/remotes/` 目标缺失时可以创建。
22
+ 多个匹配 remote/URL、多个目标、其他来源也管理同一目标、不支持的 refspec、
23
+ 本地分支/标签目标和符号引用目标,均明确标为未管理。push URL 不证明 fetch 身份。
24
+
25
+ 只允许修改唯一映射目标。fetch 不顺带更新其他 tracking refs、不获取/修剪标签、
26
+ 不递归获取 submodule、不写入 `FETCH_HEAD`,也不改 remote/upstream 配置。
27
+ 只读 tracking 观察复用相同映射证明;无法唯一确证时不返回 tracking 匹配。
28
+
29
+ ## 结果与竞争
30
+
31
+ - `fromCommit`、`toCommit`、`changed` 描述 HEAD;`changed: false` 不代表没有
32
+ 发生 tracking 修复。
33
+ - `tracking.status` 为 `updated` 或 `current` 时,目标已同步,并包含精确 ref
34
+ 和新旧对象 ID。
35
+ - `tracking.status: unmanaged` 带有原因。HEAD 仍可刷新成功,但不声称 tracking
36
+ 一致。
37
+ - 操作开始后失败,沿用非零的 `RUNTIME_ERROR` 通道。JSON 的 `details.refresh`
38
+ 保留实际观察到的 HEAD、可用时的已验证提交和 tracking 结果(受管目标为
39
+ `failed`)。缺失或不可读的观察可为 null。文本错误也说明实际部分结果。
40
+ 变更前的前置条件失败可以不带部分结果。
41
+
42
+ refresh 在更新前后复查映射、干净状态、分支与 HEAD。Git ref 事务同时验证稳定分支,
43
+ 并以捕获的旧值(或不存在)比较后写入 tracking 目标。本地 ref 竞争、映射变化、
44
+ checkout 分歧或 fetched/advertised 不一致都会显式失败。ff 之后 tracking 更新失败,
45
+ HEAD 保留实际的新提交;不会回滚或覆盖竞争方的 ref。不自动重试、重放,也没有后台
46
+ 同步器。
47
+
48
+ 清理临时 ref 时比较已知 fetched 对象后才删除。清理失败报告保留的 ref;获取中断或
49
+ 失败可报告供检查的精确临时命名空间。这些是 Git 诊断,不是持久 Task 进度或新恢复协议。
50
+
51
+ maintenance fence 串行化 Yui 维护,不锁住任意外部 Git 命令或用户编辑。检查和 Git
52
+ 锁约束本次观察,不承诺观察之后本地或远端不再变化。只有当前分支 upstream 指向此次
53
+ 刷新的 tracking ref,普通 `git status` 才会消除相应虚假 `ahead`。不同或缺失的
54
+ upstream 保持原样,不作这一承诺。
55
+
56
+ ## 采用边界
57
+
58
+ 本操作不新增 Yui 持久 schema 或迁移。安装实现代码不等于刷新真实 Project;
59
+ 正常获授权的 refresh 才应用此行为。Task 完成、集成、发布和归档仍是独立操作。
@@ -0,0 +1,70 @@
1
+ # Bounded Provider recovery
2
+
3
+ Yui can continue an owned input after a positively identified transient Provider
4
+ failure without discarding its Session or local work. The Driver supplies failure
5
+ and native-state evidence; the Controller schedules and atomically admits the
6
+ next input. Agents still own semantic recovery and acceptance.
7
+
8
+ - At most five automatic attempts after the initial failure, within ten minutes.
9
+ - Exponential windows start at five seconds and cap at sixty seconds, with
10
+ 50–100% jitter. A trusted Retry-After is a minimum, with positive jitter.
11
+ A wait beyond the remaining deadline ends automatic recovery.
12
+ - Busy/admission waiting does not consume a model attempt. Acceptance, heartbeat
13
+ and partial output do not reset the streak. Only the matching successful
14
+ native terminal ends the chain; audit history remains.
15
+ - A rejected input retains its original durable reference. An accepted failed
16
+ Turn gets a new Turn in the same Session with a system recovery instruction:
17
+ inspect existing work and receipts and continue only unfinished actions.
18
+ - Unknown acceptance is never replayed. Existing exact-identity reconciliation
19
+ may supply the missing outcome. Restarting the Controller does not reset the
20
+ counter, deadline, pending input or writer fence.
21
+ - An explicit manual retry of the same Run retains its recovery lineage,
22
+ automatic count and original deadline. It is not charged as an automatic
23
+ attempt, but a further failure cannot replenish automatic allowance.
24
+
25
+ The records live on the existing Provider binding, with indexed pending-record
26
+ reads and the existing Controller deadline timer. There is no retry Task status,
27
+ second queue, automatic Session replacement, account-wide circuit breaker or
28
+ model switch. The original failed AgentRun stays failed; ordinary Run/Review
29
+ retry primitives own its successor and keep the original ReviewRound.
30
+
31
+ ## Inspect and control
32
+
33
+ Task Sessions:
34
+
35
+ ```sh
36
+ yui task role session retry <task> <role> show
37
+ yui task role session retry <task> <role> cancel
38
+ yui task role session retry <task> <role> disable
39
+ yui task role session retry <task> <role> enable
40
+ ```
41
+
42
+ Global Sessions use `yui session retry <role> show|cancel|disable|enable`.
43
+ This narrow existing Session surface does not register the unrelated
44
+ top-level Global `role` command family.
45
+
46
+ The same projection appears in Context, Session inspection and the Web role
47
+ panel. `cancel` withdraws this recovery chain; `disable` also disables future
48
+ chains on the current Provider binding. Neither interrupts an admitted Turn.
49
+ `enable` does not replay historical failures. Existing Task/Role authority applies.
50
+
51
+ ## Supported boundary and adoption
52
+
53
+ Current controlled Codex Hosts advertise exact recovery support. The native
54
+ preflight checks the latest failed Turn identity for accepted-input recovery
55
+ and a complete empty background-terminal page; ordinary `systemError` admission
56
+ remains closed. Missing protocol methods, a changed/active Turn, unresolved
57
+ background execution or a changed Session/configuration require inspection,
58
+ not automatic cleanup. Native chats without an owned input reference, old Hosts,
59
+ and Adapters without this proof capability are not automatically replayed.
60
+ Claude/ACP retain their normal error and explicit recovery behavior.
61
+
62
+ Storage transition 26→27 adds optional recovery/input facts and indexes without
63
+ scanning or scheduling old failures. Adoption requires the normal explicitly
64
+ authorized release/upgrade and compatible Host lifecycle. Building or completing
65
+ this Task does not enable the change in an already-running shared instance.
66
+
67
+ Deterministic checks use disposable SQLite Homes, fake native protocol and
68
+ injected time; they do not establish real-provider behavior or idempotency of
69
+ arbitrary external tools. External effects still require their normal authority
70
+ and receipt/idempotency protections.
@@ -74,6 +74,45 @@ Candidate and Task-final ReviewRound records must all carry that one contract.
74
74
  Conflicting records fail closed; there is no rebind event, recovery command, or
75
75
  second contract state machine.
76
76
 
77
+ ## Persistent Agent Host compatibility
78
+
79
+ A running Host keeps its original Endpoint implementation. It records exact
80
+ Session/attempt/native-Turn facts in the existing durable Inbox before contacting
81
+ the Controller; only the current Controller resolves Run ownership, validates
82
+ authority/workspace/lifecycle/history, and commits the result. An Inbox file is
83
+ not acceptance. Files are consumed only after commit, so downtime or a lost ACK
84
+ does not replay user input or model work.
85
+
86
+ Startup facts use the exact Run identity from the redeemed launch payload, not
87
+ the long-lived Session environment. This preserves pre-adoption evidence even
88
+ when the frozen Run workspace differs from the Role's default; later activity
89
+ and terminal facts still resolve solely by their own native input identities.
90
+
91
+ The supported Host boundary is control `yui-agent-host/v5`, event source
92
+ `yui-agent-host-events/v1`, and Controller RPC version 4. Hosts advertising
93
+ `storage=controller-owned` do not open the Home database, including for process
94
+ custody, native account locations, or execution-environment checks. Home 22
95
+ declares the additive Inbox source envelope; valid older Inbox v1 facts and
96
+ domain history remain readable. Future changes must retain this wire boundary
97
+ or reject incompatible live producers before changing storage. CLI wrapper
98
+ refresh and a successful new `doctor` are not Host compatibility proofs.
99
+
100
+ `upgrade`, the staged target's `update` preflight, and release activation inspect
101
+ live Host capabilities independently. An old Host without this capability,
102
+ including an idle Host or one whose response is unconfirmed, blocks adoption.
103
+ Checks are repeated at the existing fenced/quiesced handover boundary before
104
+ migration or promotion. No Host is killed, replaced, or reloaded by these checks.
105
+ Let existing work settle and preserve original pending input/result evidence;
106
+ then an authorized Operator can select a safe Session replacement/cleanup before
107
+ retrying. Installing this change cannot repair already-loaded legacy Host code
108
+ or collect a terminal that that code never durably emitted.
109
+
110
+ `task role status`, `task role list`, and `task role session inspect` expose Host
111
+ reporting alongside durable Run state. Pending native results or known reporting
112
+ failures require attention; they do not mean the Provider failed, the Run ended,
113
+ or the work was accepted. The Host's live diagnostics inspect only its own event
114
+ file identities and never parse or quarantine another producer's newer payload.
115
+
77
116
  ## CLI and Controller release boundary
78
117
 
79
118
  The global `yui` command is the stable user and managed-Session interface. It
@@ -59,6 +59,35 @@ Session 使用普通的 `yui` 命令,兼容性由协议和存储身份检查
59
59
  Task-final 的 ReviewRound 记录必须全部携带那唯一的合同。冲突的记录 fail closed;
60
60
  不存在重新绑定事件、恢复命令或第二套合同状态机。
61
61
 
62
+ ## 常驻 Agent Host 升级兼容
63
+
64
+ 存活 Host 保持原 Endpoint 实现,先把准确的 Session/attempt/nativeTurn 事实写入现有
65
+ 持久 Inbox,再联系 Controller。只有当前 Controller 解析 Run 归属、校验权限、工作区、
66
+ 生命周期与历史关联并提交结果。Inbox 文件不代表接受;提交后才确认消费,断线或丢失
67
+ ACK 不会重放用户输入或模型工作。
68
+
69
+ 启动事实从已兑现的 launch payload 取得准确 Run 身份,不把 Run 固定到长期 Session
70
+ 环境。即使冻结的 Run 工作区不同于 Role 默认值,登记前的证据也能保留;后续活动和
71
+ 终态仍只按各自的原生输入身份解析归属。
72
+
73
+ 支持边界为控制协议 `yui-agent-host/v5`、事件来源协议 `yui-agent-host-events/v1`、
74
+ Controller RPC 版本 4。声明 `storage=controller-owned` 的 Host 不打开 Home 数据库,
75
+ 包括进程归属、原生账号位置和执行环境校验。Home 22 声明 Inbox 的新增来源字段,
76
+ 不改写有效历史事实与业务记录。后续版本要么保留该线协议,要么在修改存储前拒绝不兼容
77
+ 的存活生产者。刷新 Session CLI wrapper 或新 `doctor` 成功都不能证明旧 Host 兼容。
78
+
79
+ `upgrade`、`update` 的目标版本预检及 release activation 独立检查存活 Host。
80
+ 没有此能力的 legacy Host(包括 idle)以及兼容响应不确定的 Host 都阻止采用;
81
+ 在既有隔离/静默交接边界再次检查,先于迁移或发布切换。检查不会 kill、替换或 reload
82
+ Host。先让原有工作结束并保留原始未决输入/结果证据,再由获授权的 Operator 在安全
83
+ 边界选择 Session 替换或清理,之后重试。安装新代码不能修改已加载的 legacy Host 内存,
84
+ 也不能回收它从未持久投递过的终态。
85
+
86
+ `task role status`、`task role list` 和 `task role session inspect` 在持久 Run 状态旁
87
+ 显示 Host 上报观测。原生结果待落库或已知上报故障需要关注,但不代表 Provider 失败、
88
+ Run 已结束或业务已验收。Host 诊断只检查自己已投递文件的身份是否存在,不解析或隔离
89
+ 其他生产者的新格式事件。
90
+
62
91
  ## CLI 与 Controller 发布边界
63
92
 
64
93
  全局 `yui` 命令是稳定的用户与受管 Session 接口。对普通命令,它不跟随