Skip to content

[Testing] Fix MainThread isolation and integration failure diagnostics - #38575

Merged
kubaflo merged 2 commits into
mainfrom
kubaflo-main-ci-fix
Sep 17, 2026
Merged

kubaflo merged 2 commits into
mainfrom
kubaflo-main-ci-fix

Conversation

@kubaflo

@kubaflo kubaflo commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Fixes confirmed test-isolation and integration-harness defects found while investigating recent maui-pr failures on main:

  • Restore MainThreadStaticStateCollection with DisableParallelization = true. Its deletion left the existing collection attributes without cross-collection isolation, allowing MainThread bridge tests to race other tests that create a MauiApp.
  • Update MSBuild.StructuredLogger from 2.2.158 to 2.3.246 to fix the property-reassignment reader crash that masked the original Android build timeout.
  • Report incomplete binlogs without replacing the original build failure. Use Replay with its actual truncation status and explicitly propagate reader exceptions; retain errors read before the truncation. Authoritative warning validation rejects incomplete logs, including truncation after BuildFinished during the embedded import archive or before the final end marker.
  • Initialize StructuredLogger message resources explicitly before Replay, which otherwise fails on property reassignment in a fresh process. ReadRecords initializes them but does not populate HasEncounteredTruncation, so merely checking that flag after ReadRecords is insufficient.
  • Terminate timed-out command process trees, preserve the emulator's intentional startup-capture keep-alive behavior, and bound output draining so inherited pipes cannot hang cleanup. Timeout and drain diagnostics fall back to the console when no test output helper is supplied.
  • Add eleven harness regression cases and document the timeout/binlog behavior and workload-free test command. Tests that capture the process-wide console run in a nonparallel collection.

Issues Fixed

  • Main build 1595566: intermittent InvokeOnMainThreadAsync_Action_WorksThroughBridge failure with NotImplementedInReferenceAssemblyException.
  • Main build 1597559: the .NET 9 Debug Android template hit its 1,800-second build timeout, after which binlog parsing threw ArgumentNullException and obscured the underlying failure.

Scope limitation: this PR does not establish or fix the cause of the underlying Android SDK BuildApk packaging hang. It fixes the proven isolation, process-cleanup, and diagnostic defects; it does not claim that all main-branch CI failures are resolved. The invalid Android tools ZIP in build 1595566 was a separate provisioning failure and is not changed here.

Validation

  • Current integration-harness regressions: 11 passed in both Debug and Release, .NET SDK 10.0.100 on macOS ARM64.
  • Before the review fixes, the two late-truncation cases and no-helper timeout diagnostic case failed against the previous PR head; all now pass. The late-truncation fixtures retain BuildFinished from a real MSBuild binlog and cut either inside its embedded archive or immediately before its end marker.
  • Verified property-reassignment parsing separately in a fresh test process to rule out resource initialization by another test.
  • Committed inherited-pipe regression verifies the parent exits normally, the child remains alive, and output draining returns within the bound and emits a diagnostic. Existing cases cover timeout process-tree cleanup and explicit keep-alive behavior.
  • MainThread bridge tests: 13 passed. Coupled Core test slice: 112 passed, with 20/20 repeated runs clean (unchanged since initial validation).
  • Initial revision: replayed the actual failing CI binlog to reproduce the old reader's ArgumentNullException and confirm incomplete-log diagnostics and strict warning rejection after the fix.
  • Previous PR revision passed maui-pr build 1598385. CI for the review revision is being rerun; no result is claimed yet.
  • The full Core suite has not been rerun locally, and the underlying Android packaging hang has not been reproduced end-to-end.

Restore the nonparallel MainThread test collection, upgrade the binlog reader, preserve incomplete-log diagnostics, and terminate timed-out process trees without stopping emulator startup. Add focused regression coverage and harness documentation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 15, 2026 22:40
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38575

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38575"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Timeout test determinism, timeout diagnostics, and pipe-drain coverage need correction or completion.

Pull request overview

This PR fixes MAUI test isolation and integration-harness failure diagnostics.

Changes:

  • Restores serialized MainThread state tests.
  • Adds process-tree cleanup and bounded output draining.
  • Detects incomplete binlogs and upgrades StructuredLogger.
  • Adds regression tests and documentation.
File summaries
File Description
src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/ToolRunner.cs Timeout cleanup, diagnostics, and output draining.
src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/BuildWarningsUtilities.cs Incomplete binlog detection.
src/TestUtils/src/Microsoft.Maui.IntegrationTests/ToolRunnerTests.cs Timeout and process-tree regression tests.
src/TestUtils/src/Microsoft.Maui.IntegrationTests/Microsoft.Maui.IntegrationTests.csproj StructuredLogger update.
src/TestUtils/src/Microsoft.Maui.IntegrationTests/BuildWarningsUtilitiesTests.cs Binlog parsing and truncation tests.
src/TestUtils/src/Microsoft.Maui.IntegrationTests/Android/Emulator.cs Preserves emulator keep-alive behavior.
src/Core/tests/UnitTests/MainThreadStaticStateCollection.cs Serializes shared MainThread state tests.
docs/DevelopmentTips.md Documents harness behavior and test commands.
Review details

Suppressed comments (4)

src/TestUtils/src/Microsoft.Maui.IntegrationTests/ToolRunnerTests.cs:29

  • On Windows, ping -n 60 127.0.0.1 is not a 60-second delay: loopback replies immediately, so the command normally finishes before the one-second timeout. The test then observes exit code 0 instead of exercising timeout/keep-alive behavior. Use a deterministic sleep command (or a genuinely delayed target) for the Windows branch.
		var info = CreateShell("sleep 60", "ping -n 60 127.0.0.1 > nul");

src/TestUtils/src/Microsoft.Maui.IntegrationTests/ToolRunnerTests.cs:60

  • This Windows child uses the same loopback ping as a supposed 60-second hold, but those 60 replies complete almost immediately. Consequently the parent can finish before the five-second timeout and this test does not verify child-tree termination (and will fail its timeout assertion). Replace it with a deterministic delayed child process.
			info.ArgumentList.Add("$child = Start-Process -FilePath $env:ComSpec -ArgumentList '/c ping -n 60 127.0.0.1 > nul' -NoNewWindow -PassThru; [Console]::WriteLine($child.Id); $child.WaitForExit()");

src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/ToolRunner.cs:81

  • This timeout diagnostic is dropped whenever callers omit ITestOutputHelper; for example, Apple/Codesign.cs:13-17 calls ToolRunner.Run without one. A timed-out process is then killed and returns -1 with no PID or duration in the test output, defeating the new failure-diagnostics behavior. Emit this message to Console when output is null, as the bounded-drain warning below already does.
					output?.WriteLine($"[ToolRunner] Process '{Path.GetFileName(p.StartInfo.FileName)}' (PID {p.Id}) timed out after {timeoutInSeconds} seconds.");

src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/ToolRunner.cs:99

  • This new branch is the safeguard for a parent that exits while a descendant keeps an inherited redirected pipe open, but the added tests do not exercise it: the child-tree test kills the descendant, and the keep-alive case skips this drain entirely because exited remains false. Add a regression case where the parent exits but a child retains stdout/stderr, and assert Run returns after the documented bound and reports the bounded-drain diagnostic; otherwise the main pipe-hang fix is unprotected.
				if (exited && !Task.WhenAll(stdoutClosed.Task, stderrClosed.Task).Wait(TimeSpan.FromSeconds(10)))
  • Files reviewed: 8/8 changed files
  • Comments generated: 0
  • Review effort level: Lite

@kubaflo

kubaflo commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the complete eight-file revision 97e75d0ea7917438b72f5ab83ec7c15d9f74fd2f, including process-cleanup consumers, test isolation, and binlog producer/reader behavior. One incomplete-input validation issue remains.

Reject truncation after BuildFinished, too. The guard at BuildWarningsUtilities.cs:103-115 treats the finishing event as sufficient proof of completeness. The actual SDK writer still embeds imports and writes the end-of-file marker afterward. With the pinned StructuredLogger 2.3.246, a short import-archive stream can be consumed without throwing, then the record reader catches physical EOF, sets its premature-EOF flag, and ends enumeration normally. MAUI does not inspect that status.

A writer-faithful format-25 reduction with real framed events and a ZIP import archive reproduces the boundary: cutting the finalized compressed file during the archive retains BuildStarted and BuildFinished but loses the remainder and EOF marker. The shared helper consequently returns an empty warning list and emits no incomplete-log diagnostic. Cutting before BuildFinished correctly rejects the input. Preserve/check actual reader truncation or end-marker status, keep diagnostics nonthrowing, and make authoritative validation reject this late-truncated case. Add a regression truncating after BuildFinished, during finalization.

The demonstrated loss is import/archive/footer metadata, not warning events, and timed-out builds still fail; this is not a false-green-build claim. The blocker is the explicit documented requirement to reject incomplete binlogs and report their incompleteness. The accepted scope excluding the underlying Android packaging hang and provisioning failures is unchanged. No other high-confidence blocking issue was found; the Windows ping comments were not substantiated by the actual test behavior.

Evidence combines exact package/runtime/writer source, a reviewer-authored binary-framing and decompression reduction, and inspected exact-head CI results; downloaded PR code was not executed.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 16, 2026
MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Sep 16, 2026
Use Replay truncation status and propagate read exceptions without losing captured build errors. Initialize message resources for cold-start parsing. Preserve timeout diagnostics without a test output helper and add late-finalization and inherited-pipe regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 17, 2026 11:18
@kubaflo kubaflo changed the title Fix MainThread test isolation and integration failure diagnostics [Testing] Fix MainThread isolation and integration failure diagnostics Sep 17, 2026
@kubaflo

kubaflo commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review details

Suppressed comments (1)

src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/ToolRunner.cs:92

  • If the process exits in the race between the timeout return and p.Kill, the catch block acknowledges that state but leaves exited false. The subsequent drain is therefore skipped, so final stdout/stderr can be lost even though the process has already exited. Set exited = true (or recompute it and wait for exit) in this branch before applying the output-drain logic.
						catch (InvalidOperationException) when (p.HasExited)
						{
							// The process exited between the timeout and termination.
						}
						exited = p.WaitForExit(10000);
  • Files reviewed: 8/8 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-reviewed the complete eight-file revision 0a43f99cf7ed7c6beb9e2b70e344d3cdb5a3135a, including the replacement Replay pipeline, all eleven harness cases, process-cleanup consumers, and current CI boundary. The previous late-truncation finding is fixed: actual truncation status, read-error propagation, resource initialization, retained diagnostics, and both late-cut cases are addressed. Console fallback and inherited-pipe coverage are also present.

One new regression remains: a callback failure can deadlock Replay's producer. At BuildWarningsUtilities.cs:108-115, Replay dispatches the callback on a worker consuming a bounded queue. A supported warning with a null filename reaches NormalizeFilePath(warning.File), line95, whose Replace call dereferences it. The exception faults the sole consumer; the producer continues until a queue insertion blocks. OnException observes errors from reader.Read, not exceptions from processEvent.

The SDK logging API permits a null file, and its location backfill does not replace that null when a line number is supplied. The pinned diagnostic reader preserves the optional value. Replay uses ten bounded batches, and BatchBlockingCollection uses 8,192 events per batch without making producer additions observe a faulted consumer.

An independently authored, fully framed format-25 reduction with ZIP imports and EOF establishes the failure boundary: a null-file warning near the start of a 100,003-event log faults the consumer and strands the producer once its queue fills. An otherwise-identical empty-file warning completes; a small five-event null-file input reaches the task failure instead of hanging. This is source/finite-reduction evidence, not a claim that current CI has exhibited a hang or that downloaded PR/package code was executed.

The null assumption predates this revision, but the failure-mode regression does not: the old synchronous reader failed promptly, whereas the Replay replacement can hang authoritative warning validation inside the test host, beyond ToolRunner's subprocess timeout protection. Normalize optional warning filenames, as the error path already does, and ensure callback failures are captured/propagated without terminating the sole consumer while leaving its producer blocked. Add a bounded regression with a filename-less warning and enough events to exceed queue capacity.

No other current high-confidence blocker remains. Pending CI is not an additional finding; the accepted Android packaging/provisioning exclusions and emulator/process-lifetime policies are unchanged.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 17, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review Summary

@kubaflo — new AI review results are available based on commit 0a43f99.

Gate No Tests Confidence Low Platform Android


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ⚠️ SKIPPED

No tests were detected in this PR.

Recommendation: Add tests to verify the fix using the write-tests-agent.


📋 Pre-Flight — Context & Validation

PR #38575 Pre-Flight

PR context

  • Title: [Testing] Fix MainThread isolation and integration failure diagnostics
  • State/base/head: Open; main <- kubaflo-main-ci-fix (0a43f99cf7ed7c6beb9e2b70e344d3cdb5a3135a)
  • Materialized review commit: 96fa6da51214c3d219bf276e65cb187519d6bb37
  • Author: kubaflo
  • Context source: Public GitHub REST response and the locally materialized squashed commit. gh was unavailable because this environment has no GitHub authentication.
  • Reported failures: An intermittent MainThread bridge failure caused by process-wide state races, and an Android template build timeout whose original failure was obscured by a binlog reader exception.
  • Scope limitation: The PR explicitly does not fix or reproduce the underlying Android SDK BuildApk packaging hang.

Direct diff inspection

The committed PR changes 8 files (+435/-20):

  1. Restores src/Core/tests/UnitTests/MainThreadStaticStateCollection.cs with DisableParallelization = true.
  2. Updates MSBuild.StructuredLogger from 2.2.158 to 2.3.246.
  3. Replaces BinLogReader.ReadRecords use with Replay, explicit resource initialization, exception propagation, and completeness checks while retaining errors read before truncation.
  4. Extends ToolRunner.Run with timeout diagnostics, default process-tree termination, a killOnTimeout: false escape hatch, and a 10-second bound on redirected-output draining.
  5. Uses the escape hatch for intentional Android emulator startup capture.
  6. Adds 11 targeted regression cases in ToolRunnerTests.cs and BuildWarningsUtilitiesTests.cs, plus documentation.

The current PR mechanisms that alternatives must not merely restate are: xUnit collection-level nonparallelization; a StructuredLogger package update plus Replay-based completeness validation; and synchronous WaitForExit followed by tree kill and separately bounded output completion.

Validation boundary

  • Platform: Android.
  • Gate: Skipped previously because no tests were detected. The gate must not be rerun and gate/content.md must not be created or overwritten.
  • Narrow primary command found in the PR diff:
    dotnet test src/TestUtils/src/Microsoft.Maui.IntegrationTests --filter "FullyQualifiedName~ToolRunnerTests|FullyQualifiedName~BuildWarningsUtilitiesTests"
  • Mandatory regression tests supplied by the STEP 5a request: None beyond the primary command.
  • Do not run a full suite. Each candidate gets one implementation/test pass and at most one focused correction/retest.

Safety constraints for attempts

The PR adds three tracked files. Each try-fix invocation must obey the skill's baseline-state boundary: if .github/.baseline-state.json reports any NewFiles, the result is Blocked, no tracked file may be edited, all mandatory artifacts must still be recorded, and the exact restore script must run. The large pre-existing worktree delta under .github/ and eng/ is harness-owned and must be preserved unchanged.


🔬 Code Review — Deep Analysis

Code Review — PR #38575

Independent Assessment

What this changes: The submitted eight-file change restores nonparallel execution for tests sharing MainThread/dispatcher static state; upgrades StructuredLogger; replaces synchronous binlog record enumeration with Replay plus explicit completeness checks; and changes ToolRunner timeout handling to terminate process trees, preserve the emulator's intentional lifetime, bound redirected-output draining, and report timeout/drain diagnostics. It adds focused regression coverage for the new binlog and process behavior.

Inferred motivation: Prevent process-wide test-state races and preserve the original integration-build failure when a timed-out process leaves an incomplete binlog or inherited output pipes.

Reconciliation with PR Narrative

The current title and description accurately describe the submitted mechanisms, their scope limitation, and the added tests. The current implementation does reject truncation after BuildFinished by checking HasEncounteredTruncation; that resolves the earlier review finding against revision 97e75d0e.

Prior Review Reconciliation

Prior ❌ Error Finding Source Status Evidence
Late truncation after BuildFinished was accepted dalexsoto, revision 97e75d0e ✅ Fixed ReadBuildEvents now checks BinLogReader.HasEncounteredTruncation, and the theory covers cuts inside the import archive and before the end marker.
A filename-less warning can fault Replay's only consumer and strand its bounded producer dalexsoto, revision 0a43f99c ❌ Unresolved ReadNativeAOTWarningsFromBinLog passes warning.File directly to NormalizeFilePath, and AnyEventRaised invokes processEvent without containing callback exceptions. The old synchronous reader failed promptly; Replay can block after its consumer faults and the producer fills the bounded queue.

The current expert pass generated no duplicate inline comment, so inline-findings.json is the required valid empty array. The unresolved current-head error remains controlling review evidence.

Blast Radius Assessment

  • Runs for all instances: The ToolRunner policy applies to every integration-harness subprocess; Replay applies to every binlog warning/error read.
  • Startup impact: No product startup impact; this is shared test/CI infrastructure.
  • Static/shared state: The restored xUnit collection intentionally serializes tests using process-wide MainThread/dispatcher state. ConsoleOutputCollection similarly protects process-wide console capture.
  • Default/null behavior: MSBuild permits warnings without a file path. That supported default is unsafe in the new asynchronous Replay callback path.

CI Status

  • Required-check result: Current-head check runs include 29 successes, one skip, and failures in maui-pr, Windows Debug build, Build Analysis, and Build Insights.
  • Classification: Red CI is not needed to establish the Replay defect, and no claim is made here that every current check failure is PR-caused. The trusted Gate was explicitly skipped because it detected no tests, despite the submitted focused tests.
  • Action taken: No gate rerun or full-suite run. Confidence is capped at low because this is shared test infrastructure, current CI is red, and the trusted Gate supplied no regression evidence.

Findings

❌ Error — Replay can deadlock when a build-event callback throws

At src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/BuildWarningsUtilities.cs:95, a supported BuildWarningEventArgs with File == null reaches NormalizeFilePath and throws. At lines 108-115, AnyEventRaised lets that exception escape from Replay's sole bounded-queue consumer. The producer can then block once queued events exceed capacity, turning warning validation into an unbounded test-host hang. Normalize the optional filename and capture callback exceptions without terminating the consumer; propagate the captured exception after Replay has drained. Add a bounded, filename-less warning regression large enough to exceed the queue capacity.

The suppressed ToolRunner.cs:92 race concern is not actionable: after the InvalidOperationException catch, the unconditional p.WaitForExit(10000) recomputes exited, so the drain path is not skipped when the process won the timeout/kill race.

Failure-Mode Probing

  • Filename-less warning near the start of a large complete binlog: the callback throws before Replay drains its bounded queue; the producer can block indefinitely. Unresolved.
  • Complete failed build with ordinary compiler errors/warnings: the explicit end marker leaves HasEncounteredTruncation == false, so nonzero build outcome is not conflated with an incomplete log.
  • Timeout where the process exits just before tree termination: the catch tolerates the race, then the unconditional timed WaitForExit refreshes exited and permits bounded drain handling.
  • Intentional emulator keep-alive: killOnTimeout: false keeps the emulator alive and deliberately skips waiting for pipes owned by that still-running process.

External Output Contract

Consumer token/pattern Producer location Producer emission condition Consumer assumption Ordinary negative case Downstream effect
BuildFinishedEventArgs MSBuild binary logger Written when the build finishes, before embedded imports and the final EOF marker Build events finished, but not sufficient alone to prove physical completeness A complete build that failed normally still emits BuildFinished and EOF Accepted as complete only when Replay also reports no truncation
HasEncounteredTruncation / EOF marker StructuredLogger reading MSBuild binlog Set when the physical stream ends without the required final marker The binlog is incomplete A complete failed build has EOF and must remain valid Warning validation rejects incomplete evidence; error reporting retains events read first
BuildWarningEventArgs.File MSBuild task logging Optional; may be null even for a valid warning Current callback assumes a non-null path A complete failed build containing a legitimate filename-less warning Current Replay callback can fault and deadlock instead of returning or failing promptly
failed to initialize HVF Android emulator stderr Emitted when HVF initialization fails Startup failed because acceleration is unavailable Normal emulator startup does not emit the token Adds targeted diagnostic text; does not classify ordinary nonzero exits as hangs

Verdict: NEEDS_CHANGES

Confidence: low

Summary: The submitted fix addresses its prior truncation, timeout-diagnostic, and output-drain review gaps, but the Replay replacement introduces a concrete unbounded-hang path for valid filename-less warnings. Fix that callback-failure boundary and add the discriminating regression before merge; current red CI and the skipped trusted Gate also prevent an approval recommendation.


🛠️ Try-Fix — Analysis & Comparison

Try-Fix Attempts (PR #38575)

Candidate 1 (STEP 5a)

Candidate 1 (STEP 5a) — Try-Fix Execution Report

Approach

Streaming timeout diagnostics via bounded asynchronous stdout/stderr readers with explicit reader-state finalization (defined only; not implemented due baseline block).

Prior approach avoided

Did not repeat PR mechanisms: collection-level DisableParallelization for MainThread tests, StructuredLogger Replay/resource initialization/truncation checks, or synchronous WaitForExit + Kill(entireProcessTree:true) + 10s output-drain bound.

Mechanism-level difference

Alternative root cause hypothesis: diagnostics are lost primarily due to post-exit drain timing dependence. Proposed mechanism continuously drains output and classifies timeout from reader state, removing reliance on pipe closure timing after process termination.

Files changed

No tracked PR files changed (blocked before edit).
Attempt artifacts only under:
CustomAgentLogsTmp/PRState/38575/PRAgent/try-fix/attempt-1/

Diff

Empty diff for target PR files (no code edits applied).

Test command/result

Required command (not run due block):
dotnet test src/TestUtils/src/Microsoft.Maui.IntegrationTests --filter "FullyQualifiedName~ToolRunnerTests|FullyQualifiedName~BuildWarningsUtilitiesTests"

Summary: baseline establishment failed first (DIRTY WORKING DIRECTORY), .github/.baseline-state.json absent, so attempt marked Blocked before any edit/test.

Result

Blocked

Failure analysis

pwsh .github/scripts/EstablishBrokenBaseline.ps1 failed and did not produce baseline state. Per skill boundary, absence of baseline allow-list (RevertedFiles) forbids tracked-file edits. Therefore no implementation/testing could proceed safely.

Self-review

reviewer-findings.json created with [] (0 findings).

Artifacts

CustomAgentLogsTmp/PRState/38575/PRAgent/try-fix/attempt-1/

  • baseline.log
  • approach.md
  • reviewer-findings.json
  • reviewer-findings.diff
  • result.txt (Blocked)
  • fix.diff (empty)
  • test-output.log
  • analysis.md

Artifact gate: passed (all required files present).

Restore confirmation

Executed exact required cleanup:
pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore
Output: No baseline state found. Nothing to restore. (Restored=False), consistent with no baseline state having been created.


Candidate 2 (STEP 5a) — Try-Fix Execution Report

Approach

Make process timeout a typed primary failure (designed only; not implemented because the mandatory baseline boundary blocked the attempt). The proposed change would make ToolRunner.Run throw a dedicated timeout exception containing the command, PID, timeout, partial captured output, and process-tree termination outcome instead of collapsing timeout into the ordinary exitCode = -1 result. That exception would propagate through DotnetInternal before its generic nonzero-exit path attempts to parse a potentially truncated binlog.

Prior approaches avoided

This does not repeat the PR mechanisms: xUnit collection-level DisableParallelization; the StructuredLogger upgrade plus Replay/resource initialization/truncation validation; or synchronous WaitForExit, process-tree kill, a separate 10-second output-drain bound, and emulator killOnTimeout: false.

It also does not repeat candidate 1, which proposed asynchronous continuous stdout/stderr streaming and reader-state timeout finalization based on the hypothesis that diagnostics were lost during post-exit pipe draining. No candidate 1 code or test attempt was reopened, rerun, modified, or corrected.

Mechanism-level difference

The alternative root-cause hypothesis is that masking occurs because timeout is encoded in the same sentinel exit-code channel as an ordinary completed build failure. Downstream code consequently enters normal failure diagnostics and parses a binlog even though a timed-out writer can leave that file incomplete. A typed timeout exits that downstream branch before binlog parsing, keeping timeout context authoritative. This changes failure propagation rather than parser recovery or stdout/stderr draining, and it does not depend on asynchronous streaming, reader state, output finalization, or pipe-closure timing.

Files changed

No tracked files changed. Baseline establishment failed before editing and .github/.baseline-state.json was absent, so the skill provided no RevertedFiles allow-list.

Intended implementation area (not edited):

  • src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/ToolRunner.cs
  • targeted timeout coverage in src/TestUtils/src/Microsoft.Maui.IntegrationTests/ToolRunnerTests.cs

Attempt artifacts were created only under:
CustomAgentLogsTmp/PRState/38575/PRAgent/try-fix/attempt-2/

Full captured diff

(empty — no tracked candidate changes)

Test command and output summary

Required narrow command:

dotnet test src/TestUtils/src/Microsoft.Maui.IntegrationTests --filter "FullyQualifiedName~ToolRunnerTests|FullyQualifiedName~BuildWarningsUtilitiesTests"

The command was not run. pwsh .github/scripts/EstablishBrokenBaseline.ps1 failed with DIRTY WORKING DIRECTORY; the mandatory follow-up check returned BASELINE_STATE_ABSENT. Per the baseline-file boundary, the attempt stopped before any tracked edit or test. test-output.log records this reason and the exact unexecuted command. No other test, build, or gate command ran.

Result

Blocked

Failure analysis

The pre-existing dirty worktree caused baseline establishment to fail, and no .github/.baseline-state.json was created. Without that file there was no safe modification allow-list or script-restorable boundary. Implementing or testing the candidate would therefore have violated the workflow and risked pre-existing worktree changes. The mechanism remains untested; no conclusion about behavioral correctness is claimed.

Self-review

Inline expert self-review count: 0 findings. The overarching principles and always-active Logic and Correctness, Regression Prevention, and Complexity Reduction dimensions were applied to the empty candidate diff. reviewer-findings.json contains [], and reviewer-findings.diff is empty. No correction/retest was applicable.

Artifacts

CustomAgentLogsTmp/PRState/38575/PRAgent/try-fix/attempt-2/

  • baseline.log
  • approach.md
  • reviewer-findings.json
  • reviewer-findings.diff
  • result.txt (Blocked)
  • fix.diff (empty)
  • test-output.log
  • analysis.md

Artifact gate: passed; all eight mandatory artifacts exist.

Restore confirmation

Executed the exact required cleanup command after the artifact gate:

pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore

Completed with exit code 0 and output No baseline state found. Nothing to restore. / Restored False, which is the expected no-state completion after a baseline block with no candidate edits. A post-restore target-file diff was empty, confirming no attempt-created tracked change remains.

Attempt status

Done — Blocked by the mandatory baseline safety boundary.


🏁 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Winner

pr is the single comparative winner because it is the only implemented candidate with reported passing focused regressions and successful current-head macOS/Windows integration-test lanes. This is a relative win, not an approval: a valid filename-less warning can fault Replay's sole consumer and block its bounded producer indefinitely, the trusted Gate was skipped, and current required CI is red.

Comparative ranking

Rank Candidate Implementation Regression validation Expert assessment Outcome
1 pr Complete eight-file submitted fix: MainThread static-state isolation, StructuredLogger 2.3.246, Replay completeness/error handling, timeout process-tree cleanup, bounded drain, emulator keep-alive, diagnostics, and tests PR description reports 11 focused harness cases passing in Debug and Release plus 13 MainThread tests and a 112-test coupled slice; current-head macOS and Windows integration-test check runs passed. Trusted Gate was skipped and was not rerun. Fixes the earlier late-truncation and diagnostic findings, but warning.File is still treated as non-null inside an asynchronous Replay callback. A callback exception can terminate the consumer and strand the bounded producer. Comparative winner, but REQUEST CHANGES. Best available evidence, with one concrete blocking defect and undetermined overall merge readiness.
2 pr-plus-reviewer Adds optional-path normalization, deferred callback-exception propagation, and two large-binlog regressions Failed. The one permitted targeted command stopped at compile errors before tests ran because Task is ambiguous in both new async tests. No repair/retest was permitted. The mechanism targets the blocker correctly, but the captured patch is not buildable and candidates failing required regression validation must rank below one with passing evidence. Retain as refinement evidence only; do not select.
3 try-fix-2 Design-only proposal to represent timeout as a typed primary failure and bypass normal post-failure binlog parsing Blocked. Baseline establishment rejected the dirty worktree; no code changed and no test ran. Could prevent a timeout from being masked, but it neither validates incomplete binlogs for other consumers nor addresses MainThread isolation. It also changes failure propagation without executable evidence. Below implemented candidates.
4 try-fix-1 Design-only proposal for continuously streamed output and bounded reader-state finalization Blocked. Baseline establishment rejected the dirty worktree; no code changed and no test ran. Targets output-drain timing only and does not address the MainThread or binlog-completeness defects. Last; no implementation or evidence.

Why the raw PR wins but cannot be approved

The raw PR is materially broader and better evidenced than either blocked STEP 5a design. It also outranks pr-plus-reviewer under the explicit rule that a candidate failing required regression validation ranks below one with passing regression evidence. However, ReadNativeAOTWarningsFromBinLog passes the optional BuildWarningEventArgs.File directly to NormalizeFilePath; under Replay, the resulting callback exception can fault the only bounded-queue consumer while the producer continues filling the queue. This is a concrete unbounded-hang regression from the previous synchronous reader.

The latest check-run snapshot has 29 successes, one skip, and failures in maui-pr, the Windows Debug build, Build Analysis, and Build Insights. The macOS and Windows integration-test lanes passed, but the failing overall checks were not classified in this constrained comparison and cannot be treated as green. The trusted Gate explicitly reported SKIPPED — no tests detected; its recommendation is inconsistent with the submitted test files, but the contract forbids rerunning it.

Required change

Normalize filename-less warnings and ensure exceptions from processEvent are captured without killing Replay's consumer, then propagate the captured exception after Replay drains. Add a bounded large-binlog regression for both the supported null-file warning and a callback failure. The retained pr-plus-reviewer/reviewer.patch demonstrates the intended mechanism, but its test references must be made unambiguous and validated in a new author revision rather than repaired in this one-pass comparison.


📱 UI Tests — Button,Label,Layout

Detected UI test categories: Button,Label,Layout

✅ Deep UI tests — 422 passed, 0 failed, 7 skipped across 3 categories on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
Button 104/106 (2 skipped) ✓ —
Label 123/125 (2 skipped) ✓ —
Layout 195/198 (3 skipped) ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

🧭 Next Steps — review latest findings

No alternative fix was selected for this run. Review the session findings and CI results before merging.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Sep 17, 2026
@kubaflo

kubaflo commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto stamp

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Stamping as requested by @kubaflo; no code review performed.

@kubaflo
kubaflo merged commit e18917e into main Sep 17, 2026
30 of 34 checks passed
@kubaflo
kubaflo deleted the kubaflo-main-ci-fix branch September 17, 2026 22:48
@github-actions github-actions Bot added this to the .NET 10 SR12 milestone Sep 17, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants