namespace ZB.MOM.WW.OtOpcUa.Core.Authorization;
///
/// Address of a node in the 6-level scope hierarchy the Phase 6.2 evaluator walks.
/// Assembled by the dispatch layer from the node's namespace + UNS path + tag; passed
/// to which walks the matching trie path.
///
///
/// Per decision #129 and the Phase 6.2 Stream B plan the hierarchy is
/// Cluster → Namespace → UnsArea → UnsLine → Equipment → Tag for UNS
/// (Equipment-kind) namespaces. Galaxy (SystemPlatform-kind) namespaces instead use
/// Cluster → Namespace → FolderSegment(s) → Tag, and each folder segment takes
/// one trie level — so a deeply-nested Galaxy folder implicitly reaches the same
/// depth as a full UNS path.
///
/// Unset mid-path levels (e.g. a Cluster-scoped request with no UnsArea) leave
/// the corresponding id null. The evaluator walks as far as the scope goes +
/// stops at the first null.
///
public sealed record NodeScope
{
/// Cluster the node belongs to. Required.
public required string ClusterId { get; init; }
/// Namespace within the cluster. Null is not allowed for a request against a real node.
public string? NamespaceId { get; init; }
/// For Equipment-kind namespaces: UNS area (e.g. "warsaw-west"). Null on Galaxy.
public string? UnsAreaId { get; init; }
/// For Equipment-kind namespaces: UNS line below the area. Null on Galaxy.
public string? UnsLineId { get; init; }
/// For Equipment-kind namespaces: equipment row below the line. Null on Galaxy.
public string? EquipmentId { get; init; }
///
/// For Galaxy (SystemPlatform-kind) namespaces only: the folder path segments from
/// namespace root to the target tag, in order. Empty on Equipment namespaces.
///
public IReadOnlyList FolderSegments { get; init; } = [];
/// Target tag id when the scope addresses a specific tag; null for folder / equipment-level scopes.
public string? TagId { get; init; }
/// Which hierarchy applies — Equipment-kind (UNS) or SystemPlatform-kind (Galaxy).
public required NodeHierarchyKind Kind { get; init; }
}
/// Selector between the two scope-hierarchy shapes.
public enum NodeHierarchyKind
{
/// Cluster → Namespace → UnsArea → UnsLine → Equipment → Tag — UNS / Equipment kind.
Equipment,
/// Cluster → Namespace → FolderSegment(s) → Tag — Galaxy / SystemPlatform kind.
SystemPlatform,
}