Repository navigation
Conversation
…elds [DRK-2635] Tier-2 architecture rule from the 2026-12 architecture review (finding DRK-2640). SaveChanges hooks are resolved scoped, so one instance serves the outer save and every nested save on the same DbContext; a mutable collection field carrying state from BeforeSaveAsync to AfterSaveAsync is overwritten by the nested save and the outer save's audit entries or declared events are silently lost. - Scan the AuditLogs, Events and DataAuthorization hook assemblies - KnownViolations baseline: EfCoreAuditHook._cache, EventHook._declaredEvents - Stale-entry and vacuous-scan self-checks - EfCore.AuditLogs.Tests references DKNet.EfCore.Events for the scan Test-only change; no production code touched. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]>
📊 Code Coverage Report |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #550 +/- ##
=======================================
Coverage 93.25% 93.25%
=======================================
Files 219 219
Lines 7191 7191
Branches 1220 1220
=======================================
Hits 6706 6706
Misses 259 259
Partials 226 226
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test-only enforcement from the 2026-12 monthly architecture review (DRK-2635). It adds one Tier-2 architecture rule,
HookInstanceStateArchitectureTests, inEfCore.AuditLogs.Tests/Architecture/.Rule: a concrete SaveChanges hook (
IHookBaseAsync) inDKNet.EfCore.AuditLogs,DKNet.EfCore.EventsorDKNet.EfCore.DataAuthorizationmust not keep a mutable collection (List<>,Dictionary<,>,HashSet<>, concurrent collections, and similar) in an instance field.Why: hooks are resolved scoped (
AddHook→AddKeyedScoped). The same instance therefore runs for the outer save and for every nestedSaveChangesAsyncon the sameDbContext.HookRunnerInterceptorgives each nesting level its ownHookContext/SnapshotContext, but a collection field shared across levels is overwritten or cleared by the nested save. The outer save's audit entries or declared events are then silently lost. Finding: DRK-2640.Baseline (
KnownViolations, shrink-only):DKNet.EfCore.AuditLogs.Internals.EfCoreAuditHook._cacheDKNet.EfCore.Events.Internals.EventHook._declaredEventsThe class also carries two self-checks:
EfCore.AuditLogs.Tests.csprojgains aProjectReferencetoDKNet.EfCore.Eventsso the scan can seeEventHook.Evidence
dotnet build src/DKNet.FW.sln -c Release: 60 projects, 0 warnings, 0 errors.dotnet test src/EfCore/EfCore.AuditLogs.Tests: 72 passed, 0 failed (3 new).KnownViolations_AreAllStillViolationspasses, which proves the detector finds both current offenders.dotnet format whitespace --verify-no-changesis clean on the new file.DOTNET_ROLL_FORWARD=Major. CI runs on .NET 10.No production code is touched. Coverage impact: none on library code.
Merge danger
Low. Two test-project files only. The new
ProjectReferenceaddsDKNet.EfCore.Events(and its transitive Mapster dependency) to the AuditLogs test build. No shared fixtures changed.Related findings from the same review, which this PR does not fix: DRK-2636 … DRK-2645.
🤖 Generated with Claude Code