Portal Community

GuardRailCheckResult Shape

// BizFirst.Ai.GuardRails.Domain.Models.GuardRailCheckResult
public class GuardRailCheckResult
{
    // True = execution proceeds; False = execution is blocked
    public bool   IsAllowed          { get; }

    // Error or warning message (set on Blocked or Warning results)
    public string? ErrorMessage       { get; }

    // Retry-after hint in seconds (for rate limit Blocked results)
    public int?   RetryAfterSeconds   { get; }

    // Additional metadata (e.g. scope, counts, limits)
    public IDictionary<string, object?> Metadata { get; }

    // Whether the guard modified the output (for Post-phase sanitizers)
    public bool   OutputModified      { get; }

    // Timestamp of result creation
    public DateTime CreatedAt         { get; }
}

Factory Methods

// Allow — execution continues normally
return GuardRailCheckResult.Success();

// Allow with output modified (e.g. PII was redacted)
return GuardRailCheckResult.Success(
    outputModified: true,
    metadata: new Dictionary<string, object?> { { "redacted_fields", "email,phone" } });

// Block — execution is prevented
return GuardRailCheckResult.Blocked(
    errorMessage: "Rate limit exceeded: 100 req/s (limit: 10)",
    retryAfterSeconds: 30,
    metadata: new Dictionary<string, object?>
    {
        { "scope",             "tenant"  },
        { "requests_in_window", 100      },
        { "limit",              10       }
    });

// Warning — execution continues but a warning is logged
return GuardRailCheckResult.Warning(
    warningMessage: "Token usage is approaching quota (85% used)",
    metadata: new Dictionary<string, object?> { { "usage_percent", 85 } });

When Each Result Is Used

ResultIsAllowedWhen to Use
Success() true Guard check passed — no issues found
Success(outputModified: true) true Post-phase: guard sanitized output (e.g. PII redaction applied)
Warning(message) true Issue detected but not severe enough to block (quota at 85%, for example)
Blocked(message) false Constraint violated — must stop execution
Blocked(message, retryAfterSeconds) false Rate limit or temporary block — tells the client when to retry
Warning Is Not a Block GuardRailCheckResult.Warning sets IsAllowed = true. The execution proceeds normally. The warning message is logged by the guard infrastructure and may appear in the Observer Panel logs, but it does not change the execution outcome. Use it for advisory conditions, not enforcement.