PtcRunner.Kernel.ResourceRegistrar (PtcRunner v0.14.0)

Copy Markdown View Source

Scoped acquisition handle for one provider session.

A registrar belongs to one PtcRunner.Kernel.ProviderSession acquisition scope and is inert until activated. Successful acquisition commits one provider close operation for the scope; failed acquisition aborts it. Each scope has a private signal owner for process roots. A root monitors that owner and registers synchronously before its start operation returns.

A handle cannot be retargeted: every field is covered by the sealed attestation valid?/1 checks on entry, so mutating one invalidates it. It can be constructednew/8 attests whatever arguments it is given, and PtcRunner.Kernel.Attestation is explicitly not a security boundary against code running in the same VM. What contains a minted handle is the session's own authority rather than this struct: it honours only scope references it opened, fences activate and commit with the deadline it sealed for itself rather than the one the handle carries, and clamps an abort to a budget it installed.

Summary

Functions

Removes an adopted terminalization root from scope cleanup.

Returns the private signal owner for roots in this acquisition scope.

Registers the calling local process as a root of this active scope.

Types

t()

@opaque t()

Functions

handoff_root(registrar, root)

@spec handoff_root(t() | nil, pid()) ::
  :ok | {:error, :resource_registrar_unavailable}

Removes an adopted terminalization root from scope cleanup.

owner(registrar)

@spec owner(t()) :: pid() | nil

Returns the private signal owner for roots in this acquisition scope.

register_root(registrar)

@spec register_root(t() | nil) :: :ok | {:error, :resource_registrar_unavailable}

Registers the calling local process as a root of this active scope.

A provider process calls this from its init callback after monitoring owner/1 and before its start operation returns.

valid?(registrar)

@spec valid?(term()) :: boolean()