Interface IProgramExecutionEngine
- Namespace
- AiDotNet.ProgramSynthesis.Interfaces
- Assembly
- AiDotNet.dll
Defines an execution boundary for running synthesized programs against inputs.
public interface IProgramExecutionEngine
Remarks
Implementations should execute code in a sandboxed, resource-limited environment appropriate for the target language (timeouts, memory limits, restricted I/O, etc.).
For Beginners: This is the "runner" that actually executes the generated code.
Program synthesis can generate code as text, but to verify it works we need to run it safely. This interface lets you plug in a safe execution environment (for example, a container, an isolated process, or a remote service) without embedding unsafe execution inside the library.
Methods
TryExecute(ProgramLanguage, string, string, out string, out string?, CancellationToken)
Tries to execute the given program source against the provided input.
bool TryExecute(ProgramLanguage language, string sourceCode, string input, out string output, out string? errorMessage, CancellationToken cancellationToken = default)
Parameters
languageProgramLanguageThe programming language the source is written in.
sourceCodestringThe program source code.
inputstringThe input to execute the program with.
outputstringThe captured output produced by the program (if successful).
errorMessagestringAn optional error message if execution failed.
cancellationTokenCancellationTokenOptional cancellation token for the execution attempt.
Returns
- bool
True if execution succeeded and output is available; otherwise, false.