Skip to content

fix(conversations): initialize LastRound so fresh conversations survive cleanup - #640

Open
MorquinDevlar wants to merge 1 commit into
GoMudEngine:masterfrom
MorquinDevlar:morq-fix-conversation-lastround
Open

fix(conversations): initialize LastRound so fresh conversations survive cleanup#640
MorquinDevlar wants to merge 1 commit into
GoMudEngine:masterfrom
MorquinDevlar:morq-fix-conversation-lastround

Conversation

@MorquinDevlar

Copy link
Copy Markdown
Contributor

The bug

getConversation has a 2% chance per call of running maintenance that deletes any conversation more than 10 rounds stale, measured as rNow - LastRound. But AttemptConversation never set LastRound, and the round counter starts at 1,314,000 - so every freshly created conversation looked ancient until its first NextActions call. Any lookup that won the maintenance roll deleted a conversation that was just created.

Two consequences:

  • In game: a conversation can silently vanish between creation and its first line of dialogue (2% per lookup in that window).
  • In CI: TestAttemptConversation_UsesPluginFile creates a conversation and immediately looks it up, so it fails on ~2% of runs regardless of what a PR changes. Example: the initial Go Tests failure on perf(users): sync the user index incrementally, carry character names in index records #639 (this run), which passed untouched on rerun. Reproducible on master with go test -run TestAttemptConversation_UsesPluginFile -count 300 ./internal/conversations/.

The fix

LastRound now starts at the current round, matching StartRound. Dialogue timing is unchanged: conversations are created by the mob converse command during a round, and actions are pulled by the NewRound_IdleMobs hook on the following round, so the same-round guard in NextActions never bit in the real flow.

Includes a deterministic regression test. Verified with 300 consecutive -count runs, which reliably failed on master before the fix.

…ve cleanup

getConversation has a 2% chance per call of deleting any conversation
more than 10 rounds stale, measured as rounds since LastRound. New
conversations left LastRound at zero while the round counter starts at
1314000, so a brand-new conversation was always eligible: any lookup
that won the maintenance roll deleted it before its first action fired.

This is also why TestAttemptConversation_UsesPluginFile fails on
roughly 2% of CI runs - the test creates a conversation and immediately
looks it up.

LastRound now starts at the current round, matching StartRound. Adds a
deterministic regression test.
@MorquinDevlar
MorquinDevlar requested a review from Volte6 as a code owner July 27, 2026 09:12
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