Skip to content

Commit 2ccdacc

Browse files
committed
docs(emergent,sandbox): clarify sandbox memory-limit enforcement is nominal not preemptive
The node:vm-backed JavaScript executor reports heap deltas after the fact; it does not preemptively terminate the process when the nominal memoryMB budget is exceeded. Previous TSDoc on SandboxExecutionRequest.memoryMB and SandboxExecutionResult.error overstated the enforcement guarantee, which could mislead callers into shipping untrusted code under the assumption that runaway allocators would be killed. Updated the type-level docs + tests + sandbox executor + the EMERGENT_CAPABILITIES architecture page so the contract reads honestly and the future-isolate-backed-runtime path is documented as the route to preemptive enforcement.
1 parent 0aa71ec commit 2ccdacc

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

docs/architecture/EMERGENT_CAPABILITIES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ await importEmergentTool('./slugify.emergent-tool.yaml', { seedId: agentSeedId }
556556
maxSessionTools: 10, // Max tools per session
557557
maxAgentTools: 50, // Max persisted per agent
558558

559-
// Sandbox resource limits
559+
// Sandbox resource limits and telemetry
560560
sandboxTimeoutMs: 5000, // VM execution timeout
561-
sandboxMemoryMB: 128, // VM memory cap
561+
sandboxMemoryMB: 128, // Nominal budget; node:vm reports heap delta only
562562

563563
// Judge configuration
564564
judgeModel: 'gpt-4o-mini', // Model for creation reviews

src/emergent/SandboxedToolForge.ts

-78 Bytes
Binary file not shown.

src/emergent/__tests__/sandboxed-forge.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type { SandboxExecutionRequest, SandboxAPI } from '../types.js';
2323

2424
/**
2525
* Build a minimal {@link SandboxExecutionRequest} from just code and input.
26-
* Defaults: empty allowlist, 128 MB memory, 5000 ms timeout.
26+
* Defaults: empty allowlist, 128 MB nominal memory budget, 5000 ms timeout.
2727
*/
2828
function makeRequest(
2929
code: string,

src/emergent/__tests__/types.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ describe('emergent/types', () => {
335335
expect(DEFAULT_EMERGENT_CONFIG.persistSandboxSource).toBe(false);
336336
});
337337

338-
it('has correct sandbox memory limit', () => {
338+
it('has correct sandbox memory budget', () => {
339339
expect(DEFAULT_EMERGENT_CONFIG.sandboxMemoryMB).toBe(128);
340340
});
341341

src/emergent/types.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ export interface SandboxExecutionRequest {
185185
allowlist: SandboxAPI[];
186186

187187
/**
188-
* Maximum heap memory in megabytes the sandbox process may consume.
189-
* The executor terminates the process if this limit is exceeded.
188+
* Nominal heap budget in megabytes for the sandbox execution.
189+
* The current node:vm-backed JavaScript executor reports heap deltas but does
190+
* not preemptively enforce this limit.
190191
* @default 128
191192
*/
192193
memoryMB: number;
@@ -215,7 +216,8 @@ export interface SandboxExecutionResult {
215216

216217
/**
217218
* Human-readable error description, present when `success` is `false`.
218-
* Includes timeout, memory-exceeded, and thrown-exception cases.
219+
* Includes timeout and thrown-exception cases. A future isolate-backed
220+
* runtime may also report memory-exceeded cases.
219221
*/
220222
error?: string;
221223

@@ -226,7 +228,7 @@ export interface SandboxExecutionResult {
226228
executionTimeMs: number;
227229

228230
/**
229-
* Peak heap memory used by the sandbox process in bytes.
231+
* Observed heap delta for the sandbox execution in bytes.
230232
* Populated when the runtime can measure it; otherwise `0`.
231233
*/
232234
memoryUsedBytes: number;
@@ -688,7 +690,9 @@ export interface EmergentConfig {
688690
persistSandboxSource: boolean;
689691

690692
/**
691-
* Memory limit in megabytes for each sandboxed tool execution.
693+
* Nominal memory budget in megabytes for each sandboxed tool execution.
694+
* The current node:vm-backed executor reports heap deltas but does not
695+
* preemptively enforce this limit.
692696
* Passed as `SandboxExecutionRequest.memoryMB`.
693697
* @default 128
694698
*/

src/sandbox/executor/CodeSandbox.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939

4040
const DEFAULT_CONFIG: SandboxConfig = {
4141
timeoutMs: 30000, // 30 seconds
42-
maxMemoryBytes: 128 * 1024 * 1024, // 128MB
42+
maxMemoryBytes: 128 * 1024 * 1024, // Nominal budget; JS node:vm reports heap delta only.
4343
maxOutputBytes: 1024 * 1024, // 1MB
4444
allowNetwork: false,
4545
allowFilesystem: false,
@@ -748,4 +748,3 @@ export class CodeSandbox implements ICodeSandbox {
748748
return 'low';
749749
}
750750
}
751-

0 commit comments

Comments
 (0)