Skip to content

fix: validate machine config before activation - #451

Merged
alongubkin merged 4 commits into
mainfrom
alon/alien-545-preserve-toml-scalar-types
Aug 21, 2026
Merged

fix: validate machine config before activation#451
alongubkin merged 4 commits into
mainfrom
alon/alien-545-preserve-toml-scalar-types

Conversation

@alongubkin

@alongubkin alongubkin commented Aug 20, 2026

Copy link
Copy Markdown
Member

Background

Machine join renders configuration from a release manifest. TOML itself accepts values such as both true and "true", but Horizond requires specific scalar types. Replacing the active file before the actual consumer validates it can turn a repair or reconfiguration into a service crash loop.

Changes

  • preserve manifest literal types when rendering TOML
  • write configuration through a durable same-directory candidate file
  • optionally run the bundle-declared configuration validator against that candidate
  • atomically replace the active config only after validation succeeds
  • leave the previous active config untouched and remove the candidate on rejection
  • recover safely from stale candidate files left by an interrupted join

The validator is optional for backward compatibility with existing bundle manifests. Horizon PR #97 adds horizond validate-config <path> and publishes it in new manifests.

Validation

  • cargo test -p alien-deploy-cli machine_config_ (4 passed)
  • rejection test proves the old active file remains byte-for-byte unchanged

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

The PR validates rendered machine configuration before activation and preserves literal TOML scalar types.

  • Writes and durably syncs a same-directory candidate before atomically replacing the active configuration.
  • Runs an optional bundle-provided validator and removes rejected candidates without altering the active file.
  • Removes a stale candidate associated with a reused process ID before creating the new candidate.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported stale-candidate issue is fixed for the regular files that interrupted candidate writes can leave behind.

Important Files Changed

Filename Overview
crates/alien-deploy-cli/src/commands/join.rs Adds typed TOML rendering, optional pre-activation validation, durable candidate writes, atomic replacement, stale-candidate recovery, and focused regression tests.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Render typed TOML] --> B[Remove stale PID candidate]
  B --> C[Create and sync candidate]
  C --> D{Validator configured?}
  D -- No --> F[Atomically replace active config]
  D -- Yes --> E{Validation succeeds?}
  E -- Yes --> F
  E -- No --> G[Remove candidate]
  G --> H[Keep active config unchanged]
  F --> I[Sync parent directory]
Loading

Reviews (4): Last reviewed commit: "fix: validate machine config before acti..." | Re-trigger Greptile

Comment thread crates/alien-deploy-cli/src/commands/join.rs
@alongubkin alongubkin changed the title fix: preserve machine config value types fix: validate machine config before activation Aug 20, 2026
@alongubkin
alongubkin force-pushed the alon/alien-545-preserve-toml-scalar-types branch from f927236 to 45626a3 Compare August 21, 2026 00:03
@alongubkin
alongubkin changed the base branch from main to alon/alien-559-regenerate-worker-runtime-typescript-client-for-locked-ts August 21, 2026 00:03
Base automatically changed from alon/alien-559-regenerate-worker-runtime-typescript-client-for-locked-ts to main August 21, 2026 01:39
@alongubkin
alongubkin merged commit cf2078a into main Aug 21, 2026
42 checks passed
@alongubkin
alongubkin deleted the alon/alien-545-preserve-toml-scalar-types branch August 21, 2026 01:39
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