Documentation
¶
Overview ¶
Package loop is `go`, the hot-path loop in one command (rust-anything's `go.rs`; a Go package cannot be called `go`): profile the workload, bridge the outermost portable hot function, record it with the calls the workload makes, hand the port to an agent, then build, diff, gate and bench it, and switch it on with `enable` only when every case matches, gate passes and the port is not slower as its callers call it. Run it again after porting by hand: every finished step is kept (the port module, a recording that is not stale, a port with no stubs left).
Index ¶
Constants ¶
const DefaultMinCases = 20
DefaultMinCases is the bar under which a recording says too little: a port checked against a dozen cases, half of them exceptions, says nothing about the original.
const DefaultRounds = 3
DefaultRounds is how many agent turns `go --agent` takes by default.
const TaskFile = "TASK.md"
TaskFile is the task `go` writes into the port module and hands to the agent.
Variables ¶
This section is empty.
Functions ¶
func AgentCommand ¶
AgentCommand is the agent's command line: `claude` and `codex` run headless with edits allowed in the port module; anything else runs as given, reading the prompt on stdin.
func ModuleName ¶
ModuleName is the port module `go` makes for a function: `fuzzyScore` gets `fuzzy-score-go`.
func SlowerAdvice ¶
SlowerAdvice is what to do when every case matches but the port, called as its callers call it, loses.
Types ¶
type Options ¶
type Options struct {
Root string
Command []string
Lang core.Lang
// Agent is `claude`, `codex`, or a command that reads the prompt on stdin; empty stops at the
// task.
Agent string
// Function is ported instead of the profile's pick.
Function string
// Count is the number of generated cases per function.
Count int
// Rounds are agent turns: the first port, then one per failed diff or gate; nil is the
// default, DefaultRounds.
Rounds *int
// MinCases is the number of recorded cases that did not throw, at least, before the port goes
// to an agent or is switched on.
MinCases int
// Progress receives each step as `go: <step>` (stderr on the command line); the agent's and
// the workload's output go there too.
Progress io.Writer
// Version is the go-anything version written to the audit log.
Version string
}
Options are `go`'s flags.
type Outcome ¶
type Outcome struct {
Stage Stage `json:"stage"`
Pick Pick `json:"pick"`
ModuleDir string `json:"module_dir"`
Task string `json:"task"`
Cases *int `json:"cases,omitempty"`
Matched *int `json:"matched,omitempty"`
Recording *RecordingFacts `json:"recording,omitempty"`
// Speedup is `bench`'s geometric-mean speedup, call included, once every check passed.
Speedup *float64 `json:"speedup,omitempty"`
FailedChecks []string `json:"failed_checks"`
Steps []string `json:"steps"`
Next string `json:"next"`
}
Outcome is what a run did and where it stopped.
type Pick ¶
type Pick struct {
Function string `json:"function"`
File string `json:"file"`
Line int `json:"line"`
TotalPct profile.Float `json:"total_pct"`
// Batch is the `function:param` the profile advises batching; `bridge --batch` is not built
// in go-anything yet, so the function is bridged alone and the plan says so.
Batch *string `json:"batch,omitempty"`
// Caller is the caller that spends the most time in it: its name and `file:line`.
Caller *[2]string `json:"caller,omitempty"`
Why string `json:"why"`
}
Pick is the function `go` ports, and why.
type RecordingFacts ¶
type RecordingFacts struct {
Cases int `json:"cases"`
// Generated cases `record` made; nil for a recording kept from an earlier run.
Generated *int `json:"generated,omitempty"`
// Captured calls the workload made, recorded as cases; nil when none were captured (or the
// recording was kept).
Captured *int `json:"captured,omitempty"`
// Threw counts the cases whose original threw.
Threw int `json:"threw"`
}
RecordingFacts are where the recorded cases came from.
type Stage ¶
type Stage string
Stage is where a run stopped.
const ( // WaitingForPort: the task is written; port port/port.go and run `go` again. WaitingForPort Stage = "waiting_for_port" // Mismatch: recorded cases still differ after the agent's turns. Mismatch Stage = "mismatch" // GateFailed: every case matches but a gate check fails. GateFailed Stage = "gate_failed" // Thin: too few recorded cases that did not throw to trust a port against. Thin Stage = "thin" // On: everything passed and the unit is switched on. On Stage = "on" // Passed: everything passed; the unit is switched with the shadow module instead. Passed Stage = "passed" // Slower: everything matches, but `bench` times the port slower than the original as its // callers call it, so it stays off. Slower Stage = "slower" )