Repository navigation
chore(coverage): clean up coverage config, document unit+selftest merge - #41
Merged
Chris Anderson (codemonkeychris) merged 2 commits intoApr 19, 2026
Merged
Conversation
Overall merged coverage jumps from 62% to 87% by excluding noise rather than by adding tests: - Drop stale ReactorD3.dll include (merged into Reactor.dll long ago). - Exclude generated code (obj/, *.g.cs) and attribute-marked code ([ExcludeFromCodeCoverage], [GeneratedCode]) — WinRT/AOT source-gen output alone was ~11k lines of noise in the denominator. - Exclude Reactor.AppTests.Host test scaffolding (Fixtures/, DevtoolsStress/, FixtureRegistry.cs) that is exercised by the Appium/E2E runner, not by selftest. Also document the unit+selftest merge flow in CONTRIBUTING.md as the canonical coverage command, since the merged number is what we care about going forward. Product (Reactor.dll) coverage sits at 81% and has room to grow via targeted selftest fixtures in follow-up work. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Reactor.AppTests.Host is the selftest harness — measuring how much of the harness its own fixtures exercise is circular and juices the combined number without saying anything about product-code quality. Drop it from ModulePaths entirely (and drop the now-redundant Sources excludes for its subfolders). Honest unit+selftest merged coverage of Reactor.dll is 81.3%, not the 86.8% the previous config was reporting. Closing the remaining gap to 85% is a code-adding task, handled separately. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Chris Anderson (codemonkeychris)
deleted the
chore/coverage-config-cleanup
branch
April 19, 2026 17:41
This was referenced Jun 25, 2026
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 26, 2026
Hot keyed list-diff path (grid steady state) allocated heavily and missed fast-paths even when keys were unchanged. Eliminate per-diff allocations and add the missing fast-path, preserving diff behavior exactly. ChildReconciler.cs: - Keyed prefix/suffix loops now take the Element.CanSkipUpdate early-exit that the positional path has, so stable keyed rows no longer re-diff every tick (#30); cache children.Count once instead of re-reading the COM IVector.get_Size per suffix iteration (#37). - Replace HashSet-returning ComputeLIS with allocation-free ComputeLISInto filling a pooled bool mask; pool tails/tailIndices/predecessors from ArrayPool (#31/#32). Keep a thin ComputeLIS(int[]) wrapper for tests. - Pool ReconcileKeyedMiddle's working arrays (ArrayPool) and the two key->index maps (re-entrancy-safe ThreadStatic dict pool); buffers cleared and returned on every exit (#33). - Filter: count-pass + single Element[] fill, no List+ToArray (#36). - GetKey: cache Type.Name via ConcurrentDictionary (#38). KeyedListDiff.cs: - Rent newKeys from ArrayPool<string>, threading explicit newCount (rented array may be larger); returned clearArray:true in a finally (#2). - Move the no-op (SequenceEqual) + empty/empty fast paths ABOVE the duplicate scan so the steady-state grid case never allocates/scans a dup set (#1). - Fold the churn-bailout decision into ApplyGeneral, computed from the same post-prefix/suffix scratch map the general walk builds (diff-range churn == full-range churn), removing the O(2n) null-marker pre-pass (#34). - Pool the doomed ReactorRow[] (ArrayPool, descending IComparer sort over [0,removes), cleared+returned) (#3). - Lazy-allocate movedRows only on an actual move under an ambient (#35). - In-place SyncLastKeysToSource instead of LastKeys Clear()+Add (#10). - HasDuplicates reuses state.Scratch (TryAdd) for 4+ keys instead of a fresh HashSet (#11); cached null-key diagnostic sample (#41). Tests: add pooling non-corruption coverage (rented-buffer-larger-than-count, interleaved independent states, randomized stress vs oracle with survivor identity, pooled doomed removes, churn with shared prefix+suffix, Scratch reuse for the dup scan) and ComputeLISInto bool-mask coverage. Full Reactor.Tests suite green (9693 passed); core lib Release build is warning-clean (AOT/trim). Closes #653 Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 27, 2026
…ff (#657) * perf: eliminate per-diff allocations in ChildReconciler + KeyedListDiff Hot keyed list-diff path (grid steady state) allocated heavily and missed fast-paths even when keys were unchanged. Eliminate per-diff allocations and add the missing fast-path, preserving diff behavior exactly. ChildReconciler.cs: - Keyed prefix/suffix loops now take the Element.CanSkipUpdate early-exit that the positional path has, so stable keyed rows no longer re-diff every tick (#30); cache children.Count once instead of re-reading the COM IVector.get_Size per suffix iteration (#37). - Replace HashSet-returning ComputeLIS with allocation-free ComputeLISInto filling a pooled bool mask; pool tails/tailIndices/predecessors from ArrayPool (#31/#32). Keep a thin ComputeLIS(int[]) wrapper for tests. - Pool ReconcileKeyedMiddle's working arrays (ArrayPool) and the two key->index maps (re-entrancy-safe ThreadStatic dict pool); buffers cleared and returned on every exit (#33). - Filter: count-pass + single Element[] fill, no List+ToArray (#36). - GetKey: cache Type.Name via ConcurrentDictionary (#38). KeyedListDiff.cs: - Rent newKeys from ArrayPool<string>, threading explicit newCount (rented array may be larger); returned clearArray:true in a finally (#2). - Move the no-op (SequenceEqual) + empty/empty fast paths ABOVE the duplicate scan so the steady-state grid case never allocates/scans a dup set (#1). - Fold the churn-bailout decision into ApplyGeneral, computed from the same post-prefix/suffix scratch map the general walk builds (diff-range churn == full-range churn), removing the O(2n) null-marker pre-pass (#34). - Pool the doomed ReactorRow[] (ArrayPool, descending IComparer sort over [0,removes), cleared+returned) (#3). - Lazy-allocate movedRows only on an actual move under an ambient (#35). - In-place SyncLastKeysToSource instead of LastKeys Clear()+Add (#10). - HasDuplicates reuses state.Scratch (TryAdd) for 4+ keys instead of a fresh HashSet (#11); cached null-key diagnostic sample (#41). Tests: add pooling non-corruption coverage (rented-buffer-larger-than-count, interleaved independent states, randomized stress vs oracle with survivor identity, pooled doomed removes, churn with shared prefix+suffix, Scratch reuse for the dup scan) and ComputeLISInto bool-mask coverage. Full Reactor.Tests suite green (9693 passed); core lib Release build is warning-clean (AOT/trim). Closes #653 Co-authored-by: Copilot <[email protected]> * perf: address PR review on keyed-diff allocation fixes Review follow-ups on #657 (keyed list-diff allocation work): - ChildReconciler.ReconcileKeyedMiddle: return the pooled matched and inLis bool[] buffers with clearArray:false instead of true (Copilot review). Both are value-typed (no reference pinning) and have their used range fully (re)initialized before any read - matched via the Array.Clear on rent, inLis via ComputeLISInto leading clear - so the full-array wipe on return was avoidable O(rented-capacity) work on the hot path. Matches how the int[] newToOld already returns. Reference-typed pooled buffers (string[]/ReactorRow[] in KeyedListDiff) still clear. - Tests (ChildReconcilerLisIntoTests): replace the circular oracle that compared ComputeLISInto against ComputeLIS (now a thin wrapper over it) with an independent brute-force LIS-length DP that honors the -1 unmapped sentinel, asserting the mask marks a valid strictly-increasing subsequence of maximal length. - Tests (ChildReconcilerKeyedSkipTests, new): cover the #30 keyed CanSkipUpdate fast path - an identical keyed list skips every row with no ops and no child-control access, across repeated stable frames. Co-authored-by: Copilot <[email protected]> * fix: correct keyed-middle reorder identity (C1/H1) + reorder & alloc tests The keyed-middle reconciliation in ChildReconciler patched surviving controls by their FINAL panel index while the panel was only partially rearranged, so on reorders a survivor was patched against the wrong control (C1, CRITICAL): e.g. rotation [a,b,c,d]->[b,c,d,a] rendered "c" at slot 0 and scrambled keyed identity (focus/animation/state landed on the wrong row). A related stale keyToIndex (only the moved key was rewritten) left shifted siblings mis-indexed after an insert/move (H1). Fix: extract the index logic into RunKeyedMiddleCore<TSink> behind a struct-generic IKeyedMiddleSink seam (devirtualized, AOT-clean) and replace the left-to-right loop with the canonical right-to-left LIS walk. Each item is positioned immediately before its already-placed right neighbour; LIS members stay put and only out-of-LIS movers relocate (minimal moves). Every survivor is patched at its CURRENT live position, resolved from a pooled oldRelToPanel int[] that is mutated in lock-step with every Insert/Move so it stays exact -- fixing C1 and H1 together. The production RealKeyedMiddleSink drives the identical Mount/Move/ UpdateChild/Unmount/Replace + ambient enter/move behaviour as before. oldRelToPanel replaces the second pooled key->index dict (one fewer rented dict per call). Tests: - ChildReconcilerKeyedMiddleCoreTests (new): a headless SimKeyedMiddleSink drives the SAME RunKeyedMiddleCore over identity cells (exact production parity, no live-WinUI selftest wall), with a 4-invariant oracle (length, prefix/suffix untouched, per-slot identity+content, every patch hits its claimed survivor) across rotation, full reverse, scramble, block-swap, inserts/removes/duplicates and prefix/suffix offsets. A faithful pre-fix reproduction proves the rotation regression test has teeth (the buggy walk corrupts content[0] and mis-patches; the real core is clean). - KeyedListDiffPoolingTests: two GC.GetAllocatedBytesForCurrentThread budgets guarding the #1/#2/#11 pooling -- no-op steady-state diff is 0 B/iter and a 128-key reorder is 72 B/diff; reverting the pooling (a new string[128] + a 128-entry HashSet per diff) fails them. Diff correctness preserved; pooled buffers returned on every exit. Co-authored-by: Copilot <[email protected]> * fix: gate keyed no-op fast path on duplicate-free state + test hardening Address Copilot re-review of e664f9f. KeyedListDiff: the no-op fast path runs above the duplicate scan (#1), so an UNCHANGED list that already holds duplicate keys -- the state a prior duplicate bailout leaves behind, since ReactorListState.Reset preserves the dups in Source/LastKeys but collapses ByKey to first occurrences -- would match LastKeys and return Empty, silently skipping the duplicate bailout/diagnostic and leaving the diff in an invalid duplicate state. Gate the fast path on `state.ByKey.Count == oldCount`: true exactly for the duplicate-free steady state (allocation-free path preserved), false when dups were collapsed (re-takes the bailout). The check is O(1) and short-circuits before the O(n) SequenceEqualOrdinal, so the common unique-key path pays nothing. No-op steady-state allocation stays 0 B/iter. Tests: - KeyedListDiffTests: new Apply_Unchanged_Duplicate_List_Re_Bails_Instead_ Of_NoOp_FastPath -- proves an unchanged duplicate list re-bails; verified to FAIL without the guard (takes the no-op path and returns Empty). - ChildReconcilerLisIntoTests: strengthen the LIS oracle to assert selected indices are never the unmapped -1 sentinel (a buggy impl could swap a real member for a -1 and still satisfy strictly-increasing + length). - KeyedListDiffPoolingTests: drop the unused `using System.Buffers;` (fully-qualify the one ArrayPool cref) flagged by the reviewer. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
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
Clean up
coverage.settings.xmlso the combined unit+selftest coverage number reflects product-code quality, not test-harness self-coverage.What changed in
coverage.settings.xml:ReactorD3.dllinclude (the D3 project was folded intoReactor.dlllong ago, leaving the entry as a dangling warning in every coverage run).obj/**paths and*.g.csfiles (WinRT/AOT source-generator output was ~11k lines of noise in the denominator — un-hand-written, un-testable).[ExcludeFromCodeCoverage],[GeneratedCode].Reactor.AppTests.Host.dllfromModulePathsentirely. The test harness's own self-coverage is circular — selftest fixtures cover themselves by definition. Including it just juiced the number.What changed in
CONTRIBUTING.md:dotnet-coverage merge unit.cobertura.xml selftest.cobertura.xml ...) as the canonical coverage command.Resulting numbers (merged unit + selftest, Reactor.dll only)
Most of the jump comes from (a) merging in unit-test coverage that was never being counted and (b) no longer drowning the denominator in WinRT source-generator output.
The honest number is below the 85% target. Closing that gap via new selftest fixtures for uncovered areas (
SemanticPanel,PreviewCaptureServer,TransitionEngine, reconciler edge cases, etc.) is a follow-up change — this PR is config only.Test plan
dotnet test tests/Reactor.Tests— 4600 pass, 0 faildotnet run --project tests/Reactor.AppTests.Host -- --self-test— 0 failuresdotnet-coverage merge unit.cobertura.xml selftest.cobertura.xml …produces a merged Cobertura report without warnings🤖 Generated with Claude Code