Repository navigation
feat(cohort-mcp): retention and recovery - #109
Merged
Merged
Conversation
Cohort never hard-deletes a record, so a removed or superseded record keeps its full content in git history. cohort recover restores a record by id from history into the working tree for a human to review and commit, guarding against a path that once held a different record. cohort retention lists records removed from the working tree and flags whether each is still within the configured recovery window (.cohort/retention.yml, default 365 days). Nothing here rewrites or prunes git history; the retention window is the guaranteed recovery period, not an expiry that destroys anything. Closes #67 Signed-off-by: evdatsion <31140661+evdatsion@users.noreply.github.com>
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds retention and recovery on top of git history.
cohort recover --vault <dir> <id>reads the record's last-existing version from history and, with--write, restores it to the working tree for a human to review and commit.cohort retention --vault <dir>lists records removed from the working tree and flags whether each is still within the configured recovery window (.cohort/retention.yml, default 365 days).Closes #67.
Security
The retention window is a guaranteed recovery period, not an expiry: nothing here rewrites or prunes git history, so a record is never destroyed by this feature, only reported as inside or beyond the window (and it stays in git either way). Recovery writes into the working tree but never commits, so a restore is a reviewable proposal rather than a silent change, consistent with the rest of Cohort. The id guard prevents recovering the wrong record when a path has been reused.
Tests
Eight new tests:
pathForIdmapping, the retention-window calculation, config parsing with a default and bad-input rejection, recovering a removed record (reporting the removal and then restoring it), reporting a still-tracked record, not-found for an id with no history, andlistRemovedfinding a removed record and flagging the window under both a normal and a zero-day policy. Full suite: 160 tests, 159 pass, 1 skipped (real-gitleaks). Build, lint, audit clean; local redaction scan clean.