@zq-silk/yui 0.15.11 → 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 (101) 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/agentRun/agentRun.js +3 -0
  5. package/dist/cli/commandCatalog.js +38 -10
  6. package/dist/cli/interactionPolicy.js +4 -0
  7. package/dist/cli/managedDiagnostics.js +1 -1
  8. package/dist/cli.js +46 -15
  9. package/dist/commands/executionAuditCommands.js +10 -0
  10. package/dist/commands/globalRoleCommands.js +27 -2
  11. package/dist/commands/projectCommands.js +44 -15
  12. package/dist/commands/taskCommands.js +95 -33
  13. package/dist/commands/taskIntegrationCommands.js +3 -1
  14. package/dist/commands/taskOverviewCommand.js +4 -3
  15. package/dist/commands/taskPublicationAdoptCommand.js +127 -0
  16. package/dist/commands/taskPublicationCommands.js +11 -2
  17. package/dist/commands/taskPublicationVerifyCommand.js +23 -39
  18. package/dist/commands/taskRemoteDeliveryCommand.js +18 -7
  19. package/dist/context/runContextPack.js +3 -0
  20. package/dist/context/taskCatalog.js +187 -0
  21. package/dist/context/taskContext.js +17 -4
  22. package/dist/controller/controller.js +11 -2
  23. package/dist/controller/fileSchedulerStoreAdapter.js +80 -19
  24. package/dist/controller/globalInputDelivery.js +13 -0
  25. package/dist/controller/providerRetryAdmission.js +100 -0
  26. package/dist/controller/providerRetryDelivery.js +218 -0
  27. package/dist/controller/runtime.js +36 -1
  28. package/dist/integration/gitIntegrationService.js +19 -6
  29. package/dist/lifecycle/exactRunTerminalization.js +4 -1
  30. package/dist/message/globalProviderRetry.js +15 -0
  31. package/dist/observability/executionAudit.js +19 -0
  32. package/dist/repository/gitWorkspace.js +371 -105
  33. package/dist/repository/projectMaintenanceLock.js +75 -18
  34. package/dist/repository/taskWorkspaceCoordinator.js +71 -124
  35. package/dist/repository/taskWorkspacePreparer.js +86 -24
  36. package/dist/repository/workspaceCleanupInspection.js +187 -0
  37. package/dist/runtime/agentError.js +5 -3
  38. package/dist/runtime/agentHost.js +28 -11
  39. package/dist/runtime/builtinAgentErrorMappers.js +91 -0
  40. package/dist/runtime/codexAppServerRuntime.js +34 -3
  41. package/dist/runtime/providerControl.js +5 -1
  42. package/dist/runtime/providerRetry.js +198 -0
  43. package/dist/runtime/providerRuntimeIdentity.js +28 -2
  44. package/dist/runtime/sessionTokenMetrics.js +15 -5
  45. package/dist/runtime/structuredProviderHost.js +6 -2
  46. package/dist/runtime/taskUsageMetrics.js +275 -0
  47. package/dist/scheduler/activeRoleRunDelivery.js +12 -0
  48. package/dist/scheduler/leaderWakeupProcessor.js +5 -0
  49. package/dist/scheduler/taskExecutionProjection.js +26 -5
  50. package/dist/scheduler/taskObservabilityProjection.js +6 -44
  51. package/dist/storage/sqliteSchema.js +31 -0
  52. package/dist/storage/sqliteStore.js +17 -0
  53. package/dist/storage/storageVersions.js +1 -1
  54. package/dist/storage/storeRpc.js +1 -0
  55. package/dist/storage/taskCatalog.js +123 -0
  56. package/dist/storage/taskStore.js +2 -0
  57. package/dist/task/archiveDiagnostics.js +1 -0
  58. package/dist/task/archivePreflight.js +124 -0
  59. package/dist/task/publicationAdoption.js +56 -0
  60. package/dist/task/publicationReference.js +10 -0
  61. package/dist/task/remoteDelivery.js +31 -16
  62. package/dist/web/assets/client/app.js +92 -17
  63. package/dist/web/assets/client/components.js +55 -13
  64. package/dist/web/assets/client/i18n.js +72 -4
  65. package/dist/web/assets/client/taskSurface.js +2 -1
  66. package/dist/web/assets/client/view.js +35 -7
  67. package/dist/web/assets/shell.js +6 -0
  68. package/dist/web/assets/styles/layout.js +7 -0
  69. package/dist/web/webServer.js +14 -3
  70. package/dist/web/webSnapshot.js +12 -3
  71. package/dist/workspace/cleanupInspection.js +63 -0
  72. package/dist/workspace/workItemChangeSetManager.js +110 -50
  73. package/docs/agent-result-consumption.md +4 -0
  74. package/docs/agent-result-consumption.zh-CN.md +3 -0
  75. package/docs/agent-runtime-drivers.md +7 -0
  76. package/docs/agent-runtime-drivers.zh-CN.md +5 -0
  77. package/docs/architecture/README.md +2 -0
  78. package/docs/architecture/README.zh-CN.md +3 -1
  79. package/docs/architecture/capabilities-and-resources.md +30 -5
  80. package/docs/architecture/capabilities-and-resources.zh-CN.md +23 -3
  81. package/docs/managed-turn-and-session-runtime.md +47 -0
  82. package/docs/managed-turn-and-session-runtime.zh-CN.md +40 -0
  83. package/docs/observability/README.md +62 -0
  84. package/docs/observability/README.zh-CN.md +47 -0
  85. package/docs/project-refresh.md +77 -0
  86. package/docs/project-refresh.zh-CN.md +59 -0
  87. package/docs/provider-retry.md +70 -0
  88. package/docs/task-delivery.md +133 -13
  89. package/docs/task-delivery.zh-CN.md +99 -10
  90. package/docs/task-discovery.md +102 -0
  91. package/docs/task-discovery.zh-CN.md +86 -0
  92. package/docs/testing/verification-levels.md +16 -0
  93. package/docs/testing/verification-levels.zh-CN.md +13 -1
  94. package/i18n/README.zh-CN.md +13 -7
  95. package/package.json +1 -1
  96. package/skills/yui-leader/references/execution.md +3 -2
  97. package/skills/yui-operator/SKILL.md +13 -2
  98. package/skills/yui-reviewer/SKILL.md +4 -0
  99. package/skills/yui-runtime/SKILL.md +17 -2
  100. package/skills/yui-runtime/references/publication.md +26 -4
  101. package/skills/yui-runtime/references/recovery.md +24 -0
@@ -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.
@@ -13,6 +13,9 @@ prepares physical workspaces, and adopts status/ownership atomically. Failed
13
13
  preparation leaves the Task Draft with a failed request and a diagnosis delivered
14
14
  to the Leader. Deferred activation retains the exact intent and waits for native
15
15
  quiescence, whether requested in a planning Run or subsequent discussion.
16
+ Project maintenance contention waits asynchronously before resource adoption.
17
+ A lock timeout or cancelled wait preserves the original activation request;
18
+ after acquiring the lock, activation rechecks current intent and authority.
16
19
 
17
20
  Task type describes the requested outcome, not the mandatory executor.
18
21
  Leader owns bounded work directly or assigns substantial independent WorkItems.
@@ -22,7 +25,8 @@ attempts at the same frozen Assignment, followed by Leader-selected synthesis.
22
25
  ## Managed workspaces
23
26
 
24
27
  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
28
+ multi-Project root with independent per-Project Git clones; WorkItem, Review and
29
+ Integration worktrees belong to those Task repositories. For one Project, the Agent's
26
30
  normal cwd is its managed Git root; for multiple Projects, the root and native
27
31
  additional-directory mechanism expose the explicit Project set.
28
32
 
@@ -75,31 +79,147 @@ Leader delivery. The current native turn must end so the pending notification
75
79
  can arrive; the Leader then reads the original message and reassesses completion.
76
80
  This derives from existing Messages and mailbox delivery, not a second
77
81
  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.
82
+ Terminal workspace cleanup can remain an advisory at completion. Ordinary
83
+ archive requires it to be settled; explicitly authorized force archive may
84
+ retain unresolved resources as described below. Artifacts selected as results
85
+ must be fixed, present and Task-local.
80
86
 
81
87
  Publication records a remote PR/MR reference. Reported merge, independently
82
88
  verified merge and exact Task-head coverage are separate facts. Task completion
83
89
  does not prove any of them. Remote delivery is read from exact publication/head
84
90
  evidence, not inferred from a title or branch name.
85
91
 
92
+ Completion heads remain the immutable acceptance baseline. A later, authorized
93
+ integration may produce a different publication candidate (including a rebase
94
+ or merge before a remote squash). Neither ancestry nor a successful Integration
95
+ proves that the accepted behavior survived, or accepts additional changes.
96
+
97
+ For a completed, unarchived Task, record the exact candidate as the Publication's
98
+ `localCommit`, then read `task publication diff <task>/<publication>`. This reads
99
+ only Task-owned local Git objects and returns the original completion reference,
100
+ both commit/tree endpoints, the full diff (including binary changes), and a
101
+ digest binding those facts. Review removals, additions and conflict resolutions
102
+ against the original requirements. If they preserve the accepted result and all
103
+ relevant increments are accepted, use
104
+ `task publication adopt <task>/<publication> --reviewed-diff <sha256> --acceptance <text>`.
105
+ The acceptance must explain that judgment and its verification/review evidence;
106
+ Core checks fixed identity and facts, not the meaning of the code. If an existing
107
+ Task Integration produced that exact candidate, pass its local ID with
108
+ `--integration <id>` to both commands to bind its committed evidence as well.
109
+ This records one Task event, not a new delivery status, Candidate lifecycle,
110
+ Git operation, or permission to change completed work.
111
+
112
+ `task publication verify` remains the explicit, authorized provider read. It
113
+ records the remote source head, PR/MR state and merge commit independently of
114
+ Task acceptance. A mismatched head or non-merged state is saved as **reported**,
115
+ superseding earlier verification; provider errors or mismatched external identity
116
+ write nothing. A merged provider observation verifies only that Publication's
117
+ exact local candidate. A squash merge needs no fabricated commit ancestry.
118
+ Metadata/verification successors preserve adoption only through an uninterrupted
119
+ same-candidate Publication lineage. Candidate or referenced Integration changes
120
+ cannot silently reuse the decision.
121
+
122
+ CLI, current Leader Context and Web derive coverage from these same facts, with
123
+ no provider reads or evidence writes. They distinguish not delivered, merged
124
+ but uncovered, covering merge not verified, partial delivery and verified merge.
125
+ Each Project retains its own accepted head, selected candidate, adoption reference
126
+ and reason. Unknown historical heads remain unknown; old exact-SHA evidence stays
127
+ valid without inventing adoption, and archive never proves remote delivery.
128
+
86
129
  Cancelled intent does not prove the runtime stopped. User/Operator may reopen
87
130
  cancelled Tasks; Leader may reopen completed Tasks. Reopening requires fresh
88
131
  explicit input/work selection and never replays previous delivery requests.
89
132
 
90
133
  ## Archive
91
134
 
92
- Archive is a separate authorized action after active work is settled and
93
- resources are clean and removable. Choose integrated delivery or deliberate
94
- abandonment explicitly. Integrated archive requires exact merged heads and
95
- verified publication evidence. An explicitly authorized verification override
96
- cannot bypass missing or stale heads or an unmerged result.
97
-
98
- Managed WorkItem resources must be integrated or deliberately abandoned before
99
- cleanup. Review, Lane and Integration resources must be settled. Dirty worktrees
100
- remain for the Agent to resolve; no implicit reset or force deletion occurs.
101
- Task main branches and durable Task records retain recovery information.
135
+ Archive requires independent user/Operator authorization for an exact completed
136
+ or cancelled (retired) Task. Completion alone grants none, and ordinary archive
137
+ approval does not authorize force. Select one disposition explicitly:
138
+
139
+ ```sh
140
+ yui task archive <task> --integrated
141
+ yui task archive <task> --abandon
142
+ # Only with explicit force authorization, preserving the chosen disposition:
143
+ yui task archive <task> (--integrated|--abandon) --force
144
+ ```
145
+
146
+ ### Ordinary archive
147
+
148
+ Active work and inputs must be settled, and managed resources clean and safely
149
+ removable. WorkItem results must be integrated or deliberately abandoned;
150
+ Review, Lane and Integration resources must be settled. With `--integrated`,
151
+ each Project requiring code delivery needs a merged, verified Publication
152
+ covering its accepted head, either exactly or through valid explicit candidate
153
+ adoption. `--abandon` records deliberate non-delivery,
154
+ not verified merge.
155
+
156
+ Missing/stale coverage, unresolved execution or dirty worktrees prevent ordinary
157
+ archive. Resolve the reported facts before an explicit retry; no implicit reset
158
+ or force deletion occurs.
159
+
160
+ ### Explicit force archive
161
+
162
+ `--force` is not merely a merge-verification override. It commits the archive
163
+ and stops new Task scheduling before attempting safe foreground cleanup.
164
+ Missing or stale delivery evidence, an unmerged result, unresolved execution
165
+ and cleanup failures become warnings with retained resource references, rather
166
+ than blocking that archive commit. Authority, eligible lifecycle, exact resource
167
+ identity and mandatory audit persistence still fail closed.
168
+
169
+ Force neither verifies a merge nor accepts work, proves quiescence, discards
170
+ dirty data or implies `--abandon`. It preserves the selected disposition and
171
+ original Publication/completion evidence. Unverified local commits and resources
172
+ that cannot safely be released stay owned and traceable. A cleanup failure does
173
+ not roll back archive; late runtime events remain source evidence without
174
+ resuming the Task or settling unknown input.
175
+
176
+ ### Read the result before cleanup
177
+
178
+ `yui task show <task> --json` exposes `data.archive.warnings`,
179
+ `data.archive.retainedResources` and `data.archive.cleanupEvents`.
180
+ `yui task context <task> --json` retains the original records and events;
181
+ `yui task remote-delivery <task> --json` reports delivery separately.
182
+ Warnings include historical cleanup attempts; retained references describe
183
+ current ownership, not a second cleanup queue.
184
+
185
+ An archive result with `archived=true` proves archival, not that cleanup fully
186
+ succeeded. Even `cleanupFinished` means the foreground pass finished, not that
187
+ every resource was removed. Repeating archive reports current facts and does
188
+ not replay cleanup. After inspection, use explicit exact-owner resource
189
+ operations for safe cleanup; no background retry or broader deletion authority
190
+ is implied. Both archive paths preserve Task history and recovery information.
102
191
  Archived Tasks cannot reopen.
103
192
 
193
+ `yui task archive-preflight <task> (--integrated|--abandon) [--force] [--json]`
194
+ reads current admission, delivery and exact-owner cleanup checks in one report.
195
+ It is available before and after archive, including to the Task's authorized
196
+ Leader reader. `--force` here only selects the behavior to inspect. It never
197
+ archives, prepares workspaces, refreshes Git indexes, stops Sessions, acquires
198
+ maintenance locks, fetches remote data, or writes a cleanup plan.
199
+
200
+ Each blocking/unknown check has a resource, reason code, expected and observed
201
+ values, source references and existing inspection/disposition commands. Git
202
+ paths outside the authorized Task are redacted. The report distinguishes
203
+ missing Candidate workspace, changed workspace identity/metadata/path, missing
204
+ frozen commit, moved HEAD, dirty worktree, missing/locked Git registration,
205
+ unintegrated result, uncovered delivery, unsettled owner and unknown execution.
206
+ Status inspection disables optional index writes and filesystem-monitor hooks.
207
+ If a tracked file selects a configured clean/process filter (including an
208
+ initialized submodule's), it reports `git-status-requires-filter` as unknown instead of
209
+ executing the program or bypassing normalization and guessing clean/dirty.
210
+ Historical Candidate paths remain immutable. A path difference, including one
211
+ consistent with an earlier layout migration, does not itself prove a safe
212
+ relocation: without an exact mapping the check reports the difference and
213
+ retains the resource; it does not repair history or weaken commit/owner checks.
214
+
215
+ Preflight is an observation, not a removal permit. Cleanup reloads the same
216
+ checks and Git verifies ownership/dirt again at removal. A Task-main clone's
217
+ dependent registrations are expected before child cleanup and must be absent
218
+ before clone removal. Archive preserves new dirt even in a failed Integration
219
+ workspace; the separate explicit Integration cleanup command keeps its existing
220
+ disposable-conflict behavior. A finished force cleanup means the foreground
221
+ attempt ended, not that every resource was released. Current retained references
222
+ and exact physical runtime evidence remain separate from historical diagnostics.
223
+
104
224
  Use each command's `--help` to inspect its exact authority and options before
105
225
  cleanup; reading a lifecycle document does not authorize an external write.
@@ -11,6 +11,8 @@ Task 生命周期是 `draft / active / completed / cancelled / archived`。Draft
11
11
  状态/所有权。准备失败会让 Task 停在 Draft,附带一个失败请求和投递给 Leader 的
12
12
  诊断。延迟激活保留确切意图并等待原生静止,无论它是在规划 Run 中还是在后续讨论中
13
13
  被请求的。
14
+ Project 维护争用会在采用资源前异步等待。锁超时或等待被取消时保留原激活请求;
15
+ 获得锁后重新检查当前意图与权限。
14
16
 
15
17
  Task type 描述被请求的结果,而不是强制的执行者。Leader 直接负责有界工作,或分派
16
18
  有独立价值的 WorkItem。直接执行没有 Group。复制是为了在同一个冻结 Assignment 上
@@ -19,7 +21,8 @@ Task type 描述被请求的结果,而不是强制的执行者。Leader 直接
19
21
  ## 受管工作区
20
22
 
21
23
  稳定的 Project checkout 是只读参考。Task main 是一个逻辑上的多 Project 根,带有
22
- 按 Project 划分的 Git worktree。对单个 Project,Agent 的正常 cwd 是其受管 Git 根;
24
+ 按 Project 划分的独立 Git clone;WorkItem、Review 和 Integration worktree 归这些
25
+ Task 仓库所有。对单个 Project,Agent 的正常 cwd 是其受管 Git 根;
23
26
  对多个 Project,根加上原生的附加目录机制暴露明确的 Project 集合。
24
27
 
25
28
  一个隔离的 WorkItem 为可写 Project 拥有独立 worktree,为其余 Project 提供 Task-main
@@ -58,25 +61,111 @@ Reviewer Run 持有报告;执行成功不等于语义通过。验收归 Leader
58
61
  干净且已提交的 Task-main 快照。当有一条新的 user/Operator 消息仍在等待 Leader
59
62
  投递时,它也会拒绝完成。当前原生轮次必须结束,待处理的通知才能到达;随后 Leader
60
63
  读取原始消息并重新评估完成。这派生自既有的 Message 和 mailbox 投递,而不是第二套
61
- 确认或工作流状态。终态工作区清理在完成时可以只是建议,但在归档时不行。被选作
62
- 结果的 Artifact 必须是固定的、存在的且 Task 局部的。
64
+ 确认或工作流状态。终态工作区清理在完成时可以只是建议。普通归档要求清理已结算;
65
+ 明确授权的 force 归档可以保留下文所述的未解决资源。被选作结果的 Artifact 必须是
66
+ 固定的、存在的且 Task 局部的。
63
67
 
64
68
  发布记录一个远程 PR/MR 引用。被报告的合并、独立验证的合并以及确切的 Task-head
65
69
  覆盖是彼此独立的事实。Task 完成不证明其中任何一项。远程交付从确切的发布/head
66
70
  证据读取,而不从标题或分支名推断。
67
71
 
72
+ 完成 head 始终是不可变的验收基线。之后获授权的集成可能产生不同的发布候选
73
+ (例如远端 squash 前的 rebase 或 merge)。祖先关系和 Integration 成功都不能
74
+ 证明验收行为未被撤销,也不验收额外增量。
75
+
76
+ 对于已完成但未归档的 Task,先把精确候选记为 Publication 的 `localCommit`,
77
+ 再读 `task publication diff <task>/<publication>`。此命令只读取 Task 自有的
78
+ 本地 Git 对象,返回原完成记录引用、两端 commit/tree、完整差异(含二进制变更),
79
+ 以及绑定这些事实的摘要。逐项核对删除、增加和冲突处理是否仍满足原需求;仅在原成果
80
+ 保留、相关增量也已验收时,执行
81
+ `task publication adopt <task>/<publication> --reviewed-diff <sha256> --acceptance <text>`。
82
+ 验收依据应解释上述判断及其验证/审阅证据;Core 核验固定身份和事实,不裁定代码语义。
83
+ 如果已有本 Task 的 Integration 产出了该精确候选,在两个命令中都传入
84
+ `--integration <id>`,一并绑定其已提交证据。这只新增一个 Task 事件,不新增交付
85
+ 状态表、Candidate 生命周期或 Git 操作,也不授权修改已完成成果。
86
+
87
+ `task publication verify` 仍是显式且须获授权的 provider 读取。它独立于 Task
88
+ 验收,记录远端 source head、PR/MR 状态和 merge commit。head 不匹配或尚未合并时,
89
+ 保存为 **reported** 并取代旧验证;provider 错误或外部身份不匹配则不写任何证据。
90
+ 已合并的 provider 观察仅验证该 Publication 的精确本地候选;squash 不需要伪造
91
+ 提交祖先关系。元数据/验证更新只有沿连续同候选的 Publication 血缘才能继承采用;
92
+ 候选或所引用的 Integration 变化,不能悄悄复用旧决定。
93
+
94
+ CLI、当前 Leader Context 和 Web 从同一组事实推导覆盖,不联网、不写证据。展示
95
+ 区分尚未交付、PR/MR 已合并但未覆盖、已覆盖合并但未验证、部分交付、已验证合并。
96
+ 每个 Project 保留自己的验收 head、候选、采用引用和原因。缺失的历史 head 仍然
97
+ 未知;旧精确 SHA 证据无需补造采用记录,归档也不能反推已交付。
98
+
68
99
  取消意图不证明运行时已停止。user/Operator 可以重开已取消的 Task;Leader 可以重开
69
100
  已完成的 Task。重开需要全新的显式输入/工作选择,绝不重放先前的交付请求。
70
101
 
71
102
  ## 归档
72
103
 
73
- 归档是一次单独的授权动作,发生在活动工作已了结、资源干净可移除之后。显式选择
74
- 集成交付或有意放弃。集成归档要求确切的已合并 head 和已验证的发布证据。一次显式
75
- 授权的验证覆盖不能绕过缺失或陈旧的 head,也不能绕过一个未合并的结果。
76
-
77
- 受管的 WorkItem 资源必须在清理前被集成或有意放弃。Review、Lane 和 Integration
78
- 资源必须已结算。脏 worktree 留给 Agent 解决;不发生隐式 reset 或强制删除。Task
79
- main 分支和持久 Task 记录保留恢复信息。已归档的 Task 不能重开。
104
+ 归档需要针对确切的 completed 或 cancelled(retired)Task 获得独立的 user/Operator
105
+ 授权。完成本身不授予归档权限,普通归档批准也不授权 force。显式选择一种处置:
106
+
107
+ ```sh
108
+ yui task archive <task> --integrated
109
+ yui task archive <task> --abandon
110
+ # 仅在明确授权 force 后使用,并保留所选处置:
111
+ yui task archive <task> (--integrated|--abandon) --force
112
+ ```
113
+
114
+ ### 普通归档
115
+
116
+ 活动工作与输入必须已了结,受管资源干净且可安全移除。WorkItem 结果必须已集成或
117
+ 有意放弃;Review、Lane 和 Integration 资源必须已结算。使用 `--integrated` 时,
118
+ 每个需要代码交付的 Project 都要求已合并且已验证的 Publication,通过精确匹配
119
+ 或有效显式采用候选覆盖其验收 head。`--abandon` 记录有意不交付,而不是已验证合并。
120
+
121
+ 缺失或陈旧的覆盖、未解决的执行或脏 worktree 会阻止普通归档。先解决报告的事实,
122
+ 再显式重试;不会隐式 reset 或强制删除。
123
+
124
+ ### 明确授权的 force 归档
125
+
126
+ `--force` 不只是覆盖合并验证要求。它先提交归档并停止新的 Task 调度,再尝试安全的
127
+ 前台清理。缺失或陈旧的交付证据、未合并结果、未解决的执行和清理失败会成为警告及
128
+ 保留资源引用,而不阻止这次归档提交。权限、合法生命周期、精确资源身份和强制审计
129
+ 持久化仍严格检查,失败时拒绝相应操作。
130
+
131
+ Force 不验证合并、不验收工作、不证明物理静止、不丢弃脏数据,也不隐含 `--abandon`。
132
+ 它保留所选处置及原始 Publication/完成证据。未验证的本地提交和无法安全释放的资源
133
+ 仍有明确 owner 且可追溯。清理失败不回滚归档;迟到的运行时事件仍作为来源证据,
134
+ 不恢复 Task 或结算未知输入。
135
+
136
+ ### 清理前先读结果
137
+
138
+ `yui task show <task> --json` 暴露 `data.archive.warnings`、
139
+ `data.archive.retainedResources` 和 `data.archive.cleanupEvents`。
140
+ `yui task context <task> --json` 保留原始记录与事件;
141
+ `yui task remote-delivery <task> --json` 单独报告交付。警告包含历史清理尝试;
142
+ 保留引用描述当前所有权,不是第二套清理队列。
143
+
144
+ 归档结果中的 `archived=true` 证明已归档,不证明清理全部成功。即使 `cleanupFinished`
145
+ 也只代表前台清理已走完,不代表资源全部移除。重复归档只报告当前事实,不重放清理。
146
+ 检查后通过显式的精确 owner 资源操作进行安全清理;不隐含后台重试或更广泛的删除
147
+ 权限。两条归档路径都保留 Task 历史与恢复信息。已归档的 Task 不能重开。
148
+
149
+ `yui task archive-preflight <task> (--integrated|--abandon) [--force] [--json]`
150
+ 一次读取归档条件、交付覆盖与各精确 owner 的清理检查。归档前后都可用,获授权的
151
+ Task Leader reader 也可读取。这里的 `--force` 仅选择要检查的行为,不会归档、
152
+ 准备工作区、刷新 Git index、停止 Session、获取维护锁、抓取远端或保存清理计划。
153
+
154
+ 每项阻断/未知检查都有资源、原因码、预期/观察值、来源引用及既有检查/处置命令。
155
+ 无权访问的 Task 外路径会脱敏。报告区分 Candidate 工作区缺失、工作区身份/元数据/
156
+ 路径变化、冻结 commit 缺失、HEAD 变化、脏 worktree、Git 注册缺失或锁定、结果未集成、
157
+ 交付未覆盖、owner 未结算和执行未知。状态检查禁用可选 index 写入及 filesystem-monitor
158
+ 钩子;若已跟踪文件的属性选择了配置中的 clean/process filter(包括已初始化的 submodule),则返回
159
+ `git-status-requires-filter` 未知诊断,不执行程序,也不绕过规范化猜测干净/脏状态。
160
+ 历史 Candidate 路径保持不可变。路径差异即使
161
+ 符合早期布局迁移的形状,也不单独证明安全迁址;没有确切映射时只报告差异并保留资源,
162
+ 不会改写历史或放宽 commit/owner 保护。
163
+
164
+ 预检是观察,不是删除凭据。清理会重新读取同一组检查,Git 删除时再验证身份和脏状态。
165
+ Task-main clone 在子工作区清理前存在关联 Git 注册是正常现象,但移除 clone 前它们必须
166
+ 已释放。归档会保留失败 Integration 工作区中新出现的脏文件;独立的显式 Integration
167
+ 清理命令保留既有的可丢弃冲突现场合同。force 清理完成只表示这次前台尝试结束,不表示
168
+ 全部资源已释放;当前保留引用、精确物理运行时证据与历史诊断仍是不同事实。
80
169
 
81
170
  清理前用每个命令的 `--help` 查看它确切的权限和选项;阅读一份生命周期文档不授权
82
171
  一次外部写入。