Documentation
¶
Overview ¶
Package experiments is the registry of devcell's experimental features and the gate that turns them on.
An experiment is off until named in --experimental=a,b, DEVCELL_EXPERIMENTAL or [cell] experimental (the three are unioned). Code guards a feature with Set.Enabled or Require; docs are generated from List (see Markdown and JSON, wired into `task docs:experimental`). Names are "<group>-<slug>": the group is the area the experiment touches (ui, engine).
Lifecycle, after go-task's experiments package: an experiment is Active while it can be enabled; once shipped it becomes Released, once dropped Abandoned. Both stay registered so an old setting fails with a reason instead of an "unknown experiment" error.
Index ¶
- Constants
- Variables
- func Block(doc string) (string, bool)
- func JSON() ([]byte, error)
- func Markdown(linkBase string) string
- func Names() []string
- func ReplaceBlock(doc, body string) (string, error)
- func Require(s Set, x Experiment, what string) error
- type Experiment
- type InactiveError
- type RequiredError
- type Set
- type State
- type UnknownError
Constants ¶
const ( BeginMarker = "<!-- experiments:begin -->" EndMarker = "<!-- experiments:end -->" )
Markers around the generated block in README.md and docs/experimental.md.
const ( Flag = "--experimental" // comma-separated names Env = "DEVCELL_EXPERIMENTAL" // comma-separated names Key = "[cell] experimental" // TOML list or comma-separated string )
Where an experiment can be switched on.
Variables ¶
var ( // Cage wraps the run in a host tmux session with a one-line bottom bar. Cage = Experiment{ Name: "ui-cage", Summary: "one-line bottom bar (workspace, cell name, clocks) drawn by a host tmux session around the agent", Doc: "docs/cage.md", Ticket: "CELL-655", } // BootPopup renders the boot panel in a tmux popup that closes before // the agent starts. Needs Cage. BootPopup = Experiment{ Name: "ui-boot-popup", Summary: "boot panel in a centred tmux popup, closed before the agent starts (needs ui-cage)", Doc: "docs/cage.md", Ticket: "CELL-657", } // Windows is the Windows guest: --os windows or winpe, engine winkit. Windows = Experiment{ Name: "engine-windows", Summary: "Windows guest (--os windows or winpe): a Windows PE + WSL VM run by the winkit engine on vz or QEMU", Doc: "README.md#engines-and-guests", } )
The registered experiments. Add a new one here and in all, then run `task docs:experimental`.
Functions ¶
func Markdown ¶
Markdown renders the experiments table that README.md, docs/experimental.md and the website share. Doc links are prefixed with linkBase: "" for a file at the repo root, "../" from docs/, a GitHub blob URL for the site.
func ReplaceBlock ¶
ReplaceBlock swaps the text between the markers in doc for body.
Types ¶
type Experiment ¶
type Experiment struct {
Name string // what users write: "<group>-<slug>", e.g. "ui-cage"
Summary string // one line: what turning it on does
Doc string // repo-relative markdown path, e.g. "docs/cage.md"; "" when none
Ticket string // tracking ticket, e.g. "CELL-655"; "" when none
State State
}
Experiment describes one experimental feature.
func (Experiment) EnvSetting ¶
func (x Experiment) EnvSetting() string
EnvSetting is the environment form that enables x.
func (Experiment) Flag ¶
func (x Experiment) Flag() string
Flag is the command-line form that enables x.
func (Experiment) Group ¶
func (x Experiment) Group() string
Group is the area prefix of Name: "ui" for "ui-cage".
func (Experiment) HowToEnable ¶
func (x Experiment) HowToEnable() string
HowToEnable lists every way to turn x on, for error messages and docs.
func (Experiment) TOMLSetting ¶
func (x Experiment) TOMLSetting() string
TOMLSetting is the devcell.toml form that enables x.
type InactiveError ¶
type InactiveError struct{ Experiment }
InactiveError is a registered experiment that can no longer be enabled.
func (*InactiveError) Error ¶
func (e *InactiveError) Error() string
type RequiredError ¶
type RequiredError struct {
What string // what was attempted, e.g. "the windows guest"
Experiment
}
RequiredError is a code path reached without the experiment it needs.
func (*RequiredError) Error ¶
func (e *RequiredError) Error() string
type Set ¶
Set is the resolved set of enabled experiments.
func Resolve ¶
Resolve unions the --experimental flag value (comma-separated) with the names the config resolved from [cell] experimental and DEVCELL_EXPERIMENTAL (cfg.CellSection.ResolvedExperimental; the environment is read there, like every other devcell option). Unknown names are an *UnknownError, inactive ones an *InactiveError, so a typo or a stale setting cannot silently leave a feature off.
type UnknownError ¶
UnknownError is a name that is not a registered experiment.
func (*UnknownError) Error ¶
func (e *UnknownError) Error() string