Documentation
¶
Overview ¶
Package managedtarget resolves a caller-facing shell name into one host-shaped Sidecar-owned target. Resolve is state-free: callers supply the candidates they are authorized to expose. List/Candidates load that universe from a Sidecar state directory so the CLI and the TUI cannot disagree.
Index ¶
- Constants
- func DiscoverWorktreeRoots(ctx context.Context, proj Project) []string
- func IsManagedSession(value string) bool
- func ObserveWorktreeOrphans(ctx context.Context, projects []Project, opts ObserveOptions) shellliveness.OrphanObservation
- func SessionSelector(session string) string
- func ValidateCaller(e CallerEvidence) error
- func WorktreeOrphans(ctx context.Context, projects []Project, opts ObserveOptions) shellliveness.OrphanPlan
- type CallerEvidence
- type DiscoverFunc
- type Error
- type ErrorKind
- type ObserveOptions
- type Project
- type Query
- type Target
- func Candidates(ctx context.Context, stateDir string, projects []Project) ([]Target, error)
- func CandidatesWith(ctx context.Context, stateDir string, projects []Project, ...) ([]Target, error)
- func List(ctx context.Context, stateDir, projectKey string) ([]Target, error)
- func Resolve(candidates []Target, q Query) (Target, error)
Constants ¶
const ( KindShell = "shell" KindWorktree = "worktree" )
Variables ¶
This section is empty.
Functions ¶
func DiscoverWorktreeRoots ¶ added in v1.16.0
DiscoverWorktreeRoots is every non-bare worktree Git lists for proj, or nil when Git cannot answer.
func IsManagedSession ¶ added in v1.16.0
IsManagedSession reports the reserved session-name shapes. Missing values in these namespaces must never be reinterpreted as display names.
func ObserveWorktreeOrphans ¶ added in v1.15.0
func ObserveWorktreeOrphans(ctx context.Context, projects []Project, opts ObserveOptions) shellliveness.OrphanObservation
ObserveWorktreeOrphans gathers the evidence for projects. A tmux server with no sessions is an empty listing, not a failure: `no server running` means there is nothing live to be orphaned.
Git is asked only when there is something to judge. Every verdict needs a directory that is gone, so a pass with no live worktree session in a missing directory (and no caller asking for root verdicts) never spawns git at all. That keeps the common `agent list` free of a git process per project.
func SessionSelector ¶ added in v1.16.0
SessionSelector protects a literal session name, including one that starts with the human display-name selector prefix.
func ValidateCaller ¶ added in v1.16.0
func ValidateCaller(e CallerEvidence) error
ValidateCaller refuses contradictions, never chooses a replacement target. A live pane directory verifies a deliberate cd, even outside the owning project. Without live directory evidence, only a known registered cwd can contradict the stored origin; arbitrary directories claim no other shell.
func WorktreeOrphans ¶ added in v1.15.0
func WorktreeOrphans(ctx context.Context, projects []Project, opts ObserveOptions) shellliveness.OrphanPlan
WorktreeOrphans is ObserveWorktreeOrphans followed by the decision.
Types ¶
type CallerEvidence ¶ added in v1.16.0
type CallerEvidence struct {
ClaimedSession, PaneSession, Cwd, PaneWorkDir, OriginWorkDir, RegisteredCwdRoot string
OriginVerified bool
}
CallerEvidence is independently collected context for an implicit selector. Paths are canonicalized by the host adapter. A shell's owning project does not change when its live pane changes directory.
type DiscoverFunc ¶ added in v1.16.0
DiscoverFunc lists the Git worktree roots of one project, as DiscoverWorktreeRoots does. A caller that scans many times over one observation can supply a memoized one.
type Error ¶
type ObserveOptions ¶ added in v1.15.0
type ObserveOptions struct {
// WantRoots asks for root verdicts even when no session is suspect, for a
// caller (`shell list`) that marks shells rather than sessions.
WantRoots bool
}
ObserveOptions says how much evidence a caller needs.
type Project ¶ added in v1.15.0
Project is the registered-project facts the candidate scan needs. Callers that already loaded the registry (the CLI) pass this; List loads it from stateDir.
func LoadProjects ¶ added in v1.15.0
LoadProjects reads every registered project under stateDir/projects.
type Target ¶
type Target struct {
Host, Project, ProjectRoot, Kind, Session, Name, Namespace, WorkDir, WorktreeRoot, ManifestPath string
Priority int
}
func Candidates ¶ added in v1.15.0
Candidates is every shell and worktree session the given projects own, each worktree root listed exactly once.
Shell records belong to the project whose manifest holds them. Worktree roots do not, because several registered projects can see the same directory. Each root therefore has one owner, chosen by how strongly a project claims it: created worktree, then the project's own checkout, then the first project that merely discovered it through Git.
func CandidatesWith ¶ added in v1.16.0
func CandidatesWith(ctx context.Context, stateDir string, projects []Project, discover DiscoverFunc) ([]Target, error)
CandidatesWith is Candidates with the Git worktree discovery supplied by the caller; nil means DiscoverWorktreeRoots. Manifests and registered worktrees are always read fresh.
func List ¶ added in v1.15.0
List is every managed shell and worktree in stateDir, or only projectKey when that is set. Empty projectKey means every registered project. This is the universe agent list and agent broadcast share.
func Resolve ¶
Resolve prefers exact session identities. Ordinary bare values may fall back to a unique display name; managed session-shaped values and session: selectors never do. name: selects a display name explicitly, including session-shaped names. Every filter is exact; an empty field leaves that axis unscoped.