Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Darling/Darling.Tests/CollectionOutputBesideCostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,10 @@ public void BothSkusToolDescriptions_TeachThatACorrectZeroExists()
var source = ReadRepoFile(relative);

Assert.Contains("what it BOUGHT", source, StringComparison.Ordinal);
Assert.Contains("that zero was CORRECT", source, StringComparison.Ordinal);
/* #3898: the pg_deadlocks anecdote that used to carry "that zero was CORRECT" moved to the
CHANGELOG (D4); the rule it taught - a zero can be the healthy reading - stays in the tail
right after it, so the pin re-points to that rule instead of the story. */
Assert.Contains("would fire on the healthy quiet install", source, StringComparison.Ordinal);
Assert.Contains("deliberately NOT a band", source, StringComparison.Ordinal);
Assert.Contains("needs a grant", source, StringComparison.Ordinal);
}
Expand Down
6 changes: 6 additions & 0 deletions Darling/Darling.Tests/McpToolGuideHeads.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class McpToolGuideHeadsDataTests
{
private static readonly string[] ConvertedTools =
[
"get_collection_health",
"get_file_io_stats",
"get_perfmon_stats",
"get_server_properties",
Expand All @@ -33,6 +34,11 @@ public sealed class McpToolGuideHeadsDataTests
/// <summary>The per-tool guardrail phrase each head must state.</summary>
private static readonly (string Tool, string Fact)[] HeadFacts =
[
("get_collection_health", "STOPPED (gate off) does not count as failing"),
("get_collection_health", "rows_stored=0 is NOT a fault by itself"),
("get_collection_health", "last_error is a sticky slot, not necessarily current"),
("get_collection_health", "regressed_from_productive floors WARNING on an axis SEPARATE from failed_collector_count"),
("get_collection_health", "alert_read_health uses a DIFFERENT since-restart window"),
("get_file_io_stats", "LATEST IS A TIME: the newest snapshot, not a window"),
("get_perfmon_stats", "LATEST IS A TIME: the newest snapshot, not a window"),
("get_server_properties", "LATEST IS A TIME: the newest snapshot, not a window"),
Expand Down
24 changes: 13 additions & 11 deletions Darling/Darling.Tests/McpToolGuideTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
Expand All @@ -16,6 +17,7 @@
using System.Text.Json;
using System.Text.RegularExpressions;
using Microsoft.Extensions.DependencyInjection;
using ModelContextProtocol.Server;
using PerformanceMonitor.Alerting;
using PerformanceMonitor.Common;
using PerformanceMonitor.Darling.Service.Mcp;
Expand Down Expand Up @@ -171,17 +173,17 @@ public void GetToolGuide_ServesTails_AndTopics_AndReportsUnknownNames()
public void GetToolGuide_WithNoArguments_IsTheIndex()
{
/* HostCatalog wires up exactly DarlingMcpHealthParserTools, DarlingMcpDataTools and
DarlingMcpToolGuideTools, so this fixture's own guide-bearing roster is a local, self-contained fact
about THIS test's host, not a family pin (that lives in McpToolGuideHeadsHealthParserTests). */
var fixtureToolsWithGuides = new[]
{
"get_file_io_stats",
"get_health_parser_cpu_tasks", "get_health_parser_io_issues", "get_health_parser_memory_broker",
"get_health_parser_memory_conditions", "get_health_parser_memory_node_oom", "get_health_parser_scheduler_issues",
"get_health_parser_severe_errors", "get_health_parser_significant_waits", "get_health_parser_system_health",
"get_perfmon_stats", "get_server_properties", "get_top_procedures_by_cpu", "get_top_queries_by_cpu",
"get_wait_stats", "list_servers",
};
DarlingMcpToolGuideTools, so the expected roster is every tool on those
types whose Description carries the marker. It is derived, not hand-kept: a hand-kept roster made
every content PR that converts one of these tools edit the same lines (#3898). */
var fixtureToolsWithGuides = new[] { typeof(DarlingMcpHealthParserTools), typeof(DarlingMcpDataTools), typeof(DarlingMcpToolGuideTools) }
.SelectMany(type => type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
.Select(method => (Tool: method.GetCustomAttribute<McpServerToolAttribute>(), Description: method.GetCustomAttribute<DescriptionAttribute>()))
.Where(m => m.Tool?.Name is not null && m.Description?.Description.Contains(McpToolGuide.Marker, StringComparison.Ordinal) == true)
.Select(m => m.Tool!.Name!)
.OrderBy(name => name, StringComparer.Ordinal)
.ToArray();
Assert.Contains("get_health_parser_system_health", fixtureToolsWithGuides);

using var doc = JsonDocument.Parse(DarlingMcpToolGuideTools.GetToolGuide(HostCatalog(), null, null));
var withGuides = doc.RootElement.GetProperty("tools_with_guides").EnumerateArray().Select(e => e.GetString()).ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ param get_blocking_stats.as_of 167
param get_blocking_stats.hours_back 191
param get_blocking_stats.server_name 28

tool get_collection_health 21026
tool get_collection_health 583
param get_collection_health.server_name 28

tool get_collection_log 6995
Expand Down

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Lite.Tests/CollectionOutputBesideCostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ public void BothSkusToolDescriptions_TeachThatACorrectZeroExists()
var source = File.ReadAllText(Path.Combine(RepoRoot(), relative));

Assert.Contains("what it BOUGHT", source, StringComparison.Ordinal);
Assert.Contains("that zero was CORRECT", source, StringComparison.Ordinal);
/* #3898: the pg_deadlocks anecdote that used to carry "that zero was CORRECT" moved to the
CHANGELOG (D4); the rule it taught - a zero can be the healthy reading - stays in the tail
right after it, so the pin re-points to that rule instead of the story. */
Assert.Contains("would fire on the healthy quiet install", source, StringComparison.Ordinal);
Assert.Contains("deliberately NOT a band", source, StringComparison.Ordinal);
Assert.Contains("needs a grant", source, StringComparison.Ordinal);
}
Expand Down
6 changes: 6 additions & 0 deletions Lite.Tests/McpToolGuideHeads.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed class McpToolGuideHeadsDataTests
{
private static readonly string[] ConvertedTools =
[
"get_collection_health",
"get_file_io_stats",
"get_perfmon_stats",
"get_server_properties",
Expand All @@ -31,6 +32,11 @@ public sealed class McpToolGuideHeadsDataTests

private static readonly (string Tool, string Fact)[] HeadFacts =
[
("get_collection_health", "STOPPED (gate off) does not count as failing"),
("get_collection_health", "rows_stored=0 is NOT a fault by itself"),
("get_collection_health", "last_error is a sticky slot, not necessarily current"),
("get_collection_health", "regressed_from_productive floors WARNING on an axis SEPARATE from failed_collector_count"),
("get_collection_health", "alert_read_health uses a DIFFERENT since-restart window"),
("get_file_io_stats", "LATEST IS A TIME: the newest snapshot, not a window"),
("get_perfmon_stats", "LATEST IS A TIME: the newest snapshot, not a window"),
("get_server_properties", "LATEST IS A TIME: the newest snapshot, not a window"),
Expand Down
23 changes: 13 additions & 10 deletions Lite.Tests/McpToolGuideTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
*/

using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.RegularExpressions;
using Microsoft.Extensions.DependencyInjection;
using ModelContextProtocol.Server;
using PerformanceMonitor.Common;
using PerformanceMonitorLite.Mcp;
using Xunit;
Expand Down Expand Up @@ -106,16 +108,17 @@ public void GetToolGuide_ServesTails_AndTopics_AndReportsUnknownNames()
[Fact]
public void GetToolGuide_WithNoArguments_IsTheIndex()
{
/* HostCatalog wires up exactly McpHealthParserTools, McpDiscoveryTools and McpToolGuideTools, so this
fixture's own guide-bearing roster is a local, self-contained fact about THIS test's host, not a
family pin (that lives in McpToolGuideHeadsHealthParserTests). */
var fixtureToolsWithGuides = new[]
{
"get_health_parser_cpu_tasks", "get_health_parser_io_issues", "get_health_parser_memory_broker",
"get_health_parser_memory_conditions", "get_health_parser_memory_node_oom", "get_health_parser_scheduler_issues",
"get_health_parser_severe_errors", "get_health_parser_significant_waits", "get_health_parser_system_health",
"list_servers",
};
/* HostCatalog wires up exactly McpHealthParserTools, McpDiscoveryTools and McpToolGuideTools, so the expected roster is every tool on those
types whose Description carries the marker. It is derived, not hand-kept: a hand-kept roster made
every content PR that converts one of these tools edit the same lines (#3898). */
var fixtureToolsWithGuides = new[] { typeof(McpHealthParserTools), typeof(McpDiscoveryTools), typeof(McpToolGuideTools) }
.SelectMany(type => type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
.Select(method => (Tool: method.GetCustomAttribute<McpServerToolAttribute>(), Description: method.GetCustomAttribute<DescriptionAttribute>()))
.Where(m => m.Tool?.Name is not null && m.Description?.Description.Contains(McpToolGuide.Marker, StringComparison.Ordinal) == true)
.Select(m => m.Tool!.Name!)
.OrderBy(name => name, StringComparer.Ordinal)
.ToArray();
Assert.Contains("get_health_parser_system_health", fixtureToolsWithGuides);

using var doc = JsonDocument.Parse(McpToolGuideTools.GetToolGuide(HostCatalog(), null, null));
var withGuides = doc.RootElement.GetProperty("tools_with_guides").EnumerateArray().Select(e => e.GetString()).ToArray();
Expand Down
2 changes: 1 addition & 1 deletion Lite.Tests/McpToolsListBudget/McpHealthTools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ param get_blocking_stats.as_of 167
param get_blocking_stats.hours_back 191
param get_blocking_stats.server_name 28

tool get_collection_health 21026
tool get_collection_health 583
param get_collection_health.server_name 28

tool get_collection_log 4405
Expand Down
2 changes: 1 addition & 1 deletion Lite/Mcp/McpHealthTools.cs

Large diffs are not rendered by default.

Loading