optswitch

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package optswitch is the registry of optimization kill switches (#287).

Every optimization that can change the shape of query results — pruning, pushdown, plan rewrites, fast-path operator variants — registers a Toggle here, named and bound to its env kill switch. Production behavior is unchanged: a toggle is on unless its env var is "0", exactly the convention the ad-hoc `os.Getenv(...) != "0"` vars used.

The registry exists so the optimization-invariance oracle (internal/oracle) can enumerate every switch and run each corpus query with optimizations individually disabled, asserting identical results. Adding a kill switch for new optimization work is part of its definition of done — registering it here extends the oracle for free.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Toggle

type Toggle struct {
	Name string // short stable id, e.g. "scan-filter"
	Env  string // kill-switch env var, e.g. WADJET_SCAN_FILTER
	Desc string // one-line description of what turning it off disables
	// contains filtered or unexported fields
}

Toggle is one registered optimization switch. On() is safe for concurrent readers and cheap enough for per-query (not per-row) checks.

func All

func All() []*Toggle

All returns every registered toggle, sorted by name. Only toggles whose defining packages are linked into the binary appear.

func Register

func Register(name, env, desc string) *Toggle

Register creates, records, and returns a toggle. The initial value comes from the env var: enabled unless set to "0". Duplicate names panic — each optimization registers exactly once, in the package that owns it.

func (*Toggle) On

func (t *Toggle) On() bool

On reports whether the optimization is enabled.

func (*Toggle) Set

func (t *Toggle) Set(v bool) (prev bool)

Set flips the toggle and returns the previous value. Test-only in spirit: production code never calls Set, it reads env at Register time.

Jump to

Keyboard shortcuts

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