Skip to main content

ComposeReport

Struct ComposeReport 

Source
pub struct ComposeReport {
Show 16 fields pub schema_version: String, pub server_count: usize, pub total_tools: usize, pub total_estimated_tokens: usize, pub total_200_turn_uncached_usd: f32, pub total_200_turn_cached_usd: f32, pub combined_score: f32, pub combined_tier: Tier, pub cross_server_exact_duplicates: usize, pub cross_server_semantic_collisions: usize, pub score_if_namespaced: f32, pub exact_duplicates_if_namespaced: usize, pub servers: Vec<ServerTokenShare>, pub cross_server_collisions: Vec<CrossServerCollision>, pub deferral_recommendations: Vec<DeferralRecommendation>, pub combined_audit: AuditReport,
}
Expand description

Complete multi-server composition and federation audit report returned by compose_catalogs.

Fields§

§schema_version: String

Schema version.

§server_count: usize

Number of composed MCP servers.

§total_tools: usize

Total tools loaded simultaneously into the agent context.

§total_estimated_tokens: usize

Total estimated serialized prompt tokens across all servers.

§total_200_turn_uncached_usd: f32

Estimated 200-turn uncached USD cost across all servers.

§total_200_turn_cached_usd: f32

Estimated 200-turn cached USD cost across all servers.

§combined_score: f32

Overall quality score of the combined multi-server catalog (1.0–5.0).

§combined_tier: Tier

Overall letter tier of the combined catalog.

§cross_server_exact_duplicates: usize

Count of exact duplicate tool names across distinct servers.

§cross_server_semantic_collisions: usize

Count of non-exact high-similarity collisions across distinct servers.

§score_if_namespaced: f32

Simulated overall score if each server’s tools are prefixed with <server>_.

§exact_duplicates_if_namespaced: usize

Simulated exact duplicate count after <server>_ namespace prefixing (always 0 for distinct server names).

§servers: Vec<ServerTokenShare>

Per-server token/cost/quality breakdown sorted descending by estimated_tokens.

§cross_server_collisions: Vec<CrossServerCollision>

Cross-server collisions sorted exact duplicates first, then descending similarity.

§deferral_recommendations: Vec<DeferralRecommendation>

Context-budget deferral recommendations when combined tokens exceed config.max_catalog_tokens.

§combined_audit: AuditReport

Full combined AuditReport across the merged catalog.

Implementations§

Source§

impl ComposeReport

Source

pub fn to_json_pretty(&self) -> Result<String>

Serializes this composition report as pretty-printed JSON.

Source

pub fn to_json_compact(&self) -> Result<String>

Serializes this composition report as minified single-line JSON for AI agents.

Source

pub fn to_text(&self) -> String

Formats a concise terminal summary of multi-server token cost and cross-server collisions.

Examples found in repository?
examples/multi_server_compose.rs (line 80)
6fn main() {
7    let github = Catalog::from_mcp_json(
8        r#"{
9          "tools": [
10            {
11              "name": "create_issue",
12              "description": "Creates a new GitHub issue in a repository and returns its issue URL.",
13              "inputSchema": {
14                "type": "object",
15                "properties": {
16                  "owner": { "type": "string", "description": "Repository owner." },
17                  "repo": { "type": "string", "description": "Repository name." },
18                  "title": { "type": "string", "description": "Issue title." }
19                },
20                "required": ["owner", "repo", "title"]
21              }
22            },
23            {
24              "name": "search_repositories",
25              "description": "Searches GitHub repositories by keyword and returns a paginated list.",
26              "inputSchema": {
27                "type": "object",
28                "properties": {
29                  "query": { "type": "string", "description": "GitHub search query." },
30                  "perPage": { "type": "integer", "description": "Results per page." }
31                },
32                "required": ["query"]
33              }
34            }
35          ]
36        }"#,
37    )
38    .expect("valid github catalog");
39
40    let gitlab = Catalog::from_mcp_json(
41        r#"{
42          "tools": [
43            {
44              "name": "create_issue",
45              "description": "Creates a new GitLab issue in a project and returns its issue IID.",
46              "inputSchema": {
47                "type": "object",
48                "properties": {
49                  "project_id": { "type": "string", "description": "Project ID or URL-encoded path." },
50                  "title": { "type": "string", "description": "Issue title." }
51                },
52                "required": ["project_id", "title"]
53              }
54            },
55            {
56              "name": "list_merge_requests",
57              "description": "Lists open GitLab merge requests for a project with pagination.",
58              "inputSchema": {
59                "type": "object",
60                "properties": {
61                  "project_id": { "type": "string", "description": "Project ID." },
62                  "limit": { "type": "integer", "description": "Max rows returned." }
63                },
64                "required": ["project_id"]
65              }
66            }
67          ]
68        }"#,
69    )
70    .expect("valid gitlab catalog");
71
72    // 1) Multi-server composition & namespace simulation
73    let composed = compose_catalogs(
74        &[
75            ("github".into(), github.clone()),
76            ("gitlab".into(), gitlab.clone()),
77        ],
78        &AuditConfig::default(),
79    );
80    println!("{}", composed.to_text());
81
82    // 2) Pre-indexed Bm25Index on the namespaced catalog + explainability
83    let mut combined = github.with_namespace_prefix("github").tools().to_vec();
84    combined.extend(
85        gitlab
86            .with_namespace_prefix("gitlab")
87            .tools()
88            .iter()
89            .cloned(),
90    );
91    let namespaced = Catalog::new(combined);
92
93    let index = Bm25Index::build(&namespaced);
94    let hits = index.search("open gitlab merge requests", 2);
95    println!(
96        "Top Bm25Index hit: {} ({:.3})",
97        hits[0].tool_name, hits[0].score
98    );
99
100    let explanation = explain_query(
101        &namespaced,
102        "open gitlab merge requests",
103        Bm25Ranker::default(),
104        2,
105    );
106    println!("{}", explanation.to_text());
107
108    // 3) Side-by-side ranker comparison on an auto-generated adversarial suite
109    let suite = EvalSuite::generate_adversarial(&namespaced);
110    let tfidf = TfIdfRanker::default();
111    let hybrid = HybridRanker::default();
112    let cmp = compare_rankers(
113        &suite,
114        &namespaced,
115        &[("bm25", &index), ("tfidf", &tfidf), ("hybrid", &hybrid)],
116        3,
117    );
118    println!("{}", cmp.to_text());
119}
Source

pub fn to_markdown(&self) -> String

Formats a GitHub-Flavored Markdown report suitable for PR comments and architecture reviews.

Trait Implementations§

Source§

impl Clone for ComposeReport

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ComposeReport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ComposeReport

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ComposeReport

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ComposeReport

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ComposeReport

Auto Trait Implementations§

§

impl Forget for ComposeReport

§

impl Freeze for ComposeReport

§

impl Move for ComposeReport

§

impl RefUnwindSafe for ComposeReport

§

impl Send for ComposeReport
where RawVecInner: Send, NodeRef<Owned, Dimension, f32, LeafOrInternal>: Send, BoxRaw<(Dimension, f32)>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send,

§

impl Sync for ComposeReport
where RawVecInner: Sync, NodeRef<Owned, Dimension, f32, LeafOrInternal>: Sync, BoxRaw<(Dimension, f32)>: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync,

§

impl Unpin for ComposeReport
where *const u8 is !null: Unpin, *const LeafNode<Dimension, f32> is !null: Unpin, Box<(Dimension, f32)>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin,

§

impl UnsafeUnpin for ComposeReport

§

impl UnwindSafe for ComposeReport

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.