Compiles deployment prelude SOURCE into a %PtcRunner.Lisp.Prelude{}
artifact.
What this does
- Parses the prelude source to raw AST.
- Walks the top-level program treating
(ns name "doc" {meta})as a COMPILER-ONLY directive (not a general user-runtime form), anddefn/defn-as export/private-helper definitions under the current namespace. - Runs compile-time validation that does NOT depend on a selected
runtime: reserved-namespace rejection, missing/invalid namespace,
duplicate public refs, invalid visibility, invalid arity/signature
metadata. Failures are returned as
{:error, %PtcRunner.Lisp.Prelude.ValidationError{}}. - Builds
%Export{}records for public definitions and records every transitively referencedtool/<name>as atool:<name>requirement. - Captures a callable private prelude env by analyzing+evaluating the
definition forms (ns directives stripped,
defn-rewritten todefn) through the existing PTC-Lisp pipeline. The captured value is the resultinguser_nsmap (bare symbol =>{:closure, ...}). NOTE: the evaluator's lexical closure capture does NOT fold sibling top-level defs into each closure'scaptured_env— sibling helpers resolve by name throughuser_nsat CALL time. The wholeprivate_envmap IS that namespace, soprivate_envmust be threaded as the user_ns layer when invoking an export for siblings to resolve (the capture seam). - Computes a sha256 source hash.
Attach-time requires validation against granted tools is a separate phase.
Summary
Functions
Compiles prelude source into a %PtcRunner.Lisp.Prelude{}.
Functions
@spec compile( String.t(), keyword() ) :: {:ok, PtcRunner.Lisp.Prelude.t()} | {:error, PtcRunner.Lisp.Prelude.ValidationError.t()}
Compiles prelude source into a %PtcRunner.Lisp.Prelude{}.
Options for declared prelude-to-prelude dependencies:
:deps— compiled%Prelude{}artifacts whose PUBLIC exports are visible to namespaces that declare them in:namespace_deps.:namespace_deps—%{namespace => [dep_namespace]}declaring which dep namespaces each compiled namespace may reference. A declared dep must be provided by:depsor be a sibling namespace of this compile; siblings are processed in dependency order with progressive scope.
Undeclared cross-namespace references keep failing (unknown namespace),
and defn- privates of a dep have no export record so they stay
unreachable. Dep references inside def initializers are rejected
(:dep_ref_in_def): initializers evaluate at compile time under a no-op
tool executor, so a dep call there would silently compute garbage.
Returns {:ok, prelude} or {:error, %ValidationError{}}.