Skip to content

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

Draft
aheritier wants to merge 1 commit into
mainfrom
fix/3593-atomic-startupinfo
Draft

fix(runtime): make startupInfoEmitted atomic (#3593)#3608
aheritier wants to merge 1 commit into
mainfrom
fix/3593-atomic-startupinfo

Conversation

@aheritier

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.

This is finding A4 from the internal codebase audit.

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 (A6) on the LocalRuntime struct: A6 changes
alignment / adjacent fields while keeping the old bool. Reconciliation keeps
A6's fields and this branch's atomic.Bool. Not a blocker in isolation.

Opened as a draft pending final maintainer review.

@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
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)

1 participant