Skip to content

feat(recipes): dependency ordering, dry-run, and cloudinit post-boot apply - #43

Merged
NovusEdge merged 2 commits into
mainfrom
recipe-system-fixes
Aug 10, 2026
Merged

feat(recipes): dependency ordering, dry-run, and cloudinit post-boot apply#43
NovusEdge merged 2 commits into
mainfrom
recipe-system-fixes

Conversation

@NovusEdge

@NovusEdge NovusEdge commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Implements docs/specs/2026-08-10-recipe-system-fixes-design.md.

  • Delete v1 metadata parser + wire cloudinit to v2. MatchesVM (via new MatchReason) is the sole capability checker. cloudinit.Prepare and clone.go build seeds through ManifestFor+ScriptContent+WrapScripts. sweepV1 warns when it moves a recipe it does not recognise as stoat's own.
  • Dependency ordering. New depends manifest field, recipes.TopoSort with cycle detection, apply-time satisfaction checks, create/CLI validation (CheckDependencies), and TUI auto-add (ResolveDependencies, "Added docker (required by devtools)").
  • Cloudinit post-boot apply. Drop ErrAppliedAtBoot; each recipe's runcmd writes a marker; discoverCloudInitApplied reads them over ssh to rebuild v.Applied.
  • Dry-run. stoat apply --dry-run [--json] via PlanApply, computed host-side (works on stopped VMs).
  • Docs. ## Reboot Behavior section in docs/recipe-spec-v2.md.
  • Stage validation. Reject stage = "install" at add time until BYO ISO lands.

Excludes an unrelated concurrent apkovl.go banner change in the working tree.

Summary by CodeRabbit

  • New Features
    • Added apply --dry-run to preview planned recipe actions in human-readable or JSON format.
    • Recipes now support dependencies, including automatic dependency selection, ordering, and clear validation errors.
    • Cloud-init VMs can apply recipes after boot and recover previously completed recipes.
    • Added one-time reboot support for disk-mode VMs after applying recipes.
  • Bug Fixes
    • Improved compatibility and capability error messages.
    • Prevented unsupported install-stage recipes from being selected.
  • Documentation
    • Updated recipe v2 behavior, migration guidance, and reboot rules.

- Item 1 now includes cloudinit v2 conversion (coupled, not independent)
- Item 4 (stage field) reduced to validation-only rejection
- Item 2 adds dependency satisfaction rules and apply-time cycle check
- Item 3 moves up in priority (fixes broken backend)
- Migration section fixed (sweepV1 already runs)
- Added missing files-to-modify for ErrAppliedAtBoot removal
- dry-run works on stopped VMs
- Hash discovery note added
…apply

Implements docs/specs/2026-08-10-recipe-system-fixes-design.md.

- Delete the v1 metadata parser and wire cloudinit to v2 scripts:
  MatchesVM (via MatchReason) is the sole capability checker; Prepare
  and clone build seeds through ManifestFor+ScriptContent+WrapScripts;
  sweepV1 warns when it moves a recipe it does not recognise as stoat's.
- Add recipe dependency ordering: a `depends` manifest field, TopoSort
  with cycle detection, apply-time satisfaction checks, create/CLI
  validation, and TUI auto-add of missing dependencies.
- Cloudinit post-boot path: drop ErrAppliedAtBoot, write a marker per
  recipe from runcmd, and rebuild v.Applied over ssh after first boot.
- Add `stoat apply --dry-run [--json]`: PlanApply reports the run/skip
  plan host-side, without starting the VM.
- Document the single-reboot behaviour in docs/recipe-spec-v2.md.
- Reject `stage = "install"` at add time until BYO ISO support lands.
@NovusEdge NovusEdge added enhancement New feature phase-2 Live VMs reachable over SSH + recipe provisioning tui Terminal UI: layout, styling, interaction labels Aug 10, 2026
@NovusEdge NovusEdge self-assigned this Aug 10, 2026
@NovusEdge
NovusEdge merged commit 822367d into main Aug 10, 2026
6 of 7 checks passed
@NovusEdge
NovusEdge deleted the recipe-system-fixes branch August 10, 2026 19:12
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: adad47d3-fd86-4ad3-b6d0-384508bb47eb

📥 Commits

Reviewing files that changed from the base of the PR and between af6c143 and bed3922.

📒 Files selected for processing (34)
  • docs/recipe-spec-v2.md
  • docs/specs/2026-08-10-recipe-system-fixes-design.md
  • internal/backend/cloudinit.go
  • internal/cli/cli.go
  • internal/cli/grammar.go
  • internal/cli/run_apply.go
  • internal/cli/subcommands_test.go
  • internal/cli/wire/errors.go
  • internal/cli/wire/errors_test.go
  • internal/cloudinit/scripts.go
  • internal/cloudinit/scripts_test.go
  • internal/core/apply.go
  • internal/core/apply_test.go
  • internal/core/clone.go
  • internal/core/core.go
  • internal/core/deps.go
  • internal/core/deps_test.go
  • internal/recipes/deps.go
  • internal/recipes/deps_test.go
  • internal/recipes/manifest.go
  • internal/recipes/manifest_test.go
  • internal/recipes/metadata.go
  • internal/recipes/metadata_test.go
  • internal/recipes/recipes.go
  • internal/recipes/recipes_test.go
  • internal/sshx/sshx_test.go
  • internal/tui/autoprov_test.go
  • internal/tui/deps.go
  • internal/tui/edit.go
  • internal/tui/edit_test.go
  • internal/tui/form.go
  • internal/tui/labels.go
  • internal/tui/provision.go
  • internal/tui/provision_test.go

Walkthrough

The change moves recipe execution to v2 manifests, adds dependency validation and ordering, supports cloud-init post-boot state recovery, introduces host-side apply planning with CLI dry-run output, and documents disk-mode reboot behavior.

Changes

Recipe Apply System

Layer / File(s) Summary
Manifest migration and script provisioning
docs/specs/..., internal/backend/cloudinit.go, internal/core/clone.go, internal/core/core.go, internal/recipes/*, internal/sshx/sshx_test.go, internal/tui/*_test.go
Recipe resolution now requires v2 manifests. Applicability uses manifest metadata. Cloud-init and clone provisioning load OS-specific script content. Legacy files use checksum-based sweep handling.
Dependency contracts and ordering
internal/recipes/deps.go, internal/core/deps.go, internal/core/apply.go, internal/tui/deps.go, internal/tui/edit.go, internal/tui/form.go, internal/tui/*_test.go
Manifests declare dependencies. Core resolution validates missing, incompatible, and cyclic dependencies. Apply uses topological ordering. TUI selection adds required recipes and reports additions.
Cloud-init marker recovery
internal/cloudinit/scripts.go, internal/core/apply.go, internal/cli/wire/errors.go, internal/tui/provision.go, internal/*_test.go
Successful cloud-init scripts write per-recipe markers. Apply discovers markers over SSH and reconstructs v.Applied. The obsolete applied-at-boot refusal path was removed.
Host-side apply planning
internal/core/apply.go, internal/cli/cli.go, internal/cli/grammar.go, internal/cli/run_apply.go, internal/core/apply_test.go
ApplyPlan and PlanApply calculate run and skip actions. apply --dry-run prints the plan as text or JSON without executing recipes.
Reboot and implementation specification
docs/recipe-spec-v2.md, docs/specs/2026-08-10-recipe-system-fixes-design.md, internal/core/apply_test.go
Documentation defines disk-mode-only reboot aggregation, live-mode restart handling, install-stage rejection, migration behavior, and expanded validation coverage.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Poem

A rabbit checks the manifest bright,
Orders each recipe left to right.
Cloud-init marks the work it grew,
Dry-run plans what Stoat will do.
Reboot waits till runs are through.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch recipe-system-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature phase-2 Live VMs reachable over SSH + recipe provisioning tui Terminal UI: layout, styling, interaction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant