build

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(source, output string) error

Parse parses source with the pinned leyline binary and writes the result to output — the library equivalent of `mache build <source> <output>` with no --schema flag. That is the common case, and it is what Open expects: a raw leyline-parsed .db (nodes/node_defs/node_refs), which SQLiteGraph reads directly with no import/populate step (see Open's doc comment).

The leyline binary is resolved the same way every mache entry point resolves it (PATH, if it matches the pin; else the version-namespaced cache; else auto-download, SHA-verified) — see leyline.ResolveBinary. Set MACHE_NO_LEYLINE to opt out of auto-download; Build then fails with a clear error instead of silently falling back to anything else, since leyline is mache's only parser.

This does NOT run mache's --schema re-projection path (Engine + ASTWalker over a custom api.Topology) — that stays CLI-only for now. It also does not stamp the CLI's _mache_meta provenance table: mache_version/ mache_commit there identify the mache BINARY that built the file, which a library caller isn't one of, and nothing in this package or Open reads that table.

func ParseWithSchema

func ParseWithSchema(source, output string, topology *api.Topology, opts ...Option) error

ParseWithSchema parses source with the pinned leyline binary and projects the resulting AST through topology into output. It is the library equivalent of `mache build --schema` for callers that already hold a topology.

output is published atomically: a reader sees the previous database or the finished one, never a partial or missing file, and a failed build leaves the previous database in place.

func ParseWithSchemaRef

func ParseWithSchemaRef(source, output, ref, baseDir string, opts ...Option) error

ParseWithSchemaRef resolves a bundled preset name or schema file relative to baseDir, then parses and projects source into output.

Types

type Option

type Option func(*parseOptions)

Option configures ParseWithSchema and ParseWithSchemaRef.

func WithFinalize

func WithFinalize(fn func(path string) error) Option

WithFinalize runs fn against the finished database before it is published at output. fn receives the database's private path, not output: anything it writes lands in the same atomic publish as the projection. Writing to output after the build returns would modify a file readers may already have open.

An error from fn abandons the build and leaves output as it was.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL