feat: load LearningCaptureConfig from .terraphim/learning-capture.toml #38
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
The learning-capture specification (
docs/specifications/learning-capture-specification-interview.md, Configuration Design section) explicitly requires a TOML config file at.terraphim/learning-capture.tomlwith[learnings],[learnings.ignore], and[learnings.redaction]sections. This lets users:enabled = false)project_dirandglobal_dirpathsignore_patterns(e.g.cargo bench*,make check*) without recompilingcustom_patternsto the redactor (e.g. company-specific token formats)Today,
crates/terraphim_agent/src/learnings/mod.rsexposesLearningCaptureConfigbut only as hard-coded defaults. There is nofrom_toml()/load()/load_or_default()constructor, no precedence logic between project and home configs, and theredaction.rsSECRET_PATTERNSslice isconst-- impossible to extend at runtime. As a result the capture hook is one-size-fits-all and forces users to fork the binary for any policy tweak.Acceptance Criteria
LearningCaptureConfig::load(path: &Path) -> Result<Self, LearningError>that parses TOML matching the spec layoutLearningCaptureConfig::load_or_default()that walks./.terraphim/learning-capture.toml->~/.terraphim/learning-capture.toml(XDG-friendly viadirs) -> baked defaults[learnings.ignore].commandsarray merges with (does not silently replace) the built-in test-runner patterns; document precedence in the rustdoc[learnings.redaction].custom_patternsarray is compiled into aVec<(Regex, &'static str)>at load time and consumed byredact_secrets()alongside the const sliceLearningError::Config(String); missing file falls back to defaults without errorcargo test -p terraphim_agent learnings::configcovers happy-path load, merge of ignore patterns, custom redaction, missing file, malformed TOMLcargo test -p terraphim_agentpassescargo clippy -p terraphim_agent -- -D warningspassesProposed Approach
Crates affected:
crates/terraphim_agentonly.Files to add/modify:
crates/terraphim_agent/src/learnings/mod.rs-- addload,load_or_default,Configdeserialisation struct (private), andLearningError::Configvariant viacapture::LearningErrorcrates/terraphim_agent/src/learnings/redaction.rs-- accept&[(Regex, &str)]extra patterns; keep the const slice as the floorcrates/terraphim_agent/src/learnings/capture.rs-- thread the loaded config throughcapture_failed_commandso custom patterns reachredact_secretscrates/terraphim_agent/src/learnings/config.rs(optional split) for the serde shapesKey types:
Use
toml = "0.8"(already in workspace) andregex(already a dependency of redaction). No new crates required.Dependencies
None. This issue is independently implementable. It is a sibling to #25 (
[aliases]TOML), but the two configs live in different files (learning-capture.tomlvsaliases.tomlor central agent config); pick the dispatch already used by #25 if merged first.Verification
Scope
Single PR, ~250-350 lines including tests. Extending
LearningCaptureConfig, parsing, merging, and threading custom redaction patterns throughredact_secrets()only. Do not change the capture pipeline semantics, do not introduce a CLI--configflag (separate follow-up if needed).