harness

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 10 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 harness recognizes the processes of the coding agents stagent knows (Claude Code, Codex, omp), and connections that come from their process trees (guard.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interpreter

func Interpreter(n string) bool

Interpreter reports whether n (a ptable.BaseName) is a script interpreter an agent may run under.

func Name

func Name(n string) string

Name returns the harness a program called n (a ptable.BaseName) is, "" for other programs.

func Of

func Of(name string, argv []string) string

Of recognizes an agent by its process name, its argv[0] (native binaries, and scripts that set their process title) or the script an interpreter runs; "" for other processes.

Types

type Guard

type Guard struct {
	// PeerPID returns the pid of the process that connected c.
	PeerPID func(c net.Conn) (int, error)
	Table   Table
	// Sandboxed tells whether pid runs in a macOS sandbox (nil: not
	// asked). Seatbelt has no PID namespace, so a sandboxed command that
	// double forks leaves the agent's tree but stays sandboxed.
	Sandboxed func(pid int) bool
}

Guard tells whether a connection comes from a coding agent's process tree, which stagent refuses (ADR 0004): with a sandboxed agent's commands approved without asking, the agent could otherwise type approvals into its own session or commands into another one outside its sandbox.

func NewGuard

func NewGuard(l *paths.Layout) *Guard

NewGuard returns the guard of the stagent location l: nil, which refuses nothing, when l is isolated (STAGENT_HOME: tests and development, which run under agents) and on Windows, which keeps the parent pid of a process whose parent exited, so parents cannot be told reliably. The receiving side decides with its own layout, so a client cannot opt out.

func (*Guard) Check

func (g *Guard) Check(c net.Conn) *wire.Error

Check returns nil when c may be served, else the agent_refused error to answer its requests with. A connection whose process cannot be read any more is refused too: a process could otherwise hand its socket to a child and exit before it is checked.

func (*Guard) CheckPID

func (g *Guard) CheckPID(pid int) *wire.Error

CheckPID is Check for the process pid: the bridge asks it of itself before it starts a holder that would refuse its connection.

type Table

type Table struct {
	Process func(pid int) (ptable.Proc, bool)
	Argv    func(pid int) ([]string, error)
}

Table reads single processes; ptable.Process and ptable.Argv on a real host.

func (Table) Agent

func (t Table) Agent(pid int) (string, error)

Agent returns the harness that pid is, or that is one of its ancestors ("" when there is none). It fails when that cannot be told: pid exited, its ancestry is deeper than maxAncestry, or kept changing.

An ancestor that cannot be read while its child is still there with the same parent ends the walk: it runs as another user, or is hidden like one (Linux's hidepid), and an agent runs as stagent's user — the only user ipc lets connect. When the child is gone or has a new parent instead, an ancestor exited meanwhile, and the walk starts again from pid along the new parents (up to a sandbox's subreaper).

Jump to

Keyboard shortcuts

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