- assigned_to: thomijasir
#29 [Feature]: Restart run processes when secrets change
Originally created by: thomijasir
Originally owned by: thomijasir
Feature description
Add a watch mode that restarts a child process after the selected environment changes.
Current behavior
dopbase run fetches secrets once and runs one child process. A secret change requires a manual restart.
Why we need this
Long-running local services should be able to pick up configuration changes without developers stopping and starting them by hand.
Proposed CLI interface
dopbase run ENVIRONMENT --watch -- commanddopbase run ENVIRONMENT --watch --restart-timeout 10s -- command
Expected behavior
- Subscribe to a server-provided change stream for the resolved environment.
- Start only one child process at a time.
- When a relevant change arrives, request graceful termination, wait for the restart timeout, force termination if needed, fetch a fresh runtime payload, and start a new child.
- Debounce bursts so one saved change set causes one restart.
- Reconnect to the event stream with bounded backoff and jitter.
- Keep the current child running while reconnecting unless the server reports that the cached runtime is invalid.
- Stop watching when the child exits by itself and return its exit code.
- Forward Ctrl+C and termination signals to the current child process group.
- Do not support watch mode with explicit offline execution.
Security and compatibility
- The change stream carries revision or event metadata only, never secret values.
- Fetch plaintext only when initially starting or after a confirmed change.
- Authenticate the stream with the same environment scope as runtime access.
- Do not restart from stale cache after an authorization or not-found response.
Out of scope
- Polling the runtime secrets endpoint for changes.
- Running several child instances concurrently.
- Watching multiple environments in one command.
Acceptance criteria
- [ ] One environment change causes one controlled restart with fresh secrets.
- [ ] Bursts are debounced.
- [ ] Graceful and forced termination paths work.
- [ ] Reconnects do not stop a healthy child unnecessarily.
- [ ] Authorization loss stops watch mode without falling back to stale data.
- [ ] Offline and watch flags conflict at argument parsing.
- [ ] Final exit codes and user signals remain predictable.
Test scenarios
- Add event-stream and child-process integration tests under
app/tests/cli/. - Cover initial connection, restart, debounce, reconnect, stale events, graceful timeout, forced kill, child exit, signals, authorization loss, server errors, and offline conflict.
Documentation
Document restart behavior, debounce, failure handling, signal behavior, server requirements, and local development use.
Dependencies
Blocked until the server exposes an authenticated environment change stream. The server work must define event ordering, keepalive behavior, reconnection cursors, and authorization.