Skip to content

Add composable test-host orchestrator middleware - #11607

Merged
Amaury Levé (Evangelink) merged 11 commits into
mainfrom
dev/amauryleve/composable-orchestrator-design
Sep 30, 2026
Merged

Amaury Levé (Evangelink) merged 11 commits into
mainfrom
dev/amauryleve/composable-orchestrator-design

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

  • add an experimental single-invocation middleware boundary around one existing test-host execution orchestrator
  • preserve legacy orchestrator registration, Retry behavior, handshake metadata, and protocol semantics
  • enforce cancellation propagation, single invocation, downstream failure preservation, and drain-before-lifetime-cleanup behavior
  • add localized diagnostics, API baselines, documentation, and focused regression coverage

Scope

This is the first composition increment. It intentionally does not implement typed multi-run Retry, Stress, Sharding, Hot Reload, or protocol metadata composition. Middleware must begin its single next invocation before returning or throwing; it may observe the returned task asynchronously, but cannot defer the call itself.

Validation

  • build.cmd platform and unit-test project builds passed for net8.0, net9.0, netstandard2.0, and net462
  • 34 middleware/orchestrator/API metadata tests passed on net8.0, net9.0, and net462
  • full net8.0 unit suite: 2655 passed, 2 pre-existing Windows named-pipe security failures reproduced on the unmodified baseline
  • three independent architecture/code/API review rounds plus a final post-fix code review completed

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 28, 2026 15:46
@github-actions github-actions Bot added the needs/merge-conflict-resolution PR has merge conflicts that must be resolved. label Sep 28, 2026

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.

Copilot review overview

🟡 Changes recommended

A null task returned by extension code can leave the drain placeholder incomplete and hang execution and lifetime cleanup.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Adds an experimental middleware boundary around a single MTP test-host orchestrator invocation.

Changes:

  • Adds middleware registration APIs and configuration.
  • Implements guarded composition, cancellation propagation, and draining.
  • Adds diagnostics, API baselines, documentation, and regression tests.
File Description
test/​UnitTests/​Microsoft.Testing.Platform.UnitTests/​TestHostOrchestratorManagerTests.cs Tests middleware registration and compatibility.
test/​UnitTests/​Microsoft.Testing.Platform.UnitTests/​TestHostExecutionOrchestratorMiddlewarePipelineTests.cs Tests pipeline semantics and cancellation.
test/​UnitTests/​Microsoft.Testing.Platform.UnitTests/​TestHostExecutionOrchestratorMiddlewareApiMetadataTests.cs Verifies experimental API metadata.
test/​UnitTests/​Microsoft.Testing.Platform.UnitTests/​Hosts/​TestHostOrchestratorHostTests.cs Tests host and lifetime integration.
src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​TestHostOrchestratorManagerExtensions.cs Adds the registration extension method.
src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​TestHostOrchestratorManager.cs Builds registered middleware.
src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​TestHostOrchestratorConfiguration.cs Stores middleware configuration.
src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​TestHostExecutionOrchestratorMiddlewarePipeline.cs Implements the guarded pipeline.
src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​ITestHostExecutionOrchestratorMiddlewareManager.cs Defines the optional manager capability.
src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​ITestHostExecutionOrchestratorMiddleware.cs Defines the middleware contract.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​PlatformResources.resx Adds diagnostic resources.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.cs.xlf Updates Czech localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.de.xlf Updates German localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.es.xlf Updates Spanish localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.fr.xlf Updates French localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.it.xlf Updates Italian localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.ja.xlf Updates Japanese localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.ko.xlf Updates Korean localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.pl.xlf Updates Polish localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.pt-BR.xlf Updates Portuguese localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.ru.xlf Updates Russian localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.tr.xlf Updates Turkish localization catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.zh-Hans.xlf Updates Simplified Chinese catalog.
src/​Platform/​Microsoft.Testing.Platform/​Resources/​xlf/​PlatformResources.zh-Hant.xlf Updates Traditional Chinese catalog.
src/​Platform/​Microsoft.Testing.Platform/​PublicAPI/​PublicAPI.Unshipped.txt Tracks new public APIs.
src/​Platform/​Microsoft.Testing.Platform/​InternalAPI/​InternalAPI.Unshipped.txt Tracks new internal APIs.
src/​Platform/​Microsoft.Testing.Platform/​Hosts/​TestHostOchestratorHost.cs Integrates middleware with host execution.
src/​Platform/​Microsoft.Testing.Platform/​Hosts/​TestHostBuilder.Modes.cs Validates orchestrator composition.
docs/​Changelog-Platform.md Documents the experimental feature.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Sep 28, 2026
@github-actions github-actions Bot added needs/merge-conflict-resolution PR has merge conflicts that must be resolved. and removed needs/merge-conflict-resolution PR has merge conflicts that must be resolved. state/needs-review Awaiting review from the team. labels Sep 28, 2026
…able-orchestrator-design

# Conflicts:
#	docs/Changelog-Platform.md
#	src/Platform/Microsoft.Testing.Platform/PublicAPI/PublicAPI.Unshipped.txt
Copilot AI review requested due to automatic review settings September 29, 2026 07:32
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed needs/merge-conflict-resolution PR has merge conflicts that must be resolved. labels Sep 29, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 29, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 29, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 29, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 29, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Sep 29, 2026

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.

Copilot review overview

🟡 Changes recommended

Two lifecycle paths can hang pipeline cleanup, and API tracking plus concurrency coverage remain incomplete.

Review effort: Balanced
Findings: 2 High severity · 2 Medium severity

Open (4)
Resolved since last review (2)

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Sep 29, 2026
@github-actions github-actions Bot added the state/approved Proposal approved; ready for implementation. label Sep 29, 2026

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.

Copilot review overview

🟡 Changes recommended

Middleware-thrown exceptions currently bypass downstream failure validation and can replace the original fault or cancellation.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Copilot AI review requested due to automatic review settings September 29, 2026 08:24
@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Sep 29, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Sep 29, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Sep 29, 2026
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Sep 29, 2026

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.

Copilot review overview

🔵 Needs a closer look

The pipeline currently accepts a deferred next invocation that the documented single-invocation contract explicitly forbids.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Close next gate before awaiting deferred middleware task

src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​TestHostExecutionOrchestratorMiddlewarePipeline.cs:86

This keeps the next gate open until the middleware task completes, so a middleware such as async (next, ct) => { await Task.Yield(); return await next(ct); } is accepted even though it defers the call until after OrchestrateTestHostExecutionAsync has returned its task. That contradicts the PR/API contract that next must begin synchronously. Capture the middleware task first, close the guard immediately after the call returns (or throws), and only then await that task; add a regression using an initial incomplete await before next.

@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

Copilot review overview

🔵 Needs a closer look

The pipeline currently accepts deferred continuation invocation and can replace downstream cancellation with a wrapper exception.

Review effort: Balanced
Findings: None

Previously missed (1)

In code that hasn't changed since last review

Medium severity Close middleware next-call guard before awaiting async task

src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​TestHostExecutionOrchestratorMiddlewarePipeline.cs:87

The guard stays open for the entire middleware task, so async middleware can await Task.Yield() and invoke next only afterward. That invocation is accepted even though the public contract and PR scope require next to begin before the middleware call returns. Close the guard immediately after obtaining the middleware task (before awaiting it), and add a regression for a deferred next call.

This issue also appears on line 136 of the same file.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Final test-triage resolution — Azure Pipelines build 1615940

Result: one deterministic test failure in the Windows Debug leg, in the "Test (unit tests only)" step. Confidence is medium. The evidence is complete (evidenceIncomplete=false).

Failing test: StartAsyncTimeoutKillsProcessAndReleasesListener [net8.0], in Microsoft.Testing.Platform.ServerMode.Client.Sources.UnitTests (MtpServerProcessTests.cs:79).

  • It failed in both attempts of the leg (Attempt1 and Attempt2), with no passing attempt in between, so it is not proven flaky.
  • The assertion expects the message to contain did not connect back within.
  • The actual message was The Microsoft.Testing.Platform application '...\NeverConnects.cmd' exited with code 0 before connecting back.
  • The stub process exited before the timeout fired, so the "timeout kills process" path was never exercised.

History: the same test passed (about 3.5 s) in the most recent successful branch build, 20260929.29. The other 11 sampled builds have no matching record for it, so the history shows no prior failure of this signature.

Other signals:

  • The Windows_App_Model_Diagnostics record RetryTestMethod_PassesOnSecondAppContainerHost is reported as failed in appcontainer-retry.trx. This is a retry-verification asset that is designed to fail on the first host, and nothing else links it to this build failure. I treated it as non-actionable.
  • There are no crash or hang diagnostics and no slowness regressions.
  • No other test failures were found.

Assessment: this looks like a failure tied to this pull request, or to a Windows-specific behavior of the .cmd stub, rather than a durable defect. No issue was created, because there is no recurrence across independent builds. The pull request changes host and orchestrator code under src/Platform/Microsoft.Testing.Platform/Hosts/, which is plausibly related, but I did not confirm a root cause.

Next step: reproduce locally on Windows with MtpServerProcessTests, and check whether the stub .cmd exits immediately (exit code 0) under the changed host or process startup path. If it does, fix the test or the product code accordingly.

🤖 Automated content by GitHub Copilot. Generated by the Pipeline Test Triage workflow. · copilot · auto · 28.9 AIC · ⌖ 6.17 AIC · ⊞ 9.6K

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.

Copilot review overview

🟡 Changes recommended

The pipeline currently accepts a deferred first next invocation after the middleware method has returned, violating its public contract.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

Copilot review overview

🔵 Needs a closer look

Independent downstream cancellation can be wrapped as a middleware failure instead of being preserved unchanged.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity A genuinely canceled downstream task is wrapped unless the linked token also happens to be…

src/​Platform/​Microsoft.Testing.Platform/​TestHostOrchestrator/​TestHostExecutionOrchestratorMiddlewarePipeline.cs:151

A genuinely canceled downstream task is wrapped unless the linked token also happens to be canceled. For example, if the orchestrator returns Task.FromCanceled<int>(anIndependentCanceledToken) and middleware starts next but returns a failure code, DownstreamTask.IsCanceled is true while EffectiveToken.IsCancellationRequested is false; execution falls into the generic catch and reports InvalidOperationException instead of preserving cancellation as the public contract requires. Include the task's canceled state in this filter and add a regression for independent downstream cancellation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants