Skip to content

Simplify public event sink setup - #240

Merged
arthur-zhang merged 1 commit into
mainfrom
codex/simplify-public-event-sink
Aug 13, 2026
Merged

Simplify public event sink setup#240
arthur-zhang merged 1 commit into
mainfrom
codex/simplify-public-event-sink

Conversation

@arthur-zhang

Copy link
Copy Markdown
Contributor

What changed

  • Treat the public event sink as an assembly-time dependency and remove its runtime mutex.
  • Document the worker-to-public status mapping flow.
  • Require exact managed-agent session event type matching.

Why

These changes were left out when #239 was merged. The sink is installed before request handling starts and is not replaced at runtime, so synchronization around every publish is unnecessary.

Validation

  • go test -race ./internal/codesessions ./internal/sessions ./internal/managedagentsevents -count=1
  • package-scoped golangci-lint
  • just dead-code
  • just duplicates
  • just complexity
  • just large-files

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@arthur-zhang, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 34896522-79a8-44a6-a490-ee639b7830dd

📥 Commits

Reviewing files that changed from the base of the PR and between 3d4d54d and 9cbbbdc.

📒 Files selected for processing (4)
  • internal/codesessions/public_event_sink.go
  • internal/codesessions/service.go
  • internal/codesessions/status.go
  • internal/managedagentsevents/events.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@arthur-zhang
arthur-zhang marked this pull request as ready for review August 13, 2026 10:57
@arthur-zhang
arthur-zhang merged commit 5004194 into main Aug 13, 2026
8 checks passed

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Minor suggestions only.

Reviewed changes

  • Remove runtime sink synchronization — SetPublicEventSinkpublishPublicPayloads 不再使用 sinkMu,公开事件 sink 变为仅在组装阶段注入的依赖,并在 setter 注释中记录“运行期不得替换”的约定;生产组装路径(api.NewServersessions.NewHandler)在请求/worker 处理开始前完成注入,go 语句创建的 goroutine 提供 happens-before 保证,因此该去除是安全的。
  • Document worker→public status mapping — 为 publicSessionStatusPayloads 补充函数级与行内注释,说明状态事件映射及重复发布跳过逻辑。
  • Require exact event type matching — SessionStatus 不再对入参做 strings.TrimSpace,事件类型必须精确匹配。

行为面核对:SessionStatus 的两个调用方(codesessions/status.gopublicEventTypeFromWorkerStatus 输出、sessions/event_effects.go 读取的 session_events.event_type)传入的都是已归一化的事件类型,去掉 trim 不会引入回归;SetPublicEventSink 全仓仅有 sessions/transport.go:32 一个调用点,且位于服务开始接收请求之前。

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Flash𝕏


func SessionStatus(eventType string) (string, bool) {
switch strings.TrimSpace(eventType) {
switch eventType {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SessionStatus 现在是 managedagentsevents 里唯一不做 TrimSpace 的匹配函数,与 ThreadStatusCategoryForIsClientInput 等其余 helper 行为不一致。当前两个调用方传入的都是已归一化的类型,不会回归;但后续若有人把原始 worker payload 的 type 直接传入,会在状态投影路径上静默返回 ("", false)。建议在注释里说明这一不对称的原因,或补一个精确匹配的单元测试固定语义。

return nil, nil
}
}
//

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里残留了一行空的 // 注释,像是删除原注释块后留下的,可以直接删掉。

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