Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
53756f7
Plan consolidate the Session tree and retire treeCommands
eric8810 Nov 20, 2026
d913118
Merge remote-tracking branch 'origin/main' into impl-1909-tree
eric8810 Nov 20, 2026
c6f49d0
Move branch commands and bounded reads onto the Session timeline tree
eric8810 Nov 20, 2026
6464bae
Merge remote-tracking branch 'origin/main' into impl-1909-tree
eric8810 Nov 20, 2026
80940b7
Keep Goal branch state matching within the formatter limit
eric8810 Nov 20, 2026
3fa9981
Keep branch construction and Session tree control private to assembly
eric8810 Nov 20, 2026
5726071
Capture the report conversation cutoff from the tree directory
eric8810 Nov 20, 2026
5e23427
Dispatch selected branch operations through timelineTree.call
eric8810 Nov 20, 2026
38821e8
Integrate branch Prompt owner operations for selected tree calls
eric8810 Nov 20, 2026
7827715
Dispatch Prompt operations on the selected timeline branch
eric8810 Nov 20, 2026
c727580
Read collaboration approval details through the selected tree
eric8810 Nov 20, 2026
302fd13
Read prompt suggestion usage through the selected timeline tree
eric8810 Nov 20, 2026
af88da9
Withdraw inactive member approval inputs through the tree
eric8810 Nov 20, 2026
b8cca05
Route language adoption through the selected tree and read measuremen…
eric8810 Nov 20, 2026
afefb39
Pin the selected main branch before resolving an Agent profile update
eric8810 Nov 20, 2026
e251d0b
Dispatch operator withdrawals on the branch admitted before steer checks
eric8810 Nov 20, 2026
c800423
Route Collaboration approval decisions through the member Session tree
eric8810 Nov 20, 2026
01b9703
Send Collaboration input withdrawals to the selected branch via Timel…
eric8810 Nov 20, 2026
0df53fa
Deliver collaboration results through tree input and observe the moun…
eric8810 Nov 20, 2026
b6deeae
Expose the branch tool’s existing final-message end operation on time…
eric8810 Nov 20, 2026
2671d86
Merge commit 'cb88ed8fb7c352634d5f52ed40eb1e724f42bce9' into impl-190…
eric8810 Nov 21, 2026
2dfdb05
Merge remote-tracking branch 'origin/eric/1292-domain-loop-prompt' in…
eric8810 Nov 21, 2026
5b42d91
Merge remote-tracking branch 'origin/eric/1292-domain-loop-prompt' in…
eric8810 Nov 21, 2026
f2e4d5f
Use the consolidated tree in the inherited close race test
eric8810 Nov 21, 2026
bb0134b
Merge remote-tracking branch 'origin/eric/1292-domain-loop-prompt' in…
eric8810 Nov 21, 2026
e863517
Format tree withdrawal and refresh service declarations
eric8810 Nov 21, 2026
6f36d5d
Refresh timeline tree service catalog after the owner merge
eric8810 Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/dim-agent-capabilities/src/agent_loop/read.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
methods::{Interruption, MethodDecl, RpcError, SessionMethods, params},
timeline_tree::TreeCommands,
timeline_tree::TimelineTree,
};
use dim_agent_runtime::*;
use rutis::host::{BoxFuture, CtxHost, DynPlugin, Effect, Key, TypeKey};
Expand All @@ -20,7 +20,7 @@ struct Params {
}

pub struct LoopMethodsPlugin {
tree: Key<TreeCommands>,
tree: Key<TimelineTree>,
methods: Key<SessionMethods>,
}
impl LoopMethodsPlugin {
Expand Down
72 changes: 45 additions & 27 deletions crates/dim-agent-capabilities/src/context_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::{
context_preparation::{ContextOpError, ContextPreparation},
methods::{Interruption, MethodCall, MethodDecl, RpcError, SessionMethods, params, reply},
timeline_tree::TreeCommands,
timeline_tree::{BranchCall, BranchOperation, TimelineTree},
};
use dim_agent_runtime::{
Branch, Names, QueryFilter, QueryOperand, QueryOutput, QueryPage, QuerySelect, QuerySpec,
Expand All @@ -19,7 +19,7 @@ use tokio_util::sync::CancellationToken;
pub const NAMESPACE: &str = "session.context";

pub struct ContextMethodsPlugin {
tree: Key<TreeCommands>,
tree: Key<TimelineTree>,
methods: Key<SessionMethods>,
}
impl ContextMethodsPlugin {
Expand Down Expand Up @@ -62,11 +62,19 @@ impl DynPlugin for ContextMethodsPlugin {
branch_id: String,
}
let Params { branch_id } = params(value)?;
let branch = tree.get(&branch_id)?;
match method.as_str() {
"session.context.compact" => compact(&branch, &cancel).await,
_ => usage(&branch, cancel).await,
}
let operation = if method == "session.context.compact" {
BranchOperation::CompactAndWait
} else {
BranchOperation::ContextUsage
};
tree.call_branch(
BranchCall {
branch_id,
operation,
},
cancel,
)
.await
})
}),
)?;
Expand All @@ -76,7 +84,10 @@ impl DynPlugin for ContextMethodsPlugin {
}
/// Writes `context/compact`, or joins the outstanding command, and waits for
/// the result that carries that command.
async fn compact(branch: &Branch, cancel: &CancellationToken) -> Result<Value, RpcError> {
pub(crate) async fn compact(
branch: &Branch,
cancel: &CancellationToken,
) -> Result<Value, RpcError> {
let command = branch
.service::<dyn dim_agent_runtime::AgentLoop>()?
.compact()?;
Expand Down Expand Up @@ -191,24 +202,31 @@ async fn compact(branch: &Branch, cancel: &CancellationToken) -> Result<Value, R
}
}

async fn usage(branch: &Branch, cancel: CancellationToken) -> Result<Value, RpcError> {
match branch.service::<ContextPreparation>()?.usage(cancel).await {
Ok(usage) => reply(usage),
Err(ContextOpError::NotReady) => Err(RpcError::app(
-32000,
"context_usage_unavailable",
ContextOpError::NotReady.to_string(),
)),
Err(ContextOpError::NotConfigured) => Err(RpcError::app(
-32000,
"context_not_configured",
ContextOpError::NotConfigured.to_string(),
)),
Err(ContextOpError::Model(error)) => Err(RpcError::app(
-32000,
"context_model_failed",
error.to_string(),
)),
Err(ContextOpError::Read(error)) => Err(error.into()),
impl TimelineTree {
pub(crate) async fn context_usage(
&self,
branch_id: &str,
cancel: CancellationToken,
) -> Result<crate::context_preparation::ContextUsage, RpcError> {
let branch = self.get(branch_id)?;
match branch.service::<ContextPreparation>()?.usage(cancel).await {
Ok(usage) => Ok(usage),
Err(ContextOpError::NotReady) => Err(RpcError::app(
-32000,
"context_usage_unavailable",
ContextOpError::NotReady.to_string(),
)),
Err(ContextOpError::NotConfigured) => Err(RpcError::app(
-32000,
"context_not_configured",
ContextOpError::NotConfigured.to_string(),
)),
Err(ContextOpError::Model(error)) => Err(RpcError::app(
-32000,
"context_model_failed",
error.to_string(),
)),
Err(ContextOpError::Read(error)) => Err(error.into()),
}
}
}
78 changes: 43 additions & 35 deletions crates/dim-agent-capabilities/src/input_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod recovery;
use crate::{
host::HostFuture,
methods::{Interruption, MethodCall, MethodDecl, RpcError, SessionMethods, params, reply},
timeline_tree::TreeCommands,
timeline_tree::TimelineTree,
};
use dim_agent_runtime::{
AgentError, Dispatcher, InputSnapshot, Names, Registrations, Result, StateCell, Timeline,
Expand Down Expand Up @@ -207,7 +207,7 @@ pub struct InputQueue {
observable: Arc<StateCell<InputSnapshot>>,
pending_snapshot: Mutex<Option<(u64, usize)>>,
timeline: Arc<Timeline>,
tree: Arc<TreeCommands>,
tree: Arc<TimelineTree>,
branch_id: String,
/// Answers to `input/withdraw` commands by their sequence, until the
/// withdrawal that wrote each one collects it.
Expand All @@ -232,7 +232,7 @@ impl Drop for WithdrawalWaiter<'_> {
impl InputQueue {
/// Commits an input through the branch entry, accepting each submission id once.
pub async fn submit(&self, input: InputMessageData) -> Result<InputRef> {
let event = self.tree.get(&self.branch_id)?.input(input).await?;
let event = self.tree.input(self.branch_id.clone(), input).await?;
Ok(InputRef {
input_id: event.id.clone(),
sequence: event.sequence,
Expand Down Expand Up @@ -365,7 +365,7 @@ pub struct InputQueuePlugin {
queue: Key<InputQueue>,
timeline: Key<Timeline>,
dispatcher: Key<Dispatcher>,
tree: Key<TreeCommands>,
tree: Key<TimelineTree>,
identity: Key<TimelineIdentity>,
}
impl InputQueuePlugin {
Expand Down Expand Up @@ -642,10 +642,42 @@ struct WithdrawParams {
steer: Option<UserInput>,
}

impl TimelineTree {
async fn withdraw_checked(
&self,
branch_id: &str,
command: impl Future<Output = std::result::Result<InputWithdrawData, RpcError>> + Send,
cancel: &CancellationToken,
) -> std::result::Result<WithdrawalAnswer, RpcError> {
let branch = self.get(branch_id)?;
let queue = branch.service::<InputQueue>()?;
let answer = queue.withdraw_checked(command.await?).await?;
if let (Withdrawal::Deleted { sequence }, Some(_)) = &answer {
let publication = branch.publication();
let mut progress = publication.watch();
tokio::select! {
_ = progress.wait_for(
|&(published, closed)| published >= *sequence || closed,
) => {}
_ = cancel.cancelled() =>
return Err(RpcError::interrupted()),
}
if publication.sequence() < *sequence {
return Err(RpcError::app(
-32000,
"publication_unknown",
"committed, but publication was not confirmed; query history after recovery",
));
}
}
Ok(answer)
}
}

/// Serves `session.input.withdraw` for every branch of its Session through
/// the branch's InputQueue, so Rpc names no owning service.
pub struct InputMethodsPlugin {
tree: Key<TreeCommands>,
tree: Key<TimelineTree>,
methods: Key<SessionMethods>,
checks: Key<SubmitChecks>,
}
Expand Down Expand Up @@ -687,14 +719,13 @@ impl DynPlugin for InputMethodsPlugin {
return pending::read(&tree, value, &cancel).await;
}
let p: WithdrawParams = params(value)?;
let branch = tree.get(&p.branch_id)?;
let queue = branch.service::<InputQueue>()?;
let mut checks_warnings = Vec::new();
let command = async {
let mut steer = p.steer.map(|user| InputMessageData {
user: Some(user),
mode: Some(InputMode::Steer),
..Default::default()
});
let mut checks_warnings = Vec::new();
if let Some(input) = &steer {
// The operator's own content is validated before
// the checks run: a check's context must never be
Expand Down Expand Up @@ -734,35 +765,12 @@ impl DynPlugin for InputMethodsPlugin {
}
}
}
let (answer, replacement) = queue
.withdraw_checked(
InputWithdrawData {
input_id: p.input_id,
reason: p.reason,
steer,
},
)
.await?;
Ok(InputWithdrawData {input_id:p.input_id,reason:p.reason,steer})
};
let (answer, replacement) =
tree.withdraw_checked(&p.branch_id, command, &cancel).await?;
let mut result = match answer {
Withdrawal::Deleted { sequence } => {
if replacement.is_some() {
let publication = branch.publication();
let mut progress = publication.watch();
tokio::select! {
_ = progress.wait_for(
|&(published, closed)| published >= sequence || closed,
) => {}
_ = cancel.cancelled() =>
return Err(RpcError::interrupted()),
}
if publication.sequence() < sequence {
return Err(RpcError::app(
-32000,
"publication_unknown",
"committed, but publication was not confirmed; query history after recovery",
));
}
}
serde_json::json!({"status": "deleted", "sequence": sequence})
}
Withdrawal::NotHeld => serde_json::json!({"status": "notHeld"}),
Expand Down
2 changes: 1 addition & 1 deletion crates/dim-agent-capabilities/src/input_queue/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct Params {
}

pub(super) async fn read(
tree: &TreeCommands,
tree: &TimelineTree,
value: Value,
cancel: &CancellationToken,
) -> std::result::Result<Value, RpcError> {
Expand Down
3 changes: 1 addition & 2 deletions crates/dim-agent-capabilities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ fn register_names_in(catalog: &mut dim_agent_runtime::names::ServiceCatalog) {
};
let session = Some(SESSION_GROUP);
register::<timeline_tree::TimelineTree>(catalog, session);
register::<timeline_tree::TreeCommands>(catalog, session);
register::<tool_registry::ToolRegistry>(catalog, session);
catalog.register_shared_instance("toolSourcesView", SESSION_GROUP);
register::<history::HistoryRenderer>(catalog, session);
Expand Down Expand Up @@ -144,7 +143,7 @@ impl PublicService for shell_session::ShellSession {}
impl PublicService for dyn exec_stop::ExecStop {}
impl PublicService for workspace_tools::file_reads::FileReads {}
impl PublicService for timeline_tree::BranchLine {}
impl PublicService for timeline_tree::TreeCommands {}
impl PublicService for timeline_tree::TimelineTree {}
impl PublicService for wait::Wait {}
impl PublicService for skills::SkillsBranch {}
impl PublicService for prompt::Prompt {}
Expand Down
20 changes: 9 additions & 11 deletions crates/dim-agent-capabilities/src/prompt_suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
//! The `prompt-suggestion` Settings source belongs to the App Server
//! ([`PromptSuggestionSettingsHost`]); the part reads it at each decision and
//! stays idle while it is off.
use crate::context_preparation::ContextPreparation;
use crate::history::fold_output_parts;
use crate::host::{
HostError, ModelChunk, ModelConnection, ModelHost, ModelStream, ProviderConnectionResolver,
Expand All @@ -23,7 +22,7 @@ use crate::session_broadcast::{
SessionBroadcast, SessionBroadcastEvent, SessionNotice, notify, session_channel,
};
use crate::settings::{SettingsChanged, settings_changes};
use crate::timeline_tree::TreeCommands;
use crate::timeline_tree::TimelineTree;
use dim_agent_runtime::{
AgentBuilder, CollaborationRole, Feature, Names, SessionConfig, SessionIdentity,
SessionLifecycle,
Expand Down Expand Up @@ -484,15 +483,15 @@ struct Hosts {
model: Arc<ModelHost>,
resolver: Option<Arc<ProviderConnectionResolver>>,
settings: Option<Arc<PromptSuggestionSettingsHost>>,
tree: Arc<TreeCommands>,
tree: Arc<TimelineTree>,
}

struct PromptSuggestionPlugin {
identity: Key<SessionIdentity>,
config: Key<SessionConfig>,
lifecycle: Key<SessionLifecycle>,
methods: Key<SessionMethods>,
tree: Key<TreeCommands>,
tree: Key<TimelineTree>,
model: Key<ModelHost>,
resolver: Option<Key<ProviderConnectionResolver>>,
settings: Option<Key<PromptSuggestionSettingsHost>>,
Expand Down Expand Up @@ -1100,13 +1099,12 @@ impl Part {
}

async fn compaction_due(&self, max_chars: u32, cancel: CancellationToken) -> bool {
let Ok(branch) = self.hosts.tree.get(DEFAULT_BRANCH_ID) else {
return false;
};
let Ok(preparation) = branch.service::<ContextPreparation>() else {
return false;
};
let Ok(usage) = preparation.usage(cancel).await else {
let Ok(usage) = self
.hosts
.tree
.context_usage(DEFAULT_BRANCH_ID, cancel)
.await
else {
return false;
};
compaction_due(
Expand Down
6 changes: 3 additions & 3 deletions crates/dim-agent-capabilities/src/recall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use crate::{
context_policy::check_cancel,
host::{HostError, HostFuture, ToolExecutionContext},
timeline_tree::TreeCommands,
timeline_tree::TimelineTree,
tool_registry::{ToolConcurrency, ToolContribution, ToolHandler, ToolRegistry, definition},
};
use dim_agent_runtime::{
Expand Down Expand Up @@ -91,7 +91,7 @@ fn recall_definition() -> ToolDefinition {
}

pub struct RecallPlugin {
tree: Key<TreeCommands>,
tree: Key<TimelineTree>,
tools: Key<ToolRegistry>,
}

Expand Down Expand Up @@ -127,7 +127,7 @@ impl DynPlugin for RecallPlugin {
}
}

struct RecallTool(Arc<TreeCommands>);
struct RecallTool(Arc<TimelineTree>);

impl RecallTool {
async fn run(
Expand Down
6 changes: 3 additions & 3 deletions crates/dim-agent-capabilities/src/recall/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ fn text_candidates(words: &[String]) -> Option<QueryFilter> {
}

pub(super) async fn run(
tree: &TreeCommands,
tree: &TimelineTree,
branch: &Branch,
branch_id: &str,
arguments: &Arguments,
Expand Down Expand Up @@ -875,7 +875,7 @@ fn mark_current(
}

pub(super) async fn open(
tree: &TreeCommands,
tree: &TimelineTree,
branch: &Branch,
branch_id: &str,
head: u64,
Expand Down Expand Up @@ -1097,7 +1097,7 @@ impl Search<'_> {
}

pub(super) async fn index(
tree: &TreeCommands,
tree: &TimelineTree,
branch: &Branch,
branch_id: &str,
calling_turn: &str,
Expand Down
Loading