//! In-VM Dockerfile builder (docs/design/in-vm-builder-2026-06-05.md).
//!
//! Builds a Dockerfile by executing each step inside a supermachine
//! microVM and snapshotting the result, so every layer is a snapshot and
//! the final layer is the bootable run artifact (fused build+run, zero
//! conversion). This module currently holds the **frontend** — parsing a
//! Dockerfile into a structured instruction model ([`dockerfile`]); the
//! build DAG and the snapshot-per-layer executor build on top of it.

pub mod dockerfile;
// The snapshot-as-layer executor drives only cross-backend APIs (Image::from_oci
// / from_snapshot, Pool::acquire, Vm::exec, PooledVm::snapshot{,_diff}, in-process
// squashfs). KVM now provides the non-consuming PooledVm::snapshot(&self) (live
// snapshot: pause → capture → resume) the per-layer loop needs, so the executor
// builds + runs on both backends.
#[cfg(any(
    all(target_os = "macos", target_arch = "aarch64"),
    all(target_os = "linux", target_arch = "x86_64")
))]
pub mod executor;
#[cfg(any(
    all(target_os = "macos", target_arch = "aarch64"),
    all(target_os = "linux", target_arch = "x86_64")
))]
mod fetch;
#[cfg(any(
    all(target_os = "macos", target_arch = "aarch64"),
    all(target_os = "linux", target_arch = "x86_64")
))]
mod subst;

pub use dockerfile::{parse, Dockerfile, Instruction, ShellOrExec, Stage};
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
pub use executor::{
    build_linear, commit_squashfs, export_oci, prune_dockerfile_layer_snapshots,
    runsc_prune_dockerfile_layers_enabled, BuildOutcome, Builder, CommitOutcome, ImageConfig,
    OciExportOutcome,
};
// `commit_kvm_bootable` (commit → KVM-bootable read-only-rootfs image) is
// Linux/x86 only — it re-bakes via `Image::bake_kvm_from_squashfs_auto`.
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
pub use executor::{
    build_linear, commit_kvm_bootable, commit_squashfs, export_oci,
    prune_dockerfile_layer_snapshots, runsc_prune_dockerfile_layers_enabled, BuildOutcome, Builder,
    CommitOutcome, ImageConfig, OciExportOutcome,
};
