Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions docs/architecture/rust-agent/plugins/Wait.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wait

The Wait plugin registers Wait in every Session and WaitBranch in every branch.
The Wait plugin registers Wait in every Session and WaitBranch in every branch. The branch part's target contract is [WaitBranch](../../../design/plugins/WaitBranch.md).

## Wait

Expand Down Expand Up @@ -82,18 +82,9 @@ Provides branch-local wait state recording eligible arrivals during an open turn
| `B:Dispatcher` | Consume arrivals and turn boundaries in order. |
| `B:Timeline` | Read the last `turn/start` or `turn/end` and the unpublished tail, so the rebuild knows whether a turn is open. |

### Data face
### Data face (current and target)

`wait` is this part's service by name
([service faces §3.4](../../../design/service-faces.md#34-对象句柄拆成操作加-id)):

```text
wait.wait(taskId: string | null, timeoutMs: number, cancelled: () => void | Promise<void>)
-> {reason: "notification", taskIds, waitedMs}
| {reason: "user_steer", waitedMs} | {reason: "already_notified", taskIds, waitedMs}
| {reason: "timeout", waitedMs} | {reason: "interrupted", waitedMs}
-> error {code: "AlreadyWaiting" | "Reloading", message}
```
Current implementation: `wait(taskId, timeoutMs, cancelled)` in [wait.rs](../../../../crates/dim-agent-capabilities/src/wait.rs), answering `WaitResult` or `WaitCallError`. The target is [WaitBranch](../../../design/plugins/WaitBranch.md) § Operations, which takes `wait(request, cancelled)` and a `state()` read, and answers `WaitResult`, `WaitState` or `WaitCallError`.

It is the same wait the tool call makes. `cancelled` is the call's own
cancellation and ends it as `interrupted`, releasing the single-wait slot.
Expand Down
2 changes: 1 addition & 1 deletion docs/design/capability-document-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and completion belong in the issue. The proposed authoring method is in the
| What do order, state responsibility and work settlement mean? | [Time bus §1–5](../architecture/rust-agent/time-bus.md) | State the feature's transitions and consequences, not another global rule |
| What can a plugin read/write and how does it join live consumption? | [Plugin contract §5–7](plugin-contract.md) | State dependencies and use the contract; bindings describe spelling only |
| What does a query return, and how do cutoff, relations and continuation work? | [Property query §2–3](timeline-property-query.md) | Define business selection and arguments; do not reproduce query semantics |
| What survives a reload for one feature? | The [lifecycle contract](plugin-contract.md#72-generations-reload-and-rebuild) and its owner design, for example [Goal state](plugins/Goal-state-read.md), [Queue recovery](input-queue-recovery.md), [Prompt state](prompt-state-read.md), [Wait](../architecture/rust-agent/plugins/Wait.md) | Apply the existing lifecycle obligations and the owner's business recovery outcome; restoring state does not justify leaving old execution running |
| What survives a reload for one feature? | The [lifecycle contract](plugin-contract.md#72-generations-reload-and-rebuild) and its owner design, for example [Goal state](plugins/Goal-state-read.md), [Queue recovery](input-queue-recovery.md), [Prompt state](prompt-state-read.md), [WaitBranch](plugins/WaitBranch.md) | Apply the existing lifecycle obligations and the owner's business recovery outcome; restoring state does not justify leaving old execution running |
| How do owner reads and saved results fit together? | [Saving boundaries](owner-state-indexed-reads.md), [Resume design](resume-read-design.md) | Keep cross-module dependencies here and detailed fields/algorithms in owner documents |
| How does a part mount, name dependencies and cross languages? | [rutis usage](rutis-usage.md), [service faces](service-faces.md) | Link the current binding; do not copy old API spellings into architecture rules |
| What exists in the actual assembly? | [Generated catalog](../architecture/rust-agent/generated/catalog.md) | Use as implementation evidence for that profile, not a closed universe of plugins |
Expand Down
65 changes: 36 additions & 29 deletions docs/design/cli-current-activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,39 +136,44 @@ Source reviewed against `077892025020a2875a559b432dfa3256878422ff`.

## Owner requirement for named waits

To show “Waiting for task: CI checks” in #1659, ToolExecution needs an agreed
public per-call activity contract with [Wait](../architecture/rust-agent/plugins/Wait.md).
ToolExecution owns tool lifecycle and call identity. WaitBranch owns admission
and settlement through the existing branch-local `wait` face. Tool handler start
alone cannot establish that WaitBranch accepted a wait or supply its clock.

The owner decision must cover:

- A scoped identity for the admitted wait: Session, branch, turn, request,
dispatch event ID and call ID, with an optional task ID. Publish a positive
admission signal and the authoritative admission time if elapsed time is
supported. Correlate the target by exact task identity in the same Session
and branch. Use the task projection’s existing title fallback.
- Matching settlement for notices, steer, timeout, interruption and reload,
ordered against batch and turn completion. Handle rejected calls and
immediate outcomes without leaving a live wait claim. A timeout ends the
To show “Waiting for task: CI checks” in #1659, the CLI reads a positive
admission signal and its start from [WaitBranch](plugins/WaitBranch.md)'s
`state` read. ToolExecution owns the tool's lifecycle and call identity;
WaitBranch owns the line's admitted wait, its admission and its settlement. A
tool handler's start alone cannot establish that WaitBranch accepted a wait or
supply its clock.

The decision covers:

- One admitted wait per line: `state()` answers `{waiting, startedAt?, taskId?}`,
with the optional task ID and the admission time. The reply carries no call
ID and no turn or request identity; the client correlates it with its own
turn and batch. Reading the task’s title uses the task projection’s existing
title fallback.
- Settlement by the `wait` call’s result: notices, steer, timeout,
interruption and reload end it, ordered against batch and turn completion.
A refused call ends at once and leaves no live wait claim. A timeout ends the
wait independently of the target’s outcome.
- Evidence for any claim that the foreground is waiting on one object.
A concurrent wait can share a step with calls such as `read`. Use the
neutral batch status while a sibling is active or its state is unknown.
A confirmed untargeted wait can say “Waiting for a background task or
new input”. A confirmed targeted wait with an unavailable task can say
“Waiting for task: details unavailable”.
- If exact reconnect restoration is required, a bounded owner read at a
fixed cutoff and an ordered handoff to live updates. A gap leaves the
relationship unknown. WaitBranch reload settles accepted calls and
rebuilds open-turn status, so a reload does not reconstruct an old wait.
- Reconnect: a client reads `state` again and claims a wait only while it
answers one. WaitBranch reload settles accepted calls and rebuilds open-turn
status, so a reload does not reconstruct an old wait.

The owners decide whether existing progress facts can contribute and what
additional admission or settlement evidence is needed. The design with
shipped facts adds no service face, Timeline event, stored format or flag
change. The conditional status below depends on that owner decision and
an admitted wait with an authoritative start.
The design with shipped facts adds no Timeline event, stored format or flag
change; the owner adds the `state` read. The App Server reads it by
`(sessionId, branchId)` and answers a protocol v4 client through a method or
notice that needs a maintainer decision, so the client-protocol addition is a
separate decision. Until that lands, the status below has no client path.

The former per-call requirement — a call ID, dispatch event ID, request
identity and a per-call admission record — is dropped: the slot makes the
line’s admitted wait unique, and the `wait` result settles it. Recorded in
[WaitBranch](plugins/WaitBranch.md) § Use and scope.

Conditional scrollback and fullscreen examples:

Expand Down Expand Up @@ -230,14 +235,16 @@ adopted inputs. Repainting adds zero RPCs, history scans or remote CI polls.
Cover untargeted and unknown-target waits, colliding task IDs across
scopes, immediate outcomes, active or unknown concurrent siblings and
missing clock origins.
If exact reconnect becomes part of that contract, test owner cutoff,
live handoff, stale settlement and wait generation reload.
Reconnect is settled by [WaitBranch](plugins/WaitBranch.md)'s `state` read:
a client reads it again and claims a wait only while it answers one, and a
reload does not restore an old wait. Test that re-read, not owner cutoff,
live handoff or stale settlement.

## Ablation review

The existing composer, task strip and bounded projection suffice for
batch-level display. Keep batch and task identities separate because
their lifetimes diverge at handoff. A per-call tracker, an additional
store or a timer read cannot establish admission from the default facts.
Named waits depend on the owner contract. Exact restoration is a
separate requirement for that contract to settle.
Named waits read the owner contract's `state`. Reconnect restoration is
settled there: the client re-reads `state` and an old wait is not restored.
4 changes: 2 additions & 2 deletions docs/design/examples/capability-models/coverage-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
| [ToolExecutor](../../../architecture/rust-agent/plugins/ToolExecution.md#toolexecutor) | 执行段、排他、取消、单父调用的子效果 | claim 在提交前登记、未派发批次释放;resolve_write 后批准和执行同一个调用;两个父调用各收自己的子 effects;已有父返回效果不重复补入;progress/completed/batch-result 身份和顺序 | 不证明宿主副作用能回滚;也不新增排队后的二次授权。NestedSettlement 只有一个 parent,不能检查跨 parent 混入 |
| [InputQueue](../../../architecture/rust-agent/plugins/InputQueue.md#inputqueue) | held/released、替代与删除同批、单输入首个控制 | 多条 Queue 的实际到达顺序;不同 turn 的 handover;普通 pending 排除 handover;notHeld 不产生替代;已接纳但发布未知的服务结果;多个 owed withdrawal 按命令序结算;observable snapshot 等结果提交后更新 | SubmitChecks 是 Session 入口的依赖,不重做检查;“检查通过不预留条目”仍须与条件接纳一起核对 |
| [Loop](../../../architecture/rust-agent/plugins/Loop.md) | 单 turn/request、工具后下一步、reload 失败、局部 continuation | 已采用输入如何组成每轮请求;停止后旧未应用队列不被误启动;未执行工具身份逐项结算;预算恢复、输出上限、工具步骤、用户输入共同决定结束还是续行;failure chain 数值跨请求不重置 | 不检查模型回答质量;输入和失败链影响下一步选择,不能仅作为无结构布尔值丢掉 |
| [WaitBranch](../../../architecture/rust-agent/plugins/Wait.md) | 槽/tracker、关闭 drain、task 匹配、最后回合边界恢复 | 通知资格、顺序、Steer 优先;不匹配通知保留;AlreadyWaiting/Reloading/Interrupted/Timeout 的可观察区别;已有通知立即取走与注册唤醒的交接;工具与服务的 timeout 边界不同。详见下一节 | 不负责后台任务执行完成;超时也不停止任务。无需模拟真实毫秒,但要有“到期”输入 |
| [WaitBranch](../../../architecture/rust-agent/plugins/Wait.md)、[契约](../../plugins/WaitBranch.md) | 槽/tracker、关闭 drain、task 匹配、最后回合边界恢复 | 通知资格、顺序、Steer 优先;不匹配通知保留;AlreadyWaiting/Reloading/Interrupted/Timeout 的可观察区别;已有通知立即取走与注册唤醒的交接;工具与服务的 timeout 边界不同。详见下一节 | 不负责后台任务执行完成;超时也不停止任务。无需模拟真实毫秒,但要有“到期”输入 |
| [ContextPreparation](../../../architecture/rust-agent/plugins/ContextPreparation.md) | prepare 结果互斥、内容 cut、compaction 返回后交接 | 预算超限先压缩、仍不适配则终止且不无限再恢复;最终请求被 host 改变后重新验证,不能沿用旧估计;Steer 在自动压缩中到达时延后替换;配置/guide 更新对同一 source 的采用 | 压缩文本质量及 codec 算法可外置;是否允许 model/call、是否重用估计是本次请求的状态责任 |
| [ModelProvider](../../../architecture/rust-agent/plugins/ModelProvider.md#failure-chain) | 单请求输出终态、重试上限/等待预算 | continuation 继承 attempts/waited,预算耗尽时根本不调用;request-local backoff/malformed 额度重置与 chain 总额不重置;ToolStart 与完整 ToolUse 的不同错误结算;按 request 关联 usage/terminal | 流解析算法可外置,但“工具参数未完成”与“已完整但未执行”必须保留为不同交接状态 |
| [Prompt](../../../architecture/rust-agent/plugins/Prompt.md) | source 单调采用、配置同批、退役记录同批 | configure 成功/失败/被 supersede 的结果;撤销缺失 source;首次 opening receipt 与后续动态变更的顺序;按完整 source/scope 身份恢复有效 entry。现有 Retirement 模型每 scope 一个集合成员,未覆盖多 source 的替换关系 | 未定位生产者的 context/scope 不当作已完成端到端路径;无需重写 PromptHost 内部加载 |
Expand All @@ -56,7 +56,7 @@
先找队列中第一个 Steer,再找第一个匹配 task。无 taskId 时两个不同 task 都匹配。

两段历史 `task A → task B` 与 `task B → task A` 在原模型中得到相同集合 `{A,B}`;
但调用 `wait(null, ...)` 在代码中应分别取 A 和 B。因此原抽象不足以检查这个选择承诺。
但调用 `wait(WaitRequest { task_id: None, timeout_ms }, cancelled)` 在代码中应分别取 A 和 B。因此原抽象不足以检查这个选择承诺。
这不影响原模型对 tracker/drain 的检查,却限制了它能代表的 Wait 行为范围。
这里依据的是方法注释和实现的现行选择行为,不另立新的公开 FIFO 规范;集合抽象对原先的生命周期命题仍可适用。

Expand Down
2 changes: 1 addition & 1 deletion docs/design/examples/owner-handoff-verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
| [时间总线 §2、§4](../../architecture/rust-agent/time-bus.md):生产方只按自身已消费状态复核;消费者拒绝中断后的迟到请求 | `AgentLoop::on_event` 在模型终态上写 tool-call;ToolExecutor 的 handler 记录 interrupt、拒绝批次;`InterruptHandoff.Deliver` | Dispatcher 单事实串行交付;允许在较早事实尚在派发时追加 interrupt。两个消费者进度分开,不引入全局取消位 |
| ToolExecutor 在途工作先释放资源再写结果;Loop 等结果再结束 turn | [ToolExecution](../../architecture/rust-agent/plugins/ToolExecution.md) 的任务 join 与 result;`Invoke/Finish`、`TurnEndWaitsForResult` | 本模型将 host 结束作为动作机会;不证明 host 尊重取消或最终返回 |
| [重载协议](../../architecture/rust-agent/single-tree.md#能力重载协议):旧工作不重执行,各 owner 写自己的终态 | `WaitBranch` cleanup、ToolExecutor cleanup/rebuild、Loop rebuild/on_event;`GenerationHandoff` | 一个已持久化的 turn 和顶层 batch;一个调用、各 owner 最多一次正常换代,另允许一次进程崩溃 |
| [Wait](../../architecture/rust-agent/plugins/Wait.md) 重载拒绝旧调用,并把 reload 交给工具结算 | `ReplyReload/Settle/ConsumeLoop`,`ReloadDoesNotContinue` | `Reloading` → HostError → result settlement 标记的转换来自代码;普通完成另有 `NormalReply`,不会预先假定所有结果都是重载失败 |
| [WaitBranch](../plugins/WaitBranch.md) 重载拒绝旧调用,并把 reload 交给工具结算(当前实现见 [Wait](../../architecture/rust-agent/plugins/Wait.md)) | `ReplyReload/Settle/ConsumeLoop`,`ReloadDoesNotContinue` | `Reloading` → HostError → result settlement 标记的转换来自代码;普通完成另有 `NormalReply`,不会预先假定所有结果都是重载失败 |
| 新代读完整固定 cut 后再消费后缀 | ToolExecutor `rebuild`、Loop `rebuild`;`CaptureTool/CaptureLoop` 与后续处理 | C 的暂存/串行算法作为既有接口前提;本模型不复制队列,而让 Loop 在重建前后读到终态 |
| 失败不能伪装成功接管 | `RebuildTool(FALSE)/RebuildLoop(FALSE)` 保留 failed;`Settle(FALSE)`、`StorageFailure` 保留写入故障 | 查询失败与存储故障分开;required apply 失败的装配回滚不在模型中,见第 4 节。不能据此宣称分支继续健康运行 |

Expand Down
2 changes: 1 addition & 1 deletion docs/design/examples/timeline-capability-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
- **转换**:open 回合内的合格通知或 Steer 可结束等待;匹配 task ID 取对应通知;turn/end 清通知;reload 终止旧调用并拒绝保留原生句柄的新调用。
- **恢复**:`open=(last({turn/start,turn/end},c)=start)`;pending 通知和旧调用不恢复。工具结果归 ToolExecutor 写,不由 Wait 另写终态。
- **性质/论证**:open 的最后边界等价于对边界规则的归纳;接纳和关闭共用锁,tracker 登记发生在解锁前,关闭后 drain 不会漏过新接纳;释放槽早于释放 tracker。进度仍依赖调用 future 被 poll 或 drop。
- **对应**:[wait.rs](../../../crates/dim-agent-capabilities/src/wait.rs)、[Wait](../../architecture/rust-agent/plugins/Wait.md)、[#1619](https://github.com/arcships/dim/pull/1619);复用 #1616 的有界恢复模型,当前 local_execution 的原生、face、完整工具 reload 流程验证新实现。
- **对应**:[wait.rs](../../../crates/dim-agent-capabilities/src/wait.rs)、[WaitBranch](../plugins/WaitBranch.md)(当前实现见 [Wait](../../architecture/rust-agent/plugins/Wait.md))、[#1619](https://github.com/arcships/dim/pull/1619);复用 #1616 的有界恢复模型,当前 local_execution 的原生、face、完整工具 reload 流程验证新实现。

## 7. ContextPreparation

Expand Down
2 changes: 1 addition & 1 deletion docs/design/examples/timeline-contract-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ B 的后续查询范围证据见 [#1737](https://github.com/arcships/dim/pull/17

| 所有者 | 设计/实现入口 | 已有模型与尚待闭合的前提 |
| --- | --- | --- |
| Wait | `plugins/Wait.md`;`wait.rs::rebuild` | `RecoveryBoundary/WaitRuntime`:只恢复 open-turn,丢弃通知/旧等待;固定 cut 与动态 consume 由 B/C 提供 |
| WaitBranch | `plugins/WaitBranch.md`;`wait.rs::rebuild` | `RecoveryBoundary/WaitRuntime`:只恢复 open-turn,丢弃通知/旧等待;固定 cut 与动态 consume 由 B/C 提供 |
| InputQueue | `plugins/InputQueue.md`;`input_queue/recovery.rs::rebuild` | `InputRecovery/InputOrdering`:成员、首个控制决定、handover/turn;先等 committed cut 发布再查询,不能只做 start-minus-end |
| Approval、ToolExecutor、ModelProvider、ContextPreparation、Loop | [逐项分析 §2–8](timeline-capability-analysis.md#2-approval) 中链接的 owner 页与 rebuild/恢复查询 | `RecoverySelection` 仅适用于对应未结算身份子问题;effects、控制事件、旧 request/turn 及结算次序仍依赖各业务模型,D 不可只复用集合公式 |
| Prompt、ToolBinding、ContextUsage | [逐项分析 §9–11](timeline-capability-analysis.md#9-prompt) 中链接的采用、projection/checkpoint、usage 入口 | `PromptRetirement/ToolRetirement/ContextUsage/UsageIdentity`:持久业务身份与当前资源身份不同;B 的选择与 D 的采用交接待闭合 |
Expand Down
Loading