Skip to content

feat(runtime): read a Session through its own scope (base-3) - #2316

Draft
eric8810 wants to merge 17 commits into
mainfrom
dim/2025-session-describe
Draft

eric8810 wants to merge 17 commits into
mainfrom
dim/2025-session-describe

Conversation

@eric8810

Copy link
Copy Markdown
Collaborator

Base-3 of #2015: Session-scope reads (#2025). Draft while the migration lands.

Scope

  • sessionScope.describe() -> { sessionId, restored, config, agent }, replacing the sessionIdentity, sessionConfig and agentConfig faces. The values are the ones the Session was assembled from (SessionAssembly::config, restored, assembly.config), so no conversion is introduced.
  • timelineIdentity goes; callers read timelineContext.identity().
  • SessionIdentity.unloading goes; the fact is read from sessionLifecycle.unloading(), a new operation this PR adds per the #2025 decision.
  • RequestSettings/repair belong to dim/2025-session-host and are not in this PR.

Progress

  • sessionScope.describe() and SessionLifecycle::unloading() in the runtime; declarations regenerated (npm/branch-services.d.ts).
  • Remove the four faces and migrate every caller: sessionIdentity, sessionConfig, agentConfig, timelineIdentity (Rust, npm declarations, fixtures, tests, docs), then record the names in the access layer's removed list and drop their allowlist entries.

Refs #2025

`sessionScope.describe()` answers `{sessionId, restored, config, agent}` from
the values the Session was assembled with: the configuration it was created
with and the Agent that owns it, so a part reads one call instead of three
faces. `SessionLifecycle` carries the unloading token and answers
`unloading()`, which is where that fact will be read once the identity face
goes (#2025).

Refs #2025
…k A-C, red)

The parts that injected `SessionIdentity` now name `SessionScope`, and the
branch parts that injected `TimelineIdentity` name `TimelineContext`; 44 files
follow the rename. The field reads still use the old shapes, so this commit does
not compile: the remaining 63 errors are field reads (see the PR body).

Refs #2025
`TimelineContext` gained `session_id()`/`branch_id()` and `SessionScope` gained
`session_id()`, so the field reads that followed the rename resolve; the
workspace compiles with `cargo check --workspace --all-targets`.

The runtime assembly check still fails: every branch part that now injects
`TimelineContext` cannot load (`TimelineContext@128 Missing`), because the
context is provided by the branch's timeline row these parts build.

Refs #2025
`ToolExecutor`, `Prompt` and `ModelProvider` no longer list `TimelineContext` in
`injects`: they keep its key and read it with `ctx.get_at` when they need an
identity, reporting "timeline context unavailable" when it is not there. This
follows ADR 002 D3 - a lookup, not a load-order dependency, and no second
identity.

Refs #2025
The branch parts that need an identity no longer list `TimelineContext` in
`injects`; they read it with `ctx.get_at` and report "timeline context
unavailable". The assembly check now stops at that error rather than at a
pending row, which shows the reads still happen in `apply`, before the branch's
timeline row provides the context.

Refs #2025
`BranchLifecycle` now holds its `session_id`/`branch_id` and answers them Rust-only
(`#[service(skip)]`), so a branch part can read the ids without taking a
`TimelineContext`, which its own timeline row provides only after the parts are
assembled. `TimelineContext::identity()` returns `TimelineIdentity` as data and
the `timelineIdentity` face is no longer provided.

Partial: four parts still pass an `Arc<TimelineContext>` into their runtimes, so
`cargo check` reports `cannot find value identity` at
`context_preparation.rs:1045/1061`, `model_provider.rs:696`, `prompt.rs:794`.

Refs #2025
`BranchLifecycle` carries `session_id`/`branch_id` (Rust-only,
`#[service(skip)]`), and the branch parts that used to inject `TimelineContext`
or `TimelineIdentity` read the ids there instead, so no part depends on a
context its own timeline row provides later. `TimelineContext::identity()`
remains the one public read and the `timelineIdentity` face is no longer
provided.

Intermediate: four plugins still collide on a `lifecycle` field name, so the
crate does not compile yet (`session_broadcast.rs:154`, `shell_session.rs:1147`,
`timeline_tree.rs:3297`, `hooks/runner.rs:2239`).

Refs #2025
Four plugins had two `lifecycle` fields and locals that still named the removed
identity; the duplicates are gone and `shell_session`/`timeline_tree` read the
ids from `branch_lifecycle`. Remaining errors are per-plugin field/name fallout
in `hooks/runner.rs`, `session_broadcast.rs`, `shell_session.rs`.

Refs #2025
`HooksSessionPlugin` had lost its field while the duplicates were removed; it
holds the Session's scope under `lifecycle` and reads the id from it, so the
field and constructor agree again. `hooks/runner.rs` is clean; the other files
keep their errors.

Refs #2025
`SessionBroadcastPlugin` injects the branch lifecycle (not a removed identity)
and takes its `session_id`; the end plugin keeps one key per fact - the Session
scope for the id and the Session lifecycle for `unloading()` - instead of two
duplicate `lifecycle` parameters.

Refs #2025
The plugin carried a `lifecycle` key and a `branch_lifecycle` key for the same
service; it keeps the second, lists it in `injects`, and reads the ids through
its methods.

Refs #2025
…dentity face

The plugins that needed a branch's ids now read them from `BranchLifecycle`
(the tree timeline, the shell session, the broadcast, the tool executor and the
loop); `TimelineContext::identity()` returns `TimelineIdentity` as data and the
`timelineIdentity` face is gone from the catalog and the declarations. The
plugin pages name the services the code actually injects.

Refs #2025
Twelve files stop naming `SessionConfig`/`AgentConfig` as a service and name
`SessionScope` instead; the call sites that read the values still use the old
shape, so the workspace reports the remaining conversions.

Refs #2025
The Questions part takes the Session's configuration from `sessionScope.describe()`,
and the agent-config face test now compares the wire reply with the whole
description the scope answers instead of the removed single-value face.

Refs #2025
…and app-server parts

The plugins that named `SessionConfig` as a service now name `SessionScope` and
read `describe().config` (and `describe().agent.model` for the model lookup),
so no part depends on a face that is being removed. The Questions plugin page
names the scope it injects.

Refs #2025
…timelineIdentity faces

The three Session faces and the branch identity are gone from the catalog, the
assembly and the declarations; their data types stay where code still uses them,
and `sessionScope.describe()`/`timelineContext.identity()` are the reads.
`SessionIdentity` had no data reader left and went with its face. The access
layer loses the stale `SessionConfig::exclude_codemode_below` entry (154 -> 153).

Composition still fails: parts that inject `SessionConfig`/`SessionIdentity` by
name have not been migrated to `describe()` yet, which the check now reports as
a pending assembly.

Refs #2025
…parts

WorkspaceTools, ToolRegistry, ShellInput, Skills and TemporaryMcp take
`sessionScope.describe()` (its `config` or its `sessionId`) instead of a removed
`SessionConfig`/`SessionIdentity` name.

Refs #2025

This branch has not been deployed

No deployments
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