Skip to main content

Crate lm_provision

Crate lm_provision 

Source
Expand description

§lm-provision

§Architecture

A spec-first pod provisioner built entirely in Rust around a typed profile_ast::ProfileNode AST. A profile is authored as JSON or the canonical text form, parsed into the AST by the frontend, and then run through the read-only pipeline stages (validate / canonical / hash / plan) or the effectful exec engine (apply). There is no embedded scripting runtime: the earlier embedded-Lua authoring frontend and its VM / sandbox / bridge stack have been removed in favour of the single AST pipeline.

§Modules

  • frontend — parse a profile file (.json → serde bridge, canonical text → PEG grammar, .lua → explicit rejection) into a profile_ast::ProfileNode AST.
  • profile_ast — the ProfileNode AST (spec + the phase catalog kinds), the semantics adapter (ProfileSemantics / ProfileValue), and the dsl-kit engine wiring that drives execution.
  • resolve — the fragment-import resolve stage between load and validate (11-fragment-import.md §Resolution): every Import node is replaced by its fragment’s expanded phase list, so everything downstream sees a plain expanded Spec.
  • validate — the AST validate stage (03-pipeline-stage-artifacts.md §validate).
  • canonical — deterministic byte encoder + SHA-256 profile hash over the profile_ast::ProfileNode AST (03-pipeline-stage-artifacts.md §canonical / §hash). Frontend- independent by construction: NodeId is excluded, declared lists are sorted, phase order preserved.
  • pin — the resolver-layer pin subcommand (spec 11 §The resolver layer): rewrite name@version imports in a JSON profile into the explicit pinned src + hash form against an index.json, verifying the rewritten document resolves before overwriting it.
  • plan — the AST plan stage: expand a profile into the plan artifact (03-pipeline-stage-artifacts.md §plan).
  • to_bridge_json — expanded AST → serde-JSON serializer whose output the JSON serde bridge accepts (spec 11 §Cache last paragraph: the pin-verifiable cache entries the resolve stage writes, and — later — the payload the driver preflight uploads).
  • resource — what a phase creates (produces) and what it needs already there (requires / assumes), and the forward fold that decides whether a profile is well-formed under that. Every ComfyUI-relative path is derived here from one declared root instead of being a host constant.
  • digest — the crate’s single SHA-256 implementation, shared by the profile hash, the Assert model’s content predicate, and the driver’s ensure-binary check.
  • exec — the execution layer, with no embedded scripting runtime: the capability gate, the declaration-derived path / HTTP / secret policies, the pure-Rust effect implementations, and the per-step report builder (05-sandbox-layer-contract.md, 09-apply-report-and-ledger.md).
  • machine — what the machine itself must be, and the contract a target implements to be judged against it: machine::admit before one exists, machine::observe once one does.
  • normalize — the canonical phase order every stage reads, imposed on a profile’s as-written order.
  • [derive] — the dsl_exec attribute’s expansion surface.
  • apply — host-side plan → dispatch → apply → report entry point (apply::run_apply_ast, 09-apply-report-and-ledger.md).
  • cli — subcommand / flag surface (07-cli.md).

§Static binary

Build a musl static binary requiring zero preinstalled dependencies on the target pod (08-push-driver-protocol.md §Inputs):

rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl

Modules§

apply
Host-side apply entry point: plan → dispatch → apply → report (09-apply-report-and-ledger.md).
canonical
Canonical byte encoding + profile hash over the ProfileNode AST.
cli
CLI subcommand surface and pipeline wiring (07-cli.md).
derive
Derive what a profile will demand of its declared lists, so validate can assert declared ⊇ derived (spec 00 §Capability derivation).
digest
Content identity: the crate’s single SHA-256 implementation.
egress
sh.exec egress pin — route every subprocess’s network egress through a declared host allowlist (issue 45930cb0, spec 05 §L3).
exec
Execution layer for the ProfileNode DSL, with no embedded scripting runtime.
fetch
fetch — retrieve a shared profile over HTTP(S) and keep it only if its canonical hash matches the one the caller already holds (07-cli.md §Invocation fetch).
frontend
Profile file frontend: parse a profile file into a ProfileNode AST.
machine
What the machine itself must be, and which targets can be that.
normalize
Canonical-order normalization: the one AST→AST pass that both the plan stage and apply run before they consume a profile.
pin
The pin subcommand (spec 11 §The resolver layer): rewrite every Import in a JSON profile whose src is the name@version shorthand into the explicit pinned src + hash form, using an index.json — local file or HTTPS URL — as the resolver.
plan
Expand a ProfileNode AST into the ordered plan artifact (03-pipeline-stage-artifacts.md §plan).
profile_ast
The ProfileNode AST: the top-level Spec and the phase catalog kinds (spec 02).
resolve
Fragment-import resolution: the pipeline stage between load and validate (spec 11-fragment-import.md §Resolution).
resource
Resources: the static half of the model.
to_bridge_json
Expanded ProfileNode AST → serde_json::Value serializer whose output the JSON serde bridge accepts.
validate
First-violation validation over the ProfileNode AST (03-pipeline-stage-artifacts.md §validate).