Skip to content

fix(im): daemonSessionTurnIndex reads UsageHistory/Metrics via snapshot accessors (#3091) - #3092

Merged
topcheer merged 1 commit into
mainfrom
fix-3091
Oct 2, 2026
Merged

topcheer merged 1 commit into
mainfrom
fix-3091

Conversation

@topcheer

@topcheer topcheer commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Fixes #3091 (low, #3086/#3087 follow-up consistency cleanup).

Root cause

daemonSessionTurnIndex (daemon_bridge.go) kept two bare slice reads (len(ses.UsageHistory) + last element, same for s.Metrics) after #3087 introduced the lock-guarded snapshot accessors for exactly these cross-goroutine reads. Sole caller is bridge construction (once, before collectors register), so the race window is near zero - a consistency gap, not a reproducible fault, as the issue itself adjudicates.

Fix

Both reads replaced with UsageHistorySnapshot()/MetricsSnapshot(); max-TurnIndex semantics unchanged.

Verification

  • go build -tags goolm ./... OK
  • internal/im tests green under -race
  • New probe zz_issue3091_test.go: nil session, empty session, max-from-usage-entry, max-from-metric-entry

…ot accessors (#3091)

#3086/#3087 introduced the lock-guarded snapshot accessors for
cross-goroutine reads of the shared slices, but this helper kept two
bare slice reads (len + last element). The sole caller runs once at
bridge construction before the collectors register, so the window is
near zero (low, consistency cleanup, not a reproducible fault) - but
the accessor comments name exactly this use. Replaced both reads with
UsageHistorySnapshot()/MetricsSnapshot().

Verified: go build + internal/im tests green under -race; new
zz_issue3091 probe (nil/empty/max-from-usage/max-from-metric).
@topcheer
topcheer merged commit 1a6e4ac into main Oct 2, 2026
9 checks 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.

[code-review] daemon_bridge daemonSessionTurnIndex bare-reads UsageHistory/Metrics instead of snapshot accessors (low)

1 participant