Skip to content

fix: make local builds and supervised shutdown reliable - #984

Merged
alongubkin merged 4 commits into
mainfrom
alon/alien-1387-dev-sigterm
Oct 10, 2026
Merged

alongubkin merged 4 commits into
mainfrom
alon/alien-1387-dev-sigterm

Conversation

@alongubkin

Copy link
Copy Markdown
Member

Two independent failures make local development unreliable during cold builds and supervised shutdown.

  • Parallel Rust resource builds can all observe a missing target and run rustup target add concurrently, racing over shared download files. Serialize the check/install within the process, recheck under the lock, and release it before compilation. Report a failed target-list command immediately.
  • A ready full alien dev session handles Ctrl-C but exits abruptly on SIGTERM, bypassing manager shutdown. Register SIGTERM for the session and route it through the existing shutdown path. Keep the listener alive during cleanup.

Reproduction

  1. Build several Rust resources with distinct binary names using a disposable toolchain missing x86_64-unknown-linux-musl: alien build --platforms local --targets linux-x64. Concurrent installation can fail with a missing .partial file.
  2. Start alien dev --status-file status.json --no-browser, wait for Ready, then send SIGTERM to the CLI PID. Before this fix it exits from signal 15 and leaves Ready status; afterward it exits successfully and shuts down the manager.

Validation

  • Three real Rust binaries with a rustup shim rejecting overlapping installers: baseline fails with three attempts; fixed build succeeds with one. A real cold-toolchain build also succeeds with one installation.
  • Four committed full-session/server SIGINT/SIGTERM tests pass; the full-session SIGTERM regression fails against the old binary.
  • 437 CLI and 171 build library tests pass (four existing build tests ignored).
  • Real native-worker development flows pass: start, queries, graceful stop, forced termination and restart, interrupted-update recovery, container recreation, and persistent data. Package-manager SIGINT/SIGTERM shutdown leaves no surviving native processes.
  • Formatting and diff checks pass. Validation ran on Linux; macOS/Docker Desktop has not been exercised.

SIGTERM received during a cold build is handled when startup reaches the watch phase; this change does not implement immediate build cancellation. The install lock coordinates resource builds within one CLI process, not separate CLI processes.

Refs ALIEN-1382, ALIEN-1387.

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no blocking issue remains.

Summary

This PR makes cold Rust builds and supervised local shutdown more reliable.

  • Parallel Rust builds install each missing target only once.
  • Full alien dev sessions shut down cleanly on SIGTERM.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Rust resource build] --> B[Acquire install lock]
  B --> C[List installed targets]
  C -->|Failed| D[Return build error]
  C -->|Missing| E[Install target]
  C -->|Present| F[Release lock]
  E --> F
  F --> G[Compile resource]
  H[Full dev session receives SIGTERM] --> I[Leave watch loop]
  I --> J[Shut down manager]
  J --> K[Write final status]
Loading

Reviews (2) · Last reviewed commit: "test: cover concurrent Rust target insta..." · Reviewed by Greptile

Comment thread crates/alien-build/src/toolchain/rust.rs Outdated
@alongubkin
alongubkin merged commit 1f67d49 into main Oct 10, 2026
24 checks passed
@alongubkin
alongubkin deleted the alon/alien-1387-dev-sigterm branch October 10, 2026 09:09
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