Expand description
engine orchestration: load, validate, plan, apply.
Re-exports§
pub use external::run_external_adapter;pub use external::ExternalAdapter;pub use external::ExternalEnvelope;pub use external::ExternalEnvelopeRef;pub use external::ExternalObject;pub use external::ExternalRequest;pub use external::ExternalRequestRef;pub use external::ExternalResponse;pub use external::EXTERNAL_PROTOCOL_VERSION;pub use journal::Journal;
Modules§
- external
- helpers for implementing external adapters.
- journal
- Keep track of successfully applied ops to enable resume after an error.
- mapping
- shared mapping helpers used by multiple adapters.
Macros§
- alembic_
external_ main - convenience macro to define an external adapter main.
Structs§
- Applied
Op - result for a single applied operation.
- Apply
Report - aggregated apply report.
- Changed
Entry - an object present in both intent and backend, but with diverging fields.
- Drift
Entry - an object that exists on only one side of the diff (missing or extra).
- Drift
Report - read-only report of how observed backend state diverges from declared intent.
- Field
Change - field-level change for an update op.
- Import
Report - MapSpec
- a map specification: the target schema plus the transformation rules.
- Observed
Object - observed backend object representation.
- Observed
State - observed backend state indexed by id and key.
- Plan
- full plan document.
- Plan
Summary - high-level summary of plan operations.
- Provision
Report - report from ensure_schema provisioning.
- Retry
Apply Result - State
Data - on-disk state schema.
- State
Mappings - per-type
backend-id -> uidmap for read-side ref normalization. - State
Store - state store wrapper with load/save helpers.
- Transforms
Spec - the
transforms:block of a map spec: starlark source from a file or inline. exactly one of the two must be set.
Enums§
- Adapter
Apply Error - Backend
- a constructed backend, tagged with its capability.
- Backend
Id - generic backend identifier (integer or string/uuid).
- Op
- plan operation.
- Postgres
TlsMode - TLS configuration for postgres state backend connections.
Traits§
- Adapter
- full adapter contract for read+write backends; may also provision schema.
- Emitter
- write capability: apply a plan’s operations.
- Observer
- read capability: observe backend state.
- Retry
Apply Driver
Functions§
- apply_
non_ delete_ journaled - journal-wiring shared by the internal apply-adapters: build the journal from
state, run the retry loop, and return the result plus the resumed count (Nonewhen none), ready forApplyReport::previously_applied_count. - apply_
non_ delete_ with_ retries - apply_
plan - apply a plan and update the state store. full adapters provision schema before writing; emitters only write.
- backend_
id_ from_ value - read a backend id out of a raw json value: a number, a string, or an object
with an
idfield (a nested brief). - build_
key_ from_ schema - build_
plan - observe backend state and produce a deterministic plan.
- build_
request_ body - compile_
map - transform an ir inventory into another ir inventory under the target schema.
- describe_
missing_ refs - comma-joined referenced uids in
opsthat are absent fromresolved. - eval_
map_ transform - evaluate a single named transform from a map spec against a json value,
consulting the spec’s user transforms first, then the built-ins. backs
alembic map transform, the iteration loop for writing transforms: one value in, the typed result out, no inventory or backend involved. - guard_
schema_ deletes - refuse destructive schema provisioning (deleting custom object types/fields
the inventory no longer declares) unless
allow_deleteis set. these deletes cascade to their objects on the backend, so they are gated behind the same flag as object deletes.previewis the read-only schema preview bothplan(before provisioning) andapplycompute. - import_
inventory - is_
missing_ ref_ error - true when
erris a retryable missing-ref apply error. - load_
inventory - load a inventory file (yaml or json) and merge any includes.
- load_
map_ spec - load a map spec from a yaml file. the spec remembers the file’s directory so
transforms.fileand starlarkload()paths resolve relative to it. - normalize_
attrs_ refs - rewrite every reference-typed field of
attrsfrom backend ids back to canonical uids. read-side inverse ofbuild_request_body. - normalize_
endpoint - normalize a rest-api endpoint to its canonical
app/resource/path, dropping a trailing object-id segment whenis_object_idmatches it. netbox and nautobot share this and differ only inis_object_id(integer vs uuid pks). - plan
- build a deterministic plan from desired and observed state.
- plan_
write_ only - produce a plan for a write-only backend, which cannot report existing state. the inventory is validated, then planned against an empty observation, so every declared object becomes a create (and nothing is updated or deleted).
- pluralize
- pluralize a django/drf endpoint segment, the way django’s url router does. shared by the netbox, nautobot, and django adapters.
- query_
filters_ from_ key - render_
plan - render a plan’s operations as a human-readable summary: a one-line count
header, then each op grouped under create / update / delete with its type and
human key (and per-field
from -> tofor updates). long categories are truncated with an... and N moreline so a large plan stays readable. - report_
to_ result - helper to format a validation report into a Result.
- report_
to_ result_ with_ sources - helper to format a validation report with source locations into a Result.
- resolve_
value_ for_ type - resolved_
ids_ from_ state - project the state store into a flat
uid -> backend-idmap, keeping only the backend idsextractaccepts. companion tostate_mappings_by_id. - resolved_
ids_ identity - project the state store into a flat
uid -> backend-idmap, keeping every mapping. identity companion toresolved_ids_from_state. - sort_
ops_ for_ apply - order operations for apply: creates/updates first (topologically sorted so referenced objects are created before the objects that reference them), then deletes (reverse-toposorted so an object is deleted only after everything referencing it). reference cycles fall back to a stable order.
- state_
mappings_ by_ id - project the state store into a per-type
backend-id -> uidmap, keeping only the backend idsextractaccepts (the variant a given adapter retains). - validate
- validate an inventory and return the report.