// -----------------------------------------------------------------------------
// ResolverBoundaryAttribute.cs
// Sprint: SPRINT_20251226_007_BE_determinism_gaps
// Task: DET-GAP-18
// Description: Attribute marking methods/classes as resolver boundaries requiring canonicalization.
// -----------------------------------------------------------------------------
namespace StellaOps.Determinism;
///
/// Marks a method or class as a resolver boundary where canonicalization is required.
/// The STELLA0100 analyzer will enforce RFC 8785 JCS canonicalization within marked scopes.
///
///
/// Apply this attribute to:
///
/// - Methods that compute digests for attestations or signatures
/// - Methods that serialize data for replay or comparison
/// - Classes that produce deterministic outputs
///
///
///
///
/// [ResolverBoundary]
/// public string ComputeVerdictDigest(VerdictPayload payload)
/// {
/// // Analyzer will warn if JsonSerializer.Serialize is used here
/// var canonicalizer = new Rfc8785JsonCanonicalizer();
/// return canonicalizer.Canonicalize(payload);
/// }
///
///
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class ResolverBoundaryAttribute : Attribute
{
///
/// Gets or sets whether NFC normalization is required for strings.
///
public bool RequireNfc { get; set; }
///
/// Gets or sets whether strict ordering is required for collections.
///
public bool RequireOrdering { get; set; } = true;
///
/// Gets or sets a description of the boundary purpose.
///
public string? Description { get; set; }
}
///
/// Marks a method as requiring canonicalization for its output.
/// Alias for for semantic clarity.
///
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class RequiresCanonicalizationAttribute : Attribute
{
///
/// Gets or sets the canonicalization scheme required.
///
public string Scheme { get; set; } = "RFC8785";
}
///
/// Marks a method as producing deterministic output that must be reproducible.
///
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class DeterministicOutputAttribute : Attribute
{
///
/// Gets or sets the hash algorithm used for verification.
///
public string HashAlgorithm { get; set; } = "SHA256";
///
/// Gets or sets whether the output is signed.
///
public bool IsSigned { get; set; }
}