search and ai stabilization work, localization stablized.

This commit is contained in:
master
2026-02-24 23:29:36 +02:00
parent 4f947a8b61
commit b07d27772e
766 changed files with 55299 additions and 3221 deletions

View File

@@ -6,6 +6,7 @@ using StellaOps.Timeline.Core.Export;
using StellaOps.HybridLogicalClock;
using StellaOps.Timeline.WebService.Security;
using StellaOps.Auth.ServerIntegration.Tenancy;
using static StellaOps.Localization.T;
namespace StellaOps.Timeline.WebService.Endpoints;
@@ -46,12 +47,12 @@ public static class ExportEndpoints
{
if (string.IsNullOrWhiteSpace(correlationId))
{
return TypedResults.BadRequest("Correlation ID is required");
return TypedResults.BadRequest(_t("timeline.validation.correlation_id_required"));
}
if (!IsSupportedFormat(request.Format))
{
return TypedResults.BadRequest("Format must be either 'ndjson' or 'json'.");
return TypedResults.BadRequest(_t("timeline.validation.format_invalid"));
}
if (!TryParseHlc(request.FromHlc, "fromHlc", out var fromHlc, out var fromParseError))
@@ -68,7 +69,7 @@ public static class ExportEndpoints
var result = await queryService.GetByCorrelationIdAsync(correlationId, new TimelineQueryOptions { Limit = 1 }, cancellationToken);
if (result.Events.Count == 0)
{
return TypedResults.BadRequest($"No events found for correlation ID: {correlationId}");
return TypedResults.BadRequest(_t("timeline.error.no_events_for_correlation", correlationId));
}
var operation = await bundleBuilder.InitiateExportAsync(
@@ -161,7 +162,7 @@ public static class ExportEndpoints
return true;
}
error = $"Invalid {parameterName} value '{rawValue}'. Expected format '{{physicalTime13}}-{{nodeId}}-{{counter6}}'.";
error = _t("timeline.error.hlc_invalid_format", parameterName, rawValue);
return false;
}

View File

@@ -5,6 +5,7 @@ using StellaOps.HybridLogicalClock;
using StellaOps.Timeline.Core.Replay;
using StellaOps.Timeline.WebService.Security;
using StellaOps.Auth.ServerIntegration.Tenancy;
using static StellaOps.Localization.T;
namespace StellaOps.Timeline.WebService.Endpoints;
@@ -50,12 +51,12 @@ public static class ReplayEndpoints
// Validate request
if (string.IsNullOrWhiteSpace(correlationId))
{
return TypedResults.BadRequest("Correlation ID is required");
return TypedResults.BadRequest(_t("timeline.validation.replay_correlation_id_required"));
}
if (!IsSupportedMode(request.Mode))
{
return TypedResults.BadRequest("Mode must be either 'dry-run' or 'verify'.");
return TypedResults.BadRequest(_t("timeline.validation.replay_mode_invalid"));
}
if (!TryParseHlc(request.FromHlc, "fromHlc", out var fromHlc, out var fromParseError))
@@ -172,7 +173,7 @@ public static class ReplayEndpoints
return true;
}
error = $"Invalid {parameterName} value '{hlcString}'. Expected format '{{physicalTime13}}-{{nodeId}}-{{counter6}}'.";
error = _t("timeline.error.hlc_invalid_format", parameterName, hlcString);
return false;
}

View File

@@ -5,6 +5,7 @@ using StellaOps.HybridLogicalClock;
using StellaOps.Timeline.Core;
using StellaOps.Timeline.WebService.Security;
using StellaOps.Auth.ServerIntegration.Tenancy;
using static StellaOps.Localization.T;
namespace StellaOps.Timeline.WebService.Endpoints;
@@ -144,7 +145,7 @@ public static class TimelineEndpoints
return true;
}
error = $"Invalid {parameterName} value '{rawValue}'. Expected format '{{physicalTime13}}-{{nodeId}}-{{counter6}}'.";
error = _t("timeline.error.hlc_invalid_format", parameterName, rawValue);
return false;
}
}

View File

@@ -1,4 +1,5 @@
using StellaOps.Auth.Abstractions;
using StellaOps.Localization;
using StellaOps.Auth.ServerIntegration;
using StellaOps.Auth.ServerIntegration.Tenancy;
using StellaOps.Eventing;
@@ -38,6 +39,9 @@ builder.Services.AddAuthorization(options =>
builder.Services.AddStellaOpsCors(builder.Environment, builder.Configuration);
builder.Services.AddStellaOpsLocalization(builder.Configuration);
builder.Services.AddTranslationBundle(System.Reflection.Assembly.GetExecutingAssembly());
// Stella Router integration
var routerEnabled = builder.Services.AddRouterMicroservice(
builder.Configuration,
@@ -57,19 +61,22 @@ if (app.Environment.IsDevelopment())
}
app.UseStellaOpsCors();
app.UseStellaOpsLocalization();
app.UseAuthentication();
app.UseAuthorization();
app.UseStellaOpsTenantMiddleware();
app.TryUseStellaRouter(routerEnabled);
// Map endpoints
await app.LoadTranslationsAsync();
app.MapTimelineEndpoints();
app.MapReplayEndpoints();
app.MapExportEndpoints();
app.MapHealthEndpoints();
app.TryRefreshStellaRouterEndpoints(routerEnabled);
app.Run();
await app.RunAsync().ConfigureAwait(false);
namespace StellaOps.Timeline.WebService
{

View File

@@ -15,6 +15,11 @@
<ProjectReference Include="..\..\__Libraries\StellaOps.HybridLogicalClock\StellaOps.HybridLogicalClock.csproj" />
<ProjectReference Include="..\..\Router\__Libraries\StellaOps.Microservice\StellaOps.Microservice.csproj" />
<ProjectReference Include="..\..\Authority\StellaOps.Authority\StellaOps.Auth.ServerIntegration\StellaOps.Auth.ServerIntegration.csproj" />
<ProjectReference Include="..\..\__Libraries\StellaOps.Localization\StellaOps.Localization.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Translations\*.json" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,11 @@
{
"_meta": { "locale": "en-US", "namespace": "timeline", "version": "1.0" },
"timeline.error.no_events_for_correlation": "No events found for correlation ID: {0}.",
"timeline.error.hlc_invalid_format": "Invalid {0} value '{1}'. Expected format '{{physicalTime13}}-{{nodeId}}-{{counter6}}'.",
"timeline.validation.correlation_id_required": "Correlation ID is required.",
"timeline.validation.format_invalid": "Format must be either 'ndjson' or 'json'.",
"timeline.validation.replay_correlation_id_required": "Correlation ID is required.",
"timeline.validation.replay_mode_invalid": "Mode must be either 'dry-run' or 'verify'."
}

View File

@@ -2,12 +2,18 @@
using System.Net;
using System.Net.Http.Json;
using System.Security.Claims;
using System.Text.Encodings.Web;
using FluentAssertions;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using StellaOps.Eventing.Models;
using StellaOps.Eventing.Storage;
using StellaOps.Eventing;
@@ -308,6 +314,14 @@ public sealed class TimelineWebApplicationFactory : WebApplicationFactory<Stella
{
builder.UseEnvironment("Development");
builder.ConfigureAppConfiguration((_, config) =>
{
config.AddInMemoryCollection(new Dictionary<string, string?>
{
["Authority:ResourceServer:Authority"] = "http://localhost",
});
});
builder.ConfigureServices(services =>
{
// Replace with in-memory store for tests
@@ -323,10 +337,42 @@ public sealed class TimelineWebApplicationFactory : WebApplicationFactory<Stella
"test-node",
new InMemoryHlcStateStore(),
NullLogger<StellaOps.HybridLogicalClock.HybridLogicalClock>.Instance));
// Override authentication with a test handler that always succeeds
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = "TimelineTest";
options.DefaultChallengeScheme = "TimelineTest";
}).AddScheme<AuthenticationSchemeOptions, TimelineTestAuthHandler>("TimelineTest", _ => { });
});
}
}
internal sealed class TimelineTestAuthHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{
public TimelineTestAuthHandler(
IOptionsMonitor<AuthenticationSchemeOptions> options,
ILoggerFactory logger,
UrlEncoder encoder)
: base(options, logger, encoder)
{
}
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
var claims = new[]
{
new Claim(ClaimTypes.NameIdentifier, "test-user"),
new Claim("scope", "timeline:read timeline:write"),
new Claim("stellaops:tenant", "test-tenant"),
};
var identity = new ClaimsIdentity(claims, Scheme.Name);
var principal = new ClaimsPrincipal(identity);
var ticket = new AuthenticationTicket(principal, Scheme.Name);
return Task.FromResult(AuthenticateResult.Success(ticket));
}
}
internal sealed class NoOpTimelineEventEmitter : ITimelineEventEmitter
{
public Task<TimelineEvent> EmitAsync<TPayload>(

View File

@@ -24,6 +24,7 @@ public sealed class TimelineStartupRegistrationTests
["Eventing:ServiceName"] = "timeline-tests",
["Eventing:UseInMemoryStore"] = "false",
["Eventing:ConnectionString"] = "Host=localhost;Port=5432;Database=timeline;Username=postgres;Password=postgres",
["Authority:ResourceServer:Authority"] = "http://localhost",
});
});
});