Repository navigation
fix(hr): a re-observed up-to-date file must be a silent no-op (spec 055) - #23865
Conversation
|
Claude finished @dr1rrb's task in 5m 58s —— View job PR Review —
|
| # | Severity | Location | Issue |
|---|---|---|---|
| 1 | Medium | line 8 (Related links) | Specs 053 and 054 don't exist in the repo; spec 054 is load-bearing (it is what turns the 0-update branch into Failed). Dependency order should be confirmed before implementation. |
| 2 | Medium | lines 28-35 (Overview) | The "overwrites the real outcome" claim is only accurate for the exception path in ProcessFileChanges (where the catch block completes O1 outside the gate). The normal path is already protected by the under-gate merge decision; a parasite pass there gets a fresh O2. The "Observed live" scenario should pin which path was observed. |
| 3 | Medium | line 111 (Test plan #5) | Test case 5 as written targets "same operation" but the gate-protected flow puts pass B on O2, not O1. The test should either drive the HotReloadOperation.Complete CAS directly (idempotency), or construct the exception-path scenario that actually reuses O1. |
| 4 | Minor | line 53 (R1) | SourceText.ContentEquals is O(n) on every call; SourceText.GetChecksum() caches the hash after first computation. The spec already mentions checksums as an alternative — suggest presenting checksum comparison as the primary path (with ContentEquals as the fallback) rather than the reverse. |
There was a problem hiding this comment.
Pull request overview
Adds a new Hot Reload design spec (spec 055) describing how to deduplicate trailing file-system watcher batches that produce no effective solution changes, and how to prevent such no-op passes from overwriting real operation outcomes.
Changes:
- Introduces requirements for content-level no-op detection during solution updates (document + additional document text comparisons).
- Specifies operation-lifecycle protections so vacuous continuation passes cannot degrade an already-determined outcome.
- Defines a unit-test plan for the updater, manager short-circuiting, and merged-operation outcome preservation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Claude finished @dr1rrb's task in 5m 8s —— View job PR Review —
|
| # | Severity | Location | Issue |
|---|---|---|---|
| 1 | Minor | Given_SolutionUpdater.cs:16 (and all other [Description] attributes in that file + Given_HotReloadManager.cs:317) |
All descriptions reference "Spec 055 R2" for behaviour that is R1 in the spec (content-level no-op detection). R2 is "the info file stays a first-class change", which is not directly unit-tested. Systematic off-by-one impairs traceability as the spec evolves. |
| 2 | Minor | SolutionUpdater.cs:37 |
<see cref="..."/> inside a plain // comment is not processed by the doc generator — it renders as literal XML markup to source readers. |
| 3 | Style | HotReloadManager.cs:174 |
GetAllPaths().ToImmutableArray() is { IsEmpty: false } upToDate — the IsEmpty: false double-negation is uncommon. Two-liner (var upToDate = ...; if (!upToDate.IsEmpty)) is clearer and equivalent. |
No functional or correctness issues found in the implementation.
|
Claude finished @dr1rrb's task in 5m 12s —— View job PR Review —
|
| # | Severity | Location | Issue |
|---|---|---|---|
| 1 | Nit | SolutionUpdater.cs:158 |
ChangeSet.Empty with { ... } always creates a new record even when both builders are empty (common non-parasite path); a count guard preserves the existing default and skips the allocation. |
| 2 | Minor | HotReloadManager.cs:174 |
GetAllPaths().ToImmutableArray() instantiates an enumerator + ImmutableArray on every hot-reload pass; a cheap IsEmpty pre-check on the struct fields avoids both in the fast path. |
| 3 | Nit | Given_HotReloadManager.cs:333 |
UpToDateChanges = ChangeSet.IgnoreAll(["/work/Model.cs"]) uses the IgnoredFiles slot, which works but diverges from how production code populates UpToDateChanges (EditedDocuments/EditedAdditionalDocuments). |
Cross-cutting observations:
specs/053andspecs/054are still absent from the repo (flagged in the previous review cycle). If they're on other in-flight branches, fine; if they're expected to exist before implementation, they should land first.ContentEquals(O(n) character scan) vsGetChecksum()(cached after first call) was previously noted on the spec. The implementation follows the spec's stated choice — the performance trade-off is a spec-level call, not a code-level defect.- Test coverage in
Given_SolutionUpdateris thorough: realized-identical, realized-different, additional-document, mixed batch, and unrealized-text boundary cases are all covered. The manager test for the fully-reduced-batch short-circuit is well-structured.
Spec (first review round): - Replace dead links to specs 053/054 (absent from the repo) with the blocked-compilation audit issue #23861; drop the tangential 053 reference. - Scope the "overwrites the real outcome" claim to the still-open window (the normal path is already guarded by the under-gate merge decision 8076b44, which routes a completed operation's parasite to a fresh operation). - Document why ContentEquals is preferred over GetChecksum for this access pattern (fresh disk text carries no cached checksum; one comparison per pass). Code (second review round): - SolutionUpdater: keep UpToDateChanges as ChangeSet.Empty unless at least one entry was skipped, so the common path allocates no ChangeSet; plain-text doc reference in the // comment (a <see cref> there is not processed). - HotReloadManager: guard the up-to-date verbose report on the cheap EditedDocuments/EditedAdditionalDocuments emptiness check, so the common path builds neither the GetAllPaths enumerator nor the ImmutableArray. - TempDirectory: broaden the best-effort cleanup catch to UnauthorizedAccessException. - Tests: correct the Spec 055 R2 -> R1 requirement labels; build UpToDateChanges via EditedDocuments (as the real updater does) rather than IgnoreAll.
|
Claude finished @dr1rrb's task in 2m 26s —— View job PR Review —
|
| Round | Finding | Status |
|---|---|---|
| 1 | Dead links to specs 053/054 | Removed; #23861 and spec 050 remain |
| 1 | "overwrites real outcome" claim too broad | Overview now precisely scopes to the exception-path / still-open-operation window |
| 1 | Test plan inconsistent with gate-flow | Test plan rewritten around content-level no-op; spec status updated to Resolved |
| 1 | ContentEquals vs GetChecksum trade-off undocumented | Rationale added to spec (lines 54–61) |
| 2 | [Description] attributes cited R2 for R1 behaviour |
Fixed across all 5 Given_SolutionUpdater methods and the manager test |
| 2 | <see cref> in plain // comment |
Replaced with plain-text reference |
| 2 | IsEmpty: false double-negation |
Replaced with clean struct-field emptiness guard |
| 3 | UpToDateChanges allocated on every pass |
Guarded: ChangeSet.Empty returned when no entries skipped |
| 3 | Unconditional GetAllPaths().ToImmutableArray() |
Guarded on EditedDocuments/EditedAdditionalDocuments emptiness check |
| 3 | TempDirectory.Dispose caught only IOException |
Now catches IOException or UnauthorizedAccessException |
| 3 | Manager test used IgnoredFiles slot |
Fixed: test populates EditedDocuments to match how the real updater reports up-to-date entries |
Implementation quality notes (no action needed):
TryGetText+ContentEqualsguard is correctly ordered: the file is always read (needed for theWithDocumentTextcall on change/unrealized paths), and only the identical-content case bears the unnecessary I/O cost — the accepted trade-off for simpler code (the spec explains the ContentEquals reasoning at lines 54–61).UpToDateChangesdocuments inSolutionUpdaterare from the original solution snapshot; the manager only consumes theirFilePathviaGetAllPaths(), so snapshot provenance doesn't matter downstream.- Test harness in
When_FullyReducedBatch_Then_NoChangesWithoutEmitNorAuditbuilds the upToDateDocumentfrom a forked snapshot (not what's returned), but the comment explains this and the assertion only checks the file path — correct for the test's purpose.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23865/wasm-skia-net9/index.html |
autocarl
left a comment
There was a problem hiding this comment.
Static review of the current head. The content comparison and snapshot preservation are sound, and the hosted CI failure is an unrelated iOS worker timeout. However, the new up-to-date signal does not yet prevent the outcome race that motivates the PR, so I cannot approve this head.
|
Claude finished @dr1rrb's task in 4m 50s —— View job PR Review —
|
| # | Severity | Location | Issue |
|---|---|---|---|
| 1 | Nit | HotReloadManager.cs:138 |
No targeted test for the exception-path gate race. When_BatchMergedIntoCompletedOperation_Then_ItsResultIsTracked covers the normal-path only; a throw-while-queued scenario would directly verify the new invariant. |
| 2 | Nit | spec.md:95 |
Non-goal bullet "operation lifecycle untouched" is now stale — the gate scope was widened in 2c9d392d. |
No functional or correctness issues found in any changed file.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Uno.HotReload/Diffing/SolutionUpdater.cs:52
- Pre-size the additional-document builder to avoid internal growth allocations when many additional files are edited in a batch.
var upToDateAdditionalDocuments = ImmutableArray.CreateBuilder<TextDocument>();
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23865/wasm-skia-net9/index.html |
|
Tick the box to add this pull request to the merge queue (same as
|
…il operations Trailing file-system events can re-open a watcher batch for files whose content is already in the solution: the pass forks the solution anyway (identical text still produces a new snapshot), emits 0 updates, lands in the blocked- compilation audit, and - when it merged into the originating request's still- open operation - overwrites the real outcome (observed: request reported Failed after its edits applied successfully). Spec: content-level no-op detection in the solution updater (SourceText.ContentEquals, docs + additional docs, reference-equal solution when fully reduced), and lifecycle protection so a vacuous continuation never degrades a substantive outcome. The info file stays a first-class change (content-based dedup only).
FileUpdater writes a request's edits AND its per-request hot-reload info file (HotReloadInfo.g.cs) under the BufferGate, so they flush as one batch. But the file system is not transactional: a single write emits several inotify events (IN_MODIFY, IN_CLOSE_WRITE) and WaitForFileUpdated only syncs on the first. A trailing event - typically the close-write for a file the pipeline just wrote itself, delivered after the 250 ms buffer closed (observed on Linux/inotify during a long first pass) - opened a NEW watcher batch for a file whose on-disk content was already in the solution. That parasite pass forked the solution (byte-identical WithDocumentText still creates a snapshot), emitted 0 updates, landed in the blocked-compilation audit, and - when merged into a still-open operation - overwrote the real outcome (observed: request reported Failed after its edits applied successfully). Fix (spec 055): content-level no-op detection in SolutionUpdater. Before replacing a document's text, compare the new on-disk content with the current text (SourceText.ContentEquals, documents + additional documents) and skip identical writes. Only realized texts are compared, so a never-read document is always applied (never swallow a first edit). A fully-reduced batch returns the original solution instance, so the manager's reference-equality NoChanges short-circuit fires BEFORE the emit: no metadata roundtrip, no audit, no Failed. Skipped entries are surfaced on SolutionUpdateResult.UpToDateChanges (consumed, not ignored) and reported by the manager with a verbose line. The info file stays a first-class change: its content genuinely changes per request, so on the request's own batch it differs from the solution and is applied/emitted normally (VersionId keeps bumping - spec 050 R6). The dedup is strictly content-based; only byte-identical re-observations are suppressed. No watcher-level trigger exclusion: making a specific file unable to open the update gate is conceptually wrong and cannot be made reliable (the file system is not transactional). The operation lifecycle, TryMerge and the merge-under-gate decision (8076b44) are untouched.
Spec (first review round): - Replace dead links to specs 053/054 (absent from the repo) with the blocked-compilation audit issue #23861; drop the tangential 053 reference. - Scope the "overwrites the real outcome" claim to the still-open window (the normal path is already guarded by the under-gate merge decision 8076b44, which routes a completed operation's parasite to a fresh operation). - Document why ContentEquals is preferred over GetChecksum for this access pattern (fresh disk text carries no cached checksum; one comparison per pass). Code (second review round): - SolutionUpdater: keep UpToDateChanges as ChangeSet.Empty unless at least one entry was skipped, so the common path allocates no ChangeSet; plain-text doc reference in the // comment (a <see cref> there is not processed). - HotReloadManager: guard the up-to-date verbose report on the cheap EditedDocuments/EditedAdditionalDocuments emptiness check, so the common path builds neither the GetAllPaths enumerator nor the ImmutableArray. - TempDirectory: broaden the best-effort cleanup catch to UnauthorizedAccessException. - Tests: correct the Spec 055 R2 -> R1 requirement labels; build UpToDateChanges via EditedDocuments (as the real updater does) rather than IgnoreAll.
…c 055) ProcessFileChanges acquired the solution-update gate inside the try, so on the failure path the `using` released it as the exception unwound — before the catch completed the operation as InternalError. In that window a queued batch could acquire the gate, merge into the still-open operation (TryMerge sees _result == -1) and complete it first (e.g. as a content-no-op NoChanges), dropping this pass's real outcome and reporting a failed pass as a clean reload. Hold the gate across the whole pass, including the catch, so the completion — terminal outcome on success, or InternalError on failure — always happens under the gate. A queued batch then only runs after this operation is completed, so its TryMerge starts a fresh operation instead of overwriting this one. Ownership is enforced by the gate; no separate completion-ownership guard is needed. Also: TempDirectory.WriteFileAsync (test helper) rejects a rooted relativePath before Path.Combine, so a rooted value cannot silently drop the temp root.
2c9d392 to
2d8bfc2
Compare
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/Uno.HotReload.Tests/Given_HotReloadManager.cs:483
- The test builds
upToDateDocby callingsolution.AddDocument(...)but then returns the originalsolutioninstance. That meansUpToDateChangescontains aDocumentthat does not belong toresult.Solution(and holds onto an extra solution snapshot), which is confusing and could break if production code later assumes those documents are from the returned solution. Since the manager only needs paths for diagnostic logging here, consider populatingUpToDateChanges.IgnoredFileswith the up-to-date path instead of manufacturing aDocumentfrom a different snapshot.
// Mirror the real updater: up-to-date entries are surfaced via EditedDocuments (with
// their file path), never IgnoredFiles. Build a document to reference but return the
// original solution unchanged, so the reference-equality NoChanges short-circuit fires.
var docId = DocumentId.CreateNewId(solution.ProjectIds[0]);
var upToDateDoc = solution
.AddDocument(docId, "Model.cs", "class Model { }", filePath: "/work/Model.cs")
.GetDocument(docId)!;
return new SolutionUpdateResult(solution, ChangeSet.IgnoreAll([]))
{
UpToDateChanges = ChangeSet.Empty with { EditedDocuments = [upToDateDoc] },
};
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23865/wasm-skia-net9/index.html |
|
|
GitHub Issue: closes #23862
PR Type:
🐞 Bugfix
What changed? 🚀
A trailing file-system event for a file the hot-reload pipeline wrote itself — the
per-request
HotReloadInfo.g.cs, whose lateIN_CLOSE_WRITE(Linux/inotify) arrives afterthe 250 ms watcher buffer already closed — re-opened a watcher batch for content that was
already in the solution. That parasite pass forked the solution (a byte-identical
WithDocumentTextstill produces a new snapshot), emitted 0 updates, landed in theblocked-compilation audit, and — when it merged into the originating request's still-open
operation — overwrote the real outcome (observed live: the request reported
Failedafter its edits had applied successfully).
Fix — content-level no-op detection in
SolutionUpdater. Before replacing a document'stext, the new on-disk content is compared with the current text (
SourceText.ContentEquals,documents and additional documents) and identical writes are skipped. Only realized
texts are compared, so a document that was never read is always applied (a first edit is
never swallowed). A fully-reduced batch returns the original
Solutioninstance, so themanager's reference-equality
NoChangesshort-circuit fires before the emit — nometadata roundtrip, no audit, no spurious
Failed. Skipped entries are surfaced onSolutionUpdateResult.UpToDateChanges(consumed, not ignored) and reported by the manager.The info file stays a first-class change: on the request's own batch its content genuinely
differs from the solution, so it is applied and emitted normally and the app's
HotReloadInfo.VersionIdkeeps bumping (spec 050 R6). The operation lifecycle,TryMerge,and the merge-under-gate decision (
8076b444aa) are untouched. No watcher-level triggerexclusion — making a specific file "unable to open the update gate" is conceptually wrong
and cannot be made reliable (the file system is not transactional). Full reasoning and the
rejected alternatives are recorded in
specs/055-hotreload-noop-pass-dedup/spec.md.PR Checklist ✅
Screenshots Compare Test Runresults.