feat(security): complete capability messaging workflows

This commit is contained in:
2026-07-29 11:21:15 +08:00
parent df88fa19cb
commit 5c4de4b282
35 changed files with 19544 additions and 89 deletions

View File

@@ -82,6 +82,22 @@ public sealed class TenantExecutionScope(
ArgumentException.ThrowIfNullOrWhiteSpace(request.Caller);
ArgumentException.ThrowIfNullOrWhiteSpace(request.Reason);
ArgumentException.ThrowIfNullOrWhiteSpace(request.CorrelationId);
if (request.TargetTenantId is null && !request.IsGlobal)
{
throw new ArgumentException("System scope requires a target tenant or an explicit global declaration.", nameof(request));
}
if (request.TargetTenantId is not null && request.IsGlobal)
{
throw new ArgumentException("A tenant-targeted system scope cannot also be global.", nameof(request));
}
if (request.IsGlobal && request.CallerType is SystemScopeCallerType.Worker or SystemScopeCallerType.PublicQuestionBank)
{
throw new ArgumentException("Worker and public question bank scopes must target a tenant.", nameof(request));
}
if (!Enum.IsDefined(request.CallerType))
{
throw new ArgumentOutOfRangeException(nameof(request), "Unknown system scope caller type.");
}
}
private static async Task WriteAuditAsync(
@@ -105,6 +121,7 @@ public sealed class TenantExecutionScope(
request.Caller,
request.Reason,
request.CorrelationId,
request.IsGlobal,
startedAt,
elapsedMilliseconds,
failureType