Skip to content

design(tools): target contracts for the branch tool chain - #2100

Closed
eric8810 wants to merge 11 commits into
mainfrom
dim/2028-tools-contract
Closed

eric8810 wants to merge 11 commits into
mainfrom
dim/2028-tools-contract

Conversation

@eric8810

@eric8810 eric8810 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #2028 · Refs #2015

Summary

Target contracts for the six owners of the branch tool chain: ToolBinding, ToolExecutor, Approval, Permission, BackgroundExec and FileReads. Each document states the owner's responsibility split, the caller intents behind its operations, the operations with cancellation and errors, the flows, exceptions with reasons, the rule check and the requirements raised to sibling owners.

The surfaces become data faces: toolBinding, toolExecutor, approval, permission, backgroundExec, fileReads. No handler, claim guard, gate object or live process crosses an owner: execution moves to ToolRegistry's operations, declarations stay with the pin record, calls are adopted from the host's task id, and approval answers are one data operation.

Delivery

The delivery part — deletion list, caller migration, implementation task and acceptance — is on #2028.

Verification

  • node scripts/adr-check.mjs --base origin/main passed.
  • cargo run --locked -p xtask-check passed.

Merge order

#2029 → #2080 → #2091/#2092/#2093 → #2094 → #2096 → the rest.

Sibling heads this change is aligned with: #2092 d96802349, #2102 3b48e1248, #2103 59a77a3d1. A paragraph that depends on a sibling names that PR; its head is the one above.

Six owner contracts under design rules §7: ToolBinding, ToolExecutor, Approval, Permission, BackgroundExec and FileReads. Each states its responsibility split, caller intents, operations, errors, flows, rule check and the requirements raised to ToolRegistry, Prompt, the Session access mechanism and HostPlatform.
ToolRegistry (#2026), Prompt (#2027), SessionScope (#2093), TimelineTree (#2092), the Session access mechanism and HostPlatform (#2032).
ToolRegistry adopt/release/run/resolve_write/ordering/claim/release_claims, Prompt configure, PermissionRules rules, HostPlatform spawn/wait/kill/settle, and ToolExecutor close for Code Mode's effects.
fileAccessFacts.check takes {access, mode, path}; the service is resolved at the Session instance, so no Session id is a request field and Permission no longer needs SessionScope identity.
fileAccessFacts.check takes {access, mode, path}; the service is resolved at the Session instance.
@eric8810

Copy link
Copy Markdown
Collaborator Author

评审(head 5cbdc4329):需改 1 处;Approval、Permission(advise 回调)、BackgroundExec、FileReads、ToolExecutor 的 gate id 符合。

  1. 同一份「请求采用的工具代」由两个所有者分两套接口管理。 ToolBinding 的 bind/release/transfer/retain_only 包着 ToolRegistry(docs(design): target contracts for the Session registries and tools #2103)的 adopt/release 和 claim/release_claims,Loop 要驱动其中六个操作,并且要「在每条结束路径上 release」。请说明 ToolBinding 与 ToolRegistry 的采用记录为什么生命周期不同;说明不了就合并成一个所有者(ADR 002 D2)。release 改由所有者按请求的终态事实结算,Loop 不在每条路径上调用。

The registry keeps the Session's resolvable generations; ToolBinding keeps a line's request record, its pins and its claims. bind/claim call the registry, transfer moves the record, and the owner settles the record and its claims from step/tool-result and turn/end instead of Loop releasing on every path.
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 40512f331。

  1. 工具采用记录:选择分开(不合并)。理由是 ADR 002 D1 的职责分界:ToolRegistry 持有 Session 可解析的代次(处理器与版本保留,跨行共享,adoption 绑在采用行);ToolBinding 持有一条线的请求记录(哪个 adoption、claim、pin,按该行事实更新,请求终态结束)。合并会把分支的请求状态放进 Session 所有者,或把贡献方的处理器放进分支。两份文档的 Use and scope 各写了持有什么。
  2. 一套分支接口:ToolBinding 的 bind/adopted/claim/transfer 是分支侧唯一接口;注册表的 adopt/release/claim/release_claims 只由 ToolBinding 调用,Loop 不再直接驱动注册表,操作数从六个降到三个。
  3. 释放按终态事实结算:ToolBinding 在 step/tool-result、turn/end 与关闭时结算记录与 claim,删除 release/retain_only 两个公开操作;调用方示例、操作表、错误、流程、绑定与交付评论已同步。

node scripts/adr-check.mjs --base origin/main 与 cargo run --locked -p xtask-check 通过。

@eric8810
eric8810 marked this pull request as ready for review November 23, 2026 12:13

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope: This PR adds six branch-scope owner contracts for the tool chain (ToolBinding, ToolExecutor, Approval, Permission, BackgroundExec and FileReads) and indexes them in docs/design/plugins/README.md. Each document states the responsibility split, the operations with cancellation and errors, the flows, exceptions, rule check and requirements raised to sibling owners. Refs #2028 and #2015.

Verdict: REQUEST_CHANGES

P1: none.

P2

  1. The wire codes in every error table disagree with the appendices and with the published faces.
    Problem: all six tables use lowercase or snake_case kinds such as already_bound, no_batch, unknown_task and invalid_limit (ToolBinding.md:140-148, ToolExecutor.md:86-93, Approval.md:88-93, Permission.md:98-103, BackgroundExec.md:94-101, FileReads.md:86-88), while every error enum in the binding appendices derives Debug and Display only (ToolBinding.md:253-263, ToolExecutor.md:194-204, Approval.md:184-194, Permission.md:236-246, BackgroundExec.md:205-219, FileReads.md:202-206). The rutis binding takes a method error's wire code from its serde form when the type implements Serialize, otherwise from the Debug variant name. These enums therefore produce AlreadyBound, NoBatch, UnknownTask and InvalidLimit. The already-published faces also use other spellings: invalidLimit and read (docs/architecture/rust-agent/plugins/WorkspaceTools.md:549,566) and Unknown/Cancelled/Closed (docs/architecture/rust-agent/plugins/Permission.md:343-345).
    Failure scenario: a cross-language caller matching invalid_limit or no_batch never matches; an existing backgroundExec client matching invalidLimit breaks even if the new spelling is adopted; Rust callers do not see the mismatch until the wire is used.
    Fix: derive Serialize and Deserialize on each error enum with the documented rename, or document the Debug names; make one compatibility decision for the published invalidLimit and Unknown codes; do the same for value strings such as never_read (FileReads.md:79) versus the appendix's camelCase neverRead (FileReads.md:180-183).

  2. Permission.advise cannot be a data operation and cannot be withdrawn at the caller's unload.
    Problem: AdviseRequest derives Debug, Serialize and Deserialize (Permission.md:208-211) over AdviseFn, an Arc<dyn Fn> (Permission.md:230-234) that implements none of them; the callback argument type AdviceRequest is undefined; and the operation carries no caller context or lease id. The current registration is bound to the caller's rutis row through ctx: &Ctx (crates/dim-agent-capabilities/src/permission.rs:238-247).
    Failure scenario: the appendix does not compile, a foreign caller cannot pass a function inside serde data, and a Hooks reload cannot withdraw its advisor, so stale advice can still deny or ask a call.
    Fix: make the callback a method parameter with the caller's &Ctx (and keep it off the data face if the binding cannot carry it), or return a lease id and add a release operation; define the advice input as data.

  3. The existing target contracts still require the removed surfaces.
    Problem: docs/design/contracts/runtime-owner-operations.md:63,76-77 defines fileReads as binding({path}), writeBinding({path}) and record(...), and toolBinding as bind, bindCurrent, definitions, transfer and release; docs/design/service-faces.md:139-140,156 lists permission.check, approval.pending()/decide(requestId, decision) and the positional backgroundExec methods; docs/design/contracts/session-boundary.md:391 names Prompt::adopt_tools and bind_current. The new documents remove or rename all of these.
    Failure scenario: delivery follows either contract and breaks the other, and callers reading the retained-operations table still call operations the owners no longer have.
    Fix: update these documents in this PR or raise the conflicting entries as requirements with their owning PRs, and state which surface supersedes.

  4. Owner-internal read and append failures have no error kind.
    Problem: BackgroundExec.md:85-101 drops the published read code (docs/architecture/rust-agent/plugins/WorkspaceTools.md:549,566); Approval.md:88-93 has no kind for a failed approval/request commit, which current code maps to failed (crates/dim-agent-capabilities/src/approval.rs:163-174); Permission.md:98-103 has no kind for a failed update append, which current code reports as PermissionUpdateError::Failed (crates/dim-agent-capabilities/src/permission.rs:104-111); FileReads.md:79,86-88 has no kind for a failed compaction query, which current write_binding reports as HostError.
    Failure scenario: a storage failure is reported as closed or unknown, or cannot be reported, and callers retry or retire work when the correct next step is to report an owner failure.
    Fix: add a failed or owner-specific kind for internal I/O and append failures, or state that these failures are reported as faults and the operation ends closed; add a flow test for the path.

  5. ToolExecutor's gate row binding has no mechanism and no verification.
    Problem: ToolExecutor.md:84 promises that gateId is bound to the calling row and that a call from another row is gate_closed, but OpenRequest carries only parentCallId and context (ToolExecutor.md:164-167), InvokeRequest and CloseRequest carry only gateId (177-192), and the verification list (112-118) has no cross-row test.
    Failure scenario: any row holding a gate id can invoke a child tool through another line's parent call; the promised refusal cannot be implemented and no test would notice.
    Fix: carry the caller row or context on invoke and close, or bind the gate to the caller's &Ctx at open; add a flow test for the refusal.

  6. ToolBinding.claim's context has no destination in the ToolRegistry contract.
    Problem: ToolBinding.md:133,240-244 makes context a field of ClaimRequest, but the ToolRegistry contract in #2103 defines claim({request, calls}), while its claim callback takes a ToolExecutionContext. The current implementation passes the context to ToolHandler::claim (crates/dim-agent-capabilities/src/tool_binding.rs:246-253).
    Failure scenario: ToolBinding cannot forward the context, so a contributor's claim loses the execution context or the registry contract must change silently.
    Fix: add context to the registry's claim request and raise it on #2103, or drop it here and state how the contributor gets the context.

  7. FileReads keys bindings by canonical path, but its caller example looks up the display path.
    Problem: FileReads.md:11 keys one binding per canonical path; the write example calls binding with display.clone() (FileReads.md:37-38) but records with canonical.clone() (49-52). The current code resolves the path before both the lookup and the record (crates/dim-agent-capabilities/src/workspace_tools/files/write.rs:65-104).
    Failure scenario: a write records the canonical path, the next write looks up the raw display path, the binding is missing, and the tool refuses with text_binding_required, forcing a re-read.
    Fix: pass the resolved path to both operations and state in the request table that path is canonical.

  8. FileReads' codec types do not cross as data.
    Problem: FileReads.md:217 says TextEncoding, EncodingSource, Bom and Eol are existing codec types that cross as data, but those types have no serde derives (crates/dim-agent-capabilities/src/workspace_tools/file_reads.rs:24-59), and the existing TextFileBinding uses raw_revision: [u8; 32] (line 62), while the appendix defines revision: String (FileReads.md:170-176). The derived Serialize and Deserialize on the appendix type do not compile against the existing types.
    Failure scenario: the binding appendix cannot produce the documented wire value, and the read result and the face would carry two different revision fields.
    Fix: raise the serde and representation change as a requirement to the file-tools owner, or define DTOs here with an explicit mapping from the codec types.

  9. Published face signatures change without a compatibility statement.
    Problem: backgroundExec is already a data face with positional methods (docs/architecture/rust-agent/plugins/WorkspaceTools.md:546-557); the target turns each into a request object (BackgroundExec.md:85-88) and replaces invalidLimit with invalid_limit. approval and permission are also published faces (docs/architecture/rust-agent/plugins/Permission.md:24-26,343-345); the target changes pending from an array to {requests} and decide from two arguments to a request object (Approval.md:81-82), and renames permission.check to decide (Permission.md:87).
    Failure scenario: existing external clients call the old wire shapes and fail after delivery; the one-change rule cannot migrate callers outside the repository.
    Fix: state whether the published faces keep their signatures with the new operations added, or whether the break is accepted and versioned; link the client migration.

  10. ToolBinding says Loop never calls the registry, contradicting its own example and the ToolRegistry contract.
    Problem: ToolBinding.md:125 says Loop never calls the registry and line 207 says Loop calls this owner only, but the caller example calls registry.declarations() (ToolBinding.md:52-53,76), and the ToolRegistry contract in #2103 assigns declarations to Loop and the fingerprint.
    Failure scenario: Loop implementers cannot tell where declarations come from, and the stated boundary is broken by the first example.
    Fix: say that Loop calls ToolBinding for bind, claim and transfer and the registry only for declarations, or add a declarations operation to ToolBinding and update #2103.

P3

  1. Appendix examples and signatures do not compile together. FileReads.md:53 awaits record, declared as pub fn record at FileReads.md:213; ToolBinding.md:90 and 96 await the sync transfer and adopted and pass a &String to adopted(String) (ToolBinding.md:270-272); ToolBinding.md:243 and ToolExecutor.md:164,211 use types they do not import.
  2. Reply tables do not match the appendix returns: ToolExecutor.md:81 says {result} but returns a bare ToolResult (211); Permission.md:88 says {version} but returns u64 (253); BackgroundExec.md:85-88 says {text} and {terminal} but returns String and ExecEndedData (226-229). A cross-language caller reading .text, .result or .version gets undefined.
  3. BackgroundExec.md:125 says an unknown task is unknown on every operation, but adopt returns unknown_task (BackgroundExec.md:84,96). Align the verification or the codes.
  4. The README additions leave the index inconsistent: the six new branch parts are missing from the By scope table at README.md:62, and the Rules line (README.md:3) says design rules sections 1 and 4 while these contracts rely on section 7. Add the parts and link the section 7 source (PR #2029).
  5. The contracts are forward references to open PRs: every rule check cites section 7, which is in PR #2029, and the sibling contracts live in open PRs #2102, #2103, #2092, #2093 and #2094. Land the series together or label the links as targets and name the owning PRs in the text.
  6. PermissionRules is process scope in #2094, but Permission.md:77 labels it Session. Use P:PermissionRules and fix the ADR 002 D3 row in Permission.md:153.
  7. ToolBinding.md:142,154 can leak an adoption on already_bound and on any failure after registry.adopt: the flow adopts before inserting the record, and the table only releases adoptions at the row's unload. Check the record before adopting or release the adoption on the error path.
  8. FileReads.md:187-192 can return a reply with both fields absent, so the caller's .expect("one of binding or unavailable") (FileReads.md:44-45,61) can panic on a value from another language. Use an enum or make the unavailable case required.

Comment thread docs/design/plugins/ToolBinding.md Outdated

| Kind | Operation | What the caller does next |
| --- | --- | --- |
| `already_bound` | `bind` | A caller bug: the request id was bound twice. Fail the turn as a fault. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table names already_bound, invalid, unavailable and closed, but BindingError at ToolBinding.md:253-263 derives only Debug and Display. The rutis binding uses the serde form when the error implements Serialize, otherwise the Debug variant name, so the wire codes are AlreadyBound, Invalid, Unavailable and Closed. A cross-language caller matching the table never succeeds. Derive Serialize and Deserialize with the documented rename, or document the Debug names; apply the same fix to the other five contracts and reconcile invalidLimit and read in the existing backgroundExec face.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed: all six error enums now derive Serialize and Deserialize with snake_case and match their tables. Remaining: FileReads spells the unavailable value never_read at FileReads.md:79 while the appendix and the shared row use neverRead; the published faces' invalidLimit, read and Unknown still have no compatibility decision.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. The six appendices now derive Serialize with #[serde(tag = "code", rename_all = "snake_case")] (for example ToolBinding.md:275-277); FileReads uses neverRead in the shared row (runtime-owner-operations.md:63) and the Unavailable enum (FileReads.md:221-233); and the client-visible sections record invalid_limit, read and the code case changes (BackgroundExec.md:124, Permission.md:119, Approval.md:115).

Comment thread docs/design/plugins/ToolBinding.md Outdated
| `B:Timeline`, `B:Dispatcher` | Reconcile the prefix's last configuration at branch opening; consume `step/tool-result` and `turn/end` for settlement; write nothing. |
| `B:BranchLifecycle` | Gate the registry-change watcher on activation and closing. |

The registry's `adopt`, `release`, `claim` and `release_claims` are called only by ToolBinding; Loop never calls the registry.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This contradicts the example above, which calls registry.declarations() (ToolBinding.md:52-53,76), and the ToolRegistry contract in #2103, which assigns declarations to Loop and the fingerprint. Say that Loop never calls the registry's adopt, release, claim or release_claims but does call declarations, or move declarations behind ToolBinding and update #2103.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open: line 125 and line 214 still say Loop never calls the registry and calls this owner only, while the examples call registry.declarations() at lines 53 and 76.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. ToolBinding.md:18 and 131 now say Loop calls the registry only for declarations, and the examples call it (lines 58, 82). New issue on the same call: #2103 declares declarations async (ToolRegistry.md:340), so the samples still need .await; see the new inline on line 58.

pub struct ClaimRequest {
pub request_id: String,
pub calls: Vec<ToolCall>,
pub context: ToolExecutionContext,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context has no destination: the ToolRegistry contract in #2103 defines claim({request, calls}) without a context, while its claim callback takes a ToolExecutionContext. The current implementation passes the context to ToolHandler::claim (crates/dim-agent-capabilities/src/tool_binding.rs:246-253). Either add context to the registry's claim request or state how the contributor obtains it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open: ClaimRequest carries context (ToolBinding.md:248-252), but #2103's claim request is {request, calls} and its example passes only a rutis ctx; the contributor's claim callback gets no turn, request or branch data. The claim table also has no callback error for a registry claim refusal.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed in 038e60c. #2103 now carries context in ClaimCalls (ToolRegistry.md:108,309) and answers callback (ToolRegistry.md:124), and ToolBinding's claim and requirement state the context. Remaining: the refusal carries only cause.code and cause.message (ToolRegistry.md:218,245), while ToolBinding's Callback needs call_id (ToolBinding.md:154), and #2103's invalid claim error has no mapping in ToolBinding's claim table. See the new inline.

Comment thread docs/design/plugins/ToolBinding.md Outdated

| Operation | Normal path | Caller cancels | Caller unloads | Owner closes or reloads | Settled by |
| --- | --- | --- | --- | --- | --- |
| `bind` | Ask the registry to adopt the declarations, insert the record, release the adoptions of pins no later prefix declares | None: the call is synchronous and bounded | Nothing to release; the record is settled at the request's terminal fact or the close | A record in flight is refused with `closed`; the registry releases an adoption it granted at the row's unload | ToolBinding and ToolRegistry |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flow adopts first and inserts the record second. If the insert fails with already_bound (ToolBinding.md:142), the new adoption is not released here; the table only notes that the registry releases at the row's unload, so the generation stays retained. Check the record before adopting or release the adoption on the error path.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open: the flow still adopts before inserting the record and does not release the adoption on already_bound; the errors table only says to fail the turn.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. The bind flow checks the record before adopting (ToolBinding.md:163), and the verification adds the second-bind case (ToolBinding.md:190).

Comment thread docs/design/plugins/ToolBinding.md Outdated
ToolExecutor reads the adoption once per call and hands it to the registry, which resolves the version's handler:

```rust
let adopted = binding.adopted(&context.request_id).await?; // Invalid

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adopted is declared pub fn adopted(&self, request_id: String) at ToolBinding.md:270, so this .await and the &String argument do not compile. The same mismatch appears at ToolBinding.md:90 for transfer, declared sync at ToolBinding.md:272. Align the signatures and the calls.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open: adopted and transfer remain sync at ToolBinding.md:279-281 while this example and line 90 await them; adopted also takes String, not &String.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. transfer and adopted are called without await and adopted takes an owned String (ToolBinding.md:96,102,114); the appendix declares both sync (lines 297,301).

Comment thread docs/design/plugins/FileReads.md Outdated

```rust
let binding = reads.binding(BindingRequest {
path: display.clone(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The owner keys bindings by canonical path (FileReads.md:11), but this lookup uses the raw display path while record uses canonical (FileReads.md:49-52). Current code resolves the path before both the lookup and the record (crates/dim-agent-capabilities/src/workspace_tools/files/write.rs:65-104). A write would record a binding the next write cannot find, so the tool refuses with text_binding_required and forces a re-read. Pass the resolved path to both operations and document the request path as canonical.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open: the lookup still uses display while record uses canonical (lines 38 and 50), and the request table does not say the path is canonical.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. The example resolves once and passes canonical to both binding and record (FileReads.md:39-55), and the request table says the path is canonical (line 85).

Comment thread docs/design/plugins/FileReads.md Outdated
path: canonical.clone(),
binding: new_binding,
established,
}).await?; // Closed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

record is declared pub fn record(&self, request: RecordRequest) -> Result<(), FileReadsError> at FileReads.md:213, so this .await does not compile. Make record async or remove the await and state that it is synchronous.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open: record is still pub fn at FileReads.md:220 while this example awaits it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. The record example no longer awaits (FileReads.md:55), and the appendix declares pub fn record (line 258).

| §4 rule 9 | No Timeline fact of its own; the bindings are a projection of public facts, and the projection is this owner's state. |
| §7 resources and objects | No resource; the owner stores values and returns values. |
| §7 no proxy | The owner answers its own bindings; it returns no file's bytes. |
| §7 one surface | `binding` and `record`; `get` and `write_binding` are removed. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes operations that main still requires: docs/design/contracts/runtime-owner-operations.md:63 defines fileReads as binding({path}), writeBinding({path}) and record(...), and docs/design/service-faces.md:156-160 lists the positional backgroundExec methods. Update those contracts in this PR or raise the conflicting entries as requirements; otherwise delivery can follow either text.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: runtime-owner-operations.md:63,76-77, service-faces.md:139-140,156 and session-boundary.md:391 now carry the new operations, and the Supersedes sections point at the replaced rows.

Comment thread docs/design/plugins/FileReads.md Outdated
}
```

`TextEncoding`, `EncodingSource`, `Bom` and `Eol` are the existing value types of the file-tool codec; they cross as data and stay defined beside the codec, not here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not existing serde types: TextEncoding, EncodingSource, Bom and Eol derive only Debug, Clone, PartialEq and Eq (crates/dim-agent-capabilities/src/workspace_tools/file_reads.rs:24-59), and TextFileBinding uses raw_revision: [u8; 32] (line 62), not the appendix's revision: String. The appendix derives Serialize and Deserialize over types that do not implement them. Raise the serde and representation change as a requirement to the file-tools owner or define DTOs here with a mapping.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open: TextEncoding, EncodingSource, Bom and Eol in crates/dim-agent-capabilities/src/workspace_tools/file_reads.rs:24-59 still have no serde derives, and TextFileBinding still uses raw_revision: [u8; 32] (line 62) against the appendix's revision: String.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed in 038e60c. The appendix now defines the DTOs, uses revision: String and encoding: String, and raises the codec mapping requirement (FileReads.md:157,174-242). Remaining: the requirement says the three enums use their snake-case names while the DTOs derive camelCase (lines 195-219), and the encoding labels differ from the codec's current utf8/utf16le labels (codec.rs:79-82). TextEncoding::Legacy also still cannot derive serde, so the "or derives serde on them" alternative does not work for it. See the inline.


| Plugin | Process part | Session part | Branch part | Phase / issue |
| --- | --- | --- | --- | --- |
| [ToolBinding](ToolBinding.md) (owner contract) | — | — | a request's adopted tool set, its claims and its pins behind the `toolBinding` operations | [#2028](https://github.com/arcships/dim/issues/2028) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The six new rows are branch parts, but the By scope table at README.md:62 still lists none of them, and the Rules line (README.md:3) says design rules sections 1 and 4 while these contracts rely on section 7. Add the parts to the branch row and link the section 7 source (PR #2029).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed: the By scope row now lists the six branch parts. The Rules line (README.md:3) still says sections 1 and 4 and does not link section 7, which the six contracts cite.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. The By scope row lists the six branch parts (README.md:62), and line 3 links section 7 to PR #2029 (target, pending #2029).

… rules

Binding appendices: error enums serialize with snake_case codes matching the tables, caller: &Ctx on the row-bound operations, the advice callback is a direct parameter over defined request and answer types, and the examples match the signatures. Consistency: cancelled is defined per operation, BackgroundExec states one writer per command fact, and the README By scope lists the six branch parts. Supersedes sections and the existing documents' owner paragraphs replace the old shapes; line access follows ADR 027.
@eric8810

eric8810 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

已按 /tmp/round3-rules.md 的 A–G 自查修改,head e5db2cd1b。两个检查通过。

  • A(绑定与线形):六个错误枚举都加 serde::Serialize/Deserialize 与 rename_all = "snake_case",线形 code 与错误表一致:ToolBinding already_bound/invalid/unavailable/closed;ToolExecutor closed/interrupted/no_batch/gate_closed/cancelled;Approval denied/cancelled/closed/unknown;Permission cancelled/closed/conflict/duplicate;BackgroundExec unknown_task/unknown/unavailable/invalid_limit/timeout/closed/cancelled;FileReads closed。行绑定操作加 caller: &Ctx(toolExecutor 的 open/invoke/close,permission.advise),并说明它不是请求字段。审批 advisor 回调改成直接参数,补 AdviceRequest/OwnDecision 定义;advisor 失败按无意见处理,不转发其 code/message。补全 ToolExecutionContext 等导入与类型来源,调用方示例与附录签名一致。
  • B(内部一致):open/invoke/wait 的取消结局写进操作表、错误表与流程,并补 Cancelled 变体;BackgroundExec 写明每个命令的 exec/started 与 exec/ended 只有一个写方(adopt 的任务归本所有者,ShellSession 的命令归它),流程、例外与 Rule check 一致;README 的 By scope 补上六个分支部件。
  • C(取代):六份契约各加 Supersedes;改现有文档中只描述本所有者的段落:service-faces.md 的 approval/permission/backgroundExec/toolBinding/toolExecutor/fileReads 行及指向旧页面的句子,runtime-owner-operations.md 的 Approval/FileReads/ToolBinding/ToolExecutor 行,session-boundary.md §A.5 的 ToolBinding 采纳段,background-task-output.md 的 TreeCommands 查找段。没有改其他所有者段落或 ADR。
  • D(客户端):无客户端可见变更;approval.respond、session.permission.*、session.exec.*、通知与模型可见文本不变。
  • E(偏移读):backgroundExec.output_page 标明是无状态的偏移读,不引入 pin/release。
  • F(引用):跨 PR 链接用 PR URL(docs(design): target contracts for the Session scope and its host ports #2093/docs(design): target contracts for the branch turn chain #2102/docs(design): target contracts for the Session registries and tools #2103/docs(principles): add owners and operations #2029);README By scope 已随索引行更新;没有把已关闭 issue 列为待办。
  • G(按 id 直达):fileReads、backgroundExec 与 background-task-output.md 的访问改为 line_owner::<T>(line),链接 ADR 027,并说明登记点与生命周期服务不在其中。

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope: This PR adds six branch-scope owner contracts for the tool chain (ToolBinding, ToolExecutor, Approval, Permission, BackgroundExec and FileReads), updates three shared contracts and the plugin index, and self-checks the set against the design rules. Refs #2028 and #2015.

Verdict: REQUEST_CHANGES

P1: none.

Round-1 status: of the ten P2 findings, one is fixed (the retained contracts), four are partially fixed (wire codes, Permission.advise, the ToolExecutor gate mechanism, the published-face supersession) and five remain open. Of the eight P3 findings, the README By scope table was fixed; the rest remain open, and the new sync advise adds another example/signature mismatch. The self-check's error-derive and supersession changes hold; its claim that the examples match the signatures does not.

P2

  1. Owner-internal failures still have no error kind.
    Problem: BackgroundExec.md:94-102 has no kind for a failed task-fact read, though the current face publishes read (docs/architecture/rust-agent/plugins/WorkspaceTools.md:549,566) and the implementation returns TaskError::Read, OutputPageError::Read and WaitError::Read (crates/dim-agent-capabilities/src/workspace_tools/background.rs:55-102). Approval.md:88-93 has no kind for a failed approval/request commit, which current code maps to failed (crates/dim-agent-capabilities/src/approval.rs:163-174). Permission.md:95-100 has no kind for a failed update append, which current code reports as PermissionUpdateError::Failed (crates/dim-agent-capabilities/src/permission.rs:104-111). FileReads.md:86-88 has only closed, while write_binding returns HostError (crates/dim-agent-capabilities/src/workspace_tools/file_reads.rs:117).
    Failure scenario: a storage or fact-read failure is reported as closed, unknown or a denial, or cannot be reported at all; the caller retries or retires work when the correct next step is an owner failure.
    Fix: add a failed or owner-specific kind and a flow test for each owner, or state that these failures are fault reports and name the operation's end state.

  2. ToolBinding.claim has no destination for its context and cannot report a refused claim.
    Problem: ClaimRequest carries context (ToolBinding.md:133,248-252), but #2103's claim request is {request, calls} and its caller example passes only a rutis ctx; nothing carries the turn, request and branch data to the contributor's claim callback. #2103's claim also returns callback when the contributor's claim callback refuses, while ToolBinding's claim errors are only invalid and closed (ToolBinding.md:133,145).
    Failure scenario: a contributor whose claim needs the execution context cannot implement it, and a refused claim is lost or reported as a generic invalid.
    Fix: add context and the callback refusal to #2103's claim request and reply, or state the mapping here, and add the matching kind to ToolBinding's claim errors.

  3. FileReads keys bindings by canonical path but its example and request table use the display path.
    Problem: the owner keys one binding per canonical path (FileReads.md:11), the write example looks up with display.clone() (FileReads.md:37-38) and records with canonical.clone() (49-52), and the request table (line 79) does not say the path is canonical. Current code resolves the path before both (crates/dim-agent-capabilities/src/workspace_tools/files/write.rs:65-104).
    Failure scenario: a write records a binding the next write cannot find; the tool refuses with text_binding_required and forces a reread.
    Fix: pass the resolved canonical path to both operations and state in the request table that path is canonical.

  4. FileReads' appendix types are not data.
    Problem: FileReads.md:224 calls TextEncoding, EncodingSource, Bom and Eol "the existing value types" that "cross as data", but they derive only Debug, Clone, PartialEq and Eq (crates/dim-agent-capabilities/src/workspace_tools/file_reads.rs:24-59), and TextEncoding::Legacy holds a &'static encoding_rs::Encoding, which cannot derive Deserialize. TextFileBinding uses raw_revision: [u8; 32] (line 62) while the appendix defines revision: String (FileReads.md:176-182).
    Failure scenario: the appendix does not compile against these types, and the read result and the face carry two different revision representations.
    Fix: define DTOs here with an explicit mapping, or raise the serde and representation change as a requirement to the codec owner and state the wire revision as lowercase hex.

  5. Published faces change without a compatibility decision, and one value string still differs.
    Problem: backgroundExec is published with positional methods and codes invalidLimit and read (docs/architecture/rust-agent/plugins/WorkspaceTools.md:546-566); approval publishes pending() -> ApprovalRequestData[] and decide(requestId, decision) with Unknown, Cancelled and Closed (docs/architecture/rust-agent/plugins/Permission.md:343-345); permission publishes check (same file:24-26). The target replaces these shapes (BackgroundExec.md:84-88, Approval.md:78-82, Permission.md:84-87); the new Supersedes sections state which rows and pages they replace and say the implementation page keeps describing the implementation until the contract lands, but they do not say whether the published wire keeps its signature or the break is versioned. Separately, FileReads.md:79 spells the unavailable value never_read, while the appendix and runtime-owner-operations.md:63 use neverRead.
    Failure scenario: existing clients call the old shapes and fail; a cross-language caller matching never_read never matches.
    Fix: state whether the published faces keep their signatures with new operations added or the break is accepted and versioned, link the client migration, and use one spelling for the unavailable value.

  6. ToolBinding still says Loop never calls the registry.
    Problem: ToolBinding.md:18 and 125 say Loop drives bind, claim and transfer and never calls the registry; line 214 says Loop calls this owner only. The examples call registry.declarations() (lines 53 and 76), and #2103 assigns declarations to Loop and the fingerprint.
    Failure scenario: Loop implementers cannot tell where declarations come from, and the first caller example breaks the stated boundary.
    Fix: say that Loop calls ToolBinding for the record and the registry only for declarations, or move declarations behind ToolBinding and update #2103.

  7. ToolExecutor.invoke treats cancellation as both an error and a result.
    Problem: ToolExecutor.md:94 lists cancelled as an invoke error and says "the child's result records the cancellation", while line 84 says a child call's refusal, cancellation or failure is a ToolResult with is_error: true and line 109 says a child's failure is a result, not an operation error. The example comment at line 47 also omits Cancelled.
    Failure scenario: a program or bridge cannot tell whether a cancelled invoke returns Err(cancelled) or Ok(ToolResult { is_error: true }), and the parent result can disagree with the thrown error.
    Fix: separate the two cases. The caller's token ends invoke with cancelled; the child's own cancellation is a result. Remove the "child's result records the cancellation" wording from the error row and update the example.

P3

  1. Appendix examples still await sync operations. ToolBinding.md:90 and 96 await the sync transfer and adopted (ToolBinding.md:279-281); FileReads.md:49-53 awaits the sync record (FileReads.md:220); Permission.md:55 awaits the new sync advise (Permission.md:270); adopted also takes String, not &String.
    Failure scenario: the examples do not compile, and the self-check claim that they match the signatures is false.
    Fix: make the operations async or remove the awaits and the reference.

  2. Reply tables still differ from the appendix returns. ToolExecutor.md:81 says {result} but returns a bare ToolResult (line 222); Permission.md:85 says {version} but returns u64 (line 269); BackgroundExec.md:85-88 says {text} and {terminal} but returns String and ExecEndedData (lines 236-239). A cross-language caller reading .result, .version, .text or .terminal gets undefined.
    Fix: wrap the replies or document positional replies as the existing faces do.

  3. BackgroundExec verification says an unknown task is unknown on every operation (BackgroundExec.md:132), but adopt answers unknown_task (lines 84 and 96). Adjust the sentence or unify the code.

  4. Two appendix details: ToolBinding.md:148 says bind errors carry name, while BindingError::Invalid carries reason (line 267); Permission.md:100 tells the caller to withdraw the first registration, but no withdraw or release operation exists (lines 82-87). Align the fields and drop the withdrawal advice or add the operation.

  5. README and forward references. README.md:3 still says rules sections 1 and 4 and does not link section 7; the six contracts cite section 7, ADR 027 (PR #2029) and sibling contracts in open PRs #2092, #2093, #2094, #2102 and #2103. Land the series together or label every link as a target and name its owning PR.

  6. PermissionRules is process scope in #2094, but Permission.md:74 labels it Session and the dependency table says S:PermissionRules; the ADR 002 D3 row at line 155 says Session capabilities. Use P:PermissionRules and process.

  7. ToolBinding.bind can leave an adoption behind. The flow adopts before inserting the record (ToolBinding.md:154), and the errors table only says to fail the turn on already_bound (line 142). Check the record before adopting or release the adoption on the error path.

  8. FileReads' reply can carry neither binding nor unavailable (FileReads.md:193-198), so the caller's .expect(...) (lines 44-45 and 61) can panic on a value produced by another language. Use an enum or make unavailable required.

  9. BackgroundExec recovery does not rebuild ended tasks. Line 14 writes failed terminals for unfinished commands, but no flow or verification says how a reloaded generation reconstructs ended tasks and their output paths. The current face answers historical outputPage, wait and stop from task facts (docs/architecture/rust-agent/plugins/WorkspaceTools.md:549-557), and line 131 promises the preview in every state. State the rebuild or remove the historical promise.

Comment thread docs/design/plugins/ToolExecutor.md Outdated
| `interrupted` | `open` | The turn was interrupted; stop the program. |
| `no_batch` | `open` | The parent call is not part of the current batch; a caller bug: stop the program and report it. |
| `gate_closed` | `invoke`, `close` | The gate's parent call settled or the batch was interrupted; stop the program; the parent result carries the effects already confirmed. |
| `cancelled` | `open`, `invoke` | The caller's token ended the call; for `invoke` the child's result records the cancellation and the gate stays usable. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invoke now has a cancelled error, but line 84 says a child call's refusal, cancellation or failure is a ToolResult with is_error: true, and line 109 says a child's failure is a result, not an operation error. A program or bridge cannot tell whether a cancelled invoke returns Err(cancelled) or Ok(ToolResult { is_error: true }), and the parent result and the thrown error can disagree. Separate the two cases: the caller's token ends invoke with cancelled, while the child's own cancellation is a result. Update the example comment at line 47 too.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. The operation table and errors now say the caller's token ends invoke with cancelled, while the child's own cancellation is a ToolResult (ToolExecutor.md:83,88,98,107,130), and the example comment includes Cancelled (line 49).

Comment thread docs/design/plugins/ToolBinding.md Outdated
| --- | --- | --- | --- | --- | --- |
| `bind` | Fix a request to one adopted generation | `{requestId, turnId, through, declared, sources}` | `{}` | None; the owner completes the adoption and the record | `already_bound`, `invalid` (the registry refused the declarations), `unavailable` (a source version is gone), `closed` |
| `adopted` | The record's adoption id and declarations | `{requestId}` | `{adoption, tools}` | None | `invalid` (no record), `closed` |
| `claim` | Register the calls' claims before their batch fact | `{requestId, calls, context}` | `{}` | None | `invalid` (no record), `closed` |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claim carries context and has no callback error. #2103's claim request is {request, calls} and its caller example passes only a rutis ctx, so the contributor's claim callback gets no turn, request or branch data. #2103's claim also returns callback when the contributor's claim callback refuses, while this table has only invalid and closed. Add context and the refusal to #2103's claim request and reply, or state the mapping here, and add the matching error kind.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed in 038e60c. #2103 now carries context in ClaimCalls and answers callback (ToolRegistry.md:108,124,309), so the context part is fixed. Remaining: the refusal has no call id, and ToolBinding's Callback requires one; #2103's invalid also has no mapping here. See the reply on the line 265 thread and the new inline.

| `invalid` | `adopted`, `claim`, `transfer` | The request has no record: a caller bug or a request released before its batch. Fail the turn as a fault. |
| `closed` | any | The branch is closing or unloading; the turn ends. |

`bind` errors carry the declaration that failed (`name`) or the source that is gone (`key`, `version`); the owner reports no failure the record cannot have.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind errors are documented as carrying the failed declaration's name, but BindingError::Invalid carries reason (line 267) and Unavailable carries key and version. A cross-language caller reading the documented name gets nothing. Add name to Invalid or change this sentence to the fields the appendix carries.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. Invalid now carries name and reason (ToolBinding.md:280-281), and the error table says the error names the declaration and the reason (line 151). New sourcing issue: #2103's adopt error still carries only a message, so the name cannot be filled from the registry; see the inline on line 157.

Comment thread docs/design/plugins/Permission.md Outdated
| `cancelled` | `decide` | The call's batch was cancelled; do not run the call. |
| `closed` | any | The generation is closing or reloading; stop; a later generation serves. |
| `conflict` | `update` | Re-read the version from `PermissionState` and decide whether to retry the update with the new base. |
| `duplicate` | `advise` | The name is taken; pick another or withdraw the first registration. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicate row tells the caller to withdraw the first registration, but the contract has no withdraw or release operation: the operations are decide, update, advise and the published value (lines 82-87), and the flow says only the calling row's unload withdraws a registration (line 110). A caller that hits duplicate can only unload its part. Drop the withdrawal advice or add a release operation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. The duplicate row now says to choose another name and that the registration stays until the row unloads (Permission.md:100); the withdrawal advice is gone.

Comment thread docs/design/plugins/FileReads.md Outdated
#[serde(skip_serializing_if = "Option::is_none")]
pub binding: Option<TextFileBinding>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unavailable: Option<Unavailable>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both fields are optional with skip_serializing_if, so a serialized reply can carry neither binding nor unavailable. The caller then panics on binding.unavailable.expect(...) (lines 44-45 and 61), so a foreign implementation or a partial value turns a refusal into a panic. Make the reply an enum, or make unavailable present whenever binding is absent.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. BindingReply is an enum with Bound and Unavailable variants (FileReads.md:228-233), the caller example matches the variants, and the shared row is updated (runtime-owner-operations.md:63).

Comment thread docs/design/plugins/BackgroundExec.md Outdated
- **The task table.** One task per background command of the line: the task id, its description and title, the registered output path, the process it supervises, and its terminal record.
- **Supervision.** Wait for the process the host started, write `exec/ended` with its status and result, hold the Session until the terminal fact is appended, and wake the line with a bounded notice unless the end came from a stop, a branch close or an unload.
- **The output artifact.** The task's registered output file: the tail preview and its bounded pages, the truncation flag, and the unavailable answer when the file is gone. The bytes are appended by the process; the artifact reference and every read belong to this owner.
- **Recovery.** On load, write failed terminals for commands whose process did not survive, and post the wakes the previous generation lost.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recovery writes failed terminals for unfinished commands, but the contract never says how a reloaded generation rebuilds ended tasks or their registered output paths. The current face answers historical outputPage, wait and stop calls from task facts (docs/architecture/rust-agent/plugins/WorkspaceTools.md:549-557), and the verification promises the preview in every state of the task (line 131). State the rebuild or remove the historical read promise.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed in 038e60c. The task table and load flow now rebuild ended tasks from the facts (BackgroundExec.md:11,117,132,145-146). Remaining: the verification at line 147 still promises the tail preview in every state, while output is unknown for an ended task (lines 86,98,113,125); see the inline.

Comment thread docs/design/plugins/FileReads.md Outdated

| Operation | Intent | Request | Reply | Cancellation | Errors |
| --- | --- | --- | --- | --- | --- |
| `binding` | Whether a file may be replaced or edited, and on which binding | `{path, purpose}` | `{binding?}` or `{unavailable: never_read\|compacted}` | None; the owner completes the read | `closed` |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unavailable value is never_read here, but the appendix's Unavailable uses #[serde(rename_all = "camelCase")] and serializes neverRead (lines 184-189), and the updated shared row in docs/design/contracts/runtime-owner-operations.md:63 also uses neverRead. A cross-language caller matching never_read never matches. Use one spelling in the table, the appendix and the shared row.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 038e60c. The operations table uses BindingReply, the Unavailable enum serializes neverRead (FileReads.md:221-233), and the shared row uses neverRead (runtime-owner-operations.md:63).

Owner failures get kinds (read, failed); claim carries its execution context and reports the contributor's refusal; FileReads keys by canonical path and defines wire DTOs; published faces keep their shapes or state the break in Client-visible changes; Loop gets declarations from the registry and ToolBinding provides the operations Loop requires; invoke separates the caller's cancellation from the child's result; examples, replies, recovery and the superseded documents follow.
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审与自查标准修改,head 038e60c91。两个检查通过;绑定附录在临时 crate(rutis 0.23 + 工作区 crate,#[rutis::service] 与附录逐字,函数体 todo!())里 cargo check 通过,未提交。

评审逐条处理

  • P2.1 所有者内部失败没有错误种类:BackgroundExec 加 read(任务事实读取失败)与 failed(exec/started 提交失败);Approval 加 failed(request/respond 提交失败);Permission 加 failed(permission/changed 提交失败或事实读取失败);FileReads 加 failed。四份错误表都写明是否可重试与下一步,流程与验收各有失败路径。
  • P2.2 claim 的 context 与拒绝:ClaimRequest 带 context(turn/request/branch),ToolBinding 把它交给注册表的 claim;要求 docs(design): target contracts for the Session registries and tools #2103 的 claim 收 {request, calls, context} 并以 callback 带回调自己的 code/message 回答拒绝;ToolBinding 映射为 callback {callId, reason, message}(回调 code 在 reason),错误表与流程写明批次不发布。
  • P2.3 canonical path:binding 与 record 都用文件工具解析后的 canonical path,请求表与示例写明,runtime-owner-operations 行同步。
  • P2.4 FileReads 的类型不是数据:附录自己定义 wire DTO(revision 为小写 hex,encoding 为编码标签,三个枚举为数据),并给 codec 所有者提出映射需求(docs(design): target contracts for the Session registries and tools #2103);不依赖 codec 类型的 serde。
  • P2.5 已发布面与兼容决定:approval(pending/decide 位置参数、ApprovalRequestData[])与 backgroundExec(output/outputPage/wait/stop 形状与语义)保持已发布签名;permission 的 check 被 decide 取代,按第 3 节在文档里加「Client-visible changes」并请维护者确认;neverRead 拼写统一。
  • P2.6 Loop 与 declarations:改为 Loop 对记录只调 ToolBinding,对注册表只调 declarations(指纹同);示例、依赖与 Rule check 一致。
  • P2.7 invoke 的取消:调用方的 token 结束 invoke 为 cancelled;子调用自身的取消是 ToolResult;错误行、流程与示例分开写。
  • P3.1:同步操作的示例去掉 await(adopted、transfer、record、advise),adopted 收 String。
  • P3.2:回复表改成与附录一致的按位置回复(ToolResult、u64、String、ExecEndedData、OutputPage、ApprovalRequestData[])。
  • P3.3:验收句子改为 adopt 答 unknown_task,其余操作答 unknown。
  • P3.4:Invalid {name, reason};duplicate 改为「换一个名字」,不再提撤回。
  • P3.5:README 第 3 行链接 §7(target, pending docs(principles): add owners and operations #2029);每份契约加 Targets 行,写明目标与所属 PR(docs(design): target contracts for the Session scope and its host ports #2093/design(settings): owner contracts for Settings and the settings sections #2094/docs(design): target contracts for the branch turn chain #2102/docs(design): target contracts for the Session registries and tools #2103/所有者扫描:HostPlatform 与执行设置 #2032)与机制需求 按 id 调用:由持有实例的一方选目标(base-1) #2127。
  • P3.6:PermissionRules 改为 process 作用域 P:PermissionRules,Rule check 的 ADR 002 D3 行同步。
  • P3.7:bind 先查记录再 adopt;already_bound 不会留下 adoption;流程与验收写明。
  • P3.8:BindingReply 改为枚举(bound / unavailable),示例不再 expect。
  • P3.9:BackgroundExec 装载时从 exec/started/exec/ended 在一个 cutoff 上重建任务表(未完成的写失败终结),历史 outputPage/wait/stop 从重建记录与文件回答;流程与验收写明。

自查额外修改(第 1–3 节)

  • 第 1 节:所有对现有代码/契约/调用方的陈述都对了源码或最新 head(file_reads.rs、background.rs、approval.rs、permission.rs、host.rs、WorkspaceTools/Permission 的架构页、docs(design): target contracts for the Session registries and tools #2103 head 52d078af8、docs(design): target contracts for the branch turn chain #2102 Loop)。
  • 第 2 节:冲突在本 PR 内解决——Hooks A.6.1 与 Appendix H 的 Approval/Permission 行、background-task-output.md、session-boundary.md §A.5、runtime-owner-operations.md、service-faces.md 都已改为新契约或链接。
  • 第 3 节:Supersedes 列出的每一处都在本 PR 改过或删除;没有改其他所有者段落与已接受 ADR。
  • 命名一致性:adopt/claim/run/resolve_write/ordering/declarations 与 docs(design): target contracts for the Session registries and tools #2103 最新 head 一致;unknown_task/unknown、no_record、callback、failed、cancelled、closed 在各表、流程、示例、附录同词。
  • 入库链接检查:全仓 grep 了本所有者名字与锚点;没有删除被代码注释引用的锚点,无代码改动。
  • Rule check 的部件数与 README By scope 一致(六个分支部件)。

客户端可见变更

  • Approval:respond→decide、replay 删除、错误码大小写改为 unknown/cancelled/closed 并新增 denied/failed;admit 新增。approval.respond 客户端方法名与事实不变。
  • Permission:check 由 decide 取代(请求/回复形状见文档);update/advise 新增;错误码 Failed/Cancelled→failed/cancelled。
  • BackgroundExec:新增 adopt;output/outputPage/wait/stop 保持形状与语义;invalidLimit→invalid_limit,新增 unknown_task/failed/cancelled。
  • 其余四份(ToolBinding、ToolExecutor、FileReads)不是已发布面。无 RPC 方法名、通知名、字段或模型可见文本变化。

已重新请 yyhhyyyyyy 评审。

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope: This PR adds six branch-scope owner contracts for the tool chain (ToolBinding, ToolExecutor, Approval, Permission, BackgroundExec and FileReads), updates the shared contracts and the plugin index, and aligns Hooks with the target operation names. Refs #2028 and #2015.

Verdict: REQUEST_CHANGES

Round-2 status: fixed in this head are the owner failure kinds, the FileReads canonical path, the record signature, the BindingReply enum and neverRead, the BackgroundExec read kind and rebuild flow, the PermissionRules scope, the README scope row and section 7 link, the bind record check, the sync examples, the ToolExecutor reply and cancellation split, the Approval failed kind, and the bind error name field. Partially fixed: claim context (now in #2103; the call id is not), published-face compatibility (sections added, the Approval bullet is wrong), the FileReads codec mapping (DTOs added, the wire names contradict), Permission.advise (input is data, the callback remains on the face) and BackgroundExec recovery (rebuild added, the preview promise remains). New in this head: release and retain_only are branch-facing while the shared contracts do not have them, and the ToolRegistry declaration and error shapes do not match.

P2

  1. ToolBinding adds release and retain_only that the shared contracts do not have.
    Problem: ToolBinding.md:18 says Loop calls bind, claim, transfer, retain_only and release, and the operations table adds release and retain_only (lines 140-141). The shared row this PR updates lists only bind, adopted, claim and transfer and says the record is settled from facts (runtime-owner-operations.md:76). PR #2102 at 851f531 has the same four in its dependencies (Loop.md:67) and says "the Loop calls no release or retain operation" (Loop.md:145). The appendix returns () for both (ToolBinding.md:299-300) while the table gives them a closed error (140-141).
    Failure scenario: an implementer following #2102 never calls the two operations, so the rebuild and budget-recovery paths keep stale records and claims until close; one following this table calls operations the shared contracts do not define, and the delivery task can skip the caller migration. A caller matching the table's closed on release has no error to match.
    Evidence: ToolBinding.md:18,140-141,166-167,176,299-300; runtime-owner-operations.md:76; PR #2102 Loop.md:67,145. Current Loop code already calls both (crates/dim-agent-capabilities/src/agent_loop.rs:1190,1458,1664-1760), so the shared contracts are the likely side to update.
    Fix: pick one. If the operations stay, add them to #2102 and the shared row and return Result for the documented closed. If they do not, remove the two rows and keep settlement from the facts.

  2. ToolBinding's ToolRegistry interface does not match #2103.
    Problem: three shapes disagree with PR #2103 at 734d364. First, registry.declarations() is called synchronously at ToolBinding.md:58 and 82, while #2103 declares pub async fn declarations and awaits it (ToolRegistry.md:82,340). Second, bind errors carry a declaration name or a key/version (ToolBinding.md:151-157,280-283), while #2103's adopt refuses with ToolError::Invalid { message } or Unavailable { message } (ToolRegistry.md:122-124,212-219). Third, claim's refusal carries the call id (ToolBinding.md:154), while #2103's ToolError::Callback has only cause.code and cause.message (ToolRegistry.md:108,124,218,245), and #2103's invalid claim error has no mapping in ToolBinding's claim table (ToolBinding.md:139,153).
    Failure scenario: the bind and claim samples do not compile against #2103; a bind refusal cannot name the failed declaration or source; a batch with one claim refusal cannot identify the call, so the turn fault loses it; a registry invalid claim has no defined end state.
    Evidence: ToolBinding.md:58,82,151-157,280-283; PR #2103 ToolRegistry.md:82,108,122-124,212-219,245,340.
    Fix: align one contract with the other. Restore .await?; add structured name/key/version and the call id to #2103's errors, or drop them from BindingError and state what callers receive; map invalid.

  3. Permission.advise is still a Rust callback on the data face.
    Problem: advise is an operation in the table (Permission.md:85) and in service-faces.md:140, and the appendix puts it in the #[rutis::service] impl with AdviseFn = Arc<dyn Fn...> and no #[service(skip)] (Permission.md:258-262,285). The section 7 cross-language row says every parameter and reply is data (line 162). The new exception cites section 7's callback-by-reference allowance (line 124), but section 7 also requires the public face to be cross-language and keeps Rust-only methods inside the owner (PR #2029 principles.md:123,131). Current code marks register_advice #[service(skip)] (crates/dim-agent-capabilities/src/permission.rs:237-238).
    Failure scenario: a non-Rust branch part cannot register an advisor; if the callback goes on the wire, it cannot cross; removing the current skip in delivery either breaks the face or leaves a Rust-only method on a face the rule check calls cross-language.
    Evidence: Permission.md:85,124,162,258-262,285; service-faces.md:140; PR #2029 principles.md:123,131; permission.rs:237-238.
    Fix: keep advise off the data face with #[service(skip)] and state that it is Rust-only and private, or define a data registration plus a bridge route and keep the rule check true.

  4. FileReads' codec mapping contradicts itself.
    Problem: the requirement says the three enums use "their snake-case names" (FileReads.md:157), while the DTOs derive camelCase (lines 195-219, utf8Policy, utf16Le). The encoding comment says utf-8, utf-16le, utf-16be (lines 187-189), while the codec's current labels are utf8, utf16le, utf16be (crates/dim-agent-capabilities/src/workspace_tools/files/codec.rs:79-82) and utf8-policy (line 287).
    Failure scenario: the codec owner maps to utf8_policy while the DTO emits utf8Policy, or to utf-8 while the read result emits utf8; a cross-language caller matching one spelling never matches the other, and the encoding fidelity check compares different strings.
    Evidence: FileReads.md:157,187-189,195-219; codec.rs:79-82,287.
    Fix: state one set of wire values, probably the appendix's camelCase, and either keep the codec's current labels or record the change; align the requirement sentence and the DTO comments.

P3

  1. BackgroundExec.md:147 still promises "The tail preview and the pages read the artifact in every state of the task", while output is unknown for an ended task (lines 86, 98, 113, 125). Fix: say "the pages read the artifact in every state; the tail preview only while the task runs." An acceptance test written from this line otherwise expects a preview after the task ends.

  2. FileReads.md:46 uses BindingReply::Unavailable(reason) while the variant is Unavailable { reason } (line 232); the second example at line 64 uses the struct form. Fix the first pattern.

  3. Approval.md:113 says respond(requestId, decision) is renamed decide, but the published face already exposes decide (docs/architecture/rust-agent/plugins/Permission.md:337-345) and respond is the #[service(skip)] method (crates/dim-agent-capabilities/src/approval.rs:330-331); decide delegates to it at approval.rs:91. Say that respond is removed, decide stays and admit is added.

  4. Approval.md:168 says ADR 027 is not applicable while the same sentence says the Collaboration route reaches the line's pending approvals. That route is the ADR 027 D3 data-face path (runtime-owner-operations.md:26; PR #2029 ADR 027 D3). Say D3 or drop the claim. The BackgroundExec and FileReads rows describe the same D3 route correctly; no D5 lease citation is needed because their Session hold is #2093's lease.

  5. ToolExecutor.md:131-132 still has no cross-row test: the contract says a call from another row is gate_closed (line 86) and open, invoke and close take caller: &Ctx (lines 229-231), but the verification only covers a parent call outside the batch and a settled gate. Add the call from a second row.

Cross-PR and verification

  • PR #2101 rewrites Hooks.md and edits README.md and service-faces.md, which this PR also edits; #2101 already cites Permission.advise and Approval.decide as pending #2100. Coordinate the landing order and expect a textual conflict. #2097, #2098 and #2099 also touch the same index files.
  • Sibling heads checked: #2102 851f531, #2103 734d364, #2093 a4f2377, #2094 8ef2691, #2029 da6f4a9.
  • Main is 6e86d48, merge base 5a279d6. node scripts/adr-check.mjs --base 5a279d69 passed. CI: ci-ok and changes pass; the other jobs are skipped for a docs-only change. The merge state is BLOCKED by this review.
  • Prior opinions withdrawn: the wire-code, canonical-path, BindingReply, record-await, read kind, unknown_task, README, PermissionRules, bind-leak, ToolExecutor reply, ToolExecutor cancellation and Approval failed findings are fixed and should not be repeated. The claim-context finding narrows to the call id and the missing invalid mapping.


ToolBinding does not execute tools, decide admission, hold a handler or a claim guard. The registry's `adopt`/`release`, `claim`/`release_claims` are the Session-side capability ToolBinding requests; execution, write-target resolution and ordering class belong to the registry's `run`, `resolve_write` and `ordering`. The adopted configuration fact (`context/configured`'s tool part) belongs to Prompt.

Loop calls ToolBinding for the request record (`bind`, `claim`, `transfer`, `retain_only`, `release`) and calls the registry only for `declarations`, which answers the current host and contributed declarations; that read is the fingerprint's too, and no adoption or claim goes through it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release and retain_only are new branch-facing operations here, but #2102 at 851f531 lists only bind, adopted, claim and transfer (Loop.md:67) and says "the Loop calls no release or retain operation" (Loop.md:145); the shared row this PR updates also lists only the four and fact settlement (runtime-owner-operations.md:76). The appendix returns () for both (ToolBinding.md:299-300) while the table gives them a closed error (140-141). Failure: an implementer following #2102 leaves stale records or claims on rebuild and budget recovery; one following this table calls operations the shared contracts do not define, and a caller cannot match the documented closed. Fix: add both to #2102 and the shared row and return Result for the documented error, or remove the two rows and keep settlement from the facts. Current code calls both (agent_loop.rs:1190,1458,1664-1760), so the shared contracts are the likely side to update.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 437266b. runtime-owner-operations.md:76 and PR #2102 at 3b48e12 (Loop.md:67,145) now list release and retain_only, and the appendix returns Result for the documented closed.

}).await?, // AlreadyBound, Invalid, Unavailable, Closed
None => {
// No tool part: declare the registry's current host and contributed tools.
let current = registry.declarations()?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2103 at 734d364 declares pub async fn declarations (ToolRegistry.md:340) and awaits it in its own example (ToolRegistry.md:82). This call and the one at line 82 omit .await, so the samples do not compile against the sibling contract and current.tools is read from a future. Failure: an implementer copying the sample gets a type error, or changes #2103 to sync to make it compile. Fix: restore .await? in both samples, or change #2103 and state the async boundary.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open. PR #2103 at 59a77a3 declares pub async fn declarations and awaits it (ToolRegistry.md:82,340), while ToolBinding.md:58 and 82 call it synchronously. See the inline on line 58.

| `invalid` | `bind` | No | The registry refused the declarations; the error names the declaration and the reason; fail the turn and report them. |
| `unavailable` | `bind` | Yes, after re-preparing | The prefix declares a source version the registry no longer retains; re-prepare from the current declarations, or fail the turn. |
| `no_record` | `adopted`, `claim`, `transfer` | No | The request has no record: a caller bug or a request released before its batch; fail the turn as a fault. A reload settlement is not this error. |
| `callback` | `claim` | Depends on the cause | The contributor's claim callback refused; the error carries the call id, and the callback's own code in `reason` and its message in `message`. The batch is not published; the turn fails unless the cause says the call may be retried in a later request. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callback { call_id, ... } requires the call id, but #2103's claim refusal is ToolError::Callback { cause: ToolCallbackError } with only code and message (ToolRegistry.md:218,245), and its claim reply carries only the claimed ids (ToolRegistry.md:108). A batch with one refusal cannot name the call. The requirement at line 227 asks #2103 only for the context and the code/message, so the sibling contract does not supply the field. Failure: the turn fault loses which call refused, and the caller cannot report or retry that call. Fix: add the call id to #2103's claim refusal or drop call_id from this error and define how the refusing call is identified. Also map #2103's invalid claim error: this table has no entry for it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open. #2103's ToolError::Callback carries only cause.code and cause.message (ToolRegistry.md:218,245), and claim answers only the claimed ids on success (line 108); ToolBinding.md:154 and 287 require call_id. #2103's invalid claim error (line 122) also has no mapping. See the inline on line 154.

| `callback` | `claim` | Depends on the cause | The contributor's claim callback refused; the error carries the call id, and the callback's own code in `reason` and its message in `message`. The batch is not published; the turn fails unless the cause says the call may be retried in a later request. |
| `closed` | any | No, in this generation | The branch is closing or reloading; the turn ends; a replacement generation serves the next request. |

`bind` errors carry the declaration that failed (`name`) or the source that is gone (`key`, `version`); the owner reports no failure the record cannot have.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind errors are documented with name for invalid and key/version for unavailable, and the appendix encodes them (lines 280-283). #2103's adopt refusal is ToolError::Invalid { message } and Unavailable { message } (ToolRegistry.md:122-124,212-219), with no structured fields. Failure: ToolBinding cannot populate its own error; a cross-language caller reading name or key gets nothing and must parse a message. Fix: add the fields to #2103's adopt errors, or narrow this error to what the registry returns and say so here and in the requirement at line 227.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open. #2103's adopt refuses with Invalid { message } and Unavailable { message } (ToolRegistry.md:212-219), so ToolBinding cannot fill the name/key/version fields at ToolBinding.md:157 and 281-283. See the inline on line 157.

| §7 resources and objects | No resource; no object crosses. Advice is a callback by reference. |
| §7 no proxy | The owner answers its own decision and publishes its own state. |
| §7 one surface | `decide`, `update`, `advise`, and the published value; `admit_decision`, `check` and the separate `decide` are removed. |
| §7 cross-language | Every parameter and reply is data; the decision is a value, not an error. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row is false while advise stays on the same face with an Arc<dyn Fn> argument (lines 85, 258-262, 285). Section 7 allows callbacks by reference as values (PR #2029 principles.md:123), but it also requires the public face to be cross-language and keeps Rust-only methods inside the owner (principles.md:131); the current code marks register_advice #[service(skip)] (crates/dim-agent-capabilities/src/permission.rs:237-238), and service-faces.md:140 lists advise on the data face. Failure: a non-Rust branch part cannot register an advisor; if the callback goes on the wire it cannot cross; delivery removes the current skip without a bridge. Fix: mark it skip and state that it is Rust-only and private, or define a data registration plus a bridge route.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Withdrawn. rutis 0.23.0 supports a function parameter on a #[rutis::service] method (FromFunction), and service-faces section 1 rule 4 allows callbacks by reference, so the advisor can cross languages and the target's exception at Permission.md:124 is accurate. The only remainder is the optional wording at Permission.md:162; see the new inline.

Comment thread docs/design/plugins/FileReads.md Outdated
## Requirements raised to mechanism owners

- **Cross-scope access ([ADR 027](https://github.com/arcships/dim/pull/2029), [#2127](https://github.com/arcships/dim/issues/2127), target).** A Session part reaches a line's data face by line id with `line_owner::<T>(line)`. The file tools use it to reach `binding` and `record`; FileReads adds no forwarding operation.
- **File-tool codec ([#2103](https://github.com/arcships/dim/pull/2103), target).** The codec's `TextEncoding`, `EncodingSource`, `Bom`, `Eol` and `TextFileBinding` are not wire data (`TextEncoding::Legacy` holds an `encoding_rs` reference and `raw_revision` is `[u8; 32]`). The codec owner provides the mapping to the DTOs below: the encoding label (`utf-8`, `utf-16le`, `utf-16be`, or the requested legacy name lowercased), the revision as lowercase hex, and the three enums as their snake-case names; or derives serde on them with the same wire values. This owner does not change the codec.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mapping sentence and the appendix disagree on the wire values. This line asks for "the three enums as their snake-case names" (utf8_policy, utf16_le), while the appendix derives camelCase (lines 195-219, utf8Policy, utf16Le). The encoding comment says utf-8/utf-16le/utf-16be (lines 187-189), while the codec's current labels are utf8/utf16le/utf16be (crates/dim-agent-capabilities/src/workspace_tools/files/codec.rs:79-82) and utf8-policy (line 287). The codec owner cannot satisfy both, and a cross-language caller matching either never matches the other. Failure: the mapping ships one spelling and the DTO another; encoding fidelity checks compare different strings. Fix: state one set of values, probably the appendix's camelCase, and either keep the codec's current labels or record the change; align the requirement and the DTO comments.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 437266b. The requirement now uses the codec's utf8, utf16le and utf16be labels, maps utf8-policy to utf8Policy, and the DTOs derive camelCase; the shared row uses neverRead.

Comment thread docs/design/plugins/BackgroundExec.md Outdated
- A command moved to the background ends once, its terminal is written once, and the line wakes once; a stop cancels it without a wake; a branch close cancels it without a wake.
- A reload writes failed terminals for unfinished commands, rebuilds every ended task with its output path, posts the wakes the previous generation lost, and refuses a new adoption; a Session close settles the hold.
- A historical task answers `output_page` and `stop` after a reload; `output` is `unknown` for it; `wait` answers its terminal at once.
- The tail preview and the pages read the artifact in every state of the task; a page's cursor advances by its bytes; a limit of zero is `invalid_limit`; a deleted file is `unavailable`; a failed task-fact read is `read`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output is unknown for an ended task (lines 86, 98, 113, 125), but this verification still promises the tail preview in every state. The two cannot both pass. Failure: an acceptance test written from this line expects a preview after the task ends; the implementation either fails the test or re-adds the historical preview the contract removed. Fix: say "the pages read the artifact in every state; the tail preview only while the task runs."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 437266b. The verification now says the pages read in every state and the tail preview only while the task runs (BackgroundExec.md:145).

Comment thread docs/design/plugins/FileReads.md Outdated
}).await?; // Closed, Failed
match binding {
BindingReply::Bound(binding) => { /* preserve encoding and line endings; check the revision */ }
BindingReply::Unavailable(reason) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reply is a struct variant, BindingReply::Unavailable { reason: Unavailable } (line 232), so this tuple pattern does not compile; the second example at line 64 uses the struct form. Failure: a reader copying the first example gets a pattern type error. Fix: use BindingReply::Unavailable { reason }.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed in 437266b. The first example now uses BindingReply::Bound { binding } (FileReads.md:45); the edit example at FileReads.md:63 still uses BindingReply::Bound(binding). See the inline on line 63.

Comment thread docs/design/plugins/Approval.md Outdated

The published `approval` face ([Permission plugin page](../../architecture/rust-agent/plugins/Permission.md#approval-data-face)) keeps `pending()` and `decide(requestId, decision)` positionally and keeps `ApprovalRequestData[]` as `pending`'s reply. It changes as follows, and the maintainer is asked to confirm:

- `respond(requestId, decision)` is renamed `decide`; the callers are Hooks and the App Server's `approval.respond` built-in. The built-in keeps its name and settles through this operation; the client RPC is unchanged.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The published approval face already exposes decide (docs/architecture/rust-agent/plugins/Permission.md:337-345), and respond is the Rust-only method marked #[service(skip)] (crates/dim-agent-capabilities/src/approval.rs:330-331); decide delegates to it at approval.rs:91. So respond is not renamed to decide; it is removed, and decide stays. Failure: a delivery task renames respond to decide and collides with the existing method, or migrates Hooks as if the face name changed. Fix: say that respond is removed as a Rust-only method, decide is unchanged on the face and admit is the added operation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in Approval.md:113. The same claim remains in Hooks.md:26, which says the target renames respond to decide; Hooks.md:504 and 589 also use lowercase duplicate, unknown, failed and closed. See the inline on Hooks.md:26.

Comment thread docs/design/plugins/Approval.md Outdated
| ADR 002 D3 | Depends on Permission (branch) and the branch infrastructure. |
| ADR 002 D4 | No configuration. |
| ADR 002 D5 | Language-neutral operations and data. |
| ADR 027 | Not applicable: the line's own part serves its callers; the Collaboration route uses the line access owned by ADR 027. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not applicable contradicts the same sentence: the Collaboration route reaches a member line's pending/decide by line id, which is ADR 027 D1/D3 (runtime-owner-operations.md:26; PR #2029 ADR 027 D3). A reader cannot tell whether Approval must be a resolvable data face. Failure: delivery treats approval as not cross-scope and leaves it unreachable by id. Fix: cite D3 and state the route, or remove the route claim.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 437266b. The ADR 027 row now says it applies through line_owner::<Approval>(line). #2029 is merged, so the link can point to docs/adr/027-cross-scope-access-by-id.md.

Keep the published approval, permission and backgroundExec codes with their faces; remove the Rust-only respond method instead of renaming it; state the advise callback as a FromFunction value; align the FileReads DTO values with the codec labels; add the cross-row gate test; make the background tail preview state its live-only promise; return Result from release and retain_only.
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head a68b32288。两个检查通过;绑定附录在临时 crate(rutis 0.23 + 工作区 crate,#[rutis::service] 与附录逐字,函数体 todo!())里 cargo check 通过,未提交。

评审逐条(针对 head 038e60c 的新 inline)

  • Approval.md:113 respond 不是改名:改为「respond 是 Rust-only 的 #[service(skip)] 方法(crates/dim-agent-capabilities/src/approval.rs),decide 已是面操作;目标保留 decide、删除 skip 方法」;admit 为新增。
  • Approval.md:168 ADR 027:Rule check 改为「ADR 027 D3 适用」,写明 Collaboration 以 line_owner::<Approval>(line) 到达 pending/decide,该面可按行 id 解析、不是登记点。
  • Permission.md:162 advise 的 skip/bridge:回调是直接参数、也是函数值(rutis::FromFunction),桥把它作为函数传递,所以方法留在面上、不需要 #[service(skip)];当前代码的 skip 由本契约删除。写进 Exceptions 与 Client-visible changes。
  • Permission.md:77 PermissionRules 作用域:上一轮已改为 P:PermissionRules,本轮未回退。
  • Permission.md:100 duplicate 撤回:上一轮已改为「换一个名字,登记留到行卸载」。
  • BackgroundExec.md:85 read:上一轮已加 read(output_page/wait/stop)。
  • BackgroundExec.md:86 已发布面的兼容决定:给出明确决定——approval、permission、backgroundExec 的已发布错误码保持不变(Unknown/Cancelled/Closed、Failed/Cancelled、invalidLimit/read/unknown/unavailable/closed/timeout),用 PascalCase 与显式 invalidLimit rename 保留;新增码为 Denied/Failed、Closed/Conflict/Duplicate、unknown_task/failed/cancelled。三个 Client-visible changes 小节写明并请维护者确认。
  • BackgroundExec.md:125 验收句:上一轮已改为 adopt 答 unknown_task、其余答 unknown。
  • FileReads.md:38 canonical path / :53 record await / :144 共享行 / :197 回复枚举 / :79 neverRead:上一轮已改;本轮核对无回退。
  • FileReads.md:217 映射与 DTO 不一致:映射句改为与 DTO 一致——EncodingSource 用 bom/user/utf8Policy、Bom/Eol 用 camelCase wire 名、encoding 用 codec 现行标签 utf8/utf16le/utf16be(或显式 legacy 名小写);并说明 TextEncoding::Legacy 持有 encoding_rs 引用,derive serde 不能替代,映射就是契约。
  • BackgroundExec.md:14 重建已结束任务:上一轮已加「装载时从 exec/started/exec/ended 重建」;本轮修正验收句为「分页读在所有状态可用,尾部预览只在运行中」,与 output 的 unknown 一致。
  • FileReads.md:46 枚举模式:第一个示例改为 BindingReply::Unavailable { reason },与附录的 struct variant 一致。
  • ToolExecutor.md:84 跨行拒绝:验收加「另一行调用 invoke/close 得 gate_closed,gate id 绑开启它的行」。
  • ToolExecutor.md:211 回复表:上一轮已改为 ToolResult/CloseReply/OpenReply,示例注释含 Cancelled。
  • ToolBinding.md:142 错误 serde:上一轮已改;本轮把 release/retain_only 的附录返回值改为 Result<(), BindingError>,与表里的 closed 一致。
  • ToolBinding.md:125 Loop 与 declarations:上一轮已改;本轮未回退。
  • ToolBinding.md:154/96:上一轮已改(先查记录、sync 示例);本轮未回退。
  • ToolBinding.md:157 invalid 的 name:上一轮已加 Invalid {name, reason};registry 侧只能填 message 的问题留给第二步。
  • ToolBinding.md:265 claim context/callback:上一轮已加 context 与 callback;call id 与 invalid 映射留给第二步。
  • README.md:11:上一轮已加 By scope 与第 3 行的 §7 链接(target, pending docs(principles): add owners and operations #2029)。

自查发现(第 1–9 条)

  1. 新增的现有状态陈述都对了源码:approval.rs(decide 在面上、respond 为 skip)、permission.rs(register_advice 为 skip)、codec.rs(utf8/utf16le/utf16be、utf8-policy)、WorkspaceTools 架构页。
  2. 与现有文档的冲突:本 PR 已改 service-faces、runtime-owner-operations、session-boundary §A.5、background-task-output、Hooks A.6.1/Appendix H;本轮没有新增冲突。
  3. 一词一义:每个已发布面按自己的已发布码保留(见上),新码与表、流程、示例、附录一致;invalidLimit 只在 backgroundExec 出现。
  4. 表、流程、例外、Rule check、附录、示例一致;release/retain_only 的返回类型已与表对齐;示例的模式与 struct variant 对齐。
  5. 每个结局给下一步:Approval Failed、Permission Failed、BackgroundExec invalidLimit/read、FileReads failed 都带重试与下一步;重复调用、对方关闭、重载各有说明。
  6. rename/deletion 后 grep:respond/replay/registerAdvice/admit_decision/never_read/bindCurrent 在六份契约中只剩「已删除」的说明;approval/cancelled 是事实名,保留小写。
  7. 规则不带 Rust 拼写;跨 PR 链接用 PR URL 并写「target, pending #N」;没有把扫描 issue 当机制 issue。
  8. 新写的句子按 1–5 复核:Client-visible 小节不动 client RPC;advise 的 FromFunction 说明引用 rutis 0.23 的实际能力;FileReads 映射与 DTO 注释一致。
  9. 用到的兄弟定义都打开了最新 head:docs(design): target contracts for the Session registries and tools #2103 734d364c、principles a3c7c4d8a、approval.rs、permission.rs、codec.rs。

left for step 2(跨 PR,先不改)

  1. docs(design): target contracts for the Session registries and tools #2103 declarations 的同步/异步:其最新 head 声明 pub async fn declarations,本 PR 的示例(ToolBinding.md:58、82)仍无 .await;等 docs(design): target contracts for the Session registries and tools #2103 定稿后一起改。
  2. ToolBinding 的 release/retain_only 与 docs(design): target contracts for the branch turn chain #2102 Loop 的四个操作(Loop 说 Loop 不调 release/retain)及共享 runtime-owner-operations 行不一致。
  3. docs(design): target contracts for the Session registries and tools #2103 的 claim 拒绝只有 code/message,没有 call id;ToolBinding 的 Callback {call_id} 无法填,且 docs(design): target contracts for the Session registries and tools #2103 的 invalid claim 错误在本表没有映射。
  4. docs(design): target contracts for the Session registries and tools #2103 的 adopt 错误只有 message,ToolBinding 的 Invalid {name, reason}/Unavailable {key, version} 无法从 registry 填出结构化字段。
  5. design(2033): target contracts for Goal, SessionTitle, Web and Code Mode #2099 的 adopted 行(按本轮指示留给第二步)。

已重新请 yyhhyyyyyy 评审。

@eric8810
eric8810 requested a review from yyhhyyyyyy November 24, 2026 05:32
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head c7ec39bee。

跨 PR 对齐:

验证:node scripts/adr-check.mjs --base origin/main 通过;链接与锚点无新增断链。

@eric8810

Copy link
Copy Markdown
Collaborator Author

补充说明,head 437266bff(ADR 027 收回到决定层后):

  • Approval 的 Rule check 行不再复述 D3 的可解析范围,改为本所有者自己的调用加 D1–D3 链接与 #2127。
  • FileReads、BackgroundExec 的 ADR 027 引用只在 D1–D6 内,未复述 ADR 内容;本 PR 不写三个错误名。

验证:node scripts/adr-check.mjs --base origin/main 通过;链接与锚点无新增断链。

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope: This PR adds six branch-scope owner contracts for the tool chain (ToolBinding, ToolExecutor, Approval, Permission, BackgroundExec and FileReads), updates the shared contracts and the plugin index, and aligns Hooks with the target operation names. Refs #2028 and #2015.

Verdict: REQUEST_CHANGES

Round-3 status: fixed in 437266b are the release/retain_only gap, the FileReads codec mapping, the BackgroundExec preview promise, the Approval ADR 027 row and the ToolExecutor cross-row test. The ToolRegistry mismatch remains. The Permission.advise P2 is withdrawn: rutis 0.23.0 supports a function parameter on a #[rutis::service] method (FromFunction), and service-faces section 1 rule 4 allows callbacks by reference, so the advisor can cross and the target's exception is accurate. The FileReads pattern is fixed at line 45 but remains at line 63. The Approval rename is fixed in Approval.md but remains in Hooks.md.

P2

  1. ToolBinding's ToolRegistry interface still does not match #2103.
    Problem: three shapes disagree with PR #2103 at 59a77a3. First, ToolBinding.md:58 and 82 call registry.declarations() synchronously, while #2103 declares pub async fn declarations and awaits it (ToolRegistry.md:82,340). Second, bind errors carry a declaration name or a key/version (ToolBinding.md:157,281-283), while #2103's adopt refuses with ToolError::Invalid { message } or Unavailable { message } (ToolRegistry.md:122-124,212-219). Third, claim's refusal carries the call id (ToolBinding.md:154,287), while #2103's ToolError::Callback has only cause.code and cause.message (ToolRegistry.md:108,124,218,245); #2103's invalid claim error has no mapping in ToolBinding's claim table (ToolBinding.md:153).
    Failure scenario: the samples do not compile against #2103; a bind refusal cannot name the failed declaration or source without parsing a message; a batch with one claim refusal cannot identify the call, so the turn fault loses it; a registry invalid claim has no defined end state.
    Evidence: ToolBinding.md:58,82,153-157,281-287; PR #2103 ToolRegistry.md:82,108,122-124,212-219,245,340.
    Fix: align one contract with the other. Restore .await? in both samples. Add structured name/key/version and the call id to #2103's errors and map invalid, or drop those fields from BindingError and state what callers receive.

  2. Hooks.md contradicts the owner contracts on the target operation and its codes.
    Problem: Hooks.md:26 says the target "renames the operation to approval.decide", but Approval.md:113 says respond is removed as the Rust-only skip method and decide is already the face's operation. Hooks.md:589 spells the decide errors unknown, failed and closed against the PascalCase enum at Approval.md:194-195, and Hooks.md:504 spells the advisor duplicate duplicate against Permission.md:100 Duplicate.
    Failure scenario: a delivery task following Hooks renames Approval::respond to decide and collides with the existing decide (crates/dim-agent-capabilities/src/approval.rs:91); a cross-language caller matching the lowercase codes never matches the owner's wire codes.
    Evidence: Hooks.md:26,504,589; Approval.md:113,194-195; Permission.md:100; approval.rs:91.
    Fix: say respond is removed and decide is unchanged, and use Unknown, Failed, Closed and Duplicate. Since #2101 at 18d5e4f rewrites Hooks.md, dropping these Hooks edits from this PR is the simpler fix. The earlier rounds checked Approval.md's wording; Hooks.md kept the same claim and now contradicts the corrected owner contract.

P3, optional

  1. FileReads.md:63 matches BindingReply::Bound(binding) against the struct variant Bound { binding: TextFileBinding } declared at FileReads.md:230-231. The first example at line 45 uses the struct form. Copying the edit example gets a pattern type error. Fix: BindingReply::Bound { binding } => binding.

  2. runtime-owner-operations.md:26,48,63,76 and 77 use full-width Chinese parentheses in an English document. Fix: use ASCII parentheses.

  3. README.md:3 says section 7 is "target, pending #2029", but #2029 merged at 4d081fe and is on current main. The same PR link appears at Approval.md:168, BackgroundExec.md:17, FileReads.md:18,76,156, runtime-owner-operations.md:26 and background-task-output.md:74. Fix: link docs/adr/027-cross-scope-access-by-id.md and the principles section 7 anchor, and drop the pending label.

  4. Approval.md:93 says unknown and line 103 says closed while the error kinds and the appendix use PascalCase (Unknown, Closed). A migration reader matching the backticked strings can miss the wire codes. Fix: use Unknown and Closed in both sentences.

  5. Permission.md:162 says every parameter and reply is data, but advise takes a callback by reference (line 124), and the request column at line 85 lists caller: &Ctx while line 181 says the caller is not a request field. This is the only issue left from the withdrawn P2. Fix: say data or a callback by reference (service-faces section 1 rule 4), and show the request as {name, callback} with the caller noted separately.

  6. Approval.md removes the Rust-only respond and replay but no longer names their App Server callers. Current code calls Approval::respond at crates/dim-app-server/src/approval.rs:24 and crates/dim-app-server/src/collaboration/approvals.rs:162,342,707, and Approval::replay at approval.rs:39 and collaboration/approvals.rs:642. The client method approval.respond stays, so these sites must move to decide and pending. Fix: state the migration so the skip methods can be removed in one change.

Cross-PR and conflicts

  • #2102 at 3b48e12 now includes release, retain_only and adopted for Loop (Loop.md:67,145) and PromptAdoption.md:85-96 defines configure and invalid_model; the earlier P2 is fixed. ToolBinding.md:18 omits adopted from Loop's call list while #2102 lists it; the operation exists, so this is a minor wording mismatch.
  • #2103 at 59a77a3 keeps the async declarations and the message-only adopt errors; P2 1 remains.
  • #2101 at 18d5e4f rewrites Hooks.md and edits README.md and service-faces.md, which this PR also edits. Expect a textual conflict; #2101 already cites Permission.advise and Approval.decide.
  • #2093 at 53961a1 also edits runtime-owner-operations.md and session-boundary.md, and its runtime-owner-operations.md still has the old toolBinding row. Its SessionScope hold/release and FileAccessFacts check shapes match this PR's requirements.
  • #2094 at 0677c71 defines permissionRules.rules as this PR requires. Its changed docs/design/appserver/permission-command-rules.md:27,266,305 still says Approval's methods, approval.respond and replay are unchanged; the client method keeps its name, but the Rust respond and replay do not.
  • #2098 at c3acab3 and #2099 at 8f440bd reference approval.respond as a client method; this PR keeps that name, so those references stay valid, but both PRs also edit README.md or service-faces.md and will conflict textually.
  • #2029 is merged on current main at 4d081fe. ADR 027 is present and proposed; the PR's links to the pull request should become links to the ADR.

Verification

  • Head 437266b verified in the detached worktree. origin/main is bf3a4e6; git merge-tree --write-tree origin/main HEAD is clean.
  • LC_ALL=en_US.UTF-8 with isolated HOME and TMPDIR under the data directory. node scripts/adr-check.mjs --base 5a279d69 passed; a local Markdown link check over the 12 changed files found 0 broken links. No Rust tests were run because the change is docs-only. No processes were started, so none remain.
  • CI: changes and ci-ok succeed; the other jobs are skipped for a docs-only change. mergeStateStatus is BLOCKED by review, not by CI.

}).await?, // AlreadyBound, Invalid, Unavailable, Closed
None => {
// No tool part: declare the registry's current host and contributed tools.
let current = registry.declarations()?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registry.declarations() is called synchronously here and at line 82. PR #2103 at 59a77a3 declares pub async fn declarations and awaits it (ToolRegistry.md:82,340). The sample does not compile against the sibling contract. Fix: use registry.declarations().await? in both places, or change #2103 to sync and state the async boundary.

| `invalid` | `bind` | No | The registry refused the declarations; the error names the declaration and the reason; fail the turn and report them. |
| `unavailable` | `bind` | Yes, after re-preparing | The prefix declares a source version the registry no longer retains; re-prepare from the current declarations, or fail the turn. |
| `no_record` | `adopted`, `claim`, `transfer` | No | The request has no record: a caller bug or a request released before its batch; fail the turn as a fault. A reload settlement is not this error. |
| `callback` | `claim` | Depends on the cause | The contributor's claim callback refused; the error carries the call id, and the callback's own code in `reason` and its message in `message`. The batch is not published; the turn fails unless the cause says the call may be retried in a later request. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This callback row and the appendix at line 287 require call_id, but #2103's ToolError::Callback carries only cause.code and cause.message (ToolRegistry.md:218,245), and claim answers only the claimed ids on success (ToolRegistry.md:108). A refused batch therefore cannot name the call. #2103's invalid claim error (ToolRegistry.md:122) also has no mapping here. Fix: add the call id and map invalid in #2103, or drop call_id and define the mapping here.

| `callback` | `claim` | Depends on the cause | The contributor's claim callback refused; the error carries the call id, and the callback's own code in `reason` and its message in `message`. The batch is not published; the turn fails unless the cause says the call may be retried in a later request. |
| `closed` | any | No, in this generation | The branch is closing or reloading; the turn ends; a replacement generation serves the next request. |

`bind` errors carry the declaration that failed (`name`) or the source that is gone (`key`, `version`); the owner reports no failure the record cannot have.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind errors are documented with the failed declaration's name and the source's key/version, but #2103's adopt refuses with Invalid { message } and Unavailable { message } (ToolRegistry.md:212-219). ToolBinding cannot fill these fields from a batch refusal without parsing the message. Fix: add the structured fields to #2103's adopt errors, or narrow BindingError to what the registry returns and state the change.

| --- | --- | --- | --- |
| `PreToolUse` | `Approval::admit(AdmitCall {source, call}, risk, cancel)` calls `Permission::decide(call, risk, cancel)` for the admission and again for the recheck after an allow; `decide` already awaits the command-rules port; a Deny becomes `HostError::failed(reason)`, the error text of the call's result | `decide` cannot ask anyone else, does not receive `source` (the call id is only in `AdmitCall.source`), and cannot tell the admission from the recheck | A.6.1: Approval passes `source` to the admission decision only; Permission calls its registered advisors there. ToolExecutor needs no change |
| `PermissionRequest` | `approval/request {approval_id, source, call, reason}`; `Approval::respond(approval_id, decision)` accepts the first consumed response, else `Unknown`/`Cancelled`/`Closed`; `approval/respond {approval_id, decision}` has no reason | No reason on a deny | Usable as is; a hook deny shows Approval's generic text (decision 7) |
| `PermissionRequest` | `approval/request {approval_id, source, call, reason}`; `Approval::respond(approval_id, decision)` accepts the first consumed response, else `Unknown`/`Cancelled`/`Closed`; `approval/respond {approval_id, decision}` has no reason | The target renames the operation to `approval.decide(approvalId, decision)` ([Approval](../plugins/Approval.md)); the fact and the client method keep their names | `decision` accepts the first consumed answer, else `unknown`; a hook deny shows Approval's generic text (decision 7) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval.md:113 says respond is removed as the Rust-only skip method and decide is already the face's operation; it is not renamed. The codes are Unknown, Failed and Closed (Approval.md:194-195), not unknown, and the advisor duplicate is Duplicate (Permission.md:100), not duplicate at line 504. A delivery task following this row can rename respond into a collision with the existing decide (crates/dim-agent-capabilities/src/approval.rs:91) and match the wrong wire codes. Fix: say respond is removed and decide is unchanged, and use the owner contracts' spellings. Since #2101 at 18d5e4f rewrites Hooks.md, dropping these Hooks edits from this PR is the simpler fix.

```rust
let reply = reads.binding(BindingRequest { path: canonical, purpose: Purpose::Edit }).await?;
let binding = match reply {
BindingReply::Bound(binding) => binding,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bound is a struct variant, Bound { binding: TextFileBinding } (FileReads.md:230-231), so this tuple pattern does not compile. The first example at line 45 uses the struct form. Fix: BindingReply::Bound { binding } => binding.

| Context RPC → target branch | `agentLoop.compact` and `contextUsage.read`. |
| Goal and Shell admission → timelineTree | `directory({id})` returns the matching directory entry or the unknown-branch error using a single-branch lookup. Goal reads ended history through `query`; writes retain the ended/unknown errors. |
| InputQueue and Collaboration approvals → target branch | `timelineTree.input`, `inputQueue.withdraw` after submission checks, and `approval.pending/decide` on the selected branch. |
| InputQueue and Collaboration approvals → target branch | `timelineTree.input`, `inputQueue.withdraw` after submission checks, and `approval.pending/decide` on the selected branch([Approval](../plugins/Approval.md)); the caller reaches the line's owner by line id ([ADR 027](https://github.com/arcships/dim/pull/2029)). |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new links at lines 26, 48, 63, 76 and 77 use full-width Chinese parentheses in an English document. Fix: replace them with ASCII parentheses.

# Plugin designs

Designs of the new plugins and proposed supplements to existing plugins in the [overall design](../overview.md). Local-execution plugins and their capabilities are documented in [architecture/rust-agent/plugins](../../architecture/rust-agent/plugins/README.md). Rules: [design rules](../../architecture/rust-agent/principles.md) §1 and §4, [ADR 002](../../adr/002-plugin-scope.md), [plugin contract](../plugin-contract.md) ([ADR 006](../../adr/006-plugin-contract.md)). Shared contracts: [session-access](../contracts/session-access.md), [session-boundary](../contracts/session-boundary.md).
Designs of the new plugins and proposed supplements to existing plugins in the [overall design](../overview.md). Local-execution plugins and their capabilities are documented in [architecture/rust-agent/plugins](../../architecture/rust-agent/plugins/README.md). Rules: [design rules](../../architecture/rust-agent/principles.md) §1 and §4, [§7 owners and operations](https://github.com/arcships/dim/pull/2029) (target, pending #2029), [ADR 002](../../adr/002-plugin-scope.md), [plugin contract](../plugin-contract.md) ([ADR 006](../../adr/006-plugin-contract.md)). Shared contracts: [session-access](../contracts/session-access.md), [session-boundary](../contracts/session-boundary.md).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2029 merged at 4d081fe and is on current main, so section 7 is no longer pending. The same PR link appears at Approval.md:168, BackgroundExec.md:17, FileReads.md:18,76,156, runtime-owner-operations.md:26 and background-task-output.md:74. Fix: link docs/adr/027-cross-scope-access-by-id.md and the principles section 7 anchor, and drop the pending label.

| `Cancelled` | `admit` | No | The batch token was dropped or the batch was interrupted; do not run the call. |
| `Failed` | `admit`, `decide` | Yes, by a later attempt | The request or response could not be committed (storage or fact failure); nothing is pending for the call, or the answer did not take; the owner reports a fault and the turn fails. A repeated call is a new admission or a fresh answer. |
| `Closed` | any | No, in this generation | The generation is closing or reloading; stop; a replacement generation serves the next request. |
| `Unknown` | `decide` | No | The request is no longer pending; retire the prompt and do not retry the answer. A repeated answer is `unknown` too. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error kinds and the appendix use PascalCase (Unknown, Closed and the rest at Approval.md:194-195), but this row's prose says unknown and line 103's says closed. A cross-language caller matching the backticked strings can miss the wire codes. Fix: use Unknown and Closed in both sentences.

| §7 resources and objects | No resource; no object crosses. Advice is a callback by reference. |
| §7 no proxy | The owner answers its own decision and publishes its own state. |
| §7 one surface | `decide`, `update`, `advise`, and the published value; `admit_decision`, `check` and the separate `decide` are removed. |
| §7 cross-language | Every parameter and reply is data; the decision is a value, not an error. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row says every parameter and reply is data, but advise takes a callback by reference (line 124), and the request column at line 85 lists caller: &Ctx while line 181 says the caller is not a request field. Fix: say data or a callback by reference (service-faces section 1 rule 4), and show the request as {name, callback} with the caller noted separately.

@eric8810

Copy link
Copy Markdown
Collaborator Author

Closing as part of abandoning the owner-split experiment.

@eric8810 eric8810 closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants