# MoonBit API

The root package exposes parse_config, Config, Service and Graph. Parse UTF-8 JSON, pass config.services to Graph::build, then use layers, startup_order, shutdown_order, dependencies or affected to inspect the plan. ConfigError includes the invalid field path or the dependency cycle.

The native runtime package exposes run(config, command), returning RunReport and the absolute report.json path. An empty command starts the services, waits for readiness, and tears down. A nonempty command is an executable plus its argument vector. Runtime failures are represented in RunReport; directory setup and publication errors raise. output_root selects the artifact folder. Set reap_orphans only in a dedicated Linux process.

RunReport.events is the ordered session timeline. The same timeline is available as events.jsonl with an explicit run_id on each line. services.json contains one row per configured service, ordered as declared, including any terminal state, started PID, log paths and diagnostic metadata. report.json is committed last and marks the completed artifact set.

The managed programs receive MOONHARNESS_FIXTURE_DIR. Use it for temporary inputs or outputs shared among services and the scenario. The runtime removes that directory after the children stop; write durable diagnostic data to captured output.
