pub struct ConfigV1 {
pub version: u32,
pub gate: GateConfig,
pub checks: Vec<CheckConfig>,
pub triggers: Vec<UserTriggerConfig>,
/* private fields */
}Fields§
§version: u32Schema version. Must equal CONFIG_VERSION; mismatches fail with
KlaspError::ConfigVersion.
gate: GateConfig§checks: Vec<CheckConfig>§triggers: Vec<UserTriggerConfig>User-defined [[trigger]] blocks. These extend (not replace) the
built-in commit/push regex. Validated eagerly on parse via
UserTriggerConfig → UserTrigger compilation.
Implementations§
Source§impl ConfigV1
impl ConfigV1
Sourcepub fn load(repo_root: &Path) -> Result<Self>
pub fn load(repo_root: &Path) -> Result<Self>
Resolve and load klasp.toml. Lookup order per design §14:
$CLAUDE_PROJECT_DIR first (set by Claude Code), then the supplied
repo_root. The first existing file wins; any parse error
short-circuits.
The $CLAUDE_PROJECT_DIR candidate is only honoured when the process
cwd is inside that directory — otherwise a session bound to repo A
would run A’s gate against an unrelated sibling repo B. On mismatch
the env candidate is skipped and resolution falls through to
repo_root; if neither exists, KlaspError::ConfigNotFound is
returned and the gate fails open.
Sourcepub fn from_file(path: &Path) -> Result<Self>
pub fn from_file(path: &Path) -> Result<Self>
Read and parse a specific TOML file. Public so tests and callers that already know the path can skip the lookup logic.
Sourcepub fn parse(s: &str) -> Result<Self>
pub fn parse(s: &str) -> Result<Self>
Parse from raw TOML. Validates the version field and eagerly compiles
all [[trigger]] regexes so caller code never sees a malformed ConfigV1.
Sourcepub fn compiled_triggers(&self) -> &[UserTrigger]
pub fn compiled_triggers(&self) -> &[UserTrigger]
Return the compiled user triggers. Populated by Self::parse; calling
this on a ConfigV1 constructed by other means falls back to a fresh
compile (still infallible post-parse, but avoid the path).