Skip to content

Commit 0c05a32

Browse files
committed
Checkpoint current Aspire options and SQL changes
Save all remaining current working-tree changes on main at the owner request. Parallel implementation remains in progress. This is an unqualified source checkpoint; required build, functional coverage and complete test gates remain open.
1 parent 35aa86c commit 0c05a32

57 files changed

Lines changed: 653 additions & 398 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎benchmarks/KeyLoad.Comparisons/Features/BenchmarkComparisons/Configuration/OpenLoopExecutionOptions.cs‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using KeyLoad;
2-
using Microsoft.Extensions.Options;
32

43
namespace KeyLoad.Comparisons;
54

@@ -44,26 +43,3 @@ internal static OpenLoopExecutionPolicy Snapshot(OpenLoopExecutionOptions option
4443
options.ControlPollMilliseconds, options.SpinWindowMicroseconds);
4544
}
4645
}
47-
48-
/// <summary>Rejects any options that differ from the qualified open-loop execution policy.</summary>
49-
public sealed class OpenLoopExecutionOptionsValidator : IValidateOptions<OpenLoopExecutionOptions>
50-
{
51-
private const string ValidationFailureMessage = "Open-loop execution policy must match the qualified v1 cohort.";
52-
53-
/// <inheritdoc />
54-
public ValidateOptionsResult Validate(string? name, OpenLoopExecutionOptions options)
55-
{
56-
ArgumentNullException.ThrowIfNull(options);
57-
return IsExact(options) ? ValidateOptionsResult.Success
58-
: ValidateOptionsResult.Fail(ValidationFailureMessage);
59-
}
60-
61-
private static bool IsExact(OpenLoopExecutionOptions options)
62-
=> options.QueueCapacity == OpenLoopExecutionOptions.DefaultQueueCapacity
63-
&& options.ConcurrentSessions == OpenLoopExecutionOptions.DefaultConcurrentSessions
64-
&& options.MaximumNodes == OpenLoopExecutionOptions.DefaultMaximumNodes
65-
&& options.OperationDeadlineMilliseconds == OpenLoopExecutionOptions.DefaultOperationDeadlineMilliseconds
66-
&& options.DrainMilliseconds == OpenLoopExecutionOptions.DefaultDrainMilliseconds
67-
&& options.ControlPollMilliseconds == OpenLoopExecutionOptions.DefaultControlPollMilliseconds
68-
&& options.SpinWindowMicroseconds == OpenLoopExecutionOptions.DefaultSpinWindowMicroseconds;
69-
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Extensions.Options;
2+
3+
namespace KeyLoad.Comparisons;
4+
5+
/// <summary>Rejects any options that differ from the qualified open-loop execution policy.</summary>
6+
public sealed class OpenLoopExecutionOptionsValidator : IValidateOptions<OpenLoopExecutionOptions>
7+
{
8+
private const string ValidationFailureMessage = "Open-loop execution policy must match the qualified v1 cohort.";
9+
10+
/// <inheritdoc />
11+
public ValidateOptionsResult Validate(string? name, OpenLoopExecutionOptions options)
12+
{
13+
ArgumentNullException.ThrowIfNull(options);
14+
return IsExact(options) ? ValidateOptionsResult.Success
15+
: ValidateOptionsResult.Fail(ValidationFailureMessage);
16+
}
17+
18+
private static bool IsExact(OpenLoopExecutionOptions options)
19+
=> options.QueueCapacity == OpenLoopExecutionOptions.DefaultQueueCapacity
20+
&& options.ConcurrentSessions == OpenLoopExecutionOptions.DefaultConcurrentSessions
21+
&& options.MaximumNodes == OpenLoopExecutionOptions.DefaultMaximumNodes
22+
&& options.OperationDeadlineMilliseconds == OpenLoopExecutionOptions.DefaultOperationDeadlineMilliseconds
23+
&& options.DrainMilliseconds == OpenLoopExecutionOptions.DefaultDrainMilliseconds
24+
&& options.ControlPollMilliseconds == OpenLoopExecutionOptions.DefaultControlPollMilliseconds
25+
&& options.SpinWindowMicroseconds == OpenLoopExecutionOptions.DefaultSpinWindowMicroseconds;
26+
}

‎benchmarks/KeyLoad.Comparisons/Features/BenchmarkComparisons/Contracts/OpenLoopCancellationProofV1.cs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ public sealed record OpenLoopNativeCompletionV1(string ProfileId, Scenario Scena
3939
/// <summary>Names and bounds the separate child-process cancellation proof artifacts.</summary>
4040
public static class OpenLoopCancellationProofContract
4141
{
42+
/// <summary>Gets the fixed cancellation proof schema version.</summary>
43+
public const int SchemaVersion = 1;
44+
/// <summary>Gets the fixed pending proof path name beneath the owned output directory.</summary>
45+
public const string PendingProofFileName = ".open-loop-cancellation-proof.v1.json.pending";
46+
/// <summary>Gets the fixed marker field separator.</summary>
47+
public const char MarkerFieldSeparator = '|';
48+
/// <summary>Gets the exact request bytes.</summary>
49+
public const int RequestBytes = 10;
50+
/// <summary>Gets the bounded request read buffer size, including one excess byte.</summary>
51+
public const int RequestReadBufferBytes = 11;
52+
/// <summary>Gets the exact number of fields in the marker.</summary>
53+
public const int CompletionMarkerFieldCount = 7;
54+
/// <summary>Gets the largest ASCII code point admitted by the marker format.</summary>
55+
public const int MaximumMarkerAsciiCodePoint = 0x7F;
4256
/// <summary>Gets the fixed request path name beneath the owned output directory.</summary>
4357
public const string RequestFileName = "open-loop-cancel.v1.request";
4458
/// <summary>Gets the fixed pending request path name beneath the owned output directory.</summary>
@@ -49,6 +63,8 @@ public static class OpenLoopCancellationProofContract
4963
public const string CompletionMarkerPrefix = "OpenLoopNativeCompletionV1";
5064
/// <summary>Gets the fixed request token bytes.</summary>
5165
public const string RequestText = "cancel-v1\n";
66+
/// <summary>Gets the asynchronous JSON writer buffer size in bytes.</summary>
67+
public const int JsonWriterBufferBytes = 8_192;
5268
/// <summary>Gets the maximum proof artifact size in bytes.</summary>
5369
public const int MaximumProofBytes = 4 * 1024 * 1024;
5470
/// <summary>Gets the maximum child marker length in ASCII bytes.</summary>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace KeyLoad.Comparisons;
2+
3+
/// <summary>Owns immutable identities and bounds for the separate open-loop evidence format.</summary>
4+
internal static class OpenLoopEvidenceContract
5+
{
6+
internal const int SchemaVersion = 1;
7+
internal const int MaximumArtifactBytes = 4 * 1024 * 1024;
8+
internal const int JsonWriterBufferBytes = 16_384;
9+
internal const int Sha256HexCharacters = 64;
10+
internal const int GitRevisionHexCharacters = 40;
11+
internal const int MaximumWorkerTargetCharacters = 256;
12+
internal const int MaximumProfileIdCharacters = 64;
13+
internal const int MaximumWorkerSourceRevisionCharacters = 64;
14+
internal const int MaximumRepositoryCharacters = 512;
15+
internal const int MaximumRefCharacters = 512;
16+
internal const int MaximumWorkflowCharacters = 256;
17+
internal const int MaximumStorageDescriptionCharacters = 512;
18+
internal const int MaximumRuntimeDescriptionCharacters = 256;
19+
internal const int MaximumTargetFieldCharacters = 2_048;
20+
internal const int MaximumTargetMetadataBytes = 8_192;
21+
internal const int MaximumClusterObservations = 64;
22+
internal const int MaximumObservationCharacters = 1_024;
23+
internal const int MaximumObservationBytes = 8_192;
24+
25+
internal const string OpenLoopEvidenceFileName = "open-loop-evidence.v1.json";
26+
internal const string PendingOpenLoopEvidenceFileName = ".open-loop-evidence.v1.json.pending";
27+
internal const string ProgressMessageFormat = "open-loop {0} {1}/s: {2}/{3} succeeded";
28+
}

‎benchmarks/KeyLoad.Comparisons/Features/BenchmarkComparisons/Contracts/OpenLoopExecutionPolicy.cs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ public sealed record OpenLoopExecutionPolicy(int QueueCapacity, int ConcurrentSe
77
int OperationDeadlineMilliseconds, int DrainMilliseconds, int ControlPollMilliseconds,
88
int SpinWindowMicroseconds)
99
{
10+
private const int MillisecondsPerSecond = 1_000;
11+
private const int MicrosecondsPerSecond = 1_000_000;
12+
private const int CeilingRoundingAdjustment = 1;
13+
1014
/// <summary>Checks that evidence carries the single currently qualified v1 policy.</summary>
1115
/// <returns>Whether all seven values match the canonical options definition.</returns>
1216
internal bool IsQualifiedV1()
@@ -19,17 +23,17 @@ internal bool IsQualifiedV1()
1923
&& SpinWindowMicroseconds == OpenLoopExecutionOptions.DefaultSpinWindowMicroseconds;
2024

2125
internal long OperationDeadlineTicks
22-
=> ToStopwatchTicks(OperationDeadlineMilliseconds, 1_000);
26+
=> ToStopwatchTicks(OperationDeadlineMilliseconds, MillisecondsPerSecond);
2327

2428
internal long DrainTicks
25-
=> ToStopwatchTicks(DrainMilliseconds, 1_000);
29+
=> ToStopwatchTicks(DrainMilliseconds, MillisecondsPerSecond);
2630

2731
internal long SpinWindowTicks
28-
=> ToStopwatchTicks(SpinWindowMicroseconds, 1_000_000);
32+
=> ToStopwatchTicks(SpinWindowMicroseconds, MicrosecondsPerSecond);
2933

3034
private static long ToStopwatchTicks(int amount, int unitsPerSecond)
3135
{
3236
var numerator = checked((long)amount * Stopwatch.Frequency);
33-
return checked((numerator + unitsPerSecond - 1) / unitsPerSecond);
37+
return checked((numerator + unitsPerSecond - CeilingRoundingAdjustment) / unitsPerSecond);
3438
}
3539
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace KeyLoad.Comparisons;
2+
3+
internal static class OpenLoopFailureMessages
4+
{
5+
internal const string CellOutsideFrozenProfile = "The open-loop cell is outside its frozen profile.";
6+
internal const string CancellationProofCellUnsupported = "The cancellation proof cell is unsupported.";
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace KeyLoad.Comparisons;
2+
3+
internal static class ScaledCorpusReadbackFailureCodes
4+
{
5+
internal const string Operation = "ScaledCorpusReadback";
6+
internal const string ExtraRecord = "ScaledCorpusReadbackExtraRecord";
7+
internal const string CursorDidNotAdvance = "ScaledCorpusReadbackCursorDidNotAdvance";
8+
internal const string CountMismatch = "ScaledCorpusReadbackCountMismatch";
9+
}

‎benchmarks/KeyLoad.Comparisons/Features/BenchmarkComparisons/Execution/ComparisonSessionCleanup.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace KeyLoad.Comparisons;
77
internal static class ComparisonSessionCleanup
88
{
99
internal const string Failure = "ComparisonSessionCleanupFailed";
10+
private const int MinimumTimeoutSeconds = 1;
1011

1112
internal static async Task<bool> CloseAsync(IEnumerable<IComparisonSession> sessions, int timeoutSeconds)
1213
{
@@ -19,7 +20,7 @@ internal static Task<ComparisonSessionCloseResult> CloseAndJoinAsync(
1920
IEnumerable<IComparisonSession> sessions, int timeoutSeconds)
2021
{
2122
ArgumentNullException.ThrowIfNull(sessions);
22-
ArgumentOutOfRangeException.ThrowIfLessThan(timeoutSeconds, 1);
23+
ArgumentOutOfRangeException.ThrowIfLessThan(timeoutSeconds, MinimumTimeoutSeconds);
2324
return CloseAndJoinAsync(sessions, TimeSpan.FromSeconds(timeoutSeconds));
2425
}
2526

‎benchmarks/KeyLoad.Comparisons/Features/BenchmarkComparisons/Execution/OpenLoopCancellationProofRunner.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private static void ValidateArguments(ScaledComparisonProfile profile, int rate,
9999
|| !OpenLoopRateContract.AcceptedRates.Contains(rate) || target.Profile.Name != OpenLoopProtocolIdentities.KeyLoadTarget
100100
|| !target.Supports(Scenario.PointRead))
101101
{
102-
throw new ArgumentOutOfRangeException(nameof(worker), "The cancellation proof cell is unsupported.");
102+
throw new ArgumentOutOfRangeException(nameof(worker), OpenLoopFailureMessages.CancellationProofCellUnsupported);
103103
}
104104
}
105105

@@ -136,7 +136,7 @@ private static async Task<OpenLoopWatcherSettlement> StopAndJoinWatcherAsync(
136136

137137
private static OpenLoopCancellationProofV1 CreateProof(OpenLoopComparisonReport report,
138138
OpenLoopProgressV1 milestone, OpenLoopHealthyReadResult health)
139-
=> new(1, report.Worker!, report.ProfileId, report.OfferedRatePerSecond, report.Scenario,
139+
=> new(OpenLoopCancellationProofContract.SchemaVersion, report.Worker!, report.ProfileId, report.OfferedRatePerSecond, report.Scenario,
140140
report.DatasetRecords, report.DatasetSha256, milestone, report.Accounting, report.ExecutionPolicy,
141141
report.CallerCancelled,
142142
true, true, report.SessionsClosed, true, health.Revision, health.JsonSha256, health.SessionClosed);

‎benchmarks/KeyLoad.Comparisons/Features/BenchmarkComparisons/Execution/OpenLoopCancellationRequestWatcher.cs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ namespace KeyLoad.Comparisons;
44

55
internal static class OpenLoopCancellationRequestWatcher
66
{
7-
private const int RequestBytes = 10;
8-
private const int ReadLimit = 11;
97

108
internal static void ValidateFresh(string output)
119
{
@@ -71,13 +69,13 @@ private static void ValidateRequestAttributes(string path, FileAttributes attrib
7169
private static async Task ValidateRequestAsync(string path, CancellationToken cancellationToken)
7270
{
7371
var info = new FileInfo(path);
74-
if (info.Length != RequestBytes)
72+
if (info.Length != OpenLoopCancellationProofContract.RequestBytes)
7573
{
7674
throw new ComparisonFailureException(OpenLoopFailureCodes.OpenLoopCancellationControlInvalid);
7775
}
78-
var bytes = new byte[ReadLimit];
76+
var bytes = new byte[OpenLoopCancellationProofContract.RequestReadBufferBytes];
7977
await using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read,
80-
ReadLimit, FileOptions.Asynchronous | FileOptions.SequentialScan);
78+
OpenLoopCancellationProofContract.RequestReadBufferBytes, FileOptions.Asynchronous | FileOptions.SequentialScan);
8179
var read = 0;
8280
while (read < bytes.Length)
8381
{
@@ -86,7 +84,7 @@ private static async Task ValidateRequestAsync(string path, CancellationToken ca
8684
read += count;
8785
}
8886
var expected = Encoding.UTF8.GetBytes(OpenLoopCancellationProofContract.RequestText);
89-
if (read != RequestBytes || !bytes.AsSpan(0, RequestBytes).SequenceEqual(expected))
87+
if (read != OpenLoopCancellationProofContract.RequestBytes || !bytes.AsSpan(0, OpenLoopCancellationProofContract.RequestBytes).SequenceEqual(expected))
9088
{
9189
throw new ComparisonFailureException(OpenLoopFailureCodes.OpenLoopCancellationControlInvalid);
9290
}

0 commit comments

Comments
 (0)