Skip to content

feat: orchd is Zig - #76

Merged
adiled merged 7 commits into
mainfrom
zig-core
Nov 9, 2026
Merged

adiled merged 7 commits into
mainfrom
zig-core

Conversation

@adiled

@adiled adiled commented Nov 9, 2026

Copy link
Copy Markdown
Owner

The Rust core is gone. orchd is Zig 0.17.1, std only, with no dependencies.

What it is

  • types, config, settings: the spec and Config. Settings resolve as flag, then env, then .orchrc, then default.
  • spec: reads the Orchfile through orch parse, the spec's reference parser, with the built-in variables overlay and ORCH_ARG_* / --arg overrides.
  • rootstock: a tagged union of apple (built in) and external (contract 1, found beside orchd or on PATH).
  • platform: an enum over launchd, systemd and orchdi. Each renders beds (artifacts, plus the stale paths a bed replaces). grow and orchd tend write them with the same code, so plant now renders orchdi beds and launchd's disabled split. In Rust it rendered neither.
  • keeper: orchd tend --spec. Gates, pre_start, the tree in its own process group, HUP to reload with MAINPID, TERM to tear down within the stop budget, and the ready marker.
  • engine, orchard: grow/survey/fell/logs and the sow/plant/tend rows. The spec is parsed once per run.
  • cli: one comptime table of flags drives both parsing and help. The version comes from build.zig.zon.

Parity with the Rust core

  • orch parse | orchd sow | orchd plant over an Orchfile with deps, health checks, a oneshot, STOP, RELOAD, env and env files, limits, logs, user and DISABLED. Every artifact matches Rust's: 7/7 on launchd (plists byte for byte, keeper specs equal in content) and 8/8 on systemd (units, ready gates, target).
  • Live on launchd and orchdi: grow, grow --reload (the HUP reaches the tree), fell (nothing left), and a container under bare is refused. The fell-check takes 30 s on Rust and on Zig alike.
  • Keeper: reload with MAINPID, graceful TERM, a STOP that doesn't stop is killed after its timeout, an optional gate proceeds, a failing required gate refuses, a oneshot leaves its ready marker, and a failure removes it.
  • 62 unit tests.

Deliberate differences

  • A tree killed by a signal exits 128+signal. Rust reported 0, which launchd read as a success and wrote the ready marker for.
  • A host service under apple keeps its RELOAD.
  • reload with no names skips trees the rootstock can't plant, instead of failing.
  • An unknown platform is an error, not a quiet systemd.
  • Messages say the thing itself (error: no bed is planted for x), without platform error: lifecycle failed: in front.

Release

  • release.sh bumps build.zig.zon and its lockstep files.
  • Linux binaries are static (musl). Each tarball bundles orch.
  • There is no crate to publish any more.
  • The pre-commit hook runs zig fmt.

Spec types read from orch parse, Config, and the supervise helpers every
platform shares, as plain Zig: explicit arenas, diagnostics beside error
sets, tests that pin the behaviour.
orchd tend --spec keeps a tree in Zig: gates, pre_start, the tree in its own
process group, HUP to reload with MAINPID, TERM to tear down within the stop
timeout, and the ready marker for oneshots. The CLI is one table of flags
that drives both parsing and help; the version comes from build.zig.zon.
Config comes from flags, env, .orchrc and defaults; the Orchfile is read by
orch parse, the spec's reference parser; a rootstock is apple or a plugin
found beside orchd or on PATH, speaking contract 1, heard even when it fails
before reading its envelope.
release.sh bumps build.zig.zon and its lockstep files, the version orchd
reports; releases build static Linux binaries with musl and bundle orch;
the pre-commit hook runs zig fmt.
@adiled
adiled merged commit 0bbd2e5 into main Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant