cayu.environments.deferred
Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.
DeferredMaterialization
Section titled “DeferredMaterialization”from cayu.environments import DeferredMaterializationShared single-flight state behind one deferred runner and binding.
materialize(mode) is factory-owned and returns the exact runner plus the
real binding to run against it. It must reuse the factory’s ordinary
creation path so admission and isolation evidence match an eager start.
dispose_unmaterialized removes a resource a crashed process created but
never bound; it runs at finalization when this process never materialized.
init (method)
Section titled “init (method)”DeferredMaterialization.__init__(materialize: MaterializeCallable, *, default_cwd: str, placeholder_workspace: Callable[[Runner], Workspace | None] | None=None, configured_candidate: Callable[[ExecutionRequirements], ExecutionAdmissionCandidate | None] | None=None, environment_authority: ExecutionEnvironmentAuthority | None=None, dispose_unmaterialized: Callable[[], Awaitable[None]] | None=None, isolation: str='unknown') -> Noneis_materialized (property)
Section titled “is_materialized (property)”DeferredMaterialization.is_materialized() -> boolmaterialized_runner (property)
Section titled “materialized_runner (property)”DeferredMaterialization.materialized_runner() -> Runner | NoneThe live runner once created, even before its first-use bind.
attach_observer (method)
Section titled “attach_observer (method)”DeferredMaterialization.attach_observer(observer: MaterializationObserver | None) -> NoneReceive started/completed/failed notifications (runtime-owned).
attach_admission (method)
Section titled “attach_admission (method)”DeferredMaterialization.attach_admission(admission: MaterializationAdmission | None) -> NoneRun the runtime’s live admission on the new runner before it is used.
A refusal raises; the runner is closed and the triggering call fails.
materialize (method)
Section titled “materialize (method)”async DeferredMaterialization.materialize(mode: MaterializationMode='use') -> RunnerReturn the materialized runner, creating and binding it once.
Release source · Runtime guarantees · Capability guides
DeferredRunner
Section titled “DeferredRunner”from cayu.environments import DeferredRunnerA runner that materializes on first command execution.
Command, workspace and admission calls that need a live target materialize once and then delegate to the exact runner the factory created. Admission for requirements that only need declared evidence is answered from the factory’s configured candidate, so session start dispatches nothing. Requirements that need live evidence (declared executables) materialize eagerly at session start, exactly like an eager environment.
Bases: Runner.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
isolation |
str |
'unknown' |
default_cwd |
str |
'/' |
system_execution_mode |
RunnerSystemExecutionMode |
'shared' |
workload_authority (method)
Section titled “workload_authority (method)”DeferredRunner.workload_authority(name: str) -> RunnerWorkloadAuthority | NoneReturn runner-owned authority for an exact provisioned workload.
execution_environment_authority (method)
Section titled “execution_environment_authority (method)”DeferredRunner.execution_environment_authority() -> ExecutionEnvironmentAuthorityoutput_secret_values_present (method)
Section titled “output_secret_values_present (method)”DeferredRunner.output_secret_values_present() -> bool | Nonebrowser_control_endpoint_reachable (method)
Section titled “browser_control_endpoint_reachable (method)”DeferredRunner.browser_control_endpoint_reachable(endpoint: str) -> bool | NoneReport whether the guest can dial a browser control or recording endpoint.
None makes no declaration: reachability then rests on deployment
configuration, as with Docker’s colocated control-server alias. A runner
whose guest has a fixed, verified control path returns False for
every endpoint outside it, so no control credential is sent there.
browser_recording_supported (method)
Section titled “browser_recording_supported (method)”DeferredRunner.browser_recording_supported() -> boolDeclare that this runner captures and finalizes browser recordings.
execution_profile_identity (property)
Section titled “execution_profile_identity (property)”DeferredRunner.execution_profile_identity() -> ExecutionProfileBehaviorIdentity | NoneReturn a stable application declaration, or None when non-portable.
preflight_exec (method)
Section titled “preflight_exec (method)”DeferredRunner.preflight_exec(command: ExecCommand, **kwargs: Any) -> Noneexec (method)
Section titled “exec (method)”async DeferredRunner.exec(command: ExecCommand, *, cwd: str | None=None, env: dict[str, str] | None=None, env_remove: tuple[str, ...]=(), timeout_s: int | None=None, stdin: str | None=None, output_limit_bytes: int | None=DEFAULT_EXEC_OUTPUT_LIMIT_BYTES) -> ExecResultexec_redacted (method)
Section titled “exec_redacted (method)”async DeferredRunner.exec_redacted(command: ExecCommand, **kwargs: Any) -> ExecResultexec_system (method)
Section titled “exec_system (method)”async DeferredRunner.exec_system(command: ExecCommand, **kwargs: Any) -> ExecResultclose (method)
Section titled “close (method)”async DeferredRunner.close() -> Noneawait_pending_command_settlement (method)
Section titled “await_pending_command_settlement (method)”async DeferredRunner.await_pending_command_settlement() -> boolrefresh_execution_admission (method)
Section titled “refresh_execution_admission (method)”async DeferredRunner.refresh_execution_admission() -> Noneexecution_admission_candidate (method)
Section titled “execution_admission_candidate (method)”DeferredRunner.execution_admission_candidate() -> ExecutionAdmissionCandidate | Nonecollect_execution_admission_candidate (method)
Section titled “collect_execution_admission_candidate (method)”async DeferredRunner.collect_execution_admission_candidate() -> ExecutionAdmissionCandidate | NoneCollect final evidence after lifecycle-owned mutating setup completes.
The default adapts existing side-effect-free snapshot implementations. Runners whose evidence depends on live external state override this hook and complete or positively transfer settlement ownership for every dispatched probe before returning or raising for any reason.
execution_admission_candidate_for (method)
Section titled “execution_admission_candidate_for (method)”DeferredRunner.execution_admission_candidate_for(requirements: ExecutionRequirements) -> ExecutionAdmissionCandidate | Noneexecution_admission_observer (method)
Section titled “execution_admission_observer (method)”DeferredRunner.execution_admission_observer(requirements: ExecutionRequirements) -> RunnerExecutionAdmissionObservercollect_execution_admission_candidate_for (method)
Section titled “collect_execution_admission_candidate_for (method)”async DeferredRunner.collect_execution_admission_candidate_for(requirements: ExecutionRequirements) -> ExecutionAdmissionCandidate | NoneCollect final request-bound evidence under lifecycle ownership.
Requirements are input, never proof. Implementations must isolate concurrent requirement sets and settle or positively transfer every dispatched probe under the same contract as the ordinary collector.
resource_key (property)
Section titled “resource_key (property)”DeferredRunner.resource_key() -> tuple[object, ...] | Noneis_closed (property)
Section titled “is_closed (property)”DeferredRunner.is_closed() -> boolWhether terminal runner finalization has completed.
lifecycle_state (property)
Section titled “lifecycle_state (property)”DeferredRunner.lifecycle_state() -> RunnerLifecycleStateObserve execution eligibility without exposing provider internals.
workspace_capability (method)
Section titled “workspace_capability (method)”DeferredRunner.workspace_capability(capability_type)binary_stream_capability (method)
Section titled “binary_stream_capability (method)”DeferredRunner.binary_stream_capability() -> RunnerBinaryStreamCapability | Nonereopen_exec (method)
Section titled “reopen_exec (method)”DeferredRunner.reopen_exec() -> NoneClear an intentional execution fence on an otherwise-open runner.
This is not recovery authority for inconclusive command cleanup. Poisoned instances cannot be reopened, including after a late cleanup acknowledgement; a new independently verified allocation owner is needed.
resolve_cwd (method)
Section titled “resolve_cwd (method)”DeferredRunner.resolve_cwd(cwd: str | None=None) -> straenter (method)
Section titled “aenter (method)”async DeferredRunner.__aenter__() -> Selfaexit (method)
Section titled “aexit (method)”async DeferredRunner.__aexit__(exc_type: Any, exc_val: Any, exc_tb: Any) -> boolinit (method)
Section titled “init (method)”DeferredRunner.__init__(state: DeferredMaterialization, *, default_cwd: str, configured_candidate: Callable[[ExecutionRequirements], ExecutionAdmissionCandidate | None] | None, environment_authority: ExecutionEnvironmentAuthority | None, isolation: str) -> Nonematerialization (property)
Section titled “materialization (property)”DeferredRunner.materialization() -> DeferredMaterializationexec_stream (method)
Section titled “exec_stream (method)”async DeferredRunner.exec_stream(command: ExecCommand, *, cwd: str | None=None, env: dict[str, str] | None=None, env_remove: tuple[str, ...]=(), timeout_s: int | None=None, stdin: BinaryIO | None=None, stdout: BinaryIO | None=None, stdout_limit_bytes: int | None=None, output_limit_bytes: int | None=DEFAULT_EXEC_OUTPUT_LIMIT_BYTES) -> ExecResultRelease source · Runtime guarantees · Capability guides
DeferredWorkspaceBinding
Section titled “DeferredWorkspaceBinding”from cayu.environments import DeferredWorkspaceBindingBind nothing at session start; run the real binding at materialization.
Finalization, recovery and abandonment delegate to the real binding once the environment materialized, and are no-ops (apart from disposing an unbound resource left by a crashed process) when it never did.
Bases: WorkspaceBinding.
bind (method)
Section titled “bind (method)”async DeferredWorkspaceBinding.bind(workspace: Workspace | None, runner: Runner | None, *, session_id: str, agent_name: str | None=None, environment_name: str | None=None, metadata: dict[str, Any] | None=None) -> BoundWorkspacefinalize (method)
Section titled “finalize (method)”async DeferredWorkspaceBinding.finalize(bound: BoundWorkspace, *, outcome: str | None=None, metadata: dict[str, Any] | None=None) -> WorkspaceSnapshot | Noneobserve_revision (method)
Section titled “observe_revision (method)”async DeferredWorkspaceBinding.observe_revision(bound: BoundWorkspace) -> WorkspaceRevisionObservationObserve the materialized workspace under this binding’s identity.
The runtime registered this binding, with the session-start placeholder workspace, so it expects that identity. The real binding’s observation describes the same workspace once materialized and is re-stamped with it. Before materialization nothing exists to observe: unsupported.
input_capability (method)
Section titled “input_capability (method)”DeferredWorkspaceBinding.input_capability() -> ImmutableInputAdapterCapabilityDescribe how this binding exposes environment input bytes.
observe_writer_isolation (method)
Section titled “observe_writer_isolation (method)”DeferredWorkspaceBinding.observe_writer_isolation(bound: BoundWorkspace) -> WorkspaceWriterIsolationEvidenceabandon (method)
Section titled “abandon (method)”DeferredWorkspaceBinding.abandon(bound: BoundWorkspace) -> boolinit (method)
Section titled “init (method)”DeferredWorkspaceBinding.__init__(state: DeferredMaterialization) -> Nonematerialization (property)
Section titled “materialization (property)”DeferredWorkspaceBinding.materialization() -> DeferredMaterializationRelease source · Runtime guarantees · Capability guides
EnvironmentMaterializationError
Section titled “EnvironmentMaterializationError”from cayu.environments import EnvironmentMaterializationErrorA deferred environment could not be created, admitted or bound.
The triggering tool call fails with this error; the session stays usable and a later runner use attempts materialization again.
Bases: RunnerUnavailableError.
init (method)
Section titled “init (method)”EnvironmentMaterializationError.__init__(message: str, *, reason: str) -> None