2026-10-04 12:26:26 +02:00
namespace AIStudio.Settings.DataModel ;
/// <summary>
2026-10-18 19:39:55 +02:00
/// Where a chat may still send data, and which source of internal content demands it.
2026-10-04 12:26:26 +02:00
/// </summary>
/// <remarks>
2026-10-18 19:39:55 +02:00
/// The source travels along so a tool which is kept from running can name it, and the user
2026-10-23 09:27:22 +02:00
/// learns what stands in the way. For a mailbox or a data source, the reference is its id rather
/// than its name, because either may be renamed after a chat read from it.
2026-10-04 12:26:26 +02:00
/// </remarks>
/// <param name="Restriction">Where the chat may still send data.</param>
2026-10-18 19:39:55 +02:00
/// <param name="Origin">What kind of source demands the restriction, or NONE when nothing restricts the chat.</param>
2026-10-23 09:27:22 +02:00
/// <param name="Reference">Which source of its kind demands the restriction: the id of a mailbox or of a data source, or the host of a private web page. An empty text when the kind says it all, as for the wiki, or when nothing restricts the chat.</param>
2026-10-18 19:39:55 +02:00
public sealed record OutboundDataRequirement ( OutboundDataRestriction Restriction , OutboundDataOrigin Origin , string Reference )
2026-10-04 12:26:26 +02:00
{
/// <summary>
2026-10-18 19:39:55 +02:00
/// Demands nothing: what a chat holds before it read any internal content, and what a result
/// demands which brought none in.
2026-10-04 12:26:26 +02:00
/// </summary>
2026-10-18 19:39:55 +02:00
public static readonly OutboundDataRequirement NONE = new ( OutboundDataRestriction . UNRESTRICTED , OutboundDataOrigin . NONE , string . Empty );
2026-10-04 12:26:26 +02:00
/// <summary>
/// The stricter of this requirement and another one.
/// </summary>
/// <remarks>
2026-10-18 19:39:55 +02:00
/// On a tie, this one is kept, whatever the origin of either, so the source which set a level
/// first stays the one which is named, and a chat does not name another source with every
2026-10-23 09:27:22 +02:00
/// search. A restriction this version does not know counts as the strictest one, and the
/// requirement which wins carries that one instead.
2026-10-04 12:26:26 +02:00
/// </remarks>
/// <param name="other">The other requirement.</param>
/// <returns>The requirement whose restriction is the stricter one.</returns>
2026-10-23 09:27:22 +02:00
public OutboundDataRequirement StricterOf ( OutboundDataRequirement other )
{
var stricter = other . Restriction . OrStrictestWhenUnknown () < this . Restriction . OrStrictestWhenUnknown () ? other : this ;
var knownRestriction = stricter . Restriction . OrStrictestWhenUnknown ();
return knownRestriction == stricter . Restriction ? stricter : stricter with { Restriction = knownRestriction };
}
2026-10-04 12:26:26 +02:00
}