Documentation
¶
Overview ¶
Package runner runs a delegated role through a command-line harness the operator named, with the same brief, inputs and output contract the host's own sub-agent gets (itd-2609201916056194, spc-2609221533057881).
A role's route is roles.<role>.runner in the layered configuration (config.go): host, the default, or a runner this machine enabled under runner.<name>. The shipped runners are the claude CLI in print mode with the bare flag (claude.go) and opencode's run mode (opencode.go). Each is started as a process (proc.go): the argv is a vector and never a shell line, the binary is resolved on PATH and refused inside the repository, the environment is the parent's scrubbed of every git repository-selection and config-injection variable, stdin is the null device, output is bounded, and a run past its time is killed with the process group it leads.
The fallback is decided in one place (dispatch.go): an absent, refusing, failing or unparsable runner, or an answer the contract's validator refuses, hands the role to the host session, or with no host session to the host the operator configured (runner.fallback_host), and writes one receipt naming the role, the runner asked for, the reason and the route that ran. Tally counts those receipts per runner and per role for the run's summary.
The package never prints. It starts processes only through Dispatch and the adapters' Run, and never logs a harness in: a harness's credential is its own, read from its own environment or configuration, and abcd never puts one on a command line, in an error or in a receipt.
Index ¶
- Constants
- Variables
- func AdmitClaude(repoRoot string) error
- func CheckLogin(ctx context.Context, p Profile) error
- func CheckWallSettings(p Profile, bin string) error
- func HeldCredentials() []string
- func HookedEnv(p Profile) func([]string) []string
- func LongestRun(timeout time.Duration) time.Duration
- func PinPrograms(names ...string)
- func PreflightEnv(p Profile) []string
- func ProveWall(ctx context.Context, p Profile, bin string) error
- func ResetStageHome(p Profile) error
- func SelfBinary() string
- func SessionOnProfile(home, configDir string) (on bool, why string)
- func StageCachesNote(p Profile) string
- func WriteWallSettings(p Profile, bin string) (replaced bool, _ error)
- type Answer
- type AwaitRepeat
- type Blame
- type ClaudeCLI
- type Command
- type Config
- func (c *Config) FallbackHost() string
- func (c *Config) FlagRoutes() map[string]string
- func (c *Config) JudgeOnOpenCode() bool
- func (c *Config) Ledger() *Ledger
- func (c *Config) OnWalledLogin() bool
- func (c *Config) Override(routes []oracle.FlagRoute) error
- func (c *Config) PinnedToHost(roles []string) []string
- func (c *Config) ProbeLimit(ctx context.Context, role, model string) (bool, *Failure)
- func (c *Config) Quota(ctx context.Context, name string) (Quota, bool, error)
- func (c *Config) RouteFor(role string) Route
- func (c *Config) Runner(name string) (RunnerConfig, bool)
- func (c *Config) TimeoutFor(role string) time.Duration
- func (c *Config) Walled(p Profile) *Config
- type Counts
- type Dispatcher
- type Failure
- type FallbackReceipt
- type HarnessSeen
- type HistoryStore
- type LaunchEnd
- type LaunchStart
- type LaunchWork
- type Ledger
- type LedgerEntry
- type LedgerListing
- type LedgerProblem
- type LedgerQuery
- type LedgerTotals
- type LimitError
- type NoVerdictError
- type OpenCodeCLI
- type Orchestrator
- type Outcome
- type Output
- type Profile
- type Quota
- type QuotaReporter
- type Reason
- type Request
- type Retention
- type RoleReceipt
- type Route
- type RouteRecord
- type Runner
- type RunnerConfig
- type Sides
- type Spend
- type TranscriptStore
- type WallError
Constants ¶
const ( RouteKey = "key" RouteSubscription = "subscription" RouteHost = "host" RouteUnknown = "unknown" )
The billing routes an entry names. Only RouteKey's cost counts as spend.
const ( OutcomeRunning = "running" OutcomeFinished = "finished" OutcomeFailed = "failed" OutcomeStopped = "stopped" OutcomeHanded = "handed-to-host" OutcomeLost = "lost" )
The outcomes an entry names. OutcomeLost is never written: a reader judges it, of a running entry whose process is gone.
const ( OrchestratorSession = "session" OrchestratorRun = "run" )
The kinds of orchestrator: a host session, or a run with no session over it.
const ( DefaultRetentionDays = 30 DefaultRetentionCount = 20000 )
The shipped retention (decision 14).
const ( StageHomeEnv = abcdhome.StageHomeEnv StageProtectEnv = "ABCD_STAGE_PROTECT" StageDeclaredEnv = "ABCD_STAGE_DECLARED" StageBaseEnv = "ABCD_STAGE_BASE" )
The rest of what a walled launch's guard reads: the shell's home, what is protected from the stage, what its work declares it changes, and the commit its lane was cut from.
const ( // ProfilesIntent admits several named profiles. ProfilesIntent = "itd-2611040344170206" // BudgetIntent covers how a key reaches the harness and what it may spend. BudgetIntent = "itd-2611011230226453" )
The intents a drive's refusals name.
const ( Host = "host" Claude = "claude" OpenCode = "opencode" )
The routes a role may name. Host is the default.
const ( MinTimeout = 5 * time.Minute MaxTimeout = 12 * time.Hour )
MinTimeout and MaxTimeout bound a roles.<role>.timeout the person sets.
const ( WallLogin = "login state" WallSettingsFile = "settings" WallLaunch = "live launch" WallTools = "tool list" WallServers = "servers" WallPlugins = "plugins" WallKey = "no key" WallGuard = "guard" WallWorkingTree = "working tree's settings" WallHome = "shell's home" WallEnv = "shell's environment" WallIdentity = "git identity" )
The walls a drive names when one does not hold.
const ApproverTool = "mcp__abcd__approve"
ApproverTool is the permission prompt tool a shell launch names.
const ConfigDirEnv = "CLAUDE_CONFIG_DIR"
ConfigDirEnv is the variable that points the agent tool at its configuration directory. Another host's session reports no such variable and so reads as off a profile.
const CostNote = "a cost is the harness's own estimate at its price table, and the provider's invoice is the final figure; " +
"only a key's cost counts as spend"
CostNote is said wherever a cost is shown (the fourth scope condition).
const DefaultImplementerTimeout = 3 * time.Hour
DefaultImplementerTimeout bounds an implementer's run when the person set no roles.implementer.timeout. An implementer builds, commits, writes its report and runs its scoped definition of done, which waits at the load gate behind other preflights on a shared machine; on 2026-11-01 three routed implementers were killed at the hour with their work committed and their receipts unwritten (iss-2611012202511008).
const DefaultTimeout = 60 * time.Minute
DefaultTimeout bounds one run when the request names no timeout and the person set no roles.<role>.timeout (Config.TimeoutFor).
const HostSessionEnv = "CLAUDE_CODE_SESSION_ID"
HostSessionEnv is where the host exports the id of the session running a command (decision 10).
const LedgerSchema = 1
LedgerSchema is the version of the entries this build writes. A reader takes an entry above it as far as it can and names it as newer.
const RetentionFloorDays = 32
RetentionFloorDays is the shortest the store ever keeps an entry: the longest cap period a key's budget counts, a calendar month of 31 days (itd-2611011230226453), plus one day, so a month's totals are always summed from entries still held.
const StageWritesEnv = "ABCD_STAGE_WRITES"
StageWritesEnv names where a walled launch's file tools may write.
const TokenBasis = "every count the harness reports: prompt, completion, cache read and cache write"
TokenBasis is what a token total counts, said wherever one is shown: reasoning tokens sit inside the completion count, so they add nothing.
Variables ¶
var ( ErrNotOnPath = errors.New("not on PATH") ErrRefused = errors.New("refused before it is run") ErrNotStarted = errors.New("could not be started") ErrKilled = errors.New("killed") )
The launch stages a Failure can name through errors.Is: the program was not found, it was found and refused, or it was admitted and could not start. ErrKilled names a run that started and was killed, past its time or when the run it belongs to ended (iss-2611021751406429): its work may stand in its working tree, and what it spent shows only in its transcript. Every other failure (a non-zero exit, an overrun bound) is none of them.
var ( ErrNoProfile = errors.New("no profile directory") ErrSeveralProfiles = errors.New("more than one profile directory") )
The refusals DriveProfile names, through errors.Is.
Functions ¶
func AdmitClaude ¶ added in v0.16.2
AdmitClaude reports why the claude harness would not be run from the checkout repoRoot, nil when it would.
func CheckLogin ¶ added in v0.16.2
CheckLogin asks the harness whether the walled directory has a login. It reads the one state and keeps nothing else the harness reports.
func CheckWallSettings ¶ added in v0.16.2
CheckWallSettings compares the walled settings with what abcd wrote for bin.
func HeldCredentials ¶ added in v0.16.2
func HeldCredentials() []string
HeldCredentials names each of credentialVars set in this process's environment. It reports the names alone and keeps no value.
func HookedEnv ¶ added in v0.16.2
HookedEnv is the environment a hook the driver's own git runs gets: what a stage carries, under its home, with git's own settings kept and the configuration the drive wrote in place of whatever a stage left in that home.
func LongestRun ¶ added in v0.16.1
LongestRun is the longest a run of the given bound can last: its bound and the most it is credited for waiting at the load gate.
func PinPrograms ¶ added in v0.16.2
func PinPrograms(names ...string)
PinPrograms fixes what each program name means for the rest of this process and what it starts: the directory each resolves into goes first on PATH, in PATH's own order, so each name keeps its first match and one placed earlier on PATH later is not what runs. A name not on PATH is left.
func PreflightEnv ¶ added in v0.16.2
PreflightEnv is the environment a lane's preflight runs in: what a stage carries, under its home, with the person's home named for the load gate and the Go caches kept. Nothing else of the parent's passes.
func ProveWall ¶ added in v0.16.2
ProveWall starts one short live launch on p and reads each wall from what the harness reports: the tools it holds are the ones the launch named, the only server is the approver, no plugin is loaded, no key is in use, the guard hook refuses a command it is meant to refuse, and a settings file in the working tree has no effect. bin is the abcd binary serving the approver.
func ResetStageHome ¶ added in v0.16.2
ResetStageHome makes a stage's home empty but for its git configuration, so nothing one stage leaves there reaches the next or a preflight. Every step goes through a root on the home's parent, so it stays inside: no link, however it came to be there, carries a change of mode, a removal or a write out of the tree. A home that is no real directory is refused, not followed.
func SelfBinary ¶ added in v0.16.2
func SelfBinary() string
SelfBinary is the absolute path of the running abcd, "" when the system cannot name it: the binary a drive's hooks name.
func SessionOnProfile ¶ added in v0.16.2
SessionOnProfile reports whether configDir, the value of ConfigDirEnv in the session's environment, names a profile of the person whose home directory is home. When it does not, why says how the setting reads, naming neither the variable nor a path.
A profile is a directory directly under the profiles' folder, judged after resolving configDir's links, so a link out of the folder is off and a link into it is on. Only home itself may be reached through a link, as temporary and some home directories are: a linked ~/.abcd.noindex or profiles folder reads as off, as a linked level of abcd's home is refused everywhere else. Every doubt reads as off, since a warning printed once too often costs a line.
func StageCachesNote ¶ added in v0.16.2
StageCachesNote says why the stages on p's shell home will not use the person's Go caches, "" when they will or there is no Go: what WriteWallSettings found.
func WriteWallSettings ¶ added in v0.16.2
WriteWallSettings writes the walled settings at each start, so a new binary re-wires them. It reports whether it replaced a file that abcd did not render, which the caller says. Nothing else in the directory is touched.
Types ¶
type Answer ¶
type Answer struct {
// Text is the harness's final message.
Text string
// Model is the model the harness reports, "" when it reports none: the
// model the runner asked for is Sides.ModelAsked, and never stands in for
// the one that answered (itd-166, iss-2610161709506207).
Model string
// SessionID is the harness's own session id, "" when it reports none.
SessionID string
// Sides is both sides of the run: what the runner asked for, and the
// token counts, cost and served models the harness's events report.
Sides
// contains filtered or unexported fields
}
Answer is the one answer shape every adapter parses its harness's events into. The contract's own answer is the receipt file; this is what the harness said about the run.
type AwaitRepeat ¶ added in v0.16.2
type AwaitRepeat struct {
Run string `json:"run"`
Lane string `json:"lane,omitempty"`
Await string `json:"await"`
Launches []string `json:"launches"`
}
AwaitRepeat is two or more launches for one await: the first place a role paid for twice shows (iss-2611031337115764).
type Blame ¶ added in v0.16.2
type Blame int
Blame is what a failed launch says of the work it was launched for.
const ( // BlameNone: nothing: it shows an outage, or no launch ran. BlameNone Blame = iota // BlameAsk: it does not say; a probe answering shows the account is alive, // which leaves the work. BlameAsk // BlameWork: its answer was refused, so the work is what failed. BlameWork )
What a failed launch says.
type ClaudeCLI ¶
type ClaudeCLI struct {
// contains filtered or unexported fields
}
ClaudeCLI is the claude CLI runner.
type Command ¶ added in v0.13.0
type Command struct {
// Name is the program's fixed name, looked up on PATH; a name carrying a
// path separator is refused, so no caller can point Exec at a file.
Name string
// Args is the argument vector, never a shell line.
Args []string
// Dir is the working directory the program runs in; empty runs it at the
// file-system root, never in the caller's directory, which for abcd is
// usually a project whose settings a vendor binary must not read.
Dir string
// Guards are the folders a program resolving inside is refused from,
// lexically or through a link: repository content is never run. A caller
// running in or for a project passes it here; Exec cannot know it.
Guards []string
// Timeout bounds the run; past it the program's group is killed. A
// command without one is never run.
Timeout time.Duration
// MaxStdout and MaxStderr bound each stream; past either the run fails.
MaxStdout, MaxStderr int
}
Command is one program found on PATH that another package runs under this file's discipline: the one launch primitive abcd has for a vendor binary, so a second copy of the admission, the group kill and the bounds is never written. Zero output bounds take a harness's own.
type Config ¶
type Config struct {
// Diagnostics are the non-fatal reports the read produced, one line each,
// for a front door to print on stderr.
Diagnostics []string
// contains filtered or unexported fields
}
Config is the runner configuration one invocation read.
func Load ¶
Load reads and validates the runner configuration. A fault is an error naming the file and the key; none falls through to a default.
func (*Config) FallbackHost ¶
FallbackHost is the runner that runs a role when there is no host session, "" when none is configured.
func (*Config) FlagRoutes ¶ added in v0.16.0
FlagRoutes are the roles the person's --route routed for this invocation (Override), each with the --route text verbatim; nil when none did.
func (*Config) JudgeOnOpenCode ¶ added in v0.16.2
JudgeOnOpenCode reports whether the machine routes the drain's judge to opencode.
func (*Config) Ledger ¶ added in v0.16.2
Ledger is the launch ledger this configuration's launches are written to.
func (*Config) OnWalledLogin ¶ added in v0.16.2
OnWalledLogin reports whether every launch runs on a walled login (Walled).
func (*Config) Override ¶ added in v0.16.0
Override places the person's --route runner routes (oracle.ParseRunnerRoutes) in the flag layer, for this invocation alone (iss-2610161801358637): each hands its role to the runner it names, asking for the model it names in place of the runner's machine model, which stays every other role's. The flag is the person's own, so it may hand a role to a runner as the machine file may (personal), but only to a runner this machine enabled, and only for a model the runner's provider lists: the allowlist check a machine model route passes (adr-2609221009491186). A refusal routes nothing and names the fix.
func (*Config) PinnedToHost ¶ added in v0.16.2
PinnedToHost lists those of roles a configured layer keeps on the host.
func (*Config) ProbeLimit ¶ added in v0.16.2
ProbeLimit asks whether a limit has lifted for role, with one short launch on the profile, on model, a model route, or the runner's own for "". It reports true when the launch answers what it was asked; otherwise the failure says what came back: a rate-limited one with the reset it named, if any, or any other, which says nothing about the limit.
func (*Config) Quota ¶ added in v0.14.0
Quota asks the runner the machine enabled under name for its remaining quota. The host, and a name the machine has not enabled, report none.
func (*Config) RouteFor ¶
RouteFor returns where role runs: its configured route, or the host from the bundled default.
func (*Config) Runner ¶
func (c *Config) Runner(name string) (RunnerConfig, bool)
Runner returns the runner this machine enabled under name.
func (*Config) TimeoutFor ¶ added in v0.16.1
TimeoutFor is how long one run of role may take on a runner: the machine's roles.<role>.timeout, else DefaultImplementerTimeout for the implementer and DefaultTimeout for every other role.
type Counts ¶
type Counts struct {
Total int `json:"total"`
ByRunner map[string]int `json:"by_runner"`
ByRole map[string]int `json:"by_role"`
// CostUSD is what the killed launches among them spent, as their
// transcripts show it in USD, and ChargedRuns the agent runs charged for
// those whose transcripts show no cost (Spend).
CostUSD float64 `json:"cost_usd,omitempty"`
ChargedRuns int `json:"charged_runs,omitempty"`
}
Counts is the fallback intel a run's summary reports.
func Tally ¶
func Tally(rs []FallbackReceipt) Counts
Tally counts fallback receipts per runner asked for and per role. A run with none reports zero, with empty maps rather than none.
type Dispatcher ¶
type Dispatcher struct {
// Config is the runner configuration read at the lane's start.
Config *Config
// HostSession is true when a host session drives the loop and can take a
// role handed back to it.
HostSession bool
// Attended is true when the person is at the terminal with no host session
// (the plain-Terminal interviews, spc-2610030911534855): a role routed to a
// runner runs there although no runner.fallback_host is configured, and a
// runner that does not answer stops the run, its fallback receipt naming
// none as the route that ran, rather than leaving the role nowhere to land.
// A role on the host still needs a host session or a configured host.
Attended bool
// Validate is the contract's validator: the same check the host sub-agent's
// answer passes. It is handed the runner that ran the role, so a caller
// whose validator also records the answer (the loop's receipt verifier)
// can name the route that ran.
Validate func(runner string, req Request, ans Answer) error
// Transcripts is where every runner's transcript lands.
Transcripts TranscriptStore
// Record appends one fallback receipt to the run's state.
Record func(FallbackReceipt) error
// Prepare, when set, readies req's files for the runner about to run it,
// before each runner starts: the routed one and a fallback host alike. A
// *Failure it returns is that runner's failure, recorded and fallen back
// on as a launch's would be, with nothing launched; any other error ends
// the dispatch.
Prepare func(runner string, req Request) error
// Now is the clock the receipts are stamped with; time.Now when nil.
Now func() time.Time
}
Dispatcher runs roles by their routes.
type Failure ¶
type Failure struct {
Runner string
Reason Reason
Detail string
// Spent is what a killed launch spent, read from its transcript
// (ErrKilled, Spend); nil for every other failure.
Spent *Spend
// ResetsAt is when a rate limit resets, as the harness reported it; zero
// when it reported none or the failure is no limit.
ResetsAt time.Time
// Seen is what the harness showed of its failure, for a run's evidence
// file; nil when no launch ran. It stays out of Detail, which is abcd's.
Seen *HarnessSeen
// Model is the model route the failed launch asked for, "" for the
// harness's own default.
Model string
// contains filtered or unexported fields
}
Failure is a runner's failure. Detail is written by abcd, never copied from the harness's output, so it cannot carry anything the harness printed, a credential it echoed included.
func (*Failure) Blame ¶ added in v0.16.2
Blame is what this launch says of the work it was launched for. Only an answer the contract refused shows that by itself. A launch that spent may have lost the service afterwards, so that is the probe's to settle: a live account answers, and a service that is down does not. With nothing spent, a launch that was retrying the model service, or a result naming a status that is the account's or the service's, says nothing of the work. An init event shows nothing either: on 2.1.318 it was seen to come before any contact with the model. Anything else does not say, so the caller may ask a probe.
type FallbackReceipt ¶
type FallbackReceipt struct {
At time.Time `json:"at"`
Role string `json:"role"`
Asked string `json:"asked"`
Reason Reason `json:"reason"`
// Detail is abcd's own account of the reason; it never carries the
// harness's output.
Detail string `json:"detail"`
Ran string `json:"ran"`
// Spent is what the launch spent when it was killed (ErrKilled), read
// from its transcript; nil for every other failure, which spent nothing
// a transcript shows or reported its spend as it ended.
Spent *Spend `json:"spent,omitempty"`
}
FallbackReceipt is one fallback: the role, the runner asked for, the reason, and the route that ran instead.
type HarnessSeen ¶ added in v0.16.2
type HarnessSeen struct {
// ExitCode is the process's status, -1 when it was killed or did not exit.
ExitCode int
// Shape is the end of its event stream, one line per event, with every
// identifier dropped and free text reduced to its length.
Shape []string
// Stderr is the first line it wrote to stderr.
Stderr string
// SilentFor is how long it had written nothing when it ended.
SilentFor time.Duration
// Spent says its stream shows tokens or a cost above zero.
Spent bool
// APIStatus is the status a failed result names, "" for none.
APIStatus string
// Retries counts the retries of the model service its stream reports, and
// Retrying says the stream ended on one.
Retries int
Retrying bool
}
HarnessSeen is what a launch that failed showed, in the terms a person needs to learn how a harness behaves at a limit: nothing here is read to decide anything. The strings are the harness's own and not yet redacted, so whoever keeps them passes them through the scanner first.
type HistoryStore ¶
HistoryStore is the production store: the repository's lane of the user-level transcript store, keyed on its root commit.
type LaunchEnd ¶ added in v0.16.2
type LaunchEnd struct {
Answer Answer
// Transcript is the harness's event stream, what a failed or killed launch
// has to show for itself.
Transcript []byte
// Err is the launch's own failure, which RecordLaunch records and returns
// to the caller untouched.
Err error
}
LaunchEnd is what a launch returned.
func RecordLaunch ¶ added in v0.16.2
func RecordLaunch(ctx context.Context, l *Ledger, s LaunchStart, run func(context.Context) LaunchEnd) (LaunchEnd, error)
RecordLaunch is the one way an entry is written. It writes the entry marked running, runs run with a context launchStarted answers on, and completes the entry from what run returned; a nil run is a role handed to the host, which gets a placeholder with no figures (decision 21).
An error means nothing ran: the entry could not be written, and a launch that could not be recorded is not started, since the claim is that none escapes the record. The launch's own failure comes back in LaunchEnd.Err. A completion that cannot be written leaves the answer standing and the entry as it was, which a reader shows as lost once the process is gone.
type LaunchStart ¶ added in v0.16.2
type LaunchStart struct {
Role string
// Runner is the runner that will run it, or Host for a role handed over.
Runner string
// ModelAsked is the model the runner asks for, "" for the harness's own.
ModelAsked string
// Repo is the checkout the launch works for.
Repo string
Work LaunchWork
// Fallback names the orchestrator when no session and no run does: the
// launch's own transcript session.
Fallback string
// Key is the configured name of the key abcd handed this launch, never
// its value; "" when it handed none.
Key string
}
LaunchStart is what is known of a launch before it starts.
type LaunchWork ¶ added in v0.16.2
LaunchWork is the piece of work a launch is for: the run, lane and await, or an interview and its turn. Each is free of meaning to the ledger but for the listing, and two launches naming one await are named as a pair.
type Ledger ¶ added in v0.16.2
type Ledger struct {
// contains filtered or unexported fields
}
Ledger is the store one machine's launches are written to.
func (*Ledger) Read ¶ added in v0.16.2
func (l *Ledger) Read(q LedgerQuery) (LedgerListing, error)
Read is ReadLedger on this ledger's store.
type LedgerEntry ¶ added in v0.16.2
type LedgerEntry struct {
Schema int `json:"schema_version"`
ID string `json:"id"`
Orchestrator Orchestrator `json:"orchestrator"`
Repo string `json:"repo,omitempty"`
Run string `json:"run,omitempty"`
Lane string `json:"lane,omitempty"`
Await string `json:"await,omitempty"`
Role string `json:"role"`
Runner string `json:"runner"`
ModelAsked string `json:"model_asked,omitempty"`
// Route is the billing route, Key the configured name of a key route's
// key, and RouteWhy why a route reads unknown.
Route string `json:"route"`
Key string `json:"key,omitempty"`
RouteWhy string `json:"route_why,omitempty"`
// Model is the model the harness says answered.
Model string `json:"model,omitempty"`
Usage *oracle.Usage `json:"usage,omitempty"`
Cost *oracle.Cost `json:"cost,omitempty"`
// APIMillis is the time the harness says it spent waiting on the model,
// absent when it reports none.
APIMillis *int64 `json:"api_ms,omitempty"`
WallMillis int64 `json:"wall_ms,omitempty"`
Outcome string `json:"outcome"`
Reason string `json:"reason,omitempty"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at,omitempty"`
// PID is the process a reader judges a running entry by: the launcher's
// until the harness has started, then the harness's. PIDStartUnix is the
// harness's start, which tells it from a later process given the same id;
// zero while PID is the launcher's.
PID int `json:"pid,omitempty"`
PIDStartUnix int64 `json:"pid_start_unix,omitempty"`
}
LedgerEntry is one launch: one line of one file.
type LedgerListing ¶ added in v0.16.2
type LedgerListing struct {
Entries []LedgerEntry `json:"entries"`
Totals LedgerTotals `json:"totals"`
// TokenBasis and CostNote say what the totals count.
TokenBasis string `json:"token_basis"`
CostNote string `json:"cost_note"`
// Unreadable is every file the reader could not take as an entry. It
// cannot say whose launch one was, so a filtered listing names them too.
Unreadable []LedgerProblem `json:"unreadable"`
// Newer is the id of every entry a later abcd wrote, read as far as this
// one can.
Newer []string `json:"newer"`
// Repeats is every await with two or more launches.
Repeats []AwaitRepeat `json:"repeats"`
// LivenessUnread is true when the process table could not be read, so a
// running entry stands as written and none was judged lost.
LivenessUnread bool `json:"liveness_unread,omitempty"`
}
LedgerListing is what a read of the ledger found, oldest launch first.
func ReadLedger ¶ added in v0.16.2
func ReadLedger(home string, q LedgerQuery) (LedgerListing, error)
ReadLedger reads home's ledger for q. An absent store is an empty listing; a store that cannot be opened (behind a link, or not a folder) is an error.
type LedgerProblem ¶ added in v0.16.2
LedgerProblem is a file in the store the reader could not take as an entry.
type LedgerQuery ¶ added in v0.16.2
LedgerQuery says which launches to read: one session's, one run's, or every one.
type LedgerTotals ¶ added in v0.16.2
type LedgerTotals struct {
Launches int `json:"launches"`
Running int `json:"running"`
Finished int `json:"finished"`
Failed int `json:"failed"`
Stopped int `json:"stopped"`
Lost int `json:"lost"`
Handed int `json:"handed_to_host"`
SpendByKey map[string]float64 `json:"spend_usd_by_key"`
EstimateUSD float64 `json:"estimate_usd"`
Tokens int64 `json:"tokens"`
APIMillis int64 `json:"api_ms"`
}
LedgerTotals adds a listing up. SpendByKey is money, in USD, per key; EstimateUSD is what the rest would have cost, which is no money spent.
type LimitError ¶ added in v0.16.2
type LimitError struct {
// ResetsAt is the reset the launch named, zero when it named none.
ResetsAt time.Time
// Seen is what the launch showed.
Seen *HarnessSeen
}
LimitError is a limit a launch met before it could show anything else: a limit, never the thing it was launched to check.
func (*LimitError) Error ¶ added in v0.16.2
func (e *LimitError) Error() string
type NoVerdictError ¶ added in v0.16.2
type NoVerdictError struct {
// Detail is abcd's own words for how it ended.
Detail string
// Seen is what the launch showed.
Seen *HarnessSeen
}
NoVerdictError is the live proof's launch ending with no verdict on any check: which an outage may look like, or a limit waited out inside it. It reads as the launch's own failure, wrapped.
func (*NoVerdictError) Error ¶ added in v0.16.2
func (e *NoVerdictError) Error() string
func (*NoVerdictError) Unwrap ¶ added in v0.16.2
func (e *NoVerdictError) Unwrap() error
Unwrap reads as the failed launch to whoever does not ask for this type.
type OpenCodeCLI ¶
type OpenCodeCLI struct {
// contains filtered or unexported fields
}
OpenCodeCLI is the opencode runner.
type Orchestrator ¶ added in v0.16.2
type Orchestrator struct {
Kind string `json:"kind"`
ID string `json:"id"`
// Name is a session's persona name, "" when it has none.
Name string `json:"name,omitempty"`
}
Orchestrator is who asked for a launch.
func CurrentSession ¶ added in v0.16.2
func CurrentSession(home string) (Orchestrator, bool)
CurrentSession is the session this process runs under, with the persona name home's register holds for it: the one the host exports, else one whose host process it descends from. It reports false under neither, as a run driven from a plain terminal is.
type Outcome ¶
type Outcome struct {
// Handoff is true when the host session runs the role, exactly as it does
// with no runner configured: the caller hands the host the brief and
// awaits its receipt.
Handoff bool
// Answer is the runner's parsed answer when a runner ran the role.
Answer *Answer
// Fallback is the receipt this dispatch recorded, nil when none.
Fallback *FallbackReceipt
// Failure is the routed runner's failure the fallback was for, nil when
// none: errors.Is(Failure, ErrKilled) tells a launch killed with its
// work possibly done from one that never ran it.
Failure *Failure
// Receipt is the role's receipt block.
Receipt RoleReceipt
}
Outcome is one dispatch's result.
type Output ¶ added in v0.13.0
type Output struct {
Stdout, Stderr []byte
}
Output is what an Exec run wrote, each stream up to its bound.
func Exec ¶ added in v0.13.0
Exec admits c.Name exactly as a harness is admitted (admit) and runs it exactly as a harness is run (run): the scrubbed environment, the null device on stdin, the bounds, and the process group killed through this handle at the timeout or when ctx ends. A failure is a *Failure, whose errors.Is names the stage for ErrNotOnPath, ErrRefused and ErrNotStarted; the output is returned whenever the program produced some. Its clock never stops: the load gate's credit is a role's (gatewait.go), and c.Timeout is the caller's own bound.
type Profile ¶ added in v0.16.2
type Profile struct {
// Dir is the walled directory's absolute path.
Dir string
// StageRoot holds what a stage's shell reads: ShellHome is the home it runs
// under, and EnvFile the file it sources before each command.
StageRoot string
ShellHome string
EnvFile string
// PersonHome is the person's own home directory.
PersonHome string
// Repo is the checkout the drive runs in, whose git configuration names the
// identity a stage commits under.
Repo string
// Ledger is the launch ledger the proof's launch is written to.
Ledger *Ledger
// Env is the launch's environment switches (sealedEnv): each KEY=value is
// set over the parent's, and each bare name taken out.
Env []string
// Args are the launch's walled arguments.
Args []string
}
Profile is what a drive's launch runs on.
func DriveProfile ¶ added in v0.16.2
DriveProfile is the profile a drive runs on, below home, the person's home directory. It refuses none, several, and a directory it would not trust with the settings that decide what the drive's agents run.
func (Profile) ForCheckout ¶ added in v0.16.2
ForCheckout is p for a drive in the checkout at repo: its stage's home and shell file are that checkout's own, so a drive in another deletes nothing of this one.
type Quota ¶ added in v0.14.0
type Quota struct {
Remaining int `json:"remaining"`
}
Quota is what a runner reports of its budget before a run starts (itd-2609201925079472 criterion 7): the agent runs it can still start in its current window. A runner whose harness counts its budget in another unit converts it, or reports none.
type QuotaReporter ¶ added in v0.14.0
QuotaReporter is a Runner that reports its remaining quota. Neither shipped runner is one: the claude CLI and opencode expose no remaining quota a launch can read before it starts, so a run routed to either names it and skips the budget check out loud.
type Reason ¶
type Reason string
Reason is why a runner did not answer: the kinds the fallback records.
const ( // ReasonAbsent: the runner is not enabled on this machine, or its binary // is not on PATH or is refused. ReasonAbsent Reason = "absent" // ReasonRefused: the harness ran and reported that it refused or erred. ReasonRefused Reason = "refused" // ReasonFailed: the harness could not start, exited non-zero, ran out of // time or overran its output bound. ReasonFailed Reason = "failed" // ReasonUnparsable: the harness's output is not its structured events. ReasonUnparsable Reason = "unparsable" // ReasonInvalid: the answer failed the contract's validator. ReasonInvalid Reason = "invalid" // ReasonRateLimited: the harness reported a rate-limit response and did // not finish. It is never fallen back on (dispatch.go): every route spends // the budget the run's window paces, so the caller ends the window // (itd-2609201925079472 criterion 8). ReasonRateLimited Reason = "rate-limited" )
type Request ¶
type Request struct {
// Role is the agent the run plays: an agent in the roster, or the
// implementer.
Role string
// Brief is the absolute path of the brief the role follows; it states the
// task and the output contract.
Brief string
// Receipt is the absolute path the contract says the answer is written to.
Receipt string
// Dir is the absolute path of the working tree the role runs in.
Dir string
// Checkout is the absolute path of the checkout the run belongs to when
// Dir is a worktree of it (a lane's worktree lives outside it); a program
// inside it is repository content and is never run, as one inside Dir is
// not. Empty when Dir is the checkout itself.
Checkout string
// Tools are the tools the role's contract grants, granted without a
// prompt; none granted when empty.
Tools []string
// Base is the full object name of the commit the run's working tree was
// cut from: a lane's base, or the HEAD an interview launched on. A launch
// that grants the shell needs it, since the approver judges every
// command against the hazard registry at that commit.
Base string
// Declared are the paths the work declares it changes, relative to Dir.
Declared []string
// Denied are the tools the role is refused outright, whatever else would
// grant them: a harness that keeps a deny list takes them there, ahead of
// every grant.
Denied []string
// Model is the <provider>/<model> route this request runs at, over the
// model the runner's own route names, so one runner serves two reviewers
// at two classes (itd-2610240922461281 decision 4); "" keeps the route's.
// It is admitted against the provider's allowlist when the request is
// dispatched, as a configured route is when it is read, never trusted
// because a caller stored it.
Model string
// SessionID names the run's transcript record when the harness reports no
// session of its own.
SessionID string
// Timeout bounds the run; DefaultTimeout when zero.
Timeout time.Duration
// Work is the piece of work the launch is for, as the ledger lists it.
Work LaunchWork
// Key is the configured name of the key abcd hands this launch, never its
// value, which the ledger's route reads; "" when it hands none.
Key string
}
Request is what a role is handed: the same the host sub-agent is handed.
type Retention ¶ added in v0.16.2
Retention is how long the store keeps entries: the next writer prunes the oldest whole files past either limit, and never one inside the floor.
type RoleReceipt ¶
type RoleReceipt struct {
Role string `json:"role"`
Brief string `json:"brief"`
// Contract is the receipt path the contract names.
Contract string `json:"contract"`
Route RouteRecord `json:"route"`
}
RoleReceipt is a role run's receipt block. Everything but Route is the request's, so two runs of one request differ in their route alone.
type RouteRecord ¶
type RouteRecord struct {
// Asked is the route the configuration named: host or a runner.
Asked string `json:"asked"`
// Ran is the route that ran the role: host, a runner, or none.
Ran string `json:"ran"`
// Model is the model the runner that ran it reported, the canonical
// served model; "" on the host, whose own receipt reports it, and when
// the runner reported none.
Model string `json:"model"`
// Override is the --route text verbatim when the person's flag routed the
// role for this invocation, so a run on a chosen model is never mistaken
// for the configured route; "" otherwise.
Override string `json:"override,omitempty"`
// Sides is both sides of the run, present when a runner ran it; its
// fields are omitted when empty, so a host's or an older record reads as
// it always has.
Sides
}
RouteRecord is the route a role asked for and the one that ran it, and, when a runner ran it, both sides of the run (itd-166).
func RecordOf ¶ added in v0.16.0
func RecordOf(asked, ran string, ans Answer) RouteRecord
RecordOf is the route record of a role ran ran, routed to asked, whose harness answered ans: the served model as the canonical one, and both sides beside it.
type Runner ¶
type Runner interface {
// Name is the route's name, as roles.<role>.runner spells it.
Name() string
// Run runs the role and returns the parsed answer and the transcript, the
// harness's raw event stream. A failure is a *Failure; the transcript is
// returned whenever the harness produced one, failure or not.
Run(ctx context.Context, req Request) (Answer, []byte, error)
}
Runner is one route a role can run through.
type RunnerConfig ¶
type RunnerConfig struct {
Name string
// Model is the admitted <provider>/<model> route, "" for the harness's own
// default.
Model string
// Pin is the machine's pin for that model on that provider
// (oracle.Pin), nil when it sets none; the opencode runner holds a run
// to it.
Pin *oracle.Pin
// Local says the model's provider is a block on this machine, and
// LocalPin is the machine's local pin for the model, nil when it sets
// none (oracle.LocalPin): opencode is held to it after a probe.
Local bool
LocalPin *oracle.LocalPin
Origin string
}
RunnerConfig is one runner this machine enabled.
type Sides ¶ added in v0.16.0
type Sides struct {
// ModelAsked is the model the runner passed the harness, "" when it
// passed none and the harness chose.
ModelAsked string `json:"model_asked,omitempty"`
// ServedModels is every model the harness says served the run (claude's
// per-model usage), sorted; empty when it names none.
ServedModels []string `json:"served_models,omitempty"`
// ServedProvider is the provider the harness names as serving the
// canonical model, "" when it names none.
ServedProvider string `json:"served_provider,omitempty"`
// FinishReason is why the run's last turn stopped, as the harness says.
FinishReason string `json:"finish_reason,omitempty"`
// HarnessVersion is the harness's own version, as it reports it.
HarnessVersion string `json:"harness_version,omitempty"`
// PromptSHA256 is the SHA-256 of the prompt the runner handed the harness
// (prompt), never its text; the brief it names is the run's own file.
PromptSHA256 string `json:"prompt_sha256,omitempty"`
// Usage and Cost are the run's token counts and cost, nil when the
// harness reported none. Each count is the harness's own: claude's
// input_tokens and opencode's input exclude the cached prompt tokens,
// which are counted apart.
Usage *oracle.Usage `json:"usage,omitempty"`
Cost *oracle.Cost `json:"cost,omitempty"`
// Unpinned lists every field of the fixed lists the run could not pin.
Unpinned []oracle.Unpinned `json:"unpinned,omitempty"`
// ProviderPin is the pin the run's opencode was pointed at, and
// PinConfigSHA256 the SHA-256 of the sealed configuration that carried it
// (pin.go); empty when the run was not pinned. It is what was configured,
// not what reached OpenRouter, so Unpinned lists it as not verified.
ProviderPin *oracle.Pin `json:"provider_pin,omitempty"`
PinConfigSHA256 string `json:"pin_config_sha256,omitempty"`
// LocalPin is the local pin of a run routed to a model on this machine
// (oracle.LocalPin, iss-2610161734428291), and LocalServed what the
// server reported when it was probed before the run; both absent on any
// other route. LocalServed describes the probe, not the run: opencode
// can still be pointed at another server (askedUnpinned), so the local
// fields stay not verified. PinConfigSHA256 is then the sealed
// configuration that pointed opencode at the probed server.
LocalPin *oracle.LocalPin `json:"local_pin,omitempty"`
LocalServed *oracle.LocalServed `json:"local_served,omitempty"`
// Local says the route's provider is a block on this machine, so the
// record lists the local fields (iss-2610171545099084). A harness's
// output cannot say so; the configuration does.
Local bool `json:"local,omitempty"`
}
Sides is both sides of a run as a runner records them. Every string the harness supplied is cleaned and bounded (cleanHarness) before it is set.
type Spend ¶ added in v0.16.1
type Spend struct {
Usage *oracle.Usage `json:"usage,omitempty"`
Cost *oracle.Cost `json:"cost,omitempty"`
// ChargedRuns is the agent runs the launch is charged when its
// transcript shows no cost: one, else zero.
ChargedRuns int `json:"charged_runs,omitempty"`
}
Spend is what a killed launch spent (iss-2611021751406429). A harness killed at its bound writes no closing event, so the cost it would have reported there never comes: the token counts and any cost its transcript does carry are read from it instead, and a launch whose transcript shows no cost is charged as one agent run of its runner's budget, the unit Quota counts, so its spend is never dropped from the tally.
type TranscriptStore ¶
TranscriptStore keeps one runner's transcript of one role's run.