From 594f02326ea184b158459a78c297658b1ee131d5 Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 12:15:59 +0800 Subject: [PATCH 01/10] Plan migrate special Settings sources and trusted callers From 63dd2ddc6f46f723933ccc0f4eb7216b0d430583 Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 14:39:44 +0800 Subject: [PATCH 02/10] Bind custom settings documents to their owner and migrate typed consumers --- crates/dim-agent-scheduler/src/methods.rs | 10 +- crates/dim-app-server/src/agents.rs | 8 +- .../src/collaboration_model_policy.rs | 8 +- crates/dim-app-server/src/permission_rules.rs | 8 +- crates/dim-app-server/src/settings.rs | 134 +- .../dim-app-server/src/settings/declared.rs | 81 +- .../dim-app-server/src/settings/document.rs | 148 + crates/dim-app-server/src/settings/native.rs | 18 +- .../dim-app-server/src/skills_management.rs | 28 +- .../tests/transport_flow/settings_methods.rs | 18 + crates/dim-modality/src/engine.rs | 6 +- crates/dim-modality/src/lib.rs | 12 +- .../generated/app-server/services.json | 36 +- .../generated/app-server/services.md | 12 +- .../generated/app-server/services.mmd | 12 +- .../rust-agent/generated/catalog.md | 2 +- .../rust-agent/generated/modules.json | 141 +- .../rust-agent/generated/modules.mmd | 4792 +++++++++-------- docs/design/appserver/settings-service.md | 4 +- .../contracts/resource-owner-operations.md | 2 +- docs/zh/design/appserver/settings-service.md | 4 +- npm/plugin.d.ts | 8 + runtime/fixtures/settings-owner.ts | 30 +- 23 files changed, 2988 insertions(+), 2534 deletions(-) create mode 100644 crates/dim-app-server/src/settings/document.rs diff --git a/crates/dim-agent-scheduler/src/methods.rs b/crates/dim-agent-scheduler/src/methods.rs index b02203195b..e25d685e3c 100644 --- a/crates/dim-agent-scheduler/src/methods.rs +++ b/crates/dim-agent-scheduler/src/methods.rs @@ -19,7 +19,7 @@ use dim_app_server::{ ProcessActivity, methods::ManagementMethods, plugin_files::PluginFileTransactions, - settings::{BusinessDocument, SettingsError, SettingsService}, + settings::{BusinessDocument, RegisteredDocument, Settings, SettingsError}, }; use jiff::{SignedDuration, Timestamp}; use rutis::Ctx; @@ -43,7 +43,7 @@ pub(crate) type DeliveryHolds = pub struct SchedulerPlugin { activity: Key, pub(crate) deliveries: DeliveryHolds, - settings: Key, + settings: Key, files: Key, methods: Key, sessions: Key, @@ -113,7 +113,7 @@ impl DynPlugin for SchedulerPlugin { let files = ctx.require_at(&self.files)?; let methods = ctx.require_at(&self.methods)?; let sessions = ctx.require_at(&self.sessions)?; - settings.register::(ctx)?; + let settings = settings.register_document::(ctx)?; let shared = Arc::new(Shared { ctx: ctx.clone(), activity, @@ -352,7 +352,7 @@ pub(crate) struct Shared { pub(crate) clock: Arc, pub(crate) deliveries: DeliveryHolds, pub(crate) sessions: Arc, - pub(crate) settings: Arc, + pub(crate) settings: Arc>, pub(crate) files: Arc, /// Serializes retention passes, so a pass never deletes what another reads. pub(crate) pruning: tokio::sync::Mutex<()>, @@ -527,7 +527,7 @@ pub(crate) async fn read_document( > { shared .settings - .read::(SettingsScope::User, cancel) + .read(SettingsScope::User, cancel) .await .map_err(read_failure) } diff --git a/crates/dim-app-server/src/agents.rs b/crates/dim-app-server/src/agents.rs index 4edfb12ea9..266ab7ddf1 100644 --- a/crates/dim-app-server/src/agents.rs +++ b/crates/dim-app-server/src/agents.rs @@ -1,7 +1,7 @@ use crate::{ ProcessActivity, ProcessHold, ServerConfig, protocol::{AgentInfo, CreateWorktree, SessionOrigin}, - settings::SettingsService, + settings::Settings, storage::{PreparedWorktree, SessionMetadataService, SessionStore, SqliteStorage, Store}, worktrees::{CreatedWorktree, ManagedWorktrees, WorktreeError}, }; @@ -393,7 +393,7 @@ pub struct AgentIndex { records: Option>, session_store: Option>, session_metadata: Option>, - settings: Option>, + settings: Option>, stopping: CancellationToken, /// Notified once an `idle` call on this generation is admitted and /// waiting on its branch. Feature `testing` only. @@ -2142,7 +2142,7 @@ pub(crate) struct AgentsPlugin { /// Native storage only with a database. stored: Option, /// Settings only with local execution. - settings: Option>, + settings: Option>, loader: Key, directory: Key, activity: Key, @@ -2163,7 +2163,7 @@ impl AgentsPlugin { .transpose()?, settings: config .local_execution() - .then(|| names.key::()) + .then(|| names.key::()) .transpose()?, loader: names.key()?, directory: Key::of(), diff --git a/crates/dim-app-server/src/collaboration_model_policy.rs b/crates/dim-app-server/src/collaboration_model_policy.rs index e6016c4c01..45d7456050 100644 --- a/crates/dim-app-server/src/collaboration_model_policy.rs +++ b/crates/dim-app-server/src/collaboration_model_policy.rs @@ -4,7 +4,7 @@ use crate::{ methods::ManagementMethods, protocol::Empty, - settings::{BusinessDocument, SettingsError, SettingsScope, SettingsService}, + settings::{BusinessDocument, Settings, SettingsError, SettingsScope}, }; use dim_agent_capabilities::methods::{ Interruption, MethodCall, MethodDecl, RpcError, params, reply, @@ -95,7 +95,7 @@ fn error(error: SettingsError) -> RpcError { /// Process owner of the `collaboration` source and its management methods, /// apart from Collaboration so it reloads without unloading Rpc. pub struct CollaborationModelPolicyPlugin { - settings: Key, + settings: Key, methods: Key, } impl CollaborationModelPolicyPlugin { @@ -117,7 +117,7 @@ impl DynPlugin for CollaborationModelPolicyPlugin { Box::pin(async move { let settings = ctx.require_at(&self.settings)?; let methods = ctx.require_at(&self.methods)?; - settings.register::(ctx)?; + let settings = settings.register_document::(ctx)?; methods.register( ctx, "collaboration", @@ -146,7 +146,7 @@ impl DynPlugin for CollaborationModelPolicyPlugin { "collaboration.model_policy" => { let _: Empty = params(value)?; let snapshot = settings - .read::(SettingsScope::User, &stopping) + .read(SettingsScope::User, &stopping) .await .map_err(error)?; reply(PolicyView { diff --git a/crates/dim-app-server/src/permission_rules.rs b/crates/dim-app-server/src/permission_rules.rs index 2b69b0eedf..8ae02260ca 100644 --- a/crates/dim-app-server/src/permission_rules.rs +++ b/crates/dim-app-server/src/permission_rules.rs @@ -3,7 +3,7 @@ use crate::{ methods::ManagementMethods, protocol::Empty, - settings::{BusinessDocument, SettingsError, SettingsScope, SettingsService}, + settings::{BusinessDocument, Settings, SettingsError, SettingsScope, SettingsService}, }; use dim_agent_capabilities::{ host::{HostError, HostFuture}, @@ -138,7 +138,7 @@ fn error(error: SettingsError) -> RpcError { /// Process owner of the `permission` source and its management methods. pub struct PermissionRulesPlugin { - settings: Key, + settings: Key, methods: Key, } impl PermissionRulesPlugin { @@ -160,7 +160,7 @@ impl DynPlugin for PermissionRulesPlugin { Box::pin(async move { let settings = ctx.require_at(&self.settings)?; let methods = ctx.require_at(&self.methods)?; - settings.register::(ctx)?; + let settings = settings.register_document::(ctx)?; methods.register( ctx, "permission", @@ -182,7 +182,7 @@ impl DynPlugin for PermissionRulesPlugin { "permission.rules" => { let _: Empty = params(value)?; let snapshot = settings - .read::(SettingsScope::User, &stopping) + .read(SettingsScope::User, &stopping) .await .map_err(error)?; reply(RulesView { diff --git a/crates/dim-app-server/src/settings.rs b/crates/dim-app-server/src/settings.rs index b34fcc233f..e2986d94c4 100644 --- a/crates/dim-app-server/src/settings.rs +++ b/crates/dim-app-server/src/settings.rs @@ -2,6 +2,7 @@ //! `BusinessDocument` sources and JSON Schema sources, each registered by //! the plugin that owns it (settings-service design). mod declared; +mod document; mod native; pub mod workflow_files; pub use workflow_files::WorkflowFiles; @@ -9,7 +10,7 @@ pub(crate) use workflow_files::WorkflowPackages; use crate::storage::SqliteStorage; use dim_agent_capabilities::file_storage::{FilePath, FileStorage, FileStorageError}; -use dim_agent_runtime::{Names, Registrations}; +use dim_agent_runtime::{Names, Registration, Registrations}; use rutis::host::{BoxFuture, CtxHost, DynPlugin, Effect, ErrorKind, Key, TypeKey}; use rutis::{Ctx, Event}; use serde::{Deserialize, Serialize, de::DeserializeOwned}; @@ -19,7 +20,7 @@ use std::{ collections::BTreeMap, marker::PhantomData, path::{Path, PathBuf}, - sync::{Arc, Mutex}, + sync::{Arc, Mutex, Weak}, }; use tokio_util::{sync::CancellationToken, task::TaskTracker}; @@ -147,10 +148,19 @@ pub struct SettingsSnapshot { /// How one source's documents cross the persistence boundary, so Rust and /// declared sources share the file and native paths, keyed by source name. trait Format: Send + Sync + 'static { - type Document: Serialize + Send + 'static; + type Document: Serialize + Send + Sync + 'static; fn source(&self) -> &str; /// Decodes and checks a persisted document; `None` is a missing file. - fn decode(&self, bytes: Option<&[u8]>) -> Result; + fn decode<'a>( + &'a self, + bytes: Option<&'a [u8]>, + cancel: &'a CancellationToken, + ) -> BoxFuture<'a, Result>; + fn validate<'a>( + &'a self, + document: &'a Self::Document, + cancel: &'a CancellationToken, + ) -> BoxFuture<'a, Result<()>>; } struct Typed(PhantomData D>); impl Format for Typed { @@ -158,13 +168,26 @@ impl Format for Typed { fn source(&self) -> &str { D::NAMESPACE } - fn decode(&self, bytes: Option<&[u8]>) -> Result { - let document: D = match bytes { - Some(bytes) => D::decode(bytes)?, - None => D::default(), - }; - document.validate()?; - Ok(document) + fn validate<'a>( + &'a self, + document: &'a D, + _: &'a CancellationToken, + ) -> BoxFuture<'a, Result<()>> { + Box::pin(async move { document.validate() }) + } + fn decode<'a>( + &'a self, + bytes: Option<&'a [u8]>, + _: &'a CancellationToken, + ) -> BoxFuture<'a, Result> { + Box::pin(async move { + let document: D = match bytes { + Some(bytes) => D::decode(bytes)?, + None => D::default(), + }; + document.validate()?; + Ok(document) + }) } } fn typed() -> Arc> { @@ -181,9 +204,66 @@ struct Source { } enum Kind { Rust(TypeId), + Custom, Declared(Arc), } +/// A custom source registered by one plugin generation. +pub struct RegisteredDocument { + settings: Arc, + registration: Weak>, + format: Arc>, +} + +impl RegisteredDocument { + fn path(&self, scope: SettingsScope) -> Result { + let entry = self + .settings + .sources + .get(self.format.source()) + .ok_or(SettingsError::UnknownSource)?; + if !self.registration.ptr_eq(&Arc::downgrade(&entry)) { + return Err(SettingsError::UnknownSource); + } + self.settings.locate( + &entry.value.user_file, + entry.value.project_file.as_deref(), + scope, + ) + } + pub async fn read( + &self, + scope: SettingsScope, + cancel: &CancellationToken, + ) -> Result> { + self.settings.check_open(cancel)?; + self.settings + .read_source(self.format.clone(), self.path(scope)?, scope, cancel) + .await + } + pub async fn update( + &self, + scope: SettingsScope, + expected: &str, + document: D, + cancel: &CancellationToken, + ) -> Result> { + self.format.validate(&document, cancel).await?; + self.settings.check_open(cancel)?; + self.settings + .replace( + self.format.clone(), + self.path(scope)?, + scope, + expected, + document, + |_, _| Ok(()), + cancel, + ) + .await + } +} + pub struct SettingsService { files: Arc, database: Option>, @@ -205,6 +285,12 @@ impl SettingsService { /// Registers the Rust source `D` for as long as the plugin that owns /// `ctx` is loaded. A source name or file registered already fails. pub fn register(&self, ctx: &Ctx) -> rutis::Result<()> { + self.register_typed::(ctx).map(drop) + } + fn register_typed( + &self, + ctx: &Ctx, + ) -> rutis::Result>> { let failed = |error: SettingsError| registration_failed(D::NAMESPACE, error.to_string()); validate_namespace(D::NAMESPACE).map_err(failed)?; validate_file(D::USER_FILE).map_err(failed)?; @@ -244,6 +330,7 @@ impl SettingsService { kind: Kind::Declared(Arc::new(declared)), }, ) + .map(drop) } /// The declarations of every registered JSON Schema source, by source /// name, for the client's `settings.sources` listing. @@ -253,12 +340,17 @@ impl SettingsService { .iter() .filter_map(|registered| match ®istered.value.kind { Kind::Declared(declared) => Some(declared.declaration().clone()), - Kind::Rust(_) => None, + Kind::Rust(_) | Kind::Custom => None, }) .collect() } /// Two sources sharing a name or a file would share a persisted document. - fn insert(&self, ctx: &Ctx, name: &str, source: Source) -> rutis::Result<()> { + fn insert( + &self, + ctx: &Ctx, + name: &str, + source: Source, + ) -> rutis::Result>> { let _guard = self.registering.lock().unwrap(); let taken = self.sources.get(name).is_some() || self.sources.all().iter().any(|other| { @@ -272,8 +364,7 @@ impl SettingsService { "its name or file is registered already".into(), )); } - self.sources.register(ctx, name, source)?; - Ok(()) + self.sources.register(ctx, name, source) } pub async fn authorize_project( self: &Arc, @@ -409,7 +500,7 @@ impl SettingsService { ) .await } - async fn read_source( + async fn read_source( &self, format: Arc, path: FilePath, @@ -422,7 +513,7 @@ impl SettingsService { .await .map(|(_, snapshot)| snapshot); } - snapshot(&*format, self.files.read(&path, cancel).await) + snapshot(&*format, self.files.read(&path, cancel).await, cancel).await } /// CAS on the revision. `check` sees the current and the new document /// under the file lease or at the expected native revision. @@ -430,7 +521,7 @@ impl SettingsService { clippy::too_many_arguments, reason = "one parameter per part of the compare-and-set write" )] - async fn replace( + async fn replace( self: &Arc, format: Arc, path: FilePath, @@ -453,7 +544,7 @@ impl SettingsService { .await; } let mut lease = owner.lease(&path, &cancel).await?; - let current = snapshot(&*format, lease.read(&cancel).await)?; + let current = snapshot(&*format, lease.read(&cancel).await, &cancel).await?; if current.revision != expected { return Err(SettingsError::Conflict); } @@ -538,9 +629,10 @@ fn revision(bytes: Option<&[u8]>) -> String { |bytes| format!("{:x}", Sha256::digest(bytes)), ) } -fn snapshot( +async fn snapshot( format: &F, read: std::result::Result, FileStorageError>, + cancel: &CancellationToken, ) -> Result> { let bytes = match read { Ok(bytes) => Some(bytes), @@ -548,7 +640,7 @@ fn snapshot( Err(error) => return Err(error.into()), }; Ok(SettingsSnapshot { - document: format.decode(bytes.as_deref())?, + document: format.decode(bytes.as_deref(), cancel).await?, revision: revision(bytes.as_deref()), }) } diff --git a/crates/dim-app-server/src/settings/declared.rs b/crates/dim-app-server/src/settings/declared.rs index ee06d08a07..fb9010e549 100644 --- a/crates/dim-app-server/src/settings/declared.rs +++ b/crates/dim-app-server/src/settings/declared.rs @@ -100,14 +100,31 @@ impl Format for Declared { fn source(&self) -> &str { &self.declaration.source } - fn decode(&self, bytes: Option<&[u8]>) -> Result { - let document = match bytes { - Some(bytes) => serde_json::from_slice(bytes) - .map_err(|_| SettingsError::Invalid("invalid settings document"))?, - None => json!({}), - }; - self.prepare(document).map_err(|_| { - SettingsError::Invalid("persisted settings document does not match its schema") + fn validate<'a>( + &'a self, + document: &'a Value, + _: &'a CancellationToken, + ) -> BoxFuture<'a, Result<()>> { + Box::pin(async move { + self.prepare(document.clone()) + .map(drop) + .map_err(SettingsError::Document) + }) + } + fn decode<'a>( + &'a self, + bytes: Option<&'a [u8]>, + _: &'a CancellationToken, + ) -> BoxFuture<'a, Result> { + Box::pin(async move { + let document = match bytes { + Some(bytes) => serde_json::from_slice(bytes) + .map_err(|_| SettingsError::Invalid("invalid settings document"))?, + None => json!({}), + }; + self.prepare(document).map_err(|_| { + SettingsError::Invalid("persisted settings document does not match its schema") + }) }) } } @@ -187,7 +204,7 @@ impl SettingsService { .get(source) .and_then(|registered| match ®istered.value.kind { Kind::Declared(declared) => Some(declared.clone()), - Kind::Rust(_) => None, + Kind::Rust(_) | Kind::Custom => None, }) .ok_or(SettingsError::UnknownSource)?; if let SettingsScope::Project(root) = scope { @@ -268,6 +285,11 @@ pub(crate) struct Update { #[derive(Deserialize)] #[serde(deny_unknown_fields)] struct Projects {} +#[derive(Deserialize)] +#[serde(deny_unknown_fields)] +struct AuthorizeProject { + cwd: PathBuf, +} #[derive(Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -296,7 +318,7 @@ impl SettingsError { } } /// `{ok: true, value}` or `{ok: false, error: {code, message}}`, as `sessions`. -fn envelope(result: Result) -> RpcValue { +pub(super) fn envelope(result: Result) -> RpcValue { match result { Ok(value) => json!({"ok": true, "value": value}), Err(error) => { @@ -319,6 +341,19 @@ fn request(args: RpcValue) -> std::result::Result /// calling row unloads; each source has one owner (AGENTS.md rule 11). pub struct Settings(Arc); impl Settings { + /// Registers a source with its existing decoder, defaults and write validation. + pub fn register_document( + &self, + owner: &Ctx, + ) -> rutis::Result>> { + let registration = self.0.register_typed::(owner)?; + Ok(Arc::new(RegisteredDocument { + settings: self.0.clone(), + registration: Arc::downgrade(®istration), + format: typed::(), + })) + } + /// The declarations of the JSON Schema sources the row `instance_id` /// registered and still holds, by source name. pub fn declared_by(&self, instance_id: &str) -> Vec { @@ -329,7 +364,7 @@ impl Settings { .filter(|registered| registered.value.owner == instance_id) .filter_map(|registered| match ®istered.value.kind { Kind::Declared(declared) => Some(declared.declaration().clone()), - Kind::Rust(_) => None, + Kind::Rust(_) | Kind::Custom => None, }) .collect() } @@ -362,6 +397,15 @@ impl Settings { .await } + /// Admits a project root and publishes its existing authorization notice. + pub async fn authorize_project( + &self, + cwd: PathBuf, + cancel: &CancellationToken, + ) -> Result { + self.0.authorize_project(cwd, cancel).await + } + /// Lists authorized project scopes. pub fn projects(&self) -> Vec { self.0 @@ -378,14 +422,14 @@ impl Settings { impl HostDispatch for Settings { fn methods(&self) -> Option { Some( - json!({"register": "async", "read": "async", "update": "async", "projects": "sync", "declaredBy": "sync"}), + json!({"registerDocument": "async", "register": "async", "read": "async", "update": "async", "projects": "sync", "authorizeProject": "async", "declaredBy": "sync"}), ) } fn invoke(&self, method: &str, args: RpcValue) -> Reply { let service = Self(self.0.clone()); let cancel = CancellationToken::new(); match method { - "register" => { + "register" | "registerDocument" => { let caller = rutis_bridge::session::caller_row() .map(|row| row.ctx().clone()) .ok_or_else(|| { @@ -394,6 +438,10 @@ impl HostDispatch for Settings { .into(), ) })?; + if method == "registerDocument" { + let result = super::document::register(service.0, &caller, args); + return Ok(RpcValue::future(async move { result })); + } let registered = request(args).and_then(|declaration| { service .register(&caller, declaration) @@ -406,6 +454,13 @@ impl HostDispatch for Settings { let DeclaredBy { instance_id } = request(args)?; Ok(json!(service.declared_by(&instance_id)).into()) } + "authorizeProject" => { + let AuthorizeProject { cwd } = request(args)?; + Ok(RpcValue::future(async move { + let _guard = cancel.clone().drop_guard(); + Ok(envelope(service.authorize_project(cwd, &cancel).await)) + })) + } "projects" => { let Projects {} = request(args)?; let projects = service.projects(); diff --git a/crates/dim-app-server/src/settings/document.rs b/crates/dim-app-server/src/settings/document.rs new file mode 100644 index 0000000000..b25372fdee --- /dev/null +++ b/crates/dim-app-server/src/settings/document.rs @@ -0,0 +1,148 @@ +use super::*; +use rutis_bridge::session::{Error, Reference, Reply, Value, settle}; +use serde_json::Value as Json; + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +struct Declaration { + source: String, + user_file: String, + project_file: Option, +} + +struct Codec { + name: String, + methods: Reference, + owner: CancellationToken, + service: CancellationToken, +} + +impl Codec { + async fn call( + &self, + method: &str, + argument: Value, + cancel: &CancellationToken, + ) -> Result { + tokio::select! { + biased; + _ = self.owner.cancelled() => Err(SettingsError::UnknownSource), + _ = self.service.cancelled() => Err(SettingsError::Closed), + _ = cancel.cancelled() => Err(SettingsError::Cancelled), + result = async { settle(self.methods.call_method_async(method, Value::List(vec![argument])).await?).await } => + result.map_err(|error| SettingsError::Document(error.to_string())), + } + } +} + +impl Format for Codec { + type Document = Json; + fn source(&self) -> &str { + &self.name + } + fn decode<'a>( + &'a self, + bytes: Option<&'a [u8]>, + cancel: &'a CancellationToken, + ) -> BoxFuture<'a, Result> { + Box::pin(async move { + let input = bytes.map_or(Value::Data(Json::Null), |bytes| { + Value::Bytes(bytes.to_vec()) + }); + self.call("decode", input, cancel) + .await? + .json() + .map_err(|error| SettingsError::Document(error.to_string())) + }) + } + fn validate<'a>( + &'a self, + document: &'a Json, + cancel: &'a CancellationToken, + ) -> BoxFuture<'a, Result<()>> { + Box::pin(async move { + self.call("validate", document.clone().into(), cancel) + .await + .map(drop) + }) + } +} + +pub(super) fn register(settings: Arc, caller: &Ctx, args: Value) -> Reply { + let invalid = || { + Error::Value( + "expected a settings source declaration and a codec with decode and validate functions" + .into(), + ) + }; + let [declaration, Value::Reference(methods)]: [Value; 2] = + args.list()?.try_into().map_err(|_| invalid())? + else { + return Err(invalid()); + }; + let declaration: Declaration = + serde_json::from_value(declaration.json()?).map_err(|_| invalid())?; + if !methods.is_object() { + return Err(invalid()); + } + let format = Codec { + name: declaration.source.clone(), + methods, + owner: caller.cancellation_token(), + service: settings.stopping.clone(), + }; + let checked = validate_namespace(&declaration.source) + .and_then(|()| validate_file(&declaration.user_file)) + .and_then(|()| { + declaration + .project_file + .as_deref() + .map_or(Ok(()), validate_file) + }); + checked.map_err(|error| Error::Value(error.to_string()))?; + let registration = settings + .insert( + caller, + &declaration.source, + Source { + owner: caller.instance().to_string(), + user_file: declaration.user_file, + project_file: declaration.project_file, + kind: Kind::Custom, + }, + ) + .map_err(|error| Error::Value(error.to_string()))?; + let source = Arc::new(RegisteredDocument { + settings, + registration: Arc::downgrade(®istration), + format: Arc::new(format), + }); + let read = source.clone(); + let read = Value::callback(move |args| { + let (scope,): (SettingsScope,) = serde_json::from_value(args.json()?) + .map_err(|_| Error::Value("expected a settings scope".into()))?; + let read = read.clone(); + Ok(Value::future(async move { + let cancel = CancellationToken::new(); + let _guard = cancel.clone().drop_guard(); + Ok(declared::envelope(read.read(scope, &cancel).await)) + })) + }); + let update = Value::callback(move |args| { + let (scope, revision, document): (SettingsScope, String, Json) = + serde_json::from_value(args.json()?).map_err(|_| { + Error::Value("expected scope, expectedRevision and document".into()) + })?; + let source = source.clone(); + Ok(Value::future(async move { + let cancel = CancellationToken::new(); + let _guard = cancel.clone().drop_guard(); + Ok(declared::envelope( + source.update(scope, &revision, document, &cancel).await, + )) + })) + }); + Ok(Value::Record( + [("read".into(), read), ("update".into(), update)].into(), + )) +} diff --git a/crates/dim-app-server/src/settings/native.rs b/crates/dim-app-server/src/settings/native.rs index 1c268fc165..6b24a711d2 100644 --- a/crates/dim-app-server/src/settings/native.rs +++ b/crates/dim-app-server/src/settings/native.rs @@ -14,9 +14,10 @@ fn write_error(error: dim_agent_runtime::AgentError) -> SettingsError { } } -fn decode( +async fn decode( format: &F, row: UserDocument, + cancel: &CancellationToken, ) -> Result<(i64, SettingsSnapshot)> { if row.version <= 0 { return Err(SettingsError::Invalid( @@ -26,13 +27,13 @@ fn decode( Ok(( row.version, SettingsSnapshot { - document: format.decode(Some(row.document.as_bytes()))?, + document: format.decode(Some(row.document.as_bytes()), cancel).await?, revision: token(format.source(), row.version), }, )) } impl SettingsService { - pub(super) async fn native_read( + pub(super) async fn native_read( &self, format: Arc, path: FilePath, @@ -55,9 +56,10 @@ impl SettingsService { .await .map_err(|_| SettingsError::Persistence)? { - return decode(&*format, row); + return decode(&*format, row, &cancel).await; } - let imported = snapshot(&*format, files.read(&path, &cancel).await)?; + let imported = + snapshot(&*format, files.read(&path, &cancel).await, &cancel).await?; let body = serde_json::to_string(&imported.document) .map_err(|_| SettingsError::Invalid("cannot encode settings"))?; let row = db @@ -67,17 +69,17 @@ impl SettingsService { document: body, imported_revision: imported.revision, }, - cancel, + cancel.clone(), stopping, ) .await .map_err(write_error)?; - decode(&*format, row) + decode(&*format, row, &cancel).await }) }; task.await? } - pub(super) async fn native_replace( + pub(super) async fn native_replace( self: &Arc, format: Arc, path: FilePath, diff --git a/crates/dim-app-server/src/skills_management.rs b/crates/dim-app-server/src/skills_management.rs index 30cde4c5b5..533047430f 100644 --- a/crates/dim-app-server/src/skills_management.rs +++ b/crates/dim-app-server/src/skills_management.rs @@ -7,7 +7,7 @@ use crate::{ acquire::{self, Staging}, }, protocol::{canonical_cwd, optional_non_null}, - settings::{BusinessDocument, SettingsError, SettingsScope, SettingsService}, + settings::{BusinessDocument, RegisteredDocument, Settings, SettingsError, SettingsScope}, }; use dim_agent_capabilities::methods::{ Interruption, MethodCall, MethodDecl, RpcError, params, reply, @@ -107,7 +107,7 @@ impl BusinessDocument for SkillDocument { /// Adapts the owner's business document to the reusable Skill catalog port. /// Settings announces its writes; the catalog listens to them itself. struct SkillStorage { - settings: Arc, + settings: Arc>, } impl SkillSettings for SkillStorage { fn skills( @@ -115,10 +115,7 @@ impl SkillSettings for SkillStorage { cancel: CancellationToken, ) -> BoxFuture<'_, Result> { Box::pin(async move { - let snapshot = self - .settings - .read::(SettingsScope::User, &cancel) - .await?; + let snapshot = self.settings.read(SettingsScope::User, &cancel).await?; Ok(SkillSettingsSnapshot { version: snapshot.revision, disabled: snapshot.document.disabled_skill_ids.into_iter().collect(), @@ -138,10 +135,7 @@ impl SkillSettings for SkillStorage { if id.trim().is_empty() { return Err(SkillSettingsError::Invalid("empty Skill id".into())); } - let current = self - .settings - .read::(SettingsScope::User, &cancel) - .await?; + let current = self.settings.read(SettingsScope::User, &cancel).await?; if current.revision != expected { return Err(SkillSettingsError::Conflict); } @@ -188,10 +182,7 @@ impl SkillStorage { cancel: CancellationToken, ) -> Result { loop { - let current = self - .settings - .read::(SettingsScope::User, &cancel) - .await?; + let current = self.settings.read(SettingsScope::User, &cancel).await?; let mut document = current.document; let unchanged = match &root { Some(root) => document.plugin_skills.get(&plugin) == Some(root), @@ -223,10 +214,7 @@ impl SkillStorage { cancel: CancellationToken, ) -> Result { loop { - let current = self - .settings - .read::(SettingsScope::User, &cancel) - .await?; + let current = self.settings.read(SettingsScope::User, &cancel).await?; let mut document = current.document; let unchanged = match &installation { Some(installation) => document.installations.get(&id) == Some(installation), @@ -597,7 +585,7 @@ fn recorded(source: &SkillInstallSource) -> SourceParams { pub struct SkillsCatalogPlugin { platform: Key, - settings: Key, + settings: Key, methods: Key, parts: Key, } @@ -631,7 +619,7 @@ impl DynPlugin for SkillsCatalogPlugin { let parts = ctx.require_at(&self.parts)?; let home = platform.home.clone(); clean_staging(&home); - settings.register::(ctx)?; + let settings = settings.register_document::(ctx)?; let settings = Arc::new(SkillSettingsHost(Arc::new(SkillStorage { settings }))); let catalog = dim_agent_capabilities::skills::SkillsCatalogPlugin::mount( ctx, diff --git a/crates/dim-app-server/tests/transport_flow/settings_methods.rs b/crates/dim-app-server/tests/transport_flow/settings_methods.rs index 5e02c33647..cc6edcb886 100644 --- a/crates/dim-app-server/tests/transport_flow/settings_methods.rs +++ b/crates/dim-app-server/tests/transport_flow/settings_methods.rs @@ -225,6 +225,24 @@ async fn node_settings_typescript_owner_reads_and_writes() { let created = client.rpc("session.create", create(json!([]))).await; assert_ok(&created); let session = created["result"]["sessionId"].as_str().unwrap().to_owned(); + let custom = owner(&mut client, &session, "custom_read", json!({})).await; + assert_eq!(custom["value"]["document"], json!({"count":3}), "{custom}"); + let revision = &custom["value"]["revision"]; + let update = |count| json!({"expectedRevision":revision, "count":count}); + let rejected = owner(&mut client, &session, "custom_update", update(-1)).await; + assert_eq!(rejected["error"]["code"], "invalid_document", "{rejected}"); + let written = owner(&mut client, &session, "custom_update", update(6)).await; + assert_eq!( + written["value"]["document"], + json!({"count":6}), + "{written}" + ); + assert_eq!( + owner(&mut client, &session, "custom_read", json!({})).await, + written + ); + let stale = owner(&mut client, &session, "custom_update", update(5)).await; + assert_eq!(stale["error"]["code"], "conflict", "{stale}"); let user = json!({"source":"example","scope":"user"}); let mut changes = log.0.subscribe(); diff --git a/crates/dim-modality/src/engine.rs b/crates/dim-modality/src/engine.rs index 1e2e41a7f4..a2148405c4 100644 --- a/crates/dim-modality/src/engine.rs +++ b/crates/dim-modality/src/engine.rs @@ -28,7 +28,7 @@ use dim_agent_capabilities::host_platform::{ use dim_agent_capabilities::methods::{Progress, RpcError}; use dim_agent_types::ModelId; use dim_app_server::plugin_files::PluginFileTransactions; -use dim_app_server::settings::SettingsService; +use dim_app_server::settings::RegisteredDocument; use jiff::{SignedDuration, Timestamp}; use rutis::Ctx; use rutis::host::{CtxHost, Key}; @@ -466,7 +466,7 @@ pub struct TaskResultReply { /// running tasks read. pub(crate) struct Shared { pub(crate) files: Arc, - pub(crate) settings: Arc, + pub(crate) settings: Arc>, pub(crate) selection: Arc, pub(crate) selectable: Arc, pub(crate) ctx: Ctx, @@ -491,7 +491,7 @@ impl Shared { )] pub(crate) fn new( files: Arc, - settings: Arc, + settings: Arc>, selection: Arc, selectable: Arc, ctx: Ctx, diff --git a/crates/dim-modality/src/lib.rs b/crates/dim-modality/src/lib.rs index 8102f7d0fb..f8b066711f 100644 --- a/crates/dim-modality/src/lib.rs +++ b/crates/dim-modality/src/lib.rs @@ -52,7 +52,7 @@ use dim_app_server::{ methods::ManagementMethods, plugin_files::PluginFileTransactions, protocol::Empty, - settings::{BusinessDocument, SettingsError, SettingsScope, SettingsService}, + settings::{BusinessDocument, RegisteredDocument, Settings, SettingsError, SettingsScope}, }; pub use engine::{ ArtifactHook, Clock, DEFAULT_LIST_LIMIT, MAX_INLINE_BYTES, MAX_LIST_LIMIT, MAX_RESULT_BYTES, @@ -1046,7 +1046,7 @@ pub(crate) enum OcrLookup { } pub(crate) async fn evaluate( - settings: &SettingsService, + settings: &RegisteredDocument, selectable: &SelectableModelsHost, selection: &ModelSelectionHost, ctx: &Ctx, @@ -1055,7 +1055,7 @@ pub(crate) async fn evaluate( ocr: OcrLookup, ) -> Result<(String, Evaluation), RpcError> { let snapshot = settings - .read::(SettingsScope::User, cancel) + .read(SettingsScope::User, cancel) .await .map_err(settings_error)?; let selectable_models = selectable @@ -1196,7 +1196,7 @@ fn selection_refusal( /// Process owner of the `modality` Settings source and the `modality.*` /// management namespace (Modality §1, A.3). pub struct ModalityPlugin { - settings: Key, + settings: Key, methods: Key, selection: Key, selectable: Key, @@ -1235,7 +1235,7 @@ impl DynPlugin for ModalityPlugin { let selection = ctx.require_at(&self.selection)?; let selectable = ctx.require_at(&self.selectable)?; let files = ctx.require_at(&self.files)?; - settings.register::(ctx)?; + let settings = settings.register_document::(ctx)?; // The task layer: one state for the methods, the scheduler and // `modalityTasks` (A.3, A.6). let shared = Arc::new(engine::Shared::new( @@ -1394,7 +1394,7 @@ impl DynPlugin for ModalityPlugin { } } let updated = settings - .update::( + .update( SettingsScope::User, ¶ms.expected_revision, document, diff --git a/docs/architecture/rust-agent/generated/app-server/services.json b/docs/architecture/rust-agent/generated/app-server/services.json index 863f5ed91c..c383977442 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.json +++ b/docs/architecture/rust-agent/generated/app-server/services.json @@ -295,7 +295,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" }, @@ -331,7 +331,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -369,7 +369,7 @@ "external": true }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "provider": 18, "declared": true, "external": true @@ -500,7 +500,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" } @@ -531,7 +531,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -563,7 +563,7 @@ "external": true }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "provider": 18, "declared": true, "external": true @@ -1589,7 +1589,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" }, @@ -1639,7 +1639,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -1695,7 +1695,7 @@ "external": true }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "provider": 18, "declared": true, "external": true @@ -1893,7 +1893,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" } @@ -1906,7 +1906,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -1920,7 +1920,7 @@ "external": true }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "provider": 18, "declared": true, "external": true @@ -2004,7 +2004,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" } @@ -2017,7 +2017,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -2031,7 +2031,7 @@ "external": true }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "provider": 18, "declared": true, "external": true @@ -2061,7 +2061,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" } @@ -2086,7 +2086,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -2112,7 +2112,7 @@ "external": true }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "provider": 18, "declared": true, "external": true diff --git a/docs/architecture/rust-agent/generated/app-server/services.md b/docs/architecture/rust-agent/generated/app-server/services.md index 7742e8a427..b9550e5238 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.md +++ b/docs/architecture/rust-agent/generated/app-server/services.md @@ -99,7 +99,7 @@ flowchart LR p3 -->|"dim_app_server::control::ProcessActivity"| p72 p10 -->|"dim_app_server::methods::ManagementMethods"| p72 p14 -->|"dim_app_server::plugin_files::PluginFileTransactions"| p72 - p18 -->|"dim_app_server::settings::SettingsService"| p72 + p18 -->|"dim_app_server::settings::declared::Settings"| p72 p38 -->|"dyn rutis_bridge::session::services::HostDispatch#sessions"| p72 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p71 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p70 @@ -108,7 +108,7 @@ flowchart LR p17 -->|"dim_agent_capabilities::host::SelectableModelsHost"| p68 p10 -->|"dim_app_server::methods::ManagementMethods"| p68 p14 -->|"dim_app_server::plugin_files::PluginFileTransactions"| p68 - p18 -->|"dim_app_server::settings::SettingsService"| p68 + p18 -->|"dim_app_server::settings::declared::Settings"| p68 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p67 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p66 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p65 @@ -151,7 +151,7 @@ flowchart LR p46 -->|"dim_agent_runtime::parts::PartRegistry"| p40 p38 -->|"dim_app_server::agents::AgentDirectory"| p40 p3 -->|"dim_app_server::control::ProcessActivity"| p40 - p18 -->|"dim_app_server::settings::SettingsService"| p40 + p18 -->|"dim_app_server::settings::declared::Settings"| p40 p8 -->|"dim_app_server::storage::face::Store"| p40 p8 -->|"dim_app_server::storage::metadata::binding::SessionMetadata"| p40 p6 -->|"dim_app_server::storage::sqlite::SqliteStorage"| p40 @@ -164,16 +164,16 @@ flowchart LR p46 -->|"dim_agent_runtime::parts::PartRegistry"| p36 p10 -->|"dim_app_server::methods::ManagementMethods"| p36 p10 -->|"dim_app_server::methods::ManagementMethods"| p35 - p18 -->|"dim_app_server::settings::SettingsService"| p35 + p18 -->|"dim_app_server::settings::declared::Settings"| p35 p4 -->|"dim_agent_capabilities::file_storage::face::FsHost"| p34 p10 -->|"dim_app_server::methods::ManagementMethods"| p34 p18 -->|"dim_app_server::settings::SettingsService"| p34 p10 -->|"dim_app_server::methods::ManagementMethods"| p33 - p18 -->|"dim_app_server::settings::SettingsService"| p33 + p18 -->|"dim_app_server::settings::declared::Settings"| p33 p29 -->|"dim_agent_capabilities::host_platform::HostPlatform"| p32 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p32 p10 -->|"dim_app_server::methods::ManagementMethods"| p32 - p18 -->|"dim_app_server::settings::SettingsService"| p32 + p18 -->|"dim_app_server::settings::declared::Settings"| p32 p29 -->|"dim_agent_capabilities::host_platform::HostPlatform"| p31 p10 -->|"dim_app_server::methods::ManagementMethods"| p31 p29 -->|"dim_agent_capabilities::host_platform::HostPlatform"| p30 diff --git a/docs/architecture/rust-agent/generated/app-server/services.mmd b/docs/architecture/rust-agent/generated/app-server/services.mmd index 79b3df9cdd..40dc3d5fe0 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.mmd +++ b/docs/architecture/rust-agent/generated/app-server/services.mmd @@ -94,7 +94,7 @@ flowchart LR p3 -->|"dim_app_server::control::ProcessActivity"| p72 p10 -->|"dim_app_server::methods::ManagementMethods"| p72 p14 -->|"dim_app_server::plugin_files::PluginFileTransactions"| p72 - p18 -->|"dim_app_server::settings::SettingsService"| p72 + p18 -->|"dim_app_server::settings::declared::Settings"| p72 p38 -->|"dyn rutis_bridge::session::services::HostDispatch#sessions"| p72 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p71 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p70 @@ -103,7 +103,7 @@ flowchart LR p17 -->|"dim_agent_capabilities::host::SelectableModelsHost"| p68 p10 -->|"dim_app_server::methods::ManagementMethods"| p68 p14 -->|"dim_app_server::plugin_files::PluginFileTransactions"| p68 - p18 -->|"dim_app_server::settings::SettingsService"| p68 + p18 -->|"dim_app_server::settings::declared::Settings"| p68 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p67 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p66 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p65 @@ -146,7 +146,7 @@ flowchart LR p46 -->|"dim_agent_runtime::parts::PartRegistry"| p40 p38 -->|"dim_app_server::agents::AgentDirectory"| p40 p3 -->|"dim_app_server::control::ProcessActivity"| p40 - p18 -->|"dim_app_server::settings::SettingsService"| p40 + p18 -->|"dim_app_server::settings::declared::Settings"| p40 p8 -->|"dim_app_server::storage::face::Store"| p40 p8 -->|"dim_app_server::storage::metadata::binding::SessionMetadata"| p40 p6 -->|"dim_app_server::storage::sqlite::SqliteStorage"| p40 @@ -159,16 +159,16 @@ flowchart LR p46 -->|"dim_agent_runtime::parts::PartRegistry"| p36 p10 -->|"dim_app_server::methods::ManagementMethods"| p36 p10 -->|"dim_app_server::methods::ManagementMethods"| p35 - p18 -->|"dim_app_server::settings::SettingsService"| p35 + p18 -->|"dim_app_server::settings::declared::Settings"| p35 p4 -->|"dim_agent_capabilities::file_storage::face::FsHost"| p34 p10 -->|"dim_app_server::methods::ManagementMethods"| p34 p18 -->|"dim_app_server::settings::SettingsService"| p34 p10 -->|"dim_app_server::methods::ManagementMethods"| p33 - p18 -->|"dim_app_server::settings::SettingsService"| p33 + p18 -->|"dim_app_server::settings::declared::Settings"| p33 p29 -->|"dim_agent_capabilities::host_platform::HostPlatform"| p32 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p32 p10 -->|"dim_app_server::methods::ManagementMethods"| p32 - p18 -->|"dim_app_server::settings::SettingsService"| p32 + p18 -->|"dim_app_server::settings::declared::Settings"| p32 p29 -->|"dim_agent_capabilities::host_platform::HostPlatform"| p31 p10 -->|"dim_app_server::methods::ManagementMethods"| p31 p29 -->|"dim_agent_capabilities::host_platform::HostPlatform"| p30 diff --git a/docs/architecture/rust-agent/generated/catalog.md b/docs/architecture/rust-agent/generated/catalog.md index 95485f170e..e60141bdf9 100644 --- a/docs/architecture/rust-agent/generated/catalog.md +++ b/docs/architecture/rust-agent/generated/catalog.md @@ -56,7 +56,7 @@ Each catalog name a part of the assembly provides or injects. `data` means share | `sessionPermissions` | process | AgentDirectory | data | `permission` async, `permissionDefaults` async | | `sessionStore` | process | SessionStore | internal(owner-api) | — | | `sessions` | process | AgentDirectory | data | `delete` async, `exists` async, `history` async, `idle` async, `input` async, `launch` async, `lookup` async, `pending` async, `stop` async, `withdraw` async | -| `settings` | process | Settings | data | `declaredBy` sync, `projects` sync, `read` async, `register` async, `update` async | +| `settings` | process | Settings | data | `authorizeProject` async, `declaredBy` sync, `projects` sync, `read` async, `register` async, `registerDocument` async, `update` async | | `settingsService` | process | Settings | internal(owner-api) | — | | `skillsCatalog` | process | SkillsCatalog | data | `issues` async, `plugins` async, `register` async, `withdraw` async | | `skillsInstructionsSettingsHost` | process | PromptSettings | data | `instructions` async | diff --git a/docs/architecture/rust-agent/generated/modules.json b/docs/architecture/rust-agent/generated/modules.json index ad92551a62..fe9d776f94 100644 --- a/docs/architecture/rust-agent/generated/modules.json +++ b/docs/architecture/rust-agent/generated/modules.json @@ -3683,6 +3683,15 @@ "json" ] }, + { + "id": "dim_app_server::settings::document", + "crate": "dim_app_server", + "parent": "dim_app_server::settings", + "file": "crates/dim-app-server/src/settings/document.rs", + "unexpandedMacros": [ + "tokio::select" + ] + }, { "id": "dim_app_server::settings::native", "crate": "dim_app_server", @@ -23111,16 +23120,24 @@ "from": "dim_agent_scheduler::methods", "to": "dim_app_server::settings", "references": [ + "path RegisteredDocument", "path SettingsError", "path SettingsError::Conflict", "path SettingsError::Document", "path SettingsError::DocumentShape", "path SettingsError::Invalid", - "path SettingsService", "path dim_app_server::settings::SettingsSnapshot", "use dim_app_server::settings::BusinessDocument", - "use dim_app_server::settings::SettingsError", - "use dim_app_server::settings::SettingsService" + "use dim_app_server::settings::RegisteredDocument", + "use dim_app_server::settings::SettingsError" + ] + }, + { + "from": "dim_agent_scheduler::methods", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use dim_app_server::settings::Settings" ] }, { @@ -25088,10 +25105,10 @@ }, { "from": "dim_app_server::agents", - "to": "dim_app_server::settings", + "to": "dim_app_server::settings::declared", "references": [ - "path SettingsService", - "use crate::settings::SettingsService" + "path Settings", + "use crate::settings::Settings" ] }, { @@ -27120,11 +27137,17 @@ "path SettingsError::Closed", "path SettingsError::Conflict", "path SettingsError::Invalid", - "path SettingsService", "path crate::settings::Result", "use crate::settings::BusinessDocument", - "use crate::settings::SettingsError", - "use crate::settings::SettingsService" + "use crate::settings::SettingsError" + ] + }, + { + "from": "dim_app_server::collaboration_model_policy", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use crate::settings::Settings" ] }, { @@ -30731,6 +30754,14 @@ "use crate::settings::SettingsService" ] }, + { + "from": "dim_app_server::permission_rules", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use crate::settings::Settings" + ] + }, { "from": "dim_app_server::plugin_files", "to": "dim_agent_capabilities::file_storage", @@ -33554,7 +33585,9 @@ "from": "dim_app_server::settings", "to": "dim_agent_runtime::registrations", "references": [ + "path Registration", "path Registrations", + "use dim_agent_runtime::Registration", "use dim_agent_runtime::Registrations" ] }, @@ -33578,6 +33611,14 @@ "use declared::without_write_only" ] }, + { + "from": "dim_app_server::settings", + "to": "dim_app_server::settings::document", + "references": [ + "mod document", + "path document" + ] + }, { "from": "dim_app_server::settings", "to": "dim_app_server::settings::native", @@ -33623,10 +33664,13 @@ "from": "dim_app_server::settings::declared", "to": "dim_app_server::settings", "references": [ + "path BusinessDocument", "path Format", + "path Kind::Custom", "path Kind::Declared", "path Kind::Rust", "path ProjectAuthorized", + "path RegisteredDocument", "path Result", "path SettingsError", "path SettingsError::Cancelled", @@ -33644,10 +33688,49 @@ "path SettingsService", "path SettingsSnapshot", "path project_authorizations", + "path typed", "path validate_file", "path validate_namespace" ] }, + { + "from": "dim_app_server::settings::declared", + "to": "dim_app_server::settings::document", + "references": [ + "path document", + "path super::document::register" + ] + }, + { + "from": "dim_app_server::settings::document", + "to": "dim_agent_capabilities::settings", + "references": [ + "path SettingsScope" + ] + }, + { + "from": "dim_app_server::settings::document", + "to": "dim_app_server::settings", + "references": [ + "path Format", + "path Kind::Custom", + "path RegisteredDocument", + "path Result", + "path SettingsError::Document", + "path SettingsService", + "path Source", + "path revision", + "path validate_file", + "path validate_namespace" + ] + }, + { + "from": "dim_app_server::settings::document", + "to": "dim_app_server::settings::declared", + "references": [ + "path declared::envelope" + ] + }, { "from": "dim_app_server::settings::native", "to": "dim_agent_capabilities::file_storage", @@ -33690,6 +33773,13 @@ "path snapshot" ] }, + { + "from": "dim_app_server::settings::native", + "to": "dim_app_server::settings::document", + "references": [ + "path document" + ] + }, { "from": "dim_app_server::settings::native", "to": "dim_app_server::storage::sqlite", @@ -33997,16 +34087,24 @@ "to": "dim_app_server::settings", "references": [ "path BusinessDocument", + "path RegisteredDocument", "path SettingsError", "path SettingsError::Cancelled", "path SettingsError::Closed", "path SettingsError::Conflict", "path SettingsError::Invalid", - "path SettingsService", "path crate::settings::Result", "use crate::settings::BusinessDocument", - "use crate::settings::SettingsError", - "use crate::settings::SettingsService" + "use crate::settings::RegisteredDocument", + "use crate::settings::SettingsError" + ] + }, + { + "from": "dim_app_server::skills_management", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use crate::settings::Settings" ] }, { @@ -54909,16 +55007,24 @@ "to": "dim_app_server::settings", "references": [ "path BusinessDocument", + "path RegisteredDocument", "path SettingsError", "path SettingsError::Cancelled", "path SettingsError::Closed", "path SettingsError::Conflict", "path SettingsError::Invalid", - "path SettingsService", "path dim_app_server::settings::Result", "use dim_app_server::settings::BusinessDocument", - "use dim_app_server::settings::SettingsError", - "use dim_app_server::settings::SettingsService" + "use dim_app_server::settings::RegisteredDocument", + "use dim_app_server::settings::SettingsError" + ] + }, + { + "from": "dim_modality", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use dim_app_server::settings::Settings" ] }, { @@ -55174,8 +55280,8 @@ "from": "dim_modality::engine", "to": "dim_app_server::settings", "references": [ - "path SettingsService", - "use dim_app_server::settings::SettingsService" + "path RegisteredDocument", + "use dim_app_server::settings::RegisteredDocument" ] }, { @@ -55185,6 +55291,7 @@ "path Evaluation", "path ModalityAdapterService", "path catalog_category", + "path crate::ModalitySettings", "path crate::OcrLookup::Read", "path crate::OcrLookup::Skip", "path crate::OperationRow", diff --git a/docs/architecture/rust-agent/generated/modules.mmd b/docs/architecture/rust-agent/generated/modules.mmd index 42e14f2cf6..b139576023 100644 --- a/docs/architecture/rust-agent/generated/modules.mmd +++ b/docs/architecture/rust-agent/generated/modules.mmd @@ -336,414 +336,415 @@ flowchart LR m332["dim_app_server::session_typescript::tests"] m333["dim_app_server::settings"] m334["dim_app_server::settings::declared"] - m335["dim_app_server::settings::native"] - m336["dim_app_server::settings::workflow_files"] - m337["dim_app_server::settings_methods"] - m338["dim_app_server::skills_management"] - m339["dim_app_server::skills_management::tests"] - m340["dim_app_server::storage"] - m341["dim_app_server::storage::arrays"] - m342["dim_app_server::storage::backup"] - m343["dim_app_server::storage::catalog"] - m344["dim_app_server::storage::catalog::tests"] - m345["dim_app_server::storage::codec"] - m346["dim_app_server::storage::export"] - m347["dim_app_server::storage::face"] - m348["dim_app_server::storage::files"] - m349["dim_app_server::storage::files::tests"] - m350["dim_app_server::storage::identities"] - m351["dim_app_server::storage::image_upgrade"] - m352["dim_app_server::storage::members"] - m353["dim_app_server::storage::members::tree"] - m354["dim_app_server::storage::metadata"] - m355["dim_app_server::storage::metadata::binding"] - m356["dim_app_server::storage::metadata::testing"] - m357["dim_app_server::storage::prompt_migration"] - m358["dim_app_server::storage::query"] - m359["dim_app_server::storage::reclaim"] - m360["dim_app_server::storage::sqlite"] - m361["dim_app_server::storage::text"] - m362["dim_app_server::storage::timeline"] - m363["dim_app_server::storage_methods"] - m364["dim_app_server::transport"] - m365["dim_app_server::tree_protocol"] - m366["dim_app_server::tree_protocol::tests"] - m367["dim_app_server::ui_extensions"] - m368["dim_app_server::ui_extensions::manifest"] - m369["dim_app_server::ui_extensions::resources"] - m370["dim_app_server::ui_host"] - m371["dim_app_server::ui_leaf"] - m372["dim_app_server::web"] - m373["dim_app_server::web::content"] - m374["dim_app_server::web::network"] - m375["dim_app_server::web::network::test_dns"] - m376["dim_app_server::web::network::tests"] - m377["dim_app_server::web_entry"] - m378["dim_app_server::web_entry::resources"] - m379["dim_app_server::web_entry::uploads"] - m380["dim_app_server::workspace_files"] - m381["dim_app_server::worktrees"] - m382["dim_cli"] - m383["dim_cli::args"] - m384["dim_cli::args::prompt_tests"] - m385["dim_cli::args::source_tests"] - m386["dim_cli::args::workspace_tests"] - m387["dim_cli::args::worktree_tests"] - m388["dim_cli::attachments"] - m389["dim_cli::attachments::tests"] - m390["dim_cli::browser"] - m391["dim_cli::browser::tests"] - m392["dim_cli::client"] - m393["dim_cli::client::progress_note_tests"] - m394["dim_cli::client::same_file_tests"] - m395["dim_cli::client::starting_note_tests"] - m396["dim_cli::client::web_assets_tests"] - m397["dim_cli::clipboard"] - m398["dim_cli::clipboard::copy"] - m399["dim_cli::clipboard::copy::tests"] - m400["dim_cli::clipboard::native_flow"] - m401["dim_cli::clipboard::terminal"] - m402["dim_cli::clipboard::terminal::tests"] - m403["dim_cli::clipboard::windows_flow"] - m404["dim_cli::composer"] - m405["dim_cli::configure"] - m406["dim_cli::display"] - m407["dim_cli::export"] - m408["dim_cli::goal"] - m409["dim_cli::goal::tests"] - m410["dim_cli::goal_command"] - m411["dim_cli::images"] - m412["dim_cli::input"] - m413["dim_cli::input::windows_flow"] - m414["dim_cli::leaf"] - m415["dim_cli::locale"] - m416["dim_cli::login"] - m417["dim_cli::loop_command"] - m418["dim_cli::loop_command::tests"] - m419["dim_cli::loop_view"] - m420["dim_cli::loop_view::tests"] - m421["dim_cli::maintenance"] - m422["dim_cli::management"] - m423["dim_cli::management::editor"] - m424["dim_cli::management::hooks"] - m425["dim_cli::management::mcp"] - m426["dim_cli::management::mcp::tests"] - m427["dim_cli::management::models"] - m428["dim_cli::management::permissions"] - m429["dim_cli::management::scheduler"] - m430["dim_cli::management::skills"] - m431["dim_cli::management::workflow"] - m432["dim_cli::management::workflow::tests"] - m433["dim_cli::management_command"] - m434["dim_cli::mcp"] - m435["dim_cli::mcp_command"] - m436["dim_cli::member_approval"] - m437["dim_cli::migration_command"] - m438["dim_cli::modality"] - m439["dim_cli::modality::command"] - m440["dim_cli::modality::media"] - m441["dim_cli::modality::media::tests"] - m442["dim_cli::modality::ocr"] - m443["dim_cli::modality::task"] - m444["dim_cli::modality::tests"] - m445["dim_cli::modality::tests_scripted"] - m446["dim_cli::model"] - m447["dim_cli::model::session"] - m448["dim_cli::model::session::tests"] - m449["dim_cli::model::shell"] - m450["dim_cli::model::shell::tests"] - m451["dim_cli::model::view"] - m452["dim_cli::permission"] - m453["dim_cli::permission_command"] - m454["dim_cli::plugin_command"] - m455["dim_cli::plugin_command::tests"] - m456["dim_cli::plugins"] - m457["dim_cli::projection"] - m458["dim_cli::projection::tests"] - m459["dim_cli::projection::thinking"] - m460["dim_cli::prompt_command"] - m461["dim_cli::question"] - m462["dim_cli::question::line"] - m463["dim_cli::realtime_command"] - m464["dim_cli::realtime_command::tests"] - m465["dim_cli::recording"] - m466["dim_cli::report"] - m467["dim_cli::report::tests"] - m468["dim_cli::sanitize"] - m469["dim_cli::session"] - m470["dim_cli::session::window"] - m471["dim_cli::session_command"] - m472["dim_cli::session_host"] - m473["dim_cli::session_host::compaction"] - m474["dim_cli::session_host::inventory"] - m475["dim_cli::session_host::member"] - m476["dim_cli::session_host::member::tests"] - m477["dim_cli::session_host::report"] - m478["dim_cli::session_host::report::tests"] - m479["dim_cli::session_host::tasks"] - m480["dim_cli::session_host::tasks::tests"] - m481["dim_cli::session_host::tests"] - m482["dim_cli::session_host::workflow"] - m483["dim_cli::ui"] - m484["dim_cli::ui::approvals_panel"] - m485["dim_cli::ui::atomic"] - m486["dim_cli::ui::atomic::tests"] - m487["dim_cli::ui::commands"] - m488["dim_cli::ui::composer"] - m489["dim_cli::ui::composer::history"] - m490["dim_cli::ui::composer::history::tests"] - m491["dim_cli::ui::composer::mentions"] - m492["dim_cli::ui::composer::mentions::tests"] - m493["dim_cli::ui::composer::palette"] - m494["dim_cli::ui::composer::palette::tests"] - m495["dim_cli::ui::composer::tests"] - m496["dim_cli::ui::config"] - m497["dim_cli::ui::config::tests"] - m498["dim_cli::ui::i18n"] - m499["dim_cli::ui::i18n::de"] - m500["dim_cli::ui::i18n::de::chrome"] - m501["dim_cli::ui::i18n::de::failures"] - m502["dim_cli::ui::i18n::de::management"] - m503["dim_cli::ui::i18n::de::plugins"] - m504["dim_cli::ui::i18n::de::prompts"] - m505["dim_cli::ui::i18n::de::providers"] - m506["dim_cli::ui::i18n::de::runtime"] - m507["dim_cli::ui::i18n::es"] - m508["dim_cli::ui::i18n::es::chrome"] - m509["dim_cli::ui::i18n::es::failures"] - m510["dim_cli::ui::i18n::es::management"] - m511["dim_cli::ui::i18n::es::plugins"] - m512["dim_cli::ui::i18n::es::prompts"] - m513["dim_cli::ui::i18n::es::providers"] - m514["dim_cli::ui::i18n::es::runtime"] - m515["dim_cli::ui::i18n::fr"] - m516["dim_cli::ui::i18n::fr::chrome"] - m517["dim_cli::ui::i18n::fr::failures"] - m518["dim_cli::ui::i18n::fr::management"] - m519["dim_cli::ui::i18n::fr::plugins"] - m520["dim_cli::ui::i18n::fr::prompts"] - m521["dim_cli::ui::i18n::fr::providers"] - m522["dim_cli::ui::i18n::fr::runtime"] - m523["dim_cli::ui::i18n::id"] - m524["dim_cli::ui::i18n::id::chrome"] - m525["dim_cli::ui::i18n::id::failures"] - m526["dim_cli::ui::i18n::id::management"] - m527["dim_cli::ui::i18n::id::plugins"] - m528["dim_cli::ui::i18n::id::prompts"] - m529["dim_cli::ui::i18n::id::providers"] - m530["dim_cli::ui::i18n::id::runtime"] - m531["dim_cli::ui::i18n::ja"] - m532["dim_cli::ui::i18n::ja::chrome"] - m533["dim_cli::ui::i18n::ja::failures"] - m534["dim_cli::ui::i18n::ja::management"] - m535["dim_cli::ui::i18n::ja::plugins"] - m536["dim_cli::ui::i18n::ja::prompts"] - m537["dim_cli::ui::i18n::ja::providers"] - m538["dim_cli::ui::i18n::ja::runtime"] - m539["dim_cli::ui::i18n::ko"] - m540["dim_cli::ui::i18n::ko::chrome"] - m541["dim_cli::ui::i18n::ko::failures"] - m542["dim_cli::ui::i18n::ko::management"] - m543["dim_cli::ui::i18n::ko::plugins"] - m544["dim_cli::ui::i18n::ko::prompts"] - m545["dim_cli::ui::i18n::ko::providers"] - m546["dim_cli::ui::i18n::ko::runtime"] - m547["dim_cli::ui::i18n::pt_br"] - m548["dim_cli::ui::i18n::pt_br::chrome"] - m549["dim_cli::ui::i18n::pt_br::failures"] - m550["dim_cli::ui::i18n::pt_br::management"] - m551["dim_cli::ui::i18n::pt_br::plugins"] - m552["dim_cli::ui::i18n::pt_br::prompts"] - m553["dim_cli::ui::i18n::pt_br::providers"] - m554["dim_cli::ui::i18n::pt_br::runtime"] - m555["dim_cli::ui::i18n::pt_pt"] - m556["dim_cli::ui::i18n::pt_pt::chrome"] - m557["dim_cli::ui::i18n::pt_pt::failures"] - m558["dim_cli::ui::i18n::pt_pt::management"] - m559["dim_cli::ui::i18n::pt_pt::plugins"] - m560["dim_cli::ui::i18n::pt_pt::prompts"] - m561["dim_cli::ui::i18n::pt_pt::providers"] - m562["dim_cli::ui::i18n::pt_pt::runtime"] - m563["dim_cli::ui::i18n::tests"] - m564["dim_cli::ui::i18n::zh_cn"] - m565["dim_cli::ui::i18n::zh_cn::chrome"] - m566["dim_cli::ui::i18n::zh_cn::failures"] - m567["dim_cli::ui::i18n::zh_cn::management"] - m568["dim_cli::ui::i18n::zh_cn::plugins"] - m569["dim_cli::ui::i18n::zh_cn::prompts"] - m570["dim_cli::ui::i18n::zh_cn::providers"] - m571["dim_cli::ui::i18n::zh_cn::runtime"] - m572["dim_cli::ui::i18n::zh_hant"] - m573["dim_cli::ui::i18n::zh_hant::chrome"] - m574["dim_cli::ui::i18n::zh_hant::failures"] - m575["dim_cli::ui::i18n::zh_hant::management"] - m576["dim_cli::ui::i18n::zh_hant::plugins"] - m577["dim_cli::ui::i18n::zh_hant::prompts"] - m578["dim_cli::ui::i18n::zh_hant::providers"] - m579["dim_cli::ui::i18n::zh_hant::runtime"] - m580["dim_cli::ui::isolation_panel"] - m581["dim_cli::ui::keys"] - m582["dim_cli::ui::keys::tests"] - m583["dim_cli::ui::language_panel"] - m584["dim_cli::ui::line_input"] - m585["dim_cli::ui::line_input::tests"] - m586["dim_cli::ui::lines_panel"] - m587["dim_cli::ui::lines_panel::tests"] - m588["dim_cli::ui::list_panel"] - m589["dim_cli::ui::list_panel::tests"] - m590["dim_cli::ui::management_panel"] - m591["dim_cli::ui::management_panel::tests"] - m592["dim_cli::ui::models_panel"] - m593["dim_cli::ui::models_panel::tests"] - m594["dim_cli::ui::notify"] - m595["dim_cli::ui::notify::tests"] - m596["dim_cli::ui::oauth_view"] - m597["dim_cli::ui::oauth_view::tests"] - m598["dim_cli::ui::plugins_panel"] - m599["dim_cli::ui::plugins_panel::tests"] - m600["dim_cli::ui::progress"] - m601["dim_cli::ui::progress::tests"] - m602["dim_cli::ui::prompts"] - m603["dim_cli::ui::prompts::tests"] - m604["dim_cli::ui::providers_panel"] - m605["dim_cli::ui::providers_panel::tests"] - m606["dim_cli::ui::queue_panel"] - m607["dim_cli::ui::render"] - m608["dim_cli::ui::render::fullscreen"] - m609["dim_cli::ui::render::fullscreen::tests"] - m610["dim_cli::ui::render::markdown"] - m611["dim_cli::ui::render::markdown::tests"] - m612["dim_cli::ui::render::osc8"] - m613["dim_cli::ui::render::osc8::tests"] - m614["dim_cli::ui::render::panel"] - m615["dim_cli::ui::render::panel::tests"] - m616["dim_cli::ui::render::screen"] - m617["dim_cli::ui::render::screen::tests"] - m618["dim_cli::ui::render::testterm"] - m619["dim_cli::ui::report_panel"] - m620["dim_cli::ui::rows"] - m621["dim_cli::ui::runtime_panel"] - m622["dim_cli::ui::runtime_panel::tests"] - m623["dim_cli::ui::sessions_panel"] - m624["dim_cli::ui::sessions_panel::tests"] - m625["dim_cli::ui::settings_panel"] - m626["dim_cli::ui::shell"] - m627["dim_cli::ui::shell::tests"] - m628["dim_cli::ui::status"] - m629["dim_cli::ui::status::tests"] - m630["dim_cli::ui::tasks_panel"] - m631["dim_cli::ui::terminal"] - m632["dim_cli::ui::terminal::input"] - m633["dim_cli::ui::terminal::input::tests"] - m634["dim_cli::ui::terminal::keyboard"] - m635["dim_cli::ui::terminal::keyboard::tests"] - m636["dim_cli::ui::terminal::modes"] - m637["dim_cli::ui::terminal::modes::tests"] - m638["dim_cli::ui::terminal::tests"] - m639["dim_cli::ui::terminal::unix"] - m640["dim_cli::ui::terminal::windows"] - m641["dim_cli::ui::terminal::windows::windows_flow"] - m642["dim_cli::ui::text"] - m643["dim_cli::ui::text::tests"] - m644["dim_cli::ui::theme"] - m645["dim_cli::ui::theme::ansi"] - m646["dim_cli::ui::theme::ansi::tests"] - m647["dim_cli::ui::theme::contrast"] - m648["dim_cli::ui::theme::contrast::tests"] - m649["dim_cli::ui::theme::detect"] - m650["dim_cli::ui::theme::detect::tests"] - m651["dim_cli::ui::theme::palette"] - m652["dim_cli::ui::theme::tests"] - m653["dim_cli::ui::theme::themes"] - m654["dim_cli::ui::theme_panel"] - m655["dim_cli::ui::theme_panel::tests"] - m656["dim_cli::ui::timeline_panel"] - m657["dim_cli::ui::timeline_panel::tests"] - m658["dim_cli::ui::title"] - m659["dim_cli::ui::title::tests"] - m660["dim_cli::ui::transcript"] - m661["dim_cli::ui::transcript::block"] - m662["dim_cli::ui::transcript::block::tests"] - m663["dim_cli::ui::transcript::blocks"] - m664["dim_cli::ui::transcript::blocks::tests"] - m665["dim_cli::ui::transcript::commit"] - m666["dim_cli::ui::transcript::commit::tests"] - m667["dim_cli::ui::transcript::reveal"] - m668["dim_cli::ui::transcript::reveal::tests"] - m669["dim_cli::ui::transcript::split"] - m670["dim_cli::ui::transcript::split::tests"] - m671["dim_cli::ui::transcript::stream"] - m672["dim_cli::ui::transcript::stream::tests"] - m673["dim_cli::ui::transcript::tool_group"] - m674["dim_cli::ui::tui"] - m675["dim_cli::ui::tui::tests"] - m676["dim_cli::ui::upgrade_dialog"] - m677["dim_cli::update"] - m678["dim_cli::update::staged"] - m679["dim_cli::update::staged::tests"] - m680["dim_cli::update::tests"] - m681["dim_cli::upgrade_line_tests"] - m682["dim_cli::usage"] - m683["dim_cli::web_install"] - m684["dim_cli::web_install::tests"] - m685["dim_cli::wire"] - m686["dim_cli::worktree_command"] - m687["dim_cli::worktree_command::tests"] - m688["dim_client"] - m689["dim_client::callback"] - m690["dim_client::question"] - m691["dim_client::window"] - m692["dim_client::wire"] - m693["dim_goal"] - m694["dim_goal::branch"] - m695["dim_goal::branch::recovery"] - m696["dim_goal::branch::restore"] - m697["dim_goal::fold"] - m698["dim_goal::fold::tests"] - m699["dim_goal::read"] - m700["dim_goal::session"] - m701["dim_goal::session::tests"] - m702["dim_goal::text"] - m703["dim_image_understanding"] - m704["dim_image_understanding::history"] - m705["dim_migration"] - m706["dim_migration::accounts"] - m707["dim_migration::archives"] - m708["dim_migration::engine"] - m709["dim_migration::inventory"] - m710["dim_migration::ledger"] - m711["dim_migration::native"] - m712["dim_migration::native::tests"] - m713["dim_migration::providers"] - m714["dim_migration::scheduler"] - m715["dim_migration::settings"] - m716["dim_migration::settings::permissions"] - m717["dim_migration::settings::skills"] - m718["dim_migration::settings::web"] - m719["dim_migration::source"] - m720["dim_migration::terminal"] - m721["dim_modality"] - m722["dim_modality::adapter"] - m723["dim_modality::engine"] - m724["dim_modality::engine::tests"] - m725["dim_modality::realtime"] - m726["dim_modality::targets"] - m727["dim_modality::task"] - m728["dim_modality::task::tests"] - m729["dim_ocr"] - m730["dim_ocr::args"] - m731["dim_ocr::contract"] - m732["dim_ocr::helper"] - m733["dim_ocr::helper::tests"] - m734["dim_ocr::pdf"] - m735["dim_ocr::platform"] - m736["dim_ocr::plugin"] - m737["dim_ocr::vision"] - m738["dim_report"] - m739["dim_report::draft"] - m740["dim_report::evidence"] - m741["dim_report::render"] - m742["dim_session_title"] + m335["dim_app_server::settings::document"] + m336["dim_app_server::settings::native"] + m337["dim_app_server::settings::workflow_files"] + m338["dim_app_server::settings_methods"] + m339["dim_app_server::skills_management"] + m340["dim_app_server::skills_management::tests"] + m341["dim_app_server::storage"] + m342["dim_app_server::storage::arrays"] + m343["dim_app_server::storage::backup"] + m344["dim_app_server::storage::catalog"] + m345["dim_app_server::storage::catalog::tests"] + m346["dim_app_server::storage::codec"] + m347["dim_app_server::storage::export"] + m348["dim_app_server::storage::face"] + m349["dim_app_server::storage::files"] + m350["dim_app_server::storage::files::tests"] + m351["dim_app_server::storage::identities"] + m352["dim_app_server::storage::image_upgrade"] + m353["dim_app_server::storage::members"] + m354["dim_app_server::storage::members::tree"] + m355["dim_app_server::storage::metadata"] + m356["dim_app_server::storage::metadata::binding"] + m357["dim_app_server::storage::metadata::testing"] + m358["dim_app_server::storage::prompt_migration"] + m359["dim_app_server::storage::query"] + m360["dim_app_server::storage::reclaim"] + m361["dim_app_server::storage::sqlite"] + m362["dim_app_server::storage::text"] + m363["dim_app_server::storage::timeline"] + m364["dim_app_server::storage_methods"] + m365["dim_app_server::transport"] + m366["dim_app_server::tree_protocol"] + m367["dim_app_server::tree_protocol::tests"] + m368["dim_app_server::ui_extensions"] + m369["dim_app_server::ui_extensions::manifest"] + m370["dim_app_server::ui_extensions::resources"] + m371["dim_app_server::ui_host"] + m372["dim_app_server::ui_leaf"] + m373["dim_app_server::web"] + m374["dim_app_server::web::content"] + m375["dim_app_server::web::network"] + m376["dim_app_server::web::network::test_dns"] + m377["dim_app_server::web::network::tests"] + m378["dim_app_server::web_entry"] + m379["dim_app_server::web_entry::resources"] + m380["dim_app_server::web_entry::uploads"] + m381["dim_app_server::workspace_files"] + m382["dim_app_server::worktrees"] + m383["dim_cli"] + m384["dim_cli::args"] + m385["dim_cli::args::prompt_tests"] + m386["dim_cli::args::source_tests"] + m387["dim_cli::args::workspace_tests"] + m388["dim_cli::args::worktree_tests"] + m389["dim_cli::attachments"] + m390["dim_cli::attachments::tests"] + m391["dim_cli::browser"] + m392["dim_cli::browser::tests"] + m393["dim_cli::client"] + m394["dim_cli::client::progress_note_tests"] + m395["dim_cli::client::same_file_tests"] + m396["dim_cli::client::starting_note_tests"] + m397["dim_cli::client::web_assets_tests"] + m398["dim_cli::clipboard"] + m399["dim_cli::clipboard::copy"] + m400["dim_cli::clipboard::copy::tests"] + m401["dim_cli::clipboard::native_flow"] + m402["dim_cli::clipboard::terminal"] + m403["dim_cli::clipboard::terminal::tests"] + m404["dim_cli::clipboard::windows_flow"] + m405["dim_cli::composer"] + m406["dim_cli::configure"] + m407["dim_cli::display"] + m408["dim_cli::export"] + m409["dim_cli::goal"] + m410["dim_cli::goal::tests"] + m411["dim_cli::goal_command"] + m412["dim_cli::images"] + m413["dim_cli::input"] + m414["dim_cli::input::windows_flow"] + m415["dim_cli::leaf"] + m416["dim_cli::locale"] + m417["dim_cli::login"] + m418["dim_cli::loop_command"] + m419["dim_cli::loop_command::tests"] + m420["dim_cli::loop_view"] + m421["dim_cli::loop_view::tests"] + m422["dim_cli::maintenance"] + m423["dim_cli::management"] + m424["dim_cli::management::editor"] + m425["dim_cli::management::hooks"] + m426["dim_cli::management::mcp"] + m427["dim_cli::management::mcp::tests"] + m428["dim_cli::management::models"] + m429["dim_cli::management::permissions"] + m430["dim_cli::management::scheduler"] + m431["dim_cli::management::skills"] + m432["dim_cli::management::workflow"] + m433["dim_cli::management::workflow::tests"] + m434["dim_cli::management_command"] + m435["dim_cli::mcp"] + m436["dim_cli::mcp_command"] + m437["dim_cli::member_approval"] + m438["dim_cli::migration_command"] + m439["dim_cli::modality"] + m440["dim_cli::modality::command"] + m441["dim_cli::modality::media"] + m442["dim_cli::modality::media::tests"] + m443["dim_cli::modality::ocr"] + m444["dim_cli::modality::task"] + m445["dim_cli::modality::tests"] + m446["dim_cli::modality::tests_scripted"] + m447["dim_cli::model"] + m448["dim_cli::model::session"] + m449["dim_cli::model::session::tests"] + m450["dim_cli::model::shell"] + m451["dim_cli::model::shell::tests"] + m452["dim_cli::model::view"] + m453["dim_cli::permission"] + m454["dim_cli::permission_command"] + m455["dim_cli::plugin_command"] + m456["dim_cli::plugin_command::tests"] + m457["dim_cli::plugins"] + m458["dim_cli::projection"] + m459["dim_cli::projection::tests"] + m460["dim_cli::projection::thinking"] + m461["dim_cli::prompt_command"] + m462["dim_cli::question"] + m463["dim_cli::question::line"] + m464["dim_cli::realtime_command"] + m465["dim_cli::realtime_command::tests"] + m466["dim_cli::recording"] + m467["dim_cli::report"] + m468["dim_cli::report::tests"] + m469["dim_cli::sanitize"] + m470["dim_cli::session"] + m471["dim_cli::session::window"] + m472["dim_cli::session_command"] + m473["dim_cli::session_host"] + m474["dim_cli::session_host::compaction"] + m475["dim_cli::session_host::inventory"] + m476["dim_cli::session_host::member"] + m477["dim_cli::session_host::member::tests"] + m478["dim_cli::session_host::report"] + m479["dim_cli::session_host::report::tests"] + m480["dim_cli::session_host::tasks"] + m481["dim_cli::session_host::tasks::tests"] + m482["dim_cli::session_host::tests"] + m483["dim_cli::session_host::workflow"] + m484["dim_cli::ui"] + m485["dim_cli::ui::approvals_panel"] + m486["dim_cli::ui::atomic"] + m487["dim_cli::ui::atomic::tests"] + m488["dim_cli::ui::commands"] + m489["dim_cli::ui::composer"] + m490["dim_cli::ui::composer::history"] + m491["dim_cli::ui::composer::history::tests"] + m492["dim_cli::ui::composer::mentions"] + m493["dim_cli::ui::composer::mentions::tests"] + m494["dim_cli::ui::composer::palette"] + m495["dim_cli::ui::composer::palette::tests"] + m496["dim_cli::ui::composer::tests"] + m497["dim_cli::ui::config"] + m498["dim_cli::ui::config::tests"] + m499["dim_cli::ui::i18n"] + m500["dim_cli::ui::i18n::de"] + m501["dim_cli::ui::i18n::de::chrome"] + m502["dim_cli::ui::i18n::de::failures"] + m503["dim_cli::ui::i18n::de::management"] + m504["dim_cli::ui::i18n::de::plugins"] + m505["dim_cli::ui::i18n::de::prompts"] + m506["dim_cli::ui::i18n::de::providers"] + m507["dim_cli::ui::i18n::de::runtime"] + m508["dim_cli::ui::i18n::es"] + m509["dim_cli::ui::i18n::es::chrome"] + m510["dim_cli::ui::i18n::es::failures"] + m511["dim_cli::ui::i18n::es::management"] + m512["dim_cli::ui::i18n::es::plugins"] + m513["dim_cli::ui::i18n::es::prompts"] + m514["dim_cli::ui::i18n::es::providers"] + m515["dim_cli::ui::i18n::es::runtime"] + m516["dim_cli::ui::i18n::fr"] + m517["dim_cli::ui::i18n::fr::chrome"] + m518["dim_cli::ui::i18n::fr::failures"] + m519["dim_cli::ui::i18n::fr::management"] + m520["dim_cli::ui::i18n::fr::plugins"] + m521["dim_cli::ui::i18n::fr::prompts"] + m522["dim_cli::ui::i18n::fr::providers"] + m523["dim_cli::ui::i18n::fr::runtime"] + m524["dim_cli::ui::i18n::id"] + m525["dim_cli::ui::i18n::id::chrome"] + m526["dim_cli::ui::i18n::id::failures"] + m527["dim_cli::ui::i18n::id::management"] + m528["dim_cli::ui::i18n::id::plugins"] + m529["dim_cli::ui::i18n::id::prompts"] + m530["dim_cli::ui::i18n::id::providers"] + m531["dim_cli::ui::i18n::id::runtime"] + m532["dim_cli::ui::i18n::ja"] + m533["dim_cli::ui::i18n::ja::chrome"] + m534["dim_cli::ui::i18n::ja::failures"] + m535["dim_cli::ui::i18n::ja::management"] + m536["dim_cli::ui::i18n::ja::plugins"] + m537["dim_cli::ui::i18n::ja::prompts"] + m538["dim_cli::ui::i18n::ja::providers"] + m539["dim_cli::ui::i18n::ja::runtime"] + m540["dim_cli::ui::i18n::ko"] + m541["dim_cli::ui::i18n::ko::chrome"] + m542["dim_cli::ui::i18n::ko::failures"] + m543["dim_cli::ui::i18n::ko::management"] + m544["dim_cli::ui::i18n::ko::plugins"] + m545["dim_cli::ui::i18n::ko::prompts"] + m546["dim_cli::ui::i18n::ko::providers"] + m547["dim_cli::ui::i18n::ko::runtime"] + m548["dim_cli::ui::i18n::pt_br"] + m549["dim_cli::ui::i18n::pt_br::chrome"] + m550["dim_cli::ui::i18n::pt_br::failures"] + m551["dim_cli::ui::i18n::pt_br::management"] + m552["dim_cli::ui::i18n::pt_br::plugins"] + m553["dim_cli::ui::i18n::pt_br::prompts"] + m554["dim_cli::ui::i18n::pt_br::providers"] + m555["dim_cli::ui::i18n::pt_br::runtime"] + m556["dim_cli::ui::i18n::pt_pt"] + m557["dim_cli::ui::i18n::pt_pt::chrome"] + m558["dim_cli::ui::i18n::pt_pt::failures"] + m559["dim_cli::ui::i18n::pt_pt::management"] + m560["dim_cli::ui::i18n::pt_pt::plugins"] + m561["dim_cli::ui::i18n::pt_pt::prompts"] + m562["dim_cli::ui::i18n::pt_pt::providers"] + m563["dim_cli::ui::i18n::pt_pt::runtime"] + m564["dim_cli::ui::i18n::tests"] + m565["dim_cli::ui::i18n::zh_cn"] + m566["dim_cli::ui::i18n::zh_cn::chrome"] + m567["dim_cli::ui::i18n::zh_cn::failures"] + m568["dim_cli::ui::i18n::zh_cn::management"] + m569["dim_cli::ui::i18n::zh_cn::plugins"] + m570["dim_cli::ui::i18n::zh_cn::prompts"] + m571["dim_cli::ui::i18n::zh_cn::providers"] + m572["dim_cli::ui::i18n::zh_cn::runtime"] + m573["dim_cli::ui::i18n::zh_hant"] + m574["dim_cli::ui::i18n::zh_hant::chrome"] + m575["dim_cli::ui::i18n::zh_hant::failures"] + m576["dim_cli::ui::i18n::zh_hant::management"] + m577["dim_cli::ui::i18n::zh_hant::plugins"] + m578["dim_cli::ui::i18n::zh_hant::prompts"] + m579["dim_cli::ui::i18n::zh_hant::providers"] + m580["dim_cli::ui::i18n::zh_hant::runtime"] + m581["dim_cli::ui::isolation_panel"] + m582["dim_cli::ui::keys"] + m583["dim_cli::ui::keys::tests"] + m584["dim_cli::ui::language_panel"] + m585["dim_cli::ui::line_input"] + m586["dim_cli::ui::line_input::tests"] + m587["dim_cli::ui::lines_panel"] + m588["dim_cli::ui::lines_panel::tests"] + m589["dim_cli::ui::list_panel"] + m590["dim_cli::ui::list_panel::tests"] + m591["dim_cli::ui::management_panel"] + m592["dim_cli::ui::management_panel::tests"] + m593["dim_cli::ui::models_panel"] + m594["dim_cli::ui::models_panel::tests"] + m595["dim_cli::ui::notify"] + m596["dim_cli::ui::notify::tests"] + m597["dim_cli::ui::oauth_view"] + m598["dim_cli::ui::oauth_view::tests"] + m599["dim_cli::ui::plugins_panel"] + m600["dim_cli::ui::plugins_panel::tests"] + m601["dim_cli::ui::progress"] + m602["dim_cli::ui::progress::tests"] + m603["dim_cli::ui::prompts"] + m604["dim_cli::ui::prompts::tests"] + m605["dim_cli::ui::providers_panel"] + m606["dim_cli::ui::providers_panel::tests"] + m607["dim_cli::ui::queue_panel"] + m608["dim_cli::ui::render"] + m609["dim_cli::ui::render::fullscreen"] + m610["dim_cli::ui::render::fullscreen::tests"] + m611["dim_cli::ui::render::markdown"] + m612["dim_cli::ui::render::markdown::tests"] + m613["dim_cli::ui::render::osc8"] + m614["dim_cli::ui::render::osc8::tests"] + m615["dim_cli::ui::render::panel"] + m616["dim_cli::ui::render::panel::tests"] + m617["dim_cli::ui::render::screen"] + m618["dim_cli::ui::render::screen::tests"] + m619["dim_cli::ui::render::testterm"] + m620["dim_cli::ui::report_panel"] + m621["dim_cli::ui::rows"] + m622["dim_cli::ui::runtime_panel"] + m623["dim_cli::ui::runtime_panel::tests"] + m624["dim_cli::ui::sessions_panel"] + m625["dim_cli::ui::sessions_panel::tests"] + m626["dim_cli::ui::settings_panel"] + m627["dim_cli::ui::shell"] + m628["dim_cli::ui::shell::tests"] + m629["dim_cli::ui::status"] + m630["dim_cli::ui::status::tests"] + m631["dim_cli::ui::tasks_panel"] + m632["dim_cli::ui::terminal"] + m633["dim_cli::ui::terminal::input"] + m634["dim_cli::ui::terminal::input::tests"] + m635["dim_cli::ui::terminal::keyboard"] + m636["dim_cli::ui::terminal::keyboard::tests"] + m637["dim_cli::ui::terminal::modes"] + m638["dim_cli::ui::terminal::modes::tests"] + m639["dim_cli::ui::terminal::tests"] + m640["dim_cli::ui::terminal::unix"] + m641["dim_cli::ui::terminal::windows"] + m642["dim_cli::ui::terminal::windows::windows_flow"] + m643["dim_cli::ui::text"] + m644["dim_cli::ui::text::tests"] + m645["dim_cli::ui::theme"] + m646["dim_cli::ui::theme::ansi"] + m647["dim_cli::ui::theme::ansi::tests"] + m648["dim_cli::ui::theme::contrast"] + m649["dim_cli::ui::theme::contrast::tests"] + m650["dim_cli::ui::theme::detect"] + m651["dim_cli::ui::theme::detect::tests"] + m652["dim_cli::ui::theme::palette"] + m653["dim_cli::ui::theme::tests"] + m654["dim_cli::ui::theme::themes"] + m655["dim_cli::ui::theme_panel"] + m656["dim_cli::ui::theme_panel::tests"] + m657["dim_cli::ui::timeline_panel"] + m658["dim_cli::ui::timeline_panel::tests"] + m659["dim_cli::ui::title"] + m660["dim_cli::ui::title::tests"] + m661["dim_cli::ui::transcript"] + m662["dim_cli::ui::transcript::block"] + m663["dim_cli::ui::transcript::block::tests"] + m664["dim_cli::ui::transcript::blocks"] + m665["dim_cli::ui::transcript::blocks::tests"] + m666["dim_cli::ui::transcript::commit"] + m667["dim_cli::ui::transcript::commit::tests"] + m668["dim_cli::ui::transcript::reveal"] + m669["dim_cli::ui::transcript::reveal::tests"] + m670["dim_cli::ui::transcript::split"] + m671["dim_cli::ui::transcript::split::tests"] + m672["dim_cli::ui::transcript::stream"] + m673["dim_cli::ui::transcript::stream::tests"] + m674["dim_cli::ui::transcript::tool_group"] + m675["dim_cli::ui::tui"] + m676["dim_cli::ui::tui::tests"] + m677["dim_cli::ui::upgrade_dialog"] + m678["dim_cli::update"] + m679["dim_cli::update::staged"] + m680["dim_cli::update::staged::tests"] + m681["dim_cli::update::tests"] + m682["dim_cli::upgrade_line_tests"] + m683["dim_cli::usage"] + m684["dim_cli::web_install"] + m685["dim_cli::web_install::tests"] + m686["dim_cli::wire"] + m687["dim_cli::worktree_command"] + m688["dim_cli::worktree_command::tests"] + m689["dim_client"] + m690["dim_client::callback"] + m691["dim_client::question"] + m692["dim_client::window"] + m693["dim_client::wire"] + m694["dim_goal"] + m695["dim_goal::branch"] + m696["dim_goal::branch::recovery"] + m697["dim_goal::branch::restore"] + m698["dim_goal::fold"] + m699["dim_goal::fold::tests"] + m700["dim_goal::read"] + m701["dim_goal::session"] + m702["dim_goal::session::tests"] + m703["dim_goal::text"] + m704["dim_image_understanding"] + m705["dim_image_understanding::history"] + m706["dim_migration"] + m707["dim_migration::accounts"] + m708["dim_migration::archives"] + m709["dim_migration::engine"] + m710["dim_migration::inventory"] + m711["dim_migration::ledger"] + m712["dim_migration::native"] + m713["dim_migration::native::tests"] + m714["dim_migration::providers"] + m715["dim_migration::scheduler"] + m716["dim_migration::settings"] + m717["dim_migration::settings::permissions"] + m718["dim_migration::settings::skills"] + m719["dim_migration::settings::web"] + m720["dim_migration::source"] + m721["dim_migration::terminal"] + m722["dim_modality"] + m723["dim_modality::adapter"] + m724["dim_modality::engine"] + m725["dim_modality::engine::tests"] + m726["dim_modality::realtime"] + m727["dim_modality::targets"] + m728["dim_modality::task"] + m729["dim_modality::task::tests"] + m730["dim_ocr"] + m731["dim_ocr::args"] + m732["dim_ocr::contract"] + m733["dim_ocr::helper"] + m734["dim_ocr::helper::tests"] + m735["dim_ocr::pdf"] + m736["dim_ocr::platform"] + m737["dim_ocr::plugin"] + m738["dim_ocr::vision"] + m739["dim_report"] + m740["dim_report::draft"] + m741["dim_report::evidence"] + m742["dim_report::render"] + m743["dim_session_title"] m0 --> m1 m0 -.-> m2 m0 -.-> m3 @@ -755,10 +756,10 @@ flowchart LR m0 --> m9 m0 -.-> m10 m0 --> m12 - m0 --> m688 + m0 --> m689 m1 --> m12 - m1 --> m688 m1 --> m689 + m1 --> m690 m2 --> m3 m2 --> m12 m2 --> m210 @@ -767,7 +768,7 @@ flowchart LR m3 --> m210 m3 --> m222 m3 --> m223 - m3 --> m692 + m3 --> m693 m4 --> m12 m4 --> m208 m4 --> m210 @@ -786,20 +787,20 @@ flowchart LR m5 --> m216 m5 --> m219 m5 --> m225 - m5 --> m690 m5 --> m691 m5 --> m692 + m5 --> m693 m6 --> m9 m6 --> m10 m6 --> m12 m6 --> m210 m6 --> m219 - m6 --> m690 + m6 --> m691 m7 --> m10 m7 --> m206 m7 --> m210 m7 --> m222 - m7 --> m692 + m7 --> m693 m8 --> m12 m9 --> m0 m10 -.-> m11 @@ -811,11 +812,11 @@ flowchart LR m10 --> m220 m10 --> m227 m10 --> m229 - m10 --> m692 + m10 --> m693 m11 --> m10 - m11 --> m690 - m11 --> m692 - m12 --> m688 + m11 --> m691 + m11 --> m693 + m12 --> m689 m13 -.-> m14 m13 -.-> m15 m13 --> m16 @@ -2168,6 +2169,7 @@ flowchart LR m196 --> m287 m196 --> m298 m196 --> m333 + m196 --> m334 m197 --> m191 m197 -.-> m198 m197 --> m222 @@ -2197,7 +2199,7 @@ flowchart LR m200 --> m229 m200 --> m231 m200 --> m256 - m200 --> m688 + m200 --> m689 m201 --> m190 m202 --> m200 m202 --> m201 @@ -2331,29 +2333,29 @@ flowchart LR m231 --> m331 m231 --> m333 m231 --> m334 - m231 --> m337 m231 --> m338 - m231 -.-> m340 - m231 --> m347 - m231 --> m355 - m231 --> m360 - m231 --> m362 + m231 --> m339 + m231 -.-> m341 + m231 --> m348 + m231 --> m356 + m231 --> m361 m231 --> m363 m231 --> m364 - m231 -.-> m365 - m231 --> m367 - m231 --> m369 + m231 --> m365 + m231 -.-> m366 + m231 --> m368 m231 --> m370 m231 --> m371 m231 --> m372 - m231 -.-> m377 - m231 --> m380 + m231 --> m373 + m231 -.-> m378 m231 --> m381 + m231 --> m382 m232 --> m243 m233 --> m169 m233 --> m223 m233 --> m306 - m233 --> m360 + m233 --> m361 m234 --> m64 m234 --> m72 m234 --> m85 @@ -2379,14 +2381,14 @@ flowchart LR m234 --> m256 m234 --> m306 m234 --> m330 - m234 --> m333 - m234 --> m343 - m234 --> m347 - m234 --> m354 + m234 --> m334 + m234 --> m344 + m234 --> m348 m234 --> m355 - m234 --> m360 - m234 --> m362 - m234 --> m381 + m234 --> m356 + m234 --> m361 + m234 --> m363 + m234 --> m382 m235 --> m72 m235 --> m85 m235 --> m94 @@ -2419,7 +2421,7 @@ flowchart LR m237 --> m234 m237 -.-> m238 m237 --> m306 - m237 --> m381 + m237 --> m382 m238 --> m33 m238 --> m50 m238 --> m161 @@ -2498,11 +2500,11 @@ flowchart LR m243 --> m327 m243 --> m329 m243 --> m331 - m243 --> m340 - m243 --> m342 - m243 --> m346 - m243 --> m357 - m243 --> m360 + m243 --> m341 + m243 --> m343 + m243 --> m347 + m243 --> m358 + m243 --> m361 m244 --> m58 m244 --> m176 m244 --> m245 @@ -2588,6 +2590,7 @@ flowchart LR m250 --> m287 m250 --> m306 m250 --> m333 + m250 --> m334 m251 --> m51 m251 --> m72 m251 --> m85 @@ -2624,12 +2627,12 @@ flowchart LR m251 --> m306 m251 --> m307 m251 --> m323 - m251 --> m338 - m251 --> m354 - m251 --> m365 - m251 --> m370 - m251 --> m377 - m251 --> m381 + m251 --> m339 + m251 --> m355 + m251 --> m366 + m251 --> m371 + m251 --> m378 + m251 --> m382 m252 --> m85 m252 --> m136 m252 --> m160 @@ -2654,7 +2657,7 @@ flowchart LR m253 --> m252 m253 --> m306 m253 --> m307 - m253 --> m365 + m253 --> m366 m254 --> m64 m254 --> m72 m254 --> m81 @@ -2673,11 +2676,11 @@ flowchart LR m254 --> m251 m254 --> m295 m254 --> m306 - m254 --> m362 - m254 --> m365 + m254 --> m363 + m254 --> m366 m255 --> m251 m255 --> m306 - m255 --> m367 + m255 --> m368 m256 --> m160 m256 --> m231 m257 --> m73 @@ -2904,6 +2907,7 @@ flowchart LR m296 --> m287 m296 --> m306 m296 --> m333 + m296 --> m334 m298 --> m58 m298 --> m176 m299 --> m85 @@ -2922,7 +2926,7 @@ flowchart LR m299 --> m327 m299 --> m333 m299 --> m334 - m299 --> m367 + m299 --> m368 m300 --> m299 m300 --> m302 m301 --> m85 @@ -2930,7 +2934,7 @@ flowchart LR m301 --> m300 m302 --> m299 m302 --> m327 - m302 --> m368 + m302 --> m369 m303 --> m72 m303 --> m109 m303 --> m136 @@ -2965,9 +2969,9 @@ flowchart LR m306 --> m234 m306 --> m285 m306 --> m323 - m306 --> m354 - m306 --> m365 - m306 --> m381 + m306 --> m355 + m306 --> m366 + m306 --> m382 m307 --> m37 m307 --> m43 m307 --> m72 @@ -3004,7 +3008,7 @@ flowchart LR m307 --> m323 m307 -.-> m324 m307 --> m325 - m307 --> m360 + m307 --> m361 m308 --> m37 m308 --> m72 m308 --> m220 @@ -3132,7 +3136,7 @@ flowchart LR m329 --> m176 m329 --> m178 m329 --> m215 - m329 --> m347 + m329 --> m348 m330 --> m85 m330 --> m99 m330 --> m126 @@ -3140,7 +3144,7 @@ flowchart LR m330 --> m169 m330 --> m176 m330 --> m210 - m330 --> m347 + m330 --> m348 m331 --> m36 m331 --> m72 m331 --> m81 @@ -3162,8 +3166,8 @@ flowchart LR m331 --> m287 m331 --> m327 m331 -.-> m332 - m331 --> m336 - m331 --> m369 + m331 --> m337 + m331 --> m370 m332 --> m32 m332 --> m161 m332 --> m163 @@ -3171,2131 +3175,2139 @@ flowchart LR m332 --> m231 m332 --> m237 m332 --> m331 - m332 --> m336 + m332 --> m337 m333 --> m58 m333 --> m109 m333 --> m176 m333 --> m179 m333 --> m334 - m333 -.-> m335 - m333 --> m336 - m333 --> m360 + m333 --> m335 + m333 -.-> m336 + m333 --> m337 + m333 --> m361 m334 --> m58 m334 --> m109 m334 --> m333 - m335 --> m58 + m334 --> m335 m335 --> m109 - m335 --> m169 m335 --> m333 - m335 --> m360 + m335 --> m334 m336 --> m58 + m336 --> m109 + m336 --> m169 m336 --> m333 + m336 --> m335 + m336 --> m361 m337 --> m58 - m337 --> m85 - m337 --> m176 - m337 --> m287 - m337 --> m306 m337 --> m333 - m337 --> m334 - m338 --> m73 + m338 --> m58 m338 --> m85 - m338 --> m109 - m338 --> m115 - m338 --> m116 - m338 --> m117 - m338 --> m120 m338 --> m176 - m338 --> m178 m338 --> m287 - m338 --> m299 - m338 --> m300 m338 --> m306 m338 --> m333 - m338 -.-> m339 + m338 --> m334 + m339 --> m73 + m339 --> m85 + m339 --> m109 m339 --> m115 - m339 --> m338 - m340 --> m57 - m340 --> m169 - m340 -.-> m341 - m340 --> m342 - m340 --> m343 - m340 --> m345 - m340 --> m346 - m340 --> m347 - m340 -.-> m348 - m340 --> m350 - m340 -.-> m351 - m340 --> m352 - m340 --> m354 - m340 --> m355 - m340 --> m356 - m340 --> m357 - m340 --> m358 - m340 --> m359 - m340 --> m360 - m340 --> m361 - m340 --> m362 + m339 --> m116 + m339 --> m117 + m339 --> m120 + m339 --> m176 + m339 --> m178 + m339 --> m287 + m339 --> m299 + m339 --> m300 + m339 --> m306 + m339 --> m333 + m339 --> m334 + m339 -.-> m340 + m340 --> m115 + m340 --> m339 + m341 --> m57 m341 --> m169 - m341 --> m345 + m341 -.-> m342 + m341 --> m343 + m341 --> m344 + m341 --> m346 + m341 --> m347 + m341 --> m348 + m341 -.-> m349 + m341 --> m351 + m341 -.-> m352 + m341 --> m353 + m341 --> m355 + m341 --> m356 + m341 --> m357 + m341 --> m358 + m341 --> m359 m341 --> m360 + m341 --> m361 m341 --> m362 + m341 --> m363 m342 --> m169 - m342 --> m231 - m342 --> m348 - m342 --> m360 + m342 --> m346 + m342 --> m361 + m342 --> m363 m343 --> m169 - m343 --> m208 - m343 --> m210 - m343 --> m217 - m343 --> m223 - m343 --> m306 - m343 -.-> m344 - m343 --> m354 - m343 --> m360 - m343 --> m362 - m344 --> m50 - m344 --> m161 - m344 --> m163 - m344 --> m231 - m344 --> m251 - m344 --> m343 - m344 --> m360 - m345 --> m168 - m345 --> m169 - m345 --> m170 - m345 --> m185 - m345 --> m187 - m345 --> m208 - m345 --> m210 - m345 --> m220 - m345 --> m229 - m345 --> m341 - m345 --> m360 - m346 --> m164 + m343 --> m231 + m343 --> m349 + m343 --> m361 + m344 --> m169 + m344 --> m208 + m344 --> m210 + m344 --> m217 + m344 --> m223 + m344 --> m306 + m344 -.-> m345 + m344 --> m355 + m344 --> m361 + m344 --> m363 + m345 --> m50 + m345 --> m161 + m345 --> m163 + m345 --> m231 + m345 --> m251 + m345 --> m344 + m345 --> m361 m346 --> m168 m346 --> m169 + m346 --> m170 + m346 --> m185 m346 --> m187 + m346 --> m208 m346 --> m210 - m346 --> m345 - m346 --> m360 - m346 --> m362 - m347 --> m57 - m347 --> m163 + m346 --> m220 + m346 --> m229 + m346 --> m342 + m346 --> m361 + m347 --> m164 + m347 --> m168 m347 --> m169 - m347 --> m185 m347 --> m187 - m347 --> m215 - m347 --> m306 - m347 --> m362 - m348 --> m58 - m348 --> m72 - m348 --> m73 + m347 --> m210 + m347 --> m346 + m347 --> m361 + m347 --> m363 + m348 --> m57 + m348 --> m163 m348 --> m169 - m348 --> m340 - m348 --> m349 - m348 --> m360 + m348 --> m185 + m348 --> m187 + m348 --> m215 + m348 --> m306 + m348 --> m363 m349 --> m58 m349 --> m72 m349 --> m73 - m349 --> m163 m349 --> m169 - m349 --> m187 - m349 --> m348 - m349 --> m360 - m349 --> m362 + m349 --> m341 + m349 --> m350 + m349 --> m361 + m350 --> m58 + m350 --> m72 + m350 --> m73 + m350 --> m163 m350 --> m169 - m350 --> m360 - m350 --> m362 - m351 --> m80 + m350 --> m187 + m350 --> m349 + m350 --> m361 + m350 --> m363 m351 --> m169 - m351 --> m208 - m351 --> m210 - m351 --> m216 - m351 --> m229 - m351 --> m231 - m351 --> m345 - m351 --> m359 - m351 --> m360 m351 --> m361 - m351 --> m362 + m351 --> m363 + m352 --> m80 m352 --> m169 - m352 --> m170 - m352 --> m184 - m352 --> m185 - m352 --> m187 + m352 --> m208 m352 --> m210 - m352 --> m353 - m352 --> m358 + m352 --> m216 + m352 --> m229 + m352 --> m231 + m352 --> m346 m352 --> m360 + m352 --> m361 m352 --> m362 + m352 --> m363 m353 --> m169 - m353 --> m358 - m353 --> m360 - m354 --> m106 + m353 --> m170 + m353 --> m184 + m353 --> m185 + m353 --> m187 + m353 --> m210 + m353 --> m354 + m353 --> m359 + m353 --> m361 + m353 --> m363 m354 --> m169 - m354 --> m355 - m354 --> m356 - m354 --> m360 - m354 --> m362 - m355 --> m354 - m355 --> m362 - m357 --> m94 - m357 --> m168 - m357 --> m169 - m357 --> m187 - m357 --> m360 - m357 --> m362 + m354 --> m359 + m354 --> m361 + m355 --> m106 + m355 --> m169 + m355 --> m356 + m355 --> m357 + m355 --> m361 + m355 --> m363 + m356 --> m355 + m356 --> m363 + m358 --> m94 + m358 --> m168 m358 --> m169 - m358 --> m170 - m358 --> m184 - m358 --> m185 m358 --> m187 - m358 --> m207 - m358 --> m345 - m358 --> m352 - m358 --> m360 m358 --> m361 + m358 --> m363 m359 --> m169 - m359 --> m360 + m359 --> m170 + m359 --> m184 + m359 --> m185 + m359 --> m187 + m359 --> m207 + m359 --> m346 + m359 --> m353 + m359 --> m361 m359 --> m362 - m360 --> m161 m360 --> m169 - m360 --> m187 - m360 --> m188 - m360 --> m223 - m360 --> m307 - m360 --> m317 - m360 --> m341 - m360 --> m343 - m360 --> m345 - m360 --> m350 - m360 --> m351 - m360 --> m352 - m360 --> m358 - m360 --> m359 m360 --> m361 - m360 --> m362 + m360 --> m363 + m361 --> m161 m361 --> m169 - m361 --> m185 m361 --> m187 - m361 --> m210 - m361 --> m345 + m361 --> m188 + m361 --> m223 + m361 --> m307 + m361 --> m317 + m361 --> m342 + m361 --> m344 + m361 --> m346 + m361 --> m351 + m361 --> m352 + m361 --> m353 + m361 --> m359 m361 --> m360 m361 --> m362 - m362 --> m57 - m362 --> m72 - m362 --> m163 - m362 --> m164 - m362 --> m168 + m361 --> m363 m362 --> m169 - m362 --> m176 m362 --> m185 m362 --> m187 - m362 --> m188 - m362 --> m207 m362 --> m210 - m362 --> m215 - m362 --> m220 - m362 --> m306 - m362 --> m341 - m362 --> m343 - m362 --> m345 - m362 --> m347 - m362 --> m348 - m362 --> m350 - m362 --> m352 - m362 --> m354 - m362 --> m355 - m362 --> m358 - m362 --> m360 + m362 --> m346 m362 --> m361 - m363 --> m85 + m362 --> m363 + m363 --> m57 + m363 --> m72 + m363 --> m163 + m363 --> m164 + m363 --> m168 + m363 --> m169 m363 --> m176 - m363 --> m287 + m363 --> m185 + m363 --> m187 + m363 --> m188 + m363 --> m207 + m363 --> m210 + m363 --> m215 + m363 --> m220 m363 --> m306 - m363 --> m360 - m364 --> m39 - m364 --> m51 + m363 --> m342 + m363 --> m344 + m363 --> m346 + m363 --> m348 + m363 --> m349 + m363 --> m351 + m363 --> m353 + m363 --> m355 + m363 --> m356 + m363 --> m359 + m363 --> m361 + m363 --> m362 m364 --> m85 m364 --> m176 - m364 --> m231 - m364 --> m251 - m364 --> m256 - m364 --> m295 + m364 --> m287 m364 --> m306 - m364 --> m360 - m365 --> m106 - m365 --> m162 - m365 --> m164 - m365 --> m185 - m365 --> m210 - m365 --> m216 - m365 --> m220 - m365 --> m307 - m365 -.-> m366 + m364 --> m361 + m365 --> m39 + m365 --> m51 + m365 --> m85 + m365 --> m176 + m365 --> m231 + m365 --> m251 + m365 --> m256 + m365 --> m295 + m365 --> m306 + m365 --> m361 + m366 --> m106 + m366 --> m162 + m366 --> m164 + m366 --> m185 m366 --> m210 + m366 --> m216 m366 --> m220 - m366 --> m224 - m366 --> m365 - m367 --> m58 - m367 --> m85 - m367 --> m176 - m367 --> m178 - m367 --> m231 - m367 --> m287 - m367 --> m306 - m367 --> m368 - m367 --> m369 + m366 --> m307 + m366 -.-> m367 + m367 --> m210 + m367 --> m220 + m367 --> m224 + m367 --> m366 + m368 --> m58 m368 --> m85 - m369 --> m58 + m368 --> m176 + m368 --> m178 + m368 --> m231 + m368 --> m287 + m368 --> m306 + m368 --> m369 + m368 --> m370 m369 --> m85 - m369 --> m163 - m369 --> m176 - m369 --> m180 + m370 --> m58 m370 --> m85 - m370 --> m251 - m370 --> m306 - m370 --> m371 + m370 --> m163 + m370 --> m176 + m370 --> m180 m371 --> m85 - m371 --> m370 - m372 --> m72 - m372 --> m109 - m372 --> m136 - m372 --> m176 - m372 --> m178 - m372 --> m208 - m372 --> m229 - m372 --> m264 - m372 --> m334 - m372 --> m373 - m372 --> m374 + m371 --> m251 + m371 --> m306 + m371 --> m372 + m372 --> m85 + m372 --> m371 + m373 --> m72 + m373 --> m109 + m373 --> m136 + m373 --> m176 + m373 --> m178 + m373 --> m208 + m373 --> m229 + m373 --> m264 + m373 --> m334 m373 --> m374 + m373 --> m375 m374 --> m375 - m374 -.-> m376 - m376 --> m374 - m376 --> m375 - m377 --> m85 - m377 --> m251 - m377 --> m295 - m377 --> m306 - m377 --> m364 - m377 --> m378 - m377 --> m379 + m375 --> m376 + m375 -.-> m377 + m377 --> m375 + m377 --> m376 + m378 --> m85 + m378 --> m251 + m378 --> m295 m378 --> m306 - m378 --> m367 - m378 --> m369 - m378 --> m377 - m379 --> m72 - m379 --> m80 - m379 --> m85 - m379 --> m208 - m379 --> m377 + m378 --> m365 + m378 --> m379 + m378 --> m380 + m379 --> m306 + m379 --> m368 + m379 --> m370 + m379 --> m378 + m380 --> m72 + m380 --> m80 m380 --> m85 - m380 --> m154 - m380 --> m176 - m380 --> m287 - m381 --> m57 + m380 --> m208 + m380 --> m378 m381 --> m85 - m381 --> m168 - m381 --> m169 + m381 --> m154 m381 --> m176 m381 --> m287 - m381 --> m347 - m381 --> m362 - m382 --> m0 - m382 --> m1 - m382 --> m39 - m382 --> m383 - m382 -.-> m388 - m382 --> m390 - m382 --> m392 - m382 -.-> m397 - m382 -.-> m404 - m382 -.-> m405 - m382 -.-> m406 - m382 --> m407 - m382 -.-> m408 - m382 -.-> m410 - m382 --> m411 - m382 --> m412 - m382 -.-> m414 - m382 --> m415 - m382 --> m416 - m382 -.-> m417 - m382 -.-> m419 - m382 --> m421 - m382 -.-> m422 - m382 --> m425 - m382 --> m433 - m382 -.-> m434 - m382 --> m435 - m382 -.-> m436 - m382 --> m437 - m382 --> m438 - m382 --> m443 - m382 --> m446 - m382 --> m452 - m382 -.-> m453 - m382 --> m454 - m382 --> m456 - m382 -.-> m457 - m382 --> m460 - m382 -.-> m461 - m382 --> m463 - m382 --> m465 - m382 -.-> m466 - m382 --> m468 - m382 --> m469 - m382 --> m471 - m382 --> m472 - m382 --> m483 - m382 --> m489 - m382 --> m496 - m382 --> m498 - m382 --> m642 - m382 --> m674 - m382 --> m677 - m382 -.-> m681 - m382 -.-> m682 - m382 --> m683 - m382 --> m685 - m382 --> m686 - m382 --> m688 - m383 --> m205 - m383 --> m222 - m383 --> m382 - m383 -.-> m384 - m383 -.-> m385 - m383 -.-> m386 - m383 -.-> m387 - m383 --> m388 - m383 --> m407 - m383 --> m424 + m382 --> m57 + m382 --> m85 + m382 --> m168 + m382 --> m169 + m382 --> m176 + m382 --> m287 + m382 --> m348 + m382 --> m363 + m383 --> m0 + m383 --> m1 + m383 --> m39 + m383 --> m384 + m383 -.-> m389 + m383 --> m391 + m383 --> m393 + m383 -.-> m398 + m383 -.-> m405 + m383 -.-> m406 + m383 -.-> m407 + m383 --> m408 + m383 -.-> m409 + m383 -.-> m411 + m383 --> m412 + m383 --> m413 + m383 -.-> m415 + m383 --> m416 + m383 --> m417 + m383 -.-> m418 + m383 -.-> m420 + m383 --> m422 + m383 -.-> m423 + m383 --> m426 m383 --> m434 - m383 --> m437 + m383 -.-> m435 + m383 --> m436 + m383 -.-> m437 m383 --> m438 - m383 --> m440 + m383 --> m439 + m383 --> m444 m383 --> m447 - m383 --> m452 - m383 --> m454 - m383 --> m460 - m383 --> m677 + m383 --> m453 + m383 -.-> m454 + m383 --> m455 + m383 --> m457 + m383 -.-> m458 + m383 --> m461 + m383 -.-> m462 + m383 --> m464 + m383 --> m466 + m383 -.-> m467 + m383 --> m469 + m383 --> m470 + m383 --> m472 + m383 --> m473 + m383 --> m484 + m383 --> m490 + m383 --> m497 + m383 --> m499 + m383 --> m643 + m383 --> m675 + m383 --> m678 + m383 -.-> m682 + m383 -.-> m683 + m383 --> m684 m383 --> m686 + m383 --> m687 + m383 --> m689 + m384 --> m205 + m384 --> m222 m384 --> m383 - m385 --> m383 - m386 --> m383 - m387 --> m382 - m387 --> m383 - m387 --> m686 - m388 -.-> m389 - m390 -.-> m391 - m392 --> m39 - m392 --> m382 - m392 --> m383 - m392 -.-> m393 - m392 -.-> m394 - m392 -.-> m395 - m392 -.-> m396 - m392 --> m415 - m392 --> m677 - m392 --> m688 - m393 --> m392 - m394 --> m392 - m395 --> m392 - m396 --> m392 - m397 --> m382 - m397 --> m388 - m397 --> m398 - m397 -.-> m400 - m397 -.-> m401 - m397 -.-> m403 - m397 --> m411 - m398 -.-> m399 - m400 --> m80 - m400 --> m397 - m401 --> m382 - m401 --> m397 - m401 -.-> m402 - m401 --> m411 - m402 --> m397 - m402 --> m401 - m403 --> m80 - m403 --> m397 - m404 --> m208 - m404 --> m210 - m404 --> m382 - m404 --> m388 - m404 --> m397 - m404 --> m411 - m404 --> m412 - m404 --> m688 + m384 -.-> m385 + m384 -.-> m386 + m384 -.-> m387 + m384 -.-> m388 + m384 --> m389 + m384 --> m408 + m384 --> m425 + m384 --> m435 + m384 --> m438 + m384 --> m439 + m384 --> m441 + m384 --> m448 + m384 --> m453 + m384 --> m455 + m384 --> m461 + m384 --> m678 + m384 --> m687 + m385 --> m384 + m386 --> m384 + m387 --> m384 + m388 --> m383 + m388 --> m384 + m388 --> m687 + m389 -.-> m390 + m391 -.-> m392 + m393 --> m39 + m393 --> m383 + m393 --> m384 + m393 -.-> m394 + m393 -.-> m395 + m393 -.-> m396 + m393 -.-> m397 + m393 --> m416 + m393 --> m678 + m393 --> m689 + m394 --> m393 + m395 --> m393 + m396 --> m393 + m397 --> m393 + m398 --> m383 + m398 --> m389 + m398 --> m399 + m398 -.-> m401 + m398 -.-> m402 + m398 -.-> m404 + m398 --> m412 + m399 -.-> m400 + m401 --> m80 + m401 --> m398 + m402 --> m383 + m402 --> m398 + m402 -.-> m403 + m402 --> m412 + m403 --> m398 + m403 --> m402 + m404 --> m80 + m404 --> m398 + m405 --> m208 m405 --> m210 - m405 --> m220 - m405 --> m382 - m405 --> m685 - m405 --> m688 - m405 --> m692 + m405 --> m383 + m405 --> m389 + m405 --> m398 + m405 --> m412 + m405 --> m413 + m405 --> m689 m406 --> m210 - m406 --> m382 - m406 --> m457 - m406 --> m468 - m406 --> m498 - m406 --> m692 - m407 --> m208 + m406 --> m220 + m406 --> m383 + m406 --> m686 + m406 --> m689 + m406 --> m693 m407 --> m210 - m407 --> m217 - m407 --> m382 m407 --> m383 - m407 --> m392 - m407 --> m457 + m407 --> m458 m407 --> m469 - m407 --> m688 + m407 --> m499 + m407 --> m693 + m408 --> m208 m408 --> m210 - m408 --> m214 - m408 -.-> m409 - m408 --> m688 - m408 --> m692 + m408 --> m217 + m408 --> m383 + m408 --> m384 + m408 --> m393 + m408 --> m458 + m408 --> m470 + m408 --> m689 + m409 --> m210 m409 --> m214 - m409 --> m408 - m410 --> m210 + m409 -.-> m410 + m409 --> m689 + m409 --> m693 m410 --> m214 - m410 --> m382 - m410 --> m406 - m410 --> m408 - m410 --> m469 - m410 --> m688 - m411 --> m80 - m411 --> m208 - m411 --> m382 - m411 --> m688 - m412 --> m382 - m412 -.-> m413 - m413 --> m404 - m413 --> m412 - m414 --> m382 - m414 --> m383 - m416 --> m382 - m416 --> m383 - m416 --> m390 - m416 --> m412 - m416 --> m447 - m416 --> m468 - m416 --> m688 - m417 --> m382 - m417 --> m406 - m417 -.-> m418 - m417 --> m419 + m410 --> m409 + m411 --> m210 + m411 --> m214 + m411 --> m383 + m411 --> m407 + m411 --> m409 + m411 --> m470 + m411 --> m689 + m412 --> m80 + m412 --> m208 + m412 --> m383 + m412 --> m689 + m413 --> m383 + m413 -.-> m414 + m414 --> m405 + m414 --> m413 + m415 --> m383 + m415 --> m384 + m417 --> m383 + m417 --> m384 + m417 --> m391 + m417 --> m413 + m417 --> m448 m417 --> m469 - m417 --> m688 - m417 --> m692 - m418 --> m417 - m418 --> m419 - m419 -.-> m420 - m420 --> m419 - m421 --> m382 - m421 --> m383 - m421 --> m392 - m422 --> m415 - m422 -.-> m423 - m422 --> m424 - m422 --> m425 - m422 --> m427 - m422 --> m428 - m422 --> m429 - m422 --> m430 - m422 --> m431 - m422 --> m447 - m422 --> m498 - m422 --> m688 - m423 --> m447 - m424 --> m422 - m424 --> m447 - m424 --> m498 - m424 --> m688 - m425 --> m382 - m425 --> m422 - m425 -.-> m426 - m425 --> m434 - m425 --> m447 - m425 --> m468 - m425 --> m498 - m425 --> m688 - m426 --> m425 - m427 --> m220 - m427 --> m382 - m427 --> m422 - m427 --> m447 - m427 --> m498 - m427 --> m596 - m427 --> m685 - m427 --> m688 - m428 --> m222 - m428 --> m382 - m428 --> m422 - m428 --> m447 - m428 --> m452 - m428 --> m498 - m428 --> m688 - m429 --> m210 - m429 --> m382 - m429 --> m422 - m429 --> m447 - m429 --> m498 - m429 --> m688 - m430 --> m382 - m430 --> m422 - m430 --> m447 - m430 --> m498 - m430 --> m688 - m431 --> m422 - m431 -.-> m432 - m431 --> m447 - m431 --> m498 - m431 --> m688 - m432 --> m431 - m433 --> m382 - m433 --> m383 - m433 --> m422 - m433 --> m423 - m433 --> m424 - m433 --> m425 - m433 --> m427 - m433 --> m428 - m433 --> m429 - m433 --> m430 - m433 --> m431 - m433 --> m434 - m433 --> m435 - m433 --> m447 - m433 --> m452 - m433 --> m468 - m433 --> m498 - m433 --> m688 - m434 --> m382 - m434 --> m468 - m434 --> m688 + m417 --> m689 + m418 --> m383 + m418 --> m407 + m418 -.-> m419 + m418 --> m420 + m418 --> m470 + m418 --> m689 + m418 --> m693 + m419 --> m418 + m419 --> m420 + m420 -.-> m421 + m421 --> m420 + m422 --> m383 + m422 --> m384 + m422 --> m393 + m423 --> m416 + m423 -.-> m424 + m423 --> m425 + m423 --> m426 + m423 --> m428 + m423 --> m429 + m423 --> m430 + m423 --> m431 + m423 --> m432 + m423 --> m448 + m423 --> m499 + m423 --> m689 + m424 --> m448 + m425 --> m423 + m425 --> m448 + m425 --> m499 + m425 --> m689 + m426 --> m383 + m426 --> m423 + m426 -.-> m427 + m426 --> m435 + m426 --> m448 + m426 --> m469 + m426 --> m499 + m426 --> m689 + m427 --> m426 + m428 --> m220 + m428 --> m383 + m428 --> m423 + m428 --> m448 + m428 --> m499 + m428 --> m597 + m428 --> m686 + m428 --> m689 + m429 --> m222 + m429 --> m383 + m429 --> m423 + m429 --> m448 + m429 --> m453 + m429 --> m499 + m429 --> m689 + m430 --> m210 + m430 --> m383 + m430 --> m423 + m430 --> m448 + m430 --> m499 + m430 --> m689 + m431 --> m383 + m431 --> m423 + m431 --> m448 + m431 --> m499 + m431 --> m689 + m432 --> m423 + m432 -.-> m433 + m432 --> m448 + m432 --> m499 + m432 --> m689 + m433 --> m432 + m434 --> m383 + m434 --> m384 + m434 --> m423 + m434 --> m424 + m434 --> m425 + m434 --> m426 + m434 --> m428 + m434 --> m429 + m434 --> m430 + m434 --> m431 + m434 --> m432 + m434 --> m435 + m434 --> m436 + m434 --> m448 + m434 --> m453 + m434 --> m469 + m434 --> m499 m434 --> m689 - m435 --> m382 - m435 --> m390 - m435 --> m412 - m435 --> m425 - m435 --> m434 - m435 --> m468 - m435 --> m688 + m435 --> m383 + m435 --> m469 m435 --> m689 - m436 --> m219 - m436 --> m468 - m436 --> m688 - m437 --> m382 - m437 --> m383 - m437 --> m392 - m437 --> m415 - m437 --> m468 - m437 --> m653 - m437 --> m677 - m437 --> m705 - m437 --> m719 - m437 --> m720 - m438 --> m382 + m435 --> m690 + m436 --> m383 + m436 --> m391 + m436 --> m413 + m436 --> m426 + m436 --> m435 + m436 --> m469 + m436 --> m689 + m436 --> m690 + m437 --> m219 + m437 --> m469 + m437 --> m689 m438 --> m383 - m438 --> m439 - m438 --> m440 - m438 -.-> m442 - m438 --> m443 - m438 -.-> m444 - m438 -.-> m445 - m438 --> m468 - m438 --> m688 - m439 --> m382 + m438 --> m384 + m438 --> m393 + m438 --> m416 + m438 --> m469 + m438 --> m654 + m438 --> m678 + m438 --> m706 + m438 --> m720 + m438 --> m721 m439 --> m383 - m439 --> m438 + m439 --> m384 m439 --> m440 - m439 --> m442 - m439 --> m443 - m439 --> m468 - m439 --> m688 - m440 --> m382 + m439 --> m441 + m439 -.-> m443 + m439 --> m444 + m439 -.-> m445 + m439 -.-> m446 + m439 --> m469 + m439 --> m689 m440 --> m383 - m440 --> m438 - m440 -.-> m441 + m440 --> m384 + m440 --> m439 + m440 --> m441 m440 --> m443 - m440 --> m688 - m441 --> m382 + m440 --> m444 + m440 --> m469 + m440 --> m689 m441 --> m383 - m441 --> m440 - m442 --> m382 + m441 --> m384 + m441 --> m439 + m441 -.-> m442 + m441 --> m444 + m441 --> m689 m442 --> m383 - m442 --> m438 - m442 --> m440 - m442 --> m443 - m442 --> m468 - m442 --> m688 - m443 --> m382 + m442 --> m384 + m442 --> m441 m443 --> m383 - m443 --> m438 - m443 --> m468 - m443 --> m688 + m443 --> m384 + m443 --> m439 + m443 --> m441 + m443 --> m444 + m443 --> m469 + m443 --> m689 m444 --> m383 - m444 --> m438 - m444 --> m442 - m444 --> m443 - m445 --> m382 - m445 --> m383 - m445 --> m438 + m444 --> m384 + m444 --> m439 + m444 --> m469 + m444 --> m689 + m445 --> m384 + m445 --> m439 m445 --> m443 m445 --> m444 - m445 --> m688 - m446 -.-> m447 - m446 -.-> m449 - m446 -.-> m451 - m447 --> m101 - m447 --> m208 - m447 --> m210 - m447 --> m222 - m447 --> m223 - m447 --> m405 - m447 --> m407 - m447 --> m408 - m447 --> m419 - m447 --> m430 + m446 --> m383 + m446 --> m384 + m446 --> m439 + m446 --> m444 + m446 --> m445 + m446 --> m689 m447 -.-> m448 - m447 --> m449 - m447 --> m451 - m447 --> m452 - m447 --> m466 - m447 --> m677 - m447 --> m690 - m447 --> m692 - m448 --> m447 - m449 -.-> m450 - m450 --> m449 - m451 --> m210 - m451 --> m214 - m451 --> m219 - m451 --> m436 - m451 --> m685 - m451 --> m690 + m447 -.-> m450 + m447 -.-> m452 + m448 --> m101 + m448 --> m208 + m448 --> m210 + m448 --> m222 + m448 --> m223 + m448 --> m406 + m448 --> m408 + m448 --> m409 + m448 --> m420 + m448 --> m431 + m448 -.-> m449 + m448 --> m450 + m448 --> m452 + m448 --> m453 + m448 --> m467 + m448 --> m678 + m448 --> m691 + m448 --> m693 + m449 --> m448 + m450 -.-> m451 + m451 --> m450 m452 --> m210 - m452 --> m222 - m452 --> m382 - m452 --> m383 - m452 --> m392 - m452 --> m688 + m452 --> m214 + m452 --> m219 + m452 --> m437 + m452 --> m686 + m452 --> m691 + m453 --> m210 m453 --> m222 - m453 --> m382 - m453 --> m406 - m453 --> m412 - m453 --> m452 - m453 --> m469 - m453 --> m688 - m454 --> m382 - m454 --> m447 - m454 -.-> m455 - m454 --> m468 - m454 --> m688 - m455 --> m454 - m456 --> m382 - m456 --> m383 - m456 --> m390 - m456 --> m392 - m456 --> m415 - m456 --> m472 - m456 --> m483 - m456 --> m498 - m456 --> m631 - m456 --> m674 - m456 --> m688 - m457 --> m205 - m457 --> m206 - m457 --> m208 - m457 --> m210 - m457 --> m214 - m457 --> m216 - m457 --> m217 - m457 --> m219 - m457 --> m220 - m457 --> m229 - m457 --> m411 - m457 --> m436 - m457 --> m449 - m457 --> m451 - m457 -.-> m458 - m457 --> m459 - m457 --> m498 - m457 --> m685 - m457 --> m690 - m457 --> m692 + m453 --> m383 + m453 --> m384 + m453 --> m393 + m453 --> m689 + m454 --> m222 + m454 --> m383 + m454 --> m407 + m454 --> m413 + m454 --> m453 + m454 --> m470 + m454 --> m689 + m455 --> m383 + m455 --> m448 + m455 -.-> m456 + m455 --> m469 + m455 --> m689 + m456 --> m455 + m457 --> m383 + m457 --> m384 + m457 --> m391 + m457 --> m393 + m457 --> m416 + m457 --> m473 + m457 --> m484 + m457 --> m499 + m457 --> m632 + m457 --> m675 + m457 --> m689 + m458 --> m205 m458 --> m206 - m458 --> m415 - m458 --> m451 - m458 --> m457 - m458 --> m498 - m458 --> m692 - m459 --> m468 - m460 --> m382 - m460 --> m383 - m460 --> m423 - m460 --> m447 - m460 --> m688 - m461 -.-> m462 - m462 --> m205 - m462 --> m210 - m462 --> m225 - m462 --> m382 - m462 --> m406 - m462 --> m412 - m462 --> m468 - m462 --> m688 - m462 --> m690 - m463 --> m223 - m463 --> m382 + m458 --> m208 + m458 --> m210 + m458 --> m214 + m458 --> m216 + m458 --> m217 + m458 --> m219 + m458 --> m220 + m458 --> m229 + m458 --> m412 + m458 --> m437 + m458 --> m450 + m458 --> m452 + m458 -.-> m459 + m458 --> m460 + m458 --> m499 + m458 --> m686 + m458 --> m691 + m458 --> m693 + m459 --> m206 + m459 --> m416 + m459 --> m452 + m459 --> m458 + m459 --> m499 + m459 --> m693 + m460 --> m469 + m461 --> m383 + m461 --> m384 + m461 --> m424 + m461 --> m448 + m461 --> m689 + m462 -.-> m463 + m463 --> m205 + m463 --> m210 + m463 --> m225 m463 --> m383 - m463 --> m456 - m463 -.-> m464 - m463 --> m688 + m463 --> m407 + m463 --> m413 + m463 --> m469 + m463 --> m689 + m463 --> m691 + m464 --> m223 m464 --> m383 - m464 --> m463 - m464 --> m688 - m465 --> m382 - m465 --> m383 - m465 --> m688 - m466 --> m210 - m466 --> m223 - m466 --> m382 - m466 -.-> m467 - m466 --> m688 - m466 --> m692 - m467 --> m466 - m469 --> m208 - m469 --> m210 - m469 --> m219 - m469 --> m222 - m469 --> m382 - m469 --> m383 - m469 --> m392 - m469 --> m404 - m469 --> m405 - m469 --> m406 - m469 --> m407 - m469 --> m410 - m469 --> m411 - m469 --> m412 - m469 --> m417 - m469 --> m434 - m469 --> m435 - m469 --> m436 - m469 --> m447 - m469 --> m452 - m469 --> m453 - m469 --> m462 - m469 --> m468 - m469 --> m470 - m469 --> m471 - m469 --> m472 - m469 --> m685 - m469 --> m688 - m469 --> m692 + m464 --> m384 + m464 --> m457 + m464 -.-> m465 + m464 --> m689 + m465 --> m384 + m465 --> m464 + m465 --> m689 + m466 --> m383 + m466 --> m384 + m466 --> m689 + m467 --> m210 + m467 --> m223 + m467 --> m383 + m467 -.-> m468 + m467 --> m689 + m467 --> m693 + m468 --> m467 + m470 --> m208 m470 --> m210 - m470 --> m382 + m470 --> m219 + m470 --> m222 + m470 --> m383 + m470 --> m384 + m470 --> m393 + m470 --> m405 m470 --> m406 - m470 --> m688 - m470 --> m691 - m470 --> m692 - m471 --> m382 - m471 --> m447 - m471 --> m468 - m471 --> m688 - m472 --> m101 - m472 --> m210 - m472 --> m214 - m472 --> m216 - m472 --> m219 - m472 --> m220 - m472 --> m222 - m472 --> m223 - m472 --> m382 + m470 --> m407 + m470 --> m408 + m470 --> m411 + m470 --> m412 + m470 --> m413 + m470 --> m418 + m470 --> m435 + m470 --> m436 + m470 --> m437 + m470 --> m448 + m470 --> m453 + m470 --> m454 + m470 --> m463 + m470 --> m469 + m470 --> m471 + m470 --> m472 + m470 --> m473 + m470 --> m686 + m470 --> m689 + m470 --> m693 + m471 --> m210 + m471 --> m383 + m471 --> m407 + m471 --> m689 + m471 --> m692 + m471 --> m693 m472 --> m383 - m472 --> m390 - m472 --> m392 - m472 --> m405 - m472 --> m407 - m472 --> m408 - m472 --> m411 - m472 --> m414 - m472 --> m416 - m472 --> m417 - m472 --> m419 - m472 --> m422 - m472 --> m425 - m472 --> m430 - m472 --> m434 - m472 --> m436 - m472 --> m447 - m472 --> m451 - m472 --> m452 - m472 --> m454 - m472 --> m457 - m472 --> m465 - m472 --> m466 - m472 --> m468 - m472 --> m471 - m472 --> m473 - m472 -.-> m474 - m472 --> m475 - m472 --> m477 - m472 --> m479 - m472 -.-> m481 - m472 --> m482 - m472 --> m677 - m472 --> m685 - m472 --> m688 + m472 --> m448 + m472 --> m469 m472 --> m689 - m472 --> m690 - m472 --> m692 + m473 --> m101 m473 --> m210 + m473 --> m214 + m473 --> m216 + m473 --> m219 m473 --> m220 - m473 --> m451 - m473 --> m457 + m473 --> m222 + m473 --> m223 + m473 --> m383 + m473 --> m384 + m473 --> m391 + m473 --> m393 + m473 --> m406 + m473 --> m408 + m473 --> m409 + m473 --> m412 + m473 --> m415 + m473 --> m417 + m473 --> m418 + m473 --> m420 + m473 --> m423 + m473 --> m426 + m473 --> m431 + m473 --> m435 + m473 --> m437 + m473 --> m448 + m473 --> m452 + m473 --> m453 + m473 --> m455 + m473 --> m458 + m473 --> m466 + m473 --> m467 + m473 --> m469 m473 --> m472 - m473 --> m688 + m473 --> m474 + m473 -.-> m475 + m473 --> m476 + m473 --> m478 + m473 --> m480 + m473 -.-> m482 + m473 --> m483 + m473 --> m678 + m473 --> m686 + m473 --> m689 + m473 --> m690 + m473 --> m691 + m473 --> m693 m474 --> m210 - m474 --> m214 - m474 --> m382 - m474 --> m472 - m474 --> m692 - m475 --> m206 + m474 --> m220 + m474 --> m452 + m474 --> m458 + m474 --> m473 + m474 --> m689 m475 --> m210 m475 --> m214 - m475 --> m382 - m475 --> m408 - m475 --> m447 - m475 --> m451 - m475 --> m457 - m475 --> m472 - m475 -.-> m476 - m475 --> m688 - m475 --> m691 - m475 --> m692 - m476 --> m451 - m476 --> m457 - m476 --> m472 - m476 --> m475 - m476 --> m688 - m476 --> m691 - m477 --> m382 - m477 --> m447 - m477 --> m466 - m477 --> m472 - m477 -.-> m478 + m475 --> m383 + m475 --> m473 + m475 --> m693 + m476 --> m206 + m476 --> m210 + m476 --> m214 + m476 --> m383 + m476 --> m409 + m476 --> m448 + m476 --> m452 + m476 --> m458 + m476 --> m473 + m476 -.-> m477 + m476 --> m689 + m476 --> m692 + m476 --> m693 + m477 --> m452 + m477 --> m458 + m477 --> m473 + m477 --> m476 + m477 --> m689 m477 --> m692 m478 --> m383 - m478 --> m447 - m478 --> m466 - m478 --> m472 - m478 --> m688 - m479 --> m206 - m479 --> m210 - m479 --> m382 - m479 --> m408 - m479 --> m447 - m479 --> m451 - m479 --> m457 - m479 --> m466 - m479 --> m472 - m479 --> m474 - m479 --> m477 - m479 -.-> m480 - m479 --> m482 - m479 --> m685 - m479 --> m688 - m479 --> m691 - m479 --> m692 - m480 --> m447 - m480 --> m472 - m480 --> m479 - m480 --> m688 + m478 --> m448 + m478 --> m467 + m478 --> m473 + m478 -.-> m479 + m478 --> m693 + m479 --> m384 + m479 --> m448 + m479 --> m467 + m479 --> m473 + m479 --> m689 + m480 --> m206 + m480 --> m210 + m480 --> m383 + m480 --> m409 + m480 --> m448 + m480 --> m452 + m480 --> m458 + m480 --> m467 + m480 --> m473 + m480 --> m475 + m480 --> m478 + m480 -.-> m481 + m480 --> m483 + m480 --> m686 + m480 --> m689 m480 --> m692 - m481 --> m383 - m481 --> m392 - m481 --> m447 - m481 --> m457 - m481 --> m472 - m481 --> m677 - m481 --> m688 - m482 --> m210 - m482 --> m447 - m482 --> m451 - m482 --> m472 - m482 --> m685 - m482 --> m688 - m482 --> m692 - m483 --> m411 - m483 -.-> m484 - m483 -.-> m485 - m483 -.-> m487 - m483 -.-> m488 - m483 -.-> m496 - m483 -.-> m498 - m483 -.-> m580 - m483 -.-> m581 - m483 -.-> m583 - m483 -.-> m584 - m483 -.-> m586 - m483 -.-> m588 - m483 -.-> m590 - m483 -.-> m592 - m483 -.-> m594 - m483 -.-> m596 - m483 -.-> m598 - m483 -.-> m600 - m483 -.-> m602 - m483 -.-> m604 - m483 -.-> m606 - m483 -.-> m607 - m483 -.-> m619 - m483 -.-> m620 - m483 -.-> m621 - m483 -.-> m623 - m483 -.-> m625 - m483 -.-> m626 - m483 -.-> m628 - m483 -.-> m630 - m483 -.-> m631 - m483 -.-> m642 - m483 -.-> m644 - m483 -.-> m654 - m483 -.-> m656 - m483 -.-> m658 - m483 -.-> m660 - m483 -.-> m674 - m483 -.-> m676 - m484 --> m222 - m484 --> m447 - m484 --> m452 - m484 --> m588 - m484 --> m602 - m484 --> m625 - m484 --> m632 - m484 --> m651 - m485 -.-> m486 - m486 --> m485 - m488 --> m208 - m488 --> m210 - m488 --> m217 - m488 --> m227 - m488 --> m388 - m488 --> m411 - m488 --> m447 - m488 --> m483 - m488 --> m487 - m488 --> m489 - m488 --> m491 - m488 --> m493 - m488 -.-> m495 - m488 --> m498 - m488 --> m610 - m488 --> m616 - m488 --> m620 - m488 --> m631 - m488 --> m632 - m488 --> m645 - m488 --> m651 - m489 --> m485 - m489 -.-> m490 - m490 --> m485 - m490 --> m489 - m491 -.-> m492 - m491 --> m498 - m491 --> m614 - m491 --> m620 - m491 --> m642 - m491 --> m645 - m491 --> m651 - m492 --> m491 - m493 --> m487 - m493 -.-> m494 - m493 --> m498 - m493 --> m614 - m493 --> m616 - m493 --> m620 - m493 --> m642 - m493 --> m645 - m493 --> m651 - m494 --> m415 - m494 --> m487 - m494 --> m493 - m494 --> m498 - m494 --> m620 - m494 --> m642 - m494 --> m644 - m494 --> m645 - m494 --> m651 - m495 --> m208 - m495 --> m210 - m495 --> m388 - m495 --> m411 - m495 --> m415 - m495 --> m447 - m495 --> m457 + m480 --> m693 + m481 --> m448 + m481 --> m473 + m481 --> m480 + m481 --> m689 + m481 --> m693 + m482 --> m384 + m482 --> m393 + m482 --> m448 + m482 --> m458 + m482 --> m473 + m482 --> m678 + m482 --> m689 + m483 --> m210 + m483 --> m448 + m483 --> m452 + m483 --> m473 + m483 --> m686 + m483 --> m689 + m483 --> m693 + m484 --> m412 + m484 -.-> m485 + m484 -.-> m486 + m484 -.-> m488 + m484 -.-> m489 + m484 -.-> m497 + m484 -.-> m499 + m484 -.-> m581 + m484 -.-> m582 + m484 -.-> m584 + m484 -.-> m585 + m484 -.-> m587 + m484 -.-> m589 + m484 -.-> m591 + m484 -.-> m593 + m484 -.-> m595 + m484 -.-> m597 + m484 -.-> m599 + m484 -.-> m601 + m484 -.-> m603 + m484 -.-> m605 + m484 -.-> m607 + m484 -.-> m608 + m484 -.-> m620 + m484 -.-> m621 + m484 -.-> m622 + m484 -.-> m624 + m484 -.-> m626 + m484 -.-> m627 + m484 -.-> m629 + m484 -.-> m631 + m484 -.-> m632 + m484 -.-> m643 + m484 -.-> m645 + m484 -.-> m655 + m484 -.-> m657 + m484 -.-> m659 + m484 -.-> m661 + m484 -.-> m675 + m484 -.-> m677 + m485 --> m222 + m485 --> m448 + m485 --> m453 + m485 --> m589 + m485 --> m603 + m485 --> m626 + m485 --> m633 + m485 --> m652 + m486 -.-> m487 + m487 --> m486 + m489 --> m208 + m489 --> m210 + m489 --> m217 + m489 --> m227 + m489 --> m389 + m489 --> m412 + m489 --> m448 + m489 --> m484 + m489 --> m488 + m489 --> m490 + m489 --> m492 + m489 --> m494 + m489 -.-> m496 + m489 --> m499 + m489 --> m611 + m489 --> m617 + m489 --> m621 + m489 --> m632 + m489 --> m633 + m489 --> m646 + m489 --> m652 + m490 --> m486 + m490 -.-> m491 + m491 --> m486 + m491 --> m490 + m492 -.-> m493 + m492 --> m499 + m492 --> m615 + m492 --> m621 + m492 --> m643 + m492 --> m646 + m492 --> m652 + m493 --> m492 + m494 --> m488 + m494 -.-> m495 + m494 --> m499 + m494 --> m615 + m494 --> m617 + m494 --> m621 + m494 --> m643 + m494 --> m646 + m494 --> m652 + m495 --> m416 m495 --> m488 - m495 --> m493 - m495 --> m498 - m495 --> m632 - m495 --> m644 - m495 --> m651 - m496 --> m485 - m496 -.-> m497 - m497 --> m485 - m497 --> m496 - m498 --> m415 - m498 --> m496 - m498 --> m499 - m498 --> m507 - m498 --> m515 - m498 --> m523 - m498 --> m531 - m498 --> m539 - m498 --> m547 - m498 --> m555 - m498 -.-> m563 - m498 --> m564 - m498 --> m572 + m495 --> m494 + m495 --> m499 + m495 --> m621 + m495 --> m643 + m495 --> m645 + m495 --> m646 + m495 --> m652 + m496 --> m208 + m496 --> m210 + m496 --> m389 + m496 --> m412 + m496 --> m416 + m496 --> m448 + m496 --> m458 + m496 --> m489 + m496 --> m494 + m496 --> m499 + m496 --> m633 + m496 --> m645 + m496 --> m652 + m497 --> m486 + m497 -.-> m498 + m498 --> m486 + m498 --> m497 + m499 --> m416 + m499 --> m497 m499 --> m500 - m499 --> m501 - m499 --> m502 - m499 --> m503 - m499 --> m504 - m499 --> m505 - m499 --> m506 - m507 --> m508 - m507 --> m509 - m507 --> m510 - m507 --> m511 - m507 --> m512 - m507 --> m513 - m507 --> m514 - m515 --> m516 - m515 --> m517 - m515 --> m518 - m515 --> m519 - m515 --> m520 - m515 --> m521 - m515 --> m522 - m523 --> m524 - m523 --> m525 - m523 --> m526 - m523 --> m527 - m523 --> m528 - m523 --> m529 - m523 --> m530 - m531 --> m532 - m531 --> m533 - m531 --> m534 - m531 --> m535 - m531 --> m536 - m531 --> m537 - m531 --> m538 - m539 --> m540 - m539 --> m541 - m539 --> m542 - m539 --> m543 - m539 --> m544 - m539 --> m545 - m539 --> m546 - m547 --> m548 - m547 --> m549 - m547 --> m550 - m547 --> m551 - m547 --> m552 - m547 --> m553 - m547 --> m554 - m555 --> m556 - m555 --> m557 - m555 --> m558 - m555 --> m559 - m555 --> m560 - m555 --> m561 - m555 --> m562 - m563 --> m210 - m563 --> m382 - m563 --> m415 - m563 --> m471 - m563 --> m498 - m563 --> m499 - m563 --> m507 - m563 --> m515 - m563 --> m523 - m563 --> m531 - m563 --> m539 - m563 --> m547 - m563 --> m555 - m563 --> m564 - m563 --> m572 - m563 --> m623 + m499 --> m508 + m499 --> m516 + m499 --> m524 + m499 --> m532 + m499 --> m540 + m499 --> m548 + m499 --> m556 + m499 -.-> m564 + m499 --> m565 + m499 --> m573 + m500 --> m501 + m500 --> m502 + m500 --> m503 + m500 --> m504 + m500 --> m505 + m500 --> m506 + m500 --> m507 + m508 --> m509 + m508 --> m510 + m508 --> m511 + m508 --> m512 + m508 --> m513 + m508 --> m514 + m508 --> m515 + m516 --> m517 + m516 --> m518 + m516 --> m519 + m516 --> m520 + m516 --> m521 + m516 --> m522 + m516 --> m523 + m524 --> m525 + m524 --> m526 + m524 --> m527 + m524 --> m528 + m524 --> m529 + m524 --> m530 + m524 --> m531 + m532 --> m533 + m532 --> m534 + m532 --> m535 + m532 --> m536 + m532 --> m537 + m532 --> m538 + m532 --> m539 + m540 --> m541 + m540 --> m542 + m540 --> m543 + m540 --> m544 + m540 --> m545 + m540 --> m546 + m540 --> m547 + m548 --> m549 + m548 --> m550 + m548 --> m551 + m548 --> m552 + m548 --> m553 + m548 --> m554 + m548 --> m555 + m556 --> m557 + m556 --> m558 + m556 --> m559 + m556 --> m560 + m556 --> m561 + m556 --> m562 + m556 --> m563 + m564 --> m210 + m564 --> m383 + m564 --> m416 + m564 --> m472 + m564 --> m499 + m564 --> m500 + m564 --> m508 + m564 --> m516 + m564 --> m524 + m564 --> m532 + m564 --> m540 + m564 --> m548 + m564 --> m556 m564 --> m565 - m564 --> m566 - m564 --> m567 - m564 --> m568 - m564 --> m569 - m564 --> m570 - m564 --> m571 - m572 --> m573 - m572 --> m574 - m572 --> m575 - m572 --> m576 - m572 --> m577 - m572 --> m578 - m572 --> m579 - m580 --> m447 - m580 --> m588 - m580 --> m602 - m580 --> m614 - m580 --> m632 - m580 --> m651 - m581 --> m447 - m581 --> m498 - m581 -.-> m582 - m582 --> m415 - m582 --> m447 - m582 --> m498 - m582 --> m581 - m583 --> m415 - m583 --> m498 - m583 --> m588 - m583 --> m602 - m583 --> m632 - m583 --> m651 - m584 -.-> m585 - m584 --> m631 - m584 --> m632 - m584 --> m642 - m585 --> m584 + m564 --> m573 + m564 --> m624 + m565 --> m566 + m565 --> m567 + m565 --> m568 + m565 --> m569 + m565 --> m570 + m565 --> m571 + m565 --> m572 + m573 --> m574 + m573 --> m575 + m573 --> m576 + m573 --> m577 + m573 --> m578 + m573 --> m579 + m573 --> m580 + m581 --> m448 + m581 --> m589 + m581 --> m603 + m581 --> m615 + m581 --> m633 + m581 --> m652 + m582 --> m448 + m582 --> m499 + m582 -.-> m583 + m583 --> m416 + m583 --> m448 + m583 --> m499 + m583 --> m582 + m584 --> m416 + m584 --> m499 + m584 --> m589 + m584 --> m603 + m584 --> m633 + m584 --> m652 + m585 -.-> m586 m585 --> m632 - m586 --> m210 - m586 --> m451 - m586 --> m468 - m586 --> m498 - m586 -.-> m587 - m586 --> m588 - m586 --> m602 - m586 --> m610 - m586 --> m632 - m586 --> m651 - m587 --> m451 - m587 --> m586 - m587 --> m602 - m587 --> m610 - m587 --> m614 - m587 --> m632 - m587 --> m651 - m588 --> m498 - m588 --> m584 - m588 -.-> m589 - m588 --> m614 - m588 --> m620 - m588 --> m632 - m588 --> m642 - m588 --> m645 - m588 --> m651 - m589 --> m588 - m589 --> m614 - m589 --> m632 - m589 --> m651 - m590 --> m422 - m590 --> m447 - m590 --> m468 - m590 --> m498 - m590 --> m588 - m590 -.-> m591 - m590 --> m602 - m590 --> m614 - m590 --> m620 - m590 --> m632 - m590 --> m645 - m590 --> m651 - m591 --> m447 - m591 --> m590 - m591 --> m602 - m591 --> m614 - m591 --> m632 - m591 --> m651 - m592 --> m223 - m592 --> m447 - m592 --> m498 - m592 --> m588 - m592 -.-> m593 - m592 --> m602 - m592 --> m614 - m592 --> m620 - m592 --> m632 - m592 --> m642 - m592 --> m645 - m592 --> m651 - m593 --> m447 - m593 --> m592 - m593 --> m614 - m593 --> m632 - m593 --> m651 - m594 --> m451 - m594 --> m498 - m594 -.-> m595 - m595 --> m594 - m596 --> m447 - m596 --> m468 - m596 --> m498 - m596 --> m584 - m596 -.-> m597 - m596 --> m602 - m596 --> m604 - m596 --> m612 - m596 --> m614 - m596 --> m620 - m596 --> m632 - m596 --> m642 - m596 --> m645 - m596 --> m651 - m597 --> m447 - m597 --> m584 - m597 --> m596 - m597 --> m602 - m597 --> m614 - m597 --> m632 - m597 --> m651 - m598 --> m447 - m598 --> m498 - m598 -.-> m599 - m598 --> m602 - m598 --> m614 - m598 --> m620 - m598 --> m621 - m598 --> m632 - m598 --> m642 - m598 --> m645 - m598 --> m651 - m599 --> m447 - m599 --> m598 - m599 --> m602 - m599 --> m614 - m599 --> m632 - m599 --> m651 - m600 --> m594 - m600 -.-> m601 - m600 --> m628 - m600 --> m636 - m600 --> m649 - m601 --> m600 - m601 --> m628 - m601 --> m636 - m601 --> m649 - m602 --> m210 - m602 --> m219 - m602 --> m222 - m602 --> m223 - m602 --> m405 - m602 --> m407 - m602 --> m415 - m602 --> m436 - m602 --> m447 - m602 --> m451 - m602 --> m468 - m602 --> m498 - m602 --> m584 - m602 -.-> m603 - m602 --> m614 - m602 --> m625 - m602 --> m632 - m602 --> m642 - m602 --> m645 - m602 --> m651 - m602 --> m656 - m602 --> m690 + m585 --> m633 + m585 --> m643 + m586 --> m585 + m586 --> m633 + m587 --> m210 + m587 --> m452 + m587 --> m469 + m587 --> m499 + m587 -.-> m588 + m587 --> m589 + m587 --> m603 + m587 --> m611 + m587 --> m633 + m587 --> m652 + m588 --> m452 + m588 --> m587 + m588 --> m603 + m588 --> m611 + m588 --> m615 + m588 --> m633 + m588 --> m652 + m589 --> m499 + m589 --> m585 + m589 -.-> m590 + m589 --> m615 + m589 --> m621 + m589 --> m633 + m589 --> m643 + m589 --> m646 + m589 --> m652 + m590 --> m589 + m590 --> m615 + m590 --> m633 + m590 --> m652 + m591 --> m423 + m591 --> m448 + m591 --> m469 + m591 --> m499 + m591 --> m589 + m591 -.-> m592 + m591 --> m603 + m591 --> m615 + m591 --> m621 + m591 --> m633 + m591 --> m646 + m591 --> m652 + m592 --> m448 + m592 --> m591 + m592 --> m603 + m592 --> m615 + m592 --> m633 + m592 --> m652 + m593 --> m223 + m593 --> m448 + m593 --> m499 + m593 --> m589 + m593 -.-> m594 + m593 --> m603 + m593 --> m615 + m593 --> m621 + m593 --> m633 + m593 --> m643 + m593 --> m646 + m593 --> m652 + m594 --> m448 + m594 --> m593 + m594 --> m615 + m594 --> m633 + m594 --> m652 + m595 --> m452 + m595 --> m499 + m595 -.-> m596 + m596 --> m595 + m597 --> m448 + m597 --> m469 + m597 --> m499 + m597 --> m585 + m597 -.-> m598 + m597 --> m603 + m597 --> m605 + m597 --> m613 + m597 --> m615 + m597 --> m621 + m597 --> m633 + m597 --> m643 + m597 --> m646 + m597 --> m652 + m598 --> m448 + m598 --> m585 + m598 --> m597 + m598 --> m603 + m598 --> m615 + m598 --> m633 + m598 --> m652 + m599 --> m448 + m599 --> m499 + m599 -.-> m600 + m599 --> m603 + m599 --> m615 + m599 --> m621 + m599 --> m622 + m599 --> m633 + m599 --> m643 + m599 --> m646 + m599 --> m652 + m600 --> m448 + m600 --> m599 + m600 --> m603 + m600 --> m615 + m600 --> m633 + m600 --> m652 + m601 --> m595 + m601 -.-> m602 + m601 --> m629 + m601 --> m637 + m601 --> m650 + m602 --> m601 + m602 --> m629 + m602 --> m637 + m602 --> m650 m603 --> m210 m603 --> m219 - m603 --> m602 - m603 --> m632 - m603 --> m644 - m603 --> m651 - m603 --> m690 - m604 --> m447 - m604 --> m498 - m604 --> m584 - m604 --> m588 - m604 --> m596 - m604 --> m602 - m604 -.-> m605 - m604 --> m614 - m604 --> m620 - m604 --> m632 - m604 --> m642 + m603 --> m222 + m603 --> m223 + m603 --> m406 + m603 --> m408 + m603 --> m416 + m603 --> m437 + m603 --> m448 + m603 --> m452 + m603 --> m469 + m603 --> m499 + m603 --> m585 + m603 -.-> m604 + m603 --> m615 + m603 --> m626 + m603 --> m633 + m603 --> m643 + m603 --> m646 + m603 --> m652 + m603 --> m657 + m603 --> m691 + m604 --> m210 + m604 --> m219 + m604 --> m603 + m604 --> m633 m604 --> m645 - m604 --> m651 - m605 --> m447 - m605 --> m584 - m605 --> m602 - m605 --> m604 - m605 --> m632 - m605 --> m651 - m606 --> m451 - m606 --> m468 - m606 --> m498 - m606 --> m588 - m606 --> m602 - m606 --> m632 - m606 --> m651 - m607 --> m608 - m607 -.-> m610 - m607 -.-> m612 - m607 -.-> m614 - m607 --> m616 - m607 -.-> m618 - m608 --> m498 - m608 --> m607 - m608 -.-> m609 - m608 --> m614 - m608 --> m616 - m608 --> m632 - m608 --> m642 - m608 --> m645 - m608 --> m651 + m604 --> m652 + m604 --> m691 + m605 --> m448 + m605 --> m499 + m605 --> m585 + m605 --> m589 + m605 --> m597 + m605 --> m603 + m605 -.-> m606 + m605 --> m615 + m605 --> m621 + m605 --> m633 + m605 --> m643 + m605 --> m646 + m605 --> m652 + m606 --> m448 + m606 --> m585 + m606 --> m603 + m606 --> m605 + m606 --> m633 + m606 --> m652 + m607 --> m452 + m607 --> m469 + m607 --> m499 + m607 --> m589 + m607 --> m603 + m607 --> m633 + m607 --> m652 + m608 --> m609 + m608 -.-> m611 + m608 -.-> m613 + m608 -.-> m615 + m608 --> m617 + m608 -.-> m619 + m609 --> m499 m609 --> m608 - m609 --> m612 - m609 --> m614 - m609 --> m616 - m609 --> m618 - m609 --> m632 - m609 --> m644 - m609 --> m651 - m610 -.-> m611 - m610 --> m642 - m610 --> m644 + m609 -.-> m610 + m609 --> m615 + m609 --> m617 + m609 --> m633 + m609 --> m643 + m609 --> m646 + m609 --> m652 + m610 --> m609 + m610 --> m613 + m610 --> m615 + m610 --> m617 + m610 --> m619 + m610 --> m633 m610 --> m645 - m610 --> m651 - m611 --> m610 - m611 --> m614 - m611 --> m644 - m611 --> m651 - m612 -.-> m613 - m613 --> m612 - m614 -.-> m615 - m614 --> m642 - m614 --> m645 - m614 --> m651 - m615 --> m614 - m615 --> m644 - m615 --> m651 - m616 --> m607 - m616 --> m610 - m616 -.-> m617 - m617 --> m612 - m617 --> m616 - m617 --> m618 - m619 --> m223 - m619 --> m382 - m619 --> m390 - m619 --> m398 - m619 --> m466 - m619 --> m468 - m619 --> m498 - m619 --> m584 - m619 --> m614 - m619 --> m632 - m619 --> m642 - m619 --> m645 - m619 --> m651 - m620 --> m487 - m620 --> m498 - m620 --> m614 - m620 --> m642 - m620 --> m645 - m620 --> m651 - m621 --> m447 - m621 --> m498 - m621 --> m602 - m621 --> m614 - m621 --> m620 - m621 -.-> m622 - m621 --> m632 - m621 --> m642 - m621 --> m645 - m621 --> m651 - m622 --> m447 - m622 --> m602 - m622 --> m614 + m610 --> m652 + m611 -.-> m612 + m611 --> m643 + m611 --> m645 + m611 --> m646 + m611 --> m652 + m612 --> m611 + m612 --> m615 + m612 --> m645 + m612 --> m652 + m613 -.-> m614 + m614 --> m613 + m615 -.-> m616 + m615 --> m643 + m615 --> m646 + m615 --> m652 + m616 --> m615 + m616 --> m645 + m616 --> m652 + m617 --> m608 + m617 --> m611 + m617 -.-> m618 + m618 --> m613 + m618 --> m617 + m618 --> m619 + m620 --> m223 + m620 --> m383 + m620 --> m391 + m620 --> m399 + m620 --> m467 + m620 --> m469 + m620 --> m499 + m620 --> m585 + m620 --> m615 + m620 --> m633 + m620 --> m643 + m620 --> m646 + m620 --> m652 + m621 --> m488 + m621 --> m499 + m621 --> m615 + m621 --> m643 + m621 --> m646 + m621 --> m652 + m622 --> m448 + m622 --> m499 + m622 --> m603 + m622 --> m615 m622 --> m621 - m622 --> m632 - m622 --> m651 - m623 --> m447 - m623 --> m468 - m623 --> m483 - m623 --> m498 - m623 --> m588 - m623 --> m602 - m623 -.-> m624 - m623 --> m632 - m623 --> m651 - m624 --> m447 - m624 --> m602 - m624 --> m614 - m624 --> m623 - m624 --> m632 - m624 --> m651 - m625 --> m447 - m625 --> m498 - m625 --> m588 - m625 --> m602 - m625 --> m632 - m625 --> m651 - m625 --> m673 - m626 --> m449 - m626 -.-> m627 - m627 --> m626 - m628 --> m451 - m628 --> m498 - m628 -.-> m629 - m629 --> m451 - m629 --> m628 - m629 --> m690 - m630 --> m210 - m630 --> m451 - m630 --> m468 - m630 --> m498 - m630 --> m588 - m630 --> m602 - m630 --> m610 - m630 --> m614 - m630 --> m620 - m630 --> m632 - m630 --> m642 - m630 --> m645 - m630 --> m651 - m630 --> m661 - m630 --> m663 - m630 --> m673 - m630 --> m685 - m631 --> m632 - m631 --> m634 - m631 --> m636 - m631 -.-> m638 - m631 --> m639 - m631 --> m640 - m631 --> m658 - m632 --> m401 - m632 -.-> m633 - m633 --> m632 - m634 --> m628 - m634 -.-> m635 - m635 --> m634 - m636 -.-> m637 - m637 --> m636 - m639 --> m631 - m639 --> m636 - m640 --> m631 - m640 --> m636 - m640 -.-> m641 - m641 --> m640 - m642 -.-> m643 - m643 --> m642 - m644 -.-> m645 - m644 --> m647 - m644 --> m649 - m644 --> m651 - m644 -.-> m652 - m644 --> m653 + m622 -.-> m623 + m622 --> m633 + m622 --> m643 + m622 --> m646 + m622 --> m652 + m623 --> m448 + m623 --> m603 + m623 --> m615 + m623 --> m622 + m623 --> m633 + m623 --> m652 + m624 --> m448 + m624 --> m469 + m624 --> m484 + m624 --> m499 + m624 --> m589 + m624 --> m603 + m624 -.-> m625 + m624 --> m633 + m624 --> m652 + m625 --> m448 + m625 --> m603 + m625 --> m615 + m625 --> m624 + m625 --> m633 + m625 --> m652 + m626 --> m448 + m626 --> m499 + m626 --> m589 + m626 --> m603 + m626 --> m633 + m626 --> m652 + m626 --> m674 + m627 --> m450 + m627 -.-> m628 + m628 --> m627 + m629 --> m452 + m629 --> m499 + m629 -.-> m630 + m630 --> m452 + m630 --> m629 + m630 --> m691 + m631 --> m210 + m631 --> m452 + m631 --> m469 + m631 --> m499 + m631 --> m589 + m631 --> m603 + m631 --> m611 + m631 --> m615 + m631 --> m621 + m631 --> m633 + m631 --> m643 + m631 --> m646 + m631 --> m652 + m631 --> m662 + m631 --> m664 + m631 --> m674 + m631 --> m686 + m632 --> m633 + m632 --> m635 + m632 --> m637 + m632 -.-> m639 + m632 --> m640 + m632 --> m641 + m632 --> m659 + m633 --> m402 + m633 -.-> m634 + m634 --> m633 + m635 --> m629 + m635 -.-> m636 + m636 --> m635 + m637 -.-> m638 + m638 --> m637 + m640 --> m632 + m640 --> m637 + m641 --> m632 + m641 --> m637 + m641 -.-> m642 + m642 --> m641 + m643 -.-> m644 + m644 --> m643 m645 -.-> m646 - m646 --> m645 - m647 -.-> m648 - m648 --> m647 - m649 -.-> m650 - m649 --> m651 - m650 --> m649 - m652 --> m644 - m652 --> m647 - m652 --> m651 - m654 --> m496 - m654 --> m498 - m654 --> m588 - m654 --> m602 - m654 --> m632 - m654 --> m651 - m654 --> m653 - m654 -.-> m655 - m655 --> m644 - m655 --> m651 + m645 --> m648 + m645 --> m650 + m645 --> m652 + m645 -.-> m653 + m645 --> m654 + m646 -.-> m647 + m647 --> m646 + m648 -.-> m649 + m649 --> m648 + m650 -.-> m651 + m650 --> m652 + m651 --> m650 + m653 --> m645 + m653 --> m648 + m653 --> m652 + m655 --> m497 + m655 --> m499 + m655 --> m589 + m655 --> m603 + m655 --> m633 + m655 --> m652 m655 --> m654 - m656 --> m451 - m656 --> m468 - m656 --> m498 - m656 --> m588 - m656 --> m602 - m656 --> m614 - m656 --> m632 - m656 --> m642 + m655 -.-> m656 m656 --> m645 - m656 --> m651 - m656 -.-> m657 - m657 --> m451 - m657 --> m632 - m657 --> m656 - m658 --> m628 - m658 -.-> m659 - m659 --> m628 - m659 --> m658 - m660 -.-> m661 - m660 -.-> m663 - m660 -.-> m665 - m660 -.-> m667 - m660 -.-> m669 - m660 -.-> m671 - m660 -.-> m673 - m661 --> m447 - m661 --> m449 - m661 --> m451 - m661 --> m498 + m656 --> m652 + m656 --> m655 + m657 --> m452 + m657 --> m469 + m657 --> m499 + m657 --> m589 + m657 --> m603 + m657 --> m615 + m657 --> m633 + m657 --> m643 + m657 --> m646 + m657 --> m652 + m657 -.-> m658 + m658 --> m452 + m658 --> m633 + m658 --> m657 + m659 --> m629 + m659 -.-> m660 + m660 --> m629 + m660 --> m659 m661 -.-> m662 - m661 --> m673 - m662 --> m64 - m662 --> m208 - m662 --> m451 - m662 --> m610 - m662 --> m642 - m662 --> m644 - m662 --> m651 - m662 --> m661 - m662 --> m663 - m662 --> m673 - m663 --> m227 - m663 --> m449 - m663 --> m451 - m663 --> m457 - m663 --> m466 - m663 --> m468 - m663 --> m498 - m663 --> m596 - m663 --> m610 - m663 --> m614 - m663 --> m642 + m661 -.-> m664 + m661 -.-> m666 + m661 -.-> m668 + m661 -.-> m670 + m661 -.-> m672 + m661 -.-> m674 + m662 --> m448 + m662 --> m450 + m662 --> m452 + m662 --> m499 + m662 -.-> m663 + m662 --> m674 + m663 --> m64 + m663 --> m208 + m663 --> m452 + m663 --> m611 + m663 --> m643 m663 --> m645 - m663 --> m651 - m663 --> m661 - m663 -.-> m664 - m663 --> m673 - m664 --> m210 - m664 --> m663 - m665 -.-> m666 - m666 --> m665 - m667 -.-> m668 - m668 --> m667 - m669 -.-> m670 - m670 --> m669 - m671 --> m669 - m671 -.-> m672 - m672 --> m663 - m672 --> m671 - m673 --> m451 - m673 --> m468 - m673 --> m498 - m673 --> m642 - m673 --> m645 - m673 --> m651 - m674 --> m39 - m674 --> m208 - m674 --> m210 - m674 --> m214 - m674 --> m222 - m674 --> m227 - m674 --> m382 - m674 --> m388 - m674 --> m390 - m674 --> m397 - m674 --> m398 - m674 --> m401 - m674 --> m407 - m674 --> m408 - m674 --> m411 - m674 --> m419 - m674 --> m422 - m674 --> m423 - m674 --> m447 - m674 --> m449 - m674 --> m451 + m663 --> m652 + m663 --> m662 + m663 --> m664 + m663 --> m674 + m664 --> m227 + m664 --> m450 + m664 --> m452 + m664 --> m458 + m664 --> m467 + m664 --> m469 + m664 --> m499 + m664 --> m597 + m664 --> m611 + m664 --> m615 + m664 --> m643 + m664 --> m646 + m664 --> m652 + m664 --> m662 + m664 -.-> m665 + m664 --> m674 + m665 --> m210 + m665 --> m664 + m666 -.-> m667 + m667 --> m666 + m668 -.-> m669 + m669 --> m668 + m670 -.-> m671 + m671 --> m670 + m672 --> m670 + m672 -.-> m673 + m673 --> m664 + m673 --> m672 m674 --> m452 - m674 --> m457 - m674 --> m466 - m674 --> m468 - m674 --> m471 - m674 --> m483 - m674 --> m484 - m674 --> m487 - m674 --> m488 - m674 --> m489 - m674 --> m493 - m674 --> m496 - m674 --> m498 - m674 --> m580 - m674 --> m581 - m674 --> m583 - m674 --> m586 - m674 --> m588 - m674 --> m590 - m674 --> m592 - m674 --> m594 - m674 --> m596 - m674 --> m598 - m674 --> m600 - m674 --> m602 - m674 --> m604 - m674 --> m606 - m674 --> m607 - m674 --> m608 - m674 --> m610 - m674 --> m614 - m674 --> m616 - m674 --> m619 - m674 --> m621 - m674 --> m623 - m674 --> m625 - m674 --> m626 - m674 --> m628 - m674 --> m630 - m674 --> m631 - m674 --> m632 - m674 --> m642 - m674 --> m644 - m674 --> m645 - m674 --> m649 - m674 --> m651 - m674 --> m654 - m674 --> m656 - m674 --> m658 - m674 --> m661 - m674 --> m663 - m674 --> m665 - m674 --> m667 - m674 --> m671 - m674 --> m673 - m674 -.-> m675 - m674 --> m676 - m674 --> m677 - m674 --> m682 - m674 --> m690 - m674 --> m692 - m675 --> m101 + m674 --> m469 + m674 --> m499 + m674 --> m643 + m674 --> m646 + m674 --> m652 + m675 --> m39 m675 --> m208 m675 --> m210 - m675 --> m220 - m675 --> m397 - m675 --> m405 + m675 --> m214 + m675 --> m222 + m675 --> m227 + m675 --> m383 + m675 --> m389 + m675 --> m391 + m675 --> m398 + m675 --> m399 + m675 --> m402 m675 --> m408 - m675 --> m415 - m675 --> m419 + m675 --> m409 + m675 --> m412 + m675 --> m420 m675 --> m423 - m675 --> m447 - m675 --> m449 - m675 --> m451 - m675 --> m457 - m675 --> m466 - m675 --> m483 + m675 --> m424 + m675 --> m448 + m675 --> m450 + m675 --> m452 + m675 --> m453 + m675 --> m458 + m675 --> m467 + m675 --> m469 + m675 --> m472 + m675 --> m484 + m675 --> m485 m675 --> m488 - m675 --> m493 - m675 --> m498 - m675 --> m580 - m675 --> m586 - m675 --> m590 - m675 --> m596 - m675 --> m602 + m675 --> m489 + m675 --> m490 + m675 --> m494 + m675 --> m497 + m675 --> m499 + m675 --> m581 + m675 --> m582 + m675 --> m584 + m675 --> m587 + m675 --> m589 + m675 --> m591 + m675 --> m593 + m675 --> m595 + m675 --> m597 + m675 --> m599 + m675 --> m601 + m675 --> m603 + m675 --> m605 m675 --> m607 m675 --> m608 - m675 --> m610 - m675 --> m614 - m675 --> m616 - m675 --> m618 - m675 --> m623 - m675 --> m625 + m675 --> m609 + m675 --> m611 + m675 --> m615 + m675 --> m617 + m675 --> m620 + m675 --> m622 + m675 --> m624 m675 --> m626 - m675 --> m630 + m675 --> m627 + m675 --> m629 + m675 --> m631 m675 --> m632 - m675 --> m644 - m675 --> m656 - m675 --> m661 - m675 --> m663 - m675 --> m673 + m675 --> m633 + m675 --> m643 + m675 --> m645 + m675 --> m646 + m675 --> m650 + m675 --> m652 + m675 --> m655 + m675 --> m657 + m675 --> m659 + m675 --> m662 + m675 --> m664 + m675 --> m666 + m675 --> m668 + m675 --> m672 m675 --> m674 + m675 -.-> m676 m675 --> m677 - m675 --> m690 - m675 --> m692 - m676 --> m468 - m676 --> m498 - m676 --> m602 - m676 --> m614 - m676 --> m632 - m676 --> m642 + m675 --> m678 + m675 --> m683 + m675 --> m691 + m675 --> m693 + m676 --> m101 + m676 --> m208 + m676 --> m210 + m676 --> m220 + m676 --> m398 + m676 --> m406 + m676 --> m409 + m676 --> m416 + m676 --> m420 + m676 --> m424 + m676 --> m448 + m676 --> m450 + m676 --> m452 + m676 --> m458 + m676 --> m467 + m676 --> m484 + m676 --> m489 + m676 --> m494 + m676 --> m499 + m676 --> m581 + m676 --> m587 + m676 --> m591 + m676 --> m597 + m676 --> m603 + m676 --> m608 + m676 --> m609 + m676 --> m611 + m676 --> m615 + m676 --> m617 + m676 --> m619 + m676 --> m624 + m676 --> m626 + m676 --> m627 + m676 --> m631 + m676 --> m633 m676 --> m645 - m676 --> m651 - m676 --> m677 - m677 --> m39 - m677 --> m73 - m677 --> m382 - m677 --> m392 - m677 --> m456 + m676 --> m657 + m676 --> m662 + m676 --> m664 + m676 --> m674 + m676 --> m675 + m676 --> m678 + m676 --> m691 + m676 --> m693 + m677 --> m469 + m677 --> m499 + m677 --> m603 + m677 --> m615 + m677 --> m633 + m677 --> m643 + m677 --> m646 + m677 --> m652 m677 --> m678 - m677 -.-> m680 m678 --> m39 m678 --> m73 - m678 --> m677 - m678 -.-> m679 - m679 --> m677 + m678 --> m383 + m678 --> m393 + m678 --> m457 + m678 --> m679 + m678 -.-> m681 + m679 --> m39 + m679 --> m73 m679 --> m678 - m680 --> m677 - m681 --> m382 - m681 --> m392 - m681 --> m415 - m683 --> m382 - m683 -.-> m684 - m684 --> m683 - m685 --> m216 - m685 --> m220 - m685 --> m223 - m685 --> m229 - m685 --> m682 - m685 --> m688 - m686 --> m382 - m686 --> m468 - m686 --> m623 - m686 -.-> m687 - m686 --> m688 - m687 --> m686 - m688 -.-> m689 - m688 -.-> m690 - m688 -.-> m691 - m688 -.-> m692 - m689 --> m688 - m690 --> m210 - m690 --> m229 - m690 --> m688 - m691 --> m688 - m691 --> m692 - m692 --> m205 - m692 --> m206 - m692 --> m208 - m692 --> m210 - m692 --> m216 - m692 --> m220 - m692 --> m222 - m692 --> m223 - m692 --> m225 - m692 --> m688 - m693 --> m161 - m693 --> m176 - m693 --> m178 - m693 --> m334 - m693 --> m694 - m693 -.-> m697 - m693 -.-> m699 - m693 --> m700 - m693 --> m702 - m694 --> m109 - m694 --> m126 - m694 --> m163 - m694 --> m164 - m694 --> m166 - m694 --> m168 - m694 --> m169 + m679 -.-> m680 + m680 --> m678 + m680 --> m679 + m681 --> m678 + m682 --> m383 + m682 --> m393 + m682 --> m416 + m684 --> m383 + m684 -.-> m685 + m685 --> m684 + m686 --> m216 + m686 --> m220 + m686 --> m223 + m686 --> m229 + m686 --> m683 + m686 --> m689 + m687 --> m383 + m687 --> m469 + m687 --> m624 + m687 -.-> m688 + m687 --> m689 + m688 --> m687 + m689 -.-> m690 + m689 -.-> m691 + m689 -.-> m692 + m689 -.-> m693 + m690 --> m689 + m691 --> m210 + m691 --> m229 + m691 --> m689 + m692 --> m689 + m692 --> m693 + m693 --> m205 + m693 --> m206 + m693 --> m208 + m693 --> m210 + m693 --> m216 + m693 --> m220 + m693 --> m222 + m693 --> m223 + m693 --> m225 + m693 --> m689 + m694 --> m161 m694 --> m176 - m694 --> m184 - m694 --> m185 - m694 --> m187 - m694 --> m207 - m694 --> m210 - m694 --> m214 + m694 --> m178 m694 --> m334 m694 --> m695 - m694 -.-> m696 - m694 --> m697 - m694 --> m699 - m694 --> m702 + m694 -.-> m698 + m694 -.-> m700 + m694 --> m701 + m694 --> m703 + m695 --> m109 + m695 --> m126 + m695 --> m163 + m695 --> m164 + m695 --> m166 + m695 --> m168 m695 --> m169 + m695 --> m176 m695 --> m184 m695 --> m185 + m695 --> m187 m695 --> m207 m695 --> m210 - m695 --> m697 - m695 --> m702 + m695 --> m214 + m695 --> m334 + m695 --> m696 + m695 -.-> m697 + m695 --> m698 + m695 --> m700 + m695 --> m703 m696 --> m169 + m696 --> m184 m696 --> m185 - m696 --> m694 - m696 --> m695 - m697 --> m210 - m697 -.-> m698 - m697 --> m702 + m696 --> m207 + m696 --> m210 + m696 --> m698 + m696 --> m703 + m697 --> m169 + m697 --> m185 + m697 --> m695 + m697 --> m696 m698 --> m210 - m698 --> m697 - m698 --> m702 - m699 --> m126 - m699 --> m169 - m699 --> m185 - m699 --> m214 - m699 --> m695 - m699 --> m697 - m699 --> m702 - m700 --> m72 - m700 --> m85 - m700 --> m96 + m698 -.-> m699 + m698 --> m703 + m699 --> m210 + m699 --> m698 + m699 --> m703 m700 --> m126 - m700 --> m136 - m700 --> m163 - m700 --> m176 - m700 --> m187 - m700 --> m210 - m700 --> m229 - m700 --> m694 - m700 -.-> m701 - m700 --> m702 - m701 --> m700 - m702 --> m210 - m703 --> m72 - m703 --> m96 - m703 --> m126 - m703 --> m136 - m703 --> m161 - m703 --> m163 - m703 --> m176 - m703 --> m178 - m703 --> m208 - m703 --> m223 - m703 --> m229 - m703 --> m704 - m703 --> m726 + m700 --> m169 + m700 --> m185 + m700 --> m214 + m700 --> m696 + m700 --> m698 + m700 --> m703 + m701 --> m72 + m701 --> m85 + m701 --> m96 + m701 --> m126 + m701 --> m136 + m701 --> m163 + m701 --> m176 + m701 --> m187 + m701 --> m210 + m701 --> m229 + m701 --> m695 + m701 -.-> m702 + m701 --> m703 + m702 --> m701 + m703 --> m210 m704 --> m72 - m704 --> m80 - m704 --> m107 - m704 --> m184 - m704 --> m185 - m704 --> m207 + m704 --> m96 + m704 --> m126 + m704 --> m136 + m704 --> m161 + m704 --> m163 + m704 --> m176 + m704 --> m178 m704 --> m208 - m704 --> m210 + m704 --> m223 m704 --> m229 - m704 --> m703 - m705 --> m58 - m705 -.-> m706 - m705 -.-> m707 - m705 --> m708 - m705 --> m709 - m705 --> m710 - m705 -.-> m711 - m705 -.-> m713 - m705 -.-> m714 - m705 -.-> m715 - m705 --> m719 - m705 -.-> m720 + m704 --> m705 + m704 --> m727 + m705 --> m72 + m705 --> m80 + m705 --> m107 + m705 --> m184 + m705 --> m185 + m705 --> m207 + m705 --> m208 + m705 --> m210 + m705 --> m229 + m705 --> m704 m706 --> m58 - m706 --> m168 - m706 --> m205 - m706 --> m705 - m706 --> m708 + m706 -.-> m707 + m706 -.-> m708 + m706 --> m709 + m706 --> m710 m706 --> m711 - m706 --> m719 - m707 --> m705 - m707 --> m719 - m708 --> m208 - m708 --> m705 + m706 -.-> m712 + m706 -.-> m714 + m706 -.-> m715 + m706 -.-> m716 + m706 --> m720 + m706 -.-> m721 + m707 --> m58 + m707 --> m168 + m707 --> m205 + m707 --> m706 + m707 --> m709 + m707 --> m712 + m707 --> m720 m708 --> m706 - m708 --> m707 - m708 --> m709 - m708 --> m711 - m708 --> m713 - m708 --> m714 - m708 --> m715 - m708 --> m719 - m709 --> m58 - m709 --> m705 + m708 --> m720 + m709 --> m208 + m709 --> m706 + m709 --> m707 m709 --> m708 - m709 --> m719 + m709 --> m710 + m709 --> m712 + m709 --> m714 + m709 --> m715 + m709 --> m716 + m709 --> m720 m710 --> m58 - m710 --> m705 - m710 --> m719 + m710 --> m706 + m710 --> m709 + m710 --> m720 m711 --> m58 - m711 --> m130 - m711 --> m163 - m711 --> m164 - m711 --> m168 - m711 --> m187 - m711 --> m208 - m711 --> m210 - m711 --> m216 - m711 --> m220 - m711 --> m222 - m711 --> m223 - m711 --> m229 - m711 --> m271 - m711 --> m343 - m711 --> m350 - m711 --> m352 - m711 --> m360 - m711 --> m361 - m711 --> m705 - m711 -.-> m712 - m711 --> m719 - m712 --> m711 - m713 --> m289 - m713 --> m307 - m713 --> m311 - m713 --> m705 - m713 --> m708 - m713 --> m711 - m713 --> m719 - m714 --> m130 - m714 --> m705 - m714 --> m708 - m714 --> m711 - m714 --> m719 - m715 --> m58 - m715 --> m271 - m715 --> m705 - m715 --> m708 - m715 --> m711 - m715 --> m716 - m715 --> m717 - m715 --> m718 - m715 --> m719 - m716 --> m222 - m716 --> m705 - m716 --> m711 - m716 --> m715 + m711 --> m706 + m711 --> m720 + m712 --> m58 + m712 --> m130 + m712 --> m163 + m712 --> m164 + m712 --> m168 + m712 --> m187 + m712 --> m208 + m712 --> m210 + m712 --> m216 + m712 --> m220 + m712 --> m222 + m712 --> m223 + m712 --> m229 + m712 --> m271 + m712 --> m344 + m712 --> m351 + m712 --> m353 + m712 --> m361 + m712 --> m362 + m712 --> m706 + m712 -.-> m713 + m712 --> m720 + m713 --> m712 + m714 --> m289 + m714 --> m307 + m714 --> m311 + m714 --> m706 + m714 --> m709 + m714 --> m712 + m714 --> m720 + m715 --> m130 + m715 --> m706 + m715 --> m709 + m715 --> m712 + m715 --> m720 + m716 --> m58 + m716 --> m271 + m716 --> m706 + m716 --> m709 + m716 --> m712 + m716 --> m717 + m716 --> m718 m716 --> m719 - m717 --> m705 - m717 --> m711 - m717 --> m715 - m718 --> m705 - m718 --> m708 - m718 --> m711 - m718 --> m715 - m718 --> m719 - m719 --> m58 - m719 --> m208 - m719 --> m223 - m719 --> m306 - m719 --> m705 - m720 --> m705 - m721 --> m72 - m721 --> m73 - m721 --> m85 - m721 --> m109 - m721 --> m161 - m721 --> m176 - m721 --> m220 - m721 --> m223 - m721 --> m287 - m721 --> m298 - m721 --> m306 - m721 --> m333 - m721 --> m722 - m721 --> m723 - m721 --> m725 - m721 --> m726 - m721 --> m727 - m721 --> m735 - m721 --> m736 + m716 --> m720 + m717 --> m222 + m717 --> m706 + m717 --> m712 + m717 --> m716 + m717 --> m720 + m718 --> m706 + m718 --> m712 + m718 --> m716 + m719 --> m706 + m719 --> m709 + m719 --> m712 + m719 --> m716 + m719 --> m720 + m720 --> m58 + m720 --> m208 + m720 --> m223 + m720 --> m306 + m720 --> m706 + m721 --> m706 m722 --> m72 + m722 --> m73 + m722 --> m85 + m722 --> m109 + m722 --> m161 + m722 --> m176 + m722 --> m220 m722 --> m223 - m723 --> m58 + m722 --> m287 + m722 --> m298 + m722 --> m306 + m722 --> m333 + m722 --> m334 + m722 --> m723 + m722 --> m724 + m722 --> m726 + m722 --> m727 + m722 --> m728 + m722 --> m736 + m722 --> m737 m723 --> m72 - m723 --> m73 - m723 --> m74 - m723 --> m85 - m723 --> m161 - m723 --> m208 m723 --> m223 - m723 --> m298 - m723 --> m333 - m723 --> m721 - m723 --> m722 - m723 -.-> m724 - m723 --> m727 - m723 --> m731 - m723 --> m735 - m723 --> m736 + m724 --> m58 + m724 --> m72 + m724 --> m73 m724 --> m74 + m724 --> m85 + m724 --> m161 + m724 --> m208 + m724 --> m223 + m724 --> m298 + m724 --> m333 + m724 --> m722 m724 --> m723 - m725 --> m72 - m725 --> m85 - m725 --> m223 - m725 --> m721 - m725 --> m722 - m725 --> m723 + m724 -.-> m725 + m724 --> m728 + m724 --> m732 + m724 --> m736 + m724 --> m737 + m725 --> m74 + m725 --> m724 + m726 --> m72 m726 --> m85 m726 --> m223 - m726 --> m721 + m726 --> m722 m726 --> m723 + m726 --> m724 + m727 --> m85 m727 --> m223 - m727 --> m298 m727 --> m722 - m727 -.-> m728 - m728 --> m727 - m729 --> m730 - m729 --> m731 - m729 --> m732 - m729 -.-> m734 - m729 --> m735 - m729 --> m736 - m729 -.-> m737 + m727 --> m724 + m728 --> m223 + m728 --> m298 + m728 --> m723 + m728 -.-> m729 + m729 --> m728 m730 --> m731 - m732 --> m730 - m732 --> m731 - m732 -.-> m733 - m732 --> m734 - m732 --> m737 + m730 --> m732 + m730 --> m733 + m730 -.-> m735 + m730 --> m736 + m730 --> m737 + m730 -.-> m738 + m731 --> m732 m733 --> m731 m733 --> m732 - m734 --> m731 - m737 --> m731 - m737 --> m735 - m738 --> m85 - m738 --> m126 - m738 --> m161 - m738 --> m163 - m738 --> m176 - m738 --> m178 - m738 --> m287 - m738 --> m739 - m738 -.-> m740 - m738 -.-> m741 + m733 -.-> m734 + m733 --> m735 + m733 --> m738 + m734 --> m732 + m734 --> m733 + m735 --> m732 + m738 --> m732 + m738 --> m736 m739 --> m85 m739 --> m126 + m739 --> m161 m739 --> m163 - m739 --> m223 + m739 --> m176 + m739 --> m178 + m739 --> m287 m739 --> m740 - m739 --> m741 + m739 -.-> m741 + m739 -.-> m742 m740 --> m85 - m740 --> m100 m740 --> m126 - m740 --> m162 - m740 --> m169 - m740 --> m184 - m740 --> m185 - m740 --> m207 - m740 --> m208 - m740 --> m210 - m740 --> m217 + m740 --> m163 m740 --> m223 - m741 --> m39 + m740 --> m741 + m740 --> m742 m741 --> m85 - m741 --> m306 - m741 --> m740 - m742 --> m72 + m741 --> m100 + m741 --> m126 + m741 --> m162 + m741 --> m169 + m741 --> m184 + m741 --> m185 + m741 --> m207 + m741 --> m208 + m741 --> m210 + m741 --> m217 + m741 --> m223 + m742 --> m39 m742 --> m85 - m742 --> m106 - m742 --> m109 - m742 --> m126 - m742 --> m161 - m742 --> m163 - m742 --> m176 - m742 --> m178 - m742 --> m184 - m742 --> m185 - m742 --> m208 - m742 --> m210 - m742 --> m217 - m742 --> m223 - m742 --> m334 - m742 --> m354 - m742 --> m355 + m742 --> m306 + m742 --> m741 + m743 --> m72 + m743 --> m85 + m743 --> m106 + m743 --> m109 + m743 --> m126 + m743 --> m161 + m743 --> m163 + m743 --> m176 + m743 --> m178 + m743 --> m184 + m743 --> m185 + m743 --> m208 + m743 --> m210 + m743 --> m217 + m743 --> m223 + m743 --> m334 + m743 --> m355 + m743 --> m356 diff --git a/docs/design/appserver/settings-service.md b/docs/design/appserver/settings-service.md index 10ad7b029e..ff00bcd384 100644 --- a/docs/design/appserver/settings-service.md +++ b/docs/design/appserver/settings-service.md @@ -212,6 +212,8 @@ Process scope, no instance key, provided by Settings. | Method | Mode | Request | Reply | | --- | --- | --- | --- | | `register` | async | a declaration (§3.1) | nothing; rejects when refused | +| `registerDocument` | async | `({source, userFile, projectFile?}, codec)` | Source-bound `read(scope)` and `update(scope, expectedRevision, document)`, each returning the Settings result with a snapshot. The owner supplies `decode(bytes or null)` and `validate(document)`. The registration ends on owner unload. | +| `authorizeProject` | async | `{cwd}` | Settings result with the authorized root number. A newly admitted root emits the project authorization notice (§4.4). | | `read` | async | `{source, scope: Scope}` | `Snapshot` | | `update` | async | `{source, scope: Scope, expectedRevision, document}` | `Snapshot` (the stored document) | | `declaredBy` | sync | `{instanceId: string}` (the live loader instance ID in decimal) | The JSON Schema declarations registered by that instance, ordered by source name. An instance with no live declarations returns an empty array. | @@ -230,7 +232,7 @@ Process scope, no instance key, provided by Settings. - Errors of `read`, `update` and `projects` (§6): `unknown_source`, `invalid_scope`, `invalid_document`, `user_only_field`, `conflict`, `unsynced`, `failed`, `closed`, `cancelled`. -Only `register` uses the caller's identity, to withdraw the registration with the calling row. +Both registration methods use the caller's identity, to withdraw the registration with the calling row. Ownership comes from the registering row: each source has one owner, and only that package is written against it. This is the trust model of in-process plugins (AGENTS.md rule 11): dependency declarations are not a sandbox. diff --git a/docs/design/contracts/resource-owner-operations.md b/docs/design/contracts/resource-owner-operations.md index 772c955137..8ea829ca0f 100644 --- a/docs/design/contracts/resource-owner-operations.md +++ b/docs/design/contracts/resource-owner-operations.md @@ -134,7 +134,7 @@ serves declared sources and excludes the native `mcp-secrets` document. | Caller → Settings | Current operation and contract | | --- | --- | | PluginManager; declared-source consumers | Filter declarations by live loader instance using declaredBy above. Reuse settings.read/update/projects for owner edits and reads. SettingsMethods uses its client path and lists only declared sources. | -| Agents create/restore, Hooks and MCP management | authorize_project(cwd,cancelled) → root registers the authorized root and publishes the existing notice. It is a write performed at trusted admission. project_root/path/sources are reads covered by settings.projects. | +| Agents create/restore, Hooks and MCP management | `settings.authorizeProject({cwd}) → SettingsResult` registers the authorized root and publishes the existing notice. It is a write performed at trusted admission. project_root/path/sources are reads covered by settings.projects. | | PermissionRules and CommandRules; CollaborationModelPolicy and optional Collaboration runtime | User permission and collaboration policy reads/writes. Expose the existing commandRules.read projection to rule consumers; use the policy owner's read returning {revision,policy} for Collaboration. Preserve absent-profile fallback. | | HooksSettings and HookSources | hooks, hooks-projects and hooks-plugins. The runtime consumes sources(cwd,cancelled) → HookSourcesSnapshot. Source resolution, revisions and enablement belong to Hooks. | | Mcp and McpPublication | mcp, mcp-projects, mcp-plugins and mcp-secrets. Publication reads effective server configuration and constructs live connections. Keep partial decoding of individual server entries and credential use at the MCP owner. | diff --git a/docs/zh/design/appserver/settings-service.md b/docs/zh/design/appserver/settings-service.md index 670232c59a..2037813ec0 100644 --- a/docs/zh/design/appserver/settings-service.md +++ b/docs/zh/design/appserver/settings-service.md @@ -191,6 +191,8 @@ Settings 在内存中保存已登记的来源(声明已编译),各自保 | 方法 | 模式 | 请求 | 回复 | | --- | --- | --- | --- | | `register` | async | 一份声明(§3.1) | 无;被拒绝时 reject | +| `registerDocument` | 异步 | `({source, userFile, projectFile?}, codec)` | 返回本次登记的 `read(scope)` 和 `update(scope, expectedRevision, document)`,两者都返回含快照的 Settings 结果。所有者提供 `decode(bytes 或 null)` 和 `validate(document)`。所有者卸载时登记结束。 | +| `authorizeProject` | 异步 | `{cwd}` | 返回含已授权根目录编号的 Settings 结果。首次授权会发布 §4.4 的项目授权通知。 | | `read` | async | `{source, scope: Scope}` | `Snapshot` | | `update` | async | `{source, scope: Scope, expectedRevision, document}` | `Snapshot`(保存后的文档) | | `declaredBy` | sync | `{instanceId: string}`,加载器实例 ID 的十进制字符串 | 该实例已注册且仍有效的 JSON Schema 声明,按来源名称排序。无有效声明时返回空数组。 | @@ -206,7 +208,7 @@ Settings 在内存中保存已登记的来源(声明已编译),各自保 - `read`、`update` 和 `projects` 的错误(§6):`unknown_source`、`invalid_scope`、`invalid_document`、 `user_only_field`、`conflict`、`unsynced`、`failed`、`closed`、`cancelled`。 -只有 `register` 使用调用方身份,以便随调用行撤回登记。所有权来自登记它的行:每个来源只有一个所有者, +两种登记方法都使用调用方身份,以便随调用行撤回登记。所有权来自登记它的行:每个来源只有一个所有者, 只有那个包针对它编写。这是进程内 插件的信任模型(AGENTS.md 规则 11):依赖声明不是沙箱。 diff --git a/npm/plugin.d.ts b/npm/plugin.d.ts index c7ea5d1837..ffb6e83e94 100644 --- a/npm/plugin.d.ts +++ b/npm/plugin.d.ts @@ -66,8 +66,16 @@ export interface Settings { * home when the row unloads. Rejects (failing the caller's apply) when the declaration is * invalid or its name or a file is registered already. Call it from a row's own `apply`. */ register(declaration: SourceDeclaration): Promise; + registerDocument( + declaration: { source: string; userFile: string; projectFile?: string }, + codec: { decode(bytes: Uint8Array | null): D | Promise; validate(document: D): void | Promise } + ): Promise<{ + read(scope: SettingsScope): Promise>; + update(scope: SettingsScope, expectedRevision: string, document: D): Promise>; + }>; read(request: { source: string; scope: SettingsScope }): Promise>; update(request: { source: string; scope: SettingsScope; expectedRevision: string; document: JsonObject }): Promise>; + authorizeProject(request: { cwd: string }): Promise>; projects(request: Record): SettingsResult<{ projects: { root: number; cwd: string }[] }>; } diff --git a/runtime/fixtures/settings-owner.ts b/runtime/fixtures/settings-owner.ts index a90949079c..3049c573f7 100644 --- a/runtime/fixtures/settings-owner.ts +++ b/runtime/fixtures/settings-owner.ts @@ -1,9 +1,9 @@ import { definePlugin } from '@arcships/rutis' import provides from './settings-owner.json' with { type: 'json' } import sources from './settings-owner.settings.json' with { type: 'json' } -import type { PartRegistry, SessionMethods, Settings as SettingsService, SourceDeclaration } from '../../npm/plugin.js' +import type { JsonValue, PartRegistry, SessionMethods, Settings as SettingsService, SourceDeclaration } from '../../npm/plugin.js' -type Envelope = { ok: boolean; value?: unknown; error?: { code: string; message: string } } +type Envelope = { ok: boolean; value?: JsonValue; error?: { code: string; message: string } } type Settings = { read(request: unknown): Promise; update(request: unknown): Promise } type MethodCall = { method: string; params: { sessionId: string; [key: string]: unknown } } @@ -16,17 +16,37 @@ export const part = definePlugin({ inject: ['settings', 'sessionMethods'], async apply(ctx) { const settings = ctx.use('settings') - const events: { name: string; payload: unknown }[] = [] + const registerCustom = () => ctx.use('settings').registerDocument( + { source: 'example-custom', userFile: 'example-custom.json' }, + { + decode(bytes): { count: number } { + return bytes === null ? { count: 3 } : JSON.parse(new TextDecoder().decode(bytes)) + }, + validate(document: { count: number }) { + if (!Number.isInteger(document.count) || document.count < 0) throw new Error('invalid count') + }, + }, + ) + let custom: Awaited> + const events: { name: string; payload: JsonValue }[] = [] for (const name of ['settings/example', 'settings/projects']) { - ctx.on(name, (payload: unknown) => { events.push({ name, payload }) }) + ctx.on(name, (payload: JsonValue) => { events.push({ name, payload }) }) } await ctx.use('sessionMethods').register( 'session.example', - ['read', 'update', 'events', 'declared'].map(name => ({ + ['read', 'update', 'events', 'declared', 'custom_read', 'custom_update'].map(name => ({ name: `session.example.${name}`, mutating: false, interruption: 'report', progress: false, })), async (call: MethodCall) => { const { sessionId: _, ...request } = call.params + if (call.method.endsWith('.custom_read')) { + custom ??= await registerCustom() + return { kind: 'value', value: await custom.read('user') } + } + if (call.method.endsWith('.custom_update')) { + if (typeof request.expectedRevision !== 'string' || typeof request.count !== 'number') throw new Error('expected revision and count') + return { kind: 'value', value: await custom.update('user', request.expectedRevision, { count: request.count }) } + } if (call.method.endsWith('.declared')) { if (typeof request.instanceId !== 'string') throw new Error('expected instanceId') return { kind: 'value', value: ctx.use('settings').declaredBy({ instanceId: request.instanceId }) } From 0d40780d6f59550505bfcc0c74c85cb92acc5237 Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 14:51:40 +0800 Subject: [PATCH 03/10] Keep the settings codec call within the workspace formatting limit --- crates/dim-app-server/src/settings/document.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/dim-app-server/src/settings/document.rs b/crates/dim-app-server/src/settings/document.rs index b25372fdee..eaa0b328e7 100644 --- a/crates/dim-app-server/src/settings/document.rs +++ b/crates/dim-app-server/src/settings/document.rs @@ -24,12 +24,16 @@ impl Codec { argument: Value, cancel: &CancellationToken, ) -> Result { + let invoke = async { + let args = Value::List(vec![argument]); + settle(self.methods.call_method_async(method, args).await?).await + }; tokio::select! { biased; _ = self.owner.cancelled() => Err(SettingsError::UnknownSource), _ = self.service.cancelled() => Err(SettingsError::Closed), _ = cancel.cancelled() => Err(SettingsError::Cancelled), - result = async { settle(self.methods.call_method_async(method, Value::List(vec![argument])).await?).await } => + result = invoke => result.map_err(|error| SettingsError::Document(error.to_string())), } } From aa7b692c2978703de2cd4ec432f421175500ecbc Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 14:53:09 +0800 Subject: [PATCH 04/10] Read hook source documents through their registered owner --- .../src/hooks/sources.rs | 7 +- crates/dim-app-server/src/hooks_settings.rs | 204 +++++++++++------- .../tests/hooks_settings_flow.rs | 13 ++ .../generated/app-server/services.json | 6 +- .../generated/app-server/services.md | 2 +- .../generated/app-server/services.mmd | 2 +- .../rust-agent/generated/catalog.md | 2 +- .../rust-agent/generated/modules.json | 28 ++- .../rust-agent/generated/modules.mmd | 3 +- docs/design/plugins/Hooks.md | 2 + docs/zh/design/plugins/Hooks.md | 2 + npm/plugin.d.ts | 7 + 12 files changed, 180 insertions(+), 98 deletions(-) diff --git a/crates/dim-agent-capabilities/src/hooks/sources.rs b/crates/dim-agent-capabilities/src/hooks/sources.rs index 92c1ee9c6a..63071fa57d 100644 --- a/crates/dim-agent-capabilities/src/hooks/sources.rs +++ b/crates/dim-agent-capabilities/src/hooks/sources.rs @@ -35,7 +35,8 @@ impl serde::Serialize for HookSourceId { } /// Whether a source's document was read, absent or refused. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] +#[serde(rename_all = "camelCase")] pub enum HookSourceState { Ok, Missing, @@ -43,7 +44,7 @@ pub enum HookSourceState { } /// One source as the port returns it. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, serde::Serialize)] pub struct HookSourceSnapshot { pub id: HookSourceId, /// Where the document lives: the user file, the project file, or a @@ -57,7 +58,7 @@ pub struct HookSourceSnapshot { } /// Every effective source of one working directory, in catalog order. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct HookSourcesSnapshot { pub sources: Vec, } diff --git a/crates/dim-app-server/src/hooks_settings.rs b/crates/dim-app-server/src/hooks_settings.rs index 20a6d680a2..b43f36987a 100644 --- a/crates/dim-app-server/src/hooks_settings.rs +++ b/crates/dim-app-server/src/hooks_settings.rs @@ -5,7 +5,10 @@ use crate::{ methods::{ManagementMethods, SelectionScope}, protocol::canonical_cwd, - settings::{BusinessDocument, SettingsError, SettingsScope, SettingsService, SettingsSnapshot}, + settings::{ + BusinessDocument, RegisteredDocument, Settings, SettingsError, SettingsScope, + SettingsSnapshot, + }, }; use dim_agent_capabilities::{ file_storage::{FileStorageError, FsHost}, @@ -129,7 +132,10 @@ fn plugin_sources(documents: HooksPlugins) -> Vec { /// a Settings source; the project file is read through fsHost under the /// root Settings authorized for the workspace. struct SettingsHookSources { - settings: Arc, + settings: Arc, + user: Arc>, + projects: Arc>, + plugins: Arc>, files: Arc, home: Option, } @@ -159,25 +165,30 @@ impl ReadHookSources for SettingsHookSources { let cwd = cwd.to_path_buf(); Box::pin(async move { let user = self - .settings - .read::(SettingsScope::User, &cancel) + .user + .read(SettingsScope::User, &cancel) .await .map_err(host_error)?; let projects = self - .settings - .read::(SettingsScope::User, &cancel) + .projects + .read(SettingsScope::User, &cancel) .await .map_err(host_error)?; let plugins = self - .settings - .read::(SettingsScope::User, &cancel) + .plugins + .read(SettingsScope::User, &cancel) .await .map_err(host_error)?; let mut sources = vec![user_source(&user.revision, user.document)]; // A hook point reads; it never authorizes. The Session's own // creation registered its root. - if let Some(root) = self.settings.project_root(&cwd) { - sources.push(self.project(root, &projects.document, &cancel).await?); + if self + .settings + .projects() + .iter() + .any(|project| project.cwd == cwd) + { + sources.push(self.project(&cwd, &projects.document, &cancel).await?); } sources.extend(plugin_sources(plugins.document)); Ok(HookSourcesSnapshot { sources }) @@ -193,7 +204,7 @@ impl SettingsHookSources { /// The sources of a workspace whose root the caller authorized. async fn authorized( &self, - root: usize, + workspace: &Path, user: &SettingsSnapshot, projects: &SettingsSnapshot, plugins: &SettingsSnapshot, @@ -201,7 +212,7 @@ impl SettingsHookSources { ) -> Result { let mut sources = vec![ user_source(&user.revision, user.document.clone()), - self.project(root, &projects.document, cancel).await?, + self.project(workspace, &projects.document, cancel).await?, ]; sources.extend(plugin_sources(plugins.document.clone())); Ok(HookSourcesSnapshot { sources }) @@ -210,11 +221,10 @@ impl SettingsHookSources { /// The workspace's source, from the root Settings authorized for it. async fn project( &self, - root: usize, + workspace: &Path, projects: &HooksProjects, cancel: &CancellationToken, ) -> Result { - let workspace = self.settings.project_path(root).map_err(host_error)?; let workspace_key = workspace.to_string_lossy().into_owned(); let path = workspace.join(PROJECT_FILE); let state = match self @@ -284,18 +294,34 @@ pub fn install(builder: &mut AgentBuilder, product_home: Option) { ); } +struct SessionHookSources { + owner: Arc, + home: Option, +} +impl ReadHookSources for SessionHookSources { + fn sources( + &self, + cwd: &Path, + cancel: CancellationToken, + ) -> dim_agent_capabilities::host::HostFuture<'_, HookSourcesSnapshot> { + let cwd = cwd.to_path_buf(); + Box::pin(async move { self.owner.sources(&cwd, cancel).await }) + } + fn home(&self) -> Option { + self.home.clone() + } +} + struct HookSourcesPlugin { host: Key, - settings: Key, - files: Key, + owner: Key, home: Option, } impl HookSourcesPlugin { fn new(names: &Names<'_>, home: Option) -> rutis::Result { Ok(Self { host: names.key()?, - settings: names.key()?, - files: names.key()?, + owner: names.key()?, home, }) } @@ -305,18 +331,16 @@ impl DynPlugin for HookSourcesPlugin { "HookSources" } fn injects(&self) -> Vec { - vec![self.settings.erase(), self.files.erase()] + vec![self.owner.erase()] } fn apply<'a>(&'a self, ctx: &'a Ctx) -> BoxFuture<'a, rutis::Result> { Box::pin(async move { - let settings = ctx.require_at(&self.settings)?; - let files = ctx.require_at(&self.files)?; + let owner = ctx.require_at(&self.owner)?; ctx.provide_at( self.host.clone(), - Arc::new(HookSourcesHost(Arc::new(SettingsHookSources { - settings, - files, + Arc::new(HookSourcesHost(Arc::new(SessionHookSources { home: self.home.clone(), + owner, }))), )?; Ok(Effect::Done) @@ -396,19 +420,6 @@ fn error(error: SettingsError) -> RpcError { RpcError::app(-32000, kind, error.to_string()) } -/// The port over this host's Settings and files. -fn reader( - settings: &Arc, - files: &Arc, - home: Option, -) -> Arc { - Arc::new(SettingsHookSources { - settings: settings.clone(), - files: files.clone(), - home, - }) -} - /// A refused plugin document's error and optional credential-safe reason. pub type HookRefusal = (String, Option<&'static str>); @@ -417,7 +428,7 @@ pub type HookRefusal = (String, Option<&'static str>); /// `hooks-plugins`. #[derive(Clone)] pub struct HooksService { - settings: Arc, + reader: Arc, /// Why the last registration of a plugin was refused, by plugin id: the /// raw error, and its static reason when the cause has one /// (PluginManager A.2). @@ -441,6 +452,12 @@ struct PluginRequest { #[serde(deny_unknown_fields)] struct NoArguments {} +#[derive(Deserialize)] +#[serde(deny_unknown_fields)] +struct SourceRequest { + cwd: PathBuf, +} + fn face_request( args: rutis_bridge::session::Value, ) -> Result { @@ -480,7 +497,7 @@ fn face_reply(result: crate::settings::Result) -> rutis_bridge: impl rutis_bridge::session::HostDispatch for HooksService { fn methods(&self) -> Option { Some( - serde_json::json!({"register":"async", "withdraw":"async", "plugins":"async", "refusal":"sync"}), + serde_json::json!({"register":"async", "withdraw":"async", "plugins":"async", "refusal":"sync", "sources":"async"}), ) } @@ -522,6 +539,25 @@ impl rutis_bridge::session::HostDispatch for HooksService { face_reply(owner.plugins(&cancel).await) })) } + "sources" => { + let SourceRequest { cwd } = face_request(args)?; + Ok(Value::future(async move { + let _guard = cancel.clone().drop_guard(); + let sources = owner.sources(&cwd, cancel).await.map_err(|error| { + let code = match error { + dim_agent_capabilities::host::HostError::Cancelled(_) => "cancelled", + _ => "failed", + }; + rutis_bridge::exports::failure( + "hooksService", + code, + error.to_string(), + None, + ) + })?; + rutis_bridge::session::arg(&sources) + })) + } "refusal" => { let PluginRequest { plugin } = face_request(args)?; rutis_bridge::session::arg(&self.plugin_refusal(&plugin)) @@ -534,6 +570,14 @@ impl rutis_bridge::session::HostDispatch for HooksService { } impl HooksService { + pub async fn sources( + &self, + cwd: &Path, + cancel: CancellationToken, + ) -> Result { + self.reader.sources(cwd, cancel).await + } + /// Adds or replaces the hook document of `plugin` (a plugin id, §3.7), /// whose commands read `dir` as `DIM_PLUGIN_ROOT` (Hooks A.2, A.3). The /// registration is kept in `hooks-plugins.json` and survives Hooks' @@ -603,8 +647,9 @@ impl HooksService { cancel: &CancellationToken, ) -> crate::settings::Result> { Ok(self - .settings - .read::(SettingsScope::User, cancel) + .reader + .plugins + .read(SettingsScope::User, cancel) .await? .document .plugins @@ -623,8 +668,9 @@ impl HooksService { ) -> crate::settings::Result<()> { loop { let current = self - .settings - .read::(SettingsScope::User, cancel) + .reader + .plugins + .read(SettingsScope::User, cancel) .await?; let mut document = current.document; if document.plugins.get(&plugin) == registration.as_ref() { @@ -641,7 +687,8 @@ impl HooksService { } } match self - .settings + .reader + .plugins .update(SettingsScope::User, ¤t.revision, document, cancel) .await { @@ -655,7 +702,7 @@ impl HooksService { /// Process owner of the `hooks` sources and their management methods. pub struct HooksSettingsPlugin { - settings: Key, + settings: Key, files: Key, methods: Key, product_home: Option, @@ -686,11 +733,16 @@ impl DynPlugin for HooksSettingsPlugin { let settings = ctx.require_at(&self.settings)?; let files = ctx.require_at(&self.files)?; let methods = ctx.require_at(&self.methods)?; - settings.register::(ctx)?; - settings.register::(ctx)?; - settings.register::(ctx)?; - let service = Arc::new(HooksService { + let reader = Arc::new(SettingsHookSources { + user: settings.register_document::(ctx)?, + projects: settings.register_document::(ctx)?, + plugins: settings.register_document::(ctx)?, settings: settings.clone(), + files, + home: self.product_home.clone(), + }); + let service = Arc::new(HooksService { + reader: reader.clone(), refused: Arc::default(), }); ctx.provide_as::(service.clone())?; @@ -698,7 +750,6 @@ impl DynPlugin for HooksSettingsPlugin { rutis_bridge::session::host_key("hooksService"), service, )?; - let reader = reader(&settings, &files, self.product_home.clone()); methods.register( ctx, "hooks", @@ -720,27 +771,30 @@ impl DynPlugin for HooksSettingsPlugin { match method.as_str() { "hooks.catalog" => { let p: SelectionScope = params(value)?; - let user = settings - .read::(SettingsScope::User, &stopping) + let user = reader + .user + .read(SettingsScope::User, &stopping) .await .map_err(error)?; - let projects = settings - .read::(SettingsScope::User, &stopping) + let projects = reader + .projects + .read(SettingsScope::User, &stopping) .await .map_err(error)?; - let plugins = settings - .read::(SettingsScope::User, &stopping) + let plugins = reader + .plugins + .read(SettingsScope::User, &stopping) .await .map_err(error)?; let snapshot = match p.cwd { Some(cwd) => { let cwd = canonical_cwd(&cwd).await?; - let root = settings - .authorize_project(cwd, &stopping) + settings + .authorize_project(cwd.clone(), &stopping) .await .map_err(error)?; reader - .authorized(root, &user, &projects, &plugins, &stopping) + .authorized(&cwd, &user, &projects, &plugins, &stopping) .await .map_err(|error| { RpcError::app( @@ -776,7 +830,8 @@ impl DynPlugin for HooksSettingsPlugin { } "hooks.save" => { let p: SaveHooks = params(value)?; - let snapshot = settings + let snapshot = reader + .user .update( SettingsScope::User, &p.expected_revision, @@ -792,17 +847,14 @@ impl DynPlugin for HooksSettingsPlugin { "hooks.set_enabled" => { let p: SetHookProject = params(value)?; let cwd = canonical_cwd(&p.cwd).await?; - let root = settings - .authorize_project(cwd, &stopping) + settings + .authorize_project(cwd.clone(), &stopping) .await .map_err(error)?; - let workspace = settings - .project_path(root) - .map_err(error)? - .to_string_lossy() - .into_owned(); - let snapshot = settings - .read::(SettingsScope::User, &stopping) + let workspace = cwd.to_string_lossy().into_owned(); + let snapshot = reader + .projects + .read(SettingsScope::User, &stopping) .await .map_err(error)?; if snapshot.revision != p.expected_revision { @@ -819,7 +871,8 @@ impl DynPlugin for HooksSettingsPlugin { revision: snapshot.revision, }); } - let snapshot = settings + let snapshot = reader + .projects .update( SettingsScope::User, &snapshot.revision, @@ -884,13 +937,8 @@ mod tests { wait_active(&root, &views, Duration::from_secs(5), &cancel) .await .unwrap(); - let settings = root.get::().unwrap(); - let files = root.get::().unwrap(); - let sources = SettingsHookSources { - settings: settings.clone(), - files, - home: Some(home.clone()), - }; + let settings = root.get::().unwrap(); + let sources = root.get::().unwrap(); let snapshot = sources.sources(&project, cancel.clone()).await.unwrap(); assert_eq!( snapshot.sources.len(), @@ -898,7 +946,7 @@ mod tests { "an unauthorized workspace has no project source" ); assert!( - settings.project_root(&project).is_none(), + settings.projects().iter().all(|entry| entry.cwd != project), "a hook point authorized a project" ); diff --git a/crates/dim-app-server/tests/hooks_settings_flow.rs b/crates/dim-app-server/tests/hooks_settings_flow.rs index c716e69d6b..0df3574193 100644 --- a/crates/dim-app-server/tests/hooks_settings_flow.rs +++ b/crates/dim-app-server/tests/hooks_settings_flow.rs @@ -159,6 +159,19 @@ async fn catalog_reports_sources_states_and_never_reads_foreign_hook_files() { ) .await .unwrap(); + let service = fixture.root.get::().unwrap(); + let native = service + .sources(&fixture.project, fixture.cancel.clone()) + .await + .unwrap(); + let wire = fixture + .face("sources", json!({"cwd":fixture.project})) + .await + .unwrap(); + assert_eq!(wire, serde_json::to_value(native).unwrap()); + assert_eq!(wire["sources"][1]["state"], "ok"); + assert_eq!(wire["sources"][1]["enabled"], false); + assert!(wire["sources"][1]["document"]["hooks"]["Stop"].is_array()); assert_eq!(catalog["sources"][1]["state"], "ok"); assert_eq!(catalog["sources"][1]["enabled"], false); let hooks = catalog["hooks"].as_array().unwrap(); diff --git a/docs/architecture/rust-agent/generated/app-server/services.json b/docs/architecture/rust-agent/generated/app-server/services.json index c383977442..bed547bf03 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.json +++ b/docs/architecture/rust-agent/generated/app-server/services.json @@ -1945,7 +1945,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" } @@ -1964,7 +1964,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -1984,7 +1984,7 @@ "external": true }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "provider": 18, "declared": true, "external": true diff --git a/docs/architecture/rust-agent/generated/app-server/services.md b/docs/architecture/rust-agent/generated/app-server/services.md index b9550e5238..ff159fc98f 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.md +++ b/docs/architecture/rust-agent/generated/app-server/services.md @@ -167,7 +167,7 @@ flowchart LR p18 -->|"dim_app_server::settings::declared::Settings"| p35 p4 -->|"dim_agent_capabilities::file_storage::face::FsHost"| p34 p10 -->|"dim_app_server::methods::ManagementMethods"| p34 - p18 -->|"dim_app_server::settings::SettingsService"| p34 + p18 -->|"dim_app_server::settings::declared::Settings"| p34 p10 -->|"dim_app_server::methods::ManagementMethods"| p33 p18 -->|"dim_app_server::settings::declared::Settings"| p33 p29 -->|"dim_agent_capabilities::host_platform::HostPlatform"| p32 diff --git a/docs/architecture/rust-agent/generated/app-server/services.mmd b/docs/architecture/rust-agent/generated/app-server/services.mmd index 40dc3d5fe0..1ea96c60f6 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.mmd +++ b/docs/architecture/rust-agent/generated/app-server/services.mmd @@ -162,7 +162,7 @@ flowchart LR p18 -->|"dim_app_server::settings::declared::Settings"| p35 p4 -->|"dim_agent_capabilities::file_storage::face::FsHost"| p34 p10 -->|"dim_app_server::methods::ManagementMethods"| p34 - p18 -->|"dim_app_server::settings::SettingsService"| p34 + p18 -->|"dim_app_server::settings::declared::Settings"| p34 p10 -->|"dim_app_server::methods::ManagementMethods"| p33 p18 -->|"dim_app_server::settings::declared::Settings"| p33 p29 -->|"dim_agent_capabilities::host_platform::HostPlatform"| p32 diff --git a/docs/architecture/rust-agent/generated/catalog.md b/docs/architecture/rust-agent/generated/catalog.md index e60141bdf9..815fdbc922 100644 --- a/docs/architecture/rust-agent/generated/catalog.md +++ b/docs/architecture/rust-agent/generated/catalog.md @@ -23,7 +23,7 @@ Each catalog name a part of the assembly provides or injects. `data` means share | `fileStorage` | process | FileStorage | internal(object) | — | | `fsHost` | process | FileStorage | data | `backup` async, `closeRead` async, `createDirectory` async, `list` async, `lock` async, `openRead` async, `readAt` async, `readBytes` async, `remove` async, `replace` async, `stat` async, `unlock` async | | `grokOAuthService` | process | GrokOAuth | internal(secret) | — | -| `hooksService` | process | HooksSettings | data | `plugins` async, `refusal` sync, `register` async, `withdraw` async | +| `hooksService` | process | HooksSettings | data | `plugins` async, `refusal` sync, `register` async, `sources` async, `withdraw` async | | `hostPlatform` | process | HostPlatform | internal(object) | — | | `listenAddresses` | process | Transport | data | `read` async | | `loader` | process | rutis-loader | internal(owner-api) | — | diff --git a/docs/architecture/rust-agent/generated/modules.json b/docs/architecture/rust-agent/generated/modules.json index fe9d776f94..bc5203a96f 100644 --- a/docs/architecture/rust-agent/generated/modules.json +++ b/docs/architecture/rust-agent/generated/modules.json @@ -3689,7 +3689,8 @@ "parent": "dim_app_server::settings", "file": "crates/dim-app-server/src/settings/document.rs", "unexpandedMacros": [ - "tokio::select" + "tokio::select", + "vec" ] }, { @@ -28599,32 +28600,33 @@ "to": "dim_app_server::settings", "references": [ "path BusinessDocument", + "path RegisteredDocument", "path SettingsError", "path SettingsError::Cancelled", "path SettingsError::Closed", "path SettingsError::Conflict", "path SettingsError::Invalid", - "path SettingsService", "path SettingsSnapshot", "path crate::settings::Result", "use crate::settings::BusinessDocument", + "use crate::settings::RegisteredDocument", "use crate::settings::SettingsError", - "use crate::settings::SettingsService", "use crate::settings::SettingsSnapshot" ] }, { - "from": "dim_app_server::hooks_settings::tests", - "to": "dim_agent_capabilities::file_storage", + "from": "dim_app_server::hooks_settings", + "to": "dim_app_server::settings::declared", "references": [ - "use dim_agent_capabilities::file_storage::FileStoragePlugin" + "path Settings", + "use crate::settings::Settings" ] }, { "from": "dim_app_server::hooks_settings::tests", - "to": "dim_agent_capabilities::file_storage::face", + "to": "dim_agent_capabilities::file_storage", "references": [ - "path FsHost" + "use dim_agent_capabilities::file_storage::FileStoragePlugin" ] }, { @@ -28646,7 +28648,7 @@ "from": "dim_app_server::hooks_settings::tests", "to": "dim_app_server::hooks_settings", "references": [ - "path SettingsHookSources" + "path HooksService" ] }, { @@ -28660,10 +28662,16 @@ "from": "dim_app_server::hooks_settings::tests", "to": "dim_app_server::settings", "references": [ - "path SettingsService", "use crate::settings::SettingsPlugin" ] }, + { + "from": "dim_app_server::hooks_settings::tests", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings" + ] + }, { "from": "dim_app_server::managed_oauth", "to": "dim_agent_capabilities::file_storage", diff --git a/docs/architecture/rust-agent/generated/modules.mmd b/docs/architecture/rust-agent/generated/modules.mmd index b139576023..557962c196 100644 --- a/docs/architecture/rust-agent/generated/modules.mmd +++ b/docs/architecture/rust-agent/generated/modules.mmd @@ -2724,13 +2724,14 @@ flowchart LR m261 --> m287 m261 --> m306 m261 --> m333 + m261 --> m334 m262 --> m58 - m262 --> m59 m262 --> m161 m262 --> m231 m262 --> m261 m262 --> m287 m262 --> m333 + m262 --> m334 m263 --> m58 m264 --> m161 m264 --> m220 diff --git a/docs/design/plugins/Hooks.md b/docs/design/plugins/Hooks.md index 7f10a66063..06aa13ca41 100644 --- a/docs/design/plugins/Hooks.md +++ b/docs/design/plugins/Hooks.md @@ -418,6 +418,8 @@ Plugin documents are kept in the Settings source `hooks-plugins`, one `{dir, hoo It is separate from the local client management entry in A.7. Each operation accepts exactly one JSON object; positional arrays and scalar requests are invalid. +The Session hook runner obtains the effective source documents through `hooksService.sources({cwd})`. The reply contains `{sources: [{id, path, enabled, state, document}]}`. A lookup reads the project source only for an already authorized working directory. + | Operation | Request | Reply | | --- | --- | --- | | `register` (async) | `{plugin, dir, document}`; plugin id and directory are strings | `null` | diff --git a/docs/zh/design/plugins/Hooks.md b/docs/zh/design/plugins/Hooks.md index a5bd428a1a..a7a2005744 100644 --- a/docs/zh/design/plugins/Hooks.md +++ b/docs/zh/design/plugins/Hooks.md @@ -417,6 +417,8 @@ AcpGateway 自己的设计把 Hooks 对 `session.submit` 的 `input_blocked` 拒 `hooksService` 是现有插件内容操作的进程数据面,与 A.7 的本地客户端管理入口分开。 每个操作只接受一个 JSON 对象;位置参数数组和标量请求无效。 +Session 的 Hook 执行器通过 `hooksService.sources({cwd})` 获取生效的来源文档,返回 `{sources: [{id, path, enabled, state, document}]}`。只有工作目录已获授权时,读取才包含项目来源。 + | 操作 | 请求 | 回复 | | --- | --- | --- | | `register`(异步) | `{plugin, dir, document}`;插件 ID 和目录为字符串 | `null` | diff --git a/npm/plugin.d.ts b/npm/plugin.d.ts index ffb6e83e94..ab54faae4d 100644 --- a/npm/plugin.d.ts +++ b/npm/plugin.d.ts @@ -819,6 +819,13 @@ export interface SummaryPromptSettingsHost { /** Hooks-owned plugin content registration; see Hooks A.2. */ export interface HooksService { + sources(request: { cwd: string }): Promise<{ sources: { + id: "user" | "project" | `plugin:${string}`; + path: string | null; + enabled: boolean; + state: "ok" | "missing" | { invalid: string }; + document: { hooks: Record; disableAllHooks: boolean } | null; + }[] }>; register(request: { plugin: string; dir: string; document: JsonValue }): Promise; withdraw(request: { plugin: string }): Promise; plugins(request: Record): Promise; From 36d0d80cb91e5034c12177a0782d28d95ccaf586 Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 15:11:14 +0800 Subject: [PATCH 05/10] Move MCP and collaboration policy reads to their Settings owners --- crates/dim-app-server/src/collaboration.rs | 28 ++- .../src/collaboration_model_policy.rs | 76 +++++-- crates/dim-app-server/src/lib.rs | 2 + crates/dim-app-server/src/mcp.rs | 209 ++++++++++-------- crates/dim-app-server/src/mcp/config.rs | 38 ++-- crates/dim-app-server/src/mcp/management.rs | 8 +- crates/dim-app-server/src/mcp/publication.rs | 84 +++---- crates/dim-app-server/src/mcp/session.rs | 8 +- .../dim-app-server/src/settings/declared.rs | 5 +- .../tests/transport_flow/collaboration.rs | 17 +- .../generated/app-server/services.json | 38 ++-- .../generated/app-server/services.md | 6 +- .../generated/app-server/services.mmd | 6 +- .../rust-agent/generated/catalog.md | 1 + .../rust-agent/generated/modules.json | 95 +++++--- .../rust-agent/generated/modules.mmd | 6 +- docs/design/appserver/mcp-management.md | 2 +- docs/design/subagent-model-policy.md | 2 + npm/plugin.d.ts | 7 + 19 files changed, 394 insertions(+), 244 deletions(-) diff --git a/crates/dim-app-server/src/collaboration.rs b/crates/dim-app-server/src/collaboration.rs index 97ef2b6136..ebf08497ac 100644 --- a/crates/dim-app-server/src/collaboration.rs +++ b/crates/dim-app-server/src/collaboration.rs @@ -14,9 +14,9 @@ mod pending; pub use approvals::ApprovalDestination; use crate::agents::{AgentIndex, AgentProfile, SessionRestored, UnloadedSessionDeleted}; -use crate::collaboration_model_policy::ModelPolicy; +use crate::collaboration_model_policy::{CollaborationModelPolicy, ModelPolicy}; use crate::protocol::SessionOrigin; -use crate::settings::{SettingsScope, SettingsService}; +use crate::settings::{Settings, SettingsError}; use dim_agent_capabilities::{ context_block, host::{ @@ -230,7 +230,7 @@ pub struct Collaboration { index: Arc, directory: Arc, /// The subagent model policy's source; local execution only. - settings: Option>, + policy_owner: Option, tasks: TaskTracker, stop: CancellationToken, #[cfg(feature = "testing")] @@ -279,14 +279,15 @@ impl Collaboration { .as_ref() .and_then(|model| model.metadata.as_ref()) .is_some_and(|metadata| metadata.startup.is_some()); - let policy = match &self.settings { + let policy = match &self.policy_owner { _ if startup => ModelPolicy::Inherit {}, - Some(settings) => { - settings - .read::(SettingsScope::User, &self.stop) + Some(ctx) => { + ctx.get::() + .ok_or_else(|| member_create_failed(SettingsError::UnknownSource.to_string()))? + .read(&self.stop) .await .map_err(|error| member_create_failed(error.to_string()))? - .document + .policy } None => ModelPolicy::Agent {}, }; @@ -719,7 +720,7 @@ impl Collaboration { /// with it, and the Session and branch parts it registers. pub(crate) struct CollaborationPlugin { /// The subagent model policy's source; local execution only, as Agents. - settings: Option>, + settings: Option>, index: Key, directory: Key, parts: Key, @@ -728,7 +729,7 @@ impl CollaborationPlugin { pub fn new(names: &Names<'_>, local_execution: bool) -> rutis::Result { Ok(Self { settings: local_execution - .then(|| names.key::()) + .then(|| names.key::()) .transpose()?, index: names.key()?, directory: names.key()?, @@ -754,14 +755,11 @@ impl DynPlugin for CollaborationPlugin { let index = ctx.require_at(&self.index)?; let directory = ctx.require_at(&self.directory)?; let parts = ctx.require_at(&self.parts)?; - let settings = match &self.settings { - Some(settings) => Some(ctx.require_at(settings)?), - None => None, - }; + let policy_owner = self.settings.as_ref().map(|_| ctx.clone()); let service = Arc::new(Collaboration { index, directory, - settings, + policy_owner, tasks: TaskTracker::new(), stop: CancellationToken::new(), #[cfg(feature = "testing")] diff --git a/crates/dim-app-server/src/collaboration_model_policy.rs b/crates/dim-app-server/src/collaboration_model_policy.rs index 45d7456050..22f8e55c9d 100644 --- a/crates/dim-app-server/src/collaboration_model_policy.rs +++ b/crates/dim-app-server/src/collaboration_model_policy.rs @@ -4,7 +4,7 @@ use crate::{ methods::ManagementMethods, protocol::Empty, - settings::{BusinessDocument, Settings, SettingsError, SettingsScope}, + settings::{BusinessDocument, RegisteredDocument, Settings, SettingsError, SettingsScope}, }; use dim_agent_capabilities::methods::{ Interruption, MethodCall, MethodDecl, RpcError, params, reply, @@ -73,15 +73,65 @@ struct SetPolicy { policy: ModelPolicy, } #[derive(Serialize)] -struct PolicyView { +pub(crate) struct PolicyView { revision: String, - policy: ModelPolicy, + pub(crate) policy: ModelPolicy, } #[derive(Serialize)] struct Revision { revision: String, } +#[derive(Clone)] +pub(crate) struct CollaborationModelPolicy(Arc>); + +impl CollaborationModelPolicy { + pub(crate) async fn read( + &self, + cancel: &tokio_util::sync::CancellationToken, + ) -> crate::settings::Result { + let snapshot = self.0.read(SettingsScope::User, cancel).await?; + Ok(PolicyView { + revision: snapshot.revision, + policy: snapshot.document, + }) + } +} + +impl rutis_bridge::session::HostDispatch for CollaborationModelPolicy { + fn methods(&self) -> Option { + Some(serde_json::json!({"read":"async"})) + } + fn invoke( + &self, + method: &str, + args: rutis_bridge::session::Value, + ) -> rutis_bridge::session::Reply { + use rutis_bridge::session::{Error, Value}; + if method != "read" { + return Err(Error::Value(format!( + "unknown collaborationModelPolicy method {method}" + ))); + } + let (_request,): (Empty,) = serde_json::from_value(args.json()?) + .map_err(|_| Error::Value("expected one empty request".into()))?; + let owner = self.clone(); + Ok(Value::future(async move { + let cancel = tokio_util::sync::CancellationToken::new(); + let _guard = cancel.clone().drop_guard(); + let view = owner.read(&cancel).await.map_err(|error| { + rutis_bridge::exports::failure( + "collaborationModelPolicy", + error.code(), + error.to_string(), + None, + ) + })?; + rutis_bridge::session::arg(&view) + })) + } +} + fn error(error: SettingsError) -> RpcError { let kind = match &error { SettingsError::Closed => return RpcError::reloading(), @@ -118,6 +168,12 @@ impl DynPlugin for CollaborationModelPolicyPlugin { let settings = ctx.require_at(&self.settings)?; let methods = ctx.require_at(&self.methods)?; let settings = settings.register_document::(ctx)?; + let owner = Arc::new(CollaborationModelPolicy(settings)); + ctx.provide_as::(owner.clone())?; + ctx.provide_at::( + rutis_bridge::session::host_key("collaborationModelPolicy"), + owner.clone(), + )?; methods.register( ctx, "collaboration", @@ -140,26 +196,20 @@ impl DynPlugin for CollaborationModelPolicyPlugin { params: value, .. } = call; - let settings = settings.clone(); + let owner = owner.clone(); Box::pin(async move { match method.as_str() { "collaboration.model_policy" => { let _: Empty = params(value)?; - let snapshot = settings - .read(SettingsScope::User, &stopping) - .await - .map_err(error)?; - reply(PolicyView { - revision: snapshot.revision, - policy: snapshot.document, - }) + reply(owner.read(&stopping).await.map_err(error)?) } "collaboration.set_model_policy" => { let p: SetPolicy = params(value)?; if let Err(SettingsError::Invalid(reason)) = p.policy.validate() { return Err(RpcError::invalid(reason)); } - let snapshot = settings + let snapshot = owner + .0 .update( SettingsScope::User, &p.expected_revision, diff --git a/crates/dim-app-server/src/lib.rs b/crates/dim-app-server/src/lib.rs index 2feea9c229..1d505927dc 100644 --- a/crates/dim-app-server/src/lib.rs +++ b/crates/dim-app-server/src/lib.rs @@ -1447,6 +1447,7 @@ pub(crate) fn register_names(catalog: &mut dim_agent_runtime::names::ServiceCata register::(catalog, Some(SESSION_GROUP)); register::(catalog, None); register::(catalog, None); + register::(catalog, None); register::(catalog, None); register::(catalog, None); register::(catalog, None); @@ -1475,6 +1476,7 @@ pub(crate) fn register_names(catalog: &mut dim_agent_runtime::names::ServiceCata "managedSearch", "auxiliaryModel", "settings", + "collaborationModelPolicy", "ocrHelper", ] { catalog.register_shared(name); diff --git a/crates/dim-app-server/src/mcp.rs b/crates/dim-app-server/src/mcp.rs index f2f4b01536..da2b7c7009 100644 --- a/crates/dim-app-server/src/mcp.rs +++ b/crates/dim-app-server/src/mcp.rs @@ -21,7 +21,9 @@ pub use session::{ McpWidgetResult, install, }; -use crate::settings::{BusinessDocument, SettingsError, SettingsScope, SettingsService}; +use crate::settings::{ + BusinessDocument, RegisteredDocument, Settings, SettingsError, SettingsScope, +}; use config::{ McpEntryError, McpPluginDocument, McpPluginServers, McpProjectEnablement, McpSecretEntry, McpSecrets, McpServerSettings, McpSettings, @@ -401,7 +403,7 @@ impl Drop for McpConnection { /// connection runs, and the credential key of that expansion. Every read and /// every path that contacts a server uses this one order. fn resolved_entry( - settings: &SettingsService, + settings: &McpDocuments, source: McpSource, id: &str, configuration: McpServerSettings, @@ -414,11 +416,17 @@ fn resolved_entry( McpSource::Plugins => config::Origin::Plugin, McpSource::Project(_) => config::Origin::Workspace { overlay: secret }, }; + let workspace = match source { + McpSource::Project(root) => Some(config::workspace( + &settings.authority, + SettingsScope::Project(root), + )?), + _ => None, + }; let expansion = config::connected( - settings, configuration.clone(), config::Connection { - scope: source.scope(), + workspace: workspace.as_deref(), id, secret, origin, @@ -427,14 +435,8 @@ fn resolved_entry( protected, }, )?; - let configuration = config::viewed( - settings, - source.scope(), - id, - configuration, - secret, - enablement, - )?; + let configuration = + config::viewed(workspace.as_deref(), id, configuration, secret, enablement)?; let credential = auth::credential_key(id, &expansion.configuration).map(|(key, _)| key); Ok(McpResolvedEntry { entry: McpServerEntry { @@ -452,8 +454,16 @@ fn resolved_entry( /// A plugin document's last refusal message and optional stable reason. pub type McpPluginRefusal = (String, Option<&'static str>); +struct McpDocuments { + authority: Arc, + servers: Arc>, + enablement: Arc>, + plugins: Arc>, + secrets: Arc>, +} + pub struct McpService { - settings: Arc, + settings: Arc, credentials: Arc, /// Why the last registration of a plugin was refused, by plugin id: the /// raw error, and its static reason when the cause has one @@ -596,7 +606,8 @@ impl McpService { pub async fn plugins(&self, cancel: &CancellationToken) -> Result> { self.run(cancel, move |settings, cancel| async move { Ok(settings - .read::(SettingsScope::User, &cancel) + .plugins + .read(SettingsScope::User, &cancel) .await? .document .plugins @@ -615,9 +626,7 @@ impl McpService { let changed = self .run(cancel, move |settings, cancel| async move { loop { - let current = settings - .read::(SettingsScope::User, &cancel) - .await?; + let current = settings.plugins.read(SettingsScope::User, &cancel).await?; let mut document = current.document; if document.plugins.get(&plugin) == registration.as_ref() { return Ok(false); @@ -633,6 +642,7 @@ impl McpService { } } match settings + .plugins .update(SettingsScope::User, ¤t.revision, document, &cancel) .await { @@ -674,7 +684,8 @@ impl McpService { let mut invalid: BTreeMap<(McpSource, String), McpEntryError> = BTreeMap::new(); let enablement = match project { Some(_) => settings - .read::(SettingsScope::User, &cancel) + .enablement + .read(SettingsScope::User, &cancel) .await .map(|snapshot| snapshot.document) .unwrap_or_default(), @@ -683,7 +694,8 @@ impl McpService { let secrets = match project { Some(_) => { settings - .read::(SettingsScope::User, &cancel) + .secrets + .read(SettingsScope::User, &cancel) .await? .document } @@ -691,9 +703,7 @@ impl McpService { }; for source in sources_in_precedence(project) { let Some(scope) = source.scope() else { - let plugins = settings - .read::(SettingsScope::User, &cancel) - .await?; + let plugins = settings.plugins.read(SettingsScope::User, &cancel).await?; let (entries, broken) = plugins.document.into_entries(); for (id, error) in broken { invalid.insert((source, id), error); @@ -714,10 +724,12 @@ impl McpService { continue; }; let workspace = match scope { - SettingsScope::Project(_) => Some(config::workspace(&settings, scope)?), + SettingsScope::Project(_) => { + Some(config::workspace(&settings.authority, scope)?) + } SettingsScope::User => None, }; - let snapshot = settings.read::(scope, &cancel).await?; + let snapshot = settings.servers.read(scope, &cancel).await?; match scope { SettingsScope::User => catalog.user_revision = snapshot.revision, SettingsScope::Project(_) => { @@ -784,7 +796,8 @@ impl McpService { let protected = credentials.variables().variables; let Some(scope) = source.scope() else { let (mut entries, mut invalid) = settings - .read::(SettingsScope::User, &cancel) + .plugins + .read(SettingsScope::User, &cancel) .await? .document .into_entries(); @@ -805,7 +818,7 @@ impl McpService { ); }; let source = scope; - let snapshot = settings.read::(source, &cancel).await?; + let snapshot = settings.servers.read(source, &cancel).await?; let document = snapshot.document; let Some(configuration) = document.get(&id).cloned() else { return match document.invalid_error(&id) { @@ -842,7 +855,8 @@ impl McpService { self.run(cancel, move |settings, cancel| async move { let Some(scope) = source.scope() else { let configuration = match settings - .read::(SettingsScope::User, &cancel) + .plugins + .read(SettingsScope::User, &cancel) .await? .document .declared(&id) @@ -852,10 +866,9 @@ impl McpService { Err(error) => return Err(McpError::InvalidEntry(error)), }; let expansion = config::connected( - &settings, configuration.clone(), config::Connection { - scope: None, + workspace: None, id: &id, secret: None, origin: config::Origin::Plugin, @@ -874,7 +887,7 @@ impl McpService { secret: None, }); }; - let snapshot = settings.read::(scope, &cancel).await?; + let snapshot = settings.servers.read(scope, &cancel).await?; let Some(mut configuration) = snapshot.document.get(&id).cloned() else { return match snapshot.document.invalid_error(&id) { Some(error) => Err(McpError::InvalidEntry(error.clone())), @@ -893,10 +906,9 @@ impl McpService { }, }; let expansion = config::connected( - &settings, configuration.clone(), config::Connection { - scope: None, + workspace: None, id: &id, secret: None, origin, @@ -909,7 +921,7 @@ impl McpService { SettingsScope::User => configuration.enabled(), SettingsScope::Project(_) => { let enablement = enablement(&settings, scope, &cancel).await; - let workspace = config::workspace(&settings, scope)?; + let workspace = config::workspace(&settings.authority, scope)?; enablement.contains(&workspace, &id) } }; @@ -957,7 +969,7 @@ impl McpService { return Err(McpError::InvalidId); } self.run(cancel, move |settings, cancel| async move { - let workspace = config::workspace(&settings, source)?; + let workspace = config::workspace(&settings.authority, source)?; remove_secret_if(&settings, &workspace, &id, &generation, &cancel).await }) .await @@ -984,11 +996,14 @@ impl McpService { overlay: overlay.as_ref(), }, }; + let workspace = match scope { + SettingsScope::Project(_) => Some(config::workspace(&settings.authority, scope)?), + SettingsScope::User => None, + }; Ok(config::connected( - &settings, configuration, config::Connection { - scope: Some(scope), + workspace: workspace.as_deref(), id: &id, secret: None, origin, @@ -1129,7 +1144,7 @@ impl McpService { cancel: &CancellationToken, ) -> Result { self.run(cancel, move |settings, cancel| async move { - let snapshot = settings.read::(source, &cancel).await?; + let snapshot = settings.servers.read(source, &cancel).await?; let overlays = overlays(&settings, source, &cancel).await?; Ok(import::preview( &document, @@ -1188,8 +1203,8 @@ impl McpService { } let into_project = matches!(to_scope, SettingsScope::Project(_)); self.run(cancel, move |settings, cancel| async move { - let from_snapshot = settings.read::(from_scope, &cancel).await?; - let to_snapshot = settings.read::(to_scope, &cancel).await?; + let from_snapshot = settings.servers.read(from_scope, &cancel).await?; + let to_snapshot = settings.servers.read(to_scope, &cancel).await?; let from_overlays = overlays(&settings, from_scope, &cancel).await?; let to_overlays = overlays(&settings, to_scope, &cancel).await?; if source_revision(from_scope, &from_snapshot.revision, &from_overlays) != expected_from @@ -1213,19 +1228,26 @@ impl McpService { config::merge_secret(&mut entry, secret)?; } let enablement = enablement(&settings, from_scope, &cancel).await; - let mut entry = config::effective(&settings, from_scope, &id, entry, &enablement)?; + let workspace = match from_scope { + SettingsScope::Project(_) => { + Some(config::workspace(&settings.authority, from_scope)?) + } + SettingsScope::User => None, + }; + let mut entry = config::effective(workspace.as_deref(), &id, entry, &enablement)?; let mut document = McpSettings::default(); document.insert(id.clone(), entry.clone()); document.validate()?; match to_scope { SettingsScope::Project(_) => { - let workspace = config::workspace(&settings, to_scope)?; + let workspace = config::workspace(&settings.authority, to_scope)?; let (skeleton, to_secret) = config::split_entry(&entry); set_project_enabled(&settings, to_scope, &id, false, &cancel).await?; let mut destination = to_snapshot.document; destination.insert(id.clone(), skeleton); settings + .servers .update(to_scope, &to_snapshot.revision, destination, &cancel) .await?; if let Some(secret) = to_secret { @@ -1242,12 +1264,13 @@ impl McpService { let mut source = from_snapshot.document; source.remove(&id); settings + .servers .update(from_scope, &from_snapshot.revision, source, &cancel) .await .map_err(|error| partial(error.into(), into_project))?; } SettingsScope::User => { - let workspace = config::workspace(&settings, from_scope)?; + let workspace = config::workspace(&settings.authority, from_scope)?; let enabled = enablement.contains(&workspace, &id); let (McpServerSettings::Stdio { enabled: field, .. } | McpServerSettings::Remote { enabled: field, .. }) = &mut entry; @@ -1255,6 +1278,7 @@ impl McpService { let mut destination = to_snapshot.document; destination.insert(id.clone(), entry); settings + .servers .update(to_scope, &to_snapshot.revision, destination, &cancel) .await?; if let Err(error) = @@ -1270,6 +1294,7 @@ impl McpService { let mut source = from_snapshot.document; source.remove(&id); settings + .servers .update(from_scope, &from_snapshot.revision, source, &cancel) .await .map_err(|error| partial(error.into(), into_project))?; @@ -1283,7 +1308,7 @@ impl McpService { async fn run(&self, cancel: &CancellationToken, operation: F) -> Result where T: Send + 'static, - F: FnOnce(Arc, CancellationToken) -> Fut + Send + 'static, + F: FnOnce(Arc, CancellationToken) -> Fut + Send + 'static, Fut: Future> + Send + 'static, { let task = { @@ -1316,14 +1341,15 @@ impl McpService { /// The user's enablement of project entries; empty for the user source, whose /// entries carry their own field. async fn enablement( - settings: &SettingsService, + settings: &McpDocuments, scope: SettingsScope, cancel: &CancellationToken, ) -> McpProjectEnablement { match scope { SettingsScope::User => McpProjectEnablement::default(), SettingsScope::Project(_) => settings - .read::(SettingsScope::User, cancel) + .enablement + .read(SettingsScope::User, cancel) .await .map(|snapshot| snapshot.document) .unwrap_or_default(), @@ -1332,7 +1358,7 @@ async fn enablement( /// One project entry's user-scope secret overlay, if it has one. async fn secret( - settings: &SettingsService, + settings: &McpDocuments, scope: SettingsScope, id: &str, cancel: &CancellationToken, @@ -1340,10 +1366,8 @@ async fn secret( let SettingsScope::Project(_) = scope else { return Ok(None); }; - let workspace = config::workspace(settings, scope)?; - let snapshot = settings - .read::(SettingsScope::User, cancel) - .await?; + let workspace = config::workspace(&settings.authority, scope)?; + let snapshot = settings.secrets.read(SettingsScope::User, cancel).await?; Ok(snapshot.document.get(&workspace, id).cloned()) } @@ -1364,7 +1388,7 @@ struct WriteOutcome { /// Writes one change to its source and returns the source's revision and the /// removal's captured record generation. async fn write( - settings: &Arc, + settings: &Arc, source: SettingsScope, expected: String, id: String, @@ -1376,7 +1400,7 @@ async fn write( // A disable does not need the project file, so an unreadable file // still withdraws the record. A readable file names a broken entry, // whose disable is refused. - let snapshot = settings.read::(source, cancel).await; + let snapshot = settings.servers.read(source, cancel).await; if let Ok(snapshot) = &snapshot && let Some(error) = snapshot.document.invalid_error(&id) { @@ -1389,7 +1413,7 @@ async fn write( entry_absent: false, }); } - let snapshot = settings.read::(source, cancel).await?; + let snapshot = settings.servers.read(source, cancel).await?; let overlays = overlays(settings, source, cancel).await?; if source_revision(source, &snapshot.revision, &overlays) != expected { return Err(SettingsError::Conflict.into()); @@ -1442,6 +1466,7 @@ async fn write( }; let Some(present) = removed else { let written = settings + .servers .update(source, &snapshot.revision, document, cancel) .await?; return Ok(WriteOutcome { @@ -1455,6 +1480,7 @@ async fn write( let captured = overlays.get(&id).map(|secret| secret.generation.clone()); let revision = if present { settings + .servers .update(source, &snapshot.revision, document, cancel) .await? .revision @@ -1482,14 +1508,14 @@ async fn write( /// source commit answers `ImportPartial`, and the source entries stay as /// written. async fn write_import( - settings: &Arc, + settings: &Arc, source: SettingsScope, expected: String, document: McpSettings, resolutions: BTreeMap, cancel: &CancellationToken, ) -> Result { - let snapshot = settings.read::(source, cancel).await?; + let snapshot = settings.servers.read(source, cancel).await?; let project = matches!(source, SettingsScope::Project(_)); let overlays = overlays(settings, source, cancel).await?; if source_revision(source, &snapshot.revision, &overlays) != expected { @@ -1511,11 +1537,12 @@ async fn write_import( target.insert(id, configuration); } let written = settings + .servers .update(source, &snapshot.revision, target, cancel) .await?; return Ok(source_revision(source, &written.revision, &overlays)); } - let workspace = config::workspace(settings, source)?; + let workspace = config::workspace(&settings.authority, source)?; // Every id the import writes, an import or a replace, has its // `mcp-projects` record withdrawn before the source write, so an imported // configuration never runs enabled and a replaced entry cannot run while @@ -1534,6 +1561,7 @@ async fn write_import( records.push((id, record)); } let revision = settings + .servers .update(source, &snapshot.revision, target, cancel) .await? .revision; @@ -1554,16 +1582,14 @@ async fn write_import( /// part removes the destination's record, so the pair the import leaves is /// exactly the configuration the document carried. async fn write_import_secrets( - settings: &Arc, + settings: &Arc, workspace: &str, records: &[(String, Option)], planned: &BTreeMap, cancel: &CancellationToken, ) -> Result<()> { loop { - let snapshot = settings - .read::(SettingsScope::User, cancel) - .await?; + let snapshot = settings.secrets.read(SettingsScope::User, cancel).await?; let current = snapshot .document .entries @@ -1590,6 +1616,7 @@ async fn write_import_secrets( } } match settings + .secrets .update(SettingsScope::User, &snapshot.revision, document, cancel) .await { @@ -1603,16 +1630,17 @@ async fn write_import_secrets( /// The `mcp-secrets` records of one project source's workspace, by id. A user /// source has no record. async fn overlays( - settings: &Arc, + settings: &Arc, source: SettingsScope, cancel: &CancellationToken, ) -> Result> { let SettingsScope::Project(_) = source else { return Ok(BTreeMap::new()); }; - let workspace = config::workspace(settings, source)?; + let workspace = config::workspace(&settings.authority, source)?; Ok(settings - .read::(SettingsScope::User, cancel) + .secrets + .read(SettingsScope::User, cancel) .await? .document .overlays(&workspace)) @@ -1662,7 +1690,7 @@ fn source_revision( /// already hold them. A source whose records cannot be read keeps the document /// revision: no caller can apply against it, so the fallback fails closed. async fn read_source_revision( - settings: &Arc, + settings: &Arc, source: SettingsScope, file: &str, cancel: &CancellationToken, @@ -1674,38 +1702,36 @@ async fn read_source_revision( } async fn write_secret( - settings: &Arc, + settings: &Arc, workspace: &str, id: &str, mut secret: McpSecretEntry, cancel: &CancellationToken, ) -> Result<()> { secret.generation = uuid::Uuid::new_v4().to_string(); - let snapshot = settings - .read::(SettingsScope::User, cancel) - .await?; + let snapshot = settings.secrets.read(SettingsScope::User, cancel).await?; let mut document = snapshot.document; document.set(workspace, id, secret); settings + .secrets .update(SettingsScope::User, &snapshot.revision, document, cancel) .await?; Ok(()) } async fn remove_secret( - settings: &Arc, + settings: &Arc, workspace: &str, id: &str, cancel: &CancellationToken, ) -> Result<()> { - let snapshot = settings - .read::(SettingsScope::User, cancel) - .await?; + let snapshot = settings.secrets.read(SettingsScope::User, cancel).await?; let mut document = snapshot.document; if !document.remove(workspace, id) { return Ok(()); } settings + .secrets .update(SettingsScope::User, &snapshot.revision, document, cancel) .await?; Ok(()) @@ -1714,16 +1740,14 @@ async fn remove_secret( /// Deletes the record only while it still carries `generation`; a replacement /// move writes a new generation for the same id, and that record is kept. async fn remove_secret_if( - settings: &Arc, + settings: &Arc, workspace: &str, id: &str, generation: &str, cancel: &CancellationToken, ) -> Result<()> { loop { - let snapshot = settings - .read::(SettingsScope::User, cancel) - .await?; + let snapshot = settings.secrets.read(SettingsScope::User, cancel).await?; let Some(current) = snapshot.document.get(workspace, id) else { return Ok(()); }; @@ -1733,6 +1757,7 @@ async fn remove_secret_if( let mut document = snapshot.document; document.remove(workspace, id); match settings + .secrets .update(SettingsScope::User, &snapshot.revision, document, cancel) .await { @@ -1747,22 +1772,24 @@ async fn remove_secret_if( /// entries commute, so a lost race on the shared record is retried rather /// than reported as a conflict the caller cannot observe. async fn set_project_enabled( - settings: &Arc, + settings: &Arc, source: SettingsScope, id: &str, enabled: bool, cancel: &CancellationToken, ) -> Result<()> { - let workspace = config::workspace(settings, source)?; + let workspace = config::workspace(&settings.authority, source)?; loop { let current = settings - .read::(SettingsScope::User, cancel) + .enablement + .read(SettingsScope::User, cancel) .await?; let mut record = current.document; if !record.set(&workspace, id, enabled) { return Ok(()); } match settings + .enablement .update(SettingsScope::User, ¤t.revision, record, cancel) .await { @@ -1778,7 +1805,7 @@ async fn set_project_enabled( /// Session part `McpSession`, which it registers. pub struct McpPlugin { home_root: usize, - settings: Key, + settings: Key, publication: Key, files: Key, methods: Key, @@ -1820,13 +1847,17 @@ impl DynPlugin for McpPlugin { let methods = ctx.require_at(&self.methods)?; let parts = ctx.require_at(&self.parts)?; let credentials = ctx.require_at(&self.credentials)?; - settings.register::(ctx)?; - settings.register::(ctx)?; - settings.register::(ctx)?; - settings.register::(ctx)?; + let documents = Arc::new(McpDocuments { + servers: settings.register_document::(ctx)?, + enablement: settings.register_document::(ctx)?, + plugins: settings.register_document::(ctx)?, + secrets: settings.register_document::(ctx)?, + authority: settings.clone(), + }); let auth = McpAuth::new(files, self.home_root).map_err(ErrorKind::PluginFailed)?; + *publication.documents.lock().unwrap() = Some(documents.clone()); let service = Arc::new(McpService { - settings, + settings: documents, credentials, refused: Mutex::default(), publication, @@ -1844,13 +1875,7 @@ impl DynPlugin for McpPlugin { closing.close().await; Ok(()) })?; - management::provide( - ctx, - &methods, - service.clone(), - service.settings.clone(), - auth.clone(), - )?; + management::provide(ctx, &methods, service.clone(), settings, auth.clone())?; ctx.provide_as::(auth)?; ctx.provide_at(owner_key(), service.clone())?; let binding = Arc::new(McpServiceBinding(service)); diff --git a/crates/dim-app-server/src/mcp/config.rs b/crates/dim-app-server/src/mcp/config.rs index b108234513..69d21263f5 100644 --- a/crates/dim-app-server/src/mcp/config.rs +++ b/crates/dim-app-server/src/mcp/config.rs @@ -1,5 +1,5 @@ //! Typed MCP documents and the effective configuration of each entry. -use crate::settings::{BusinessDocument, Result, SettingsError, SettingsScope, SettingsService}; +use crate::settings::{BusinessDocument, Result, Settings, SettingsError, SettingsScope}; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use std::{ @@ -1801,12 +1801,16 @@ fn literal_scheme(value: &str) -> Option<&str> { /// The canonical workspace of an authorized project source, as the /// enablement key. -pub(crate) fn workspace(settings: &SettingsService, scope: SettingsScope) -> Result { +pub(crate) fn workspace(settings: &Settings, scope: SettingsScope) -> Result { let SettingsScope::Project(root) = scope else { return Err(SettingsError::Invalid("not a project MCP source")); }; settings - .project_path(root)? + .projects() + .into_iter() + .find(|project| project.root == root) + .ok_or(SettingsError::Invalid("unauthorized project"))? + .cwd .to_str() .map(str::to_owned) .ok_or(SettingsError::Invalid("project cwd must be UTF-8")) @@ -1816,7 +1820,7 @@ pub(crate) fn workspace(settings: &SettingsService, scope: SettingsScope) -> Res /// source it belongs to, the overlay to merge, who wrote each member, the /// user's project enablement, and the environment to expand from. pub(crate) struct Connection<'a> { - pub scope: Option, + pub workspace: Option<&'a str>, pub id: &'a str, pub secret: Option<&'a McpSecretEntry>, pub origin: Origin<'a>, @@ -1830,12 +1834,11 @@ pub(crate) struct Connection<'a> { /// `cwd` and enablement. Every caller uses this one order, so a probe and a /// published connection see the same values. pub(crate) fn connected( - settings: &SettingsService, configuration: McpServerSettings, connection: Connection<'_>, ) -> Result { let Connection { - scope, + workspace, id, secret, origin, @@ -1848,10 +1851,7 @@ pub(crate) fn connected( merge_secret(&mut configuration, secret)?; } let expansion = expand(&configuration, origin, environment, protected); - let configuration = match scope { - Some(scope) => effective(settings, scope, id, expansion.configuration, enablement)?, - None => expansion.configuration, - }; + let configuration = effective(workspace, id, expansion.configuration, enablement)?; Ok(Expanded { configuration, referenced: expansion.referenced, @@ -1863,8 +1863,7 @@ pub(crate) fn connected( /// the project workspace `cwd` joined, with references kept as written so a /// client can edit them. pub(crate) fn viewed( - settings: &SettingsService, - scope: Option, + workspace: Option<&str>, id: &str, configuration: McpServerSettings, secret: Option<&McpSecretEntry>, @@ -1874,29 +1873,24 @@ pub(crate) fn viewed( if let Some(secret) = secret { merge_secret(&mut configuration, secret)?; } - match scope { - Some(scope) => effective(settings, scope, id, configuration, enablement), - None => Ok(configuration), - } + effective(workspace, id, configuration, enablement) } /// The configuration an entry runs with. A project entry resolves its stdio /// cwd against the workspace and takes its enablement only from the user's /// record; its own `enabled` field is ignored. pub(crate) fn effective( - settings: &SettingsService, - scope: SettingsScope, + workspace: Option<&str>, id: &str, mut config: McpServerSettings, enablement: &McpProjectEnablement, ) -> Result { - if matches!(scope, SettingsScope::Project(_)) { - let workspace = workspace(settings, scope)?; + if let Some(workspace) = workspace { let (McpServerSettings::Stdio { enabled, .. } | McpServerSettings::Remote { enabled, .. }) = &mut config; - *enabled = Some(enablement.contains(&workspace, id)); + *enabled = Some(enablement.contains(workspace, id)); if let McpServerSettings::Stdio { cwd, .. } = &mut config { - let workspace = PathBuf::from(&workspace); + let workspace = PathBuf::from(workspace); let path = cwd .as_ref() .map_or(workspace.clone(), |cwd| workspace.join(cwd)); diff --git a/crates/dim-app-server/src/mcp/management.rs b/crates/dim-app-server/src/mcp/management.rs index 0fba6aab08..7ffb28c0ac 100644 --- a/crates/dim-app-server/src/mcp/management.rs +++ b/crates/dim-app-server/src/mcp/management.rs @@ -9,7 +9,7 @@ use super::{McpChange, McpError, McpService, McpSource}; use crate::{ methods::{ManagementMethods, SelectionScope}, protocol::{canonical_cwd, optional_non_null}, - settings::{BusinessDocument, SettingsError, SettingsScope, SettingsService}, + settings::{BusinessDocument, Settings, SettingsError, SettingsScope}, }; use dim_agent_capabilities::methods::{ Interruption, MethodCall, MethodDecl, RpcError, params, reply, @@ -553,7 +553,7 @@ pub(crate) fn error(error: McpError) -> RpcError { /// canonical path and the string the request named it by. Claude Code records /// its local store under either spelling, so both are carried. async fn authorized_workspace( - settings: &Arc, + settings: &Arc, cwd: Option, stopping: &CancellationToken, ) -> Result, RpcError> { @@ -573,7 +573,7 @@ async fn authorized_workspace( } async fn project( - settings: &Arc, + settings: &Arc, cwd: Option, stopping: &CancellationToken, ) -> Result, RpcError> { @@ -662,7 +662,7 @@ pub(super) fn provide( ctx: &Ctx, methods: &ManagementMethods, directory: Arc, - settings: Arc, + settings: Arc, auth: Arc, ) -> Result<(), Error> { let context = ctx.clone(); diff --git a/crates/dim-app-server/src/mcp/publication.rs b/crates/dim-app-server/src/mcp/publication.rs index 77ae5463ee..dbeb9b7dbc 100644 --- a/crates/dim-app-server/src/mcp/publication.rs +++ b/crates/dim-app-server/src/mcp/publication.rs @@ -1,14 +1,12 @@ //! Serialized host authority for source selection and cross-Session retirement. //! Connection resources and disposal belong exclusively to loader instances. -use super::config::{ - self, McpPluginServers, McpProjectEnablement, McpSecrets, McpServerSettings, McpSettings, -}; +use super::config::{self, McpProjectEnablement, McpSecrets, McpServerSettings}; use super::{ - McpAuth, McpConnection, McpError, McpSource, Result, daemon_environment, + McpAuth, McpConnection, McpDocuments, McpError, McpSource, Result, daemon_environment, server::{McpRuntime, McpServer, McpServerError, McpServerPlugin, McpServerState}, source_revision, sources_in_precedence, }; -use crate::settings::{SettingsScope, SettingsService}; +use crate::settings::{ProjectAuthorized, Settings, SettingsScope}; use dim_agent_capabilities::host::CredentialVariablesHost; use dim_agent_runtime::{ Modules, Names, SessionLifecycle, SessionLoader, SessionPhase, StateCell, @@ -136,6 +134,7 @@ enum Command { Settle { reply: oneshot::Sender> }, } pub struct Publication { + pub(super) documents: std::sync::Mutex>>, commands: mpsc::Sender, released: watch::Sender<()>, applications: StateCell>, @@ -218,7 +217,7 @@ impl Publication { } pub struct McpPublication { - settings: Key, + authority: Key, credentials: Key, } struct Worker { @@ -231,7 +230,7 @@ struct Worker { impl McpPublication { pub fn new(names: &Names<'_>) -> rutis::Result { Ok(Self { - settings: names.key()?, + authority: names.key()?, credentials: names.key()?, }) } @@ -258,7 +257,7 @@ impl McpPublication { } } impl Worker { - async fn run(mut self, settings: Arc, stop: CancellationToken) -> Result<()> { + async fn run(mut self, stop: CancellationToken) -> Result<()> { let mut projection = Projection { port: self.port.clone(), credentials: self.credentials.clone(), @@ -278,7 +277,10 @@ impl Worker { _ = self.released.changed() => None, _ = changes.changed() => None, }; - projection.refresh(&settings, &operation).await; + let settings = self.port.documents.lock().unwrap().clone(); + if let Some(settings) = &settings { + projection.refresh(settings, &operation).await; + } match command { Some(Command::Acquire { owner, @@ -289,9 +291,14 @@ impl Worker { if reply.is_closed() { continue; } - let result = projection - .acquire(&settings, owner, project, id, &operation) - .await; + let result = match &settings { + Some(settings) => { + projection + .acquire(settings, owner, project, id, &operation) + .await + } + None => Err(McpError::Closed), + }; if let Err(Ok(lease)) = reply.send(result) { let references = projection .generations @@ -343,15 +350,15 @@ impl DynPlugin for McpPublication { "McpPublication" } fn injects(&self) -> Vec { - vec![self.settings.erase(), self.credentials.erase()] + vec![self.authority.erase(), self.credentials.erase()] } fn apply<'a>(&'a self, ctx: &'a Ctx) -> BoxFuture<'a, rutis::Result> { Box::pin(async move { - let settings = ctx.require_at(&self.settings)?; let credentials = ctx.require_at(&self.credentials)?; let (commands, receiver) = mpsc::channel(64); let (released, releases) = watch::channel(()); let port = Arc::new(Publication { + documents: Default::default(), commands, released, applications: StateCell::new(BTreeMap::new()), @@ -366,7 +373,7 @@ impl DynPlugin for McpPublication { ctx.provide_as::(port)?; let stop = ctx.cancellation_token(); ctx.effect(move || { - let task = tokio::spawn(worker.run(settings, stop.clone())); + let task = tokio::spawn(worker.run(stop.clone())); async move { stop.cancel(); Ok(task.await??) @@ -417,16 +424,17 @@ impl Projection { fn withdrawn( &self, generation: &Generation, - projects: &[(usize, std::path::PathBuf)], + projects: &[ProjectAuthorized], enablement: &McpProjectEnablement, ) -> bool { // A project entry runs only while the user's record names it, and that // record is readable whenever the disable is: the source may be // unreadable, so its last `current` state is not consulted here. if let McpSource::Project(root) = generation.source - && !projects.iter().any(|(project, workspace)| { - *project == root - && workspace + && !projects.iter().any(|project| { + project.root == root + && project + .cwd .to_str() .is_some_and(|workspace| enablement.contains(workspace, &generation.id)) }) @@ -440,13 +448,14 @@ impl Projection { } }) } - async fn refresh(&mut self, settings: &SettingsService, cancel: &CancellationToken) { - let projects = settings.project_sources(); + async fn refresh(&mut self, settings: &McpDocuments, cancel: &CancellationToken) { + let projects = settings.authority.projects(); let enablement = if projects.is_empty() { Ok(McpProjectEnablement::default()) } else { settings - .read::(SettingsScope::User, cancel) + .enablement + .read(SettingsScope::User, cancel) .await .map(|snapshot| snapshot.document) }; @@ -456,15 +465,20 @@ impl Projection { Ok(McpSecrets::default()) } else { settings - .read::(SettingsScope::User, cancel) + .secrets + .read(SettingsScope::User, cancel) .await .map(|snapshot| snapshot.document) }; let secrets_unreadable = secrets.is_err(); let secrets = secrets.unwrap_or_default(); - for source in [McpSource::User, McpSource::Plugins] + for (source, workspace) in [(McpSource::User, None), (McpSource::Plugins, None)] .into_iter() - .chain(projects.iter().map(|(root, _)| McpSource::Project(*root))) + .chain( + projects + .iter() + .map(|project| (McpSource::Project(project.root), project.cwd.to_str())), + ) { if secrets_unreadable && matches!(source, McpSource::Project(_)) { let intent = self.sources.entry(source).or_insert_with(|| Source { @@ -479,11 +493,13 @@ impl Projection { } let read = match source.scope() { Some(scope) => settings - .read::(scope, cancel) + .servers + .read(scope, cancel) .await .map(|snapshot| (snapshot.revision, snapshot.document.into_parts().0)), None => settings - .read::(SettingsScope::User, cancel) + .plugins + .read(SettingsScope::User, cancel) .await .map(|snapshot| (snapshot.revision, snapshot.document.entries())), }; @@ -498,15 +514,12 @@ impl Projection { degraded: None, }); intent.error = Some("MCP source could not be read"); - if let McpSource::Project(root) = source { - let workspace = - config::workspace(settings, SettingsScope::Project(root)).ok(); + if matches!(source, McpSource::Project(_)) { for (id, config) in &mut intent.current { let (McpServerSettings::Stdio { enabled, .. } | McpServerSettings::Remote { enabled, .. }) = config; *enabled = Some( workspace - .as_deref() .is_some_and(|workspace| enablement.contains(workspace, id)), ); } @@ -514,10 +527,6 @@ impl Projection { continue; } }; - let workspace = match source.scope() { - Some(scope @ SettingsScope::Project(_)) => config::workspace(settings, scope).ok(), - _ => None, - }; // A project source is served from `.mcp.json` and the workspace's // withheld records, so its applied token names both (D5, D23). An // `appliedRevision` over the document alone would never match the @@ -554,10 +563,9 @@ impl Projection { McpSource::Project(_) => config::Origin::Workspace { overlay: secret }, }; let expansion = config::connected( - settings, config, config::Connection { - scope: source.scope(), + workspace, id: &id, secret, origin, @@ -665,7 +673,7 @@ impl Projection { } async fn acquire( &mut self, - settings: &SettingsService, + settings: &McpDocuments, owner: McpOwner, project: Option, id: String, diff --git a/crates/dim-app-server/src/mcp/session.rs b/crates/dim-app-server/src/mcp/session.rs index a7683bec27..9a4fad7c27 100644 --- a/crates/dim-app-server/src/mcp/session.rs +++ b/crates/dim-app-server/src/mcp/session.rs @@ -475,7 +475,13 @@ impl DynPlugin for McpSessionPlugin { let loader = ctx.require_at(&self.loader)?; let session = ctx.require_at(&self.lifecycle)?; let tools = ctx.require_at(&self.tools)?; - let project = directory.settings.project_root(Path::new(&config.cwd)); + let project = directory + .settings + .authority + .projects() + .into_iter() + .find(|project| project.cwd == Path::new(&config.cwd)) + .map(|project| project.root); let settings = super::config::settings_changes(ctx)?; let applied = directory.publication.applied(); let stopped = ctx.cancellation_token(); diff --git a/crates/dim-app-server/src/settings/declared.rs b/crates/dim-app-server/src/settings/declared.rs index fb9010e549..c23230af16 100644 --- a/crates/dim-app-server/src/settings/declared.rs +++ b/crates/dim-app-server/src/settings/declared.rs @@ -336,9 +336,8 @@ fn request(args: RpcValue) -> std::result::Result serde_json::from_value(request).map_err(|_| invalid()) } -/// The owner path: `settings` by name for every language (§4.2). Only -/// `register` uses the caller's identity, to withdraw its sources when the -/// calling row unloads; each source has one owner (AGENTS.md rule 11). +/// The owner path: `settings` by name for every language (§4.2). Source registrations +/// belong to the calling row and expire when it unloads. pub struct Settings(Arc); impl Settings { /// Registers a source with its existing decoder, defaults and write validation. diff --git a/crates/dim-app-server/tests/transport_flow/collaboration.rs b/crates/dim-app-server/tests/transport_flow/collaboration.rs index 4235da2d1f..f232419dad 100644 --- a/crates/dim-app-server/tests/transport_flow/collaboration.rs +++ b/crates/dim-app-server/tests/transport_flow/collaboration.rs @@ -542,6 +542,7 @@ async fn launch_held_team( } struct CaptureMemberConfig { + context: Arc>, configs: Arc>>>, config: rutis::host::Key, @@ -550,9 +551,11 @@ impl CaptureMemberConfig { fn new( names: &dim_agent_runtime::Names<'_>, configs: Arc>>>, + context: Arc>, ) -> rutis::Result { Ok(Self { configs, + context, config: names.key()?, }) } @@ -570,6 +573,7 @@ impl rutis::host::DynPlugin for CaptureMemberConfig { ) -> rutis::host::BoxFuture<'a, rutis::Result> { Box::pin(async move { let config = ctx.require_at(&self.config)?; + self.context.get_or_init(|| ctx.clone()); self.configs.lock().unwrap().push(config); Ok(rutis::host::Effect::Done) }) @@ -583,6 +587,8 @@ async fn product_collaboration_adopts_profile_and_default_capabilities() { std::fs::create_dir_all(&home).unwrap(); let configs = Arc::new(std::sync::Mutex::new(Vec::new())); let observed = configs.clone(); + let context = Arc::new(std::sync::OnceLock::new()); + let captured = context.clone(); let (server, agent) = launch_with(Arc::new(MockTools), ServerConfig { product_home: Some(home.clone()), target_home: Some(home.join("rust")), @@ -590,7 +596,10 @@ async fn product_collaboration_adopts_profile_and_default_capabilities() { }, move |builder| { builder.require_feature(Feature::new("capture-member-config").session( "capture-member-config", - move |names| Ok(Box::new(CaptureMemberConfig::new(names, observed.clone())?)), + move |names| { + let part = CaptureMemberConfig::new(names, observed.clone(), captured.clone())?; + Ok(Box::new(part)) + }, )); }).await; let mut client = Client::new_version(&server, false, 4).await; @@ -627,6 +636,12 @@ async fn product_collaboration_adopts_profile_and_default_capabilities() { let mut remote = Client::new_version(&server, true, 4).await; assert_eq!(remote.rpc("collaboration.model_policy", json!({})).await["error"]["data"]["appError"], "local_transport_required"); let read = client.rpc("collaboration.model_policy", json!({})).await; + let policy = context.get().unwrap().get_at::( + &rutis_bridge::session::host_key("collaborationModelPolicy"), + ).unwrap(); + let wire = policy.invoke("read", json!([{}]).into()).unwrap(); + let wire = rutis_bridge::session::settle(wire).await.unwrap().json().unwrap(); + assert_eq!(wire, read["result"]); assert_eq!(read["result"]["policy"], json!({"mode":"agent"})); let initial = read["result"]["revision"].as_str().unwrap().to_owned(); for invalid in [ diff --git a/docs/architecture/rust-agent/generated/app-server/services.json b/docs/architecture/rust-agent/generated/app-server/services.json index bed547bf03..86a1b08222 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.json +++ b/docs/architecture/rust-agent/generated/app-server/services.json @@ -1508,7 +1508,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" } @@ -1533,7 +1533,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -1557,12 +1557,6 @@ "provider": 39, "declared": true, "external": true - }, - { - "service": "dim_app_server::settings::SettingsService", - "provider": 18, - "declared": true, - "external": true } ] }, @@ -2427,7 +2421,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" } @@ -2464,7 +2458,7 @@ "generation": 1 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -2502,7 +2496,7 @@ "external": true }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "provider": 18, "declared": true, "external": true @@ -2522,7 +2516,7 @@ "status": "Ready" }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "status": "Ready" } @@ -2535,7 +2529,7 @@ "generation": 0 }, { - "service": "dim_app_server::settings::SettingsService", + "service": "dim_app_server::settings::declared::Settings", "scope": null, "provider": 18, "generation": 1 @@ -2547,12 +2541,6 @@ "provider": 1, "declared": true, "external": false - }, - { - "service": "dim_app_server::settings::SettingsService", - "provider": 18, - "declared": true, - "external": true } ] }, @@ -3517,6 +3505,12 @@ "generation": 1, "removing": false }, + { + "service": "dim_app_server::collaboration_model_policy::CollaborationModelPolicy", + "provider": 35, + "generation": 1, + "removing": false + }, { "service": "dim_app_server::connection::ConnectionHub", "provider": 43, @@ -3727,6 +3721,12 @@ "generation": 1, "removing": false }, + { + "service": "dyn rutis_bridge::session::services::HostDispatch#collaborationModelPolicy", + "provider": 35, + "generation": 1, + "removing": false + }, { "service": "dyn rutis_bridge::session::services::HostDispatch#credentialVariablesHost", "provider": 1, diff --git a/docs/architecture/rust-agent/generated/app-server/services.md b/docs/architecture/rust-agent/generated/app-server/services.md index ff159fc98f..de82202a0f 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.md +++ b/docs/architecture/rust-agent/generated/app-server/services.md @@ -147,7 +147,7 @@ flowchart LR p46 -->|"dim_agent_runtime::parts::PartRegistry"| p41 p40 -->|"dim_app_server::agents::AgentIndex"| p41 p39 -->|"dim_app_server::collaboration::CollaborationDirectory"| p41 - p18 -->|"dim_app_server::settings::SettingsService"| p41 + p18 -->|"dim_app_server::settings::declared::Settings"| p41 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p40 p38 -->|"dim_app_server::agents::AgentDirectory"| p40 p3 -->|"dim_app_server::control::ProcessActivity"| p40 @@ -190,9 +190,9 @@ flowchart LR p46 -->|"dim_agent_runtime::parts::PartRegistry"| p24 p23 -->|"dim_app_server::mcp::publication::Publication"| p24 p10 -->|"dim_app_server::methods::ManagementMethods"| p24 - p18 -->|"dim_app_server::settings::SettingsService"| p24 + p18 -->|"dim_app_server::settings::declared::Settings"| p24 p1 -->|"dim_agent_capabilities::host::CredentialVariablesHost"| p23 - p18 -->|"dim_app_server::settings::SettingsService"| p23 + p18 -->|"dim_app_server::settings::declared::Settings"| p23 p4 -->|"dim_agent_capabilities::file_storage::FileStorage"| p22 p18 -->|"dim_app_server::settings::declared::Settings"| p22 p18 -->|"dim_app_server::settings::declared::Settings"| p21 diff --git a/docs/architecture/rust-agent/generated/app-server/services.mmd b/docs/architecture/rust-agent/generated/app-server/services.mmd index 1ea96c60f6..7b4a1c6afa 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.mmd +++ b/docs/architecture/rust-agent/generated/app-server/services.mmd @@ -142,7 +142,7 @@ flowchart LR p46 -->|"dim_agent_runtime::parts::PartRegistry"| p41 p40 -->|"dim_app_server::agents::AgentIndex"| p41 p39 -->|"dim_app_server::collaboration::CollaborationDirectory"| p41 - p18 -->|"dim_app_server::settings::SettingsService"| p41 + p18 -->|"dim_app_server::settings::declared::Settings"| p41 p46 -->|"dim_agent_runtime::parts::PartRegistry"| p40 p38 -->|"dim_app_server::agents::AgentDirectory"| p40 p3 -->|"dim_app_server::control::ProcessActivity"| p40 @@ -185,9 +185,9 @@ flowchart LR p46 -->|"dim_agent_runtime::parts::PartRegistry"| p24 p23 -->|"dim_app_server::mcp::publication::Publication"| p24 p10 -->|"dim_app_server::methods::ManagementMethods"| p24 - p18 -->|"dim_app_server::settings::SettingsService"| p24 + p18 -->|"dim_app_server::settings::declared::Settings"| p24 p1 -->|"dim_agent_capabilities::host::CredentialVariablesHost"| p23 - p18 -->|"dim_app_server::settings::SettingsService"| p23 + p18 -->|"dim_app_server::settings::declared::Settings"| p23 p4 -->|"dim_agent_capabilities::file_storage::FileStorage"| p22 p18 -->|"dim_app_server::settings::declared::Settings"| p22 p18 -->|"dim_app_server::settings::declared::Settings"| p21 diff --git a/docs/architecture/rust-agent/generated/catalog.md b/docs/architecture/rust-agent/generated/catalog.md index 815fdbc922..cef5a6fee4 100644 --- a/docs/architecture/rust-agent/generated/catalog.md +++ b/docs/architecture/rust-agent/generated/catalog.md @@ -15,6 +15,7 @@ Each catalog name a part of the assembly provides or injects. `data` means share | `basePromptSettingsHost` | process | PromptSettings | data | `base` async | | `callChannel` | process | CallChannel | data | `closed` async, `notify` async | | `collaborationDirectory` | process | CollaborationDirectory | data | `relations` async | +| `collaborationModelPolicy` | process | CollaborationModelPolicy | data | `read` async | | `connectionHub` | process | Connection | internal(control) | — | | `credentialVariablesHost` | process | root | data | `variables` async | | `eventHub` | process | eventhub | data | `declare` async, `publish` async | diff --git a/docs/architecture/rust-agent/generated/modules.json b/docs/architecture/rust-agent/generated/modules.json index bc5203a96f..ce35659825 100644 --- a/docs/architecture/rust-agent/generated/modules.json +++ b/docs/architecture/rust-agent/generated/modules.json @@ -2737,6 +2737,8 @@ "parent": "dim_app_server", "file": "crates/dim-app-server/src/collaboration_model_policy.rs", "unexpandedMacros": [ + "format", + "serde_json::json", "unreachable", "vec" ] @@ -24367,6 +24369,7 @@ "to": "dim_app_server::collaboration_model_policy", "references": [ "mod collaboration_model_policy", + "path collaboration_model_policy::CollaborationModelPolicy", "path collaboration_model_policy::CollaborationModelPolicyPlugin::new" ] }, @@ -26405,14 +26408,6 @@ "use dim_agent_capabilities::prompt_state::PromptSnapshot" ] }, - { - "from": "dim_app_server::collaboration", - "to": "dim_agent_capabilities::settings", - "references": [ - "path SettingsScope::User", - "use crate::settings::SettingsScope" - ] - }, { "from": "dim_app_server::collaboration", "to": "dim_agent_capabilities::timeline_tree", @@ -26754,10 +26749,11 @@ "from": "dim_app_server::collaboration", "to": "dim_app_server::collaboration_model_policy", "references": [ - "path ModelPolicy", + "path CollaborationModelPolicy", "path ModelPolicy::Agent", "path ModelPolicy::Fixed", "path ModelPolicy::Inherit", + "use crate::collaboration_model_policy::CollaborationModelPolicy", "use crate::collaboration_model_policy::ModelPolicy" ] }, @@ -26780,8 +26776,16 @@ "from": "dim_app_server::collaboration", "to": "dim_app_server::settings", "references": [ - "path SettingsService", - "use crate::settings::SettingsService" + "path SettingsError::UnknownSource", + "use crate::settings::SettingsError" + ] + }, + { + "from": "dim_app_server::collaboration", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use crate::settings::Settings" ] }, { @@ -27133,6 +27137,7 @@ "to": "dim_app_server::settings", "references": [ "path BusinessDocument", + "path RegisteredDocument", "path SettingsError", "path SettingsError::Cancelled", "path SettingsError::Closed", @@ -27140,6 +27145,7 @@ "path SettingsError::Invalid", "path crate::settings::Result", "use crate::settings::BusinessDocument", + "use crate::settings::RegisteredDocument", "use crate::settings::SettingsError" ] }, @@ -29055,14 +29061,22 @@ "from": "dim_app_server::mcp", "to": "dim_app_server::settings", "references": [ + "path RegisteredDocument", "path SettingsError", "path SettingsError::Conflict", "path SettingsError::Document", "path SettingsError::Invalid", - "path SettingsService", "use crate::settings::BusinessDocument", - "use crate::settings::SettingsError", - "use crate::settings::SettingsService" + "use crate::settings::RegisteredDocument", + "use crate::settings::SettingsError" + ] + }, + { + "from": "dim_app_server::mcp", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use crate::settings::Settings" ] }, { @@ -29244,13 +29258,19 @@ "path SettingsError", "path SettingsError::Invalid", "path SettingsError::shape", - "path SettingsService", "path crate::settings::ProjectAuthorized", "path crate::settings::project_authorizations", "use crate::settings::BusinessDocument", "use crate::settings::Result", - "use crate::settings::SettingsError", - "use crate::settings::SettingsService" + "use crate::settings::SettingsError" + ] + }, + { + "from": "dim_app_server::mcp::config", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use crate::settings::Settings" ] }, { @@ -29584,10 +29604,16 @@ "path SettingsError::DocumentShape", "path SettingsError::Invalid", "path SettingsError::Worker", - "path SettingsService", "use crate::settings::BusinessDocument", - "use crate::settings::SettingsError", - "use crate::settings::SettingsService" + "use crate::settings::SettingsError" + ] + }, + { + "from": "dim_app_server::mcp::management", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use crate::settings::Settings" ] }, { @@ -29681,6 +29707,7 @@ "to": "dim_app_server::mcp", "references": [ "path McpConnection", + "path McpDocuments", "path McpError::Closed", "path McpError::Disabled", "path McpError::Unavailable", @@ -29694,6 +29721,7 @@ "path source_revision", "path sources_in_precedence", "use super::McpConnection", + "use super::McpDocuments", "use super::McpError", "use super::McpSource", "use super::Result", @@ -29714,15 +29742,12 @@ "from": "dim_app_server::mcp::publication", "to": "dim_app_server::mcp::config", "references": [ - "path McpPluginServers", "path McpProjectEnablement", "path McpProjectEnablement::default", - "path McpSecrets", "path McpSecrets::default", "path McpServerSettings", "path McpServerSettings::Remote", "path McpServerSettings::Stdio", - "path McpSettings", "path config", "path config::Connection", "path config::Origin::Plugin", @@ -29732,11 +29757,9 @@ "path config::settings_changes", "path config::workspace", "use super::config", - "use super::config::McpPluginServers", "use super::config::McpProjectEnablement", "use super::config::McpSecrets", - "use super::config::McpServerSettings", - "use super::config::McpSettings" + "use super::config::McpServerSettings" ] }, { @@ -29766,9 +29789,17 @@ "from": "dim_app_server::mcp::publication", "to": "dim_app_server::settings", "references": [ - "path SettingsService", + "path ProjectAuthorized", "path crate::settings::SettingsError::Invalid", - "use crate::settings::SettingsService" + "use crate::settings::ProjectAuthorized" + ] + }, + { + "from": "dim_app_server::mcp::publication", + "to": "dim_app_server::settings::declared", + "references": [ + "path Settings", + "use crate::settings::Settings" ] }, { @@ -56805,6 +56836,14 @@ "module": "dim_app_server::collaboration_model_policy", "path": "D::Error" }, + { + "module": "dim_app_server::collaboration_model_policy", + "path": "Error::Value" + }, + { + "module": "dim_app_server::collaboration_model_policy", + "path": "Value::future" + }, { "module": "dim_app_server::connection", "path": "ClientChannel::Tui" diff --git a/docs/architecture/rust-agent/generated/modules.mmd b/docs/architecture/rust-agent/generated/modules.mmd index 557962c196..026a21a731 100644 --- a/docs/architecture/rust-agent/generated/modules.mmd +++ b/docs/architecture/rust-agent/generated/modules.mmd @@ -2523,7 +2523,6 @@ flowchart LR m246 --> m91 m246 --> m96 m246 --> m100 - m246 --> m109 m246 --> m126 m246 --> m136 m246 --> m160 @@ -2556,6 +2555,7 @@ flowchart LR m246 --> m306 m246 --> m307 m246 --> m333 + m246 --> m334 m247 --> m36 m247 --> m72 m247 --> m81 @@ -2765,6 +2765,7 @@ flowchart LR m266 --> m286 m266 --> m287 m266 --> m333 + m266 --> m334 m267 --> m58 m267 --> m268 m267 --> m269 @@ -2779,6 +2780,7 @@ flowchart LR m271 --> m109 m271 -.-> m272 m271 --> m333 + m271 --> m334 m272 --> m271 m273 -.-> m274 m273 --> m276 @@ -2803,6 +2805,7 @@ flowchart LR m278 --> m287 m278 --> m306 m278 --> m333 + m278 --> m334 m279 --> m271 m279 --> m278 m280 --> m72 @@ -2819,6 +2822,7 @@ flowchart LR m280 -.-> m281 m280 --> m282 m280 --> m333 + m280 --> m334 m281 --> m58 m281 --> m72 m281 --> m109 diff --git a/docs/design/appserver/mcp-management.md b/docs/design/appserver/mcp-management.md index 65cbd57e42..079289ebf4 100644 --- a/docs/design/appserver/mcp-management.md +++ b/docs/design/appserver/mcp-management.md @@ -1358,7 +1358,7 @@ business configuration, not an event. | `McpAuth` ([MCP OAuth](mcp-oauth.md)) | The `mcp.auth.*` methods of the same namespace; the credential record is untouched by a move | | `credentialVariablesHost` (capabilities host, D19) | The names of the environment variables the daemon reads credentials from; `McpPublication` and `McpPlugin` declare it, and the assembly root in `serve` provides it | -The MCP publication coordinator is private typed wiring within the MCP owner. Its command queue, connection generations and application watch have no public catalog name; the existing management methods and `mcpSession` expose the owner operations. The explicit private dependency still orders assembly and shutdown. +The MCP publication coordinator is private typed wiring within the MCP owner. Its command queue, connection generations and application watch have no public catalog name; the existing management methods and `mcpSession` expose the owner operations. The explicit private dependency still orders assembly and shutdown. MCP registers its documents with Settings and uses the same source-bound reads for management and publication. The secrets document stays inside MCP. ### 8.1 Plugin content data face diff --git a/docs/design/subagent-model-policy.md b/docs/design/subagent-model-policy.md index b933a994f5..e02864b513 100644 --- a/docs/design/subagent-model-policy.md +++ b/docs/design/subagent-model-policy.md @@ -136,6 +136,8 @@ contract §3.2. | `collaboration.model_policy` | `{}` | `{revision: string, policy: Policy}` | false | `Report` | | `collaboration.set_model_policy` | `{expectedRevision: string, policy: Policy}` | `{revision: string}` | true | `Report` | +The process data face `collaborationModelPolicy.read({})` and the local management read return the same `{revision, policy}`. Collaboration reads the owner when selecting a new member’s model. + `Policy` is exactly the tagged source type above. Use the existing local v3 management authorization; a paired device has no access. Invalid request shape or policy is invalid params (`-32602`, `invalid_params`); source CAS conflict is diff --git a/npm/plugin.d.ts b/npm/plugin.d.ts index ab54faae4d..ea11f6a682 100644 --- a/npm/plugin.d.ts +++ b/npm/plugin.d.ts @@ -79,6 +79,13 @@ export interface Settings { projects(request: Record): SettingsResult<{ projects: { root: number; cwd: string }[] }>; } +export interface CollaborationModelPolicy { + read(request: Record): Promise<{ + revision: string; + policy: { mode: "agent" } | { mode: "inherit" } | { mode: "fixed"; model: ModelId }; + }>; +} + export type TitleSource = 'auto' | 'manual'; export interface Title { text: string; source: TitleSource } /** `revision` counts committed title writes; 0 means never written. */ From e7576cb8c83398def315d1af88eb96bab4c9ccb3 Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 15:17:21 +0800 Subject: [PATCH 06/10] Use the permission owner document and retire the public SettingsService key --- crates/dim-app-server/src/lib.rs | 2 - crates/dim-app-server/src/permission_rules.rs | 18 +++---- crates/dim-app-server/src/settings_methods.rs | 2 +- crates/dim-app-server/tests/mcp_flow.rs | 2 +- crates/dim-app-server/tests/settings_flow.rs | 52 ++++++++++++------- .../tests/transport_flow/settings_methods.rs | 6 +-- .../generated/app-server/services.json | 6 +++ .../rust-agent/generated/catalog.md | 1 - .../rust-agent/generated/modules.json | 11 ++-- 9 files changed, 58 insertions(+), 42 deletions(-) diff --git a/crates/dim-app-server/src/lib.rs b/crates/dim-app-server/src/lib.rs index 1d505927dc..2514391dae 100644 --- a/crates/dim-app-server/src/lib.rs +++ b/crates/dim-app-server/src/lib.rs @@ -1445,7 +1445,6 @@ pub(crate) fn register_names(catalog: &mut dim_agent_runtime::names::ServiceCata register::(catalog, None); register::(catalog, None); register::(catalog, Some(SESSION_GROUP)); - register::(catalog, None); register::(catalog, None); register::(catalog, None); register::(catalog, None); @@ -1519,7 +1518,6 @@ pub fn register_faces(builder: &mut dim_agent_runtime::AgentBuilder) { ("serverControl", "control"), ("sessionLoader", "control"), ("sessionStore", "owner-api"), - ("settingsService", "owner-api"), ("submitChecks", "hot-path"), ("timelineFactory", "control"), ("timelineTree", "owner-api"), diff --git a/crates/dim-app-server/src/permission_rules.rs b/crates/dim-app-server/src/permission_rules.rs index 8ae02260ca..33420eb87f 100644 --- a/crates/dim-app-server/src/permission_rules.rs +++ b/crates/dim-app-server/src/permission_rules.rs @@ -3,7 +3,7 @@ use crate::{ methods::ManagementMethods, protocol::Empty, - settings::{BusinessDocument, Settings, SettingsError, SettingsScope, SettingsService}, + settings::{BusinessDocument, RegisteredDocument, Settings, SettingsError, SettingsScope}, }; use dim_agent_capabilities::{ host::{HostError, HostFuture}, @@ -55,15 +55,15 @@ pub fn install(builder: &mut AgentBuilder) { } /// Reads the user source on each call; nothing is cached. -struct SettingsRules(Arc); +struct SettingsRules(Ctx); impl ReadCommandRules for SettingsRules { fn rules(&self, cancel: CancellationToken) -> HostFuture<'_, Vec> { Box::pin(async move { - match self + let document = self .0 - .read::(SettingsScope::User, &cancel) - .await - { + .get::>() + .ok_or_else(|| HostError::failed(SettingsError::UnknownSource.to_string()))?; + match document.read(SettingsScope::User, &cancel).await { Ok(snapshot) => Ok(snapshot.document.command_rules), Err(SettingsError::Cancelled) => { Err(HostError::Cancelled("command rules read cancelled".into())) @@ -77,7 +77,7 @@ impl ReadCommandRules for SettingsRules { struct CommandRulesPlugin { host: Key, face: Key, - settings: Key, + settings: Key, } impl CommandRulesPlugin { fn new(names: &Names<'_>) -> Result { @@ -97,8 +97,7 @@ impl DynPlugin for CommandRulesPlugin { } fn apply<'a>(&'a self, ctx: &'a Ctx) -> BoxFuture<'a, rutis::Result> { Box::pin(async move { - let settings = ctx.require_at(&self.settings)?; - let rules = Arc::new(CommandRules(Arc::new(SettingsRules(settings)))); + let rules = Arc::new(CommandRules(Arc::new(SettingsRules(ctx.clone())))); ctx.provide_at(self.host.clone(), rules.clone())?; ctx.provide_at( self.face.clone(), @@ -161,6 +160,7 @@ impl DynPlugin for PermissionRulesPlugin { let settings = ctx.require_at(&self.settings)?; let methods = ctx.require_at(&self.methods)?; let settings = settings.register_document::(ctx)?; + ctx.provide_as::>(settings.clone())?; methods.register( ctx, "permission", diff --git a/crates/dim-app-server/src/settings_methods.rs b/crates/dim-app-server/src/settings_methods.rs index 8cd1fdd3b2..db589319c2 100644 --- a/crates/dim-app-server/src/settings_methods.rs +++ b/crates/dim-app-server/src/settings_methods.rs @@ -121,7 +121,7 @@ pub struct SettingsMethodsPlugin { impl SettingsMethodsPlugin { pub fn new(names: &Names<'_>) -> rutis::Result { Ok(Self { - service: names.key()?, + service: Key::of(), methods: names.key()?, }) } diff --git a/crates/dim-app-server/tests/mcp_flow.rs b/crates/dim-app-server/tests/mcp_flow.rs index 1d6bb87d31..33e26723ba 100644 --- a/crates/dim-app-server/tests/mcp_flow.rs +++ b/crates/dim-app-server/tests/mcp_flow.rs @@ -41,7 +41,7 @@ impl Capture { Ok(Self { services, mcp: dim_app_server::mcp::owner_key(), - settings: names.key()?, + settings: Key::of(), files: names.key()?, }) } diff --git a/crates/dim-app-server/tests/settings_flow.rs b/crates/dim-app-server/tests/settings_flow.rs index 897d1402e7..a5576bdc3d 100644 --- a/crates/dim-app-server/tests/settings_flow.rs +++ b/crates/dim-app-server/tests/settings_flow.rs @@ -48,11 +48,9 @@ fn owner( name: &'static str, register: impl Fn(&SettingsService, &Ctx) -> rutis::Result<()> + Send + Sync + 'static, ) -> Owner { - let catalog = dim_app_server::catalog(); - let build = Build::default(); Owner { name, - settings: Names::copy(&catalog, &build).key().unwrap(), + settings: Key::of(), register: Arc::new(register), } } @@ -82,14 +80,6 @@ struct ProcessSettings { capture: Captured, settings: Key, } -impl ProcessSettings { - fn new(names: &Names<'_>, capture: Captured) -> rutis::Result { - Ok(Self { - capture, - settings: names.key()?, - }) - } -} impl DynPlugin for ProcessSettings { fn name(&self) -> &str { "test.process-settings" @@ -181,11 +171,15 @@ async fn server_reload_preserves_project_root_identity_and_settings() { let mut builder = AgentBuilder::new(AgentConfig::default()); defaults::mock_hosts(&mut builder); defaults::install(&mut builder); - builder.require_feature( - Feature::new("test.process-settings").session("test.process-settings", move |names| { - Ok(Box::new(ProcessSettings::new(names, capture.clone())?)) - }), - ); + builder.require_feature(Feature::new("test.process-settings").session( + "test.process-settings", + move |_| { + Ok(Box::new(ProcessSettings { + capture: capture.clone(), + settings: Key::of(), + })) + }, + )); let server = serve( builder, ServerConfig { @@ -800,8 +794,12 @@ async fn sources_appear_while_registered_and_names_are_exclusive() { owner_call(&dispatch, "read", read.clone()).await["error"]["code"], "unknown_source" ); - let source = root.plugin(owner("test.owner", |settings, ctx| { - settings.register::(ctx)?; + let first = Arc::new(std::sync::OnceLock::new()); + let registered = first.clone(); + let public = root.get::().unwrap(); + let source = root.plugin(owner("test.owner", move |settings, ctx| { + let doc = public.register_document::(ctx)?; + assert!(registered.set(doc).is_ok()); settings.register_declared(ctx, declaration("declared")) })); wait_active( @@ -885,7 +883,23 @@ async fn sources_appear_while_registered_and_names_are_exclusive() { "unknown_source" ); assert!(home.join("example.json").exists()); - settings.register::(&root).unwrap(); + let next = root + .get::() + .unwrap() + .register_document::(&root) + .unwrap(); + assert!(matches!( + first + .get() + .unwrap() + .read(SettingsScope::User, &cancel) + .await, + Err(SettingsError::UnknownSource) + )); + assert_eq!( + next.read(SettingsScope::User, &cancel).await.unwrap(), + saved + ); assert_eq!( settings .read::(SettingsScope::User, &cancel) diff --git a/crates/dim-app-server/tests/transport_flow/settings_methods.rs b/crates/dim-app-server/tests/transport_flow/settings_methods.rs index cc6edcb886..cf4c2b48b8 100644 --- a/crates/dim-app-server/tests/transport_flow/settings_methods.rs +++ b/crates/dim-app-server/tests/transport_flow/settings_methods.rs @@ -6,7 +6,7 @@ use super::*; use dim_agent_runtime::Names; use dim_app_server::{ session_typescript::SessionTypeScriptConfig, - settings::{SettingsChanged, SettingsService, SourceDeclaration, settings_changes}, + settings::{Settings, SettingsChanged, SourceDeclaration, settings_changes}, }; use rutis::Ctx; use rutis::host::{BoxFuture, DynPlugin, Effect, Key, TypeKey}; @@ -100,7 +100,7 @@ fn configured_models() -> Arc { /// Registers a declared source with project scope, the way a C4 owner row does /// (§3.1): `settings.read`/`settings.update` need one to take `{project: root}`. -struct ProjectSource(Key); +struct ProjectSource(Key); impl ProjectSource { fn new(names: &Names<'_>) -> rutis::Result { Ok(Self(names.key()?)) @@ -115,7 +115,7 @@ impl DynPlugin for ProjectSource { } fn apply<'a>(&'a self, ctx: &'a Ctx) -> BoxFuture<'a, rutis::Result> { Box::pin(async move { - ctx.require_at(&self.0)?.register_declared( + ctx.require_at(&self.0)?.register( ctx, SourceDeclaration { source: "example".into(), diff --git a/docs/architecture/rust-agent/generated/app-server/services.json b/docs/architecture/rust-agent/generated/app-server/services.json index 86a1b08222..bc7affbe27 100644 --- a/docs/architecture/rust-agent/generated/app-server/services.json +++ b/docs/architecture/rust-agent/generated/app-server/services.json @@ -3595,6 +3595,12 @@ "generation": 1, "removing": false }, + { + "service": "dim_app_server::settings::RegisteredDocument", + "provider": 33, + "generation": 1, + "removing": false + }, { "service": "dim_app_server::settings::SettingsService", "provider": 18, diff --git a/docs/architecture/rust-agent/generated/catalog.md b/docs/architecture/rust-agent/generated/catalog.md index cef5a6fee4..4628427823 100644 --- a/docs/architecture/rust-agent/generated/catalog.md +++ b/docs/architecture/rust-agent/generated/catalog.md @@ -58,7 +58,6 @@ Each catalog name a part of the assembly provides or injects. `data` means share | `sessionStore` | process | SessionStore | internal(owner-api) | — | | `sessions` | process | AgentDirectory | data | `delete` async, `exists` async, `history` async, `idle` async, `input` async, `launch` async, `lookup` async, `pending` async, `stop` async, `withdraw` async | | `settings` | process | Settings | data | `authorizeProject` async, `declaredBy` sync, `projects` sync, `read` async, `register` async, `registerDocument` async, `update` async | -| `settingsService` | process | Settings | internal(owner-api) | — | | `skillsCatalog` | process | SkillsCatalog | data | `issues` async, `plugins` async, `register` async, `withdraw` async | | `skillsInstructionsSettingsHost` | process | PromptSettings | data | `instructions` async | | `sqliteStorage` | process | SqliteStorage | data | `abandonFile` async, `agentOwner` async, `agents` async, `batchEnd` async, `batchEndAt` async, `branches` async, `commitFile` async, `commitTimelineRound` async, `createSession` async, `delete` async, `head` async, `importUserIfAbsent` async, `ledMembers` async, `memberSessions` async, `members` async, `ownedAgents` async, `ownedPaths` async, `owners` async, `ownsFile` async, `ownsOutput` async, `readPreferences` async, `readSelection` async, `readUser` async, `registerOutput` async, `replaceUser` async, `reserveFile` async, `save` async, `sessionConfig` async, `storageReport` async, `unfinishedOwned` async, `writeSelection` async | diff --git a/docs/architecture/rust-agent/generated/modules.json b/docs/architecture/rust-agent/generated/modules.json index 5691a09065..1a302db4f1 100644 --- a/docs/architecture/rust-agent/generated/modules.json +++ b/docs/architecture/rust-agent/generated/modules.json @@ -24643,8 +24643,7 @@ "mod settings", "path settings", "path settings::SettingsPlugin::native", - "path settings::SettingsPlugin::new", - "path settings::SettingsService" + "path settings::SettingsPlugin::new" ] }, { @@ -29755,7 +29754,6 @@ "path config::Origin::Workspace", "path config::connected", "path config::settings_changes", - "path config::workspace", "use super::config", "use super::config::McpProjectEnablement", "use super::config::McpSecrets", @@ -30781,16 +30779,17 @@ "to": "dim_app_server::settings", "references": [ "path BusinessDocument", + "path RegisteredDocument", "path SettingsError", "path SettingsError::Cancelled", "path SettingsError::Closed", "path SettingsError::Conflict", "path SettingsError::Invalid", - "path SettingsService", + "path SettingsError::UnknownSource", "path crate::settings::Result", "use crate::settings::BusinessDocument", - "use crate::settings::SettingsError", - "use crate::settings::SettingsService" + "use crate::settings::RegisteredDocument", + "use crate::settings::SettingsError" ] }, { From 93abff0855d09aa01b4fc0414507228a51a36ee1 Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 17:07:23 +0800 Subject: [PATCH 07/10] Recheck Settings source ownership on write admission and keep foreign codecs outside file leases --- crates/dim-app-server/src/settings.rs | 71 +++++++++++++------ .../dim-app-server/src/settings/declared.rs | 4 +- crates/dim-app-server/src/settings/native.rs | 10 ++- crates/dim-app-server/tests/settings_flow.rs | 44 ++++++++++++ .../tests/transport_flow/settings_methods.rs | 24 +++++++ .../appserver/permission-command-rules.md | 2 +- docs/design/appserver/settings-service.md | 10 +-- .../contracts/resource-owner-operations.md | 4 +- docs/design/plugins/Hooks.md | 2 +- docs/design/plugins/Scheduler.md | 2 +- docs/design/subagent-model-policy.md | 11 ++- .../appserver/permission-command-rules.md | 2 +- docs/zh/design/appserver/settings-service.md | 7 +- docs/zh/design/plugins/Hooks.md | 2 +- docs/zh/design/plugins/Scheduler.md | 2 +- runtime/fixtures/settings-owner.ts | 30 +++++++- 16 files changed, 176 insertions(+), 51 deletions(-) diff --git a/crates/dim-app-server/src/settings.rs b/crates/dim-app-server/src/settings.rs index e2986d94c4..4197ed6fa6 100644 --- a/crates/dim-app-server/src/settings.rs +++ b/crates/dim-app-server/src/settings.rs @@ -208,6 +208,25 @@ enum Kind { Declared(Arc), } +type CompareDocument = Box Result<()> + Send>; + +enum WriteCheck { + Registered(Weak>), + Compare(CompareDocument), +} + +fn current_registration( + settings: &SettingsService, + name: &str, + registration: &Weak>, +) -> Result>> { + settings + .sources + .get(name) + .filter(|entry| registration.ptr_eq(&Arc::downgrade(entry))) + .ok_or(SettingsError::UnknownSource) +} + /// A custom source registered by one plugin generation. pub struct RegisteredDocument { settings: Arc, @@ -217,14 +236,7 @@ pub struct RegisteredDocument { impl RegisteredDocument { fn path(&self, scope: SettingsScope) -> Result { - let entry = self - .settings - .sources - .get(self.format.source()) - .ok_or(SettingsError::UnknownSource)?; - if !self.registration.ptr_eq(&Arc::downgrade(&entry)) { - return Err(SettingsError::UnknownSource); - } + let entry = current_registration(&self.settings, self.format.source(), &self.registration)?; self.settings.locate( &entry.value.user_file, entry.value.project_file.as_deref(), @@ -257,7 +269,7 @@ impl RegisteredDocument { scope, expected, document, - |_, _| Ok(()), + WriteCheck::Registered(self.registration.clone()), cancel, ) .await @@ -495,7 +507,7 @@ impl SettingsService { scope, expected, document, - |_, _| Ok(()), + WriteCheck::Compare(Box::new(|_, _| Ok(()))), cancel, ) .await @@ -528,7 +540,7 @@ impl SettingsService { scope: SettingsScope, expected: &str, document: F::Document, - check: impl FnOnce(&F::Document, &F::Document) -> Result<()> + Send + 'static, + check: WriteCheck, cancel: &CancellationToken, ) -> Result> { let task = { @@ -544,11 +556,25 @@ impl SettingsService { .await; } let mut lease = owner.lease(&path, &cancel).await?; - let current = snapshot(&*format, lease.read(&cancel).await, &cancel).await?; - if current.revision != expected { - return Err(SettingsError::Conflict); + let stored = stored_bytes(lease.read(&cancel).await)?; + match check { + WriteCheck::Registered(registration) => { + let source = current_registration(&owner, format.source(), ®istration)?; + if matches!(source.value.kind, Kind::Rust(_)) { + format.decode(stored.as_deref(), &cancel).await?; + } + if revision(stored.as_deref()) != expected { + return Err(SettingsError::Conflict); + } + } + WriteCheck::Compare(compare) => { + let current = format.decode(stored.as_deref(), &cancel).await?; + if revision(stored.as_deref()) != expected { + return Err(SettingsError::Conflict); + } + compare(¤t, &document)?; + } } - check(¤t.document, &document)?; let mut bytes = serde_json::to_vec_pretty(&document) .map_err(|_| SettingsError::Invalid("cannot encode settings"))?; bytes.push(b'\n'); @@ -629,16 +655,21 @@ fn revision(bytes: Option<&[u8]>) -> String { |bytes| format!("{:x}", Sha256::digest(bytes)), ) } +fn stored_bytes(read: std::result::Result, FileStorageError>) -> Result>> { + match read { + Ok(bytes) => Ok(Some(bytes)), + Err(FileStorageError::Io(error)) if error.kind() == std::io::ErrorKind::NotFound => { + Ok(None) + } + Err(error) => Err(error.into()), + } +} async fn snapshot( format: &F, read: std::result::Result, FileStorageError>, cancel: &CancellationToken, ) -> Result> { - let bytes = match read { - Ok(bytes) => Some(bytes), - Err(FileStorageError::Io(error)) if error.kind() == std::io::ErrorKind::NotFound => None, - Err(error) => return Err(error.into()), - }; + let bytes = stored_bytes(read)?; Ok(SettingsSnapshot { document: format.decode(bytes.as_deref(), cancel).await?, revision: revision(bytes.as_deref()), diff --git a/crates/dim-app-server/src/settings/declared.rs b/crates/dim-app-server/src/settings/declared.rs index c23230af16..7f625d3eed 100644 --- a/crates/dim-app-server/src/settings/declared.rs +++ b/crates/dim-app-server/src/settings/declared.rs @@ -256,10 +256,10 @@ impl SettingsService { scope, expected, document, - move |current, next| match writer { + WriteCheck::Compare(Box::new(move |current, next| match writer { Writer::Client => Ok(()), Writer::Owner => rules.user_only(current, next), - }, + })), cancel, ) .await diff --git a/crates/dim-app-server/src/settings/native.rs b/crates/dim-app-server/src/settings/native.rs index 6b24a711d2..2a0250dea2 100644 --- a/crates/dim-app-server/src/settings/native.rs +++ b/crates/dim-app-server/src/settings/native.rs @@ -85,7 +85,7 @@ impl SettingsService { path: FilePath, expected: String, document: F::Document, - check: impl FnOnce(&F::Document, &F::Document) -> Result<()> + Send + 'static, + check: WriteCheck, cancel: &CancellationToken, ) -> Result> { let (version, current) = self.native_read(format.clone(), path, cancel).await?; @@ -94,7 +94,13 @@ impl SettingsService { if current.revision != expected { return Err(SettingsError::Conflict); } - let decision = match check(¤t.document, &document) { + let checked = match check { + WriteCheck::Registered(registration) => { + current_registration(self, format.source(), ®istration).map(|_| ()) + } + WriteCheck::Compare(compare) => compare(¤t.document, &document), + }; + let decision = match checked { Ok(()) => UserDecision::Write { document: serde_json::to_string(&document) .map_err(|_| SettingsError::Invalid("cannot encode settings"))?, diff --git a/crates/dim-app-server/tests/settings_flow.rs b/crates/dim-app-server/tests/settings_flow.rs index a5576bdc3d..1d826582d8 100644 --- a/crates/dim-app-server/tests/settings_flow.rs +++ b/crates/dim-app-server/tests/settings_flow.rs @@ -871,6 +871,26 @@ async fn sources_appear_while_registered_and_names_are_exclusive() { .await .is_err() ); + let files = root.get::().unwrap(); + let mut notices = listen::(&root, &settings_changes("example")); + let held = files + .lock(&files.path(0, "example.json").unwrap(), &cancel) + .await + .unwrap(); + let pending = first.get().unwrap().update( + SettingsScope::User, + &saved.revision, + Document { + value: "obsolete".into(), + }, + &cancel, + ); + tokio::pin!(pending); + assert!( + tokio::time::timeout(Duration::from_millis(75), &mut pending) + .await + .is_err() + ); source.dispose().await.unwrap(); assert!(matches!( settings @@ -888,6 +908,8 @@ async fn sources_appear_while_registered_and_names_are_exclusive() { .unwrap() .register_document::(&root) .unwrap(); + drop(held); + assert!(matches!(pending.await, Err(SettingsError::UnknownSource))); assert!(matches!( first .get() @@ -907,6 +929,28 @@ async fn sources_appear_while_registered_and_names_are_exclusive() { .unwrap(), saved ); + let committed = next + .update( + SettingsScope::User, + &saved.revision, + Document { + value: "current".into(), + }, + &cancel, + ) + .await + .unwrap(); + saw( + &mut notices, + change(SettingsScope::User, &committed.revision), + ) + .await; + assert!( + notices + .borrow() + .iter() + .all(|event| event.revision == saved.revision || event.revision == committed.revision) + ); root.shutdown().await.unwrap(); fs::remove_dir_all(home).unwrap(); } diff --git a/crates/dim-app-server/tests/transport_flow/settings_methods.rs b/crates/dim-app-server/tests/transport_flow/settings_methods.rs index cf4c2b48b8..4f11d8a297 100644 --- a/crates/dim-app-server/tests/transport_flow/settings_methods.rs +++ b/crates/dim-app-server/tests/transport_flow/settings_methods.rs @@ -364,6 +364,30 @@ async fn node_settings_typescript_owner_reads_and_writes() { let mut other = create(json!([])); other["cwd"] = json!(project); assert_ok(&client.rpc("session.create", other).await); + let roots = client.rpc("settings.projects", json!({})).await; + let root = roots["result"]["projects"] + .as_array() + .unwrap() + .iter() + .find(|entry| entry["cwd"] == json!(project.canonicalize().unwrap())) + .unwrap()["root"] + .clone(); + let parallel = tokio::time::timeout( + Duration::from_secs(10), + owner( + &mut client, + &session, + "custom_concurrent", + json!({"root": root}), + ), + ) + .await + .expect("a suspended decoder must not block writers"); + assert_eq!(parallel["stale"]["error"]["code"], "conflict", "{parallel}"); + assert_eq!( + parallel["written"]["value"]["document"]["count"], 8, + "{parallel}" + ); let events = tokio::time::timeout(Duration::from_secs(5), async { loop { let events = owner(&mut client, &session, "events", json!({})).await; diff --git a/docs/design/appserver/permission-command-rules.md b/docs/design/appserver/permission-command-rules.md index b7fabf37eb..db41e0158b 100644 --- a/docs/design/appserver/permission-command-rules.md +++ b/docs/design/appserver/permission-command-rules.md @@ -181,7 +181,7 @@ Bindings per profile (exactly one each): | --- | --- | | `defaults::install`, `install_with_prompt`, `install_with_process_model` (mock App Server profile and test hosts) | `install_profile` binds the fixed empty host `NoCommandRules` with `session_data_value`, next to the `EmptyPromptHost` it already binds. Existing tests are unchanged | | `install_with_prompt_capability`, `install_local_execution`, `install_minimal_execution` | Bind nothing, like `PromptHost`: the host that installs them binds the port. Capability-only hosts (integration tests, the `xtask` local graph) bind `CommandRules(Arc::new(NoCommandRules))` | -| App Server product profile (`install_local_execution` in `main.rs`, its tests and the `xtask` App Server graph) | The profile calls `permission_rules::install(&mut builder)`, which adds the feature `CommandRules` and requires its Session part `CommandRules` (`require_feature`, Deps `Keyed`); it provides `CommandRules` reading `SettingsService::read::(User)` on each call. `serve` registers the process part `PermissionRulesPlugin` (`register_part`, Deps `Keyed` and `Keyed`, owner row `permission`) with local execution, next to `mcp` and `skills`; it provides the management methods. Both live in `dim-app-server/src/permission_rules.rs` with the `PermissionSettings` document type (`NAMESPACE = "permission"`, `USER_FILE = "permission.json"`, no `PROJECT_FILE`) | +| App Server product profile (`install_local_execution` in `main.rs`, its tests and the `xtask` App Server graph) | The profile calls `permission_rules::install(&mut builder)`, which adds the feature `CommandRules` and requires its Session part `CommandRules` (`require_feature`, Deps `Keyed`); it provides `CommandRules` reading `RegisteredDocument::read(User)` on each call. `serve` registers the process part `PermissionRulesPlugin` (`register_part`, Deps `Keyed` and `Keyed`, owner row `permission`) with local execution, next to `mcp` and `skills`; it provides the management methods. Both live in `dim-app-server/src/permission_rules.rs` with the `PermissionSettings` document type (`NAMESPACE = "permission"`, `USER_FILE = "permission.json"`, no `PROJECT_FILE`) | ## 5. Flows diff --git a/docs/design/appserver/settings-service.md b/docs/design/appserver/settings-service.md index ff00bcd384..b2dc904356 100644 --- a/docs/design/appserver/settings-service.md +++ b/docs/design/appserver/settings-service.md @@ -17,8 +17,7 @@ each source with Settings when it starts ([ADR 007](../../adr/007-plugin-configu the source name, its files, a JSON Schema (with `default` values) and its user-only fields (§3.1). Settings then offers three things over JSON documents: -- the process service `settings`, which the owner uses: `register`, `read`, `update` (CAS on - the revision) and `projects`; +- the process service `settings` for source registration, reads, writes and project admission (§4.2); - the client management methods `settings.read`, `settings.update`, `settings.sources` and `settings.projects`; - the same rutis events as S8a, `settings.changed` and `settings.project_authorized`. Their @@ -315,15 +314,16 @@ Permission does). ### 4.5 Rust binding The `Settings` binding exposes the owner operations of the public `settings` data face. -It provides `register(ctx, declaration)`, `read(source, scope, cancel)`, -`update(source, scope, expected, document, cancel)` and `projects()`. +Declared sources use `register`, `declared_by`, `read` and `update`. Custom sources use +`register_document` and its bound read/update operations. Project admission and listing use +`authorize_project` and `projects`. The dispatcher calls these same operations, and native consumers call them directly without JSON conversion. Registration retains the caller's lifetime; updates are owner writes and preserve user-only fields. The existing Settings owner still supplies the source registry, validation and persistence. `SettingsService` retains the native `BusinessDocument` and client management paths below. -PluginManager's declared-source tools also use it for reads and owner writes. +PluginManager reads and updates its declared sources through the public `Settings` binding. This binding does not make native sources visible through declared-source operations or change the local-client boundary in §4.3 and §7. diff --git a/docs/design/contracts/resource-owner-operations.md b/docs/design/contracts/resource-owner-operations.md index 8ea829ca0f..aac700a567 100644 --- a/docs/design/contracts/resource-owner-operations.md +++ b/docs/design/contracts/resource-owner-operations.md @@ -11,7 +11,7 @@ directly. The rutis binding dispatches its data arguments and returns its result | `fileStorage`, `mentionIndex` | File tools and workspace completion use [fsHost §4](../resource-faces.md#4-fshost), including mentions. Storage clients use the owner's file and lease operations. An opened reader uses openRead/readAt/closeRead. | | `sessionStore` | Session repository, metadata, attachments, Timeline and worktree associations use store, store.readMetadata/setTitle, sessionFiles, timelineStore and store.associateWorktree respectively. Session construction binds the existing Session-scoped timelineStore. Path import and fileId reads use the [Session files contract](../appserver/session-files.md). | | `pluginFileTransactions` | Scheduler and EventHub use pluginFiles.open(), scope.withLock and lease.read/replace for the same atomic text update. Scope.list/remove and lease.readBytes/replaceBytes have their existing contracts. | -| `settingsService` | Declared sources use settings.register/read/update/projects. PluginManager uses the owner-write form for CAS edits and applies its existing writeOnly redaction. SettingsMethods retains the local client-write path. [Settings contract](../appserver/settings-service.md#42-service-settings-owner-path). | +| `settings` | Declared sources use settings.register/read/update/projects. PluginManager uses the owner-write form for CAS edits and applies its existing writeOnly redaction. SettingsMethods retains the local client-write path. [Settings contract](../appserver/settings-service.md#42-service-settings-owner-path). | | Permission, PromptSources, Skills catalog/management and execution/shell Settings → resource owners | Use the node facts and file operations in the [resource caller matrix](../resource-faces.md#6-provider-binding-and-the-owners-that-use-each-operation), including execHost.info and fsHost resolution and reads. | ## Additional public bindings @@ -148,4 +148,4 @@ existing decoder for stored bytes, its default for absence, and validates the re `validate(document) → void` applies BusinessDocument write validation before admitting a replacement. Settings performs serialization, version checks and persistence. Both calls propagate the original Settings error and end with the registration generation. Foreign codec -calls occur outside SQLite transactions. Declared-schema sources reuse their existing codec. +calls occur outside SQLite transactions and exclusive file leases. Declared-schema sources reuse their existing codec. diff --git a/docs/design/plugins/Hooks.md b/docs/design/plugins/Hooks.md index 06aa13ca41..effeafc0de 100644 --- a/docs/design/plugins/Hooks.md +++ b/docs/design/plugins/Hooks.md @@ -694,7 +694,7 @@ Codex `apply_patch` has no alias: its input is a patch, while Dim's `write` and | `Approval.respond` | `Approval::respond(approval_id, ApprovalDecision)` from `Keyed` | | `HookSources` | Session port `HookSourcesHost(Arc)`, bound by App Server as `CommandRules` and `SkillSettingsHost` are | | `hooks`, `hooks-projects`, `hooks-plugins` | `BusinessDocument` types in App Server (`hooks`: `USER_FILE` `hooks.json`, no `PROJECT_FILE`; `hooks-projects`: `USER_FILE` `hooks-projects.json`; `hooks-plugins`: `USER_FILE` `hooks-plugins.json`, one `{dir, hooks}` entry per plugin id, as `McpPluginServers` in `mcp/config.rs`) | -| `.dimcode/hooks.json` | Read by `HooksSettings` through `FileStorage::path(root, ".dimcode/hooks.json")` and `read_limited`, `root` from `SettingsService::project_root(cwd)`, parsed into the `hooks` document type | +| `.dimcode/hooks.json` | Read by `HooksSettings` through `FileStorage::path(root, ".dimcode/hooks.json")` and `read_limited`, `root` from `settings.projects({})`, parsed into the `hooks` document type | | `register`, `withdraw`, `plugins()` | `HooksService::register_plugin(plugin: String, dir: PathBuf, document: serde_json::Value, cancel: &CancellationToken) -> Result<()>`, `withdraw_plugin(plugin: String, cancel: &CancellationToken) -> Result<()>`, `plugins(cancel: &CancellationToken) -> Result>` and `plugin_refusal(&self, plugin: &str) -> Option<(String, Option<&'static str>)>`, as `McpService`'s (`crates/dim-app-server/src/mcp.rs`): a refused document leaves no entry, and `plugin_refusal` reports its error text with the static reason its cause carries, both read under one lock; PluginManager reads the service through `names.key()` in its `Owners`, its `Kind::Hooks` added to `OWNERS` and `CONTENT` ([PluginManager §3.7](PluginManager.md#37-content-registration)) | | `hooks.*` | `Keyed`; `methods.register(ctx, "hooks", …)` | | Runner | Session service `HooksRuntime`, private to Hooks; processes from `HostPlatform::build_process_spec` and `spawn`, with the event's stdin object (A.3) as the initial stdin (A.6.3), owned by `ctx.effect` | diff --git a/docs/design/plugins/Scheduler.md b/docs/design/plugins/Scheduler.md index 13088f4dff..c3f15819c8 100644 --- a/docs/design/plugins/Scheduler.md +++ b/docs/design/plugins/Scheduler.md @@ -924,7 +924,7 @@ no `schedule.*` methods or `schedule` tool. The process part is added with | Tool `schedule` registered with `toolRegistry` | Session part keys `ToolRegistry` from `names.key()` and calls `tools.register(ctx, ToolContribution {definition, handler})` in `apply`, as `dim-agent-questions` does | | Namespace `schedule` registered with `managementMethods` | Process part keys `ManagementMethods` and calls `methods.register(ctx, "schedule", declarations, handler)`; Rpc looks it up per call and holds no dependency on Scheduler | | `scheduleJobs`, `wakeups`, `loops` | Process-group data faces registered shared and provided at their `host_key`. Native `ScheduleJobs`, `Wakeups` and `Loops` are bindings to the same owner operations, provided under their type keys. The native Session part declares them with `names.key()` and calls them directly. Wire projection happens only at the bridge boundary. `loops` serves `start`, `next`, `list` and `stop`; the delivery pass, recovery and `settle_delivering` stay internal (§12.6) | -| `settings`, `pluginFiles` | Typed App Server services (`SettingsService`, `PluginFileTransactions`) keyed with `names.key()`; the crate depends on `dim-app-server`, which `xtask check` allows | +| `settings`, `pluginFiles` | Typed App Server services (`Settings` → `RegisteredDocument`, `PluginFileTransactions`) keyed with `names.key()`; the crate depends on `dim-app-server`, which `xtask check` allows | | `sessions` | The shared host-dispatch name, called with its JSON envelope; its native request types are private to App Server | | Process storage | The typed `PluginFileTransactions` service of App Server ([trusted plugin storage](../../../crates/dim-app-server/README.md#trusted-plugin-storage)). The host writes the `{version: 1, text}` envelope; Scheduler supplies the inner v1 text, the same bytes the TypeScript version wrote. | | Timer, delivery writes and the stop timer | Owned by the process part: the timer, delivery tasks and retention run in its task tracker and start after its methods and services are registered and the process is published (§9 R1). On unload (`ctx.cancellation_token()`), new work stops, waits end, and cleanup joins the tracker before the storage scope closes; an admitted `sessions` call settles first. A record still `delivering` is left in the file for the next generation's recovery. The Session tools return the unloading results of §1.3 and their own `schedule: cancelled before handover` or `wakeup: cancelled before handover`. | diff --git a/docs/design/subagent-model-policy.md b/docs/design/subagent-model-policy.md index e02864b513..a4fa6b6da1 100644 --- a/docs/design/subagent-model-policy.md +++ b/docs/design/subagent-model-policy.md @@ -53,7 +53,7 @@ decision by an LLM. `agent` means the existing request/profile selection behavio | Identify the requesting branch | `CollaborationSession::request` already receives `branch_id`; pass it within Collaboration, without changing an event or tool request | | Read the adopted leader model | `Session::get(branch_id)` while consuming `collaboration/request`, before starting its delivery task | | Resolve an explicit model | The existing `AgentIndex` model-selection host and configured/non-catalog profile paths | -| Persist and edit policy | Native `BusinessDocument`, `SettingsService::read/update`, source CAS and owner management methods, as used by `permission_rules.rs` | +| Persist and edit policy | Native `BusinessDocument`, source-bound `read/update`, source CAS and owner management methods, as used by `permission_rules.rs` | | Start/restore and retain members | Existing Agents/Collaboration Session creation, usage holds and cleanup, including idle unloading | Do not use `leader.config().model` or `session.summaries` as the adopted leader model: @@ -126,7 +126,7 @@ serve Rust `BusinessDocument` sources. A dedicated `CollaborationModelPolicyPlugin` process owner row provides these methods by registering namespace `collaboration` with the process `ManagementMethods` table. It owns the native document's read/validation/CAS -operations and depends on `Keyed` and `Keyed`. +operations and depends on `Keyed` and `Keyed`. It is not the Collaboration plugin that Rpc already reaches through a Gate: the management owner must reload independently without unloading Rpc, per the methods contract §3.2. @@ -149,11 +149,8 @@ before another CAS, without automatically replacing the user's selection. App Server configurations without `local_execution()` continue using existing `agent` behavior and expose no policy management methods. -Collaboration must not gain an unconditional Settings dependency: declare the -dependency as `When>`, with keys from -`names.when::>(local_execution())`, the same predicate Agents -uses. Obtain it from `Deps`. In those hosts Collaboration already -reaches Settings through AgentIndex; account-only roots do not add a wait. The +The local execution profile gates Collaboration on Settings. At member creation, +Collaboration reads the current policy through `collaborationModelPolicy.read({})`. The composition root reserves the native source and registers its dedicated management owner only under that predicate. The owner's `apply` registers its methods with `methods.register(ctx, "collaboration", ...)`. diff --git a/docs/zh/design/appserver/permission-command-rules.md b/docs/zh/design/appserver/permission-command-rules.md index 903baa45c7..77f1c40a41 100644 --- a/docs/zh/design/appserver/permission-command-rules.md +++ b/docs/zh/design/appserver/permission-command-rules.md @@ -165,7 +165,7 @@ impl Permission { | --- | --- | | `defaults::install`、`install_with_prompt`、`install_with_process_model`(App Server mock 配置与测试宿主) | `install_profile` 用 `session_data_value` 绑定固定的空宿主 `NoCommandRules`,与它已绑定的 `EmptyPromptHost` 并列。现有测试不变 | | `install_with_prompt_capability`、`install_local_execution`、`install_minimal_execution` | 与 `PromptHost` 一样不绑定:由安装它们的宿主绑定端口。只用 capabilities 的宿主(集成测试、`xtask` 本地图)绑定 `CommandRules(Arc::new(NoCommandRules))` | -| App Server 产品配置(`main.rs` 中的 `install_local_execution`、其测试与 `xtask` App Server 图) | 配置调用 `permission_rules::install(&mut builder)`,加入功能 `CommandRules` 并要求它的 Session 部分 `CommandRules`(`require_feature`,Deps `Keyed`),它提供的 `CommandRules` 每次调用都读取 `SettingsService::read::(User)`。`serve` 在本地执行时注册进程部分 `PermissionRulesPlugin`(`register_part`,Deps `Keyed` 与 `Keyed`,所有者行 `permission`),与 `mcp`、`skills` 并列,由它提供管理方法。两者与文档类型 `PermissionSettings`(`NAMESPACE = "permission"`、`USER_FILE = "permission.json"`、无 `PROJECT_FILE`)同在 `dim-app-server/src/permission_rules.rs` | +| App Server 产品配置(`main.rs` 中的 `install_local_execution`、其测试与 `xtask` App Server 图) | 配置调用 `permission_rules::install(&mut builder)`,加入功能 `CommandRules` 并要求它的 Session 部分 `CommandRules`(`require_feature`,Deps `Keyed`),它提供的 `CommandRules` 每次调用都读取 `RegisteredDocument::read(User)`。`serve` 在本地执行时注册进程部分 `PermissionRulesPlugin`(`register_part`,Deps `Keyed` 与 `Keyed`,所有者行 `permission`),与 `mcp`、`skills` 并列,由它提供管理方法。两者与文档类型 `PermissionSettings`(`NAMESPACE = "permission"`、`USER_FILE = "permission.json"`、无 `PROJECT_FILE`)同在 `dim-app-server/src/permission_rules.rs` | ## 5. 流程 diff --git a/docs/zh/design/appserver/settings-service.md b/docs/zh/design/appserver/settings-service.md index 2037813ec0..5f052c500c 100644 --- a/docs/zh/design/appserver/settings-service.md +++ b/docs/zh/design/appserver/settings-service.md @@ -16,7 +16,7 @@ Settings 为不是用 Rust 写的插件提供业务来源。这类插件在启 ([ADR 007](../../adr/007-plugin-configuration.md) D5):来源名、文件、JSON Schema(含 `default` 值)和 仅限用户的字段(§3.1)。随后 Settings 在 JSON 文档上提供三样东西: -- 进程服务 `settings`,供所有者使用:`register`、`read`、`update`(按 revision 做 CAS)和 `projects`; +- 进程服务 `settings` 用于来源登记、读写及项目授权(§4.2); - 客户端管理方法 `settings.read`、`settings.update`、`settings.sources` 和 `settings.projects`; - 与 S8a 相同的 rutis 事件 `settings.changed` 和 `settings.project_authorized`。它们的载荷改为 可序列化。没有 `subscribe(source)`。 @@ -275,13 +275,12 @@ Settings 在内存中保存已登记的来源(声明已编译),各自保 ### 4.5 Rust 绑定 `Settings` 绑定公开公共 `settings` 数据面的 owner 操作,提供 -`register(ctx, declaration)`、`read(source, scope, cancel)`、 -`update(source, scope, expected, document, cancel)` 和 `projects()`。 +声明式来源的 `register`、`declared_by`、`read` 和 `update`,自定义来源的 `register_document` 及其绑定的读写操作,以及项目授权与枚举的 `authorize_project` 和 `projects`。 Dispatcher 调用这些相同操作;原生消费者直接调用,无需 JSON 转换。登记仍绑定调用者生命周期, 更新仍是不能修改 user-only 字段的 owner 写入。来源注册、校验和持久化仍由同一个 Settings owner 承担。 `SettingsService` 保留下述原生 `BusinessDocument` 和客户端管理路径。 -PluginManager 的声明式来源工具也通过它读取并进行 owner 写入。此绑定不使声明式操作可见 +PluginManager 的声明式来源工具通过公共 `Settings` 绑定读取并写入。此绑定不使声明式操作可见 原生来源,也不改变 §4.3 和 §7 的本地客户端边界。 在 `dim-app-server::settings` 中(S8a 的类型,只在注明处改动): diff --git a/docs/zh/design/plugins/Hooks.md b/docs/zh/design/plugins/Hooks.md index a7a2005744..897f6e3489 100644 --- a/docs/zh/design/plugins/Hooks.md +++ b/docs/zh/design/plugins/Hooks.md @@ -692,7 +692,7 @@ Codex 的 `apply_patch` 没有别名:它的输入是补丁,而 Dim 的 `writ | `Approval.respond` | 经 `Keyed` 调用 `Approval::respond(approval_id, ApprovalDecision)` | | `HookSources` | Session 端口 `HookSourcesHost(Arc)`,由 App Server 绑定,如同 `CommandRules` 与 `SkillSettingsHost` | | `hooks`、`hooks-projects`、`hooks-plugins` | App Server 中的 `BusinessDocument` 类型(`hooks`:`USER_FILE` 为 `hooks.json`,没有 `PROJECT_FILE`;`hooks-projects`:`USER_FILE` 为 `hooks-projects.json`;`hooks-plugins`:`USER_FILE` 为 `hooks-plugins.json`,每个插件 id 一条 `{dir, hooks}`,如同 `mcp/config.rs` 中的 `McpPluginServers`) | -| `.dimcode/hooks.json` | 由 `HooksSettings` 经 `FileStorage::path(root, ".dimcode/hooks.json")` 与 `read_limited` 读取,`root` 来自 `SettingsService::project_root(cwd)`,解析为 `hooks` 文档类型 | +| `.dimcode/hooks.json` | 由 `HooksSettings` 经 `FileStorage::path(root, ".dimcode/hooks.json")` 与 `read_limited` 读取,`root` 来自 `settings.projects({})`,解析为 `hooks` 文档类型 | | `register`、`withdraw`、`plugins()` | `HooksService::register_plugin(plugin: String, dir: PathBuf, document: serde_json::Value, cancel: &CancellationToken) -> Result<()>`、`withdraw_plugin(plugin: String, cancel: &CancellationToken) -> Result<()>`、`plugins(cancel: &CancellationToken) -> Result>` 与 `plugin_refusal(&self, plugin: &str) -> Option<(String, Option<&'static str>)>`,如同 `McpService` 的(`crates/dim-app-server/src/mcp.rs`):被拒绝的文档不留条目,`plugin_refusal` 报告其错误文本以及原因携带的静态 reason,两者在同一把锁下读取;PluginManager 在其 `Owners` 中经 `names.key()` 读取该服务,`Kind::Hooks` 加入 `OWNERS` 与 `CONTENT`([PluginManager §3.7](PluginManager.md#37-内容登记)) | | `hooks.*` | `Keyed`;`methods.register(ctx, "hooks", …)` | | 执行器 | Session 服务 `HooksRuntime`,Hooks 私有;进程来自 `HostPlatform::build_process_spec` 与 `spawn`,事件的 stdin 对象(A.3)作为初始 stdin(A.6.3),由 `ctx.effect` 持有 | diff --git a/docs/zh/design/plugins/Scheduler.md b/docs/zh/design/plugins/Scheduler.md index 61005bf350..b74a9cf5f0 100644 --- a/docs/zh/design/plugins/Scheduler.md +++ b/docs/zh/design/plugins/Scheduler.md @@ -871,7 +871,7 @@ Scheduler 是原生 Rust,无 TypeScript 包、Node 进程或回退。上面的 | 注册到 `toolRegistry` 的工具 `schedule` | Session 部分经 `names.key()` 取得 `ToolRegistry`,并在 `apply` 中调用 `tools.register(ctx, ToolContribution {definition, handler})`,与 `dim-agent-questions` 相同 | | 注册到 `managementMethods` 的命名空间 `schedule` | 进程部分取得 `ManagementMethods` 并调用 `methods.register(ctx, "schedule", declarations, handler)`;Rpc 每次调用查找它,不持有对 Scheduler 的依赖 | | `scheduleJobs`、`wakeups`、`loops` | 注册为 shared 的进程组数据面,在各自的 `host_key` 提供 dispatcher。原生 `ScheduleJobs`、`Wakeups`、`Loops` 是同一 owner 操作的绑定,在类型键提供。原生 Session 部分用 `names.key()` 声明这些依赖并直接调用;wire 投影仅在 bridge 边界发生。`loops` 提供 `start`、`next`、`list`、`stop`;投递 pass、恢复与 `settle_delivering` 保持内部(§12.6) | -| `settings`、`pluginFiles` | 用 `names.key()` 键入的 App Server 类型化服务(`SettingsService`、`PluginFileTransactions`);该 crate 依赖 `dim-app-server`,`xtask check` 允许 | +| `settings`、`pluginFiles` | 用 `names.key()` 键入的 App Server 类型化服务(`Settings` → `RegisteredDocument`、`PluginFileTransactions`);该 crate 依赖 `dim-app-server`,`xtask check` 允许 | | `sessions` | 共享的宿主分发名称,以其 JSON 信封调用;其原生请求类型对 App Server 私有 | | 进程存储 | App Server 的类型化 `PluginFileTransactions` 服务([可信插件存储](../../../../crates/dim-app-server/README.md#trusted-plugin-storage))。宿主写入 `{version: 1, text}` 信封;Scheduler 提供内层 v1 文本,即 TypeScript 版本写下的同一批字节。 | | 定时器、投递写入与停止定时器 | 由进程部分拥有:定时器、投递任务与保留期在其任务跟踪器中运行,并在其方法与服务注册之后、进程发布之后启动(§9 R1)。卸载时(`ctx.cancellation_token()`),新工作停止、等待结束,清理在关闭存储作用域之前等待跟踪器;已准入的 `sessions` 调用先结算。仍为 `delivering` 的记录留在文件中,交给下一代的恢复。Session 工具返回 §1.3 的卸载结果及其自己的 `schedule: cancelled before handover` 或 `wakeup: cancelled before handover`。 | diff --git a/runtime/fixtures/settings-owner.ts b/runtime/fixtures/settings-owner.ts index 3049c573f7..5c265ecc07 100644 --- a/runtime/fixtures/settings-owner.ts +++ b/runtime/fixtures/settings-owner.ts @@ -16,10 +16,12 @@ export const part = definePlugin({ inject: ['settings', 'sessionMethods'], async apply(ctx) { const settings = ctx.use('settings') + let pauseDecode: (() => Promise) | undefined const registerCustom = () => ctx.use('settings').registerDocument( - { source: 'example-custom', userFile: 'example-custom.json' }, + { source: 'example-custom', userFile: 'example-custom.json', projectFile: '.example-custom.json' }, { - decode(bytes): { count: number } { + async decode(bytes): Promise<{ count: number }> { + await pauseDecode?.() return bytes === null ? { count: 3 } : JSON.parse(new TextDecoder().decode(bytes)) }, validate(document: { count: number }) { @@ -34,7 +36,7 @@ export const part = definePlugin({ } await ctx.use('sessionMethods').register( 'session.example', - ['read', 'update', 'events', 'declared', 'custom_read', 'custom_update'].map(name => ({ + ['read', 'update', 'events', 'declared', 'custom_read', 'custom_update', 'custom_concurrent'].map(name => ({ name: `session.example.${name}`, mutating: false, interruption: 'report', progress: false, })), async (call: MethodCall) => { @@ -43,6 +45,28 @@ export const part = definePlugin({ custom ??= await registerCustom() return { kind: 'value', value: await custom.read('user') } } + if (call.method.endsWith('.custom_concurrent')) { + if (typeof request.root !== 'number') throw new Error('expected project root') + const scope = { project: request.root } + const original = await custom.read(scope) + if (!original.ok) throw new Error(original.error.message) + let entered!: () => void + let release!: () => void + const decoding = new Promise(resolve => { entered = resolve }) + const released = new Promise(resolve => { release = resolve }) + pauseDecode = () => { entered(); return released } + const reader = Promise.resolve(custom.read(scope)) + try { + await decoding + const stale = await custom.update(scope, 'stale', { count: 7 }) + const written = await custom.update(scope, original.value.revision, { count: 8 }) + return { kind: 'value', value: { stale, written } } + } finally { + pauseDecode = undefined + release() + await reader + } + } if (call.method.endsWith('.custom_update')) { if (typeof request.expectedRevision !== 'string' || typeof request.count !== 'number') throw new Error('expected revision and count') return { kind: 'value', value: await custom.update('user', request.expectedRevision, { count: request.count }) } From 64b2284fa01baaf3270c62abfafda162606a78d4 Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 18:47:31 +0800 Subject: [PATCH 08/10] Document the native Settings registration used by document owners --- crates/dim-app-server/README.md | 2 +- docs/design/appserver/settings-service.md | 6 +++--- docs/zh/design/appserver/settings-service.md | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/dim-app-server/README.md b/crates/dim-app-server/README.md index 20804fb606..8e2b6a54ac 100644 --- a/crates/dim-app-server/README.md +++ b/crates/dim-app-server/README.md @@ -94,7 +94,7 @@ not add automatic retry or recovery. See the [CLI submission contract](../../doc SettingsService reads and updates generic `BusinessDocument` values with per-source CAS. Business owners define and validate their payloads: MCP types live in `mcp/config.rs`, and the Skills owner supplies the existing `SkillSettingsHost`. -Each owner registers its sources in its `apply` (`SettingsService::register`, or +Each owner registers its sources in its `apply` (`Settings::register_document` for a native `BusinessDocument`, or `register` on the named `settings` service); a source is served only while its owner is loaded, and its stored document stays when the owner unloads. Settings owns source persistence, not approvals or business management methods. diff --git a/docs/design/appserver/settings-service.md b/docs/design/appserver/settings-service.md index b2dc904356..28a98a85c2 100644 --- a/docs/design/appserver/settings-service.md +++ b/docs/design/appserver/settings-service.md @@ -118,7 +118,7 @@ owner depends on `settings`. Every owner, built-in Rust and TypeScript alike, registers its sources from its own process row's `apply`. Declared sources use `settings.register(declaration)` through their language binding -(§4.2, §4.5); native `BusinessDocument` sources use `SettingsService::register::` (§4.5). Neither the App Server's assembly nor PluginManager +(§4.2, §4.5); native `BusinessDocument` sources use `Settings::register_document::` (§4.5). Neither the App Server's assembly nor PluginManager declares sources. A registration belongs to the plugin that made it and is withdrawn when that plugin unloads (turned off, removed or reloaded); a reload registers again from the new generation. The stored documents stay in the home whether or not their source is registered: an @@ -263,7 +263,7 @@ with `managementMethods` (§4.5). They are never served to paired devices (overv the `plugin` tool's `config` command, which additionally returns the user document with `writeOnly` members redacted and listed in `writeOnlySet` (PluginManager §6). - `schedule` is not a declared source. `ScheduleDocument` is a Rust `BusinessDocument`, - registered with `settings.register::`, validated by its own `validate()`, + registered with `settings.register_document::`, validated by its own `validate()`, served by `schedule.*`, and `settings_unknown_source` on every `settings.*` path. A Rust source keeps its own typed methods and is out of a schema-driven surface; `settings.sources` lists declared sources only and therefore never lists it. @@ -314,7 +314,7 @@ Permission does). ### 4.5 Rust binding The `Settings` binding exposes the owner operations of the public `settings` data face. -Declared sources use `register`, `declared_by`, `read` and `update`. Custom sources use +Declared sources use `register`, `declared_by`, `read` and `update`. Native `BusinessDocument` sources use `register_document` and its bound read/update operations. Project admission and listing use `authorize_project` and `projects`. The dispatcher calls these same operations, and native consumers call them directly diff --git a/docs/zh/design/appserver/settings-service.md b/docs/zh/design/appserver/settings-service.md index 5f052c500c..018d0002f2 100644 --- a/docs/zh/design/appserver/settings-service.md +++ b/docs/zh/design/appserver/settings-service.md @@ -103,7 +103,7 @@ Settings 不赋予任何字段特殊含义,只有一个例外:schema 带 JSO 每个所有者,不论是内置 Rust 还是 TypeScript,都在自己进程行的 `apply` 中登记来源。声明式来源 通过对应语言绑定调用 `settings.register(declaration)`(§4.2、§4.5);原生 `BusinessDocument` 来源 -使用 `SettingsService::register::`(§4.5)。 +使用 `Settings::register_document::`(§4.5)。 App Server 的装配和 PluginManager 都不声明来源。登记属于发起它的插件,在该插件卸载(关闭、移除或 重载)时撤回;重载时由新一代重新登记。不论来源是否已登记,存储的文档都留在 home 中:未登记的来源 在所有路径上都是 `unknown_source`,有所有者登记它后,其文档重新可用。 @@ -235,7 +235,7 @@ Settings 在内存中保存已登记的来源(声明已编译),各自保 agent 侧的对应物仍是 `plugin` 工具的 `config` 命令,它额外返回用户文档,并把 `writeOnly` 成员去掉后列在 `writeOnlySet` 里(PluginManager §6)。 - `schedule` 不是声明的来源。`ScheduleDocument` 是 Rust 的 `BusinessDocument`,经 - `settings.register::` 登记,由它自己的 `validate()` 校验,由 `schedule.*` + `settings.register_document::` 登记,由它自己的 `validate()` 校验,由 `schedule.*` 提供,在所有 `settings.*` 路径上都是 `settings_unknown_source`。Rust 来源保留自己类型化的 方法,不属于 schema 驱动的表面;`settings.sources` 只列声明的来源,因此从不列出它。 - `settings.sources` 从不提供给已配对设备(§4.3 开头),也不在 Web 入口的允许清单里,因此 @@ -275,7 +275,7 @@ Settings 在内存中保存已登记的来源(声明已编译),各自保 ### 4.5 Rust 绑定 `Settings` 绑定公开公共 `settings` 数据面的 owner 操作,提供 -声明式来源的 `register`、`declared_by`、`read` 和 `update`,自定义来源的 `register_document` 及其绑定的读写操作,以及项目授权与枚举的 `authorize_project` 和 `projects`。 +声明式来源的 `register`、`declared_by`、`read` 和 `update`,原生 `BusinessDocument` 来源的 `register_document` 及其绑定的读写操作,以及项目授权与枚举的 `authorize_project` 和 `projects`。 Dispatcher 调用这些相同操作;原生消费者直接调用,无需 JSON 转换。登记仍绑定调用者生命周期, 更新仍是不能修改 user-only 字段的 owner 写入。来源注册、校验和持久化仍由同一个 Settings owner 承担。 From 6ae39cc3c8aaa4cca224366fd3593819ebebe721 Mon Sep 17 00:00:00 2001 From: eric8810 Date: Fri, 20 Nov 2026 22:18:39 +0800 Subject: [PATCH 09/10] Use rutis 0.23 value errors for Settings and collaboration policy --- .../src/collaboration_model_policy.rs | 4 ++-- crates/dim-app-server/src/settings/document.rs | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/dim-app-server/src/collaboration_model_policy.rs b/crates/dim-app-server/src/collaboration_model_policy.rs index 22f8e55c9d..888e6728b3 100644 --- a/crates/dim-app-server/src/collaboration_model_policy.rs +++ b/crates/dim-app-server/src/collaboration_model_policy.rs @@ -109,12 +109,12 @@ impl rutis_bridge::session::HostDispatch for CollaborationModelPolicy { ) -> rutis_bridge::session::Reply { use rutis_bridge::session::{Error, Value}; if method != "read" { - return Err(Error::Value(format!( + return Err(Error::value(format!( "unknown collaborationModelPolicy method {method}" ))); } let (_request,): (Empty,) = serde_json::from_value(args.json()?) - .map_err(|_| Error::Value("expected one empty request".into()))?; + .map_err(|_| Error::value("expected one empty request"))?; let owner = self.clone(); Ok(Value::future(async move { let cancel = tokio_util::sync::CancellationToken::new(); diff --git a/crates/dim-app-server/src/settings/document.rs b/crates/dim-app-server/src/settings/document.rs index eaa0b328e7..9f5119581c 100644 --- a/crates/dim-app-server/src/settings/document.rs +++ b/crates/dim-app-server/src/settings/document.rs @@ -74,9 +74,8 @@ impl Format for Codec { pub(super) fn register(settings: Arc, caller: &Ctx, args: Value) -> Reply { let invalid = || { - Error::Value( - "expected a settings source declaration and a codec with decode and validate functions" - .into(), + Error::value( + "expected a settings source declaration and a codec with decode and validate functions", ) }; let [declaration, Value::Reference(methods)]: [Value; 2] = @@ -103,7 +102,7 @@ pub(super) fn register(settings: Arc, caller: &Ctx, args: Value .as_deref() .map_or(Ok(()), validate_file) }); - checked.map_err(|error| Error::Value(error.to_string()))?; + checked.map_err(|error| Error::value(error.to_string()))?; let registration = settings .insert( caller, @@ -115,7 +114,7 @@ pub(super) fn register(settings: Arc, caller: &Ctx, args: Value kind: Kind::Custom, }, ) - .map_err(|error| Error::Value(error.to_string()))?; + .map_err(|error| Error::value(error.to_string()))?; let source = Arc::new(RegisteredDocument { settings, registration: Arc::downgrade(®istration), @@ -124,7 +123,7 @@ pub(super) fn register(settings: Arc, caller: &Ctx, args: Value let read = source.clone(); let read = Value::callback(move |args| { let (scope,): (SettingsScope,) = serde_json::from_value(args.json()?) - .map_err(|_| Error::Value("expected a settings scope".into()))?; + .map_err(|_| Error::value("expected a settings scope"))?; let read = read.clone(); Ok(Value::future(async move { let cancel = CancellationToken::new(); @@ -134,9 +133,8 @@ pub(super) fn register(settings: Arc, caller: &Ctx, args: Value }); let update = Value::callback(move |args| { let (scope, revision, document): (SettingsScope, String, Json) = - serde_json::from_value(args.json()?).map_err(|_| { - Error::Value("expected scope, expectedRevision and document".into()) - })?; + serde_json::from_value(args.json()?) + .map_err(|_| Error::value("expected scope, expectedRevision and document"))?; let source = source.clone(); Ok(Value::future(async move { let cancel = CancellationToken::new(); From 7a6608f0c8ce735789944bbae2c525664c39f6cd Mon Sep 17 00:00:00 2001 From: eric8810 Date: Sun, 22 Nov 2026 01:08:38 +0800 Subject: [PATCH 10/10] Register custom settings documents once and reuse the Hooks owner reader --- crates/dim-app-server/src/cli.rs | 2 +- crates/dim-app-server/src/hooks_settings.rs | 49 +++---------------- crates/dim-app-server/src/settings.rs | 49 +++++++++++++++---- .../dim-app-server/src/settings/declared.rs | 14 +++--- .../dim-app-server/src/settings/document.rs | 33 +++---------- .../tests/transport_flow/plugin_manager.rs | 20 ++++---- .../tests/appended_context_flow.rs | 6 +-- crates/dimcode/tests/cli_flow/hooks.rs | 2 +- 8 files changed, 78 insertions(+), 97 deletions(-) diff --git a/crates/dim-app-server/src/cli.rs b/crates/dim-app-server/src/cli.rs index a69547337b..81ef71a268 100644 --- a/crates/dim-app-server/src/cli.rs +++ b/crates/dim-app-server/src/cli.rs @@ -585,7 +585,7 @@ pub fn run_with( dim_agent_capabilities::timeline_tree::BranchToolConfig::default(), ); permission_rules::install(&mut builder); - hooks_settings::install(&mut builder, config.product_home.clone()); + hooks_settings::install(&mut builder); dim_agent_capabilities::hooks::install(&mut builder); crate::session_grants::install(&mut builder); dim_agent_capabilities::file_access::install(&mut builder); diff --git a/crates/dim-app-server/src/hooks_settings.rs b/crates/dim-app-server/src/hooks_settings.rs index ecdc43a8af..151730eaa1 100644 --- a/crates/dim-app-server/src/hooks_settings.rs +++ b/crates/dim-app-server/src/hooks_settings.rs @@ -282,49 +282,19 @@ fn host_error_message(message: String) -> dim_agent_capabilities::host::HostErro /// Registers the Session part that binds the hook sources; the host registers /// `HooksSettingsPlugin` with its Settings. -pub fn install(builder: &mut AgentBuilder, product_home: Option) { +pub fn install(builder: &mut AgentBuilder) { crate::register_names(builder.catalog_mut()); - builder.require_feature( - Feature::new("HookSources").session("HookSources", move |names| { - Ok(Box::new(HookSourcesPlugin::new( - names, - product_home.clone(), - )?)) - }), - ); -} - -struct SessionHookSources { - owner: Arc, - home: Option, -} -impl ReadHookSources for SessionHookSources { - fn sources( - &self, - cwd: &Path, - cancel: CancellationToken, - ) -> dim_agent_capabilities::host::HostFuture<'_, HookSourcesSnapshot> { - let cwd = cwd.to_path_buf(); - Box::pin(async move { self.owner.sources(&cwd, cancel).await }) - } - fn home(&self) -> Option { - self.home.clone() - } + builder.require_feature(Feature::new("HookSources").session("HookSources", |names| { + Ok(Box::new(HookSourcesPlugin { + host: names.key()?, + owner: names.key()?, + })) + })); } struct HookSourcesPlugin { host: Key, owner: Key, - home: Option, -} -impl HookSourcesPlugin { - fn new(names: &Names<'_>, home: Option) -> rutis::Result { - Ok(Self { - host: names.key()?, - owner: names.key()?, - home, - }) - } } impl DynPlugin for HookSourcesPlugin { fn name(&self) -> &str { @@ -338,10 +308,7 @@ impl DynPlugin for HookSourcesPlugin { let owner = ctx.require_at(&self.owner)?; ctx.provide_at( self.host.clone(), - Arc::new(HookSourcesHost(Arc::new(SessionHookSources { - home: self.home.clone(), - owner, - }))), + Arc::new(HookSourcesHost(owner.reader.clone())), )?; Ok(Effect::Done) }) diff --git a/crates/dim-app-server/src/settings.rs b/crates/dim-app-server/src/settings.rs index 4197ed6fa6..7ade454dc1 100644 --- a/crates/dim-app-server/src/settings.rs +++ b/crates/dim-app-server/src/settings.rs @@ -235,6 +235,23 @@ pub struct RegisteredDocument { } impl RegisteredDocument { + fn register( + settings: Arc, + owner: &Ctx, + format: Arc>, + user_file: &str, + project_file: Option<&str>, + kind: Kind, + ) -> rutis::Result> { + let registration = + settings.register_source(owner, format.source(), user_file, project_file, kind)?; + Ok(Arc::new(Self { + settings, + registration: Arc::downgrade(®istration), + format, + })) + } + fn path(&self, scope: SettingsScope) -> Result { let entry = current_registration(&self.settings, self.format.source(), &self.registration)?; self.settings.locate( @@ -297,26 +314,38 @@ impl SettingsService { /// Registers the Rust source `D` for as long as the plugin that owns /// `ctx` is loaded. A source name or file registered already fails. pub fn register(&self, ctx: &Ctx) -> rutis::Result<()> { - self.register_typed::(ctx).map(drop) + self.register_source( + ctx, + D::NAMESPACE, + D::USER_FILE, + D::PROJECT_FILE, + Kind::Rust(TypeId::of::()), + ) + .map(drop) } - fn register_typed( + + fn register_source( &self, ctx: &Ctx, + name: &str, + user_file: &str, + project_file: Option<&str>, + kind: Kind, ) -> rutis::Result>> { - let failed = |error: SettingsError| registration_failed(D::NAMESPACE, error.to_string()); - validate_namespace(D::NAMESPACE).map_err(failed)?; - validate_file(D::USER_FILE).map_err(failed)?; - if let Some(file) = D::PROJECT_FILE { + let failed = |error: SettingsError| registration_failed(name, error.to_string()); + validate_namespace(name).map_err(failed)?; + validate_file(user_file).map_err(failed)?; + if let Some(file) = project_file { validate_file(file).map_err(failed)?; } self.insert( ctx, - D::NAMESPACE, + name, Source { owner: ctx.instance().to_string(), - user_file: D::USER_FILE.into(), - project_file: D::PROJECT_FILE.map(Into::into), - kind: Kind::Rust(TypeId::of::()), + user_file: user_file.into(), + project_file: project_file.map(Into::into), + kind, }, ) } diff --git a/crates/dim-app-server/src/settings/declared.rs b/crates/dim-app-server/src/settings/declared.rs index 968fa69322..92c08e9f2a 100644 --- a/crates/dim-app-server/src/settings/declared.rs +++ b/crates/dim-app-server/src/settings/declared.rs @@ -345,12 +345,14 @@ impl Settings { &self, owner: &Ctx, ) -> rutis::Result>> { - let registration = self.0.register_typed::(owner)?; - Ok(Arc::new(RegisteredDocument { - settings: self.0.clone(), - registration: Arc::downgrade(®istration), - format: typed::(), - })) + RegisteredDocument::register( + self.0.clone(), + owner, + typed::(), + D::USER_FILE, + D::PROJECT_FILE, + Kind::Rust(TypeId::of::()), + ) } /// The declarations of the JSON Schema sources the row `instance_id` diff --git a/crates/dim-app-server/src/settings/document.rs b/crates/dim-app-server/src/settings/document.rs index 9f5119581c..f0c10ed0f9 100644 --- a/crates/dim-app-server/src/settings/document.rs +++ b/crates/dim-app-server/src/settings/document.rs @@ -94,32 +94,15 @@ pub(super) fn register(settings: Arc, caller: &Ctx, args: Value owner: caller.cancellation_token(), service: settings.stopping.clone(), }; - let checked = validate_namespace(&declaration.source) - .and_then(|()| validate_file(&declaration.user_file)) - .and_then(|()| { - declaration - .project_file - .as_deref() - .map_or(Ok(()), validate_file) - }); - checked.map_err(|error| Error::value(error.to_string()))?; - let registration = settings - .insert( - caller, - &declaration.source, - Source { - owner: caller.instance().to_string(), - user_file: declaration.user_file, - project_file: declaration.project_file, - kind: Kind::Custom, - }, - ) - .map_err(|error| Error::value(error.to_string()))?; - let source = Arc::new(RegisteredDocument { + let source = RegisteredDocument::register( settings, - registration: Arc::downgrade(®istration), - format: Arc::new(format), - }); + caller, + Arc::new(format), + &declaration.user_file, + declaration.project_file.as_deref(), + Kind::Custom, + ) + .map_err(|error| Error::value(error.to_string()))?; let read = source.clone(); let read = Value::callback(move |args| { let (scope,): (SettingsScope,) = serde_json::from_value(args.json()?) diff --git a/crates/dim-app-server/tests/transport_flow/plugin_manager.rs b/crates/dim-app-server/tests/transport_flow/plugin_manager.rs index 57004d95ef..95bb0ce6e7 100644 --- a/crates/dim-app-server/tests/transport_flow/plugin_manager.rs +++ b/crates/dim-app-server/tests/transport_flow/plugin_manager.rs @@ -3089,9 +3089,9 @@ async fn plugin_content_follows_the_record_over_restarts() { /// The product's local execution profile with mock model hosts, with Hooks /// installed: a Session mounts the Hooks parts and reads its hook sources. -fn hooks_builder(home: &Path) -> AgentBuilder { +fn hooks_builder() -> AgentBuilder { let mut builder = product_builder(); - dim_app_server::hooks_settings::install(&mut builder, Some(home.to_owned())); + dim_app_server::hooks_settings::install(&mut builder); dim_agent_capabilities::hooks::install(&mut builder); builder } @@ -3185,7 +3185,7 @@ async fn plugin_hooks_run_with_their_plugin_root_and_follow_the_record() { .to_string(), ) .unwrap(); - let server = serve(hooks_builder(&home), config.clone()).await.unwrap(); + let server = serve(hooks_builder(), config.clone()).await.unwrap(); let mut client = Client::new_version(&server, false, 3).await; select_fixture_model(&mut client).await; @@ -3261,7 +3261,7 @@ async fn plugin_hooks_run_with_their_plugin_root_and_follow_the_record() { // The registration is kept in `hooks-plugins`, so a new process restores // it without being told again. - let server = serve(hooks_builder(&home), config).await.unwrap(); + let server = serve(hooks_builder(), config).await.unwrap(); let mut client = Client::new_version(&server, false, 3).await; when_served(&mut client, "plugin.list", json!({})).await; let session = session_in(&mut client, &work).await; @@ -3334,7 +3334,7 @@ async fn a_refused_plugin_hook_document_stops_only_its_own_kind() { let source = home.join("src/kit"); write_hook_plugin(&source, "kit", &runs, "kit"); std::fs::write(source.join("hooks.json"), json!({"hooks": []}).to_string()).unwrap(); - let server = serve(hooks_builder(&home), config.clone()).await.unwrap(); + let server = serve(hooks_builder(), config.clone()).await.unwrap(); let mut client = Client::new_version(&server, false, 3).await; select_fixture_model(&mut client).await; @@ -3370,7 +3370,7 @@ async fn a_refused_plugin_hook_document_stops_only_its_own_kind() { // Startup registers every plugin in use again, so a refused document is // reported again after a restart. - let server = serve(hooks_builder(&home), config).await.unwrap(); + let server = serve(hooks_builder(), config).await.unwrap(); let mut client = Client::new_version(&server, false, 3).await; let list = call(&mut client, "plugin.list", json!({})).await; assert_eq!(item(&list, "kit")["refused"][0]["kind"], "hooks", "{list}"); @@ -3407,7 +3407,7 @@ async fn a_plugin_hooks_document_that_cannot_be_read_stays_refused() { let work = home.join("work"); std::fs::create_dir_all(&work).unwrap(); let runs = home.join("hook-runs"); - let server = serve(hooks_builder(&home), config.clone()).await.unwrap(); + let server = serve(hooks_builder(), config.clone()).await.unwrap(); let mut client = Client::new_version(&server, false, 3).await; select_fixture_model(&mut client).await; @@ -3465,7 +3465,7 @@ async fn a_plugin_hooks_document_that_cannot_be_read_stays_refused() { // Startup registers every plugin in use again, so the refusal and the // plugin's other content survive a restart. - let server = serve(hooks_builder(&home), config).await.unwrap(); + let server = serve(hooks_builder(), config).await.unwrap(); let mut client = Client::new_version(&server, false, 3).await; let list = call(&mut client, "plugin.list", json!({})).await; assert_eq!(item(&list, "kit")["refused"][0]["kind"], "hooks", "{list}"); @@ -3510,7 +3510,7 @@ async fn plugin_hooks_follow_the_hooks_owner() { let runs = home.join("hook-runs"); let source = home.join("src/kit"); write_hook_plugin(&source, "kit", &runs, "kit"); - let server = serve(hooks_builder(&home), config).await.unwrap(); + let server = serve(hooks_builder(), config).await.unwrap(); let mut client = Client::new_version(&server, false, 3).await; select_fixture_model(&mut client).await; @@ -4761,7 +4761,7 @@ async fn a_failed_prompt_hook_proceeds_and_the_reply_names_it() { .to_string(), ) .unwrap(); - let server = serve(hooks_builder(&home), config).await.unwrap(); + let server = serve(hooks_builder(), config).await.unwrap(); let mut client = Client::new_version(&server, false, 3).await; select_fixture_model(&mut client).await; let cwd = home.join("work"); diff --git a/crates/dim-session-title/tests/appended_context_flow.rs b/crates/dim-session-title/tests/appended_context_flow.rs index cd3e92cbd2..4e6e2cdfa9 100644 --- a/crates/dim-session-title/tests/appended_context_flow.rs +++ b/crates/dim-session-title/tests/appended_context_flow.rs @@ -20,14 +20,14 @@ const SKILL: &str = "\nSkill: check\nDescription: D\nF /// answers as its additional context. const HOOK_CONTEXT: &str = "Read src/parser.rs before answering."; -fn builder(home: &std::path::Path) -> AgentBuilder { +fn builder() -> AgentBuilder { let mut builder = AgentBuilder::new(AgentConfig::default()); dim_session_title::install(&mut builder); defaults::install(&mut builder); defaults::mock_model_hosts(&mut builder); defaults::tool_host(&mut builder, Arc::new(MockTools)); dim_app_server::collaboration::install(&mut builder); - dim_app_server::hooks_settings::install(&mut builder, Some(home.to_owned())); + dim_app_server::hooks_settings::install(&mut builder); dim_agent_capabilities::hooks::install(&mut builder); builder } @@ -97,7 +97,7 @@ async fn start_with( .unwrap(); }); let server = serve( - builder(&store.0), + builder(), ServerConfig { unix_path: Some(PathBuf::from("/tmp").join(format!( "dim-title-appended-{}/server.sock", diff --git a/crates/dimcode/tests/cli_flow/hooks.rs b/crates/dimcode/tests/cli_flow/hooks.rs index 1e2dd37a27..d05120dfae 100644 --- a/crates/dimcode/tests/cli_flow/hooks.rs +++ b/crates/dimcode/tests/cli_flow/hooks.rs @@ -604,7 +604,7 @@ fn a_stop_hook_exports_its_session_from_dimcode_home() { let mut builder = AgentBuilder::new(AgentConfig::default()); defaults::mock_hosts(&mut builder); defaults::install(&mut builder); - dim_app_server::hooks_settings::install(&mut builder, Some(home.0.clone())); + dim_app_server::hooks_settings::install(&mut builder); dim_agent_capabilities::hooks::install(&mut builder); let server = serve( builder,