Documentation ¶
Index ¶
- Constants
- Variables
- func CmdLogGroupsToFile(ws WatWorkspace, gs []CommandLogGroup) error
- func Execute() (outerErr error)
- func Init(a analytics.Analytics, dir string) error
- func MakeWatIgnore(root string) error
- func MustJson(obj interface{}) string
- func RecentFileInfos(ws WatWorkspace) ([]fileInfo, error)
- func RecentFileNames(ws WatWorkspace) ([]string, error)
- func RunCommands(ctx context.Context, ws WatWorkspace, cmds []WatCommand, timeout time.Duration, ...) error
- func TermBold(s string) string
- type CommandList
- type CommandLog
- type CommandLogGroup
- type CommandWithCondition
- type Condition
- type CostEstimate
- type DecisionStore
- func (s DecisionStore) AddCommandLogGroup(g CommandLogGroup)
- func (s DecisionStore) AddCommandLogGroups(logGroups []CommandLogGroup)
- func (s DecisionStore) Cost(cmd WatCommand) time.Duration
- func (s DecisionStore) CostSensitiveGain(cmd WatCommand, cond Condition) float64
- func (s DecisionStore) FailureProbability(cmd WatCommand, cond Condition) float64
- func (s DecisionStore) HasCost(cmd WatCommand) bool
- type LogContext
- type LogSource
- type PackageJSON
- type PluginGo
- type PluginNodeJS
- type PluginPytest
- type ResultHistory
- type WatCommand
- type WatCommandCostSort
- type WatWorkspace
- func (w WatWorkspace) Append(name, contents string) error
- func (w WatWorkspace) AppendLine(name, contents string) error
- func (w WatWorkspace) Exists(name string) (bool, error)
- func (ws WatWorkspace) Fatal(msg string, err error)
- func (w WatWorkspace) Read(name string) ([]byte, error)
- func (w WatWorkspace) Root() string
- func (w WatWorkspace) Stat(name string) (os.FileInfo, error)
- func (w WatWorkspace) WalkDir(dir string) ([]fileInfo, error)
- func (w WatWorkspace) WalkRoot() ([]fileInfo, error)
- func (w WatWorkspace) Write(name, contents string) error
Constants ¶
const AsciiEnter = 13
const AsciiEsc = 27
const AsciiLineFeed = 10
const Divider = "--------------------\n"
Variables ¶
var CmdTimeout time.Duration
var ErrNoWatRoot = errors.New("No wat root found")
Functions ¶
func CmdLogGroupsToFile ¶
func CmdLogGroupsToFile(ws WatWorkspace, gs []CommandLogGroup) error
func MakeWatIgnore ¶
func RecentFileInfos ¶
func RecentFileInfos(ws WatWorkspace) ([]fileInfo, error)
func RecentFileNames ¶
func RecentFileNames(ws WatWorkspace) ([]string, error)
func RunCommands ¶
func RunCommands(ctx context.Context, ws WatWorkspace, cmds []WatCommand, timeout time.Duration, outStream, errStream io.Writer, logContext LogContext) error
Runs the given commands and logs their results to file for use in making our ML model
Types ¶
type CommandList ¶
type CommandList struct { Timestamp time.Time Commands []WatCommand }
func List ¶
func List(ctx context.Context, ws WatWorkspace, ttl time.Duration) (CommandList, error)
Get the list of commands.
If there are already commands on disk fresher than the ttl, return those commands. Otherwise, generates a list of available WatCommands (i.e. command + associated files) and writes them to disk (.wat/list).
Set the ttl to 0 to always regenerate.
type CommandLog ¶
type CommandLogGroup ¶
type CommandLogGroup struct { Logs []CommandLog Context LogContext }
All the commands that ran at a particular state of the workspace, grouped together.
func ReadCmdLogGroups ¶
func ReadCmdLogGroups(ws WatWorkspace) ([]CommandLogGroup, error)
func Train ¶
func Train(ctx context.Context, ws WatWorkspace, cmds []WatCommand, ttl time.Duration) ([]CommandLogGroup, error)
Gets training data.
If sufficiently fresh training data lives on disk, return that data. Otherwise, generate new training data and write it to disk.
func (*CommandLogGroup) Add ¶
func (g *CommandLogGroup) Add(l CommandLog)
type CommandWithCondition ¶
type Condition ¶
type Condition struct { // A known recently-edited file. EditedFile string // A known successful command. SuccessCommand string }
The environment that a test is run in.
Must be a value struct so that we can use it as a key in a map.
func (Condition) Ancestors ¶
Get all the conditions that are "ancestors" of this condition, from most narrow to most broad.
func (Condition) WithEditedFile ¶
func (Condition) WithSuccess ¶
type CostEstimate ¶
type CostEstimate struct { Duration time.Duration Count int // If false, we've only seen bootstrapped durations Real bool }
func (CostEstimate) Add ¶
func (c CostEstimate) Add(log CommandLog, ctx LogContext) CostEstimate
Creates a new cost estimate after working in the old cost estimate.
type DecisionStore ¶
type DecisionStore struct {
// contains filtered or unexported fields
}
func (DecisionStore) AddCommandLogGroup ¶
func (s DecisionStore) AddCommandLogGroup(g CommandLogGroup)
func (DecisionStore) AddCommandLogGroups ¶
func (s DecisionStore) AddCommandLogGroups(logGroups []CommandLogGroup)
func (DecisionStore) Cost ¶
func (s DecisionStore) Cost(cmd WatCommand) time.Duration
func (DecisionStore) CostSensitiveGain ¶
func (s DecisionStore) CostSensitiveGain(cmd WatCommand, cond Condition) float64
A gain metric. Currently expressed as a unit of gain / cost Gain is directly proportional to failure probability, as explained in the design doc. Cost is expressed in seconds We weight gain higher than cost as gain ^ 2 / cost
func (DecisionStore) FailureProbability ¶
func (s DecisionStore) FailureProbability(cmd WatCommand, cond Condition) float64
func (DecisionStore) HasCost ¶
func (s DecisionStore) HasCost(cmd WatCommand) bool
type LogContext ¶
type LogSource ¶
type LogSource int
const ( // An edit made by the user LogSourceUser LogSource = iota // An made-up command-log used to bootstrap training, // so that we have interesting data to work with before the // user runs any commands. LogSourceBootstrap // An edit automatically generated by a fuzzer LogSourceFuzz // Logs generated when the trainer runs the commands // in the workspace for the first time. LogSourceTrainInit )
type PackageJSON ¶
type PluginNodeJS ¶
type PluginNodeJS struct { }
type PluginPytest ¶
type PluginPytest struct{}
type ResultHistory ¶
func (ResultHistory) Add ¶
func (h ResultHistory) Add(success bool) ResultHistory
type WatCommand ¶
func Decide ¶
func Decide(ctx context.Context, ws WatWorkspace, n int) ([]WatCommand, error)
func RunBuiltinPlugins ¶
func RunBuiltinPlugins(ctx context.Context, ws WatWorkspace) (result []WatCommand)
func RunUserPlugins ¶
func RunUserPlugins(ctx context.Context, ws WatWorkspace) (result []WatCommand, err error)
func (WatCommand) Empty ¶
func (c WatCommand) Empty() bool
func (WatCommand) PrettyCmd ¶
func (c WatCommand) PrettyCmd() string
PrettyCmd returns a string suitable for prettily printing this cmd to terminal
type WatCommandCostSort ¶
type WatCommandCostSort struct { Commands []WatCommand DS DecisionStore }
func (WatCommandCostSort) Len ¶
func (s WatCommandCostSort) Len() int
func (WatCommandCostSort) Less ¶
func (s WatCommandCostSort) Less(i, j int) bool
func (WatCommandCostSort) Swap ¶
func (s WatCommandCostSort) Swap(i, j int)
type WatWorkspace ¶
type WatWorkspace struct {
// contains filtered or unexported fields
}
func GetOrInitWatWorkspace ¶
func GetOrInitWatWorkspace() (WatWorkspace, error)
func GetOrInitWatWorkspaceAt ¶
func GetOrInitWatWorkspaceAt(wd string, a analytics.Analytics) (WatWorkspace, error)
func (WatWorkspace) Append ¶
func (w WatWorkspace) Append(name, contents string) error
Append appends the given contents to the specified file in the .wat dir (<wat_root>/.wat/<name>)
func (WatWorkspace) AppendLine ¶
func (w WatWorkspace) AppendLine(name, contents string) error
AppendLine appends the given contents as a newline
func (WatWorkspace) Fatal ¶
func (ws WatWorkspace) Fatal(msg string, err error)
func (WatWorkspace) Read ¶
func (w WatWorkspace) Read(name string) ([]byte, error)
Read reads the specified file from the .wat dir (<wat_root>/.wat/<name>)
func (WatWorkspace) Root ¶
func (w WatWorkspace) Root() string
func (WatWorkspace) WalkDir ¶
func (w WatWorkspace) WalkDir(dir string) ([]fileInfo, error)
func (WatWorkspace) WalkRoot ¶
func (w WatWorkspace) WalkRoot() ([]fileInfo, error)
func (WatWorkspace) Write ¶
func (w WatWorkspace) Write(name, contents string) error
Write (over)writes the specified file in the .wat dir (<wat_root>/.wat/<name>) with the given contents