Repository navigation
Fix: keep forget --all from relearning earlier tasks of live sessions - #188
Merged
Merged
Conversation
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.
Fixes #152
forget --alldeleted the session progress rows, and those rows were the only record of what had already been extracted. The next ingest of a session that was still running then treated it as new and extracted every closed task in the whole transcript again. Learning "Page 2 in src/paginate.js repeats the last product from page 1" in a session, runningtrodden forget --all --yesand then ending the next turn in that same session brought the paginate procedure straight back, along with every other task the session had done before the forget. The same happened for a queued ingest or for a session that had never been ingested yet.forget --allnow records the time it ran in the settings table, in the same transaction that deletes everything else. Ingest skips any task that started at or before that time, the same way it already skips tasks at or below a session's extracted watermark. A task that ended before the forget is left out of outcome settling too, and a task that straddles it counts like a follow-up to work already extracted: it can still settle an injection made after the forget, but it is never learned from. Tasks that start after the forget are learned as usual.I went with one global cutoff rather than keeping a watermark per session because it covers every way old events can come back, not only sessions that already had a progress row: queued ingests, sessions that were never ingested, and later hooks of journaled agents. It also means
forget --allcan keep deleting the session rows, which hold transcript paths and repositories the user asked to forget. The trade-off is thattrodden backfillafterforget --allno longer learns anything from before the forget either. That seemed right for a privacy feature, since what the user deleted should not come back by any route. Forgetting a single procedure or a repository is unchanged.To reproduce, I built the binary, pointed
TRODDEN_HOMEat a scratch directory, wrote a Claude Code transcript with two finished tasks in a fresh git repository and rantrodden ingeston it, which learned the first task. Aftertrodden forget --all --yesI appended two more tasks with later timestamps and ingested again, like the next Stop hook would. Before the fix, that ingest reported 3 new procedures andtrodden listshowed the paginate and checkout tasks from before the forget next to the new cart one. After the fix it reports 1 new procedure and only the cart task is listed.A new ingest test does the same against a live session and fails without the fix (it learns 3 tasks instead of 1). A store test checks that
forget --allrecords the time and that forgetting a repository afterwards leaves it alone.cargo fmt,cargo clippy --workspace --all-targets -D warningsandcargo test --workspacepass.