using System.Text.Json.Serialization;
namespace StellaOps.Signals.Models;
///
/// Document representing a proc snapshot for Java/.NET/PHP runtime parity.
/// Captures runtime-observed classpath, loaded assemblies, and autoload paths.
///
public sealed class ProcSnapshotDocument
{
///
/// Unique identifier for this snapshot (format: {tenant}/{image_digest}/{snapshot_hash}).
///
public required string Id { get; init; }
///
/// Tenant identifier for multi-tenancy isolation.
///
public required string Tenant { get; init; }
///
/// Image digest of the container this snapshot was captured from.
///
[JsonPropertyName("imageDigest")]
public required string ImageDigest { get; init; }
///
/// Node identifier where the snapshot was captured.
///
public string? Node { get; init; }
///
/// Container ID where the process was running.
///
public string? ContainerId { get; init; }
///
/// Process ID at capture time.
///
public int Pid { get; init; }
///
/// Process entrypoint command.
///
public string? Entrypoint { get; init; }
///
/// Runtime type: java, dotnet, php.
///
public required string RuntimeType { get; init; }
///
/// Runtime version (e.g., "17.0.2", "8.0.0", "8.2.0").
///
public string? RuntimeVersion { get; init; }
///
/// Java classpath entries (jar paths, directories).
///
[JsonPropertyName("classpath")]
public IReadOnlyList Classpath { get; init; } = Array.Empty();
///
/// .NET loaded assemblies with RID-graph resolution.
///
[JsonPropertyName("loadedAssemblies")]
public IReadOnlyList LoadedAssemblies { get; init; } = Array.Empty();
///
/// PHP autoload paths from composer autoloader.
///
[JsonPropertyName("autoloadPaths")]
public IReadOnlyList AutoloadPaths { get; init; } = Array.Empty();
///
/// Timestamp when the snapshot was captured.
///
public DateTimeOffset CapturedAt { get; init; }
///
/// Timestamp when the snapshot was stored.
///
public DateTimeOffset StoredAt { get; init; }
///
/// Expiration timestamp for TTL-based cleanup.
///
public DateTimeOffset? ExpiresAt { get; init; }
///
/// Additional annotations/metadata.
///
public IReadOnlyDictionary? Annotations { get; init; }
}
///
/// Java classpath entry representing a JAR or directory.
///
public sealed record ClasspathEntry
{
///
/// Path to the JAR file or classpath directory.
///
public required string Path { get; init; }
///
/// Type: jar, directory, jmod.
///
public string? Type { get; init; }
///
/// SHA-256 hash of the JAR file (null for directories).
///
public string? Sha256 { get; init; }
///
/// Maven coordinate if resolvable (e.g., "org.springframework:spring-core:5.3.20").
///
public string? MavenCoordinate { get; init; }
///
/// Package URL (PURL) if resolvable.
///
public string? Purl { get; init; }
///
/// Size in bytes.
///
public long? SizeBytes { get; init; }
}
///
/// .NET loaded assembly entry with RID-graph context.
///
public sealed record LoadedAssemblyEntry
{
///
/// Assembly name (e.g., "System.Text.Json").
///
public required string Name { get; init; }
///
/// Assembly version (e.g., "8.0.0.0").
///
public string? Version { get; init; }
///
/// Full path to the loaded DLL.
///
public required string Path { get; init; }
///
/// SHA-256 hash of the assembly file.
///
public string? Sha256 { get; init; }
///
/// NuGet package ID if resolvable.
///
public string? NuGetPackage { get; init; }
///
/// NuGet package version if resolvable.
///
public string? NuGetVersion { get; init; }
///
/// Package URL (PURL) if resolvable.
///
public string? Purl { get; init; }
///
/// Runtime identifier (RID) for platform-specific assemblies.
///
public string? Rid { get; init; }
///
/// Whether this assembly was loaded from the shared framework.
///
public bool? IsFrameworkAssembly { get; init; }
///
/// Source from deps.json resolution: compile, runtime, native.
///
public string? DepsSource { get; init; }
}
///
/// PHP autoload path entry from Composer.
///
public sealed record AutoloadPathEntry
{
///
/// Namespace prefix (PSR-4) or class name (classmap).
///
public string? Namespace { get; init; }
///
/// Autoload type: psr-4, psr-0, classmap, files.
///
public required string Type { get; init; }
///
/// Path to the autoloaded file or directory.
///
public required string Path { get; init; }
///
/// Composer package name if resolvable.
///
public string? ComposerPackage { get; init; }
///
/// Composer package version if resolvable.
///
public string? ComposerVersion { get; init; }
///
/// Package URL (PURL) if resolvable.
///
public string? Purl { get; init; }
}
///
/// Known runtime types for proc snapshots.
///
public static class ProcSnapshotRuntimeTypes
{
public const string Java = "java";
public const string DotNet = "dotnet";
public const string Php = "php";
}