Documentation
¶
Overview ¶
Package session records which agent sessions are running on this machine.
WB is a short-lived command with no daemon, so it cannot observe a session starting. A session announces itself once — from a harness start-up hook, or by hand — and everything WB writes afterwards can be attributed to it without each command being told again.
A record is a claim, not an observation. WB stores what it was told, adds only what it can see for itself (its own version and binary path), and evaluates liveness at read time from the declared PID.
Index ¶
Constants ¶
const ( StateLive = "live" StateGone = "gone" )
Liveness states, matching the vocabulary used for worktree owners.
const DirName = "sessions"
DirName is the directory under WB's home that holds session records.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Record ¶
type Record struct {
PID int `json:"pid"`
Runtime string `json:"runtime,omitempty"`
Model string `json:"model,omitempty"`
AgentID string `json:"agent_id,omitempty"`
// WBVersion and WBPath describe the binary that took the registration.
// Several WB builds can coexist — a release on PATH and a local build
// under test — and knowing which one a session used is what makes
// otherwise inexplicable behaviour explicable.
WBVersion string `json:"wb_version,omitempty"`
WBPath string `json:"wb_path,omitempty"`
StartedAt time.Time `json:"started_at"`
}
Record is one agent session's self-declaration.
func Register ¶
Register writes a session record, replacing any record for the same PID. Re-registering is deliberately allowed: a session that restarts its harness or corrects its model should not have to find and delete the old file.
func ResolveForProcess ¶
ResolveForProcess finds the registered session that owns a process, by walking up from startPID and returning the first ancestor that registered and is still live.
This is not the process-tree guessing WB otherwise refuses to do. It matches only against PIDs that explicitly declared themselves, so it confirms a declaration rather than inventing one: an unregistered ancestor is never treated as an owner. Depth is bounded because a corrupted /proc chain must not spin.