Skip to content

Feat/添加流处理器验证和优化CQRS调度程序管道#351

Merged
GeWuYou merged 5 commits into
mainfrom
feat/cqrs-optimization
May 14, 2026
Merged

Feat/添加流处理器验证和优化CQRS调度程序管道#351
GeWuYou merged 5 commits into
mainfrom
feat/cqrs-optimization

Conversation

@GeWuYou
Copy link
Copy Markdown
Owner

@GeWuYou GeWuYou commented May 14, 2026

Summary by CodeRabbit

发布说明

  • Bug Fixes

    • 优化请求管道执行,确保生成的请求调用器在整个管道中保持一致的调用语义
  • Tests

    • 新增调度器语义验证测试,新增请求调用器与管道行为的集成测试,避免跨测污染
  • Documentation

    • 更新基准测试说明与迁移/追踪文档,刷新当前恢复点与验证结果综述

Review Change Stack

GeWuYou added 4 commits May 13, 2026 08:29
- 更新 cqrs-rewrite tracking 到 PR #350 已合并且 branch diff 归零的当前真值
- 补充 batch boot 恢复结论与下一轮 CQRS 工作应从新分支继续的建议
- 更新 cqrs-rewrite tracking 为 recovery 刷新提交后的 branch diff 与 ahead 状态
- 补充 trace 对应的最终停点,避免 ai-plan 与真实分支指标不一致
- 更新 cqrs-rewrite tracking 为不会被后续收尾提交再次改坏的稳定事实
- 补充 trace 的自然停点说明,避免继续保留已完成提交的待办语义
- 修正 request pipeline 末端继续复用缓存 RequestInvoker 的运行时语义
- 补充 generated request invoker 与 stream 缺失 handler 的回归测试覆盖
- 更新 benchmark reader-facing 注释与 cqrs-rewrite 恢复入口记录
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2d0a8ab6-fe49-49cb-8e27-cc7a07f7dbc8

📥 Commits

Reviewing files that changed from the base of the PR and between e5b173c and 20f09f0.

📒 Files selected for processing (2)
  • ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
  • ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (4)
ai-plan/public/**

📄 CodeRabbit inference engine (AGENTS.md)

ai-plan/public/**: Contributors MUST keep committed ai-plan/public/** content safe to publish in Git history
Active tracking and trace files are recovery entrypoints, not append-only changelogs. They MUST stay concise enough for boot to locate the current recovery point quickly
When completed and validated stages begin to accumulate, contributors MUST archive their detailed history out of the active todos/ and traces/ entry files in the same change. Keep only the current recovery point, active facts, active risks, immediate next step, and pointers to the relevant archive files in the default boot path
When a topic is fully complete, move the entire topic directory under ai-plan/public/archive/<topic>/ and remove it from ai-plan/public/README.md in the same change
When a task spans multiple commits or is likely to exceed a single agent context window, update both the recovery document and the trace at each meaningful milestone before pausing or handing work off
If subagents are used on a complex task, the main agent MUST capture the delegated scope and any accepted findings in the active recovery document or trace before continuing implementation

Files:

  • ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
  • ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
ai-plan/**

📄 CodeRabbit inference engine (AGENTS.md)

ai-plan/**: Never write secrets, tokens, credentials, private keys, machine usernames, home-directory paths, hostnames, IP addresses, proprietary URLs, or other sensitive environment details into any ai-plan/** file
Never record absolute file-system paths in ai-plan/**; use repository-relative paths, branch names, PR numbers, or stable document identifiers instead

Files:

  • ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
  • ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
ai-plan/public/**/todos/**

📄 CodeRabbit inference engine (AGENTS.md)

ai-plan/public/**/todos/**: When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under ai-plan/public/<topic>/todos/ in the same change
Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point
For any multi-step refactor, migration, or cross-module task, contributors MUST create or adopt a dedicated recovery document under ai-plan/public/<topic>/todos/ before making substantive code changes
Recovery documents MUST record the current phase, the active recovery point identifier, known risks, and the next recommended resume step so another contributor or subagent can continue the work safely

Files:

  • ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
ai-plan/public/**/traces/**

📄 CodeRabbit inference engine (AGENTS.md)

Contributors MUST maintain a matching execution trace under ai-plan/public/<topic>/traces/ for complex work. The trace should record the current date, key decisions, validation milestones, and the immediate next step

Files:

  • ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
🪛 LanguageTool
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md

[uncategorized] ~67-~67: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:一致"地"调用
Context: ...rovider 在 pipeline 存在时恢复与无 pipeline 路径一致的调用语义 - 当轮验证: - `dotnet build GFramewor...

(wb4)


[uncategorized] ~78-~78: 您的意思是“"不"入”?
Context: ...tive trace;若后续需要 worker 边界或更细的阶段材料,应把该阶段补入 archive,而不是继续膨胀 active 入口。

(BU)

🔇 Additional comments (2)
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md (1)

15-29: LGTM!

Also applies to: 34-37, 40-49, 53-55, 59-77, 80-82, 94-97

ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md (1)

8-21: LGTM!

Also applies to: 22-58, 59-79


📝 Walkthrough

Walkthrough

CqrsDispatcher 的请求管道已重构为在管道执行期间传递缓存的 RequestInvoker;新增测试覆盖流 handler 缺失的同步错误和生成请求调用程序在请求管道中仍被优先使用并触发注册的管道行为;更新若干基准注释与迁移追踪文档(RP-144)。

Changes

请求管道 RequestInvoker 传播和验证

Layer / File(s) Summary
请求管道重构以传播 RequestInvoker
GFramework.Cqrs/Internal/CqrsDispatcher.cs
SendAsync 现在通过管道执行器传递缓存的 RequestInvoker。InvokeRequestPipelineExecutorAsync、RequestPipelineInvoker 委托、RequestPipelineInvocation 和 InvokeHandlerAsync 都进行了更新以接收和使用此 requestInvoker 参数,确保生成的调用程序语义在整个管道中保持一致。
流处理程序缺失验证测试
GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
新增测试 CreateStream_Should_Throw_When_Handler_Is_Missing,验证当未注册 IStreamRequestHandler 且禁用流管道行为时,CreateStream 在调用点同步抛出 InvalidOperationException,异常消息包含"No CQRS stream handler registered"。
生成的请求调用程序与管道行为集成
GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs
新增异步测试 SendAsync_Should_Use_Generated_Request_Invoker_Inside_Request_Pipeline,注册请求管道行为、发送生成的请求、验证响应、检查行为调用计数。GeneratedRequestPipelineTrackingBehavior 使用 Interlocked 和 Volatile 进行线程安全的静态计数器管理,SetUp/TearDown 重置计数。
基准测试文档更新
GFramework.Cqrs.Benchmarks/Messaging/NotificationFanOutBenchmarks.cs, GFramework.Cqrs.Benchmarks/Messaging/RequestBenchmarks.cs, GFramework.Cqrs.Benchmarks/Messaging/RequestLifetimeBenchmarks.cs, GFramework.Cqrs.Benchmarks/Messaging/StreamingBenchmarks.cs
基准测试类/方法级别 XML 文档注释更新,将对 Mediator 的引用描述更正为 NuGet Mediator(源生成的具体实现);仅文档调整,无行为变更。
迁移跟踪和追踪文档
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md, ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
将当前恢复点更新为 CQRS-REWRITE-RP-144(PR #351 OPEN),刷新当前事实、验证命令/结果与下一步建议,并将前期 RP-143 收束条目记录在 traces 中以归档。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • GeWuYou/GFramework#341: 同样修改 GFramework.Cqrs/Internal/CqrsDispatcher.cs 的 SendAsync/请求管道执行路径,与本 PR 在 dispatcher 层的改动有直接代码联系。
  • GeWuYou/GFramework#344: 也触及 CqrsDispatcher 的请求调度/管道决策逻辑,本 PR 与其在管道执行和缓存/决策方面存在交叉关注点。
  • GeWuYou/GFramework#340: 对请求/流管道路径的改动相关(本 PR 传播 RequestInvoker,关联 PR 在无行为注册时添加快速路径绕过),在实现策略上可能相互影响。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确地概括了PR的主要变更:添加流处理器验证和优化CQRS调度程序管道,与所有改动的文件和目标相符。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cqrs-optimization

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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
⚠️ CSHARP dotnet-format yes 1 no 5.94s
✅ REPOSITORY gitleaks yes no no 9.03s
✅ REPOSITORY trufflehog yes no no 7.2s

Detailed Issues

⚠️ CSHARP / dotnet-format - 1 error
Welcome to .NET 9.0!
---------------------
SDK Version: 9.0.114

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, run 'dotnet dev-certs https --trust'
Learn about HTTPS: https://aka.ms/dotnet-https

----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Unhandled exception: System.Exception: Restore operation failed.
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.OpenMSBuildWorkspaceAsync(String solutionOrProjectPath, WorkspaceType workspaceType, Boolean noRestore, Boolean requiresSemantics, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
   at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
   at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@github-actions
Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2379    ↑2 2379    ↑2 0 0 0 0 38.4s    ↓720ms

Test Results

passed 2379 passed ↑2

Details

tests 2379 tests ↑2
clock 38.4s ↓720ms
tool nunit
build CI - Build & Test arrow-right build-and-test link #1113
pull-request Feat/cqrs optimization link #351

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2267 0 3 4.8s

Fail Rate

Fail Rate 0.00%
Test 📝 Results 📊 Passed ✅ Failed ❌ Fail Rate (%) 📈
CreateStream_Should_Throw_When_Stream_Pipeline_Behavior_Context_Does_Not_Implement_IArchitectureContext 22 21 1 4.55    ↓0.21
PublishAsync_Should_Stop_After_First_Handler_Exception_When_Using_Default_Publisher 40 39 1 2.50    ↓0.06
PublishAsync_Should_Throw_When_Context_Does_Not_Implement_IArchitectureContext 44 43 1 2.27    ↓0.06

build-and-test: Run #1113

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
2379 2379 0 0 0 0 0 38.4s

🎉 All tests passed!

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
CreateStream_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 40 4.2s 4.8s
SendRequestAsync_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 55 1.1s 4.7s
Does_Not_Report_When_FieldInjectedModel_Is_Registered 55 2.2s 2.3s
Generates_Scene_Behavior_Boilerplate 55 1.9s 2.0s
CleanupDuringAcquire_Should_NotCauseRaceCondition 55 1.1s 1.1s
Append_ShouldNotBlock 55 1.0s 1.0s
Context_Caching_Should_Improve_Performance 55 781ms 794ms
PendingCount_ShouldReflectQueuedEntries 55 501ms 501ms
Cleanup_Should_NotRemoveActiveLocks 55 404ms 406ms
Cleanup_Should_RemoveUnusedLocks 55 401ms 402ms

± Comparison with run #1112 at 8ca8a09 | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 55 runs.

Github Test Reporter by CTRF 💚

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md`:
- Around line 44-47: Update the PR anchor text in the migration-tracking doc so
the "当前 PR" and any mention of the "当前 PR 锚点" reference PR `#351` instead of PR
`#350`: locate the block containing the lines "- 当前 PR:`PR `#350`(已合并到
origin/main)`" and the surrounding "当前分支:`feat/cqrs-optimization`" context in
cqrs-rewrite-migration-tracking.md, change the PR number and status to reflect
PR `#351` (opened 2026-05-14), and ensure any related recovery/anchor wording is
consistent with the new PR number.
- Around line 59-82: The document contains contradictory statements about what
the current branch diff covers (the phrase "当前 batch working-tree diff:`7` 个源码 /
测试文件" vs the section "最近权威验证" stating it only covers two `ai-plan` docs); pick
and keep one authoritative statement that matches HEAD and convert the other
into a clearly labeled historical note. Update the lines containing the tokens
"当前 batch working-tree diff:" and the "最近权威验证" block (and related bullets under
"最近已合并提交:") so they consistently report the same current-diff count and scope,
or move the non-authoritative claim under a "历史说明" subsection; ensure the
surviving authoritative wording matches the actual git checks (`git diff
--name-only origin/main...HEAD`) and the commit list shown.

In `@ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md`:
- Around line 46-56: Remove the stray extra backtick around
`$gframework-batch-boot 50` (the token `$gframework-batch-boot 50`) so it
appears as a single inline code span, and eliminate the duplicate `##
2026-05-13` heading by keeping one `## 2026-05-13` heading and moving the
subsequent content under it as subsections (e.g., use `### 阶段:PR `#350` 合并后的
recovery 入口刷新(CQRS-REWRITE-RP-142)`) to avoid repetition and markdown lint
errors in the file that contains these strings.
- Around line 8-77: The active trace for RP-143 is too verbose—reduce the body
of the "active trace" section to a concise recovery point summary: keep only the
current recovery point, key decisions, verification conclusions, and next steps;
move all execution/details (explorer conclusions, per-file accepted scope, full
validation logs) into an archive document (e.g.,
ai-plan/public/cqrs-rewrite/archive/...) and leave a short pointer in the trace;
update the trace heading(s) around "阶段:允许 subagent 后的低风险多 Agent
收口(CQRS-REWRITE-RP-143)" to reflect the slimmer summary.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34cc7a95-ab13-4a17-8c8c-6e6226b6ec26

📥 Commits

Reviewing files that changed from the base of the PR and between 4837aa2 and e5b173c.

📒 Files selected for processing (9)
  • GFramework.Cqrs.Benchmarks/Messaging/NotificationFanOutBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/RequestBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/RequestLifetimeBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/StreamingBenchmarks.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs
  • GFramework.Cqrs/Internal/CqrsDispatcher.cs
  • ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
  • ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (C#)
  • GitHub Check: Build and Test
  • GitHub Check: Code Quality & Security
🧰 Additional context used
📓 Path-based instructions (7)
**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.cs: Apply [Log] attribute for automatic logging field and logging helper method generation
Apply [Priority] attribute for automatic priority comparison implementation generation
Apply [GenerateEnumExtensions] attribute to generate enumeration extension capabilities
Apply [ContextAware] attribute to automatically implement IContextAware boilerplate logic

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///)
XML documentation comments MUST use <summary>, <param>, <returns>, <exception>, and <remarks> where applicable, explaining intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions
Avoid obvious comments such as // increment i
Methods with non-trivial logic MUST document: The core idea, Key decisions, and Edge case handling, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explaining why and when, not just what. Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Do not rely on implicit imports. Declare every required using explicitly
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and constants use PascalCase; Interfaces use I prefix; Parameters and locals use camelCase; Private fields use _camelCase
Use 4 spaces for indentation. Do not use tabs
Use Allman braces
Keep using directives at the top...

Files:

  • GFramework.Cqrs.Benchmarks/Messaging/RequestBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/StreamingBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/RequestLifetimeBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/NotificationFanOutBenchmarks.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs
  • GFramework.Cqrs/Internal/CqrsDispatcher.cs
ai-plan/public/**

📄 CodeRabbit inference engine (AGENTS.md)

ai-plan/public/**: Contributors MUST keep committed ai-plan/public/** content safe to publish in Git history
Active tracking and trace files are recovery entrypoints, not append-only changelogs. They MUST stay concise enough for boot to locate the current recovery point quickly
When completed and validated stages begin to accumulate, contributors MUST archive their detailed history out of the active todos/ and traces/ entry files in the same change. Keep only the current recovery point, active facts, active risks, immediate next step, and pointers to the relevant archive files in the default boot path
When a topic is fully complete, move the entire topic directory under ai-plan/public/archive/<topic>/ and remove it from ai-plan/public/README.md in the same change
When a task spans multiple commits or is likely to exceed a single agent context window, update both the recovery document and the trace at each meaningful milestone before pausing or handing work off
If subagents are used on a complex task, the main agent MUST capture the delegated scope and any accepted findings in the active recovery document or trace before continuing implementation

Files:

  • ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
  • ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
ai-plan/**

📄 CodeRabbit inference engine (AGENTS.md)

ai-plan/**: Never write secrets, tokens, credentials, private keys, machine usernames, home-directory paths, hostnames, IP addresses, proprietary URLs, or other sensitive environment details into any ai-plan/** file
Never record absolute file-system paths in ai-plan/**; use repository-relative paths, branch names, PR numbers, or stable document identifiers instead

Files:

  • ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
  • ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
ai-plan/public/**/traces/**

📄 CodeRabbit inference engine (AGENTS.md)

Contributors MUST maintain a matching execution trace under ai-plan/public/<topic>/traces/ for complex work. The trace should record the current date, key decisions, validation milestones, and the immediate next step

Files:

  • ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
ai-plan/public/**/todos/**

📄 CodeRabbit inference engine (AGENTS.md)

ai-plan/public/**/todos/**: When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under ai-plan/public/<topic>/todos/ in the same change
Tracking updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point
For any multi-step refactor, migration, or cross-module task, contributors MUST create or adopt a dedicated recovery document under ai-plan/public/<topic>/todos/ before making substantive code changes
Recovery documents MUST record the current phase, the active recovery point identifier, known risks, and the next recommended resume step so another contributor or subagent can continue the work safely

Files:

  • ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
**/Cqrs/**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

Use CQRS (Command Query Responsibility Segregation) pattern with the Cqrs naming entry point instead of the historical Mediator alias

Files:

  • GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs
**/*.Tests/**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.Tests/**/*.cs: Mirror the source structure in test projects whenever practical
Reuse existing architecture test infrastructure when relevant: ArchitectureTestsBase<T>, SyncTestArchitecture, AsyncTestArchitecture

Files:

  • GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs
🧠 Learnings (2)
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Cqrs.Benchmarks/Messaging/RequestBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/StreamingBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/RequestLifetimeBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/NotificationFanOutBenchmarks.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs
  • GFramework.Cqrs/Internal/CqrsDispatcher.cs
📚 Learning: 2026-05-11T06:15:15.057Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 348
File: GFramework.Cqrs.Benchmarks/Messaging/NotificationLifetimeBenchmarks.cs:52-68
Timestamp: 2026-05-11T06:15:15.057Z
Learning: In the GeWuYou/GFramework repo, do not treat a missing [GenerateEnumExtensions] attribute as a code review issue for every enum. Skip the check for:
1) local/private benchmark enums (e.g., enums defined for benchmarks such as HandlerLifetime in GFramework.Cqrs.Benchmarks),
2) enums located in projects that do NOT reference the source-generator abstractions package (the generator won’t apply there), and
3) core framework/runtime-style code paths that AGENTS.md explicitly restricts from using generator-attribute usage.
If an enum falls into any of these cases, do not flag the missing [GenerateEnumExtensions] (it has been triaged as a generalized false positive for these scenarios).

Applied to files:

  • GFramework.Cqrs.Benchmarks/Messaging/RequestBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/StreamingBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/RequestLifetimeBenchmarks.cs
  • GFramework.Cqrs.Benchmarks/Messaging/NotificationFanOutBenchmarks.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
  • GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs
  • GFramework.Cqrs/Internal/CqrsDispatcher.cs
🪛 LanguageTool
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md

[grammar] ~30-~30: Ensure spelling is correct
Context: ...Tests.cs - 补一条 stream 缺失 handler 的失败语义回归,固定当前分支在调用点同步抛InvalidOperationException` - worker ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~31-~31: Ensure spelling is correct
Context: ...ests.cs补 request/generated + pipeline 对称测试后,主线程确认这不是环境噪音,而是命中了真实运行时缺口: - request 路径在接入IPipelineBehavior<,>后,会退回_ha...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 markdownlint-cli2 (0.22.1)
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md

[warning] 53-53: Multiple headings with the same content

(MD024, no-duplicate-heading)

🔇 Additional comments (14)
GFramework.Cqrs.Benchmarks/Messaging/NotificationFanOutBenchmarks.cs (1)

25-26: LGTM!

GFramework.Cqrs.Benchmarks/Messaging/RequestBenchmarks.cs (1)

135-135: LGTM!

GFramework.Cqrs.Benchmarks/Messaging/RequestLifetimeBenchmarks.cs (1)

204-204: LGTM!

Also applies to: 251-251

GFramework.Cqrs.Benchmarks/Messaging/StreamingBenchmarks.cs (1)

171-171: LGTM!

GFramework.Cqrs/Internal/CqrsDispatcher.cs (6)

152-153: LGTM!


604-617: LGTM!


671-676: LGTM!


1153-1163: LGTM!


1207-1217: LGTM!


969-996: LGTM!

GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs (1)

150-171: LGTM!

GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs (3)

32-32: LGTM!

Also applies to: 45-45


187-209: LGTM!


638-670: LGTM!

Comment thread ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md Outdated
Comment thread ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md Outdated
Comment thread ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md Outdated
Comment thread ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md Outdated
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR fixes a semantic gap in the CQRS request pipeline: when IPipelineBehavior<,> behaviors were present, the pipeline terminal was calling _handler.Handle() via the interface vtable, bypassing any cached RequestInvoker<TResponse> delegate that a generated invoker provider might have set on the binding. The fix threads the RequestInvoker<TResponse> through RequestPipelineInvoker, CachedRequestPipelineExecutor.Invoke, and RequestPipelineInvocation, so the terminal now always calls through the invoker delegate.

  • CqrsDispatcher.cs: RequestPipelineInvocation now stores object handler + RequestInvoker<TResponse> instead of IRequestHandler<TRequest, TResponse>; InvokeHandlerAsync calls _requestInvoker(...) rather than _handler.Handle(...).
  • New tests: SendAsync_Should_Use_Generated_Request_Invoker_Inside_Request_Pipeline proves the generated invoker is honoured inside a pipeline; CreateStream_Should_Throw_When_Handler_Is_Missing verifies the dispatcher throws synchronously rather than returning a lazily-failing stream.
  • Benchmark/docs: Minor XML comment corrections (ai-libs/MediatorNuGet \Mediator`); ai-planrecovery documents refreshed toPR Feat/添加流处理器验证和优化CQRS调度程序管道 #351`.

Confidence Score: 5/5

The change is safe to merge — the fix is narrowly scoped to the request pipeline terminal and all changed paths are covered by passing tests.

The core dispatcher change is small, well-reasoned, and directly verified by the new integration test that proves the generated invoker is called (not the interface vtable) when a pipeline behavior wraps the handler. The stream pipeline was already calling through its _streamInvoker delegate at the terminal, so it did not need the same fix. All modified test files properly reset shared static state in both SetUp and TearDown, preventing cross-test pollution.

No files require special attention. The StreamPipelineInvocation unnecessary cast flagged in earlier reviews is pre-existing and unchanged in this PR.

Important Files Changed

Filename Overview
GFramework.Cqrs/Internal/CqrsDispatcher.cs Core fix: RequestPipelineInvocation now stores object handler + RequestInvoker<TResponse> and calls through the invoker delegate at the pipeline terminal, ensuring generated request invokers are honoured when pipeline behaviors are present.
GFramework.Cqrs.Tests/Cqrs/CqrsGeneratedRequestInvokerProviderTests.cs Adds SendAsync_Should_Use_Generated_Request_Invoker_Inside_Request_Pipeline test with a properly thread-safe GeneratedRequestPipelineTrackingBehavior, and resets the new counter in both SetUp and TearDown.
GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs Adds CreateStream_Should_Throw_When_Handler_Is_Missing to verify the dispatcher throws synchronously before yielding any stream elements when no handler is registered.
GFramework.Cqrs.Benchmarks/Messaging/NotificationFanOutBenchmarks.cs Documentation-only: class summary updated to mention TaskWhenAllNotificationPublisher alongside the default sequential publisher.
GFramework.Cqrs.Benchmarks/Messaging/RequestBenchmarks.cs Documentation-only: corrects 'ai-libs/Mediator' to 'NuGet Mediator' in the Mediator benchmark method summary.
GFramework.Cqrs.Benchmarks/Messaging/StreamingBenchmarks.cs Documentation-only: same 'ai-libs/Mediator' → 'NuGet Mediator' correction in the streaming benchmark summary.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant Dispatcher as CqrsDispatcher
    participant Executor as CachedRequestPipelineExecutor
    participant Invocation as RequestPipelineInvocation
    participant Behavior as IPipelineBehavior
    participant Invoker as RequestInvoker delegate

    Caller->>Dispatcher: SendAsync(request)
    Dispatcher->>Dispatcher: Resolve handler + behaviors + dispatchBinding
    Dispatcher->>Executor: "Invoke(handler, behaviors, dispatchBinding.RequestInvoker, request, ct)"
    Note over Executor: NEW: passes RequestInvoker through
    Executor->>Invocation: "new(handler, requestInvoker, behaviors)"
    Invocation->>Behavior: "Handle(request, next, ct)"
    Behavior->>Invocation: "next(request, ct)"
    Invocation->>Invoker: "_requestInvoker(_handler, request, ct)"
    Note over Invoker: "Was: _handler.Handle() via vtable. Now: uses cached generated invoker delegate"
    Invoker-->>Invocation: TResponse
    Invocation-->>Behavior: TResponse
    Behavior-->>Executor: TResponse
    Executor-->>Dispatcher: "ValueTask of TResponse"
    Dispatcher-->>Caller: TResponse
Loading

Reviews (2): Last reviewed commit: "docs(cqrs-rewrite): 收口PR351恢复入口" | Re-trigger Greptile

@GeWuYou GeWuYou changed the title Feat/cqrs optimization Feat/添加流处理器验证和优化CQRS调度程序管道 May 14, 2026
- 更新 active tracking 到 PR #351 的当前审查真值与最小恢复入口

- 修复 active tracking 中过期 PR 锚点与冲突事实

- 重构 active trace 为精简恢复摘要并保留 archive 指针

- 补充本轮 PR review、license header、diff check 与 Release build 验证结果
@github-actions
Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2379 2379 0 0 0 0 37.9s    ↓488ms

Test Results

passed 2379 passed

Details

tests 2379 tests
clock 37.9s ↓488ms
tool nunit
build CI - Build & Test arrow-right build-and-test link #1114
pull-request Feat/添加流处理器验证和优化CQRS调度程序管道 link #351

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2269 0 3 4.8s

Fail Rate

Fail Rate 0.00%
Test 📝 Results 📊 Passed ✅ Failed ❌ Fail Rate (%) 📈
CreateStream_Should_Throw_When_Stream_Pipeline_Behavior_Context_Does_Not_Implement_IArchitectureContext 23 22 1 4.35    ↓0.20
PublishAsync_Should_Stop_After_First_Handler_Exception_When_Using_Default_Publisher 41 40 1 2.44    ↓0.06
PublishAsync_Should_Throw_When_Context_Does_Not_Implement_IArchitectureContext 45 44 1 2.22    ↓0.05

build-and-test: Run #1114

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
2379 2379 0 0 0 0 0 37.9s

🎉 All tests passed!

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
CreateStream_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 41 4.2s 4.8s
SendRequestAsync_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 56 1.1s 4.7s
Does_Not_Report_When_FieldInjectedModel_Is_Registered 56 2.2s 2.3s
Generates_Scene_Behavior_Boilerplate 56 1.9s 2.0s
CleanupDuringAcquire_Should_NotCauseRaceCondition 56 1.1s 1.1s
Append_ShouldNotBlock 56 1.0s 1.0s
Context_Caching_Should_Improve_Performance 56 781ms 794ms
PendingCount_ShouldReflectQueuedEntries 56 501ms 501ms
Cleanup_Should_NotRemoveActiveLocks 56 404ms 406ms
Cleanup_Should_RemoveUnusedLocks 56 401ms 402ms

± Comparison with run #1113 at b8fe7e2 | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 56 runs.

Github Test Reporter by CTRF 💚

@GeWuYou
Copy link
Copy Markdown
Owner Author

GeWuYou commented May 14, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@GeWuYou GeWuYou merged commit a9e4b24 into main May 14, 2026
7 checks passed
@GeWuYou GeWuYou deleted the feat/cqrs-optimization branch May 14, 2026 04:55
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