// ----------------------------------------------------------------------------- // BoundaryExtractionContext.cs // Sprint: SPRINT_3800_0002_0001_boundary_richgraph // Description: Context for boundary extraction with environment hints. // ----------------------------------------------------------------------------- using StellaOps.Scanner.Reachability.Gates; using System; using System.Collections.Generic; namespace StellaOps.Scanner.Reachability.Boundary; /// /// Context for boundary extraction, providing environment hints and detected gates. /// public sealed record BoundaryExtractionContext { /// /// Empty context for simple extractions. /// /// Uses system time. For deterministic timestamps, use . [Obsolete("Use CreateEmpty(TimeProvider) for deterministic timestamps")] public static BoundaryExtractionContext Empty => CreateEmpty(); /// /// Creates an empty context for simple extractions. /// /// Optional time provider for deterministic timestamps. /// An empty boundary extraction context. public static BoundaryExtractionContext CreateEmpty(TimeProvider? timeProvider = null) => new() { Timestamp = (timeProvider ?? TimeProvider.System).GetUtcNow() }; /// /// Environment identifier (e.g., "production", "staging"). /// public string? EnvironmentId { get; init; } /// /// Deployment namespace or context (e.g., "default", "kube-system"). /// public string? Namespace { get; init; } /// /// Additional annotations from deployment metadata. /// public IReadOnlyDictionary Annotations { get; init; } = new Dictionary(); /// /// Gates detected by gate detection analysis. /// public IReadOnlyList DetectedGates { get; init; } = Array.Empty(); /// /// Whether the service is known to be internet-facing. /// public bool? IsInternetFacing { get; init; } /// /// Network zone (e.g., "dmz", "internal", "trusted"). /// public string? NetworkZone { get; init; } /// /// Known port bindings (port to protocol). /// public IReadOnlyDictionary PortBindings { get; init; } = new Dictionary(); /// /// Timestamp for the context (for cache invalidation). /// public required DateTimeOffset Timestamp { get; init; } /// /// Source of this context (e.g., "k8s", "iac", "runtime"). /// public string? Source { get; init; } /// /// Creates a context from detected gates. /// /// The detected gates. /// Optional time provider for deterministic timestamps. public static BoundaryExtractionContext FromGates(IReadOnlyList gates, TimeProvider? timeProvider = null) => new() { DetectedGates = gates, Timestamp = (timeProvider ?? TimeProvider.System).GetUtcNow() }; /// /// Creates a context with environment hints. /// /// The environment identifier. /// Whether the service is internet-facing. /// The network zone. /// Optional time provider for deterministic timestamps. public static BoundaryExtractionContext ForEnvironment( string environmentId, bool? isInternetFacing = null, string? networkZone = null, TimeProvider? timeProvider = null) => new() { EnvironmentId = environmentId, IsInternetFacing = isInternetFacing, NetworkZone = networkZone, Timestamp = (timeProvider ?? TimeProvider.System).GetUtcNow() }; }