Documentation
¶
Overview ¶
Package sessionprocess tracks session-owned OS processes independently of agent lifetime.
Index ¶
- Constants
- type Identity
- type Observation
- type Owner
- type Process
- type Result
- type Scope
- type Service
- func (s *Service) Acquire() func()
- func (s *Service) AfterStop(sessionID string, await func(context.Context) error)
- func (s *Service) Refresh(ctx context.Context) (Snapshot, error)
- func (s *Service) Shutdown()
- func (s *Service) Summary(sessionID string) Summary
- func (s *Service) Terminate(ctx context.Context, sessionID string, targets []Identity, scope Scope, ...) ([]Result, error)
- type Snapshot
- type Source
- type Store
- type Summary
- type Terminal
- type Tree
Constants ¶
const ( TreeRoleLead = "lead" TreeRoleWrapper = "wrapper" TreeRoleHelper = "helper" )
Tree roles: the lead names the tree, wrappers launched it, helpers run beside or below it.
const CaptureTimeout = 2 * time.Second
CaptureTimeout bounds best-effort ownership capture before keeping descendants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Observation ¶
type Observation struct {
Identity
Owner Owner
PGID int
FirstSeen time.Time
GroupObservedAt time.Time
Attribution string
KernelToken string
}
Observation deliberately has no session foreign key: deleting a session keeps its processes discoverable.
type Scope ¶
type Scope int
Scope selects what a session-wide stop covers besides its explicit targets.
const ( // Targets stops only the trees of the given targets. Targets Scope = iota // AllLeftRunning adds every Background and Terminal tree; tool calls stay with their turn. AllLeftRunning // AllIncludingTools adds every tree, tool calls included (stop, archive, delete cleanup). AllIncludingTools // Captured stops exactly the given identities, never their trees' later members: delayed // cleanup captured them before the session could resume and start new work. Captured )
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AfterStop ¶
AfterStop owns and joins cleanup after an accepted stop outlives its caller.
func (*Service) Terminate ¶
func (s *Service) Terminate( ctx context.Context, sessionID string, targets []Identity, scope Scope, allowed func(Owner) bool, ) ([]Result, error)
Terminate resolves targets only inside the caller's authorized ownership set and stops each target's whole tree. An empty session ID is reserved for the operator aggregate boundary.
type Source ¶
type Source interface {
ProcessActivity() (live bool, toolBusy bool)
Owners(context.Context) ([]Owner, error)
Owner(context.Context, string) (Owner, bool, error)
OrphanOwner(context.Context, procutil.ScannedProcess) (Owner, bool, error)
Terminals(context.Context) ([]Terminal, error)
CloseTerminal(context.Context, Process) error
ProcessesChanged(context.Context, string)
RecordTermination(context.Context, Process, Result) error
}
type Store ¶
type Store interface {
LoadProcessObservations(context.Context) ([]Observation, error)
SaveProcessObservations(context.Context, []Observation, []Identity) error
}
type Tree ¶
type Tree struct {
Root, Lead Identity
SessionID string
Kind string
// Wrappers run above Lead, outermost first; Members lists every process, Root first.
Wrappers []Identity
Members []Identity
Ports []int
}
Tree is one logical thing a session started: a dev server behind `bun run`, a browser with its helpers, a Terminal. Stopping it signals every member; its kind is the root's kind.