namespace AIStudio.Tools.Security;
///
/// One user action, such as sending a message, whose filtered content is reported to the user together.
///
///
/// Created through PromptInjectionGuardService.BeginAction. Content which belongs to the action carries
/// the scope down to where it is read or filtered; disposing the scope ends the action.
///
/// The service which reports what was filtered.
/// The action this scope is part of, or null when it begins an action of its own.
public sealed class PromptInjectionReportingScope(PromptInjectionGuardService guardService, PromptInjectionReportingScope? parent) : IAsyncDisposable
{
///
/// The action this scope is part of, or null when it begins an action of its own.
///
internal PromptInjectionReportingScope? Parent => parent;
///
/// What was filtered while this scope was the outermost one of its action still running.
///
///
/// Read and written under the lock of the guard service only.
///
internal List PendingResults { get; } = [];
///
/// Gets or sets a value indicating whether the action is still running.
///
///
/// Read and written under the lock of the guard service only.
///
internal bool IsOpen { get; set; } = true;
public async ValueTask DisposeAsync() => await guardService.EndActionAsync(this);
}