Table of Contents

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

language ProgramLanguage

The programming language the source is written in.

sourceCode string

The program source code.

input string

The input to execute the program with.

output string

The captured output produced by the program (if successful).

errorMessage string

An optional error message if execution failed.

cancellationToken CancellationToken

Optional cancellation token for the execution attempt.

Returns

bool

True if execution succeeded and output is available; otherwise, false.