Skip to content

particula.execution.scheduler

Resolve direct-import-only, declaration-only scheduling metadata.

This concrete module validates immutable declaration graph declarations before applying enabled-node selection, direction policy, and freshness closure. Resolution is prelaunch-only: it neither loads backends nor enters lifecycle state, allocates resources, executes refreshes, or mutates caller-owned data. Its names are not package exports and must be imported from this module directly.

Attributes

NameDescription
_FRESHNESS_EDGESNo description.
_NAME_PATTERNNo description.
_NUCLEATION_CONDENSATION_EDGESNo description.
_RESOLVER_SCHEDULESNo description.
_SCHEDULE_PROVENANCENo description.

Classes

NameDescription
EnabledNodeSelectionDeclare the complete immutable set of enabled declaration node
NucleationCondensationDirectionDeclare the reviewed nucleation/condensation ordering.
ResolvedTimestepScheduleStore canonical, immutable declaration-only scheduling metadata.
SchedulerProfileDeclare immutable scheduler direction policy without selecting execution.

Functions

NameDescription
_add_freshness_pairsAdd freshness edges only when both endpoints are selected.
_direction_edgeReturn the declared direction as one graph edge.
_raise_unsatisfied_closureRaise the stable error for a missing required predecessor.
_resolve_effective_pairsCombine retained declarations, profile policy, and freshness closure.
_retained_pairsReturn selected declaration edges after enforcing explicit dependency
_validate_profile_directionReject an explicit declaration direction that opposes the profile.
_validate_resolution_inputsValidate public scheduler carriers before declaration resolution.
_validate_schedule_contentValidate canonical schedule ordering, endpoints, and permutation.
_validate_schedule_typesValidate exact immutable schedule container and member types.
_validate_selected_idsReject selected IDs that are absent from an already resolved declaration
is_resolver_produced_scheduleReturn whether a schedule retains its exact resolver-produced graph.
resolve_timestep_scheduleResolve an immutable effective schedule without running any process.

_FRESHNESS_EDGESattributemodule attribute#

_FRESHNESS_EDGES = (
  ('environment_update', 'vapor_pressure_refresh'),
  ('environment_update', 'saturation_refresh'),
  ('gas_update', 'saturation_refresh'),
  ('environment_update', 'brownian_coagulation'),
  ('environment_update', 'wall_loss'),
  ('environment_update', 'nucleation'),
  ('gas_update', 'condensation'),
  ('gas_update', 'dilution'),
  ('gas_update', 'nucleation'),
  ('vapor_pressure_refresh', 'saturation_refresh'),
  ('saturation_refresh', 'condensation'),
  ('saturation_refresh', 'diagnostics')
)

_NAME_PATTERNattributemodule attribute#

_NAME_PATTERN = re.compile('^[a-z][a-z0-9_]*$')

_NUCLEATION_CONDENSATION_EDGESattributemodule attribute#

_NUCLEATION_CONDENSATION_EDGES = frozenset({('nucleation', 'condensation'), ('condensation', 'nucleation')})

_RESOLVER_SCHEDULESattributemodule attribute#

_RESOLVER_SCHEDULES: list[object] = []

_SCHEDULE_PROVENANCEattributemodule attribute#

_SCHEDULE_PROVENANCE = object()

EnabledNodeSelectionclassdataclass#

class EnabledNodeSelection(enabled_node_ids: frozenset[str])

Declare the complete immutable set of enabled declaration node identifiers.

Graph membership is deliberately deferred to schedule resolution, after complete declaration plan validation.

Parameters

NameTypeDescription
enabled_node_idsfrozenset[str]Exact frozenset of syntactically valid node IDs.

enabled_node_idsattributeinstance attribute#

enabled_node_ids: frozenset[str]

__init__method#

def __init__(enabled_node_ids: frozenset[str]) -> None

__post_init__method#

def __post_init__() -> None

Validate selection container and identifier syntax.

NucleationCondensationDirectionclass#

class NucleationCondensationDirection(str, Enum)

Bases: str, Enum

Declare the reviewed nucleation/condensation ordering.

CONDENSATION_THEN_NUCLEATIONattributeclass attributeinstance attribute#

CONDENSATION_THEN_NUCLEATION = 'condensation_then_nucleation'

NUCLEATION_THEN_CONDENSATIONattributeclass attributeinstance attribute#

NUCLEATION_THEN_CONDENSATION = 'nucleation_then_condensation'

ResolvedTimestepScheduleclassdataclass#

class ResolvedTimestepSchedule(nodes: tuple[ProcessNode, ...], dependencies: tuple[DependencyEdge, ...], ordered_node_ids: tuple[str, ...], source_graph: ResolvedProcessGraph | None = None, _provenance: object | None = None)

Store canonical, immutable declaration-only scheduling metadata.

Nodes and dependencies are canonically sorted. The order is a permutation of node IDs created before any lifecycle entry, resource action, or process launch.

Parameters

NameTypeDescription
nodestuple[ProcessNode, ...]Sorted exact tuple of enabled process nodes.
dependenciestuple[DependencyEdge, ...]Sorted exact tuple of effective dependency edges.
ordered_node_idstuple[str, ...]Canonical dependency order for exactly these nodes.

_provenanceattributeclass attributeinstance attribute#

_provenance: object | None = field(default=None, repr=False, compare=False)

dependenciesattributeinstance attribute#

dependencies: tuple[DependencyEdge, ...]

nodesattributeinstance attribute#

nodes: tuple[ProcessNode, ...]

ordered_node_idsattributeinstance attribute#

ordered_node_ids: tuple[str, ...]

source_graphattributeclass attributeinstance attribute#

source_graph: ResolvedProcessGraph | None = field(default=None, repr=False, compare=False)

__init__method#

def __init__(nodes: tuple[ProcessNode, ...], dependencies: tuple[DependencyEdge, ...], ordered_node_ids: tuple[str, ...], source_graph: ResolvedProcessGraph | None = None, _provenance: object | None = None) -> None

__post_init__method#

def __post_init__() -> None

Validate canonical immutable schedule fields.

SchedulerProfileclassdataclass#

class SchedulerProfile(nucleation_condensation_direction: NucleationCondensationDirection)

Declare immutable scheduler direction policy without selecting execution.

The enum represents exactly one reviewed nucleation/condensation direction; it cannot encode both directions or no direction.

Parameters

NameTypeDescription
nucleation_condensation_directionNucleationCondensationDirectionThe one permitted direction policy.

nucleation_condensation_directionattributeinstance attribute#

nucleation_condensation_direction: NucleationCondensationDirection

__init__method#

def __init__(nucleation_condensation_direction: NucleationCondensationDirection) -> None

__post_init__method#

def __post_init__() -> None

Validate the single direction declaration.

_add_freshness_pairsfunction#

def _add_freshness_pairs(pairs: set[tuple[str, str]], enabled: frozenset[str]) -> None

Add freshness edges only when both endpoints are selected.

_direction_edgefunction#

def _direction_edge(profile: SchedulerProfile) -> tuple[str, str]

Return the declared direction as one graph edge.

_raise_unsatisfied_closurefunction#

def _raise_unsatisfied_closure(before_id: str, after_id: str) -> None

Raise the stable error for a missing required predecessor.

_resolve_effective_pairsfunction#

def _resolve_effective_pairs(resolved: ResolvedProcessGraph, selection: EnabledNodeSelection, profile: SchedulerProfile, direction: tuple[str, str]) -> set[tuple[str, str]]

Combine retained declarations, profile policy, and freshness closure.

_retained_pairsfunction#

def _retained_pairs(resolved: ResolvedProcessGraph, enabled: frozenset[str]) -> set[tuple[str, str]]

Return selected declaration edges after enforcing explicit dependency closure.

_validate_profile_directionfunction#

def _validate_profile_direction(resolved: ResolvedProcessGraph, direction: tuple[str, str]) -> None

Reject an explicit declaration direction that opposes the profile.

_validate_resolution_inputsfunction#

def _validate_resolution_inputs(plan: object, selection: object, profile: object) -> None

Validate public scheduler carriers before declaration resolution.

_validate_schedule_contentfunction#

def _validate_schedule_content(schedule: ResolvedTimestepSchedule) -> None

Validate canonical schedule ordering, endpoints, and permutation.

_validate_schedule_typesfunction#

def _validate_schedule_types(schedule: ResolvedTimestepSchedule) -> None

Validate exact immutable schedule container and member types.

_validate_selected_idsfunction#

def _validate_selected_ids(selection: EnabledNodeSelection, resolved: ResolvedProcessGraph) -> None

Reject selected IDs that are absent from an already resolved declaration graph.

is_resolver_produced_schedulefunction#

def is_resolver_produced_schedule(schedule: ResolvedTimestepSchedule, graph: ResolvedProcessGraph) -> bool

Return whether a schedule retains its exact resolver-produced graph.

This internal provenance check prevents a structurally similar hand-built schedule from entering the resident execution boundary.

resolve_timestep_schedulefunction#

def resolve_timestep_schedule(plan: TimestepPlan, selection: EnabledNodeSelection, profile: SchedulerProfile) -> ResolvedTimestepSchedule

Resolve an immutable effective schedule without running any process.

After exact carrier-type checks, complete declaration graph validation happens before selection or profile inspection. This function then applies selected IDs, direction policy, required freshness closure, and canonical topology ordering. It returns metadata only and performs no lifecycle, resource, or GPU work.

Parameters

NameTypeDescription
planTimestepPlanExact declaration plan declaration.
selectionEnabledNodeSelectionExact enabled-node selection.
profileSchedulerProfileExact immutable direction policy.

Returns

ResolvedTimestepSchedule
A new canonical schedule with no disabled dependency endpoints.

Raises

TypeError
If a carrier is not its exact declared type.
ValueError
If selection, direction, closure, or effective topology is invalid. No input is mutated when resolution fails; no rollback is required because resolution has no side effects.