PtcRunner.Kernel.Environment (PtcRunner v0.15.0)

Copy Markdown View Source

Internal shared validator for workflow and mission environment constructors.

It verifies bundle attestations, JSON-like data, capability identity, reserved routes, and bundle tool requirements. The public environment structs remain distinct even though they share this validation path.

Summary

Functions

Validates common environment fields and returns normalized attributes.

Returns bounded metadata for every installed capability, regardless of prompt visibility.

Returns the whole-environment capability view.

Returns the single-capability view one dispatch callback needs.

Returns the attested component catalog for environment, if present.

Returns sorted model-visible capability metadata for one environment.

Functions

assemble(bundle, capabilities, data, kind, opts \\ [])

Validates common environment fields and returns normalized attributes.

opts carries :authorization, the workflow package authority that decides private diagnostic routes; :shipped_component_ids, the shipped library selections the bundle represents; and :inspect_only, which skips recorded tool-requirement checks for compile-and-inspect sessions.

capability_contracts(map)

@spec capability_contracts(map()) :: %{required(binary()) => map()}

Returns bounded metadata for every installed capability, regardless of prompt visibility.

capability_view(map)

Returns the whole-environment capability view.

Dispatch reads nothing from an environment but :capabilities. A callback handed to a sandboxed evaluation must capture a view rather than the environment itself: spawn does not preserve sharing, so capturing the environment would copy its frozen bundle once per capability callback.

Only the discovery routes need every capability. A callback that dispatches one capability must capture capability_view/2 instead — capturing the whole map from each of them costs the hand-over O(capabilities²), which a tool-rich MCP environment can blow the sandbox setup ceiling with before evaluation starts.

capability_view(name, capability)

Returns the single-capability view one dispatch callback needs.

Dispatcher.dispatch/8 resolves name against the :capabilities of the value it is given and reads nothing else from it, so a callback bound to one capability can carry only that capability and dispatch identically.

catalog(arg1)

@spec catalog(map()) :: PtcRunner.Kernel.ComponentCatalog.t() | nil

Returns the attested component catalog for environment, if present.

metadata(map)

Returns sorted model-visible capability metadata for one environment.