Skip to content

fix(route): answer an uninstalled service as NoService - #2238

Merged
eric8810 merged 2 commits into
mainfrom
dim/2127-no-service
Nov 27, 2026
Merged

eric8810 merged 2 commits into
mainfrom
dim/2127-no-service

Conversation

@eric8810

Copy link
Copy Markdown
Collaborator

Summary

Refs #2127. Follow-up to #2174, which merged before this point of the #2127 decision landed.

When a routed call selects a Session or a line but no provider of the service is installed there (its profile leaves the service out), the runtime answered it as the owner's own failure: Owner { name: service, message: "... is not provided now" }, which sessions.call reported as routed. No owner ran, so the holder now answers it as a selection answer:

  • RouteError::NoService { service } (crates/dim-agent-runtime/src/route.rs), code no_service;
  • SessionsError::NoService { message, service } on sessions.call, final and not retryable;
  • regenerated npm/branch-services.d.ts; npm/plugin.d.ts, the TypeScript authoring guide and the runtime owner operations contract list the new code.

Also fixes one stale phrase in the route.rs module docs ("Rust calls the same two operations": there are three).

Design rule checklist

  • Scope: n/a, no new part.
  • Commands and results: n/a, no Timeline commands.
  • Handover: n/a.
  • Timeline before callbacks: n/a.
  • Infrastructure: the routing answer changes inside the router itself (ADR 027, 按 id 调用:由持有实例的一方选目标(base-1) #2127).
  • Core mechanisms and consumers gain no plugin-specific handling.
  • Batch: n/a.
  • Context: n/a.
  • No reading another plugin's internal state or deciding for it.
  • Cross-language faces: the new error is serde data on the existing sessionScope and sessions faces.
  • Business configuration and loader rows: n/a.
  • Missing mechanism capabilities: none.
  • Timeline contents: n/a.

Documentation

  • No accepted ADR is modified.
  • No other module's design is changed: the contract and guide list the router's own new code.
  • No delivery status added.

Verification

  • cargo test -p dim-agent-capabilities --test capabilities_flow routing_flow: new cases call a line face and a Session face the catalog shares but the profile does not install, and both answer NoService.
  • cargo test -p dim-agent-scheduler --test scheduler_flow data_faces_flow
  • node --test runtime/plugin-sdk.test.mjs (the SessionsErrorThrown code union includes no_service)
  • cargo fmt --check, clippy -D warnings on the three touched crates, node scripts/adr-check.mjs --base origin/main
  • cargo run -p xtask -- check: access layer, service declarations and the other static checks pass. It then stops at execStop: internal(control) names no catalog service, which fails the same way on main at 79ce0a2b7 without this change.

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at 62d67b97bc27673c32c12f103c685449e2dbeb23. A missing dispatch now returns a non-retryable selection error in both Session and line scope; an invoked owner's error and the existing reload paths retain their behavior. On the exact merge tree, eight routing flows, three router unit tests, and two SDK tests passed. The sessions.call envelope was checked by tracing the mapping and serialization.

The required CI gate is red. Linux passed format, Clippy, build, and declaration validation, then stopped at execStop: internal(control) names no catalog service, before workspace and Node tests. The same failure is present on the current base after #2206 removed the catalog entry. macOS-native passed; Windows was not selected. This approves the PR's code, not bypassing the merge gate.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Goal: a routed call that reaches a Session or line where the requested service has no provider must answer a selection error instead of an owner-shaped failure. This PR adds RouteError::NoService { service }, maps it to SessionsError::NoService on sessions.call, and lists no_service on every surface. The change does that correctly.

Why it is correct:

  • SessionScope::line_call resolves the line before the service (crates/dim-agent-runtime/src/route.rs:363-370), and SessionScope::call checks Session liveness before the service (route.rs:339-351). SessionClosing and NoLine still win over NoService, and NotDataFace/WrongScope/MethodNotRoutable still win over it, which matches the #2127 order: Session, line, service.
  • call_face answers NoService only when the per-instance HostDispatch is missing (route.rs:446-450), before invoke. No owner runs, and no Owner construction remains for this case.
  • SessionsError::NoService is mapped at crates/dim-app-server/src/agents/sessions.rs:941, and retryable() (sessions.rs:376-387) excludes it, so the envelope reports code: no_service with retryable: false.
  • Every contract face carries the code: npm/branch-services.d.ts:1419,1482,1487,1826,1832, npm/plugin.d.ts:308-313, docs/typescript-plugin-authoring.md:36-41,63-70, and docs/design/contracts/runtime-owner-operations.md:46-51, besides the Rust docs in route.rs and agents.rs. I found no face that lists the sibling codes but omits no_service.
  • The new cases at crates/dim-agent-capabilities/tests/routing_flow.rs:604-623 register a shared branch and Session name with no provider (routing_flow.rs:80-86) and assert NoService for both line_call and call. They fail on the old code and pass now.

Findings (no P0-P2):

P3 - crates/dim-agent-runtime/src/route.rs:26: the doc phrase change is not a stale-phrase fix. The "two operations" are SessionScope::line_call and SessionScope::call; sessions.call is the process envelope over the same two forms, and the #2127 decision says Rust uses only those two. Problem: the sentence now follows a list of three operations and reads as if Rust calls sessions.call too. Failure scenario: a contributor adds a third Rust entry point or documents the binding incorrectly. Evidence: route.rs:19-23 (the three operations) and route.rs:26; the decision is the comment at #2127 (comment). Fix: keep "the same two operations", or name the two SessionScope operations.

P3 - test coverage stops at the SessionScope surface. Problem: the sessions.call mapping this PR adds is not exercised end-to-end. Failure scenario: a later change maps a missing provider back to Routed at crates/dim-app-server/src/agents/sessions.rs:941, or the code is dropped from the serialized error, and these tests still pass. Evidence: the new cases call scope.line_call/scope.call only (routing_flow.rs:604-623); sessions.call is covered in crates/dim-app-server/tests/routed_call_flow.rs:121-164 with installed faces only, and no test covers an unknown service name or NoLine precedence. Fix: add one case to routed_call_flow.rs that registers a shared name with no provider on the builder (as routing_flow.rs:80-86 does) and asserts the {ok:false, error:{code:"no_service", service, retryable:false}} envelope; optionally assert no_line wins when the line is absent. A follow-up is fine.

Verification:

  • cargo test --locked -p dim-agent-capabilities --test capabilities_flow routing_flow:: passed 8 of 8.
  • cargo test --locked -p dim-agent-runtime --lib route::tests passed 3 of 3.
  • cargo fmt --all --check is clean.
  • I did not run runtime/plugin-sdk.test.mjs: runtime/node_modules and the npm cache are absent in this offline environment, and the Linux verify job did not reach the Node step. The declaration check did pass ("service declarations passed"), so npm/branch-services.d.ts is current.
  • CI now: verify (linux) and ci-ok fail at execStop: internal(control) names no catalog service after the format, Clippy, build and declaration steps. execStop is in crates/dim-app-server/src/lib.rs:1692 on current main (06f1402) and this PR does not touch it; macos-native passed, the other jobs are skipped.
  • Cross-PR: mergeable with current main. #2226 overlaps runtime-owner-operations.md (its line 25) and branch-services.d.ts (its line 1213), not this PR's hunks; #2234 and #1881 do not touch these files.

Not verified: the process-envelope no_service path end-to-end, the Node SDK compile, and the cross-language RouteError serialization. No earlier review opinions to withdraw (round 1).

Comment thread crates/dim-agent-runtime/src/route.rs Outdated
//!
//! Each call looks the target up again, so a caller never keeps a live target
//! (D4). Rust calls the same two operations: it builds `args` from the target
//! (D4). Rust calls the same operations: it builds `args` from the target

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P3. Problem: this is not a stale phrase. The "two operations" are SessionScope::line_call and SessionScope::call; sessions.call is the process envelope that takes the same two forms, and the #2127 decision says Rust uses only those two. Failure scenario: the sentence now follows a list of three operations and reads as if Rust calls sessions.call too, which invites a third Rust entry point or an incorrect binding. Evidence: crates/dim-agent-runtime/src/route.rs:26; the operation list at route.rs:19-23; the decision comment at #2127 (comment). Fix: keep "the same two operations", or name the two SessionScope operations.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixed in b1f5f45. The sentence now names the two SessionScope operations, so it no longer reads as if Rust calls sessions.call for a routed call.

service: "notInstalledHere".into()
},
"the holder answers a face the Session does not install"
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P3. Problem: the new cases stop at the SessionScope surface, so the sessions.call mapping this PR adds is untested. Failure scenario: a later change maps a missing provider back to Routed at crates/dim-app-server/src/agents/sessions.rs:941, or the code is dropped from the serialized error, and these tests still pass. Evidence: the new assertions call scope.line_call/scope.call only (routing_flow.rs:604-623); sessions.call is exercised in crates/dim-app-server/tests/routed_call_flow.rs:121-164 only with installed faces, and no test covers an unknown service name or NoLine precedence. Fix: add one case to routed_call_flow.rs that registers a shared name with no provider on the builder (as routing_flow.rs:80-86 does) and asserts no_service with service and retryable: false; optionally assert no_line wins when the line is absent. A follow-up is fine.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixed in b1f5f45. The new case at crates/dim-app-server/tests/routed_call_flow.rs:170-202 registers a shared branch name with no provider, drives it through sessions.call, and asserts no_service with service and retryable: false, plus no_line precedence for an absent line.

@eric8810

Copy link
Copy Markdown
Collaborator Author

@yyhhyyyyyy Both P3 notes are fixed in b1f5f457a:

  1. route.rs:26 now says Rust calls the same two SessionScope operations.
  2. routed_call_flow.rs adds an_uninstalled_service_answers_no_service_after_the_line. Through sessions.call, an uninstalled branch face answers {code: "no_service", service, retryable: false}, and an absent line still answers no_line first.

CI stays red until #2239 fixes the execStop catalog check on main.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Goal: a routed call that reaches a Session or line where the requested service has no provider must answer a selection error instead of an owner-shaped failure. This PR adds RouteError::NoService, maps it to SessionsError::NoService on sessions.call, lists no_service on every contract face, and covers the process envelope end to end. The change does that correctly.

Round 1 P3s, both fixed and withdrawn:

  • crates/dim-agent-runtime/src/route.rs:26 now says "Rust calls the same two SessionScope operations". That names exactly the two SessionScope operations listed at route.rs:19-21 and matches the #2127 decision, so it no longer reads as if Rust calls sessions.call for a routed call.
  • crates/dim-app-server/tests/routed_call_flow.rs:170-202 drives an uninstalled branch face through sessions.call: the Rig shares a branch name with no provider (routed_call_flow.rs:74-77), then asserts ok: false, code: "no_service", service: "notInstalled" and retryable: false, and asserts no_line wins for an absent line. On main (06f1402) the same call answers routed through RouteError::Owner (route.rs:437-446 there), so the case fails without the fix.

No new P0-P2 findings in the complete main...head diff. The #2127 order still holds: line_call resolves the line first and call checks liveness first (route.rs:269-286,338-370), and call_face answers NoService only when the per-instance HostDispatch is missing, before invoke (route.rs:445-450). The envelope mapping and retryability are at crates/dim-app-server/src/agents/sessions.rs:941,969-977,376-387. Every surface that lists the sibling codes lists no_service: npm/branch-services.d.ts:1419,1482,1487,1826,1832, npm/plugin.d.ts:308-313, docs/typescript-plugin-authoring.md:36-41,63-70, docs/design/contracts/runtime-owner-operations.md:46-51.

Verification at b1f5f45:

  • cargo test --locked -p dim-app-server --test routed_call_flow passed 3 of 3, including the new case.
  • cargo test --locked -p dim-agent-capabilities --test capabilities_flow routing_flow:: passed 8 of 8.
  • cargo test --locked -p dim-agent-runtime --lib route::tests passed 3 of 3.
  • cargo fmt --all --check is clean.
  • node --check runtime/plugin-sdk.test.mjs passes. I did not run the Node SDK compile: runtime/node_modules is absent in this offline environment.
  • CI: verify (linux) and ci-ok fail at xtask check with execStop: internal(control) names no catalog service, after the build, lint, access layer, service declarations and the other static checks pass. The same check fails on current main at crates/dim-app-server/src/lib.rs:1692; this PR does not touch that file, and #2239 carries the fix, still open. macos-native passed; the other jobs were skipped. CI does not reach the workspace tests at this head, and the macos-native selection does not include routed_call_flow, so the local run above is the only execution of the new case.
  • Cross-PR: mergeable with main 06f1402. #2226 touches docs/design/contracts/runtime-owner-operations.md line 25, docs/typescript-plugin-authoring.md line 919 and npm/branch-services.d.ts line 1213, none of this PR's hunks. #2234 and #2239 do not touch these files.

Not verified: the Node SDK compile and the Linux workspace test run, which CI does not reach.

APPROVE

@Simon-He95 Simon-He95 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at b1f5f457.

The direction matches the #2127 decision: NoService { service } is one of the selection answers, answered by the holder before any owner runs, and final. The implementation puts it in the right place: face() first proves the name is a data face of the target's group, then call_face answers NoService only when the selected instance has no provider (crates/dim-agent-runtime/src/route.rs:445-451); sessions.call maps it to its own non-retryable no_service (crates/dim-app-server/src/agents/sessions.rs:941, and retryable() covers only reloading/publication-unknown). The tests cover line_call and call on a catalog-shared name the profile omits, and the process envelope pins line selection before service selection and retryable: false.

External interface: an additive variant on the existing sessionScope.lineCall/call and sessions.call faces. The behavior change — a missing provider was previously reported as routed with a fake owner failure — is the classification the #2127 decision already specifies. I checked the TUI and dim-electron: neither matches these codes, and the generated npm/branch-services.d.ts, npm/plugin.d.ts, the TypeScript authoring guide and the runtime owner operations contract are updated consistently. No RPC method, event or persistence change.

CI at this head: verify (linux) fails in xtask check with execStop: internal(control) names no catalog service, which is the pre-existing failure on main at 06f14021 (main run 45836621783 fails identically), not this PR. macos-native is green. Approval is code review only; the merged tree needs a green run before merge.

No blocker from my side.

A routed call that selects a Session or line where no provider of the
service is installed was answered as the owner's own failure
("... is not provided now"). No owner ran, so the holder answers it:
RouteError::NoService { service }, and `no_service` on `sessions.call`,
final and not retryable, as the #2127 decision states.

Refs #2127
Restores the route docs to name the two SessionScope operations Rust
calls, and adds a process-envelope case: an uninstalled branch face
answers no_service, non-retryable, and an absent line still answers
no_line first.

Refs #2127
@eric8810
eric8810 force-pushed the dim/2127-no-service branch from b1f5f45 to d0bb910 Compare November 27, 2026 03:04

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Goal: a routed call that reaches a Session or line where the requested service has no provider must answer a selection error instead of an owner-shaped failure: RouteError::NoService, envelope code no_service, retryable false, and the code listed on every contract face.

Rebase and new commit:

  • The head is two commits on 770f848. The full main...head diff is patch-identical to the previously approved b1f5b457 diff; only the agents.rs hunk offset moved with main. The new test commit restores the route.rs wording "Rust calls the same two SessionScope operations" and adds the process-envelope case at crates/dim-app-server/tests/routed_call_flow.rs:170-202.
  • The new case registers a catalog-shared branch name with no provider (routed_call_flow.rs:74-77), drives sessions.call, and asserts the full envelope: ok: false, code: "no_service", service: "notInstalled", retryable: false (routed_call_flow.rs:186-189), then no_line for an absent line (routed_call_flow.rs:190-199). I copied it onto 770f848 without the fix and it fails at the code assertion with {"code":"routed","name":"notInstalled","message":"notInstalled is not provided now",...}, so it pins the change. It does not duplicate the SessionScope cases and follows the Rig, launch and shutdown conventions of this file.

No P0-P2 findings. The previous P3s are fixed and withdrawn.

Code and contract check:

  • RouteError::NoService is defined at crates/dim-agent-runtime/src/route.rs:86-90, maps to no_service at route.rs:130, and is returned only when the selected instance has no dispatch for the face (route.rs:445-450). line_call resolves the line before the service (route.rs:362-370), and call checks liveness and the face before the same lookup (route.rs:338-341), so no_line, session_closing, not_data_face, method_not_routable and wrong_scope still win.
  • SessionsError::NoService is at crates/dim-app-server/src/agents/sessions.rs:315-317, mapped at sessions.rs:941, serialized by the envelope at sessions.rs:969-979, and excluded from retryable() at sessions.rs:376-387. The envelope is {ok: false, error: {code: "no_service", service, message, retryable: false}}.
  • Every face that lists the sibling codes lists no_service: npm/branch-services.d.ts:1419,1482,1487,1826,1832; npm/plugin.d.ts:307-313; docs/typescript-plugin-authoring.md:36-41,63-70; docs/design/contracts/runtime-owner-operations.md:46-51; runtime/plugin-sdk.test.mjs:140; plus the Rust docs at route.rs:43-45, crates/dim-app-server/src/agents.rs:1825-1827 and sessions.rs:299-302. I found no face that lists the siblings and omits it.

Verification:

  • cargo test --locked -p dim-app-server --test routed_call_flow: 3 passed, including the new case.
  • cargo test --locked -p dim-agent-capabilities --test capabilities_flow routing_flow::: 8 passed.
  • cargo test --locked -p dim-agent-runtime --lib route::tests: 3 passed.
  • cargo fmt --all -- --check --config error_on_line_overflow=true and node --check runtime/plugin-sdk.test.mjs pass.
  • CI at d0bb910: verify (linux), macos-native and ci-ok pass; the other jobs are skipped. This includes xtask check and the generated declaration validation.
  • Cross-PR: mergeable with main 770f848; no file overlap with #2234, #2244 or #1881. #2226 touches runtime-owner-operations.md, typescript-plugin-authoring.md and branch-services.d.ts at different hunks (25, 919, 1213), so it does not conflict with this PR's hunks.
  • I did not run the full workspace locally; CI did. runtime/node_modules is absent, so the Node SDK test was not run locally.

APPROVE

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at d0bb9106977dfb9547dea2a7e79dd993f6df3ed9. The rebase preserves both reviewed patches and the routing contract: a selected line or Session missing a registered provider returns no_service with the service name and retryable: false; no_line still takes precedence for a nonexistent line. Owner errors and reload retry behavior are unchanged.

PR check passed Linux, macOS, and ci-ok on d015fd8e6d9173b0f396b4235d9336f7492699ee. Linux passed the catalog check that stopped the old run, then ran the routing and envelope coverage, workspace tests, and Node binding checks. Windows was not selected. No remaining review blocker.

@eric8810
eric8810 merged commit 7f2acc1 into main Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants