Documentation
¶
Overview ¶
Package jobdir is the ownership marker of a delegator-side job directory under <base>/pipeline-jobs/.
That root has two kinds of writer. fleet-serve materializes the jobs it is dispatched there (agent-<n>, accel-<n> and pipeline job ids) and keeps the record of them in memory, so anything it finds on disk at startup is a previous instance's leftover. A delegator process does the same for its own in-process local placement (pipeline.RunAgentContract, reached from the MCP server, the delegate and research commands and the fleet smoke), and that process is not fleet-serve: it outlives fleet-serve restarts, so the directory of a local run in flight can be on disk at the moment fleet-serve starts.
The marker tells the two apart. A delegator writes OwnerFile into its job dir with its own process id before it writes anything else; the startup sweep keeps a marked directory while that process is alive and the directory is younger than MaxRunLifetime, and removes it otherwise. The marker sits beside the directory's context/ folder and never inside it: the seat's read root is context/, and a write door's root is relative to that, so neither can name the marker.
A process id means something only inside the process-id space that issued it, so the marker presumes that the delegator and fleet-serve share one: the same machine, the same kernel namespace. That is what a per-machine base directory gives, and it is the presumption the machine-wide GPU lease (internal/gpulease) and the activity registry beside it already make of their own pid-keyed records. A base directory shared between a Windows host and a WSL distribution, a container and its host, or two machines breaks it in the dangerous direction: a live owner probes as exited, and the sweep removes the dir of a run that is still going. Keep one base directory per process-id space.
The package imports nothing but the standard library, so the writer (internal/pipeline) and the sweeper (internal/fleetnode) can both import it. The pipeline package imports fleetnode, which rules out the sweeper importing the writer's package, and liveness (gpulease.PIDAlive) stays the sweeper's call: one definition of "alive" across the harness.
Index ¶
Constants ¶
const ( // OwnerFile is the marker's name, directly inside a job dir. OwnerFile = ".owner" // LocalRunPrefix is the name prefix of the directories a delegator mints for // its local runs (os.MkdirTemp pattern LocalRunPrefix+"*"). The writer and // the sweep share it so the two cannot drift apart: a directory with this // prefix and no usable marker is still a local run's, written by a binary // older than the marker or caught between its creation and its marker. LocalRunPrefix = "agent-local-" // MaxRunLifetime is the age past which a job directory is treated as a leak // whatever its owner's liveness says. It bounds the two ways an ownership // check can be wrong in the keep direction: a process id recycled by an // unrelated process after the real owner died, and a directory with no // marker at all, which has no owner to ask. // // It has to outlast the longest a LOCAL run can hold its directory, which is // the whole of pipeline.RunAgentContract (MkdirTemp to the deferred RemoveAll): // // admission 300 s core.AgentAdmissionSecDefault: the cordon, the // pre-flight, the cold-load warm-up, the coherence // and the window probes // seat-cap line 900 s modelaffinity.SeatCapDeadline: as long as the // run's own wall, which the delegator doors clamp // to core.AgentTimeoutSecCap // (delegate.PrepareContract); the admission // deadline moves out by the time spent in line, // so both are paid in full // loop + re-pack 14,400 s the liveness safety ceiling, pipeline.CeilingFor, // never above core.AgentCeilingSecCap (4 h) // seat-pin probe 3 s agent.ProbeSeatPin // ------ // 15,603 s about 4.3 h, against 86,400 s here: 5.5 times // // Two inputs are not capped in code, and a run that outlives this on either // is treated as leaked: agent_admission_wait_sec is an operator setting with // no ceiling, and RunAgentContract does not clamp timeout_sec itself, so a // contract built without delegate.PrepareContract (agent_run with a route // builds its own) carries the caller's number into the seat-cap wait. MaxRunLifetime = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func ReadOwner ¶
ReadOwner returns the process id recorded in dir's marker. ok is false for a missing, unreadable or garbled marker, for one that stops short of the terminating newline WriteOwner always writes (a prefix of "41728\n" is the digits of a different process, 4172), and for an id that is not a positive 31-bit number. !ok means only that the directory carries no usable owner; it never means the owner is dead, and a caller must not remove a directory on that evidence alone.
func WriteOwner ¶
WriteOwner records the calling process as the owner of the job directory dir. Call it right after creating the directory and before anything else goes into it, so a sweep that lists the directory at any later instant can see whose it is. The marker is one short write, so a concurrent reader sees it whole or, between the file's creation and that write, empty. It never relies on that: ReadOwner rejects any marker that does not end in the newline written here, so a write caught in the middle cannot read as another process's id, and a sweep resolves an unreadable marker toward keeping.
Types ¶
This section is empty.