Skip to content
API reference

sandbox-failure

Import
import * as api from "@fungi.computer/mycelium/sandbox-failure";
Kind Export Description
class SourceInvalid A location in the submitted program, never in the host’s source.
class GuestThrew Text captured inside the guest’s own exception handler.
class DeadlineExceeded The invocation owner decided its execution budget was spent.
class SandboxBusy Admission expired before any sandbox work started.
class Cancelled The invocation owner accepted cancellation.
class DispatchLost Dispatch started, but its transport did not deliver an answer.
class SandboxCrashed The sandbox process could not start or stopped before answering.
class BadResponse A received envelope could not be decoded. Its reason is operator only.
class ResultTooLarge A JSON result exceeded Mycelium’s output budget.
class ResultNotJson A result could not be represented as JSON.
class CapabilityFailed Failure at a named capability boundary, with an owner-admitted diagnostic.
class Unknown A foreign throw violated the typed adapter contract.
type alias SandboxFailureReference Optional source reference carried by sandbox failures.
type alias CapabilityDiagnostic A capability owner explicitly admits this bounded diagnostic as safe.
type alias CapabilityFailureFields Fields admitted by a capability owner, with the original cause kept private.
type alias SandboxFailure Closed error channel shared by sandbox adapters and the invocation owner.
function referenceSandboxFailure() Copy the failure to correlate one execution without mutating shared host errors.
function sandboxFailureMessage() The sole model projection. Transport, parser and raw cause fields stay private.

A location in the submitted program, never in the host’s source.

Signature
new SourceInvalid(args): SourceInvalid;
Parameter Type
args { ref?: string; line: number; column: number; excerpt: string; }
args.ref? string
args.line number
args.column number
args.excerpt string

SourceInvalid

Signature
Data.TaggedError("SourceInvalid")<
SandboxFailureReference & {
readonly line: number;
readonly column: number;
readonly excerpt: string;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("SourceInvalid").ref;
Signature
readonly line: number;
Signature
Data.TaggedError("SourceInvalid").line;
Signature
readonly column: number;
Signature
Data.TaggedError("SourceInvalid").column;
Signature
readonly excerpt: string;
Signature
Data.TaggedError("SourceInvalid").excerpt;

Text captured inside the guest’s own exception handler.

Signature
new GuestThrew(args): GuestThrew;
Parameter Type Description
args { ref?: string; name: string; message: string; missingVariable?: string; transportMessage?: string; } -
args.ref? string -
args.name string -
args.message string -
args.missingVariable? string -
args.transportMessage? string Safe provider envelope carried in the guest exception’s cause, never model text.

GuestThrew

Signature
Data.TaggedError("GuestThrew")<
SandboxFailureReference & {
readonly name: string;
readonly message: string;
readonly missingVariable?: string | undefined;
/ Safe provider envelope carried in the guest exception's cause, never model text. /
readonly transportMessage?: string | undefined;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("GuestThrew").ref;
Signature
readonly optional missingVariable?: string;
Signature
Data.TaggedError("GuestThrew").missingVariable;
Signature
readonly optional transportMessage?: string;

Safe provider envelope carried in the guest exception’s cause, never model text.

Signature
Data.TaggedError("GuestThrew").transportMessage;
Signature
name: string;
Signature
Data.TaggedError("GuestThrew").name;
Signature
message: string;
Signature
Data.TaggedError("GuestThrew").message;

The invocation owner decided its execution budget was spent.

Signature
new DeadlineExceeded(args): DeadlineExceeded;
Parameter Type
args { ref?: string; limitMs: number; elapsedMs: number; acknowledged?: boolean; }
args.ref? string
args.limitMs number
args.elapsedMs number
args.acknowledged? boolean

DeadlineExceeded

Signature
Data.TaggedError("DeadlineExceeded")<
SandboxFailureReference & {
readonly limitMs: number;
readonly elapsedMs: number;
readonly acknowledged?: boolean | undefined;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("DeadlineExceeded").ref;
Signature
readonly limitMs: number;
Signature
Data.TaggedError("DeadlineExceeded").limitMs;
Signature
readonly elapsedMs: number;
Signature
Data.TaggedError("DeadlineExceeded").elapsedMs;
Signature
readonly optional acknowledged?: boolean;
Signature
Data.TaggedError("DeadlineExceeded").acknowledged;

Admission expired before any sandbox work started.

Signature
new SandboxBusy(args): SandboxBusy;
Parameter Type
args { ref?: string; capacity: number; waitedMs: number; }
args.ref? string
args.capacity number
args.waitedMs number

SandboxBusy

Signature
Data.TaggedError("SandboxBusy")<
SandboxFailureReference & {
readonly capacity: number;
readonly waitedMs: number;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("SandboxBusy").ref;
Signature
readonly capacity: number;
Signature
Data.TaggedError("SandboxBusy").capacity;
Signature
readonly waitedMs: number;
Signature
Data.TaggedError("SandboxBusy").waitedMs;
Signature
readonly code: "sandbox-busy" = "sandbox-busy";

Stable contention code, not a sandbox health failure.


The invocation owner accepted cancellation.

Signature
new Cancelled(args): Cancelled;
Parameter Type
args { ref?: string; by: "caller" | "operator"; acknowledged?: boolean; }
args.ref? string
args.by "caller" | "operator"
args.acknowledged? boolean

Cancelled

Signature
Data.TaggedError("Cancelled")<
SandboxFailureReference & {
readonly by: "caller" | "operator";
readonly acknowledged?: boolean | undefined;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("Cancelled").ref;
Signature
readonly by: "caller" | "operator";
Signature
Data.TaggedError("Cancelled").by;
Signature
readonly optional acknowledged?: boolean;
Signature
Data.TaggedError("Cancelled").acknowledged;

Dispatch started, but its transport did not deliver an answer.

Signature
new DispatchLost(args): DispatchLost;
Parameter Type
args { ref?: string; elapsedMs: number; transport: string; errno?: string; rawCause: unknown; }
args.ref? string
args.elapsedMs number
args.transport string
args.errno? string
args.rawCause unknown

DispatchLost

Signature
Data.TaggedError("DispatchLost")<
SandboxFailureReference & {
readonly elapsedMs: number;
readonly transport: string;
readonly errno?: string | undefined;
readonly rawCause: unknown;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("DispatchLost").ref;
Signature
readonly elapsedMs: number;
Signature
Data.TaggedError("DispatchLost").elapsedMs;
Signature
readonly transport: string;
Signature
Data.TaggedError("DispatchLost").transport;
Signature
readonly optional errno?: string;
Signature
Data.TaggedError("DispatchLost").errno;
Signature
readonly rawCause: unknown;
Signature
Data.TaggedError("DispatchLost").rawCause;

The sandbox process could not start or stopped before answering.

Signature
new SandboxCrashed(args): SandboxCrashed;
Parameter Type
args { ref?: string; exit?: number; errno?: string; rawCause: unknown; }
args.ref? string
args.exit? number
args.errno? string
args.rawCause unknown

SandboxCrashed

Signature
Data.TaggedError("SandboxCrashed")<
SandboxFailureReference & {
readonly exit?: number | undefined;
readonly errno?: string | undefined;
readonly rawCause: unknown;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("SandboxCrashed").ref;
Signature
readonly optional exit?: number;
Signature
Data.TaggedError("SandboxCrashed").exit;
Signature
readonly optional errno?: string;
Signature
Data.TaggedError("SandboxCrashed").errno;
Signature
readonly rawCause: unknown;
Signature
Data.TaggedError("SandboxCrashed").rawCause;

A received envelope could not be decoded. Its reason is operator only.

Signature
new BadResponse(args): BadResponse;
Parameter Type
args { ref?: string; reason: string; rawCause: unknown; }
args.ref? string
args.reason string
args.rawCause unknown

BadResponse

Signature
Data.TaggedError("BadResponse")<
SandboxFailureReference & {
readonly reason: string;
readonly rawCause: unknown;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("BadResponse").ref;
Signature
readonly reason: string;
Signature
Data.TaggedError("BadResponse").reason;
Signature
readonly rawCause: unknown;
Signature
Data.TaggedError("BadResponse").rawCause;

A JSON result exceeded Mycelium’s output budget.

Signature
new ResultTooLarge(args): ResultTooLarge;
Parameter Type
args { ref?: string; size: number; }
args.ref? string
args.size number

ResultTooLarge

Signature
Data.TaggedError("ResultTooLarge")<
SandboxFailureReference & {
readonly size: number;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("ResultTooLarge").ref;
Signature
readonly size: number;
Signature
Data.TaggedError("ResultTooLarge").size;

A result could not be represented as JSON.

Signature
new ResultNotJson(args): ResultNotJson;
Parameter Type
args { ref?: string; kind: string; rawCause?: unknown; }
args.ref? string
args.kind string
args.rawCause? unknown

ResultNotJson

Signature
Data.TaggedError("ResultNotJson")<
SandboxFailureReference & {
readonly kind: string;
readonly rawCause?: unknown;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("ResultNotJson").ref;
Signature
readonly kind: string;
Signature
Data.TaggedError("ResultNotJson").kind;
Signature
readonly optional rawCause?: unknown;
Signature
Data.TaggedError("ResultNotJson").rawCause;

Failure at a named capability boundary, with an owner-admitted diagnostic.

Signature
new CapabilityFailed(fields): CapabilityFailed;

Retain the admitted diagnostic for ordinary Error consumers through the same safe projection.

Parameter Type
fields CapabilityFailureFields

CapabilityFailed

Signature
Data.TaggedError(
"CapabilityFailed",
)<CapabilityFailureFields>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("CapabilityFailed").ref;
Signature
readonly namespace: string;
Signature
Data.TaggedError("CapabilityFailed").namespace;
Signature
readonly operation: string;
Signature
Data.TaggedError("CapabilityFailed").operation;
Signature
readonly optional rawCause?: unknown;
Signature
Data.TaggedError("CapabilityFailed").rawCause;
Signature
cause: Readonly<{
kind: "Files" | "Forage" | "InvalidInput" | "Unavailable" | "OperationFailed";
message: string;
}>;
Signature
Data.TaggedError("CapabilityFailed").cause;

A foreign throw violated the typed adapter contract.

Signature
new Unknown(args): Unknown;
Parameter Type
args { ref?: string; rawCause: unknown; }
args.ref? string
args.rawCause unknown

Unknown

Signature
Data.TaggedError("Unknown")<
SandboxFailureReference & {
readonly rawCause: unknown;
}
>.constructor
Signature
readonly optional ref?: string;
Signature
Data.TaggedError("Unknown").ref;
Signature
readonly rawCause: unknown;
Signature
Data.TaggedError("Unknown").rawCause;

SandboxFailureReferencetype alias

Section titled “SandboxFailureReference”
Signature
type SandboxFailureReference = object;

Optional source reference carried by sandbox failures.

Signature
readonly optional ref?: string;

CapabilityDiagnostictype alias

Section titled “CapabilityDiagnostic”
Signature
type CapabilityDiagnostic = Readonly<{
kind: "Files" | "Forage" | "InvalidInput" | "Unavailable" | "OperationFailed";
message: string;
}>;

A capability owner explicitly admits this bounded diagnostic as safe.


CapabilityFailureFieldstype alias

Section titled “CapabilityFailureFields”
Signature
type CapabilityFailureFields = object;

Fields admitted by a capability owner, with the original cause kept private.

Signature
readonly optional ref?: string;
Signature
readonly namespace: string;
Signature
readonly operation: string;
Signature
readonly cause: CapabilityDiagnostic;
Signature
readonly optional rawCause?: unknown;

SandboxFailuretype alias

Section titled “SandboxFailure”
Signature
type SandboxFailure =
| SourceInvalid
| GuestThrew
| DeadlineExceeded
| SandboxBusy
| Cancelled
| DispatchLost
| SandboxCrashed
| BadResponse
| ResultTooLarge
| ResultNotJson
| CapabilityFailed
| Unknown;

Closed error channel shared by sandbox adapters and the invocation owner.

referenceSandboxFailure()function

Section titled “referenceSandboxFailure()”
Signature
function referenceSandboxFailure(failure, ref): SandboxFailure;

Copy the failure to correlate one execution without mutating shared host errors.

Parameter Type
failure SandboxFailure
ref string

SandboxFailure


sandboxFailureMessage()function

Section titled “sandboxFailureMessage()”
Signature
function sandboxFailureMessage(failure, includeReference?): string;

The sole model projection. Transport, parser and raw cause fields stay private.

Parameter Type Default value
failure SandboxFailure undefined
includeReference boolean true

string