perf(engine): collapse buildTimeline N+1 to one List per event type#62
Merged
Conversation
ReportBuilder.buildTimeline iterated five story event types, and inside each ran one rb.es.List call PER story id. For a 20-story requirement that's 5 × 20 = 100 sequential queries — 100 JSONL file reads on the default store, 100 SQLite transactions on the SQLiteStore. Report generation on long runs got noticeably slow. Switch to one List per event type with no StoryID filter, then screen results against the existing storyIDSet in memory. 5 queries total regardless of story count. The filter is cheap: storyIDSet is already constructed three lines above for the lookup that names each story title in describeStoryEvent. New TestReportBuilder_Build_TimelineFiltersByStoryOwnership seeds a STORY_MERGED for a story id outside req-001's set and asserts it does NOT appear in the timeline — guards the in-memory filter from regressing into "list everything, forget to filter." Surfaced by the 2026-06-11 Go audit (GO-MED-9).
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.
Summary
ReportBuilder.buildTimelineiterated five story event types, and inside each ran onerb.es.Listcall per story id. For a 20-story requirement that's 5 × 20 = 100 sequential queries — 100 JSONL file reads on the default store, 100 SQLite transactions on theSQLiteStore. Report generation on long runs got noticeably slow.Changes
Listper event type with noStoryIDfilter, then screen results against the existingstoryIDSetin memory.Test plan
TestReportBuilder_Build_TimelineFiltersByStoryOwnershipseeds aSTORY_MERGEDfor a story id outside req-001's set and asserts it does NOT appear in the timeline. Guards the in-memory filter from regressing into "list everything, forget to filter."go build ./...,go vet ./...,go test ./... -count=1 -timeout 240sall green locally.Audit traceability
Go audit finding GO-MED-9 (2026-06-11 sweep).