Skip to content

feat(nickel): emit_host scaffold — ProbedState → Nickel host config text#60

Merged
UnbreakableMJ merged 1 commit into
mainfrom
feat/nickel-emit-scaffold
Apr 29, 2026
Merged

feat(nickel): emit_host scaffold — ProbedState → Nickel host config text#60
UnbreakableMJ merged 1 commit into
mainfrom
feat/nickel-emit-scaffold

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

Summary

Opens M4 W1 reconcile direction (Plan §7.5) — the inverse of load_host. Where load_host shells out to nickel export and parses TOML into a DeclaredState, emit_host renders a ProbedState as Nickel host-config text intended to land at <config_dir>/hosts/<host>.imported.ncl as the starting point for an operator's reconcile review.

This first chunk emits only the always-present blocks: meta and kernel. Unprobed meta fields (timezone, arch_level, locale, keymap) get conservative placeholders that the operator hand-edits. Subsequent chunks (a) probe /etc/timezone, /etc/locale.conf, /proc/cpuinfo to populate them automatically and (b) add the packages, services, users, and config-file blocks.

The pure-function / no-I/O design keeps emit testable without the nickel binary; full round-trip via nickel export will be exercised once the engine method that wraps probe + emit ships.

  • New pearlite-nickel::emit module + emit_host(probed: &ProbedState) -> String.
  • Conservative defaults documented in rustdoc.
  • Backslash and double-quote escaping for Nickel string literals.
  • Five unit tests: basic emit, two escape paths, top-level brace shape, meta-before-kernel ordering.
  • time crate added to dev-dependencies for fixture construction.

Test plan

  • cargo test --workspace --all-features — 321 passing (+5 new)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • scripts/ci/check-spdx.sh — clean
  • pearlite-audit check . — 1 check, 0 violations
  • CI green on T1 / T2 / T3

🤖 Generated with Claude Code

Opens M4 W1 reconcile direction (Plan §7.5): the inverse of
load_host. Where load_host shells out to nickel-export and parses
TOML into a DeclaredState, emit_host renders a ProbedState as
Nickel host-config text intended to land at
<config_dir>/hosts/<host>.imported.ncl as the operator's reconcile
review starting point.

This first chunk emits only the always-present blocks: meta and
kernel. Unprobed meta fields (timezone, arch_level, locale, keymap)
get conservative placeholders that the operator hand-edits; in
follow-up chunks reconcile probes /etc/timezone, /etc/locale.conf,
/proc/cpuinfo etc. to populate them automatically.

Subsequent chunks add the packages, services, users, and config-file
blocks. The pure-function/no-I/O design keeps emit testable without
the nickel binary; round-trip via nickel-export will be exercised
once the engine method that wraps probe + emit ships.

- New `pearlite-nickel::emit` module + `emit_host(probed) -> String`.
- Conservative defaults documented in the rustdoc.
- Backslash and double-quote escaping for Nickel string literals.
- Five unit tests: basic emit, two escape paths, top-level brace
  shape, meta-before-kernel ordering.
- time crate added to dev-dependencies for fixture construction.

Tests: 321 passing (+5). Clippy clean. fmt clean. audit clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@UnbreakableMJ
UnbreakableMJ merged commit e82706d into main Apr 29, 2026
3 checks passed
@UnbreakableMJ
UnbreakableMJ deleted the feat/nickel-emit-scaffold branch April 29, 2026 06:12
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