Skip to content

fix(runtime): make startupInfoEmitted atomic (#3593)#3608

Merged
dgageot merged 1 commit into
mainfrom
fix/3593-atomic-startupinfo
Jul 13, 2026
Merged

fix(runtime): make startupInfoEmitted atomic (#3593)#3608
dgageot merged 1 commit into
mainfrom
fix/3593-atomic-startupinfo

Conversation

@aheritier

@aheritier aheritier commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #3593startupInfoEmitted was a plain bool with a check-then-set
pattern, raced by App.Start emitting startup info from a spawned goroutine
(pkg/app/app.go) while reEmitStartupInfo resets and re-emits from another
(e.g. on a new session). Result: a data race plus duplicate or missed startup
info.

What changed

  • startupInfoEmitted is now atomic.Bool. EmitStartupInfo uses
    CompareAndSwap(false, true) so only the CAS winner emits within an epoch;
    ResetStartupInfo uses Store(false) to open a new epoch allowing exactly
    one subsequent re-emit.

Testing

  • pkg/runtime/startupinfo_race_test.go — concurrent start + re-emit, plus a
    single-emission invariant. Verified to fail (data race + duplicate/missed
    emission) against the pre-fix plain-bool code and pass now.
  • task dev + go test -race -count=2 ./pkg/runtime/... ./pkg/app/...: green
    (validated in isolation).

Merge note

Minor overlap with #3587 on the LocalRuntime struct: #3587 changes
alignment / adjacent fields while keeping the old bool. Reconciliation keeps
#3587's fields and this branch's atomic.Bool. Not a blocker in isolation.

@aheritier aheritier added kind/fix PR fixes a bug (maps to fix:). Use on PRs only. area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection labels Jul 11, 2026
@aheritier aheritier marked this pull request as ready for review July 13, 2026 08:17
@aheritier aheritier requested a review from a team as a code owner July 13, 2026 08:17
@dgageot dgageot merged commit 118eb03 into main Jul 13, 2026
16 checks passed
@dgageot dgageot deleted the fix/3593-atomic-startupinfo branch July 13, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(runtime): make startupInfoEmitted atomic (check-then-set race)

2 participants