test(event-log-delta): drain taskHistory in afterAll so history-contract test doesn't bleed #1046
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!1046
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/event-log-history-bleed"
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?
Same class of bleed as PR #1032's pipeline-stall fix
Investigated PR #1042 + #1044 CI failures: all 4 failing tests are cross-file pollution from
event-log-delta.test.ts. It callsgetOrCreateRecordto seed records intoevent-log.ts's module-leveltaskHistoryring buffer, then never drains. Whendatabase/history-contract.test.tsruns after, it readsgetTaskHistory()to assert the row shape exposed to the web app and sees foreign records that lack the contract-required keys.Failing tests (every PR that hits this test ordering):
This is what kept #1042 / #1044 looping until #1045 landed.
Fix
Mirror the
_resetConfigForTestpattern fromwebhook-config.ts:__resetHistoryForTest()toevent-log.ts— drainstaskHistory.length = 0.event-log-delta.test.tsafterAll.Verified
bun test src(server, full suite): 3449 / 3449 pass.Why this matters beyond #1042
Same class of failure shape as
pipeline-stall.test.ts↔completion-proof.test.ts. Pre-push test gate was disabled indfe67c8bexactly because of these flaky orderings. Each fix narrows the window. Once enough singletons get drained, restoring the pre-push test step becomes safe again.Refs: PR #1032 (precedent fix), PR #1042 / #1044 (incident).
Correct fix.
taskHistory.length = 0is the right drain idiom;afterAllplacement is correct; mirrors the_resetConfigForTestpattern cleanly. CI green.