feat(maestro): hot-reload [daemon.policy] via SIGHUP + maestro policy CLI (NAP-237)
ci / rust (push) Failing after 2m51s
ci / rust (push) Failing after 2m51s
`PairAttachVerifier` now stores `allow_inbound` behind `Arc<RwLock<_>>` so clones share the same set. Two triggers re-read the unified config file and swap it atomically: - SIGHUP — `systemctl --user reload maestrod`, or any `kill -HUP`. The installer's user unit now sets `ExecReload=/bin/kill -HUP $MAINPID`. - `POST /api/policy/reload` — used by `maestro policy reload`. The CLI reads `[daemon].bind_addr` from the unified config (default 7070) and POSTs to `http://127.0.0.1:<port>`. No PID lookup required. Also adds `maestro policy show [--json]` and `GET /api/policy` for "did my edit get picked up?" debugging. A broken mid-edit config logs an error and leaves the previously-effective list in place rather than locking everyone out. In-flight attaches keep their existing connection — revocation requires killing the session, as spec'd. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,23 @@ pub enum Command {
|
||||
Kill(KillArgs),
|
||||
/// Set the default registry URL persisted in the CLI config.
|
||||
SetRegistry(SetRegistryArgs),
|
||||
/// Inspect or hot-reload the local daemon's `[daemon.policy]` (NAP-237).
|
||||
#[command(subcommand)]
|
||||
Policy(PolicyCmd),
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum PolicyCmd {
|
||||
/// Re-read `~/.config/maestro/config.toml` and apply
|
||||
/// `[daemon.policy].allow_inbound` without restarting the daemon. Affects
|
||||
/// only new attach attempts — in-flight sessions keep their connection.
|
||||
Reload,
|
||||
/// Print the daemon's current effective `allow_inbound` list.
|
||||
Show {
|
||||
/// Output as JSON instead of one entry per line.
|
||||
#[arg(long)]
|
||||
json: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, clap::Args)]
|
||||
@@ -195,6 +212,21 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_policy_reload() {
|
||||
let cli = Cli::try_parse_from(["maestro", "policy", "reload"]).unwrap();
|
||||
assert!(matches!(cli.command, Command::Policy(PolicyCmd::Reload)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_policy_show_json() {
|
||||
let cli = Cli::try_parse_from(["maestro", "policy", "show", "--json"]).unwrap();
|
||||
match cli.command {
|
||||
Command::Policy(PolicyCmd::Show { json }) => assert!(json),
|
||||
other => panic!("wrong subcommand: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_env_without_equals() {
|
||||
let err = Cli::try_parse_from([
|
||||
|
||||
Reference in New Issue
Block a user