Repository navigation
feat(runtime): route calls by id to a live Session or line - #2174
Conversation
|
计划在本 PR 开出后改了两处,都属于 base-1,请在本 PR 里补上。详见 #2015 计划更新。
|
|
补充一处:插件作者怎么写按 id 的调用。这一处属于 base-1,请在本 PR 里补上。 作者不直接写 改为在
要求:
|
zerob13
left a comment
There was a problem hiding this comment.
What this does
Adds a process-level route face: sessionId or (sessionId, lineId) plus a service/method is resolved to the live owner and forwarded, with NoSession / SessionClosing / NoLine. Also adds the xtask-check access-layer scan with a 115-entry baseline.
Blocking
-
Owner errors are not passed through unchanged.
crates/dim-agent-runtime/src/route.rs:245maps everyHostDispatch::invoke/settlefailure toAgentError::Fault. A language caller ofroute.line(...)therefore receivesFault, not the owner'sBranchEnded,BranchRefusedorInvalidInput; only the Rustline_ownerpath preserves the error type. The module docs, the PR body anddocs/design/contracts/runtime-owner-operations.mdall say "unchanged". Either preserve the owner's error kind on the by-name path or narrow the contract to "the message is preserved", and add a test where an owner method fails throughroute.line. -
The allowlist does not enforce its "only shrink" rule.
xtask/check/src/access.rs:94compares the found set withallowin both directions, but never against a base revision, so adding a new violation together with its matching entry still passes.removedinxtask/src/catalog.rs:59has the same property. Either compare theallowset with the merge base in CI, or remove the guarantee from the code comment and PR body and treat it as a review convention.
Should fix
- The by-name path has no scope gate.
route.rs:183/route.rs:196only refuse five literal registry names and the two lifecycle services. The typed path also checks the catalog group (session_face/public), but the by-name path reaches anything that has a dispatch at the instance key. ConcretelytimelineStore(assembly.rs:1244) andsessionLoader(session_typescript.rs:53) become reachable cross-Session: a language part can append to another Session's store or create/remove its instances by id. Decide whether those are routable; if not, refuse them, and derive the names withnames::name_ofso a rename cannot silently widen the gate. - The line index is registered before publication and never pruned.
assembly.rs:1564registers atTimelineContext::start, before TimelineTree publishes the line;lines(assembly.rs:1183-1191) never removes ended lines. §10 says a line still opening is not a line yet. Resolve through the tree's published lookup, or gate on publication and prune on close. - A close racing a call can answer outside the table.
resolve_sessionchecksclosingonce, thenloaded()(assembly.rs:1164) can returnClosedif the subtree was released in between; a line target can answerNoLineinstead ofSessionClosingin the same race. Map those to the three answers or re-check after loading.
Nits
SessionForwardingmatches only a parameter literally namedbranch(access.rs:217). It missesline_id/branch_idforwarders and flags tree operations such asSession::end_branch. The baseline reproduces today, but the check does not test the stated rule.- The refusal test covers
sessionMethodsandtoolRegistry, notpromptRegistry,guideEntriesorsubmitChecks; there is also no owner-error test through the by-name path. - "Only adds; deletes nothing" is not exact:
testing.rsalways installs process rows now (has_pluginsremoved) and thetimelineTree.callparagraph is replaced. The -1720 is generated-id churn.
Checked: full 31-file diff against main, ADR 027 D1-D4, principles §7, runtime-owner-operations.md, routing_flow.rs, access.rs and the 115-entry baseline (50 service-skip / 41 host-dispatch / 23 session-forwarding / 1 branch-type). CI green per the PR; workspace tests were not rerun locally.
|
按 id 调用的写法(定稿):本条取代上一条评论,并回答「 结论:不再单独做 作者写法(Rust 和 TS 一样)
Rust 在最后一步写明类型,例如 规则
底层:两个数据面操作,两种语言共用
链式写法由 Dim 在这两个操作上生成:
作者文档和示例只写链式写法。 对本 PR 的改动
|
A plugin calls a Session's or a line's data face with the operation the index owner serves: `sessionScope.lineCall` for its own Session's line, `sessions.call` for a Session or a line of it. No chain and no wrapper: rutis serves a Rust service's reply as data, so an object a caller continued to call was never available (maintainer correction on #2174). `xtask -- types` narrows both requests to what a route resolves: `service` is a data face of the target scope, `method` one of its methods, and `args` that method's parameters, so a typo fails `tsc`. The injected `sessions` type carries `call`, and the authoring guide shows the two operations. Refs #2015 Refs #2127
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
The shape
I agree with what base-1 does: each owner keeps its own index and does the lookup, the two operations pass the owner's own arguments, reply and error through, and no address object or chain is handed to an author. Everything below is about the line index behind sessionScope, because the branch tree work and the Goal work after this will be built on it.
I read head f5d21296c353 against ADR 027 D1 to D4, §7 and the timeline rules.
1. A line is routable before it publishes (blocking)
I agree with the point in the earlier review at 672fb9bfe (review) that the line index must be gated on publication; what a call reaches in that window is what it did not spell out.
The index is written where the line is built, not where the tree publishes it: SessionAssembly::lines (assembly.rs) is filled by register_line (assembly.rs) from the timeline factory right after TimelineContext::start (assembly.rs), and the tree calls that factory from launch (timeline_tree.rs).
Publication happens later in the same task: the opening branch/start and its input are appended and finish_opening waits for that batch (timeline_tree.rs), and only then does the line activate() and get its ready value (timeline_tree.rs). Until that point the tree hides the line: get and published answer nothing for it (timeline_tree.rs) and the directory skips it (timeline_tree.rs), which follows the rule that a line still opening is not a line yet (timeline-branches.md).
A routed call does not check that. The module docs list closing, closed and another Session's line as NoLine (route.rs) and have no case for a line that has not published. SessionScope::line_context asks SessionAssembly::line, which upgrades the weak reference and tests only is_closing (assembly.rs). So between the registration at assembly.rs#L1566 and the publication at timeline_tree.rs#L1355, a sessionScope.lineCall or sessions.call reaches a line whose parts are mounted but not activated, since activation is what starts their work (timeline_context.rs), whose opening input is not published, and which is rolled back if finish_opening fails or the create is cancelled. A call that fails there also loses its kind: the route answers the owner's failure as the single owner code with only a name and message (route.rs, route.rs), so a caller cannot tell a transient failure caused by the window from a permanent one. The id is not a secret in that window: the parent's committed branch/create carries it (timeline_tree.rs), so a caller that reads the parent's history can name the line before it exists as a line.
What I would ask for: record the line where the tree publishes it, next to ready.send_replace or by asking the tree's published lookup, and answer NoLine for a line that has not published. A test that routes while a create is held open would pin it; routing_flow covers a closing Session and a closed line, not an opening one.
2. An ended line and an unknown id answer one code (blocking)
RouteError::NoLine covers a line that is closing, closed, or was never one of this Session's (route.rs), and SessionAssembly::line cannot tell them apart: an ended line's context is gone, so the upgrade fails and the entry is dropped (assembly.rs). The tree does tell them apart under one lock: published answers BranchEnded for a line it ended and UnknownBranch for an id it never had (timeline_tree.rs), and that difference is what lets a caller fall back to the ended read instead of giving up.
That difference matters more after the branch tree PR: the point of moving ended reads into the tree is that a caller asks for a line without first knowing whether it is open, and a routed read of a finished line should answer its fixed head rather than a permanent error. With one no_line code a caller cannot tell "this line finished, read it through the tree" from "this id is wrong, stop retrying". If a routed call has to stay final for an ended line, I would still keep the kind, as BranchEnded and UnknownBranch or as two codes, so each caller does not have to reclassify it itself.
3. An ended line keeps its index entry (should fix)
I agree with the other half of the earlier review at 672fb9bfe (review), that the index must be pruned when a line closes; the size below is what it did not spell out.
lines has one writer (assembly.rs) and one reader (assembly.rs), and an entry is removed only when a later call happens to name the same dead id (assembly.rs). Ending a line removes its node and records it as ended (timeline_tree.rs), but nothing tells the Session to drop the routing entry, and a failed build leaves one too because that path only removes the node (timeline_tree.rs). A Session that opens tool lines or Goal evaluation lines therefore keeps one entry per line it ever created, for the rest of its life.
I would remove the entry where the line stops being routable: when the tree ends the line, and when a build fails.
4. Minor: names fixed at compile time are rebuilt per call
face builds name_of::<SessionLifecycle>() and name_of::<BranchLifecycle>() on every call (route.rs), and name_of allocates a character vector and a string each time (names.rs). call_face builds the dispatch key from the name again (route.rs), which is one owned string inside the key, and LineHandle::get adds the same for T (route.rs). That is three name builds per routed call for values that are known when the crate compiles. The two lifecycle names can sit as constants beside REGISTRATION_POINTS, and the typed entry can pass a static name to the same gate; no interface changes.
|
Rust 的按类型取辅助:去掉。
理由:
已更新 #2127 的已定决定。 |
|
回答" ADR 027 改为由持有实例的一方按 id 选目标,见 #2200。
本 PR 还要改的:
完整决定见 #2127 的已定决定。 |
|
补充: |
|
按 #2200 里 zerob13 的评审,本 PR 还要改两处(已写进 #2127 正文和已定决定):
Collaboration 的请求和客户端 attach 现有的保持都不变。 |
|
再补一处(yyhhyyyyyy 在 #2200 指出): 改法(已写进 #2127 的已定决定):
scheduler 测试里断言 |
|
本 PR 先暂停,等 ADR 027 的修改 #2200 合并后再继续。 合并后,按 #2127 的已定决定一次改完以下五处(详见前面几条评论):
|
f5d2129 to
4b22d77
Compare
A plugin calls a Session's or a line's data face with the operation the index owner serves: `sessionScope.lineCall` for its own Session's line, `sessions.call` for a Session or a line of it. No chain and no wrapper: rutis serves a Rust service's reply as data, so an object a caller continued to call was never available (maintainer correction on #2174). `xtask -- types` narrows both requests to what a route resolves: `service` is a data face of the target scope, `method` one of its methods, and `args` that method's parameters, so a typo fails `tsc`. The injected `sessions` type carries `call`, and the authoring guide shows the two operations. Refs #2015 Refs #2127
A minimal host serves with the offline model catalog and no product home, so `sessions.launch` works and the Session is admitted by Agents: `crates/dim-app-server/tests/routed_call_flow.rs` launches one, answers a face call, releases it with `Session::unload_if_idle` (it leaves the Agent), and then `sessions.call` restores it — D5's "load and hold for the call" measured on the production path rather than on a Session created behind Agents' back. While the Agents index is being replaced a routed call answers `session_reloading` (the one transient answer, so a caller retries), pinned by a test of the mapping. Refs #2015 Refs #2127
… serialize the route error
- `LIFECYCLE_METHODS` gains `dispatcher.listen` and `dispatcher.consume`: both
take a function, and a routed call carries data only. The list is hand
maintained, and the generator reads this same constant, so runtime and
declarations agree; the fixture and `routing_flow` assert the refusal.
- `RouteError` serializes, so a Session part's TypeScript caller reads the
owner's structured failure (`owner { name, message, data, reloading }`)
exactly as the process segment and Rust callers do.
- the authoring guide and the issue record say what the code does: the durable
`branch/end` takes a line out of the published set at once, so a later call
answers `no_line`; a call admitted before it keeps its owner's result.
Refs #2015
Refs #2127
… operations excluded - `sessionScope` is no longer one of the Session faces a routed call resolves: the scope resolves lines and the Session's faces, it is not one of them, so `sessionScope.call` cannot reach `sessionScope.lineCall`. The generated `SessionFaces` drops it, and the test asserts the refusal. - `uiResources.publishFile`/`withdraw` join the excluded operations: they take the calling row, which a routed call cannot carry. - `sessions.call` answers the same codes as the Session scope (`not_data_face`, `method_not_routable`, `wrong_scope`), and its `session_unavailable`/`no_line` carry `reason`/`line` instead of folding them into the message. - a replaced or stopping Agents index answers `session_reloading`, retryable, instead of a final `no_session`; a Session that starts closing while a line is selected answers `SessionClosing`. - the retired-name guard covers instance-only names (proved with `sessionConfig`), and the head comparison in `data_faces_flow` no longer assumes no fact publishes between two reads. - the guide states each route's code spelling, the direct-only operations, and who `sessionScope.call` serves. Refs #2015 Refs #2127
…ures `LIFECYCLE_METHODS` is no longer a hand-written list nobody checks: `xtask` reads every `#[rutis::service]` block, finds the operations whose parameters are the calling row, a cancellation or a callback, keeps those the declarations export in a routable scope, and fails when the two disagree in either direction — an operation that cannot cross but is not listed, or a listed one whose signature can. Proved both ways: dropping `uiResources.withdraw` from the list fails with "not listed: [uiResources.withdraw]", and adding `sessionConfig.get` fails with "listed but routable: [sessionConfig.get]". Refs #2015 Refs #2127
`BranchLifecycle::opening_budget` (a service-skip) and `BranchLifecycle::admit_opening_with` (a Rust-only method) come from main (#1997/#2198 era, `fbd65fa82` and `b802a3f7d`), not from this branch; they are in the allowlist now so the check can run against the merged tree. Entries: 171 -> 173, both from main. Refs #2015 Refs #2127
`RunningServer::restart("Agents")` reloads the row the routed call needs, so a
test can hold the window open: the minimal host launches a Session, restarts
Agents while calls are in flight, and asserts at least one
`session_reloading` that says `retryable`, then a retry that answers. Measured
7-8 transient answers out of 150 calls per run.
Refs #2015
Refs #2127
…ivation - `routed_call_flow` is `#![cfg(unix)]` (a Unix socket host) and says so; Windows never builds it. - `npm/plugin.d.ts`'s `SessionsError` is the generated union again, so a caller reads `reason`, `line`, `service`, `name` and `data` instead of casting. - the guide, and the PR, state the real admission cutoff: a running line that ended a tool call stays selectable until its turn ends; the turn's durable `branch/end` is what answers `no_line` afterwards. - the signature derivation has unit tests, and its documented limits name the shapes it does not recognize (`impl Fn`, a bare `fn` pointer, other aliases). Refs #2015 Refs #2127
- `SessionsError` is the generated union intersected with the envelope's `retryable`, which `envelope()` adds to every failure; the fixture reads it on a non-`routed` code. - the signature derivation also recognizes `impl Fn` and a bare `fn` pointer, and its doc says the shapes it still misses are a review-time guarantee. - the line-scope doc links `SessionScope` instead of the removed `Route`, and a stale comment about routing codes is gone. Refs #2015 Refs #2127
… NoSession - the owner-operations table no longer mentions a compact-and-wait variant: a compaction that waits calls `agentLoop.compact` through `lineCall` and waits through the Session's `timelineTree`, because `lineCall` resolves only operations an owner already serves; - the route's module docs name `SessionScope::call`, say the scope is not one of its own faces, and say that Agents loads a Session for the call, so `NoSession` means it does not exist or cannot load again (D5). Refs #2015 Refs #2127
…n addresses - the ten `@ts-expect-error` cases are inside `readByCalls`, where `scope` and `sessions` resolve, so each one now proves the call shape rather than a missing name; - `LineCall` takes no `sessionId` and `SessionCall` takes neither `lineId` nor `sessionId`, with a case for each; - the guide states the real cutoff: a line keeps answering after its durable end while `close_and_record` waits for `deliver_final`; entering closing is what answers `no_line`. Refs #2015 Refs #2127
…'s code - `SessionScope` is no longer a `PublicService`, so no `Session` read hands it out; `Session::routed_scope` is the owning instance's entry and Agents is its only caller (`dim-app-server`). A route is no longer reachable as a facade read. - `RouteError::Owner` and `SessionsError::Routed` carry the owner's own `code`, read from the bridge error beside `reloading`: a routed failure now says `UnknownBranch`, not just a name and a message. Refs #2015 Refs #2127
… code survives A `compile_fail` doctest on `Session::routed_scope` shows `session.session_service::<SessionScope>()` does not compile now that the scope is no `PublicService`; a unit test shows a remote failure's own code (`UnknownBranch`) reaches `RouteError::Owner` beside `reloading`. Refs #2015 Refs #2127
… only shared faces - `routing_flow` compares `InputQueue::withdraw`'s `InvalidInput` directly and through `lineCall`, so the owner's own code is proven to arrive unchanged. - `face` requires `catalog.is_shared`: a native-only registration answers `NotDataFace`, which a Session part cannot reach. The rig shares the faces its cases use, the way the product's `share_names` does. Refs #2015 Refs #2127
`Session::routed_scope` was a public method, so any crate with a `Session` could still take the router and write the Timeline through `lineCall`. The entry is now `dim_agent_runtime::route::routed_scope(&Session)`, which reads the owning instance through a crate-private `Session::assembly`; the facade keeps no router read, and two `compile_fail` doctests pin both ways it must stay unreadable. The owner-operations table said the compact handler routed `agentLoop.compact` and waited through `timelineTree`; those faces are internal and answer `NotDataFace`, so the row now states the direct calls the code makes. Refs #2015 Refs #2127
`call_face` now answers `Option<serde_json::Value>`: a method that replies nothing settles as `BridgeValue::Undefined` and crosses as `None`, while the owner's `null` stays `Some(Null)`. `SessionScope::call`/`line_call` and `sessions.call` follow: the process envelope omits `value` for a void reply instead of writing `null`, and the routed arm owns its envelope so it is not wrapped twice. Tests: `route::tests::a_void_reply_is_undefined_and_a_null_reply_is_a_value` for the mapping, and `routing_flow::a_void_reply_stays_undefined_and_a_value_stays_a_value` for a void `sessionLoader.remove` and a real reply through the route. Refs #2015 Refs #2127
A bare `Session` had a public path to the router (`pub mod route`, `pub use route::*`, `pub fn routed_scope`), so any crate holding one could write the Timeline through `lineCall`. The module is private again and exports only its data types; the router travels in `RoutedSession`, whose constructor is crate-private, and the mechanism caller that owns the index takes one from `Agent::routed_session(id)`. Three `compile_fail` doctests pin the ways a bare `Session` has none: `session.routed()`, `routed_scope(session)` and `RoutedSession::new(..)`. Refs #2015 Refs #2127
- `RoutedReply<C>` makes the declaration honest about the two surfaces: a method that replies nothing reaches a routed caller as `null` (the bridge maps `Value::Undefined` to JSON null) while a direct call returns `undefined`; the fixture pins the `null`, and the contract and the guide state the difference. - a Session that starts closing between the scope check and the router lookup answers `SessionClosing`, not `SessionUnavailable`. - the paragraph that describes `Session::instance` sits on `instance()` again; `routed` has its own. Refs #2015 Refs #2127
…n are - `sessionScope` answers `null` for a method that replies nothing, while the `sessions` envelope leaves `value` out and a process caller reads `undefined`; the contract, the guide and the sessions-service page say so. - `Session::instance` has its paragraph back; `SessionClosing` says the process envelope answers `session_closing` instead of claiming it reads as `NoSession`. - the rig shares the mechanism names the product shares too, so the refusal of `sessionMethods`, `toolRegistry`, `guideEntries`, `sessionLifecycle` and `branchLifecycle` is asserted for being a registration point or a lifecycle service, not for being unshared. Refs #2015 Refs #2127
Simon-He95
left a comment
There was a problem hiding this comment.
Reviewed the b7e5ef44..c27898de delta. It is docs, a restored Session::instance doc, and tests: the new routing cases pin that registration/lifecycle services are refused as non-data faces, and the contract now states the two reply shapes correctly (sessionScope sees null, the sessions envelope omits value and reads as undefined). No behavior regression; my approval carries.
The PR is now CONFLICTING after #2202 merged (the agent.rs / access-layer overlap). Rebase and rerun before merge; the Session::service_opt access-layer entry still has to be removed by whichever of #2174/#2206 lands second.
c27898d to
673342a
Compare
|
按 head 1. 这个作用域里没装目标服务时,不能答成所有者的错误
2. 变基到最新的 main base-4 已经由 #2202 合并,它改了所有创建和恢复 Session 的调用,本 PR 和 main 又有冲突了。 3. PR 描述按现在的实现更新
「Still open」里访问层检查的三处放宽,以及来自 main 的 4 条 改完后请 yyhhyyyyyy 和 zerob13 重新评审。 |
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Review: #2174 route calls by id to a live Session or line
Reviewed head 673342a0 against origin/main a8d84e93 (round 12), the full main...head diff. The branch was rebased onto the current main during this round; the old c27898de head is no longer in the history, so this review covers only the new history.
The r11 blocking P2 is fixed: the contract, the authoring guide and the sessions-service page now say per surface what a routed void answers. The rebase is lossless: git range-diff shows every branch commit identical except one import union in crates/dim-app-server/src/agents.rs, and the adaptation commit only passes CreateSessionOptions and RestoreSessionOptions defaults at two test call sites, which preserves the earlier one-argument behavior. No blocking finding.
Fixed at 673342a0
- The per-surface routed void:
docs/design/contracts/runtime-owner-operations.md:43-45,docs/typescript-plugin-authoring.md:70-72anddocs/design/appserver/sessions-service.md:144-145saysessionScopeanswersnullwhilesessions.callomitsvalueand a process caller readsundefined. The call arm leavesvalueout (crates/dim-app-server/src/agents/sessions.rs:1021-1035),reply_valuekeeps an absent value apart from JSON null (crates/dim-agent-runtime/src/route.rs:459-463,:575-578), andSessionsErrorserializes the snake_casecode(crates/dim-app-server/src/agents/sessions.rs:295). Withdrawing the r11 P2. Session::instancehas its paragraph again (crates/dim-agent-runtime/src/agent.rs:767-771), the same text main carries. Withdrawing the r11 P3.- The routing rig shares the six mechanism names and asserts
NotDataFacefor the registration points and lifecycle services (crates/dim-agent-capabilities/tests/routing_flow.rs:68-79,:497-523). All eightrouting_flowcases pass. Withdrawing the r11 P3. RouteError::SessionClosingnow says a process caller readssession_closingand ends its work (crates/dim-agent-runtime/src/route.rs:66-68);routed()maps it atcrates/dim-app-server/src/agents/sessions.rs:932. Withdrawing the r11 P3.
Cross-PR
- #2226 (open, head
244d231b) moves the fourBranchLifecycleopening methods. The PR description now lists all four (opening_budget,admit_opening,admit_opening_with,finish_opening) and says whichever merges later deletes the entries atxtask/access-layer.json:561,:566,:571,:576. - #2206 (open, head
68ff0118) removesSession::service_opt; the entry atxtask/access-layer.json:526must go when it lands. - The rebased head passes the access check against main
a8d84e93(173 allowed), so neither main nor #2202 staled the list.
Optional (P3)
RoutedReply's comment still says "a routed call" without thesessionScopescope (npm/branch-services.d.ts:1944), and the fixture comment atruntime/fixtures/branch-calls.ts:41repeats it. The guide now distinguishes the two surfaces, so scope these two comments the same way.- The PR description's verification line says the access layer check passes with 171 allowed; at
673342a0cargo run --locked -p xtask -- checkreports 173. Update the count. SessionsService::invokestill passes through any reply with a top-levelok(crates/dim-app-server/src/agents/sessions.rs:909). Sound today because only thecallarm produces one (:1021-1035), but a future method with anokfield would skip the envelope.xtask/src/catalog.rs:137linksdim_agent_runtime::route::resolves, androuteis private (crates/dim-agent-runtime/src/lib.rs:15). Point atdim_agent_runtime::resolvesor drop the link.- No
compile_failpinssession.session_service::<SessionScope>(); the existing case incrates/dim-agent-runtime/src/scope.rs:27covers another type. The type is safe today, a case keeps it so. - Test gaps unchanged: no case holds an opening
branch/startbatch and assertsNoLine;an_owner_failure_keeps_its_code_through_the_route(crates/dim-agent-capabilities/tests/routing_flow.rs:378) puts the direct result only in the assertion message; the process envelope'sroutedshape is not asserted; and no test calls a void method throughsessions.call, which is the surface the new docs sentence covers. - The owner contracts still omit the new method and face:
docs/design/contracts/session-access.md:7anddocs/design/appserver/sessions-service.md:30-31list thesessionsmethods withoutcall, anddocs/design/service-faces.mdhas nosessionScoperow.
Verification
Run with LC_ALL=en_US.UTF-8, isolated HOME, TMPDIR, XDG and CARGO_TARGET_DIR under the review data directory, and the pinned 1.100.0 toolchain. Worktree clean at the head.
git range-diff 076df0a1..c27898de a8d84e93..673342a0: every branch commit identical except commit 5, whose only difference is the import union incrates/dim-app-server/src/agents.rs(CreateSessionOptionsandRestoreSessionOptionsbesideRouteError). The old docs commit is1c3a8524cwith the same patch, and673342a0adds only the two test adaptations.cargo run --locked -p xtask-check: passes, access layer 173 allowed.cargo run --locked -p xtask -- check: passes, 43 plugin documents.cargo fmt --all -- --check: passes.cargo test -p dim-agent-capabilities --test capabilities_flow routing_flow::: 8 pass.cargo test -p dim-app-server --lib a_routed_call_during_an_index_replacement_is_transient: pass.cargo test -p dim-app-server --test routed_call_flow: 2 pass.cargo test -p dim-agent-scheduler --features testing --test scheduler_flow a_process_call_by_id_reaches_a_live_session: pass.node --test runtime/plugin-sdk.test.mjs: 2 pass.
Unverified: the runtime null for a routed void was not re-probed through a language connection at this head; it follows from reply_value and the fixture, as before. The sessions.call void omission is read from the code and still has no test, which is a test gap above. CI run 45807453955 at 673342a0: changes, scripts, static-checks, dependencies, macos-native, web and windows-cli pass; verify (linux) was still running when this review was written. GitHub reports MERGEABLE, mergeStateStatus BLOCKED by review.
Verdict: APPROVE. The r11 blocking item is fixed and the rebase preserved the branch. The remaining items are optional.
Base-1 of #2015, on the decided shape of #2127#7162130335 and ADR 027 as amended by #2200. Rebased onto
ade859730. Draft.Two operations, called directly
Whoever holds the instance selects the target, from the table it already has; there is no route object and no separate index.
sessionScope.lineCall({ lineId, service, method, args })sessionScope.call({ service, method, args })sessions.call({ sessionId, lineId?, service, method, args })sessionScopeis new here (Session group), holding its Session and no other:lineCalltakes nosessionId, and a line of another Session answersNoLine. base-3 addsdescribe().sessions.callloads the Session through Agents'acquireand holds it while the call runs (D5); withlineIdit then calls the samesessionScopeoperations in that instance, so both segments share one implementation.published: the published view both paths see, so a line that is open but not yet published answersNoLine. A closing line answersNoLine(theis_closingcheck is kept, becausepublishedstill returns it).argsfrom the target operation's request type and reads the reply as that operation's reply type. No typed entry exists:LineHandle::get,line(&scope, …)andsession_faceare gone, and no allowlist entry was added for them (ADR 027 D3).Reach is judged once (
route::face) for every call: a name the assembly marksinternal(reason), a registration point (sessionMethods,toolRegistry,promptRegistry,guideEntries,submitChecks) or a scope lifecycle service answersNotDataFace; a data face of the other scope answersWrongScope.Answers
NoSessionSessionClosingSessionReloadingSessionUnavailable { reason }NoLineRouted { name, message, data, retryable }Error::data()), and whether the owner says it may be retriedA Session part's TypeScript caller reads the same structure:
RouteErrorserializes, soRouteErrorThrown's data carriesowner { name, message, data, reloading }.The owner's failure is retryable only when the owner's own code says so (
Reloading), read with the bridge'sError::code(): a permanent failure is never retried, whatever its text says.SessionsCall's Session arm declareslineId?: never, so a Session service passed with alineIdis refused bytscinstead of reachingWrongScopeat runtime.NoSessionandSessionUnavailablefollow Agents' own classification: a Session that no Agent owns and that has no stored rows isno_session; one with stored rows that cannot be loaded answerssession_unavailablewith the reason. A Session that closed itself keeps its rows, so it answerssession_unavailable; a deleted one answersno_session.The five selection answers carry their own codes on the
sessionsface (no_session,session_closing,session_reloading,session_unavailable,no_line); the owner's failure isroutedand is retryable only when the owner's own error says reload.Types
xtask -- typesgenerates the request types for both operations:serviceis a data face of the target scope,methodone of that face's methods, andargsthat method's parameters (LineCall,SessionCall,SessionsCall). A wrong service, a wrong method or wrong arguments failtsc. The faces and their groups are read from the registration calls themselves — bothregistercalls andcatalog.register_shared_instance("name", GROUP)method calls — and the names an assembly marks internal are left out, from the single-name marks and from the product's(name, reason)table. A face whose type has no generated interface (timelineStore,timelineFactory,collaborationSession) is not offered: there is no type to give its methods.runtime/fixtures/branch-calls.tsplus nine@ts-expect-errorcases is typechecked byruntime/plugin-sdk.test.mjs.The authoring guide shows only these operations (Calling a Session or line by id).
Access layer
xtask/access-layer.jsongains, per §5's exception, three groups and nothing else:Session::service_optfbd65fa82,b802a3f7d); #2226 (244d231b) moves them toBranchOpeningBranchLifecycle::opening_budget,admit_opening,admit_opening_with,finish_opening— not this PR's code; tracked by #2213 and #2226. Whichever of the two merges later deletes these four entries.173 total, nothing removed this round. The two entries that came from main are #2213's to remove once that issue fixes
BranchLifecycle's opening registration surface; this PR does not touch that implementation.Verification
cargo clippyover the touched crates (dim-agent-runtime,dim-app-server,dim-agent-capabilities,dim-agent-scheduler,xtask-check), all targets: clean.cargo run --locked -p xtask -- check: passes (access layer 171, declarations, plugin documents, i18n, comment links, literal main).node --test runtime/plugin-sdk.test.mjs: passes — the generated requests reject unknown services, unknown methods and wrong arguments, and the fixture's valid calls compile.dim-agent-capabilitiesrouting_flow: 6 pass (own line and faces,SessionClosingwhile closing,NoLineafter an end while the Session's other calls arrive, a language call over a bug session, reach refusals, idle unload and reload).dim-app-serverrouted_call_flow: a minimal host with the offline model catalog launches a Session, answers a face call, reloads it after an idle release (D5), and observes a retryablesession_reloadingacross anAgentsrestart followed by a successful retry.dim-agent-schedulerdata_faces_flow:sessions.callover a bridge reaches a Session's face and a line's, answersno_sessionfor an unknown id and after asessions.delete,no_linefor a missing line, andsession_unavailablefor a Session that closed itself (its rows remain but Agents cannot load them).cargo test -p dim-agent-integration-tests --locked: passes.Typed replies, and the generated set against the runtime
ReplyOf<C>reads the target method's own return type from the generated interface.SessionScope.lineCall/call(declaration-merged, so the generic form is the one a caller sees) and the injectedsessions.callanswerReplyOf<C>; the fixture asserts a valid reply type and that a wrong one is refused. Faces without a generated interface (timelineStore,timelineFactory,collaborationSession) are not offered at all, rather than offered untyped.xtask -- checkcompares the two in both directions: every name the file offers must be oneroute::resolvesaccepts and the assembly provides, and every data face the route resolves that the file declares an interface for must be offered. Proved both ways — offeringloopStatefails with "offers names the route refuses", droppingbranchLinefails with "does not offer routable data faces".Review round: what changed
Owner { name, message, data, reloading }keeps the structured value the owner's error carries, andsessions.callforwards it asRouted { name, message, data, retryable }. A caller can act on the same structure a direct call would read.removedlist again, so a retired service name cannot return unnoticed; proved by listingsessionIdentity.branch/endis what answersno_lineafterwards, and a call admitted before it keeps its owner's own result.Operations a routed call cannot keep alive
An operation that needs a cancellation the caller observes through the future, or hands the caller something to settle, keeps its lifetime only when it is called directly. They are excluded on both sides from one hand-maintained list the runtime owns (
route::LIFECYCLE_METHODS); the generator reads that same constant, so the runtime and the declarations cannot disagree:dispatcherconsume,listenconsumehands the caller a subscriptionpermissioncheckcancelled: () => void | Promise<void>toolHostexecutecancelledcallbacktreeCommandscreatecancelledcallbackwaitwaitcancelledcallbackuiResources.publishFile/withdraware there too: both take the calling row, which a routed call cannot carry. The runtime refuses them withRouteError::MethodNotRoutable(permanent), the generator reads the same list and emitsOmit<Face, 'method'>in the authoring types,runtime/fixtures/branch-calls.tsassertswait.waitis refused at compile time, androuting_flowasserts the runtime refusal forwait.waitandtreeCommands.create. Runtime and declarations therefore cannot drift.Review round (line comments + maintainer note)
sessionScopeis no longer one of the Session faces a routed call resolves. It resolves a line and the Session's faces;sessionScope.calltherefore cannot reachsessionScope.lineCall, the generatedSessionFacesdrops it, androuting_flowasserts the refusal.sessionScope.callstays for the caller that selected a Session by id, as the guide says.sessions.callanswers the same codes as the Session scope (not_data_face,method_not_routable,wrong_scope), andsession_unavailable/no_linecarryreason/linebeside the message, so a caller reads them instead of parsing text.session_reloading(retryable) rather than a finalno_session; a Session that starts closing while a line is being selected answersSessionClosing.catalog.key_in'sOutsideInstance), proved by a unit test withsessionConfig.data_faces_flow's head comparison no longer assumes that no fact publishes between two reads: the routed head must lie between the two direct reads.sessionsenvelope, camelCaseRouteErrorvariants for the Session scope), the direct-only operations, and whosessionScope.callserves.Review round: what is not done
timeline.query, say) is still missing.crates/dim-app-server/tests/routed_call_flow.rsserves a minimalAgentBuilder(capabilities and mock hosts only, no Scheduler) withServerConfig { model_catalog: offline AimuxModels, database_path, unix_path, product_home: None }. It proves two of the four points on a Session Agents admitted throughsessions.launch: a face call answers;Session::unload_if_idletakes the Session out of the Agent; and the nextsessions.callrestores it (D5). A third, the transient answer, is pinned at its mapping: a routed call while the Agents index is replaced answerssession_reloading(retryable).acquire's documented behaviour.Still open
Serialize, and exempts associated functions withoutself.call_facereports a face with no dispatch asOwner { name: service }rather than a routing answer. The target has no name to keep a kind for, so the message says it is not provided.branch/endkeeps its owner's result, and a running line stays selectable until its turn ends; neither window has a test that holds it open.routed_call_flowlaunches through Agents, releases the Session withSession::unload_if_idle, and the nextsessions.callrestores it. A Session created straight on the Agent cannot be restored, becauseAgentIndexnever records it: at the callInner::versionshas no entry,Inner::owneranswers only through its live-Session fallback, and after the release that fallback answersNone, soacquire_checkedtakes itsstore.has_recordsarm and answersStorage("Session … has no available owner")— reported assession_unavailable. Recorded in 按 id 调用:由持有实例的一方选目标(base-1) #2127 for 所有者扫描:Agent 目录与协作 #2020.RunningServer::close_sessionanswersokfor such a Session and the next call restores it, because Agents' index does not know it. The tests therefore assert what they can observe: a Session that closed itself keeps stored rows Agents cannot load (session_unavailable), and a deleted one isno_session.slot.uses > 0, which Agents' idle pass skips, and observing it needs an owner operation that blocks (the blocking face operations are the ones this PR excludes).Refs #2015
Refs #2127