From 2612c03d2d79c479a5219d89ddbf491d99e004d5 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 02:10:54 -0400 Subject: [PATCH 1/2] chore(crux): move tmux session accessors out of manager.go SessionMissing and TmuxSession are tmux-session queries; they belong with the rest of the tmux boundary in manager_tmux.go. #15270 grew agent/manager.go to 1696 lines, over the 1689-line baseline enforced by crux's Go file-size ratchet, so every crux-publish sync since then fails that check on crux main. Pure move, no behaviour change. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/crux/agent/manager.go | 38 ---------------------------------- src/crux/agent/manager_tmux.go | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/crux/agent/manager.go b/src/crux/agent/manager.go index 74dc1fe1ba..ee42822448 100644 --- a/src/crux/agent/manager.go +++ b/src/crux/agent/manager.go @@ -1637,44 +1637,6 @@ func (m *Manager) GetOutput(name string, lines int) ([]string, error) { return nil, nil } -// SessionMissing reports whether an agent the manager believes is RUNNING has -// no live tmux session — the zombie case, where in-memory state and reality -// have diverged. -// -// It is deliberately false for any agent that is not StateRunning: a paused, -// stopped or never-started agent legitimately has no session, and reporting -// those as missing would turn every deliberate pause into a fault. -// -// The session check must go through the agent's OWN tmux socket. Each agent -// runs under its own UID on its own socket (e.g. /tmp/tmux-2007/hive-scanner), -// so a query against the default socket answers "no server running" even when -// every session is alive — the exact false reading that has sent live -// diagnosis down the wrong path. -func (m *Manager) SessionMissing(name string) bool { - m.mu.RLock() - agent, ok := m.agents[name] - if !ok || agent.State != StateRunning || agent.Paused { - m.mu.RUnlock() - return false - } - m.mu.RUnlock() - // The exec runs outside the lock: it shells out to tmux, and holding a - // manager lock across a subprocess is how the startup path has deadlocked - // before. - return !m.tmuxSessionExistsForAgent(agent) -} - -func (m *Manager) TmuxSession(name string) string { - m.mu.RLock() - defer m.mu.RUnlock() - - agent, ok := m.agents[name] - if !ok { - return "" - } - return agent.tmuxSession -} - func (m *Manager) bobPreflightUnlocked(agent *AgentProcess) { if agent == nil { return diff --git a/src/crux/agent/manager_tmux.go b/src/crux/agent/manager_tmux.go index 0a10a27586..dde88e4580 100644 --- a/src/crux/agent/manager_tmux.go +++ b/src/crux/agent/manager_tmux.go @@ -666,3 +666,41 @@ const attachedClientIdleGrace = 30 * time.Minute func (t tmuxTerminal) SleepDuringPromptDismiss(d time.Duration) { time.Sleep(d) } + +// SessionMissing reports whether an agent the manager believes is RUNNING has +// no live tmux session — the zombie case, where in-memory state and reality +// have diverged. +// +// It is deliberately false for any agent that is not StateRunning: a paused, +// stopped or never-started agent legitimately has no session, and reporting +// those as missing would turn every deliberate pause into a fault. +// +// The session check must go through the agent's OWN tmux socket. Each agent +// runs under its own UID on its own socket (e.g. /tmp/tmux-2007/hive-scanner), +// so a query against the default socket answers "no server running" even when +// every session is alive — the exact false reading that has sent live +// diagnosis down the wrong path. +func (m *Manager) SessionMissing(name string) bool { + m.mu.RLock() + agent, ok := m.agents[name] + if !ok || agent.State != StateRunning || agent.Paused { + m.mu.RUnlock() + return false + } + m.mu.RUnlock() + // The exec runs outside the lock: it shells out to tmux, and holding a + // manager lock across a subprocess is how the startup path has deadlocked + // before. + return !m.tmuxSessionExistsForAgent(agent) +} + +func (m *Manager) TmuxSession(name string) string { + m.mu.RLock() + defer m.mu.RUnlock() + + agent, ok := m.agents[name] + if !ok { + return "" + } + return agent.tmuxSession +} From a309c039cfa8bc94d9c04a07dc97dd853ce8feb4 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 06:11:23 +0000 Subject: [PATCH 2/2] changelog: fragment for #15330 Generated by changelog-fragment-guard from the PR title (#5675). Edit the wording freely, or replace this file with the no-changelog label if the change is not user-visible. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-15330.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/changed-15330.md diff --git a/changelog.d/changed-15330.md b/changelog.d/changed-15330.md new file mode 100644 index 0000000000..bdf34e4e18 --- /dev/null +++ b/changelog.d/changed-15330.md @@ -0,0 +1 @@ +- chore(crux): move tmux session accessors out of manager.go (#15330)