mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-06 02:22:17 +00:00
Some checks failed
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Sync Flatpak repo (push) Has been cancelled
Build and Release / Collect Flatpak artifacts (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
51 lines
2.1 KiB
C#
51 lines
2.1 KiB
C#
namespace AIStudio.Assistants.VisualBriefing;
|
|
|
|
/// <summary>
|
|
/// Guards parts compiled by AI Studio after the model-controlled contracts have been validated.
|
|
/// </summary>
|
|
internal static class VisualBriefingCompilerInvariant
|
|
{
|
|
private const string USER_MESSAGE = "AI Studio could not assemble this briefing because its own compiler produced an invalid part. This is a defect in AI Studio, not in the model response.";
|
|
|
|
/// <summary>
|
|
/// Fails the build when compiled parts violate the artifact contract.
|
|
/// </summary>
|
|
/// <param name="stage">The stage running the compilation.</param>
|
|
/// <param name="compilerIssue">The compiler issue, or an empty string when the parts are valid.</param>
|
|
/// <exception cref="VisualBriefingBuildException">Thrown when the compiled parts are invalid.</exception>
|
|
internal static void Guard(VisualBriefingBuildStage stage, string compilerIssue)
|
|
{
|
|
if (string.IsNullOrEmpty(compilerIssue))
|
|
return;
|
|
|
|
throw new VisualBriefingBuildException(
|
|
VisualBriefingFailureCode.COMPILER_INVARIANT_VIOLATED,
|
|
stage,
|
|
USER_MESSAGE,
|
|
$"Stage={stage}; CompilerIssue={compilerIssue}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Runs a compilation and translates structural failures into a compiler invariant failure.
|
|
/// </summary>
|
|
/// <typeparam name="T">The compilation result type.</typeparam>
|
|
/// <param name="stage">The stage running the compilation.</param>
|
|
/// <param name="compile">The compilation to run.</param>
|
|
/// <returns>The compilation result.</returns>
|
|
/// <exception cref="VisualBriefingBuildException">Thrown when the compilation fails structurally.</exception>
|
|
internal static T Guard<T>(VisualBriefingBuildStage stage, Func<T> compile)
|
|
{
|
|
try
|
|
{
|
|
return compile();
|
|
}
|
|
catch (InvalidDataException exception)
|
|
{
|
|
throw new VisualBriefingBuildException(
|
|
VisualBriefingFailureCode.COMPILER_INVARIANT_VIOLATED,
|
|
stage,
|
|
USER_MESSAGE,
|
|
$"Stage={stage}; CompilerIssue={exception.Message}");
|
|
}
|
|
}
|
|
} |