Repository navigation
Conversation
|
评审(head
|
|
已按评审修改,head
|
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Scope: This PR adds target owner contracts for the connection, entry and UI owners (Connection, Transport, Rpc, ManagementMethods, CallChannel, ServerControl, ProcessRoot, UiHost, UiExtensions, UiResources) and rewrites the Report and EnvironmentClients contracts around them, changing service faces, error codes, cancellation text and reply shapes across the series tracked by #2018 and #2015.
Verdict: REQUEST_CHANGES
P1
1. CallChannel and ManagementMethods appendices cannot be served by the rutis service macro
Problem: CallChannel.md:157-160 puts run on a #[rutis::service] impl with RunRequest and CancellationToken parameters. RunRequest carries CallFn and is not Deserialize, and CancellationToken is neither serde data nor &Ctx; the rutis macro binds serde data, &Ctx, Definition, or a direct callback parameter, not a callback nested in a request struct and not a cancellation token. The same pattern appears at ManagementMethods.md:169-171, where RegisterRequest carries call. NotifyError at CallChannel.md:153-155 also has no Display impl, so it cannot be the error of a marked method; after adding one, its missing serde tag makes rutis derive the code from the Debug variant (Undeclared) instead of the documented undeclared.
Failure scenario: an implementer cannot compile the appendix. Moving it to a hand-written dispatch is possible, but then the "same binding rutis already gives" claim at CallChannel.md:121 does not describe the marked-service form, and the callback's error type at CallChannel.md:127 does not match the example callback at CallChannel.md:45, which returns Result<CallReply, TableError>; a provider error also needs From<rutis::host::CallError> for the supported callback form.
Fix: make the callback a direct method parameter (impl Fn() -> BoxFuture<'static, Result<X, E>> with E: From<rutis::host::CallError>), take cancellation from the caller's token instead of a parameter, or keep the operation on a native HostDispatch and state that it is Rust-only. Define a RunError with a serde code for duplicate, and add Display plus #[serde(tag = "code", rename_all = "snake_case")] to NotifyError.
2. Connection.close_for_idle changes the public daemon_busy wire contract
Problem: Connection.md:108 and Connection.md:197-200 serialize the refusal as code busy with fields connections, attachedSessions and runningSessions. The existing public contract is daemon_busy with connections, attachedSessions and running (crates/dim-app-server/README.md shutdown section, docs/design/plugins/Tui.md:467-468, and the parser at crates/dim-cli/src/client.rs:741-749). The request also takes held_work, but Busy has no held_work field, so a refusal caused only by held process work reports three zero counts.
Failure scenario: shutdown_if_idle no longer matches daemon_busy, so the CLI cannot report why a daemon of another build stayed up; and even if it matched, running reads as absent. A client that shows the refusal counts sees 0/0/0 when a Workflow or Scheduler hold is the only reason.
Fix: keep the wire code daemon_busy and the field running, or state the Rpc mapping from busy to daemon_busy and from runningSessions to running; add held_work to Busy or give process-work refusal its own kind, matching the existing README rule that process-work refusals carry an explanation without counts.
3. Closing a connection now interrupts an accepted call, contradicting the existing methods contract
Problem: ManagementMethods.md:63 says "The calling connection closing ends the call as interrupted", Rpc.md:55 and Rpc.md:74 repeat it, and CallChannel.md:92 says "A connection close interrupts the call through its cancellation". The established contract says the opposite: docs/design/contracts/session-boundary.md A.1 says "A caller's disconnect cancels nothing", and A.2 says "A caller's disconnect cancels no call"; the admitted call belongs to the provider generation and settles according to its interruption declaration.
Failure scenario: a user closes the TUI while a management call is running (report generation, a Scheduler watch, a Workflow call). The new contracts say the provider's call is interrupted, so accepted work is cancelled or reported as interrupted, while the old contract says the provider continues and only the reply is dropped. This changes user-visible durability and makes the interruption table in A.1 unreachable for disconnects.
Fix: state that a closing connection stops delivery only and does not cancel the call, matching A.1 and A.2, or make the change explicit as a new cancellation decision with the affected callers and their settlement updated in the same owner change.
P2
4. Wire error-code mapping is missing across the rewritten faces
Problem: the new contracts use short kinds that do not match the established public codes: Rpc.md:55-67 and ManagementMethods.md:63 use reloading, unavailable and interrupted where docs/design/contracts/session-boundary.md:57-58, 112, 246, 507 requires service_reloading, service_unavailable and operation_interrupted; Report.md:126-134 uses not_found, stale, busy, model_unavailable, generation_failed, cancelled and invalid where crates/dim-report/src/draft.rs:244-416 and crates/dim-report/tests/report_flow.rs:425-528 use report_not_found, report_plan_stale, report_busy, report_model_unavailable, report_generation_failed, report_cancelled and invalid_params; UiResources.md:59-72 uses gone and invalid where docs/design/client-ui-extensions.md:208 and 437 define resource_gone, invalid_params and session_closed; Transport.md:47-55 uses invalid where crates/dim-app-server/src/transport.rs:294-305 returns invalid_path. Rpc.md:55 also omits unavailable from request errors even though ManagementMethods.md:63 returns it.
Failure scenario: an implementer following these owner contracts exposes new codes. The CLI, the TUI report dialog, the desktop and web panels, and the existing tests stop matching, so expiry, stale plan, busy, failed namespace and invalid path become generic errors. A call into a failed namespace has no defined Rpc error at all.
Fix: add one mapping table per owner from its kinds to the existing wire codes, and include unavailable in Rpc's request errors; or use the wire codes directly in the owner contracts and update the callers in the same owner change as section 7 requires.
5. ManagementMethods.call does not type the handler's own error
Problem: ManagementMethods.md:67 says a call's reply is MethodReply data, "a value, or the handler's own error with its code and message", but the appendix at ManagementMethods.md:130-132 defines only CallReply { reply: serde_json::Value }, which does not express the MethodReply | MethodError distinction, and TableError has no handler-error variant. The canonical shape in docs/design/contracts/session-boundary.md A.1 is MethodReply or MethodError.
Failure scenario: a report, Scheduler or Workflow handler that returns its own error has to smuggle it into an untyped successful value, which Rpc cannot distinguish from a value reply without a tag, or lose it because call returns only TableError. Every management and Session method error is affected.
Fix: define MethodReply as an enum (value or error with code and message), return it from call, and let Rpc map the error variant; do not flatten it to serde_json::Value.
6. Connection and Rpc disagree on which operation writes a reply
Problem: Connection.md:100 defines write_after as "Write one notification after the reply of one call", and CallChannel.md:67 uses it for notifications. Rpc.md:41 uses connection.write_after(... frame: reply.frame) to write the reply itself, while Rpc.md:48 lists only write_after and attached as Connection dependencies and never uses or declares write. The two roles cannot share the same request meaning without the owner knowing whether call_id names a reply to write or a reply to follow.
Failure scenario: an implementer treats the Rpc call as a notification and holds it behind a reply that does not exist, or treats a CallChannel notification as a reply and releases the held queue too early. Either way the reply ordering that write_after exists to guarantee can be wrong.
Fix: define separate operations for the reply and the notification (for example reply and write_after), or document one operation that distinguishes the two roles and make both Rpc and CallChannel declare it consistently.
7. ServerControl.hold promises row-unload release without a caller identity
Problem: ServerControl.md:77 takes {} for hold, with no &Ctx or row id, but ServerControl.md:85, 104 and 112 say the calling row's unload releases its holds. The owner cannot know which row called, and the appendix at ServerControl.md:155 has the same shape.
Failure scenario: an unloaded Workflow or Scheduler row leaves its hold behind. A graceful shutdown then waits until the process is forced down, exactly the state the contract says is reserved for a crashed row.
Fix: take the calling row's context as a &Ctx parameter, as UiResources.publish does at UiResources.md:153, or include a row id in the request and register the cleanup on that row. State which of the two the owner uses.
8. UiHost.shutdown documents an error the contract cannot produce
Problem: UiHost.md:76 lists ui_detached for shutdown, and UiHost.md:199 explains it, but the Errors table at UiHost.md:86-94 and the UiError enum at UiHost.md:169-183 do not contain it. The current code does return ui_detached (crates/dim-app-server/src/ui_host.rs:492-497).
Failure scenario: the appendix cannot produce the documented wire code, and a client cannot match the between-detach-and-reattach refusal.
Fix: add UiDetached to UiError and to the Errors table, or remove the error from the operation row and the appendix note.
9. EnvironmentClients contradicts itself and keeps the old face name
Problem: EnvironmentClients.md:5 says the part is a read projection of the App Server's connection and UI registries, while the new EnvironmentClients.md:13 says the branch does not read either registry. EnvironmentClients.md:136, 166 and 190 still say SessionClientsHost provides or is the public read port, while Connection.md:94 and EnvironmentClients.md:171 make the face connection.presences.
Failure scenario: the same contract both forbids reading another owner's registry and requires it. An implementer cannot tell whether to inject SessionClientsHost or connection, and the rule check at line 190 still names a face that the new Connection contract removes.
Fix: change line 5 to say the part reads connection.presences, and replace the three SessionClientsHost references with the connection face or delete the stale rows.
10. Connection claims UI-leaf attribution arrives as a UiHost fact, but UiHost defines no such fact
Problem: Connection.md:168 says the UI-leaf attribution "arrives as UiHost's fact, not as a read of its registry". UiHost.md:69-78 defines open, attach, replace, status, close, shutdown, detach and release, and UiHost.md:154-161 defines Instance without a connection id. There is no attribution value, operation or event. The current code reads the UiHost registry directly at crates/dim-app-server/src/connection.rs:2262-2295 and is_leaf_connection.
Failure scenario: Connection cannot produce the one-tui-entry dedup required at EnvironmentClients.md:105 without reading the UiHost registry, which this row forbids. Presence then either counts a TUI leaf twice or loses it.
Fix: add a UiHost value or operation such as attribution(connection_id) returning the leaf kind and session, or let UiHost compute presence and expose the projection; then name it in Connection's Dependencies.
11. Connection's contract omits the notifications its consumers require
Problem: Connection.md never names the ClientsChanged process event, while EnvironmentClients.md:18, 137 and 169 require Connection to emit it on attach, detach, UI changes and connection finish. It also does not name the ui.extensions.changed delivery that UiExtensions.md:30, 87 and 169 assign to Connection, and no contract defines how a client asks for it; the existing notification is ui.extensions.changed (docs/design/client-ui-extensions.md:438).
Failure scenario: the branch gets no wake-up after branch open, so the model's client snapshot goes stale. A published UI directory change also never reaches a client, or Connection has to read UiExtensions state without a named operation.
Fix: state both process events and their triggers in Connection's scope, and define the subscription or request by which a client is told about the UI directory revision, using the existing client notification name.
12. Report's plan reply drops the material and limits the interaction promises
Problem: Report.md:116 defines the plan reply as {planId, generation, evidence, instructionsStatus}. Report.md:82 says "With a model selected, the dialog exposes the exact model material and limits before Generate can send it", and Report.md:154 says the plan shows the exact prompt material, the chosen provider/model, output limit and an estimate. The base version of this contract had material, maxOutputTokens and estimatedCost; this PR removes them from the reply and the appendix.
Failure scenario: a client cannot render the material, output limit or cost estimate it must show before a paid one-shot call, so Generate can run values the user did not review. The reviewed-plan guarantee in the Ablation section is no longer supported by a field.
Fix: restore the fields in the plan reply and the appendix, or remove the client interaction promise and the reviewed-material requirement; do not leave both.
13. CallChannel removes the after-call notification window and the progress operation
Problem: CallChannel.md:99 says a notification sent after the callback returned is gone, and CallChannel.md:77 removes the binding when the callback ends. docs/design/contracts/session-boundary.md A.2 says the provider may keep the native Caller after the call returns and notify until the connection closes or the Rpc load unloads. The new operation list at CallChannel.md:71-75 also has no progress, although A.2 defines progress and ManagementMethods.md:147 still declares MethodDecl.progress; the run callback at CallChannel.md:127 has no progress argument.
Failure scenario: a provider that notifies from a background task after returning, or Scheduler's schedule.watch progress, has no operation to use; the only choices are gone notifications or moving the work into the callback and blocking the reply. This is a behavior change from A.2, not a spelling change.
Fix: keep the after-call window and the progress operation, or state where those responsibilities move and how existing providers migrate. Define how the run callback receives the progress sink if the progress declaration stays.
14. The Agents contract link is a forward reference to PR #2098
Problem: Connection.md:90 links [Agents contract](Agents.md), but docs/design/plugins/Agents.md does not exist at this head; the Agents contract is in PR #2098.
Failure scenario: the dependency shapes acquire {sessionId} -> {leaseId, generation}, release {leaseId} and sessions cannot be checked, and the relative link is broken for readers.
Fix: land PR #2098 first, or link that PR or its issue until the document exists.
P3
15. Connection.write conflates reply and notification limits
Problem: Connection.md:112 says write refuses a frame over the frame budget with too_large while keeping the connection open, and the Errors table at Connection.md:120-129 says too_large means the provider must shorten its notification. write is also the generic frame writer, so a caller that writes a reply through it has no defined outcome. docs/design/contracts/session-boundary.md A.2 applies too_large to notifications and closes the connection when the reply allowance is exhausted.
Failure scenario: an oversized reply (for example a large hello or generate reply) is refused with the connection still open, leaving the call unanswered.
Fix: state the reply limit and what Rpc writes after a refused reply, or separate the reply and notification limits and errors.
16. ProcessRoot retires localId without updating the documents that still list it
Problem: ProcessRoot.md:65 retires the localId.get data face, but docs/design/service-faces.md:81 still lists localId as a data face provided by root, and docs/design/resource-faces.md:634 cites localId.get as an existing sync operation.
Failure scenario: readers see a retired face still listed as target behavior.
Fix: update those documents or note the owning change that removes the face.
17. UiHost's "process root" dependency is not an operation ProcessRoot owns
Problem: UiHost.md:65 says UiHost depends on "the process root for mounting a leaf session", but ProcessRoot.md:5-15 gives the root only three values (reserved method policy, credential variable names and the peer id), and no mount operation.
Failure scenario: UiHost.open has no owner operation for the mount and cannot be composed from the named dependency.
Fix: name the actual mount operation and owner, or add it to ProcessRoot's contract.
18. Report keeps local section references after the headings are unnumbered
Problem: this PR removes the numbers from the headings at Report.md:86 and Report.md:105, but Report.md:82, 84 and 156 still refer to local section 3 and section 7. Section 7 also collides with the design rules' section 7.
Failure scenario: the evidence, CLI menu and one-shot policy references cannot be resolved.
Fix: restore the numbers or replace each reference with the section title.
19. ServerControl caller examples do not match the appendix
Problem: ServerControl.md:42 treats hold as an Option although it returns Result<HoldReply, ActivityError> at line 155; ServerControl.md:50-52 passes ShutdownMode directly although shutdown takes a mode request at line 80, and names ShutdownError while the appendix defines ActivityError at lines 142-149.
Failure scenario: copied examples do not compile.
Fix: use the request structs and error names from the appendix.
20. Rpc's hello reply leaves the new records field undefined
Problem: Rpc.md:54 and Rpc.md:110 add records: Vec<String> to the hello reply, but the text never says what a record is, and the caller example at Rpc.md:38 discards it. The example at Rpc.md:41 also reads reply.frame while the appendix defines RequestReply { reply: Reply }.
Failure scenario: an implementer cannot tell whether records is the method or feature list already carried by the hello payload, and the reply example does not match the type.
Fix: define records, or remove it and keep the hello result in reply; fix the example field name.
21. The rule-check rows cite a design-rules section that only exists in PR #2029
Problem: the rule-check tables in the new owner documents (for example CallChannel.md:110-112, Connection.md:167-168, Rpc.md:90, ServerControl.md:124 and UiResources.md:96) cite rules from section 7 of the design rules, but docs/architecture/rust-agent/principles.md at this head has no section 7; the text is in PR #2029.
Failure scenario: readers of the merged document cannot resolve the cited rules, and the rule-check tables cannot be verified against the repository state.
Fix: land PR #2029 first, or qualify the references with that PR until it merges.
|
|
||
| #[rutis::service(name = "callChannel")] | ||
| impl CallChannel { | ||
| pub async fn run(&self, request: RunRequest, cancel: CancellationToken) |
There was a problem hiding this comment.
run cannot be bound by #[rutis::service]: RunRequest holds CallFn and is not Deserialize, and CancellationToken is not serde data, &Ctx, or a direct callback. Rutis supports a callback only as a direct parameter (impl Fn() -> BoxFuture<'static, Result<X, E>>, E: From<rutis::host::CallError>). The example at line 45 also returns Result<CallReply, TableError>, not Result<serde_json::Value, CallError>. Failure: the appendix does not compile and the central call binding cannot be published. Fix: make the callback a direct parameter, keep cancellation in the caller's token, or move run to a native HostDispatch and mark it Rust-only.
There was a problem hiding this comment.
Partially fixed in c9d3ef9. The callback is now a direct parameter and RunRequest no longer carries it. Still open: CallFn returns Result<MethodReply, MethodError> with no conversion to the runtime error, and run takes a second callback parameter (CancelledFn). See the inline on the run signature.
There was a problem hiding this comment.
Partially fixed in 82c6f8e. run now takes one direct callback (CallChannel.md:210-215) and RunError has From<rutis::host::CallError> (CallChannel.md:189-193), so the marked service binds. Still open: the example at CallChannel.md:57 calls error.into_call_error(), which no type defines, and returns Result<_, rutis::Error> where run requires Result<_, RunError>; add a TableError conversion to RunError and use it in the example.
There was a problem hiding this comment.
Partially fixed in fa2eea2. The callback is a direct parameter and RunError: From<rutis::host::CallError> is defined (CallChannel.md:198-202,219-224), but the appendix now references CallOutcome and TableError, which no document defines after the last commit removed them from ManagementMethods (CallChannel.md:150,189,223). The marked service cannot compile until those types have one owner. See P2 #1 in the body.
|
|
||
| #[rutis::service(name = "managementMethods")] | ||
| impl MethodTable { | ||
| pub async fn register(&self, request: RegisterRequest) -> Result<(), TableError> { /* ... */ } |
There was a problem hiding this comment.
register is on a marked service impl, but RegisterRequest is undefined and carries call, a callback by reference. Rutis cannot decode a callback nested in a request struct; the current foreign registration uses a hand-written HostDispatch (ForeignMethods in crates/dim-agent-capabilities/src/methods.rs:1093-1139) for this reason. Failure: the appendix cannot compile. Fix: make call a direct parameter with the row's &Ctx, or take register off the marked face and document the native and foreign bindings separately.
There was a problem hiding this comment.
Partially fixed in c9d3ef9. register now takes caller: &Ctx and a direct call: HandlerFn. Still open: HandlerFn uses the same MethodError return with no conversion, and the marked service must bind two callback parameters on run. See the inline on the run signature.
There was a problem hiding this comment.
Partially fixed in 82c6f8e. register takes caller: &Ctx and a direct call (ManagementMethods.md:222-228). Still open: the prose at ManagementMethods.md:77 requires TableError: From<rutis::host::CallError>, but the appendix at ManagementMethods.md:201-218 does not implement it, and the example at ManagementMethods.md:34-42 still returns Result<MethodReply, MethodError> where the callback is Result<CallOutcome, TableError>. Both are needed for the appendix to compile under rutis 0.19.3's callback bound (service.rs:754-758,827-831).
There was a problem hiding this comment.
Fixed in fa2eea2 for the original defect. register is a native trait, the callback returns MethodReply with #2103's MethodCallbackError: From<rutis::host::CallError>, and the example returns the same (ManagementMethods.md:38-41,76,134-168). The cross-PR type placement and the A.1 shape mismatch are in P2 #2 in the body.
| | `attached` | Whether a connection views a Session now | `{connection_id, session_id}` | `{attached}` | None | none | | ||
| | `presences` | The live clients of a Session | `{session_id}` | `{presences: [{channel, label?}]}` | None | none | | ||
| | `counts` | Live connections and attached Sessions, excluding one connection | `{exclude_connection_id}` | `{connections, attached_sessions}` | None | none | | ||
| | `close_for_idle` | Commit the daemon's refusal of new clients when nothing uses it | `{exclude_connection_id, running_sessions, held_work}` | `{counts}` | None | `busy{connections, attached_sessions, running_sessions}` | |
There was a problem hiding this comment.
Busy at lines 197-200 serializes as busy with runningSessions; the existing public contract is daemon_busy with running (crates/dim-cli/src/client.rs:741-749, docs/design/plugins/Tui.md:467-468, crates/dim-app-server/README.md shutdown section). The request also takes held_work, but Busy has no such field, so a refusal caused only by process work reports three zero counts. Failure: shutdown_if_idle stops matching daemon_busy and cannot report why the daemon stayed up. Fix: keep the code and field names, or state the Rpc mapping and add held_work.
There was a problem hiding this comment.
Fixed in c9d3ef9. close_for_idle now takes running, and the contract maps busy to daemon_busy with connections, attachedSessions and running; held_work is gone. One residual shape issue: the operations row returns three fields while Counts has two.
| | Operation | Normal path | Caller cancels | Caller unloads | Owner closes or reloads | Settled by | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `hello` | Check the version window and the entry, record the greeting, build the method list | — | — | New hellos are refused as `reloading`; open connections stay | Rpc | | ||
| | `request` | Route, admit through the table with the caller identity and `call_id`, return the reply; commands settle in Rpc's tracker | A closing connection ends the call as interrupted | The call ends and its commands settle | An unloading generation cancels its commands, answers pending waits as interrupted and drains before unload; connections stay open | Rpc: the commands | |
There was a problem hiding this comment.
This flow row says a closing connection ends the call as interrupted, and CallChannel.md:92 says the connection close interrupts the call through its cancellation. docs/design/contracts/session-boundary.md A.1 says a caller's disconnect cancels nothing, and A.2 says a caller's disconnect cancels no call. Failure: closing the TUI cancels accepted report, Scheduler or Workflow work, which the existing contract says continues. Fix: say a closing connection stops delivery only, or make the new cancellation an explicit decision with the affected settlement updated.
There was a problem hiding this comment.
Partially fixed in c9d3ef9. Rpc and ManagementMethods now say a disconnect stops delivery only. Still open: CallChannel.run says the caller's token stops the callback, and the example passes one token to both table.call and run. See the inline on CallChannel.md:80.
There was a problem hiding this comment.
Fixed in 82c6f8e for this contract's path. Rpc.md:56,60 and CallChannel.md:23,87 now say a disconnect stops delivery only, and run no longer takes a cancellation token (CallChannel.md:210-215,222). Cross-PR residual: #2103 at 734d364 still says a closing connection ends a Session call as interrupted (SessionMethods.md:87,112); see the review body.
| | Operation | Intent | Request | Reply | Cancellation | Errors | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `hello` | Answer a client's greeting for this generation | `{connection_id, params}` | `{reply, records}` | None; the handshake is one step | `reloading` (no generation is serving), `invalid` (version, entry or hello fields), `closed` | | ||
| | `request` | Dispatch one call and settle what it starts | `{connection_id, call_id, request}` | `{reply}` | The calling connection closing ends the call as interrupted; an unload ends it by the method's declaration | `reloading`, `unknown_method`, `interrupted`, `invalid`, and the method's own error | |
There was a problem hiding this comment.
request lists reloading, unknown_method, interrupted, invalid but not unavailable, which ManagementMethods.md:63 returns. The established wire codes are service_reloading, service_unavailable and operation_interrupted (docs/design/contracts/session-boundary.md:57-58,112,246,507). Failure: a call into a failed namespace has no defined Rpc error, and clients matching the established codes stop working. Fix: add the table-to-wire mapping and include unavailable, or use the wire codes here.
There was a problem hiding this comment.
Fixed in c9d3ef9. Rpc uses service_reloading, service_unavailable, operation_interrupted and invalid_params, and request now includes unavailable.
| | --- | --- | --- | --- | --- | --- | | ||
| | `publish` | Publish a finalized regular file for interfaces | `{path, media_type}` | `{session_id, id}` | While the file is opened; nothing is registered | `invalid`, `unavailable`, `closed` | | ||
| | `withdraw` | Withdraw a reference this row published | `{reference}` | `{}` | None; the owner waits for admitted reads | `gone`, `invalid`, `closed` | | ||
| | `read` | One bounded page of a published file | `{reference, offset?, limit?}` | `{offset, bytes, total, media_type, data}` | The caller's token; the page stops, the reference stays | `gone`, `invalid` | |
There was a problem hiding this comment.
The face read takes {reference: {sessionId, id}, offset?, limit?} and returns gone or invalid (lines 69-72). The Ready contract docs/design/client-ui-extensions.md:208 and 437 defines the public method as {sessionId, id, offset?, limit?} with resource_gone, invalid_params and session_closed, and says data is base64. Failure: implementing this face changes the public request shape and error codes, breaking the browser and desktop clients and the validation cases. Fix: keep the client shape and codes, or state the mapping and update the client contract.
There was a problem hiding this comment.
Partially fixed in c9d3ef9. The error codes now match client-ui-extensions. Still open: read takes {reference: {sessionId, id}} while session.ui.resources.read takes {sessionId, id, offset?, limit?}. See the inline on UiResources.md:59.
There was a problem hiding this comment.
Fixed in 82c6f8e. read now takes the flat client shape {sessionId, id, offset?, limit?} (UiResources.md:59,128-137), and its error list matches the client codes (resource_gone, invalid_params, session_closed). The appendix is flat too, so session.ui.resources.read no longer changes shape.
| ## Exceptions with reasons | ||
|
|
||
| - `run` takes the callback by reference, like SessionScope's `withHold`: the callback is never called inside a commit lock, and it may notify through this owner while it runs. | ||
| - A notification sent after the callback returned is `gone`: the binding is the call's, not the connection's, so a provider that wants to react to the caller leaving uses `closed`, which is addressed by the connection and needs no binding. |
There was a problem hiding this comment.
This line says a notification sent after the callback returned is gone, and line 77 removes the binding when the callback ends. docs/design/contracts/session-boundary.md A.2 lets the provider keep the native Caller after the call returns and notify until the connection closes or the Rpc load unloads. The operation list at lines 71-75 also has no progress, although A.2 defines it and ManagementMethods.md:147 still declares MethodDecl.progress. Failure: background notifications and Scheduler schedule.watch progress have no operation. Fix: restore the after-call window and progress, or state where they move and how callers migrate.
There was a problem hiding this comment.
Fixed in c9d3ef9 for the after-call window and progress. Two residuals are reported: progress is now async with errors where A.2 says sync and dropped, and the binding has no Rpc-unload settlement. See the inline on CallChannel.md:111.
There was a problem hiding this comment.
Fixed in 82c6f8e. progress is sync and best effort (CallChannel.md:89,94), the entry lives until the connection closes, the Rpc load unloads or the row unloads (CallChannel.md:11,90,110-112), and notify lists unsupported (CallChannel.md:88,101,197-199). The after-call window is restored at CallChannel.md:117, so the Supersedes claim at line 121 now matches A.2.
|
|
||
| ### Dependencies | ||
|
|
||
| Rpc's current generation (`hello`, `request`), read by name on each frame; UiHost's `detach` and `release`; Agents' `acquire {sessionId} → {leaseId, generation}`, `release {leaseId}` and `sessions` ([Agents contract](Agents.md)). |
There was a problem hiding this comment.
| | `close_all` | Close every connection and wait for its tasks | `{}` | `{}` | None; the owner completes the close | none | | ||
| | `settle` (internal) | One connection ended: release its attachment, tell UiHost, end its writer | `{connection_id, reason}` | `{}` | None | none | | ||
|
|
||
| `write` and `write_after` are one operation family: `write_after` exists because a notification sent while a call runs must follow that call's reply, and only the connection's outbound queue knows the reply has been written. `write` refuses a frame over the connection's frame budget with `too_large`, and closes a connection whose reliable allowance is exhausted, reporting `slow` to the writer of that frame. |
There was a problem hiding this comment.
write is the generic frame writer, but this paragraph says too_large keeps the connection open and the Errors table tells the provider to shorten its notification. docs/design/contracts/session-boundary.md A.2 applies too_large to notifications and closes the connection when the reply allowance is exhausted. Failure: an oversized reply leaves the call unanswered on an open connection. Fix: state the reply limit and what Rpc writes after a refused reply, or separate the two limits and errors.
There was a problem hiding this comment.
Partially fixed in c9d3ef9. reply and write are separate. The reply's too_large outcome is still not stated.
|
|
||
| `check` is synchronous with the caller's registration: a table that proceeds without it would accept a namespace the protocol cannot route. The policy is a callback by reference the assembly binds; the check itself is data in and out. | ||
|
|
||
| `localId` has no operation. The peer id is a value (`rutis_bridge::LocalId`); the data face `localId.get` had no caller and is retired. |
There was a problem hiding this comment.
Retiring localId.get leaves existing target documents stale: docs/design/service-faces.md:81 lists localId as a data face provided by root, and docs/design/resource-faces.md:634 cites localId.get as an existing sync operation. Failure: readers see a retired face still listed as target behavior. Fix: update those documents or note the owning change that removes the face.
There was a problem hiding this comment.
Fixed in c9d3ef9. service-faces.md and resource-faces.md are updated, and ProcessRoot has a Supersedes entry.
|
已按评审修改,head 规则 A–G 与外部评审逐条: P1
P2
P3
规则 C/D/E/F
|
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Scope: This PR defines target owner contracts for the connection, entry and UI owners (Connection, Transport, Rpc, ManagementMethods, CallChannel, ServerControl, ProcessRoot, UiHost, UiExtensions, UiResources) and rewrites Report and EnvironmentClients around them, refs #2021 and #2015.
Verdict: REQUEST_CHANGES
Round 1 status
Fixed: P1 #2; P2 #6, #7, #8, #9, #10, #11, #12, #14; P3 #16, #17, #18, #20, #21.
Partially fixed: P1 #1, P1 #3; P2 #4, #5, #13; P3 #15, #19.
The fixed findings should be treated as resolved. The remaining defects are the residuals below.
P1
1. CallChannel.run still lets the caller's token stop the provider callback
Problem: CallChannel.md:80 says "The caller's token stops the callback", and the caller example at CallChannel.md:49-51 passes one cancelled value to both table.call and channel.run. Rpc.md:56 and ManagementMethods.md:71 say the caller's token stops only the wait and that a caller disconnect cancels nothing. docs/design/contracts/session-boundary.md:233 says the same. The binding has one token with two opposite meanings.
Failure scenario: a TUI closes while a report generation, a Scheduler watch or a Workflow call is admitted. Connection cancels its per-call token, Rpc passes it to run, and the callback stops, so accepted work is cancelled even though Rpc and ManagementMethods say it continues. This is the round-1 P1 #3 failure at the binding level.
Fix: remove cancelled from run and let the admitted call own interruption (the two unload events in A.1), or name it as the provider-generation/Rpc-unload token and state that Connection's disconnect token never reaches it. If both tokens exist, show both in the example.
2. The marked service still cannot bind the callback appendix
Problem: CallChannel.md:206-207 and ManagementMethods.md:213-216 put a callback parameter and CancelledFn on a #[rutis::service] method. CallFn and HandlerFn return Result<_, MethodError>, but MethodError (ManagementMethods.md:155) is a plain serde struct with no Display, no Error and no From<rutis::CallError>. The existing callback parameters in this tree return Result<_, rutis::Error> (crates/dim-agent-capabilities/src/host.rs:1169-1186). run also takes two callback parameters (call and cancelled), while the marked methods that take a callback take one. The "no runtime change" note at CallChannel.md:135 cites SessionScope's withHold and FileStorage's write source; SessionScope's target operation is hold/release (PR #2093, SessionScope.md:116) and FileStorage has no write source (PR #2080, FileStorage.md:30). The provider's caller is also lost: CallChannel.md:49 passes caller: None, so the handler has no connection or call id to use with notify or progress, although ManagementMethods.md:73 says caller is absent only for an in-process call.
Failure scenario: the appendix does not compile as a marked service. If it moves to a hand-written dispatch, the "same binding rutis already gives" claim is false and the callChannel face cannot publish run. The notify and progress examples cannot work because the provider has no call id.
Fix: make the callback return a type the runtime can carry (Result<MethodReply, RunError> with a Display error, or Result<_, rutis::Error>), keep one callback parameter, take cancellation from the admitted call, and pass caller: Some(CallerRef { connection_id, call_id }) into the table call. State the native HostDispatch binding if run stays Rust-only.
P2
3. MethodReply and MethodError do not match A.1
Problem: ManagementMethods.md:159-162 defines MethodReply as value | error and MethodError as {code: String, message: String}. A.1 defines MethodReply as {kind: "value", value} | {kind: "handedOff"} and MethodError as {code: number, appError: string, message: string} (docs/design/contracts/session-boundary.md:227-228). CallChannel.md:214 and ManagementMethods.md:105 say these shapes stay with A.1. The current wire envelope carries a numeric code and data.appError (crates/dim-agent-capabilities/src/methods.rs:24-47), and clients match appError (crates/dim-client/src/lib.rs:74).
Failure scenario: an implementer following the appendix emits a handler error without appError and with a string code, so the CLI, the TUI report dialog and the web panel cannot distinguish a handler error from a generic failure, and handedOff has no representation.
Fix: use A.1's shapes, or define a new canonical shape and update A.1 and every caller in the same owner change. Do not put Error in MethodReply while A.1 says every error is MethodError data.
4. FileStorage has no path-addressed offset read
Problem: UiResources.md:51 and UiExtensions.md:54,117 depend on FileStorage read {path, offset, length}. FileStorage's target contract defines open_read, read_at {read_id, offset} and close_read (PR #2080, FileStorage.md:30,146,180), and main's contract says the same (docs/architecture/rust-agent/plugins/FileStorage.md:43-63,350-352). The native form is FileStorage::open_read plus FileReader::read_at (crates/dim-agent-capabilities/src/file_storage.rs:230,412). No operation reads a path at an offset. UiResources.md:51 also says "No pinned reader id crosses", which the named dependency cannot satisfy.
Failure scenario: UiResources.read and UiExtensions.read cannot be composed from the dependency. An implementer either adds an unplanned FileStorage operation or keeps a reader id, contradicting the contract. This is the latest commit's central claim and it does not hold.
Fix: depend on open_read + read_at and state that the reader stays inside the calling owner (the id does not cross its boundary), or raise the path-addressed read as a FileStorage requirement on #2080.
5. close_for_idle returns a different shape than Counts
Problem: Connection.md:98 says the reply is {connections, attached_sessions, running}, but the appendix returns Counts (Connection.md:207), which has only connections and attached_sessions. The caller example at Connection.md:68 reads counts.
Failure scenario: an implementer following the table returns three fields and the appendix and callers read two, so the success reply has no defined shape.
Fix: add running to Counts and say it echoes the request, or return Counts in the table and keep the third count only in Busy.
6. UiResources.read changes the public client request shape
Problem: UiResources.md:59,130-136 uses {reference: {sessionId, id}, offset?, limit?}, and line 82 says this is the same read served as session.ui.resources.read. The client contract (docs/design/client-ui-extensions.md:208,437) and the current wire request (crates/dim-app-server/src/ui_extensions/resources.rs:161-174) are flat {sessionId, id, offset?, limit?}.
Failure scenario: a client that sends the published shape gets invalid_params, so "both stay" cannot hold. This is the remaining part of round-1 P2 #4 after the codes were fixed.
Fix: flatten ReadRequest to the client shape, or state the wire mapping and update the client contract in the same owner change.
7. CallChannel changes A.2's progress and lifetime wire semantics without saying so
Problem: CallChannel.md:111 says the wire semantics of notify, progress and closed are unchanged. A.2 defines progress as sync, best effort and dropped unless the method declared it (docs/design/contracts/session-boundary.md:289), and removes the entry when the admitting Rpc load unloads (session-boundary.md:344). The new contract makes progress async with undeclared, gone and too_large errors (CallChannel.md:82,89-94), drops notify's unsupported link error (A.2:290), and keeps the binding until the connection or row ends with no Rpc-unload rule (CallChannel.md:100).
Failure scenario: providers and links get different behavior after an Rpc reload or an undeclared or oversized progress notice, while the contract says nothing changed.
Fix: keep A.2's progress mode and drop behavior and add the Rpc-unload settlement, or list each change as a supersession and update A.2 in the same owner change.
8. Sibling contracts disagree with the shared call path and the idle close
Problem: ManagementMethods.md:128 and Rpc.md:110 say the Session table takes the same call request and MethodReply. PR #2103's SessionMethods.md:86-87,92,112,209-225 defines call(method, params, caller, cancelled) with separate arguments and a different MethodError, and keeps "the calling connection closing ends the call as interrupted". PR #2098's Agents.md:121 answers daemon_busy(running) when quiesce reports running, while Connection.md:147 says the daemon now closes gracefully instead of answering daemon_busy.
Failure scenario: Rpc cannot have one call path over both tables as written, and the idle-close outcome differs between two owner contracts that depend on each other.
Fix: #2103 owns the Session table shape and disconnect semantics, and #2098 owns the quiesce answer. Land those shapes before this claim, or narrow this PR's requirement to the management table.
P3
9. ServerControl's examples do not match the appendix
Problem: ServerControl.md:53 uses RpcError::invalid, which is not a variant of the Rpc appendix (Rpc.md:143-154), and line 54 needs a From<ActivityError> for RpcError that no appendix defines; line 42 also needs From<ActivityError> for WorkError. Failure scenario: copied examples do not compile against the target types. Fix: use InvalidParams { message }, state the conversions, or mark the block as pseudocode.
10. Report's Errors table still names a code the enum does not have
Problem: Report.md:127 says invalid while the operations and appendix use invalid_params; unavailable (line 128) has no counterpart in the current report code or the methods contract. Failure scenario: an implementer reading the table emits a code the owner never defines. Fix: rename the row to invalid_params and state the wire code for unavailable, or remove it.
11. RunError.Callback cannot serialize
Problem: CallChannel.md:183-184 serializes RunError::Callback with #[serde(tag = "code")] and a code field, which produces two code keys, and the Errors table has no callback row although the run row lists it. MethodReply::Error already carries the handler error, so the variant is redundant. Failure scenario: the callback error cannot cross a JSON boundary. Fix: drop Callback and return the handler error as MethodError data.
12. ProcessRoot is listed as a process part
Problem: docs/design/plugins/README.md:63 includes ProcessRoot in the process parts list, but ProcessRoot.md:82 says it has no plugin row and ProcessRoot.md:97 says "The root is the assembly, not a part". Failure scenario: the index contradicts the owner contract about whether a part exists. Fix: remove ProcessRoot from the list or state in both places that it is an owner value without a part.
13. process-owner-operations links are broken
Problem: docs/design/contracts/process-owner-operations.md:14-16 links ../../plugins/..., which resolves to docs/plugins/; the files are in docs/design/plugins/. Failure scenario: five owner-contract links 404. Fix: use ../plugins/....
14. Stale SessionClientsHost references remain
Problem: docs/design/agent-environment.md:104 still says SessionClientsHost is public, and docs/design/plugins/ClientView.md:50 names SessionClientsHost::presences, while this PR retires the face. Failure scenario: readers see two names for one read port. Fix: update both to connection.presences.
15. UiResources.read omits session_closed
Problem: the read row (UiResources.md:59) omits session_closed, although the owner defines it (line 72) and the client contract returns it after Session deletion (docs/design/client-ui-extensions.md:320). Failure scenario: the client has no defined code for a read after the Session closes. Fix: add session_closed to the read errors, or state that Rpc's Session routing answers it before the owner.
16. withHold and FileStorage's write source are forward references
Problem: CallChannel.md:106,135 cites SessionScope's withHold and FileStorage's write source. SessionScope's target operation is hold/release (PR #2093), and FileStorage's target reads are open_read/read_at/close_read (PR #2080). Failure scenario: the "no runtime change" argument rests on bindings that no contract defines. Fix: link the owning PR if a forward reference is intended, or remove the comparison.
Notes
- ADR check:
node scripts/adr-check.mjs --base 1bc7d67d7e3b357a64fd82c2589f57e4cb4b4becpasses. - Link scan: the five broken links in finding 13; no broken anchors.
- CI: ci-ok passed; the code jobs skip on this docs-only change.
|
|
||
| | Operation | Intent | Request | Reply | Cancellation | Errors | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `run` | Run one admitted table call with its caller's notifications enabled | `{connection_id, call_id, instance, notifications}` + `caller: &Ctx` + `call` | the callback's `MethodReply` | The caller's token stops the callback; the binding stays with the connection | `invalid_params`, `callback` | |
There was a problem hiding this comment.
run says the caller's token stops the callback, but Rpc.md:56 and ManagementMethods.md:71 say the caller's token stops only the wait and a disconnect cancels nothing (docs/design/contracts/session-boundary.md:233). The caller example at line 49 passes one cancelled value to both table.call and run. Failure: Connection cancels its per-call token when the client disconnects, Rpc passes it here, and the accepted report, Scheduler or Workflow callback stops, which is the round-1 P1 #3 behaviour at the binding level. Fix: drop cancelled from run and let the admitted call own interruption, or name it as the provider-generation/Rpc-unload token and show that Connection's disconnect token never reaches it.
There was a problem hiding this comment.
Fixed in 82c6f8e. run no longer takes cancelled; the admitted call is interrupted only by its provider or the Rpc load unloading (CallChannel.md:87,222), and the example uses the Rpc load's token (CallChannel.md:55-56). The caller example now matches Rpc.md:56 and ManagementMethods.md:71.
|
|
||
| #[rutis::service(name = "callChannel")] | ||
| impl CallChannel { | ||
| pub async fn run(&self, caller: &Ctx, request: RunRequest, call: CallFn, cancelled: CancelledFn) |
There was a problem hiding this comment.
run puts two callback parameters (call: CallFn and cancelled: CancelledFn) on a marked service method. CallFn returns Result<MethodReply, MethodError>, and MethodError (ManagementMethods.md:155) has no Display and no From<rutis::CallError>; the existing callback parameters return Result<_, rutis::Error> (crates/dim-agent-capabilities/src/host.rs:1169). The no-runtime-change note at line 135 cites SessionScope's withHold and FileStorage's write source; SessionScope's operation is hold/release (PR #2093) and FileStorage has no write source (PR #2080). The example also passes caller: None (line 49), so the provider has no connection or call id for notify/progress, although ManagementMethods.md:73 says caller is absent only in-process. Failure: the appendix does not compile as a marked service and the notify/progress examples cannot work. Fix: one callback parameter returning a runtime error type, pass caller: Some(...) into the table call, and state the native HostDispatch binding if run stays Rust-only.
There was a problem hiding this comment.
Partially fixed in 82c6f8e. The callback is one direct parameter returning Result<CallOutcome, RunError> (CallChannel.md:210-215), RunError: From<rutis::host::CallError> is defined (CallChannel.md:189-193), and the example passes caller: Some(CallerRef {...}) (CallChannel.md:49-52). Still open: the example at CallChannel.md:57 calls a nonexistent into_call_error and returns rutis::Error where run requires RunError, and ManagementMethods.md:77 claims a TableError: From<CallError> impl the appendix does not define. Both are in the review body.
|
|
||
| ## Supersedes | ||
|
|
||
| - [Methods contract](../contracts/session-boundary.md) A.2's Rust binding paragraph (`Caller`, `Callers`, `CallSite`): the operations above replace it; the wire semantics of `notify`, `progress` and `closed` are unchanged. |
There was a problem hiding this comment.
This Supersedes entry says the wire semantics of notify, progress and closed are unchanged. A.2 defines progress as sync, best effort and dropped unless declared (docs/design/contracts/session-boundary.md:289), and removes the entry when the admitting Rpc load unloads (session-boundary.md:344). This contract makes progress async with undeclared, gone and too_large errors (lines 82 and 89-94), drops notify's unsupported link error (A.2:290), and has no Rpc-unload settlement (line 100). Failure: progress and link behavior change although the contract says they do not. Fix: keep A.2's progress mode and errors and add the Rpc-unload rule, or list each change as a supersession and update A.2.
There was a problem hiding this comment.
Fixed in 82c6f8e. Progress is sync, best effort and dropped unless declared (CallChannel.md:94); the Rpc-unload settlement is in the lifetime and flows (CallChannel.md:11,90,110-112); unsupported is back in NotifyError and the Errors table (CallChannel.md:88,101,197-199). The Supersedes row at line 121 is now accurate.
|
|
||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
| #[serde(tag = "kind", rename_all = "snake_case")] | ||
| pub enum MethodReply { |
There was a problem hiding this comment.
MethodReply and MethodError are not the A.1 shapes. A.1 defines MethodReply as {kind: value | handedOff} and MethodError as {code: number, appError: string, message: string} (docs/design/contracts/session-boundary.md:227-228). This enum adds an error variant and reduces MethodError to a string code plus message, dropping appError. The current wire envelope carries a numeric code and data.appError (crates/dim-agent-capabilities/src/methods.rs:24-47), and clients match appError (crates/dim-client/src/lib.rs:74). CallChannel.md:214 and ManagementMethods.md:105 still claim these are A.1's shapes. Failure: every handler error loses its app code and handedOff has no representation. Fix: use A.1's shapes, or update A.1 and all callers in the same owner change.
There was a problem hiding this comment.
Fixed in 82c6f8e. MethodError is {code: i32, appError, message} (ManagementMethods.md:155-161) and MethodReply is value | handedOff (ManagementMethods.md:163-168), matching A.1 (session-boundary.md:225-228); appError is back and handedOff has a variant.
| } | ||
| ``` | ||
|
|
||
| `MethodError` is the handler's own `{code, message}` data; the handler returns it inside `MethodReply::Error` and the table never rewrites it. |
There was a problem hiding this comment.
This says the handler returns its error inside MethodReply::Error, but HandlerFn (line 180) returns Result<MethodReply, MethodError> and the register example at line 50 returns Result<MethodReply, MethodError>. The error travels as Err(MethodError), not inside Ok(MethodReply::Error). Failure: an implementer must choose one of two error channels; RunError::Callback (CallChannel.md:184) adds a third. Fix: pick one, return handler errors as MethodError data, and drop the Error variant and RunError::Callback.
There was a problem hiding this comment.
Partially fixed in 82c6f8e. The prose now sends the handler's own failure inside CallOutcome::Error and keeps table errors separate (ManagementMethods.md:75). Still open: the caller example at ManagementMethods.md:34-42 still returns Result<MethodReply, MethodError> while register expects Result<CallOutcome, TableError> (ManagementMethods.md:227); wrap the handler result in CallOutcome.
There was a problem hiding this comment.
Fixed in fa2eea2. The caller example passes ctx, namespace, declarations, call to the positional register and the handler returns Result<MethodReply, MethodCallbackError> (ManagementMethods.md:34-43,153-160), matching the appendix.
|
|
||
| ### Dependencies | ||
|
|
||
| FileStorage's offset read `read {path, offset, length}` and its path resolution for the file; SessionLifecycle's `closing` for the Session's end. No pinned reader id crosses. |
There was a problem hiding this comment.
FileStorage has no read {path, offset, length} operation. Its contract defines open_read, read_at {read_id, offset} and close_read (PR #2080, FileStorage.md:30,146,180), and main's contract says the same (docs/architecture/rust-agent/plugins/FileStorage.md:43-63,350-352); the native form is open_read plus FileReader::read_at (crates/dim-agent-capabilities/src/file_storage.rs:230,412). The same wrong dependency is in UiExtensions.md:54,117. Failure: UiResources.read and UiExtensions.read cannot be composed from the named operation, and "No pinned reader id crosses" cannot be satisfied. Fix: depend on open_read + read_at with the reader kept inside this owner, or raise the path-addressed read as a FileStorage requirement on #2080.
There was a problem hiding this comment.
Fixed in 82c6f8e. The dependency is now FileStorage's stateless read {path, offset?, length?} -> ReadReply {data, eof, size} | none and stat {path} (UiResources.md:51), which exists at #2080's head (FileStorage.md:161-162,170), and UiExtensions.md:54,117 uses the same read. No reader id crosses. The new client page-size and file-mutation questions are in the review body.
| | --- | --- | --- | --- | --- | --- | | ||
| | `publish` | Publish a finalized regular file for interfaces | `{path, media_type}` | `{session_id, id}` | While the file is opened; nothing is registered | `invalid_params`, `resource_unavailable`, `session_closed` | | ||
| | `withdraw` | Withdraw a reference this row published | `{reference}` | `{}` | None; the owner waits for admitted reads | `resource_gone`, `invalid_params`, `session_closed` | | ||
| | `read` | One bounded page of a published file | `{reference, offset?, limit?}` | `{offset, bytes, total, media_type, data}` | The caller's token; the page stops, the reference stays | `resource_gone`, `invalid_params` | |
There was a problem hiding this comment.
The read request is {reference: {sessionId, id}, offset?, limit?} and line 82 says this is the same session.ui.resources.read served to clients. The client contract (docs/design/client-ui-extensions.md:208,437) and the current wire request (crates/dim-app-server/src/ui_extensions/resources.rs:161-174) are flat {sessionId, id, offset?, limit?}. Failure: a client that sends the published shape gets invalid_params. Fix: flatten ReadRequest or state the wire mapping and update the client contract. The error codes are now aligned; the request shape is not.
There was a problem hiding this comment.
Fixed in 82c6f8e. The operations row says the flat {sessionId, id, offset?, limit?} shape (UiResources.md:59), and the appendix ReadRequest is flat (UiResources.md:128-137), so it matches client-ui-extensions.md:437 and the current wire request.
| | UI clients → UiHost / UiExtensions | Existing `ui.open/attach/replace/status/shutdown/close` RPCs and [extension listing, resources and notices](../client-ui-extensions.md). Transport supplies the authenticated connection identity. UiHost owns attach tokens, generations and disconnect cleanup. | | ||
| | Presence consumers → Connection | `connection.presences` ([Connection](../../plugins/Connection.md)). Connection serves this operation directly and handles broadcast, socket registration, writes, close and detach. | | ||
| | Activity consumers / daemon clients → ServerControl | `processActivity.activated/closing/hold/release/holds/shutdown/fault` ([ServerControl](../../plugins/ServerControl.md)); existing `daemon.ping/shutdown` RPCs. Shutdown settles the initiating reply before transport teardown. | | ||
| | UI clients → UiHost / UiExtensions | Existing `ui.open/attach/replace/status/shutdown/close` RPCs ([UiHost](../../plugins/UiHost.md)) and [extension listing, resources and notices](../client-ui-extensions.md) ([UiExtensions](../../plugins/UiExtensions.md), [UiResources](../../plugins/UiResources.md)). Transport supplies the authenticated connection identity. | |
There was a problem hiding this comment.
../../plugins/... from docs/design/contracts/ resolves to docs/plugins/, which does not exist. The five links to Connection, ServerControl, UiHost, UiExtensions and UiResources are broken. Use ../plugins/....
There was a problem hiding this comment.
Fixed in 82c6f8e. The five links now use ../plugins/... (process-owner-operations.md:14-16) and resolve under docs/design/plugins/.
| match activity.shutdown(ShutdownRequest { mode: ShutdownMode::Graceful }).await { | ||
| Ok(()) => { /* hold the reply until the assembly settles, then write it */ } | ||
| // Rpc maps this kind to the protocol's `invalid_params`: "Shutdown already requested". | ||
| Err(ActivityError::Conflict) => return Err(RpcError::invalid("Shutdown already requested")), |
There was a problem hiding this comment.
RpcError::invalid is not in the Rpc appendix, whose error is InvalidParams { message } (Rpc.md:143-154). Line 54 also needs a From<ActivityError> for RpcError that no appendix defines, and line 42 needs From<ActivityError> for WorkError. Failure: the example does not match the types it is meant to illustrate. Fix: use the appendix variant and state the conversion, or mark the example as pseudocode.
There was a problem hiding this comment.
Fixed in 82c6f8e. The examples use ShutdownRequest { mode } and ActivityError::Conflict/Closed (ServerControl.md:42-54), matching the appendix at lines 175-198; RpcError::invalid is gone.
| | --- | --- | | ||
| | Process parts | Provider (management supplement), Scheduler, Workflow, ExternalAgent, Modality, PluginManager, RuntimeManager, RemoteGateway, Skills (installation), PromptSuggestion (the Settings source), `CodeMode` when installed, light-ocr in the daemon, EventHub, Report; AcpGateway in its client host process; ClientView (the connection's viewed line) | | ||
| | Session parts | Questions, ShellInput, Attachments, SessionTitle, Report, PromptSuggestion, Goal, Web, Recall, ImageUnderstanding, EventHub, Hooks, Scheduler, Workflow, PromptSources, Prompt (the entries table), Code Mode when enabled, SettingsTool (the one `settings` tool, registered by ExecutionSettings in v1) | | ||
| | Process parts | Connection, Transport, ServerControl, Rpc, ManagementMethods, ProcessRoot, CallChannel, UiHost, UiExtensions; Provider (management supplement), Scheduler, Workflow, ExternalAgent, Modality, PluginManager, RuntimeManager, RemoteGateway, Skills (installation), PromptSuggestion (the Settings source), `CodeMode` when installed, light-ocr in the daemon, EventHub, Report; AcpGateway in its client host process; ClientView (the connection's viewed line) | |
There was a problem hiding this comment.
ProcessRoot is listed as a process part, but ProcessRoot.md:82 says it has no plugin row (the assembly is the provider) and ProcessRoot.md:97 says "The root is the assembly, not a part". Failure: the index contradicts the owner contract about whether a part exists. Fix: remove ProcessRoot from the Process parts list or state in both places that it is an owner value without a part.
There was a problem hiding this comment.
Partially fixed in 82c6f8e. The By-scope table no longer lists ProcessRoot among process parts (README.md:63). Still open: the index table still puts ProcessRoot in the Process part column (README.md:21) while ProcessRoot.md:82 says it has no plugin row and the root is the assembly; state it as an owner value without a part or drop the row.
|
已按评审与自查标准修改,head P1
P2
P3
自查(round4 第 1–3 节)
绑定附录编译:在 客户端可见变更: |
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Scope: This PR adds target owner contracts for Connection, Transport, ServerControl, Rpc, ManagementMethods, ProcessRoot, CallChannel, UiHost, UiExtensions, UiResources and Report, and rewrites EnvironmentClients and the related service and contract references. This round reviews the full main...head at 82c6f8e, including the last commit's switch of UI resource reads to FileStorage's stateless read.
Verdict: REQUEST_CHANGES
Round 3 status
Fixed at 82c6f8e:
- P1 #1 and P1 #3 from round 2.
runno longer takes a cancellation token; the admitted call is interrupted only by its provider or the Rpc load unloading (CallChannel.md:87,222), and a disconnect stops delivery only (Rpc.md:56,60,ManagementMethods.md:71,CallChannel.md:23). - Round-2 P2 #3:
MethodReplyisvalue | handedOffandMethodErroris{code, appError, message}(ManagementMethods.md:155-175), matchingsession-boundary.md:225-228. - Round-2 P2 #5:
close_for_idlereturnsCountsand the refusalBusycarries the third count (Connection.md:98,205-219). - Round-2 P2 #6: the UiResources request and appendix are flat
{sessionId, id, offset?, limit?}(UiResources.md:59,128-137). - Round-2 P2 #7: progress is sync and best effort, the entry has the Rpc-unload settlement, and
unsupportedis back (CallChannel.md:11,88-94,101,110-112). - Round-2 P3 #9, #11, #13, #14, #15, #16.
Partially fixed: round-2 P1 #2 for ManagementMethods (the callback is direct, but the conversion and the example still do not compile) and round-2 P2 #8 (the shared call path is narrowed to the management table, but Rpc's own disconnect sentence and the quiesce order still conflict with #2103 and #2098).
Withdrawn: round-2 P2 #4, "FileStorage has no path-addressed offset read". PR #2080 at 7224c0c now defines the stateless read {path, offset?, length?} -> ReadReply {data, eof, size} | none and stat {path} (FileStorage.md:161-162,170), and 82c6f8e follows it. The literal finding is resolved; the new contract conflicts below replace it.
P2
1. UI page reads no longer match the published client contract
Problem: UiResources.md:51,80 and UiExtensions.md:54,82 cap one page at 64 KiB, but client-ui-extensions.md:188,208,436,437 publishes 1 MiB default and 4 MiB maximum for ui.extensions.read and the same bounds for session.ui.resources.read. The current implementation serves those sizes (crates/dim-app-server/src/ui_extensions/resources.rs:79-82,111). UiResources.md:61,78 records the file size at publish, but line 59 takes total from the next read. The stateless read sees a replaced file (FileStorage.md:234 in #2080) and answers none for an absent one (FileStorage.md:170), and line 59 has no error for that absence: resource_unavailable is defined at line 70 but omitted from the read row. The publish flow at line 78 also learns size with read although the dependency at line 51 names stat; a whole read above 8 MiB answers too_large (FileStorage.md:162,170), which publish's error list at line 57 does not contain.
Failure scenario: A publisher renders chart.png and publishes it; a later render replaces the path. Page 1 comes from the old file and page 2 from the new one, and total changes between pages, contradicting client-ui-extensions.md:188 ("resources are immutable, total is fixed"). A removed file gives no defined client code. Separately, a 10 MiB render cannot be published by the flow as written, and a browser that asks for the documented 1 MiB page receives at most 64 KiB.
Evidence: docs/design/plugins/UiResources.md:51,57,59,61,70,78,80; docs/design/plugins/UiExtensions.md:54,65,71-74,82; docs/design/client-ui-extensions.md:188,208,436,437; crates/dim-app-server/src/ui_extensions/resources.rs:79-82,111,244; PR #2080 docs/design/plugins/FileStorage.md:162,170,234.
Fix: Either keep the client page sizes and use #2080's pinned open_read/read_at inside UiResources and UiExtensions (the reader id stays inside the owner), or update client-ui-extensions.md to a 64 KiB page, make total the size recorded at publish, add resource_unavailable to the read row for an absent or unreadable file, and use stat, not read, at publish.
2. The ManagementMethods and CallChannel appendices still do not compile
Problem: ManagementMethods.md:77 requires TableError: From<rutis::host::CallError>, but the TableError appendix at ManagementMethods.md:201-218 has no such impl; rutis 0.19.3 requires it for a callback parameter (rutis-0.19.3/src/service.rs:754-758,827-831). The example at ManagementMethods.md:34-42 also returns Result<MethodReply, MethodError> while register takes Result<CallOutcome, TableError> (ManagementMethods.md:227). In CallChannel.md:54-58 the callback calls error.into_call_error(), which no type in this tree defines, and returns Result<CallOutcome, rutis::Error> where run requires RunError (CallChannel.md:214). RunError has no conversion from TableError, so a service_reloading or service_unavailable outcome cannot cross the binding.
Failure scenario: An implementer cannot compile the management registration or the run example. If the table call fails because the provider is reloading, the example has no defined way to carry that code to Rpc, and a copied example fails at the callback type.
Evidence: docs/design/plugins/ManagementMethods.md:34-42,77,201-218,227; docs/design/plugins/CallChannel.md:54-58,184-193,210-215; rutis 0.19.3 src/service.rs:754-758,827-831.
Fix: Add impl From<rutis::host::CallError> for TableError (a callback-error variant is fine), wrap the example handler's result in CallOutcome::Reply and CallOutcome::Error, add RunError::Table(TableError) or From<TableError>, and replace the into_call_error expression with that conversion.
3. The handler callback cannot observe A.1's cancellation
Problem: A.1 defines the registering part's call as (MethodCall, cancelled, progress) (session-boundary.md:210) and Appendix F defines Handler as Fn(MethodCall, CancellationToken, Progress) (session-boundary.md:571-572). A.1 says the handler's token fires on the provider or Rpc unload, including for drain calls, and the provider's unload waits for every accepted call (session-boundary.md:233). Both new tables instead take Fn(MethodCall) (ManagementMethods.md:227, and #2103's SessionMethods.md:250), while ManagementMethods.md:5,107 says the shapes and interruptions stay with A.1 and supersedes nothing.
Failure scenario: Rpc unloads while a drain handler is running. callChannel.closed is not a substitute: it also resolves on a caller disconnect (CallChannel.md:90, session-boundary.md:344), which A.1 says cancels nothing, so a handler using it would stop accepted work on a TUI disconnect; a handler not using it cannot settle on the Rpc unload. An in-process call has no connection id at all. The table can only drop the future, losing the settlement A.1 promises, or wait for a result with no reason to finish.
Evidence: docs/design/contracts/session-boundary.md:210,233,344,571-572; docs/design/plugins/ManagementMethods.md:5,107,227; docs/design/plugins/CallChannel.md:90,210-215.
Fix: Keep A.1's handler signature in the callback (the token at least; progress may move to callChannel if that is stated), or write an explicit supersession of A.1 and Appendix F and name the signal that replaces the token for both unload events. Update #2103 with the same decision.
4. Rpc and Connection still conflict with #2103 and #2098
Problem: Rpc.md:60 says that for every request call a closing connection stops delivery only, but Rpc also routes Session calls (Rpc.md:49,56) and #2103's latest head still says a closing connection ends a Session call as interrupted (SessionMethods.md:87,112 at 734d364). Separately, Connection.md:147 and Rpc.md:62 say the daemon closes gracefully when Agents answers running after the commit, while #2098's idle-shutdown example answers daemon_busy(running) from quiesce (Agents.md:121-123 at 88e76b6).
Failure scenario: A user closes the TUI during an accepted Session call. Under Rpc the call continues and only the reply is dropped; under #2103 it is interrupted and reported as such. For dimcode daemon stop --if-idle, one contract refuses with daemon_busy and the other stops the daemon, and both target the same client command.
Evidence: docs/design/plugins/Rpc.md:49,56,60,62; docs/design/plugins/Connection.md:106,146-147; PR #2103 docs/design/plugins/SessionMethods.md:87,112; PR #2098 docs/design/plugins/Agents.md:121-123.
Fix: Scope Rpc's disconnect sentence to management calls and cite #2103 for Session calls, or land #2103 with A.1's semantics first. Settle the quiesce order with #2098: either quiesce after the commit and remove its daemon_busy arm, or keep the old refusal and make the pause revertable.
P3 (optional)
Report.md:284:ReportError::Unavailablestill serializes asunavailable, but no operation or Errors row returns it (Report.md:115-133). Remove the variant or document the operation and row that answer it.README.md:21: the index still puts ProcessRoot in the Process part column, whileProcessRoot.md:82says the root has no plugin row andREADME.md:63no longer lists it among process parts. State it as an owner value without a part, or drop the row.Connection.md:116still describestoo_largeonly for a notification;replylists the same error at line 88 and never states what the client receives when a reply exceeds the frame budget (round-1 P3 #15).- The PR description still says Agents leases use
useId; the head documents useleaseId(Connection.md:79,182, PR #2098Agents.md:155-156).
Notes
- ADR check:
node scripts/adr-check.mjs --base 1bc7d67d7e3b357a64fd82c2589f57e4cb4b4becpasses (25 changed files). - Link scan: no new broken links or anchors on the changed lines. The remaining hits are pre-existing lines in
docs/design/cli-commands.mdanddocs/zh/design/cli-commands.md, plus a literal absolute-path example indocs/design/web-workspace.md:160. - CI:
ci-okpassed; the code jobs skip on this docs-only change. - Sibling heads used for the cross-PR checks: #2103 734d364, #2098 88e76b6, #2080 7224c0c. ADR 027 is not present in this repository or any open sibling head, so the reported D2/D3/D4/D5 numbering has no counterpart here.
|
|
||
| ### Dependencies | ||
|
|
||
| FileStorage's stateless `read {path, offset?, length?} → ReadReply {data, eof, size} | none` and `stat {path}`; SessionLifecycle's `closing`. No reader id exists: each page is one read, the owner reports the file's `size` as the page total and `eof` as the end. |
There was a problem hiding this comment.
P2: this changes the published read guarantees. publish records the size (UiResources.md:61,78), but read takes total from the next FileStorage read (UiResources.md:59). #2080's stateless read sees a replaced file (FileStorage.md:234 in #2080) and answers none for an absent one (FileStorage.md:170); the read row at line 59 has no error for that, and resource_unavailable (line 70) is not in its list. The publish flow also gets size with read while this line names stat; a whole read over 8 MiB is too_large (FileStorage.md:162,170), which publish's errors at line 57 omit. Failure: a file replaced after publish returns page 1 from the old bytes and page 2 from the new, or a removed file has no defined client code; a 10 MiB render cannot publish. Fix: use stat at publish, state that total is the recorded publish size and that an absent or replaced file answers resource_unavailable on read, or keep a pinned reader (open_read/read_at) so published bytes cannot change.
There was a problem hiding this comment.
Partially fixed in fa2eea2. publish now uses stat and records the size (UiResources.md:57-61,78), read pins total to the recorded size, maps none and a size change to resource_unavailable, and lists it on the read row (UiResources.md:59,70,80). Still open: the page bound is 64 KiB (UiResources.md:80), while client-ui-extensions.md:188,208,437 publishes 1 MiB default and 4 MiB maximum for session.ui.resources.read and the current code serves those bounds (crates/dim-app-server/src/ui_extensions/resources.rs:80-82,111); limit: 0 is missing from the read errors. See P2 #3 in the review body.
|
|
||
| ### Dependencies | ||
|
|
||
| FileStorage (`add_root`, `list`, `read`; a page of a prepared file is `read {path, offset, length}` with the owner's 64 KiB page size, and the reply's `size`/`eof` give the end); ManagementMethods' `register` for the `ui.extensions` namespace; PartRegistry to mount the UiResources Session part (defined in the [UiResources contract](UiResources.md)). |
There was a problem hiding this comment.
P2: this 64 KiB page contradicts the client contract. client-ui-extensions.md:188,436 publishes ui.extensions.read as 1 MiB default and 4 MiB maximum (session.ui.resources.read has the same bounds at line 437), and the current code serves those sizes (crates/dim-app-server/src/ui_extensions/resources.rs:79-82). The read row lists only resource_unavailable (UiExtensions.md:65); the Errors table defines invalid_params only for register (UiExtensions.md:71-74), while the client contract makes offset > total and limit: 0 invalid_params (client-ui-extensions.md:188,208); FileStorage answers invalid past the end (FileStorage.md:170,180). Failure: a client asking for 1 MiB receives 64 KiB, and an offset past the end has no defined code. Fix: update the client page sizes and add invalid_params to the read row, or loop FileStorage reads up to the client's bound and state the offset mapping.
There was a problem hiding this comment.
Fixed in fa2eea2. read serves one client page of 1 MiB by default and 4 MiB at most by looping FileStorage's 64 KiB offset reads (UiExtensions.md:54,65,83), and invalid_params covers an offset past the end and a zero limit (UiExtensions.md:65,75).
|
|
||
| The handler's own failure is `MethodError` data inside `CallOutcome::Error` (A.1's `{code, appError, message}`), never a table error; the table returns only its routing failures. | ||
|
|
||
| `register`'s `call` is a callback parameter, not a request field, and the registration is bound to `caller`'s row: the table removes it when that row unloads. The callback runs on the registering row and is never called inside a commit lock; it returns `Result<CallOutcome, TableError>` with `TableError: From<rutis::host::CallError>`, the form rutis accepts for a callback parameter. |
There was a problem hiding this comment.
P2: the appendix does not implement the conversion this sentence requires. TableError at ManagementMethods.md:201-218 has no From<rutis::host::CallError>, which rutis 0.19.3 requires for a callback parameter (rutis-0.19.3/src/service.rs:754-758,827-831). The example at ManagementMethods.md:34-42 also returns Result<MethodReply, MethodError> while register expects Result<CallOutcome, TableError> (ManagementMethods.md:227). Failure: the marked service does not compile and a provider cannot register; the example fails on its callback type. Fix: add the From impl, and wrap the example handler's result in CallOutcome::Reply/CallOutcome::Error.
There was a problem hiding this comment.
Partially fixed in fa2eea2. The contract's own example now matches. The callback returns MethodReply with MethodCallbackError: From<rutis::host::CallError> (ManagementMethods.md:38-41,76,143-146), and the Rpc dispatch example matches the positional call (ManagementMethods.md:50-56). Residual: the types now come from #2103, whose MethodReply and MethodError do not match A.1's shapes, and the import at lines 138-140 names crate::methods for types #2103 defines in its SessionMethods appendix. See P2 #2 in the body.
| Box::pin(async move { | ||
| // The token is the Rpc load's, never the connection's: a disconnect stops delivery only. | ||
| table.call(CallRequest { method, params, caller }, rpc_unload).await | ||
| .map_err(|error| rutis::Error::from(error.into_call_error())) |
There was a problem hiding this comment.
P2: this example does not compile against the signature it illustrates. run takes impl Fn() -> BoxFuture<Result<CallOutcome, RunError>> (CallChannel.md:214), but the closure returns Result<CallOutcome, rutis::Error>: TableError has no into_call_error method (none exists in this tree), and rutis::Error does not convert to RunError. Failure: a provider copying the example cannot build the call path, and a routing failure (service_reloading, service_unavailable) has no defined way to reach Rpc. Fix: add RunError::Table(TableError) or From<TableError> and use .map_err(RunError::from) here; drop into_call_error.
There was a problem hiding this comment.
Partially fixed in 1e78ce3, then re-broken in fa2eea2. map_err(RunError::from) replaced into_call_error, but the example still calls table.call(CallRequest { .. }, rpc_unload) (CallChannel.md:56) while ManagementTable::call is now positional (ManagementMethods.md:162-168) and CallRequest is no longer declared. RunError has no From<MethodError>, and the example returns MethodReply where run expects CallOutcome (CallChannel.md:223). See P2 #1 in the body.
| caller: &Ctx, | ||
| request: RegisterRequest, | ||
| declarations: Vec<MethodDecl>, | ||
| call: impl Fn(MethodCall) -> BoxFuture<'static, Result<CallOutcome, TableError>> + Send + Sync, |
There was a problem hiding this comment.
P2: this callback drops A.1's cancellation. A.1 defines the registering part's call as (MethodCall, cancelled, progress) (session-boundary.md:210) and Appendix F's Handler as Fn(MethodCall, CancellationToken, Progress) (session-boundary.md:571-572); the handler's token fires on provider or Rpc unload, including drain calls (session-boundary.md:233). Fn(MethodCall) has no way to observe either event, and ManagementMethods.md:5,107 says the shapes and interruptions stay with A.1. Failure: Rpc unloads with a drain handler running; callChannel.closed resolves on a caller disconnect too (CallChannel.md:90, session-boundary.md:344), which cancels nothing, so a handler using it stops accepted work on a TUI disconnect while one not using it cannot settle on the Rpc unload. An in-process call has no connection id at all. Fix: keep the token in the callback (progress may move if stated), or supersede A.1 and name the signal that replaces it; update #2103 the same way.
|
|
||
| `request` mints nothing: the `call_id` comes from Connection, so the provider, CallChannel and the reply ordering name one call. The method's own error is the data the table returns; Rpc maps it to the protocol envelope and does not add kinds. | ||
|
|
||
| A calling connection closing stops delivery only: the admitted call belongs to the provider generation and settles according to its declaration, as the [methods contract A.1 and A.2](../contracts/session-boundary.md) require. The token `request` receives is the admitting Rpc load's, never the connection's. Rpc's `request` returns the reply frame; writing it is Connection's. |
There was a problem hiding this comment.
P2: this sentence covers Session calls too, and #2103 disagrees. Rpc routes both tables (Rpc.md:49,56), but #2103's latest head says a closing connection ends a Session call as interrupted (SessionMethods.md:87,112 at 734d364). Failure: a TUI closes during an accepted Session call; an implementer following Rpc continues it while one following #2103 interrupts it, and the reply or settlement differs. Fix: scope this paragraph to management calls and cite #2103 for Session calls, or land #2103 with A.1's semantics first.
| ## Client-visible changes | ||
|
|
||
| - `daemon.shutdown {ifIdle:true}` keeps the wire error `daemon_busy` with `connections`, `attachedSessions` and `running`; the field `running` counts Sessions with accepted work or an activity hold, as before. | ||
| - One narrow behaviour changes: when a Session accepts work between the caller's read and Agents' `quiesce`, the daemon closes gracefully instead of answering `daemon_busy`, because Agents' pause is one-way and cannot be reverted; the alternative order (quiesce before the commit) would leave a paused daemon running when the commit is refused. Accepted work still settles; the affected client is the CLI's `daemon stop --if-idle` and any start that stops an idle daemon. Maintaining the old refusal would need a revertable pause from Agents; this contract asks the maintainer to confirm the change. |
There was a problem hiding this comment.
P2: this behavior change remains a cross-PR conflict. Here the daemon closes gracefully when Agents answers running after the commit; #2098's idle-shutdown example answers daemon_busy(running) from quiesce (Agents.md:121-123 at 88e76b6). Failure: dimcode daemon stop --if-idle refuses under one contract and stops under the other, depending on which lands. Fix: settle the order with #2098 (quiesce after the commit and remove its daemon_busy arm, or make the pause revertable); do not publish two answers.
| #[error("{message}")] | ||
| InvalidParams { message: String }, | ||
| #[error("The report cannot be prepared now")] | ||
| Unavailable, |
There was a problem hiding this comment.
P3 optional: Unavailable serializes as unavailable, but no operation or Errors row returns it (Report.md:115-133). Failure: an implementer cannot tell whether unavailable is a public code. Fix: remove the variant or document the operation and row that answer it.
There was a problem hiding this comment.
Fixed in fa2eea2. ReportError::Unavailable is removed (Report.md:276-295), and every remaining variant appears in an operation or Errors row (Report.md:115-133).
| | [ServerControl](ServerControl.md) | publication gate, shutdown intent and accepted-work holds; `processActivity` | — | — | #2021 | | ||
| | [Rpc](Rpc.md) | handshake, built-in methods and dispatch of one call; `rpc` | — | — | #2021 | | ||
| | [ManagementMethods](ManagementMethods.md) | the process namespace table; `managementMethods` | — | — | #2021 | | ||
| | [ProcessRoot](ProcessRoot.md) | process values: reserved names and credential variable names | — | — | #2021 | |
There was a problem hiding this comment.
P3 optional: this row still puts ProcessRoot in the Process part column, while ProcessRoot.md:82 says the root has no plugin row (the assembly is the provider) and README.md:63 no longer lists it among process parts. Failure: readers see ProcessRoot as a part and as not a part. Fix: state in the row that it is an owner value without a part, or remove the row.
There was a problem hiding this comment.
Fixed in fa2eea2. The index row now says the assembly supplies the values and there is no plugin row (README.md:21), and the By-scope Process parts list omits ProcessRoot (README.md:63).
|
已按评审修改,head 本 PR 的评审项:
自查 1–9:
绑定附录编译: 留给第二步(跨 PR):Rpc 的 Session 调用语义与 #2103 |
|
已按评审修改,head 跨 PR 对齐:
验证: |
|
补充说明(ADR 027 收回到决定层后):本 PR 的契约没有 |
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Scope: This PR defines target contracts for the connection, entry and UI owners (Connection, Transport, ServerControl, Rpc, ManagementMethods, CallChannel, UiHost, UiExtensions, UiResources, ProcessRoot, Report) and updates the references in the methods contract, the service faces, the process owner operations and the client UI contract. This round reviews the full main...head at fa2eea2, including the last two commits that rewrote ManagementMethods around #2103's types and bounded the UI pages.
Verdict: REQUEST_CHANGES
Round 3 status
Fixed at fa2eea2:
- Round-3 P2 #1, the immutability half.
publishusesstatand records the size (UiResources.md:57-61,78);readpinstotalto the recorded size, mapsnoneand a size change toresource_unavailable, and lists the error (UiResources.md:59,70,80). #2080 at 5351ea7 now names this rule as #2095's acceptance ("owns the replace-between-pages acceptance",FileStorage.md:225), so the published-path rule itself is consistent. - Round-3 P2 #3. The handler is
(MethodCall, CancellationToken, Progress)(ManagementMethods.md:38-41,76,143-146), and #2103's Session table uses the same signature (SessionMethods.md:237at 59a77a3). The A.1 cancellation hole is closed. - Round-3 P3:
ReportError::Unavailableis removed (Report.md:276-295); the README row says the assembly supplies ProcessRoot and it has no plugin row (README.md:21,63); thetoo_largereply outcome is defined (Connection.md:102,116).
Partially fixed:
- Round-3 P2 #1, the page-bound half. UiExtensions now serves 1 MiB by default and 4 MiB at most by looping FileStorage's 64 KiB reads (
UiExtensions.md:54,65,83). UiResources still caps a page at 64 KiB (P2 #3 below). - Round-3 P2 #2 and round-2 P1 #2. ManagementMethods' own example and appendix now match (
ManagementMethods.md:34-43,143-168), but the last commit removed the types that CallChannel and Rpc still use (P2 #1 below). - Round-3 P2 #4 and round-2 P2 #8 remain open in both parts: the Rpc disconnect sentence still conflicts with #2103 (P2 #4), and the quiesce order still conflicts with #2098 (P2 #5).
Withdrawn: round-3 P3 #1, #2 and #3; round-3 P2 #3; the immutability half of round-3 P2 #1. Round-2 P2 #4 stays withdrawn: #2080 has the stateless read, and this PR follows it.
Earlier rounds: round-1 P1 #1 is fixed in form (the process table is a native trait with a direct callback, and the dispatch is hand-written), but the CallChannel appendix is again uncompilable for the type reasons in P2 #1. Round-1 P1 #3 is fixed for this contract, with the #2103 conflict in P2 #4. Round-1 P2 #10 and #11 remain fixed, and round-1 P3 #15 is fixed. Round-2 P1 #2 is partial as above, and round-2 P2 #8 remains open as P2 #4 and #5.
P2
1. The last commit removed the call-path types that CallChannel, Rpc and ProcessRoot still use
Problem: fa2eea2c replaced ManagementMethods' appendix with #2103's types and deleted CallOutcome, TableError, CallRequest and RegisterRequest (ManagementMethods.md:134-146). CallChannel still returns CallOutcome (CallChannel.md:87,223-224), declares RunError::Table { error: TableError } and From<TableError> (CallChannel.md:189-196), and says those types are defined in the ManagementMethods appendix (CallChannel.md:150). Its example still calls table.call(CallRequest { .. }, rpc_unload) (CallChannel.md:56) while ManagementTable::call is now positional (ManagementMethods.md:162-168), and it maps the result with RunError::from even though no From<MethodError> exists. Rpc builds its reply from the table's CallOutcome (Rpc.md:56), and ProcessRoot's example registers with RegisterRequest { namespace, declarations, call } (ProcessRoot.md:37).
Failure scenario: An implementer cannot compile the callChannel binding, the Rpc dispatch or the ProcessRoot registration example. CallOutcome, TableError, CallRequest and the management RegisterRequest have no definition for the call path in this PR or in #2103, and the table's new MethodError has no conversion to RunError, so a reloading or unavailable refusal cannot cross the binding. The last commit's claim that the three tables converged to one shape is not true at this head.
Evidence: docs/design/plugins/CallChannel.md:56,87,150,189-196,223-224; docs/design/plugins/Rpc.md:56; docs/design/plugins/ManagementMethods.md:134-168; docs/design/plugins/ProcessRoot.md:37; PR #2103 docs/design/plugins/SessionMethods.md:170-249 at 59a77a3.
Fix: Either keep one shared set of call types in ManagementMethods as at 1e78ce3 and have #2103 use it, or switch CallChannel and Rpc to MethodReply and MethodError, add From<MethodError> for RunError, and update the CallChannel, Rpc and ProcessRoot examples to the positional register and call. Re-run the binding check after the switch.
2. The shared method-table shape does not match A.1 or #2103
Problem: ManagementMethods.md:74,134 says the operations and MethodCall, MethodReply and MethodError are #2103's, and that a handler's failure is MethodReply's error data. #2103 at 59a77a3 defines MethodReply as {kind: value} | {kind: error} and MethodError as its routing enum (SessionMethods.md:202-228). This PR's A.1, which the same document names as the source of the declarations and shapes (ManagementMethods.md:5,107), still defines MethodReply as {kind: value} | {kind: handedOff} and MethodError as {code, appError, message}, and says every error is MethodError data (session-boundary.md:201,225-228). The import at ManagementMethods.md:138-140 also takes MethodReply, MethodError, MethodCallbackError and MethodDecl from crate::methods, while #2103 defines the first three in its SessionMethods appendix and calls MethodDecl a capabilities type (SessionMethods.md:170-228).
Failure scenario: A handler that returns its own error uses MethodReply::Error, but A.1's MethodReply has no error arm, so a client written to A.1 cannot decode it. A handedOff reply, which A.1 defines for the final-reply handoff, has no arm in #2103's MethodReply. The process table and the Session table are documented with different reply shapes under the same names, and the example import does not match where #2103 defines the types. This PR relies on A.1, which #2103 rewrites, so the two must merge in a fixed order or this PR must carry the A.1 update.
Evidence: docs/design/plugins/ManagementMethods.md:5,74,107,134-140; docs/design/contracts/session-boundary.md:201,209-210,225-228; PR #2103 docs/design/plugins/SessionMethods.md:92,170-228, its session-boundary.md A.1 at 59a77a3.
Fix: Land #2103's shapes in A.1 in this PR, including the handedOff decision, or land #2103 first and cite its appendix as the only definition of these types. Keep the import list on the module #2103 actually names.
3. UiResources still serves 64 KiB pages against the published 1 MiB default and 4 MiB maximum
Problem: UiResources.md:59,80 serves one page of 64 KiB at most and clamps the client's limit to it. client-ui-extensions.md:188,208,437 publishes 1 MiB default and 4 MiB maximum for ui.extensions.read and the same bounds for session.ui.resources.read, and the current code serves those bounds through the same read_page (crates/dim-app-server/src/ui_extensions/resources.rs:80-82,111). This PR fixed the same conflict for UiExtensions (UiExtensions.md:54,65,83) but not for UiResources.
Failure scenario: A desktop or TUI client asks session.ui.resources.read for the published 1 MiB page and receives 64 KiB, so a 2 MiB image takes 32 round trips instead of 2. A client that trusts the published 4 MiB maximum and sizes its buffer or timeout from it sees a different wire page size. limit: 0 is invalid_params in the client contract (client-ui-extensions.md:188,208) but is not stated in the UiResources Errors table, whose invalid_params row covers only an offset beyond the file (UiResources.md:69). Separately, when a file shrinks after publish and the next requested offset is above the new size, FileStorage answers invalid before the owner can compare size, so the read would be invalid_params instead of the resource_unavailable this contract promises for a size change.
Evidence: docs/design/plugins/UiResources.md:59,69-70,80; docs/design/client-ui-extensions.md:188,208,437; crates/dim-app-server/src/ui_extensions/resources.rs:80-82,111; PR #2080 docs/design/plugins/FileStorage.md:167,177 at 5351ea7.
Fix: Loop FileStorage's 64 KiB reads up to the client's bound as UiExtensions does, or change the client page sizes and the current code in the same owner change. Add limit: 0 to the read errors and map a FileStorage invalid for a live reference to resource_unavailable when the requested offset is inside the recorded publish size.
4. Rpc still says every disconnect stops delivery only, while #2103 interrupts Session calls
Problem: Rpc.md:60 says a calling connection closing stops delivery only and the admitted call settles by its declaration. Rpc routes both the management and Session tables (Rpc.md:49,56), but #2103 at 59a77a3 still says a closing connection ends a Session call as interrupted (SessionMethods.md:87,112).
Failure scenario: A user closes the TUI during an accepted Session call. Under Rpc the call continues and only the reply is dropped; under #2103 it is interrupted and reported as interrupted. The caller sees different settlements depending on which contract the implementer followed, and the same call path cannot satisfy both.
Evidence: docs/design/plugins/Rpc.md:49,56,60; PR #2103 docs/design/plugins/SessionMethods.md:87,112 at 59a77a3.
Fix: Scope the Rpc sentence to management calls and cite #2103 for Session calls, or land #2103 with A.1's no-cancel-on-disconnect semantics first.
5. The quiesce order still conflicts with #2098
Problem: Connection.md:106,147 and Rpc.md:62 say the idle close commits the refusal first, then runs Agents' quiesce; when quiesce answers running, the daemon closes gracefully and admission is never reopened. #2098 at c3acab3 still maps quiesce's Busy { running } to daemon_busy(running) at the same Rpc idle-shutdown call site (Agents.md:121-123), and its quiesce row says a Session that accepts work between the check and the pause answers running (Agents.md:164,175). The claim at Connection.md:106 that #2098's answer belongs to another call site does not hold.
Failure scenario: A Session accepts work between the caller's sessions read and the quiesce pause. Under #2098, dimcode daemon stop --if-idle receives daemon_busy and the daemon stays up. Under this PR, the refusal is already committed, so the daemon closes gracefully. Both contracts target the same client command and the same Rpc sequence.
Evidence: docs/design/plugins/Connection.md:106,146-147; docs/design/plugins/Rpc.md:62; PR #2098 docs/design/plugins/Agents.md:121-123,164,175 at c3acab3.
Fix: Settle the order with #2098. Either quiesce after the commit and remove its daemon_busy arm, or keep the old refusal and make the pause revertible. Update Connection, Rpc and #2098 in the same owner change; do not publish two answers.
P3 (optional)
- The "design rules §7, PR #2029 ... not yet on main" note at
ManagementMethods.md:111,Connection.md:156,Rpc.md:93and the other new contracts is stale. #2029 merged as 4d081fe and §7 is atdocs/architecture/rust-agent/principles.md#7-所有者与操作on origin/main; link that section instead. - The PR description still says lease ids are
useId, thatcallChanneldeclarations arrive atbind, and thatclose_for_idletakesheld_work. The head usesleaseId(Connection.md:79,182, #2098Agents.md:155-156), has nobind(CallChannel.md:27), and takes only{exclude_connection_id, running}(Connection.md:98,211). ManagementMethods.md:120andRpc.md:102cite "§8 rule". The settle-before-removal rule is AGENTS rule 8, and the design rules have no section 8.ManagementMethods.md:74,134linkshttps://github.com/arcships/dim/pull/2103#own-contract. A PR conversation page has noown-contractheading, so the fragment does not reach the contract; link the file at a pinned commit in #2103, or drop the fragment.UiExtensions.md:73,75has twoinvalid_paramsrows in one Errors table.client-ui-extensions.md:197still says UiResources opens the file and holds the read resource, whileUiResources.md:61says publish opens no reader. The client section also says a stale id after Session unload or daemon restart answersresource_gone(client-ui-extensions.md:208), whileUiResources.md:72answerssession_closedwhen the Session is gone.Report.md:231-236usesPlaninPrepareReply, but the appendix defines noPlan.ProcessRoot.md:37still passesRegisterRequest { namespace, declarations, call }; the head signature isregister(caller, namespace, declarations, call)(ManagementMethods.md:153-160).
Notes
- ADR check:
node scripts/adr-check.mjs --base origin/mainpasses, 25 changed files. - Link scan: no new broken links or anchors on the changed lines. The remaining hits are pre-existing lines in
docs/design/cli-commands.mdanddocs/zh/design/cli-commands.md, plus the literal/absexample inweb-workspace.md. - CI:
ci-okpasses; the code jobs skip on this docs-only change. - Sibling heads used: #2103 59a77a3, #2080 5351ea7, #2098 c3acab3. origin/main is bf3a4e6; #2029 is merged as 4d081fe, and ADR 027 is on main as 9e629e9. No new document references ADR 027.
|
|
||
| ## Binding appendix | ||
|
|
||
| `CallOutcome`, `MethodReply` and `MethodError` are the [methods contract](../contracts/session-boundary.md) A.1 shapes, defined in the [ManagementMethods](ManagementMethods.md) appendix. |
There was a problem hiding this comment.
P2: after fa2eea2 these types have no definition. ManagementMethods now defers to #2103 and no longer defines CallOutcome, TableError, CallRequest or RegisterRequest (ManagementMethods.md:134-146), yet this appendix returns CallOutcome (lines 87,223-224), carries RunError::Table { error: TableError } and From<TableError> (189-196), and its example calls the removed CallRequest (56) against the new positional ManagementMethods.call (ManagementMethods.md:162-168). CallOutcome and TableError are not in #2103 either (SessionMethods.md:170-249 at 59a77a3). Failure: the callChannel binding and the Rpc dispatch (Rpc.md:56) cannot compile, and a table refusal has no conversion to RunError. Fix: keep one shared call type set in ManagementMethods and have #2103 use it, or switch these docs to MethodReply and MethodError and add From<MethodError> for RunError; update the stale examples (CallChannel.md:56, ProcessRoot.md:37) to the positional signatures.
|
|
||
| `caller` is `{connectionId, callId}`: the connection the call arrived on and the call id the reply ordering uses. It is absent for an in-process call. The table passes it to the handler unchanged; a handler that notifies uses it with `callChannel`. | ||
|
|
||
| The handler's own failure is `MethodReply`'s error data (A.1's `{code, appError, message}`), never a table error; the table returns only its routing failures. The operations, `MethodCall`, `MethodReply` and `MethodError` are the [SessionMethods](https://github.com/arcships/dim/pull/2103#own-contract) contract's (#2103), the same shape both tables serve. |
There was a problem hiding this comment.
P2: the shapes this line and line 134 defer to do not match A.1. #2103 at 59a77a3 defines MethodReply as {kind: value} | {kind: error} and MethodError as its routing enum (SessionMethods.md:202-228), while this PR's session-boundary.md:225-228 still defines MethodReply as {kind: value} | {kind: handedOff} and MethodError as {code, appError, message}, with every error as MethodError data (line 201). Failure: a handler's own error uses MethodReply::Error, which A.1 cannot represent; a client written to A.1 cannot decode it; a handedOff reply has no arm in #2103. The import at 138-140 also takes MethodReply, MethodError, MethodCallbackError and MethodDecl from crate::methods, while #2103 defines the first three in its SessionMethods appendix and calls MethodDecl a capabilities type (SessionMethods.md:170-228). Fix: update A.1 to the shared shapes in this PR or land #2103 first and cite it as the only definition; align the import paths.
| | --- | --- | --- | --- | --- | --- | | ||
| | `publish` | Check the Session phase, `stat` the path in FileStorage (kind and `size`), register the reference (path and size) and the row's cleanup | Nothing is registered | The reference is removed by the row's cleanup | Every reference is removed | UiResources: the reference | | ||
| | `withdraw` | Check the owner row, cancel and wait for admitted reads, remove the reference | — | Already removed | Already removed | UiResources | | ||
| | `read` | Resolve the reference, call FileStorage's `read {path, offset, length}` for one page (64 KiB at most, the client's `limit` clamped to it); `total` is the recorded publish size and `eof` is the page end; a `none` reply, or a reply whose `size` differs from the recorded size, is `resource_unavailable` | The page stops; nothing changes | The read ends with the row | Admitted reads are counted and awaited before the reference goes | UiResources: the reference and the read count; FileStorage: the page | |
There was a problem hiding this comment.
P2: this 64 KiB page contradicts the client contract. client-ui-extensions.md:188,208,437 publishes 1 MiB default and 4 MiB maximum for session.ui.resources.read, and the current code serves those bounds (crates/dim-app-server/src/ui_extensions/resources.rs:80-82,111). This PR fixed the same conflict in UiExtensions.md:54,65,83 but not here. Failure: a client asking for the published 1 MiB page receives 64 KiB, and a 4 MiB request is clamped to 64 KiB; limit: 0, which the client contract makes invalid_params, is not in the Errors table. When a file shrinks after publish, a request above the new size gets FileStorage invalid before size can be compared, so the promised resource_unavailable becomes invalid_params. Fix: loop FileStorage's 64 KiB reads to the client bound as UiExtensions does, or update the client page sizes and the code in the same owner change; state limit: 0 and map invalid for a live reference to resource_unavailable when the offset is inside the recorded total.
|
|
||
| `request` mints nothing: the `call_id` comes from Connection, so the provider, CallChannel and the reply ordering name one call. The method's own error is the data the table returns; Rpc maps it to the protocol envelope and does not add kinds. | ||
|
|
||
| A calling connection closing stops delivery only: the admitted call belongs to the provider generation and settles according to its declaration, as the [methods contract A.1 and A.2](../contracts/session-boundary.md) require. The token `request` receives is the admitting Rpc load's, never the connection's. Rpc's `request` returns the reply frame; writing it is Connection's. |
There was a problem hiding this comment.
P2: this sentence covers Session calls too, and #2103 disagrees. Rpc routes both tables (lines 49,56), but #2103 at 59a77a3 says a closing connection ends a Session call as interrupted (SessionMethods.md:87,112). Failure: a TUI closes during an accepted Session call; an implementer following Rpc continues it and drops only the reply, while one following #2103 interrupts it and reports the interruption. Fix: scope this paragraph to management calls and cite #2103 for Session calls, or land #2103 with A.1's no-cancel-on-disconnect semantics first.
|
|
||
| `close_for_idle` takes `running` from Agents' `sessions` value, read immediately before. The owner rechecks only its own counts under the admission lock and commits the refusal in the same step, so no hello or attach joins after the decision. | ||
|
|
||
| The caller's sequence is Rpc's: read Agents' `sessions`, then `close_for_idle`; on `Busy` answer `daemon_busy` with the counts; the assembly then asks Agents to `quiesce`. Quiesce runs after the commit because Agents' pause is one-way; [#2098](https://github.com/arcships/dim/pull/2098)'s `Busy { running }` answer belongs to its own call site, and at this one a `running` answer is settled by the graceful close — admission is never reopened after the commit. |
There was a problem hiding this comment.
P2: the #2098 conflict is still open. #2098 at c3acab3 maps quiesce's Busy { running } to daemon_busy(running) at this same Rpc idle-shutdown call site (Agents.md:121-123), and its quiesce row says a Session that accepts work between the check and the pause answers running (Agents.md:164,175). The claim here that #2098's answer belongs to another call site is not supported. Failure: a Session accepts work between the read and quiesce; #2098 refuses with daemon_busy and keeps the daemon up, while this contract has already committed the refusal and closes gracefully. Both target dimcode daemon stop --if-idle. Fix: settle the order with #2098 (quiesce after the commit and remove its daemon_busy arm, or make the pause revertible) and update both contracts; do not publish two answers.
|
Closing as part of abandoning the owner-split experiment. |
Target contracts for the owners in #2021: Connection, Transport, ServerControl, Rpc, ManagementMethods, ProcessRoot, CallChannel, UiHost, UiExtensions, UiResources and Report. The scan report is the input; this PR is the design.
Design decisions that change a name or a shape:
connection:presences,write,write_after,write_deferred,closed,attach,detach,attached,counts,close_for_idle,close_all.sessionClientsHostis retired as a name; the 21st EnvironmentClients branch readsconnection.presences. The accepted stream is the one object handover, with its lifecycle fixed in the Connection contract.serverControldisappears intoprocessActivity: the publication gate, the shutdown intent, listener faults and accepted-work holds are one owner with one lifecycle. Session pauses stay with Agents.connection.close_for_idletakesrunning_sessionsfrom Agents'sessionsvalue andheld_workfromprocessActivity.holds, commits the refusal under its admission lock, and Agents'quiescepauses the Sessions after the commit; arunningquiesce answer does not reopen the refusal. Attachment leases use Agents'acquire {sessionId} → {useId, generation}andrelease {useId}.hold/releasestay two calls: the accepted work (a Workflow run, a Scheduler delivery) outlives the call, so awithHold(work)callback cannot represent it; the id is the caller's business object's state, released byreleaseor the row's unload.UiHost'sexpected_generationstays a request field: it is the version the client observed and confirmed, so the owner cannot choose it.helloandrequestas data; Connection looks the generation up per frame and no longer stores it.managementMethodsgainscall, and theMethodTableobject no longer crosses byDeref.callChannelkeeps its name and owns call bindings; the write is Connection'swrite_after, the declarations arrive atbind.uiHost,uiExtensionsanduiResourcesstay as data faces with id operations; UiHost no longer takes&Connectionor&ConnectionHub; UiExtensions emits a revision event instead of handing out awatch::Receiver.listenAddresses.readis Transport's only operation;localId.getis retired.Client-visible contract restored under rule D:
daemon_busykeepsconnections/attachedSessions/running; the existingservice_reloading/service_unavailable/operation_interrupted,report_*,resource_*,invalid_pathandui_*codes are unchanged; a disconnect stops delivery only and does not cancel the accepted call; notifications and progress stay available after a call returns; the Report plan again carriesmaterial,maxOutputTokensandestimatedCost. One narrow change is listed in Connection's "Client-visible changes": when a Session accepts work between the read and Agents' one-wayquiesce,daemon stop --if-idlecloses gracefully instead of answeringdaemon_busy.The delivery part (deletion list, caller migration, implementation tasks, acceptance) is in the issue comment linked here: #2021 (comment).
Refs #2021
Refs #2015
Merge order
#2029 → #2080 → #2091/#2092/#2093 → #2094 → #2096 → the rest.
Sibling heads this change is aligned with: #2098
c3acab356, #20993501002ac, #2100437266bff, #210359a77a3d1. A paragraph that depends on a sibling names that PR; its head is the one above.