Documentation
¶
Overview ¶
Package config loads and layers gatekeeper TOML configuration.
Config is harness-neutral: the same gatekeeper.toml is consulted by the claude, codex, and grok adapters. Paths are resolved with a harness-neutral canonical location plus a back-compatible ~/.claude fallback so existing Claude installs keep working unchanged.
Index ¶
Constants ¶
const ( OnErrorAbstain = "abstain" // default: on any gatekeeper error, emit no verdict OnErrorDeny = "deny" // opt-in hard posture: on any error, emit an explicit deny )
OnError values for the [on_error] knob.
Variables ¶
This section is empty.
Functions ¶
func EnsureGlobalConfig ¶
EnsureGlobalConfig copies templatePath to the back-compat global config path (~/.claude/gatekeeper.toml) if no global config already exists (in either the XDG or the ~/.claude location). This provides seamless defaults on first run when installed as a plugin.
func GlobalConfigPath ¶
func GlobalConfigPath() string
GlobalConfigPath returns the back-compatible global config write target, ~/.claude/gatekeeper.toml. Reads prefer the XDG canonical path when present (see resolveGlobalPath); writes stay at ~/.claude so existing Claude installs are undisturbed.
func GlobalOnError ¶
GlobalOnError returns the on_error decision from the GLOBAL config alone, best-effort. It returns canonical.Abstain on any problem (no global config, or an unparseable one). It is used on the error paths where the full (global+project) Load could not be trusted but a deployment's global on_error="deny" posture should still be honoured when it is readable.
Types ¶
type Config ¶
type Config struct {
// OnError controls the verdict emitted on a gatekeeper error (unparseable
// stdin, missing/unparseable config, bad rule regex, evaluate error,
// panic). "abstain" (default) emits no verdict so the harness's native
// permission system decides; "deny" emits an explicit deny. A clean
// "no rule matched" is NOT an error and always abstains.
OnError string `toml:"on_error"`
Rules []Rule `toml:"rules"`
}
Config is the top-level configuration.
func Load ¶
Load builds the final config by layering the resolved global and project files. A MISSING config file is skipped silently (a clean absence, not an error); an UNPARSEABLE config file returns an error so the caller can apply its on_error posture. Later layers (project) override earlier (global) for scalar fields like on_error; rules accumulate.
func (*Config) OnErrorDecision ¶
OnErrorDecision returns the canonical decision to emit on a gatekeeper error, per the on_error knob. Any value other than "deny" (including the empty default and an unrecognised value) resolves to Abstain — the safe posture that never decides FOR the native permission system.