ProgramSandboxLimitOptions
Options & Configuration · AiDotNet.Configuration
Resource limits applied to every sandboxed execution of an untrusted candidate program.
For Beginners
These numbers are the leash on a program that a model wrote and nobody reviewed. The time limit stops infinite loops, the memory limit stops runaway allocation, the output limits stop a program that prints forever from filling your disk or your logs, and the concurrency limit stops a large population from starting hundreds of processes at once. The defaults suit small algorithmic tasks; raise the time and memory limits if your candidates legitimately need longer, and lower them if you want a tighter feedback loop.
How It Works
The defaults mirror the free-tier limits that AiDotNet.Serving applies to container-sandboxed execution
(ServingSandboxLimitOptions): five seconds of wall clock, 256 MB of memory, one CPU, 200,000 source
characters, 100,000 standard-input characters, and 64,000 characters each of captured standard output and
standard error, with at most four executions running concurrently. Keeping the two sets of numbers identical
means a run that scores candidates locally and a run that scores them through a serving deployment agree on
which candidates time out, so a fitness landscape does not silently change shape when the sandbox does.
Every limit is enforced, not merely advertised. The time limit cancels the run and kills the whole process tree;
the memory limit becomes a Windows job-object cap or a ulimit on Unix; the output caps bound the reader
buffers, so a program that prints without stopping cannot exhaust the host’s memory and is reported with the
truncation flag set; and the concurrency limit is a semaphore held for the duration of each execution.
Constructors
| Constructor | Summary |
|---|---|
ProgramSandboxLimitOptions() |
Properties
| Property | Summary |
|---|---|
double CpuLimit { get; set; } |
Gets or sets the CPU-core allowance for one execution. |
int MaxConcurrentExecutions { get; set; } |
Gets or sets how many executions may run at the same time. |
int MaxSourceCodeChars { get; set; } |
Gets or sets the largest accepted program source, in characters. |
int MaxStdErrChars { get; set; } |
Gets or sets how many characters of standard error are captured. |
int MaxStdInChars { get; set; } |
Gets or sets the largest accepted standard input, in characters. |
int MaxStdOutChars { get; set; } |
Gets or sets how many characters of standard output are captured. |
int MemoryLimitMb { get; set; } |
Gets or sets the memory limit for one execution, in megabytes. |
int TimeLimitSeconds { get; set; } |
Gets or sets the wall-clock limit for one execution, in seconds. |
Methods
| Method | Summary |
|---|---|
ProgramSandboxLimitOptions Clone() |
Creates an independent copy so a running engine is unaffected by later mutation. |
TimeSpan GetTimeLimit() |
Gets the wall-clock limit as a time span. |
long GetMemoryLimitBytes() |
Gets the memory limit in bytes. |
void Validate() |
Rejects limits that cannot be enforced or that describe an impossible sandbox. |
Fields
| Field | Summary |
|---|---|
int MaxConcurrencyLimit |
The largest concurrency limit accepted by Validate. |
int MaxMemoryLimitMb |
The largest memory limit accepted by Validate, in megabytes. |
int MaxTimeLimitSeconds |
The largest wall-clock limit accepted by Validate, in seconds. |