feat: Implement Runtime Facts ingestion service and NDJSON reader
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled

- Added RuntimeFactsNdjsonReader for reading NDJSON formatted runtime facts.
- Introduced IRuntimeFactsIngestionService interface and its implementation.
- Enhanced Program.cs to register new services and endpoints for runtime facts.
- Updated CallgraphIngestionService to include CAS URI in stored artifacts.
- Created RuntimeFactsValidationException for validation errors during ingestion.
- Added tests for RuntimeFactsIngestionService and RuntimeFactsNdjsonReader.
- Implemented SignalsSealedModeMonitor for compliance checks in sealed mode.
- Updated project dependencies for testing utilities.
This commit is contained in:
master
2025-11-10 07:56:15 +02:00
parent 9df52d84aa
commit 69c59defdc
132 changed files with 19718 additions and 9334 deletions

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using StellaOps.Signals.Models;
namespace StellaOps.Signals.Parsing;
internal static class RuntimeFactsNdjsonReader
{
private static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web);
public static async Task<List<RuntimeFactEvent>> ReadAsync(
Stream input,
bool gzipEncoded,
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(input);
Stream effectiveStream = input;
if (gzipEncoded)
{
effectiveStream = new GZipStream(input, CompressionMode.Decompress, leaveOpen: true);
}
using var reader = new StreamReader(effectiveStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, leaveOpen: !gzipEncoded);
var events = new List<RuntimeFactEvent>();
string? line;
while ((line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false)) != null)
{
if (string.IsNullOrWhiteSpace(line))
{
continue;
}
var evt = JsonSerializer.Deserialize<RuntimeFactEvent>(line, SerializerOptions);
if (evt is null || string.IsNullOrWhiteSpace(evt.SymbolId))
{
continue;
}
events.Add(evt);
}
return events;
}
}