Judge the variant in use and count the shadow cases for what they are

The quarterly review judged the best variant of the grid instead of the one
that trades: the plan now fixes the variant in use and the protocol measures
that one, while the tries are still those of the grid. A failure while the
history is prepared is a reason in the report and no longer stops the review,
and a strategy whose protocol does not exist says so when its data are there.

The volatility improvement compared books of different days and stages: the
book keeps its stage and its previous day, and a case without a book valid on
its day is left out. Fewer than six months give no interval, the others use
the clustered error with the Student t.

The restriction balance counts a case in the period in which its outcome
became known, so no case is lost or counted twice between two reviews.

The contact given to the SEC travels only on the client that never follows a
redirect, so it cannot reach another site.

refs #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 22:26:06 +01:00
1 parent 24e20584d4
commit 3543f29aba
23 files changed
+577 -126

No files matched your search

+28 -12
View File
@@ -271,19 +271,9 @@ public sealed partial class SecurityTests
[TestCategory(Category.Integration)]
public async Task AKeyNeverFollowsARedirect()
{
var builder = WebApplication.CreateSlimBuilder();
builder.WebHost.UseUrls("http://127.0.0.1:0");
await using var other = builder.Build();
var reached = 0;
other.MapFallback(() => Interlocked.Increment(ref reached));
await other.StartAsync();
var target = other.Urls.Single();
builder = WebApplication.CreateSlimBuilder();
builder.WebHost.UseUrls("http://127.0.0.1:0");
await using var broker = builder.Build();
broker.MapFallback((HttpContext c) => Results.Redirect(target + c.Request.Path, permanent: false, preserveMethod: true));
await broker.StartAsync();
await using var other = await FallbackAsync(_ => Results.Ok(Interlocked.Increment(ref reached)));
await using var broker = await FallbackAsync(c => Results.Redirect(other.Urls.Single() + c.Request.Path, permanent: false, preserveMethod: true));
var address = new Uri(broker.Urls.Single());
using var http = Outgoing.KeyedClient();
@@ -298,6 +288,32 @@ public sealed partial class SecurityTests
Assert.AreEqual(0, reached, "The other host must never be reached.");
}
private static async Task<WebApplication> FallbackAsync(Func<HttpContext, IResult> answer)
{
var builder = WebApplication.CreateSlimBuilder();
builder.WebHost.UseUrls("http://127.0.0.1:0");
var app = builder.Build();
app.MapFallback(answer);
await app.StartAsync();
return app;
}
/// <summary>The contact for the SEC is the user's own e-mail (ADR 0020): another host must never see it, on the client the service really uses.</summary>
[TestMethod]
[TestCategory(Category.Integration)]
public async Task TheContactOfTheSecNeverFollowsARedirect()
{
var reached = 0;
await using var other = await FallbackAsync(_ => Results.Ok(Interlocked.Increment(ref reached)));
await using var sec = await FallbackAsync(c => Results.Redirect(other.Urls.Single() + c.Request.Path));
await using var test = await DatabaseTests.MigratedAsync();
var bus = new EventBus();
using var market = new MarketDataService(test.Db, SystemClock.Instance, bus, new SettingsStore(test.Db, SystemClock.Instance, bus), new SecretStore(test.Db, SystemClock.Instance, new byte[32]), null);
var agent = new Dictionary<string, string> { ["User-Agent"] = Edgar.UserAgent("prova@esempio.it")! };
await Assert.ThrowsAsync<MarketDataException>(() => market.Sec.GetBytesAsync(new Uri(sec.Urls.Single() + "/files/company_tickers"), null, agent, CancellationToken.None));
Assert.AreEqual(0, reached);
}
[TestMethod]
[TestCategory(Category.Unit)]
[DataRow("POST", "/api/v5/asset/with" + "drawal")]