Skip to content

fix(engine): enrich only newly created opportunity sessions - #5

Merged
xeronsh merged 1 commit into
mainfrom
fix/opportunity-duplicate-enrichment
Aug 7, 2026
Merged

xeronsh merged 1 commit into
mainfrom
fix/opportunity-duplicate-enrichment

Conversation

@xeronsh

@xeronsh xeronsh commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

What

Duplicate pulse events (EventID repeats) no longer spawn a second async enrichment goroutine on the same OpportunitySession.

HandlePulseEvent returns (nil, nil) when the session already exists, but the aggregator treated a nil error as "enrich again". Now enrichment only starts when a session was actually created:

sess, err := p.opportunity.HandlePulseEvent(evt)
if err != nil {
    ...
} else if sess != nil {
    p.enrichOpportunityAsync(evt)
}

Why

Two watch goroutines on one session means double OHLCV fetching, duplicate cycle work, and two writers racing to attach tickets to the same session. Non-blocker caught in PR #4 review; this is the cleanup PR.

Verification

  • TestEventAggregator_DuplicatePulseEnrichesOnce: feeds the same market_impulse EventID twice, asserts exactly one enrichment spawn (fails with 2 spawns on the old code — confirmed)
  • make check green (build / vet / fmt / mod / lint / test -race)

Closes the follow-up from #4 review.

HandlePulseEvent returns (nil, nil) for a duplicate pulse EventID, but the
aggregator treated nil error as 'enrich again', spawning a second watch
goroutine on the same session. Enrich only when a session was actually
created; regression test counts enrichment spawns for a duplicated event.
@xeronsh
xeronsh merged commit 202a882 into main Aug 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant