The no-mistakes Lifecycle Guard That Blocks Daemon Stop/Restart During Active Pipeline Runs
The Destructive Daemon Lifecycle Guard is a safety mechanism in internal/lifecycle/guard.go that blocks no-mistakes daemon stop, restart, and update operations whenever active pipeline runs are detected, requiring an explicit --force flag to proceed.
The kunchenguid/no-mistakes repository implements a robust concurrency control system to prevent accidental data loss. This lifecycle guard ensures that the daemon cannot be terminated or upgraded while it is actively managing pipeline executions, protecting worktrees from undefined states.
How the Guard Intercepts Destructive Commands
When you invoke a destructive daemon operation—such as stop, restart, or an in-place update—the guard first queries the current execution state. It utilizes the lifecycle.ActiveRuns and lifecycle.RunList helpers defined in the codebase to enumerate all runs currently in pending or running status.
If any active runs exist, the command aborts immediately and surfaces a human-readable list of the blocking executions. The operation only proceeds if the caller explicitly acknowledges the risk by appending the --force flag. This design prevents silent daemon terminations that could orphan running processes or corrupt pipeline worktrees.
CLI Behavior and the Force Override
In standard operation, the guard presents a clear error message identifying the active runs preventing the action:
$ no-mistakes daemon stop
Daemon stop blocked – active runs detected:
• run 42 (pending) – branch feature/foo
• run 57 (running) – branch fix/bar
Use --force to override.
To bypass the protection and stop the daemon despite active work, you must supply the override flag:
$ no-mistakes daemon stop --force
Daemon stopped successfully (force‑override).
The same behavior applies to updates:
$ no-mistakes update
Update aborted – the daemon has active runs.
Use --force to proceed anyway.
Audit Logging and Forensic Attribution
Every invocation of a guarded command—whether blocked or permitted—is recorded in <NM_HOME>/logs/cli.log. The guard captures detailed caller attribution, including the PID, PPID, and the full command line arguments. This audit trail is essential for forensic analysis, allowing administrators to determine who attempted to terminate the daemon and whether they used the --force override.
Key Source Files and Implementation
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →