up
Some checks failed
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Manifest Integrity / Validate Schema Integrity (push) Has been cancelled
Manifest Integrity / Validate Contract Documents (push) Has been cancelled
Manifest Integrity / Validate Pack Fixtures (push) Has been cancelled
Manifest Integrity / Audit SHA256SUMS Files (push) Has been cancelled
Manifest Integrity / Verify Merkle Roots (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Some checks failed
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Manifest Integrity / Validate Schema Integrity (push) Has been cancelled
Manifest Integrity / Validate Contract Documents (push) Has been cancelled
Manifest Integrity / Validate Pack Fixtures (push) Has been cancelled
Manifest Integrity / Audit SHA256SUMS Files (push) Has been cancelled
Manifest Integrity / Verify Merkle Roots (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using StellaOps.Signals.Models;
|
||||
|
||||
namespace StellaOps.Signals.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Builds deterministic synthetic runtime events from an existing callgraph.
|
||||
/// </summary>
|
||||
public sealed class SyntheticRuntimeProbeBuilder
|
||||
{
|
||||
private readonly TimeProvider timeProvider;
|
||||
|
||||
public SyntheticRuntimeProbeBuilder(TimeProvider timeProvider)
|
||||
{
|
||||
this.timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
|
||||
}
|
||||
|
||||
public List<RuntimeFactEvent> BuildEvents(CallgraphDocument callgraph, int requestedCount)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(callgraph);
|
||||
var now = timeProvider.GetUtcNow();
|
||||
var count = Math.Max(1, Math.Min(requestedCount <= 0 ? 5 : requestedCount, callgraph.Nodes.Count));
|
||||
|
||||
return callgraph.Nodes
|
||||
.OrderBy(n => n.Id, StringComparer.Ordinal)
|
||||
.Take(count)
|
||||
.Select((node, index) => new RuntimeFactEvent
|
||||
{
|
||||
SymbolId = node.Id,
|
||||
CodeId = node.CodeId,
|
||||
Purl = node.Purl,
|
||||
SymbolDigest = node.SymbolDigest,
|
||||
BuildId = node.BuildId,
|
||||
ObservedAt = now,
|
||||
ProcessId = 1000 + index,
|
||||
ProcessName = "synthetic-probe",
|
||||
Metadata = new Dictionary<string, string?>(StringComparer.Ordinal)
|
||||
{
|
||||
["probe"] = "synthetic",
|
||||
["probe.version"] = "v1",
|
||||
["probe.seed"] = callgraph.Id,
|
||||
}
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user