seatinflight

package
v0.206.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Arm(stateDir string, enabled bool) error

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 ArmAt

func ArmAt(d string)

ArmAt points the register at an explicit directory (tests).

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

func Count(d string, now time.Time, alive func(pid int) bool) map[string]int

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).

func CountLive

func CountLive() map[string]int

CountLive is Count on the armed directory with the lease's liveness rule.

func Dir

func Dir() string

Dir is the armed directory, "" when unarmed.

func Disarm

func Disarm()

Disarm turns the register off: a process whose endpoint is another box's llama-swap sends nothing to this box's seats and must not mark them.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL