fix(maestro): recover() re-advertises sessions under current daemon_id (NAP-264)
ci / rust (push) Successful in 6m46s

`SessionManager::recover()` re-inserted each sidecar's `Session` verbatim,
keeping the persisted `daemon_id`. If the operator renamed the daemon between
starts, recovered sessions were re-advertised under the old id and became
unroutable. Overwrite `daemon_id` with the daemon's current id on recover,
warning when the sidecar's id differs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 20:51:18 +00:00
co-authored by Claude Opus 4.8
parent 421e36c59f
commit 3517e4e145
2 changed files with 57 additions and 1 deletions
+14 -1
View File
@@ -324,7 +324,7 @@ impl SessionManager {
let live = self.inner.tmux.list_sessions()?;
let mut adopted = 0usize;
for id in live {
let session = match self.inner.sidecar.read(id) {
let mut session = match self.inner.sidecar.read(id) {
Ok(Some(s)) => s,
_ => Session {
id,
@@ -337,6 +337,19 @@ impl SessionManager {
created_at: Utc::now(),
},
};
// The sidecar persists whatever daemon_id was current when the
// session was created. If the operator renamed the daemon between
// starts, that id is stale — re-advertise under our own id so the
// session stays routable (NAP-264).
if session.daemon_id != self.inner.daemon_id {
tracing::warn!(
%id,
sidecar_daemon_id = %session.daemon_id,
current_daemon_id = %self.inner.daemon_id,
"recovered session had a stale daemon_id; re-advertising under the current id"
);
session.daemon_id = self.inner.daemon_id.clone();
}
let fifo_path = self.inner.fifo_dir.join(format!("{id}.fifo"));
let bridge =
PtyBridge::start_with_replay(fifo_path.clone(), self.inner.replay_bytes).await?;