Skip to content
2 min read · 435 words

Interface: SandboxPolicyEnforcer

Defined in: src/batteries/sandbox/contracts/policy_enforcer.ts:6

Policy boundary. run resolves on spawn and exposes live streams plus a later completion promise.

Properties

PropertyModifierTypeDescriptionDefined in
adopted?readonlybooleanWhether this adapter adopted an already-enabled process-global sandbox rather than initializing it.src/batteries/sandbox/contracts/policy_enforcer.ts:10

Methods

checkDependencies()

ts
checkDependencies(): Promise<{
  errors: string[];
  warnings: string[];
}>;

Defined in: src/batteries/sandbox/contracts/policy_enforcer.ts:12

Probe external prerequisites. A non-empty errors throws E_SANDBOX_DEPENDENCY_MISSING; warnings are surfaced through observability and are NOT fatal.

Returns

Promise<{ errors: string[]; warnings: string[]; }>


diagnosticsFor()

ts
diagnosticsFor(correlationId: string): string[];

Defined in: src/batteries/sandbox/contracts/policy_enforcer.ts:39

Retrieve diagnostics by correlation id, never by command text.

Parameters

ParameterType
correlationIdstring

Returns

string[]


dispose()

ts
dispose(): Promise<void>;

Defined in: src/batteries/sandbox/contracts/policy_enforcer.ts:41

Release what this enforcer OWNS. A no-op when it adopted a foreign sandbox — tearing down a manager we did not initialize would strip ACEs a host app depends on.

Returns

Promise<void>


effectivePolicy()

ts
effectivePolicy(): DerivedRules | undefined;

Defined in: src/batteries/sandbox/contracts/policy_enforcer.ts:37

Return the opaque derived snapshot used for drift validation.

Returns

DerivedRules | undefined


isSupported()

ts
isSupported(): boolean;

Defined in: src/batteries/sandbox/contracts/policy_enforcer.ts:8

Whether this enforcer can enforce on the current platform. false (a browser tab, where SRT does not exist) raises E_SANDBOX_UNSUPPORTED_ENV at construction rather than degrading — a shim that enforces nothing reads as sandboxed.

Returns

boolean


run()

ts
run(op: {
  argv: string[];
  correlationId: string;
  cwd: string;
  env?: Record<string, string>;
  policy: SandboxPolicy;
  signal?: AbortSignal;
}): Promise<{
  completed: Promise<{
     exitCode: number;
     failed: boolean;
  }>;
  stderr: ReadableStream<Uint8Array<ArrayBufferLike>>;
  stdout: ReadableStream<Uint8Array<ArrayBufferLike>>;
}>;

Defined in: src/batteries/sandbox/contracts/policy_enforcer.ts:14

Spawn under a narrowing policy; a non-zero exit is data, not a rejected promise.

Parameters

ParameterTypeDescription
op{ argv: string[]; correlationId: string; cwd: string; env?: Record<string, string>; policy: SandboxPolicy; signal?: AbortSignal; }-
op.argvstring[]-
op.correlationIdstring-
op.cwdstring-
op.env?Record<string, string>An ADDITIVE per-call overlay on the child's environment, applied LAST. Remarks NOT the host-inheritance control. What a child inherits from the host is the ADAPTER's decision (the Node/SRT one denies by default and takes an allow-list at construction); this field only adds to whatever that produced, and an adapter MUST NOT let it silently widen what the deployment allowed. Leaving these semantics unstated is how the Node adapter came to spread the entire process.env into every child while this field sat unused.
op.policySandboxPolicy-
op.signal?AbortSignal-

Returns

Promise<{ completed: Promise<{ exitCode: number; failed: boolean; }>; stderr: ReadableStream<Uint8Array<ArrayBufferLike>>; stdout: ReadableStream<Uint8Array<ArrayBufferLike>>; }>