mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-12 22:03:30 +08:00
- 重命名 local-plan 为 ai-plan,并收口 public 与 private 的目录语义 - 更新 AGENTS、README 与 boot skill 的恢复文档路径和安全约束 - 迁移共享 tracking 与 trace 文件到 ai-plan/public,并补充治理说明文档
5.1 KiB
5.1 KiB
CQRS Cache And Docs Hardening Trace
2026-04-17
Stage: Discovery
- Read
AGENTS.mdand.ai/environment/tools.ai.yamlbefore selecting repository tools. - Confirmed
README.mdquick-install guidance omitsGeWuYou.GFramework.CqrsandGeWuYou.GFramework.Cqrs.Abstractionseven though the module overview recommends CQRS as a first-class module. - Confirmed
docs/zh-CN/source-generators/index.mdlists the split CQRS generator package but does not provide a dedicated CQRS handler-registry section with package wiring, minimal usage, or compatibility notes. - Confirmed
GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cshas a cross-container metadata-cache test that only asserts reflection/attribute call counts and does not prove the second container still receives registrations. - Confirmed
GFramework.Cqrs/Internal/CqrsDispatcher.csandGFramework.Cqrs/Internal/CqrsHandlerRegistrar.cscurrently use process-wideConcurrentDictionary<Type, ...>/ConcurrentDictionary<Assembly, ...>caches that strongly retain collectible types and assemblies. - Reviewed
docs/zh-CN/getting-started/installation.mdas a related setup entry page; it also omits the CQRS runtime packages from the installation snippets.
Current Recovery Point
CQRS-CACHE-DOCS-HARDENING-RP-001
Immediate Next Step
- Update the tracking document and then patch the docs, runtime caches, and tests in one pass.
Stage: Implementation
- Updated
README.mdquick-install guidance to include:GeWuYou.GFramework.CqrsGeWuYou.GFramework.Cqrs.Abstractions
- Updated
docs/zh-CN/getting-started/installation.mdto add CQRS runtime package rows and installation snippets, and corrected the installation verification sample to the currentGFramework.Core.Architectures/OnInitialize()/OnInit()API shape. - Updated
docs/zh-CN/core/cqrs.mdto add explicit CQRS package wiring and document the current namespace split between message base types (GFramework.Cqrs.*) and handler base types (GFramework.Cqrs.Cqrs.*). - Updated
docs/zh-CN/source-generators/index.mdto add a dedicatedCQRS Handler Registry 生成器section covering:- required runtime and generator packages
- a minimal working architecture example
- compatibility and migration notes for reflection fallback vs generated registries
- Added
GFramework.Cqrs/Internal/WeakKeyCache.cswith unload-aware weak-key cache helpers built onConditionalWeakTable. - Replaced the CQRS runtime's process-wide strong-reference type/assembly caches with weak-key caches in:
GFramework.Cqrs/Internal/CqrsDispatcher.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs
- Expanded
GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.csso the cross-container metadata-cache test now proves both containers still resolve the expected handlers after the cache is reused. - Updated
GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherCacheTests.csto assert cache reuse through observable cached entries instead of assumingConcurrentDictionary-specific count semantics. - Evaluated the suggestion to change handler doc examples from
using GFramework.Cqrs.Cqrs.Command;tousing GFramework.Cqrs.Command;. The repository's actual handler base types still live underGFramework.Cqrs.Cqrs.*, so the implementation kept the real API and clarified the namespace split in the docs instead of documenting a non-existent namespace.
Stage: Validation
- Ran:
dotnet test GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj -c Release
- Result:
- passed,
62tests passed
- passed,
- The first validation run surfaced one nullable warning in
GFramework.Cqrs/Internal/WeakKeyCache.csbecause the nested weak cache lookup did not prove the secondary cache was non-null to the compiler.
Stage: Validation Follow-up
- Fixed
WeakTypePairCache<TValue>.TryGetValue(...)to guard the nested weak cache reference explicitly. - Re-ran:
dotnet test GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj -c Release --no-restore
- Result:
- passed,
62tests passed
- passed,
Immediate Next Step
- Stop at
CQRS-CACHE-DOCS-HARDENING-RP-001unless broader solution-level validation is requested.
Stage: Minor Follow-up
- Updated
docs/zh-CN/core/cqrs.mdagain so the standalone handler snippet now imports both:GFramework.Cqrs.CommandGFramework.Cqrs.Cqrs.Command
- Added XML documentation to the private nested binding types in
GFramework.Cqrs/Internal/CqrsDispatcher.csso the intent of the cached service-type/delegate bundles is explicit to future maintainers. - Restored the explicit
using System.Runtime.CompilerServices;directive at the top ofGFramework.Cqrs/Internal/WeakKeyCache.cssoConditionalWeakTable<,>does not rely on ambient imports. - Added a stateful
WeakKeyCache<TKey, TValue>.GetOrAdd<TState>(...)overload and updatedWeakTypePairCache<TValue>.GetOrAdd(...)to use it, removing the captured lambda allocation from the secondary-key lookup path. - Updated both
WeakKeyCache<TKey, TValue>.GetOrAdd(...)XML comments to state the full contract:valueFactoryitself must be non-null, and it must not produce a null cache value.