Package com.tnsai.quality.sandbox
Record Class ResourceLimits
java.lang.Object
java.lang.Record
com.tnsai.quality.sandbox.ResourceLimits
- Record Components:
- fractional CPU shares (1.0 = one full core, 0.5 = half a core). Must be> 0.memoryMb- RAM cap in mebibytes. Must be> 0.diskMb- writable scratch-disk cap in mebibytes.0means "no scratch space" (sandbox is read-only).timeout- wall-clock cap on a singleSandbox.execute(com.tnsai.quality.sandbox.Command)call. Must be positive.maxProcesses- maximum concurrent processes the sandbox may spawn.0= no limit.maxOutputBytes- combined stdout+stderr capture cap on the host heap. Must be> 0. Exceeding it kills the process and marks the result truncated.
public record ResourceLimits(double cpuShares, long memoryMb, long diskMb, Duration timeout, int maxProcesses, long maxOutputBytes)
extends Record
Per-sandbox resource caps (TNS-296). Enforced by the backend at
sandbox creation: backends that can't honour a cap reject the
spec at
SandboxFactory.create(com.tnsai.quality.sandbox.SandboxSpec) time rather than silently
relaxing it.- Since:
- 0.10.0 (TNS-296)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longHost-heap capture default when the 5-arg constructor is used. -
Constructor Summary
ConstructorsConstructorDescriptionResourceLimits(double cpuShares, long memoryMb, long diskMb, Duration timeout, int maxProcesses) Source-compatible 5-arg constructor.ResourceLimits(double cpuShares, long memoryMb, long diskMb, Duration timeout, int maxProcesses, long maxOutputBytes) Creates an instance of aResourceLimitsrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of thecpuSharesrecord component.longdiskMb()Returns the value of thediskMbrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longReturns the value of themaxOutputBytesrecord component.intReturns the value of themaxProcessesrecord component.longmemoryMb()Returns the value of thememoryMbrecord component.static ResourceLimitsminimal()Tight budget for short, low-cost executions (e.g. policy checks, regex evaluation).static ResourceLimitsof(double cpuShares, long memoryMb, long timeoutSec) Convenience for the common (cpu, mem, timeoutSec) shape.static ResourceLimitsstandard()Default budget for typical code-exec (Python/Node REPL, formatter, single-file runner).timeout()Returns the value of thetimeoutrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT_MAX_OUTPUT_BYTES
public static final long DEFAULT_MAX_OUTPUT_BYTESHost-heap capture default when the 5-arg constructor is used.- See Also:
-
-
Constructor Details
-
ResourceLimits
public ResourceLimits(double cpuShares, long memoryMb, long diskMb, Duration timeout, int maxProcesses, long maxOutputBytes) Creates an instance of aResourceLimitsrecord class.- Parameters:
cpuShares- the value for thecpuSharesrecord componentmemoryMb- the value for thememoryMbrecord componentdiskMb- the value for thediskMbrecord componenttimeout- the value for thetimeoutrecord componentmaxProcesses- the value for themaxProcessesrecord componentmaxOutputBytes- the value for themaxOutputBytesrecord component
-
ResourceLimits
public ResourceLimits(double cpuShares, long memoryMb, long diskMb, Duration timeout, int maxProcesses) Source-compatible 5-arg constructor. UsesDEFAULT_MAX_OUTPUT_BYTESfor the host-heap capture cap.
-
-
Method Details
-
of
Convenience for the common (cpu, mem, timeoutSec) shape. -
minimal
Tight budget for short, low-cost executions (e.g. policy checks, regex evaluation). -
standard
Default budget for typical code-exec (Python/Node REPL, formatter, single-file runner). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
memoryMb
public long memoryMb()Returns the value of thememoryMbrecord component.- Returns:
- the value of the
memoryMbrecord component
-
diskMb
public long diskMb()Returns the value of thediskMbrecord component.- Returns:
- the value of the
diskMbrecord component
-
timeout
Returns the value of thetimeoutrecord component.- Returns:
- the value of the
timeoutrecord component
-
maxProcesses
public int maxProcesses()Returns the value of themaxProcessesrecord component.- Returns:
- the value of the
maxProcessesrecord component
-
maxOutputBytes
public long maxOutputBytes()Returns the value of themaxOutputBytesrecord component.- Returns:
- the value of the
maxOutputBytesrecord component
-