Skip to content

docs(sessionmethods): add the SessionMethods owner contract - #2162

Closed
eric8810 wants to merge 41 commits into
mainfrom
dim/2026-sessionmethods
Closed

eric8810 wants to merge 41 commits into
mainfrom
dim/2026-sessionmethods

Conversation

@eric8810

Copy link
Copy Markdown
Collaborator

Owner: SessionMethods
Batch: 1
Scan issue: #2026
Old PR: #2103
Contract: docs/design/plugins/SessionMethods.md
Base: origin/main 09cf40022
Head: 8b07db140

What

Adds the SessionMethods owner contract: the Session method table, register/call/methods, the shared CallSite/Caller/CallReply call data, the per-call admission and settlement, the shared MethodError, the loaderRows status read and the Session-closing rule. The binding is a hand-written HostDispatch on the owner type; MethodProvider/Accept/MethodTable/the SessionMethods deref and ForeignMethods leave.

Shared rows:

  • docs/design/contracts/session-boundary.md (en+zh): A.1 registration/call rows, A.2 diagrams and call data, Appendix C and Appendix F bindings.
  • docs/architecture/rust-agent/plugins/SessionMethods.md: current implementation and target.
  • docs/design/plugins/README.md / zh: index row.

Dependencies

sessionLifecycle (mechanism service) for the closing rule; optional loaderRows (proposed to #2021) for withdrawn-namespace status; optional reservedMethods for the host's reserved names.

Requirements raised to mechanism owners

Supersedes

  • docs/design/contracts/session-boundary.md A.1's call paragraphs, A.2's diagrams/binding, Appendix F's MethodProvider/Accept/MethodTable/ForeignMethods shapes.
  • docs/architecture/rust-agent/plugins/SessionMethods.md current-implementation paragraphs.

Design decisions

  • One dispatcher per name: the owner type hand-writes HostDispatch; no #[rutis::service] marker.
  • call takes Option<CallSite> and returns CallReply { reply, registration, settled }; Rpc writes the reply, finishes the caller-index entry and awaits settlement.
  • A native call has no call id; a call served by another language's registration mints one, which progress/notifications observe.
  • The table answers closed from the Session's phase() reading Closing, before rows unload.
  • loaderRows is optional; without it a withdrawn namespace answers reloading, as today. With it, {found, status, copies} distinguishes unknown_method/reloading/unavailable.
  • The shared MethodError keeps Reserved for the process table's registration and adds invalid for both tables' registration.

Review record

Ready check

  • Every operation, error and caller next step defined.
  • §7.1/§7.2 and ADR 002 rows answered.
  • Dependencies and requirements match the batch table.
  • Pre-review and both mock reviews 无 P1/P2.
  • node scripts/adr-check.mjs --base origin/main, cargo run --locked -p xtask-check, git diff --check pass.
  • No maintainer question.

Refs #2026

The Session's method table behind `sessionMethods`: `register`, `call` and
`methods` replace the `MethodTable` readers, the provider object and the
`ForeignMethods` wrapper. The contract defines the method-table call data once
— `MethodCall`, `MethodReply`, the handler's error and the table's error kinds —
so A.1 and the process table stop carrying copies, and the Session boundary's
rows point at it (#2026).
The table answers `reloading` and `unavailable` from the registering row's
status, so the dependency states a host port rather than the public loader
name. Both READMEs keep only this owner's index row; the catalog's By-scope
line and the batch's names stay with the organizer.
The table answers a disconnect by nothing: only the provider generation or
the admitting Rpc load interrupts an admitted call. `call` takes the progress
sink and the cancellation so `callChannel` is no longer a dependency, and the
row status is read through `rutis/loader`, whose missing public read is raised
to the mechanism owner. The appendix binds `register` and `methods` as the
face with `#[service(skip)]` for the registration callback, and Appendix F and
A.1 now link the call data here instead of defining it a second time.
A native handler receives A.2's `Caller` in `MethodCall.origin.caller`, and
`call` takes the admission's site, so notifications work for native and foreign
handlers alike. The handler error's code is the error's application code, not
its type name; `closed` is one neutral kind for both tables; the appendix
defines `Handler` once. A.1 and Appendix F stop naming a `caller` request field
or the old provider read, and §9.4 hands the row-status answer to this table.
The call data names `Caller` and `CallSite`, pointing at A.2 for their meaning
and Appendix F for their shape, and A.1 states today's wire before the target's
nested caller. Public failure keeps Rpc's mapping: a rethrown error goes through
the same conversion, AgentError included, and a call that crosses nothing is
`failed`. `cancelled` is the admitting Rpc load's signal, not a caller's stop.
One kind answers the host's grammar and reserved refusals, registrations are per
namespace, and §9.4 keeps the `Session::instance()` record it is cited for.
The binding appendix defines the declarations, the interruption, the progress
sink and the admission's site, so the "one definition" sentences hold and the
connection hand-out is an exception with its lifetime stated. The Session-method
diagram shows `call` reaching the table and the handler. `MethodError::Reserved`
is gone, the process table's row is left to #2021, §1/§4/§6 name the moved call
data and its owner, and every reply, conversion and verification case is stated
exactly.
A duplicate namespace is `duplicate` again, while reserved names and malformed
declarations stay `invalid`. `MethodCallbackError` carries the owner's wire
fields and keeps the ones Rpc's errors already have, so a native method's error
reaches the client unchanged and `params(..)?`/`reply(..)?` convert. The
declaration gains its reply mode, `Progress` is clonable, and A.2's
notification id is the Caller's.
The row-status read becomes `loaderRows`, a dim-owned process face for one row,
instead of a read of rutis-loader's own service. The handler's error keeps the
JSON-RPC code it chooses and converts into Rpc's envelope, so the client's error
is unchanged. The caller's id is minted by the table, `Caller` and
`CallerConnection` are defined here, and the declaration's reply mode is
optional and ignored until handoff exists.
The owner serves one hand-written dispatcher: a marked service beside it would
claim `sessionMethods` twice, so `register`, `methods` and `call` stay on the
type and `HostDispatch` is the only wire entry. `loaderRows` answers each copy's
state, the call id is minted for another language only and progress keeps Rpc's
request id, and Appendix F points here for `Caller`, `CallerConnection`,
`CallSite`, `Progress` and `NotifyError`.
The zh mirror follows the English rows: no `impl Caller`, no `RpcError` in the
call data, and `reply?` optional and ignored. A.2's notification id belongs to a
call served by another language, a withdrawn namespace with no copy in this
Session is `reloading`, and `loaderRows` states the absent-row answer.
`loaderRows` carries `found`, so a row id nothing has is `unknown_method` and
the table reads before it answers. A.2's held-notification rule belongs to a
call from another language; a native handler notifies through its `Caller`.
The declaration's failure shape names its owner fields, `call_id` stays crate
private, and the architecture page includes the disabled-row answer.
Every reply and envelope summary carries the handler's owner fields, and a
missing copy in this Session is `reloading` in the flow as in the error table.
The change note scopes itself to request and reply shapes for a part of another
language, the loader row read states `found`, and the architecture page counts
the per-call tasks the table tracks.
The change note separates what stays (methods, error kinds, application codes,
rethrow) from what moves (the nested caller and a handler's owner fields). A
declaration's `reply` field is accepted and ignored in both bindings, and the
retired `RpcError`/`reply` claims and stale cross-references are corrected.
A foreign reply carrying owner fields is rejected today, not silently trimmed,
and a native handler's fields now reach the client. `closed` answers a
registration without a client code, `interrupted` names the `report` condition,
and the rule check counts the site and the `Caller` as the two stated objects.
The change note attributes the owner-field change to a handler of another
language, keeps a native handler's existing fields, lists the missing
application code and the declared `reply`. An absent or disabled registering row
is `unknown_method` in the absence summaries too, and the introduction says a
registration takes data plus the caller's function.
The change note lists the four client-visible failure changes: an absent
registering row is `unknown_method`, a code-less or binding failure carries
`appError: "failed"`, the nested caller and a handler's owner fields, and the
declared `reply`. The declaration rules keep the host's built-in notification
check with the host, `call`'s parameter is `site`, and `MethodTable` has one
stated owner.
A binding failure keeps `-32603` and gains `appError: "failed"`; the change note
splits the two client-visible failures from the two foreign-part shapes. The
admission diagrams label `call`, `MethodTable` is named as one owner's storage,
and WebEntry's in-process ask has its requirement row.
The foreign handler failure cases are stated one by one: a rethrown error keeps
its code, a thrown error without one carries its name, and a reply that never
crossed is `failed` with today's `-32603`. The change note counts three.
Registrations of another language point at the owning table's binding, and the
`call`/`methods` `closed` step says to re-acquire the Session.
The Supersedes bullet splits: the paragraphs that moved here are the binding
below, while the deleted types leave. The change note scopes a code-less failure
to the case with no remote error and counts the declaration's `reply` as an
accepted, ignored third change, and `cancelled` names an in-process caller's
own load.
The failure conversion and the change note state the cases: a remote error keeps
its code or its name, a malformed reply is `bad-value`/-32000, a bridge error
without a code is `failed`/-32000, and a call that never reached the bridge is
`failed`/-32603. The orphan-rule note is corrected, and the rule-check row says
Rpc calls the tables' operations.
The change note lists the five failure cases and their codes: an absent row is
`unknown_method`, a native code-less failure is `failed` under the service rule,
a malformed reply is `bad-value`, a thrown error without a code keeps its name,
and an error that never reached the bridge keeps `-32603`. The orphan-rule note
is restored, and `origin.entry`/`origin.peer` are removed by the target.
A native code-less failure keeps `-32603` and gains `appError: "failed"`, as the
conversion and the verification say. Appendix F drops `origin.entry` and
`origin.peer`, which the target removes, and the ADR D5 row names each owner's
binding. `loaderRows` names the disabled row, and the declaration rule covers a
name equal to its namespace.
`call` returns a `CallReply`: the reply, the foreign call's caller-index entry
and a settlement signal, so the caller writes the reply, finishes the entry and
awaits settlement as A.2 requires. `methods` is sorted by name, a declared name
may equal its namespace, and `unavailable` names the copy that failed.
The dispatch example writes the reply on every path, then finishes the foreign
call's index entry and awaits settlement, so an error or an interruption
releases the same resources as a value. The process table's `call` returns the
same `CallReply`, and notifications may equal their namespace.
The dispatch example writes the reply before it ends the caller-index entry and
awaits settlement, and a process-side caller has its own example. The process
table's reply is left to its contract, the `CallRegistration` joins the stated
objects, and A.1's call-data links point at the binding appendix.
The shared `MethodError` keeps `reserved` for the process table's registration
and gains `invalid` on `call`, as the organizer decided. Three handles cross the
owner, notifications may equal their namespace in A.2 too, and the in-process
example states its error mapping. `loaderRows` says when `status` and `copies`
are present, and Appendix C's owner-field sentence is neutral.
The Session table's `call` never answers `invalid`: a name outside the grammar is
`unknown_method` and params are the handler's, while the process table's `call`
keeps `invalid` for a malformed request. The zh mirror's call-data links point at
the binding appendix, and Exceptions counts three handles with none holding the
connection.
`invalid` owns the grammar and duplicate checks for both tables and the host's
reserved-name checks for the Session table only; the process table's
registration answers those as `reserved`. The in-process example maps each
admission kind, writes its own answer and returns it.
Every shared row that differs by table names it: the host's refusal is the
Session table's `invalid`, the process table's `reserved`; a malformed name is
the Session table's `unknown_method`, the process table's `invalid`; a table ends
with its Session or process. The site is the table's to hold and drop, and the
architecture page marks its absent-row answer as today's, not the target's.
A name outside the grammar is `unknown_method` in both tables; the process
table's `call` keeps `invalid` only for a request whose params are not an
object. The register flow names both host refusals, and the reloading and
unavailable rows and the call flow say which cells are the Session table's.
A.1's routing diagram dispatches through `sessionMethods.call`, and the table
finds the owner; the zh diagram mirrors it. The process table's `call` kinds are
left to its contract, so the invented `invalid` trigger is gone. The table checks
the grammar and declarations before consulting the host's reserved names.
The process table's `call` kinds stay with its contract: no `invalid` claim here
and none in the change note. Its shape is a requirement to #2021, not a
dependency, and the Dependencies row keeps only `heldNamespaces`. The closing
paragraph says the bridge encodes the `Caller`, and the flows and architecture
page name their tables and wrap.
A refused registration never reaches a client in either table, so `invalid`'s
client cell is empty and the kind joins the registration-only list. A bridge
error without a code is the sixth client-visible failure, and A.1's Registration
row carries the notification rules this contract's paragraph points at.
The lifecycle row restores both unload-ordering guarantees: a registration stops
admitting at the first step of its row's unload and waits for its calls, and a
foreign row's calls settle while its plugin still runs. The wire's `register`
reaches the table's private `register_foreign`, which records the same
registration against the bridge's row and mints no call id.
`register_foreign` takes the calling row's `&Ctx`, so a registration of another
language binds the same generation and unload and is recorded as foreign. A.1's
Registration row is two cells again, and its declaration rules point here. The
bridge's `MethodCall` shape, the foreign registration's `invalid` and the
Supersedes bullets for A.2 are stated.
The settlement future is the fourth hand-out in Exceptions and the §7 rows.
A.1's foreign call shape carries `callId` inside `caller` and its zh mirror is
restored, the loader row's citation is `lib.rs:1476-1482`, and Supersedes scopes
Appendix F to the Session table's paragraphs.
The Session's close ends admission: the table injects `sessionLifecycle` and
answers `closed` from `closing()` before any row unloads, and no handler runs.
`loaderRows` is optional, falling back to today's `reloading` for a withdrawn
namespace, and `session.methods` names its `service_unavailable` while the
process closes. Withdrawal order and the handler's freedom from the table lock
are stated.
The row is recorded before the namespace stops being registered, because its
effect was registered last and runs first. A caller that stops waiting leaves
its call running. A.1's Call ownership speaks of a registration, not a provider
generation, and the shared handler and call types are credited to Appendix F.
The `call` flow row is six cells again, with caller unload, owner close and
settlement in their own columns. `methods` names `service_unavailable` with its
next step, §1 lists the three injections, and a declaration's wire fields and
the call data's types each have one home.
The register flow records the row before the registration is withdrawn, and the
call flow keeps six cells. `methods` no longer claims `unavailable`; that
failure stays in the change note and A.4. The closing check is the synchronous
`phase()`, `loaderRows`' absence is stated in the two absence kinds, and the
wire-code, MethodDecl, deref and Supersedes wording is corrected.
The change list counts eight client-visible changes, the two non-client ones
following it. `Refuse as soon as` replaces the doubled word, `unknown_method`'s
condition is parenthesized, and the methods verification attributes the listing's
`service_unavailable` to Rpc's filter. A.1's routing rows carry the
`loaderRows`-absent `reloading` condition in both languages.
@eric8810

Copy link
Copy Markdown
Collaborator Author

Closing as part of abandoning the owner-split experiment.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant