Documentation
¶
Overview ¶
Package seatinflight is the machine-wide register of the harness's OWN requests to this box's llama-swap seats: one small marker file per request, written when the request is admitted and removed when it is released.
WHY IT EXISTS. PAIR's Jobs list shows harness work because the harness reports it (internal/pairworkloads). Traffic that reaches a seat without the harness — a curl soak, opencode's own chat model, codex pointed at llama-swap — was invisible there, so fleet-serve now watches the seats' live request counts and reports that traffic too (pairworkloads.SeatWatcher). A seat's count cannot tell a harness request from a direct one, and a harness job already has its own card, so the watcher subtracts what this register holds: a harness request is never shown twice.
WHY FILES. The harness runs as several processes on one box (an MCP server per editor session, CLI runs, fleet-serve serving another box's delegation); modelaffinity's gate is per-process by design and cannot count them. A marker is one create and one remove per request, never a lock, never a read on the request path — against a seat call measured in seconds.
SAFE BY CONSTRUCTION. Nothing here can fail or slow a request: every error is swallowed, and an unarmed register is a no-op. A marker left behind by a process that died is ignored (and removed) once its pid is gone, and any marker older than MaxAge is ignored regardless, so a leak can only ever hide direct traffic for a while — never invent a card.
Index ¶
Constants ¶
const MaxAge = time.Hour
MaxAge bounds how long a marker is believed. The longest harness request is a delegation's 900 s cap; an agent_run step or a proxied chat is shorter. Past this a marker is a leak whatever its pid says (a recycled pid reads as alive).
Variables ¶
This section is empty.
Functions ¶
func Arm ¶
Arm points the register at the machine-wide state root the operator's state_dir resolves to (the same root the GPU lease uses), and is called from config.Load beside modelaffinity.SetGPULease. A root that cannot be resolved disarms and returns the reason.
enabled is the box's pair_seat_activity_enabled: with the feature off NOTHING reads this register, so nothing should pay for it. modelaffinity.Admit is the gate EVERY text call passes, and a file create plus a remove per request for a consumer that does not exist is exactly the cost that gate refuses to carry.
func Begin ¶
func Begin(model string) (end func())
Begin records one request naming model (the name the request carries; an alias is fine, the reader resolves it) and returns the function that ends it. The returned function is safe to call more than once. An unarmed register or an empty model returns a no-op.
func Count ¶
Count returns the live markers in d per lower-cased model name. A marker whose process is gone is removed; one older than MaxAge is ignored and removed; an unreadable one (being written right now) is skipped. alive is the liveness test (gpulease.PIDAlive in production).
Types ¶
This section is empty.