# Execution context

Maligator 0.1.0-alpha.35 · Experimental
Source revision: c27b6cae5dcbe612a78ebe5388652738e35f229f
Canonical: https://maligator.ddv.tools/api/process

Read the compile-time command, target, and resolved application configuration. No surface flag is required. Runtime arguments, environment, working directory, and PID are separate process values.

Import from `maligator:process`. This API is experimental. Load declarations as described in [Use TypeScript](/guides/typescript). Platform imports do not require a surface flag.
`execution` is a deeply immutable snapshot of the command and resolved configuration used to compile the application. It is not the launched process's current arguments, environment, working directory, or PID. Use supported Node process APIs for runtime values.

```typescript context.ts
import { execution } from "maligator:process";

console.log(execution.command);
console.log(execution.production);
console.log(execution.config.engine.regexp);
```

Run `maligator run context.ts` to observe `run`, `false`, and the configured RegExp policy. `build --production` records production intent; profiling uses production optimizations without changing the original command's intent. Snapshot values remain fixed when a built executable is launched with different arguments or environment variables.

See [CLI options](/api/cli) for the commands that populate the snapshot and [production builds](/guides/production) for the difference between build-time and runtime settings.

<a id="execution"></a>

## execution

An immutable snapshot of the workflow, target, and resolved configuration, fixed before compilation. Known property reads can specialize application branches. Runtime arguments, environment, working directory, and PID are outside this snapshot. Profiling does not change production intent. Static and dynamic imports share its identity, and reflection sees the complete deeply frozen shape.

```typescript
export const execution: Execution;
```

Types: [`Execution`](/api/process#Execution)



```typescript
import { execution } from "maligator:process";

if (execution.compiled && execution.production) {
  console.log("native production application");
}
```

```typescript
import { execution } from "maligator:process";

if (execution.command === "test") {
  console.log(execution.options.repeat);
}
```

<a id="ExecutionProfile"></a>

## ExecutionProfile

Profiling instrumentation: none by default; sampling for --profile; compiler for --profile=compiler. Both profiling modes select full optimization without selecting production application behavior.

```typescript
type ExecutionProfile = "none" | "sampling" | "compiler";
```


<a id="ExecutionTarget"></a>

## ExecutionTarget

The fixed platform contract of the application image.
<details><summary>Full TypeScript declaration</summary>


```typescript
type ExecutionTarget = {
	/**
	 * Application operating-system target, not the compiler host. Native builds use
	 * darwin or linux; WebAssembly uses wasi.
	 */
	readonly platform: "darwin" | "linux" | "wasi";
	/**
	 * Application architecture. Cross builds report the destination architecture.
	 */
	readonly arch: "arm64" | "x64" | "wasm32";
	/**
	 * Resolved target triple, including when --target was omitted; for example
	 * aarch64-apple-darwin.
	 */
	readonly triple: string;
};
```

</details>


<a id="ExecutionTarget.platform"></a>

### ExecutionTarget.platform

Application operating-system target, not the compiler host. Native builds use
darwin or linux; WebAssembly uses wasi.

```typescript
readonly platform: "darwin" | "linux" | "wasi";
```


<a id="ExecutionTarget.arch"></a>

### ExecutionTarget.arch

Application architecture. Cross builds report the destination architecture.

```typescript
readonly arch: "arm64" | "x64" | "wasm32";
```


<a id="ExecutionTarget.triple"></a>

### ExecutionTarget.triple

Resolved target triple, including when --target was omitted; for example
aarch64-apple-darwin.

```typescript
readonly triple: string;
```


<a id="ExecutionOptions"></a>

## ExecutionOptions

Options shared by build, run, and dev. Output paths, verbosity, and compiler scheduling are tool settings and are not exposed.
<details><summary>Full TypeScript declaration</summary>


```typescript
type ExecutionOptions = {
	/**
	 * Selected application profiling instrumentation. Defaults to none; does not imply
	 * execution.production.
	 */
	readonly profile: ExecutionProfile;
};
```

Types: [`ExecutionProfile`](/api/process#ExecutionProfile)


</details>


<a id="ExecutionOptions.profile"></a>

### ExecutionOptions.profile

Selected application profiling instrumentation. Defaults to none; does not imply
execution.production.

```typescript
readonly profile: ExecutionProfile;
```

Types: [`ExecutionProfile`](/api/process#ExecutionProfile)



<a id="TestExecutionOptions"></a>

## TestExecutionOptions

Normalized test settings, fixed for the application image. Changing these values invalidates specialized test artifacts.
<details><summary>Full TypeScript declaration</summary>


```typescript
type TestExecutionOptions = {
	/**
	 * Selected test profiling instrumentation. Defaults to none; profiling preserves
	 * command: test.
	 */
	readonly profile: ExecutionProfile;
	/**
	 * Hierarchical test-name filter from --run, or null when all discovered names are
	 * eligible.
	 */
	readonly nameFilter: string | null;
	/**
	 * Number of requested test repetitions from --repeat; defaults to 1. This is not the
	 * currently executing repetition.
	 */
	readonly repeat: number;
	/**
	 * Whether --bail stops the test run after its first failure. Defaults to false.
	 */
	readonly bail: boolean;
	/**
	 * Test callback timeout in milliseconds from --timeout. Defaults to 5000.
	 */
	readonly timeoutMs: number;
	/**
	 * Resolved positive shuffle seed, or null when shuffling is disabled. --shuffle
	 * without a seed chooses it once before compilation; the same seed drives execution
	 * and cache identity.
	 */
	readonly shuffleSeed: number | null;
};
```

Types: [`ExecutionProfile`](/api/process#ExecutionProfile)


</details>


<a id="TestExecutionOptions.profile"></a>

### TestExecutionOptions.profile

Selected test profiling instrumentation. Defaults to none; profiling preserves
command: test.

```typescript
readonly profile: ExecutionProfile;
```

Types: [`ExecutionProfile`](/api/process#ExecutionProfile)



<a id="TestExecutionOptions.nameFilter"></a>

### TestExecutionOptions.nameFilter

Hierarchical test-name filter from --run, or null when all discovered names are
eligible.

```typescript
readonly nameFilter: string | null;
```


<a id="TestExecutionOptions.repeat"></a>

### TestExecutionOptions.repeat

Number of requested test repetitions from --repeat; defaults to 1. This is not the
currently executing repetition.

```typescript
readonly repeat: number;
```


<a id="TestExecutionOptions.bail"></a>

### TestExecutionOptions.bail

Whether --bail stops the test run after its first failure. Defaults to false.

```typescript
readonly bail: boolean;
```


<a id="TestExecutionOptions.timeoutMs"></a>

### TestExecutionOptions.timeoutMs

Test callback timeout in milliseconds from --timeout. Defaults to 5000.

```typescript
readonly timeoutMs: number;
```


<a id="TestExecutionOptions.shuffleSeed"></a>

### TestExecutionOptions.shuffleSeed

Resolved positive shuffle seed, or null when shuffling is disabled. --shuffle
without a seed chooses it once before compilation; the same seed drives execution
and cache identity.

```typescript
readonly shuffleSeed: number | null;
```


<a id="ExecutionEngineConfig"></a>

## ExecutionEngineConfig

Resolved engine policies. These describe build inputs, never post-DCE native feature inclusion.
<details><summary>Full TypeScript declaration</summary>


```typescript
type ExecutionEngineConfig = {
	/**
	 * Requested primordial mutation policy. Defaults to locked. The execution snapshot
	 * itself is immutable in either policy.
	 */
	readonly primordials: "locked" | "mutable";
	/**
	 * Dynamic compilation policy. false (default) rejects eval/Function execution at
	 * runtime; true enables the runtime compiler; compile-check additionally rejects
	 * statically visible dynamic compilation calls.
	 */
	readonly eval: boolean | "compile-check";
	/**
	 * Whether additional realms are enabled. Defaults to false.
	 */
	readonly realms: boolean;
	/**
	 * Whether regular expressions are enabled. Defaults to true.
	 */
	readonly regexp: boolean;
	/**
	 * Whether Temporal and its required data are enabled. Defaults to false.
	 */
	readonly temporal: boolean;
	/**
	 * Requested Intl policy after applying configuration defaults.
	 */
	readonly intl: {
		/**
		 * Whether Intl is enabled. Defaults to false.
		 */
		readonly enabled: boolean;
		/**
		 * Requested Intl service names. An empty array selects the default complete service
		 * set when Intl is enabled; it does not mean every service survived tree shaking.
		 */
		readonly features: ReadonlyArray<string>;
		/**
		 * Requested locale selection. Defaults to an empty array. Unsupported locale
		 * selections are rejected by configuration validation.
		 */
		readonly languages: ReadonlyArray<string>;
	};
};
```

</details>


<a id="ExecutionEngineConfig.primordials"></a>

### ExecutionEngineConfig.primordials

Requested primordial mutation policy. Defaults to locked. The execution snapshot
itself is immutable in either policy.

```typescript
readonly primordials: "locked" | "mutable";
```


<a id="ExecutionEngineConfig.eval"></a>

### ExecutionEngineConfig.eval

Dynamic compilation policy. false (default) rejects eval/Function execution at
runtime; true enables the runtime compiler; compile-check additionally rejects
statically visible dynamic compilation calls.

```typescript
readonly eval: boolean | "compile-check";
```


<a id="ExecutionEngineConfig.realms"></a>

### ExecutionEngineConfig.realms

Whether additional realms are enabled. Defaults to false.

```typescript
readonly realms: boolean;
```


<a id="ExecutionEngineConfig.regexp"></a>

### ExecutionEngineConfig.regexp

Whether regular expressions are enabled. Defaults to true.

```typescript
readonly regexp: boolean;
```


<a id="ExecutionEngineConfig.temporal"></a>

### ExecutionEngineConfig.temporal

Whether Temporal and its required data are enabled. Defaults to false.

```typescript
readonly temporal: boolean;
```


<a id="ExecutionEngineConfig.intl"></a>

### ExecutionEngineConfig.intl

Requested Intl policy after applying configuration defaults.
<details><summary>Full TypeScript declaration</summary>


```typescript
readonly intl: {
		/**
		 * Whether Intl is enabled. Defaults to false.
		 */
		readonly enabled: boolean;
		/**
		 * Requested Intl service names. An empty array selects the default complete service
		 * set when Intl is enabled; it does not mean every service survived tree shaking.
		 */
		readonly features: ReadonlyArray<string>;
		/**
		 * Requested locale selection. Defaults to an empty array. Unsupported locale
		 * selections are rejected by configuration validation.
		 */
		readonly languages: ReadonlyArray<string>;
	};
```

</details>


<a id="ExecutionEngineConfig.intl.enabled"></a>

### ExecutionEngineConfig.intl.enabled

Whether Intl is enabled. Defaults to false.

```typescript
readonly enabled: boolean;
```


<a id="ExecutionEngineConfig.intl.features"></a>

### ExecutionEngineConfig.intl.features

Requested Intl service names. An empty array selects the default complete service
set when Intl is enabled; it does not mean every service survived tree shaking.

```typescript
readonly features: ReadonlyArray<string>;
```


<a id="ExecutionEngineConfig.intl.languages"></a>

### ExecutionEngineConfig.intl.languages

Requested locale selection. Defaults to an empty array. Unsupported locale
selections are rejected by configuration validation.

```typescript
readonly languages: ReadonlyArray<string>;
```


<a id="ExecutionConfig"></a>

## ExecutionConfig

Resolved application engine, Web/Node surface, and module policies. Excludes build-host paths, asset declarations, and output controls.
<details><summary>Full TypeScript declaration</summary>


```typescript
type ExecutionConfig = {
	/**
	 * Engine configuration after validation and default resolution.
	 */
	readonly engine: ExecutionEngineConfig;
	/**
	 * Global and compatibility surface policy. maligator:process requires no enable
	 * flag.
	 */
	readonly surface: {
		/**
		 * Whether Web globals are requested. Defaults to false; native module imports are
		 * independent of this global installation policy.
		 */
		readonly webPlatform: boolean;
		/**
		 * Whether Node compatibility, globals, and node: module resolution are requested.
		 * Defaults to false.
		 */
		readonly node: boolean;
	};
	/**
	 * Resolved module-resolution policy.
	 */
	readonly modules: {
		/**
		 * Exact module-specifier replacements from configuration. Defaults to an empty
		 * object. Alias entries are immutable own data properties.
		 */
		readonly aliases: Readonly<Record<string, string>>;
	};
};
```

Types: [`ExecutionEngineConfig`](/api/process#ExecutionEngineConfig)


</details>


<a id="ExecutionConfig.engine"></a>

### ExecutionConfig.engine

Engine configuration after validation and default resolution.

```typescript
readonly engine: ExecutionEngineConfig;
```

Types: [`ExecutionEngineConfig`](/api/process#ExecutionEngineConfig)



<a id="ExecutionConfig.surface"></a>

### ExecutionConfig.surface

Global and compatibility surface policy. maligator:process requires no enable
flag.
<details><summary>Full TypeScript declaration</summary>


```typescript
readonly surface: {
		/**
		 * Whether Web globals are requested. Defaults to false; native module imports are
		 * independent of this global installation policy.
		 */
		readonly webPlatform: boolean;
		/**
		 * Whether Node compatibility, globals, and node: module resolution are requested.
		 * Defaults to false.
		 */
		readonly node: boolean;
	};
```

</details>


<a id="ExecutionConfig.surface.webPlatform"></a>

### ExecutionConfig.surface.webPlatform

Whether Web globals are requested. Defaults to false; native module imports are
independent of this global installation policy.

```typescript
readonly webPlatform: boolean;
```


<a id="ExecutionConfig.surface.node"></a>

### ExecutionConfig.surface.node

Whether Node compatibility, globals, and node: module resolution are requested.
Defaults to false.

```typescript
readonly node: boolean;
```


<a id="ExecutionConfig.modules"></a>

### ExecutionConfig.modules

Resolved module-resolution policy.
<details><summary>Full TypeScript declaration</summary>


```typescript
readonly modules: {
		/**
		 * Exact module-specifier replacements from configuration. Defaults to an empty
		 * object. Alias entries are immutable own data properties.
		 */
		readonly aliases: Readonly<Record<string, string>>;
	};
```

</details>


<a id="ExecutionConfig.modules.aliases"></a>

### ExecutionConfig.modules.aliases

Exact module-specifier replacements from configuration. Defaults to an empty
object. Alias entries are immutable own data properties.

```typescript
readonly aliases: Readonly<Record<string, string>>;
```


<a id="ExecutionCommon"></a>

## ExecutionCommon

Fields shared by every execution workflow. All nested objects and arrays are deeply frozen at runtime.
<details><summary>Full TypeScript declaration</summary>


```typescript
type ExecutionCommon = {
	/**
	 * Explicit production application intent. True only when production was selected for
	 * the application; independent of NODE_ENV, profiling, and optimization. Currently
	 * --production is a build option. Defaults to false.
	 */
	readonly production: boolean;
	/**
	 * Whether the application image executes as native compiled code. A native
	 * executable hosting an interpreted image reports false. This is fixed for the
	 * image, not a query about the current stack frame or an eval-created function.
	 */
	readonly compiled: boolean;
	/**
	 * Actual selected frontend optimization policy. Ordinary commands currently use
	 * development; production builds and profiling use full. Backend choice is
	 * independent.
	 */
	readonly optimization: "development" | "full";
	/**
	 * Resolved application target. The compiler's host platform is not substituted
	 * during a cross build.
	 */
	readonly target: ExecutionTarget;
	/**
	 * Validated configuration policies with defaults applied, captured before
	 * compilation.
	 */
	readonly config: ExecutionConfig;
};
```

Types: [`ExecutionTarget`](/api/process#ExecutionTarget), [`ExecutionConfig`](/api/process#ExecutionConfig)


</details>


<a id="ExecutionCommon.production"></a>

### ExecutionCommon.production

Explicit production application intent. True only when production was selected for
the application; independent of NODE_ENV, profiling, and optimization. Currently
--production is a build option. Defaults to false.

```typescript
readonly production: boolean;
```


<a id="ExecutionCommon.compiled"></a>

### ExecutionCommon.compiled

Whether the application image executes as native compiled code. A native
executable hosting an interpreted image reports false. This is fixed for the
image, not a query about the current stack frame or an eval-created function.

```typescript
readonly compiled: boolean;
```


<a id="ExecutionCommon.optimization"></a>

### ExecutionCommon.optimization

Actual selected frontend optimization policy. Ordinary commands currently use
development; production builds and profiling use full. Backend choice is
independent.

```typescript
readonly optimization: "development" | "full";
```


<a id="ExecutionCommon.target"></a>

### ExecutionCommon.target

Resolved application target. The compiler's host platform is not substituted
during a cross build.

```typescript
readonly target: ExecutionTarget;
```

Types: [`ExecutionTarget`](/api/process#ExecutionTarget)



<a id="ExecutionCommon.config"></a>

### ExecutionCommon.config

Validated configuration policies with defaults applied, captured before
compilation.

```typescript
readonly config: ExecutionConfig;
```

Types: [`ExecutionConfig`](/api/process#ExecutionConfig)



<a id="Execution"></a>

## Execution

An immutable application-image description, discriminated by command. The command describes the workflow that prepared the image, not a transient process phase.

```typescript
type Execution = ExecutionCommon & ({
	/**
	 * Prepared by maligator build. Remains build when the resulting executable runs
	 * later; application statements are not executed by the build itself.
	 */
	readonly command: "build";
	/**
	 * Normalized build options relevant to application execution.
	 */
	readonly options: ExecutionOptions;
} | {
	/**
	 * Prepared by maligator run or maligator dev. dev denotes the watch/restart workflow
	 * even when profiling selects native compilation.
	 */
	readonly command: "run" | "dev";
	/**
	 * Normalized run/dev options. Arguments after -- remain runtime argv and do not
	 * specialize application compilation.
	 */
	readonly options: ExecutionOptions;
} | {
	/**
	 * Prepared by maligator test. Preserved for interpreted tests, profiled native
	 * tests, and every fragment of the test application.
	 */
	readonly command: "test";
	/**
	 * Normalized test options. Narrow command to test before accessing test-only fields.
	 */
	readonly options: TestExecutionOptions;
});
```

Types: [`ExecutionOptions`](/api/process#ExecutionOptions), [`TestExecutionOptions`](/api/process#TestExecutionOptions), [`ExecutionCommon`](/api/process#ExecutionCommon)


