Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Verified snapshots must have stable line endings across OSes
**/.snapshots/** text eol=lf
# GitHub collapses generated files in a pull request diff; the verified snapshots are written by the tests, not by hand
**/.snapshots/** linguist-generated=true

# Raw-string fixtures in test code take the file's line endings, so a Windows checkout must not turn them into CRLF
*.cs text eol=lf
33 changes: 17 additions & 16 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<PackageVersion Include="Amazon.Lambda.S3Events" Version="4.0.0" />
<PackageVersion Include="Amazon.Lambda.Serialization.SystemTextJson" Version="3.0.1" />
<PackageVersion Include="Amazon.Lambda.SQSEvents" Version="3.0.1" />
<PackageVersion Include="AngleSharp" Version="1.10.5" />
<PackageVersion Include="AngleSharp" Version="1.11.0" />
<PackageVersion Include="HtmlSanitizer" Version="11.0.26" />
<PackageVersion Include="AWSSDK.CloudFront" Version="4.1.0.2" />
<PackageVersion Include="Elastic.Transport" Version="1.1.0" />
Expand Down Expand Up @@ -97,7 +97,7 @@
<PackageVersion Include="Sep" Version="0.18.0" />
<PackageVersion Include="Spectre.Console" Version="0.57.2" />
<PackageVersion Include="SoftCircuits.IniFileParser" Version="3.1.2" />
<PackageVersion Include="System.IO.Abstractions" Version="23.0.1" />
<PackageVersion Include="System.IO.Abstractions" Version="23.1.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="11.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="11.0.0" />
<PackageVersion Include="SharpYaml" Version="3.18.0" />
Expand Down Expand Up @@ -125,19 +125,20 @@
</ItemGroup>
<!-- Test packages -->
<ItemGroup>
<PackageVersion Include="Nullean.Snapshots" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.AwesomeAssertions" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Html" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Http" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Http.Assertions" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Json" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Objects" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Yaml" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.TUnit" Version="0.18.0" />
<PackageVersion Include="Nullean.HttpFileParser" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Browser" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Browser.Console" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots.Browser.Assertions" Version="0.18.0" />
<PackageVersion Include="Nullean.Snapshots" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.AwesomeAssertions" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Html" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Http" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Http.Assertions" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Json" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Objects" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Yaml" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Relevance" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.TUnit" Version="0.24.1" />
<PackageVersion Include="Nullean.HttpFileParser" Version="0.21.0" />
<PackageVersion Include="Nullean.Snapshots.Browser" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Browser.Console" Version="0.24.1" />
<PackageVersion Include="Nullean.Snapshots.Browser.Assertions" Version="0.24.1" />
<PackageVersion Include="Nullean.Cdp" Version="0.13.0" />
<PackageVersion Include="Nullean.Cdp.Journeys" Version="0.13.0" />
<PackageVersion Include="AutoBogus" Version="2.13.1" />
Expand All @@ -151,7 +152,7 @@
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="11.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.21.0" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="23.0.1" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="23.1.0" />
<PackageVersion Include="Testcontainers.Elasticsearch" Version="4.16.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"rollForward": false
},
"nullean.snapshots.cli": {
"version": "0.18.0",
"version": "0.24.1",
"commands": [
"snap"
],
Expand Down
1 change: 1 addition & 0 deletions tests-integration/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageReference Include="Nullean.Snapshots.Html" />
<PackageReference Include="Nullean.Snapshots.Json" />
<PackageReference Include="Nullean.Snapshots.Yaml" />
<PackageReference Include="Nullean.Snapshots.Relevance" />
<Compile Include="$(MSBuildThisFileDirectory)..\tests-shared\Elastic.Documentation.Testing\Linked\*.cs" Link="Linked\%(Filename)%(Extension)" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\tests-shared\Elastic.Documentation.Testing\Elastic.Documentation.Testing.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\Search.IntegrationTests\RelevanceSet.cs" Link="RelevanceSet.cs" />
<None Include="..\Search.IntegrationTests\RelevanceSets\agent-style-queries.json" Link="RelevanceSets\agent-style-queries.json" CopyToOutputDirectory="PreserveNewest" />
<Compile Include="..\Search.IntegrationTests\RelevanceSearch.cs" Link="RelevanceSearch.cs" />
<None Include="..\Search.IntegrationTests\relevance\agent-style-queries.judgements.yaml" Link="relevance\agent-style-queries.judgements.yaml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using AwesomeAssertions;
using Elastic.Documentation.Mcp.Remote.Responses;
using Nullean.Snapshots.Relevance;
using Search.IntegrationTests;

namespace Mcp.Remote.IntegrationTests;
Expand All @@ -18,29 +19,27 @@ public class SearchToolsIntegrationTests : McpToolsIntegrationTestsBase
[Test]
public async Task SemanticSearch_AgentStyleQueries_MeetTheFloor()
{
var set = RelevanceSet.Load("agent-style-queries");
var (searchTools, clientAccessor) = CreateSearchTools();
var ct = TestContext.Current!.Execution.CancellationToken;
Skip.Unless(searchTools is not null, "Elasticsearch is not configured");
Skip.Unless(await clientAccessor!.CanConnect(ct), "Elasticsearch is not connected");

var pagesInIndex = await RelevanceSet.PagesInIndexAsync(clientAccessor, set.AllUrls, ct);
var score = await set.MeasureAsync(
pagesInIndex,
async (query, token) =>
{
var json = await searchTools.SemanticSearch(query, pageSize: 10, cancellationToken: token);
var response = JsonSerializer.Deserialize(json, McpJsonContext.Default.SemanticSearchResponse);
return response!.Results.Select(r => r.Url).ToList();
},
ct
var target = RelevanceSearch.Target("mcp", async (query, token) =>
{
var json = await searchTools.SemanticSearch(query, pageSize: 10, cancellationToken: token);
var response = JsonSerializer.Deserialize(json, McpJsonContext.Default.SemanticSearchResponse);
return response!.Results.Select(r => r.Url).ToList();
});
// The set is linked from the search tests and copied beside this assembly, so there is no snapshot of the ranks here: the gates hold the line.
var setFile = Path.Combine(AppContext.BaseDirectory, "relevance", "agent-style-queries.judgements.yaml");
var report = await RelevanceSearch.RunAsync(setFile, clientAccessor, target, ct);

TestContext.Current?.Output.WriteLine(report.Text);
Skip.Unless(
RelevanceSearch.HoldsEnoughPages(report),
$"The index holds too few of this set's pages: {RelevanceSearch.Measured(report)} of {report.Results.Queries} queries point at a page in it"
);

var floor = set.Floors["full"];
var message = $"agent-style-queries through search_docs: {score.Describe(floor)}";
TestContext.Current?.Output.WriteLine(message);
Skip.Unless(score.Measured >= Math.Max(20, set.Queries.Count / 4), $"The index holds too few of this set's pages: {message}");
score.Meets(floor).Should().BeTrue($"{message}\n{score.Misses}");
report.Should().PassItsGates();
}

[Test]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading