[architect] refactor: extract TerminalSession interface from Manager's eight terminal seam fields (pkg/agent, #5636 phase 1) - #5638
Conversation
…s eight ad-hoc terminal seam fields Phase 1 of #5636. Manager carried eight nilable func-typed fields (paneCapture, visiblePaneCapture, sessionAttached, sendLiteralForAgent, sendKeysForAgent, promptDismissSleep, captureFullLogFn, clearHistoryFn) that together formed an implicit terminal-IO contract, each guarded by its own nil-check with an inline tmux fallback. This names that contract: - pkg/agent/terminal.go: TerminalSession interface + tmuxTerminal, the production implementation holding the exact tmux invocations moved verbatim from manager.go and kick_logs.go. - Manager gains one 'terminal TerminalSession' field; nil means tmux (Manager.term()), so a zero-value Manager behaves exactly as before. - pkg/agent/terminal_seams_test.go: funcTerminal, a per-method override fake with tmux fallback, mirroring the old unset-seam semantics; test assignments rewritten mechanically to termSeams(m).<method> = ... No behavior change: every method body is the previous fallback code, and unset overrides still reach tmux. go vet clean; full pkg/agent suite passes. Refs #5636 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: hive-architect <sec-check@hive.kubestellar.io>
|
Changelog: this PR changes code but does not touch If it is user-visible — a feature, a fix an operator would notice, a This is a reminder, not a gate; it never blocks a merge. |
|
Reviewed with specific attention to pkg/agent Manager's locking history. Approving — OK to merge. Verified interface extraction only, no behavior or lock-ordering change:
|
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
Refactor
Claimed ground:
src/pkg/agent/manager.go(Manager struct terminal fields +captureTmuxPaneForAgent,captureVisiblePaneForAgent,tmuxSessionHasAttachedClientForAgent,tmuxSendLiteralForAgent,tmuxSendKeysForAgent,sleepDuringPromptDismiss),src/pkg/agent/kick_logs.go(captureScrollbackForAgent,clearScrollbackForAgent), newsrc/pkg/agent/terminal.go+terminal_seams_test.go, and mechanical seam-assignment rewrites in 9pkg/agenttest files. Disjoint from all open hold-gated PRs (#5634 scanner escalation, #5628 docs, #5625 pkg/convergence/mutation, #5559 UPGRADE.md, #4032 proxy auth).Phase 1 of #5636 (Manager god object). Manager carried eight ad-hoc nilable func fields —
paneCapture,visiblePaneCapture,sessionAttached,sendLiteralForAgent,sendKeysForAgent,promptDismissSleep,captureFullLogFn,clearHistoryFn— that together formed an implicit terminal-IO contract, each with its own nil-guard and inline tmux fallback.This names that contract:
TerminalSessioninterface (terminal.go) withtmuxTerminalas the production impl; every method body is the previous fallback code moved verbatim from manager.go / kick_logs.go.terminal TerminalSession;nil⇒ tmux viaManager.term(), so zero-value&Manager{}(used widely in tests) behaves identically.funcTerminal(test file only) is a per-method override fake with tmux fallback, preserving old unset-seam semantics; test assignments rewritten mechanicallym.paneCapture = f→termSeams(m).capturePane = f.No behavior change.
go vetclean; fullgo test ./pkg/agent/suite passes (269s).Follow-up phases per #5636: credential/resolver grouping, nil-safe Hooks struct, file split.
Refs #5636
Filed by architect agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.
— hive: agent=architect backend=copilot model=claude-opus-4-6