feat: learn prune --older-than for age-based learning cleanup #18
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-interview.mdspec (line 122-123) explicitly definesterraphim-agent learn prune --older-than 90dfor manual cleanup, but no such subcommand exists. The spec deliberately chose "no automatic retention" and relies on this manual command as the escape valve. Without it, users who accept the "keep everything" default have no supported way to trim the store as it grows — they must delete files by hand, which risks breaking the companion KG-compiled-corrections thesaurus.Acceptance Criteria
terraphim-agent learn prune --older-than <duration>subcommand exists90d,12w,6m,1y(minimum 1 day; reject zero/negative)--yes(or--confirm) actually deletes the matching files--globalscopes to the global learnings directory--include-correctedis passed (corrections are the expensive artefact; safe default is keep)--jsonemits RobotOutput envelope with structured result--include-correctedoverride, dry-run vs confirmcargo test -p terraphim_agentpassescargo clippy -p terraphim_agent -- -D warningspassesProposed Approach
Add
Prune { older_than: String, yes: bool, global: bool, include_corrected: bool, json: bool }toLearnSubincrates/terraphim_agent/src/main.rs. Implement in a newcrates/terraphim_agent/src/learnings/prune.rsmodule:chrono::Duration(tiny helper)CapturedLearning::from_markdown, comparecaptured_attoUtc::now() - durationcorrectionfield isSomeunlessinclude_correctedis set--yes,fs::remove_fileeach matchPruneReport { scanned, matched, deleted, skipped_corrected }for JSON outputAffected crates:
terraphim_agentonly.Dependencies
None.
Verification
Scope
~180 lines of new code (duration parser + prune module + wiring + 5 unit tests). Single PR. Safe defaults (dry-run, preserve corrections) keep blast radius small.