Repository navigation
fix: keep learning from earlier bookings of a sequence after event pruning - #102
Open
claude-for-timatic[bot] wants to merge 5 commits into
Open
claude-for-timatic[bot] wants to merge 5 commits into
claude-for-timatic[bot] wants to merge 5 commits into
Conversation
…ts are pruned Store each suggestion's event sequences (source + external id) when a day is rebuilt, and look up the previous booking through them instead of through activities and events, which are pruned after 30 days. A migration backfills the sequences of existing suggestions.
Open suggestions without an entry are pruned 30 days after creation, like the events and activities they are built from. Dismissed and booked suggestions are kept.
A rebuild force-deleted a suggestion whose entry was soft-deleted, which cut the entry's link to it. It now treats a trashed entry as an entry, like the pruning does.
tomasvanrijsse
self-requested a review
November 9, 2026 07:28
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.
The lookup that finds the earlier booking of a recurring event now survives event pruning. Each suggestion keeps the sequences it was built from, so
PreviousBookingsOfSequencesno longer joins through events and activities, which are pruned after 30 days. Open suggestions that were never booked are now pruned too.Closes #35
Decisions (answers to the open questions)
entry_suggestion_sequencestable (entry_suggestion_id,source_id,external_id). It is not a single column on entries, because a suggestion often chains several sequences. A meeting that learned its customer, for example, merges with nearby commits. "Only set it for a single sequence" would drop the meeting in exactly the case the learning creates.RebuildUserDay), not when the entry is booked. Rebuild is the only moment the events are guaranteed to exist. That leaves one write point and no change to entry create or update. The lookup followsentries.entry_suggestion_id.created_at? Yes. A late-arriving event has a freshcreated_at, and counting fromended_atwould prune it before anyone could book it.created_at(MassPrunable). Their activities are gone by then anyway. Dismissed suggestions are kept because they must keep suppressing (lifecycle doc). Booked suggestions are kept.SET NULLFK would cut the link of an entry that can still be restored.insertOrIgnoreUsing, so it can't fail on rows written between the two migrations. Limitation: it only recovers suggestions whose activities still exist. Older history, and booked days that were rebuilt before this deploy, already lost their link through the old bug.Review
A code-review agent found no blockers. Fixed after its review:
Left as is:
created_atindex for the first prune run. The first nightlymodel:prunewalks every open suggestion since the start. It's a one-off, so watch it.Docs to update after #96
suggestions/lifecycle.md:deletes open suggestions that are older than the retention period.a suggestion whose entry was deleted survives the rebuild.suggestions/suggestions.md, "Learning from an earlier booking": the lookup uses sequences stored on the suggestion, so it survives pruning. Tests:a booked sequence still teaches a later occurrence after its day is rebuilt and prunedrebuilding stores the event sequences of each suggestionsuggestions/events.md, sequence bullet: the sequence is copied onto the suggestion so it outlives the event.Verification
Full Pest suite green (620), PHPStan 0 errors, Pint applied.