Skip to content

docs: design W365 pool discovery and persistent routing - #1873

Open
tbyfield wants to merge 10 commits into
mainfrom
users/tbyfield/w365-discovery-design
Open

tbyfield wants to merge 10 commits into
mainfrom
users/tbyfield/w365-discovery-design

Conversation

@tbyfield

@tbyfield tbyfield commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Proposes W365 pool discovery and persistent nonsecret routing, extending the existing backend design without repeating it.

  • Make development-contract poolId optional: discover assigned pools when omitted, or target the explicitly supplied pool.
  • Save validated service URLs for lifecycle calls from fresh processes, with explicit allocation and cleanup recovery behavior.
  • Document the request-contract change in api.md; SDK signatures and published contracts remain unchanged.

Documentation only. Authentication/token management, other backends and the original #1615 documents are unchanged. Status remains Proposed; maintainer acceptance and design approval are pending.

🔗 References

Refs #1821. Builds on #1615.

🔍 Validation

  • git diff --check origin/main...HEAD — passed.
  • Template headings/checklists and relative links/anchors — verified.
  • Runtime tests not run: documentation-only proposal. The design identifies existing native, Node and .NET fixtures to extend during implementation.

✅ Checklist

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • For implementation: linked the required approved and merged design/API spec, or explained why no spec is required
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 22:51
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
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.

🟡 Changes recommended

The design requires previously optional userObjectId and adds nil-GUID rejection without clearly scoping the compatibility impact or aligning the API documentation and fixture plan.

1 open issue
What changed in this PR

Proposes pool discovery and persistent nonsecret routing for the experimental W365 backend, extending #1615 to address #1821. This is a documentation-only proposal; implementation and maintainer approval remain pending.

Changes:

  • Define discovery when poolId is omitted and direct targeting when supplied.
  • Specify saved routing for fresh-process lifecycle calls, including storage security and allocation/release recovery.
  • Describe the development-contract change and planned validation without changing published contracts or SDK signatures.
File Description
docs/​development/​architecture/​designs/​1821-w365-discovery-routing/​README.md Defines discovery, routing persistence, recovery, and validation plans.
docs/​development/​architecture/​designs/​1821-w365-discovery-routing/​api.md Documents optional pool selection, request examples, and compatibility expectations.

Review effort: Balanced

Comment on lines +27 to +28
Provision accepts an optional `w365Agents.provision.poolId`; explicit null, empty, malformed or nil GUIDs remain rejected.
`userObjectId` remains required and non-nil under existing backend validation. An explicit pool is fetched directly and never replaced.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 23:02

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

W365 service-owner review is needed to confirm Graph discovery, credential-routing, and allocation/release recovery guarantees that existing loopback fixtures cannot establish.

1 open issue

Review effort: Balanced

@tbyfield
tbyfield marked this pull request as ready for review December 2, 2026 18:02
@tbyfield
tbyfield requested a review from a team December 2, 2026 18:02
@tbyfield
tbyfield requested a review from a team as a code owner December 2, 2026 18:02
@bbonaby Branden Bonaby (bbonaby) added the Feature-Spec-In-Review Label for feature spec PRs that are currently in review label Dec 2, 2026

@bbonaby Branden Bonaby (bbonaby) 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.

thanks!

@bbonaby

Copy link
Copy Markdown
Collaborator

CC: Gudge (@MGudgin) to also take a look

@MGudgin Gudge (MGudgin) 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.

Summary

Reviewed the two new W365 discovery/routing design documents against the existing #1615 design, W365 clients, native/Node/.NET fixtures and the proposed validation plan at 410f90c95ce9302c32ff7575b1cdd005253909e0.

Requesting changes on two design blockers: preserve CP recovery routing whenever an unsuccessful checkout returns a valid session ID, and define the operation-specific request targets derived from the returned full service URLs. The other ten inline findings are Medium design/validation-plan issues. These are proposed-behavior findings, not claims of reproduced implementation failures or requests to complete implementation in this spec PR.

Verified scope and validation

  • The pinned merge-base/head diff adds exactly the two design documents; it changes no published schema, SDK declaration, manifest, backend implementation or CI gate. The disclosed experimental request restrictions are not classified here as published SDK source/binary breaks.
  • git diff --check 40eebd39ab5e5a02d350169a8c96c28b33ddba7e..410f90c95ce9302c32ff7575b1cdd005253909e0 passed.
  • Runtime tests were not run for this documentation-only proposal. Fixture references in the inline comments are source-inspection evidence, not execution results.

Verified pre-existing - not attributed to this PR

The existing W365 service.rs, data_plane.rs, exec/transport.rs, native w365_lifecycle.rs, Node w365-fixture.ts, .NET MxcLifecycleW365Tests.cs and original #1615 README are byte-identical across the pinned range. They are supporting context, not independent pre-existing findings. The native fixture has four #[test] declarations on both sides. Comments about new fixture seams concern the proposal's validation design, not missing implementation in those unchanged files.


W365 owns the remote reservation; the caller retains release responsibility.
The routing cache neither owns the reservation nor proves remote status/readiness.
After allocation, invalid DP metadata must preserve the allocated ID and CP-only recovery routing for release.

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.

High (correctness) - Finding 1: Preserve CP-only routing for every failed checkout with a cleanup ID.

Attribution: introduced_by_change - requiring a saved record adds a new prerequisite for the existing known-session cleanup path.

The recovery rule explicitly covers invalid DP metadata, but checkout can also return HTTP 408 or 500 with a valid session ID. The existing src/mxc-sdk/tests/w365_lifecycle.rs:1067-1101 scenarios retain that ID and release it. With the new mandatory routing lookup, reporting the ID without saving its CP route makes fresh-process deprovision fail before DELETE, even when storage is healthy. This is separate from the documented case where saving any record itself fails.

Fix: Require CP-only routing whenever an unsuccessful checkout returns a valid cleanup ID, not only after invalid DP metadata. Extend the existing 408/500 scenarios to verify release from a fresh process.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 097f420: any failed checkout returning a valid cleanup ID must save CP-only recovery routing, including 408/500. The fixture plan now requires fresh-process deprovision for those cases and explicit combined errors if recovery persistence fails.


Modes and call order remain as in [#1615](../1615-w365a-backend/README.md#execution-and-container-lifecycle-support).
Provision saves routing; fresh-process start/exec/stop/deprovision load it without
Graph or endpoint variables. Full URLs drive readiness/exec requests. Stop and

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.

High (correctness) - Finding 2: Define how full service URLs become operation targets.

Attribution: introduced_by_change - full service URLs replace hostname inputs, but their operation-specific interpretation is not defined.

The existing client uses distinct targets: checkout /api/pools/{poolId}/sessions?api-version=3.0, readiness /computers/{sessionId}/status?api-version=1.0, and exec /computers/{sessionId}/microsoft.exec?api-version=1.0 (service.rs:180-190, data_plane.rs:98-107, exec/transport.rs:350-355 under src/mxc-sdk/src/backends/w365agents/). The proposal defines authority-only release, but not whether poolUrl/computerUrl are bases, resource URLs or complete endpoints. Replacing a non-root path can discard routing; appending the existing target can duplicate resource segments, and existing queries need defined API-version handling.

Fix: Specify the resulting target for checkout, readiness and exec, with a worked non-root-path/query example and exact fixture assertions. This is a service-contract decision, not a choice of URL library.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 991dabf. The spec now defines poolUrl as the full checkout endpoint and computerUrl as the computer resource, with resulting request URL examples, query preservation and explicit API-version rules. Release retains its existing authority-based API 2.0 target. Added exact target assertions to the fixture plan.

containing the service-provided full CP URL and validated checkout `computerUrl`, never credentials or responses.

Use locks, atomic writes, owner/link checks and exact identity/destination validation.
Validate HTTPS destinations and reject embedded credentials, authentication query parameters and fragments.

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.

Medium (security) - Finding 3: Define which destinations may receive each bearer token.

Attribution: introduced_by_change - service-returned and saved URLs replace caller-supplied destination hostnames.

HTTPS, absence of userinfo/fragments and exact record consistency do not establish which hosts are trusted to receive W365A_CP_TOKEN or W365A_DP_TOKEN. An unexpected out-of-service HTTPS URL can satisfy the stated format checks. The inherited #1615 rule against unrelated-origin credential forwarding expresses the intent, but its trust anchor is unspecified once caller-supplied host routing is removed.

Fix: Define trusted service origins/domain rules per token and environment, and require validation on receipt and on every record load before attaching credentials. CP and DP need not share an origin. Identify which inherited service-returned-URL restriction this proposal supersedes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Clarified in d90c09e: the fixed Graph origin is the trust anchor for the matching pool's URL; that checkout service supplies the computer URL. MXC performs local HTTPS/443, DNS-host, credentials/query and fragment checks rather than inventing a service-host allowlist. Protected records preserve that trust, with ownership/link, identity and URL checks repeated before attaching credentials. Redirects are prohibited and Graph pagination stays on the selected origin. The spec explicitly identifies the inherited service-returned-URL restriction being superseded.

failover only, and no second checkout after uncertainty or persistence failure.
- Fresh-process lifecycle: assert saved full paths/queries are used, no Graph or
endpoint settings are needed, output/exit results are preserved and release uses API 2.0.
- Invalid DP metadata, storage corruption/conflict, ownership/link violations and

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.

Medium (security) - Finding 4: Assert that rejected destinations receive no bearer token.

Attribution: introduced_by_change - the new returned/persisted-URL credential path needs explicit negative destination assertions.

The plan checks successful path/query preservation and storage failures, but does not explicitly require zero credential forwarding for rejected HTTP URLs, userinfo, fragments, authentication query parameters or destinations outside the trust policy. Ownership/corruption checks alone do not prove this; a well-formed record can name an unacceptable destination.

Fix: Extend the loopback fixtures with both response-sourced and stored-URL rejection cases. Assert an explicit error and zero token-bearing requests to the rejected destination, retaining the already-planned conflicting-destination checks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in 82694a2: response-sourced and stored invalid URLs must fail explicitly with zero token-bearing requests to the rejected destination. The plan also covers redirects and cross-origin Graph pagination. An unfamiliar hostname alone is not rejected: the agreed trust policy relies on Graph/checkout provenance plus local URL safety checks, not a guessed hostname allowlist.

without checkout. Missing/malformed metadata fails. Read authoritative `poolUrl`
from the matching pool resource, never endpoint variables or region reconstruction.

Try another pool only after a definitive non-408 HTTP 4xx checkout rejection, with no allocation and `possiblySucceeded=false`.

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.

Medium (reliability, performance) - Finding 5: Bound discovery and classify failover rejections.

Attribution: introduced_by_change - the new sequential candidate loop expands the prior single-pool checkout operation.

A definitive non-408 4xx includes 401/403 credential failures and 429 throttling. The proposal does not distinguish operation-wide authentication/throttling failures from candidate-specific rejection or define Retry-After handling. It also supplies no overall Graph/discovery/failover budget. The existing 45-second timeout is per checkout (src/mxc-sdk/src/backends/w365agents/service.rs:11,184), so total work and latency can scale with every assigned pool.

Fix: Define which responses permit another candidate, how authentication and throttling terminate or delay selection, and a total discovery/failover budget. Add corresponding failure and exhaustion cases. Preserve the existing no-allocation and no-replay conditions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 8ef4d5e. Selection has a shared 120-second deadline, with 30 seconds for listing across pages, 30 per detail fetch and 45 per checkout, all capped by remaining time. Checkout 401/403 may permit another candidate only with no cleanup identity and possiblySucceeded=false; they need not apply to every pool. A 429 stops selection and surfaces Retry-After without automatic sleep/retry. Graph failures, 408/5xx and uncertain allocations stop selection. The fixture plan covers budget exhaustion, per-pool diagnostics and recovery persistence at deadline expiry.


Extend `w365_lifecycle` (including `lifecycle_contract_and_recovery_fixture` and Windows `lifecycle_fresh_executor_fixture`),
Node `w365-fixture.ts` and .NET `MxcLifecycleW365Tests.cs`.
Use existing loopback TLS fixtures and isolated `test-support` builds on supported Windows/Linux/macOS hosts with OpenSSL.

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.

Medium (testability) - Finding 8: Plan an offline Graph transport seam.

Attribution: introduced_by_change - the proposed Graph list/fetch stages must be driven through the offline validation infrastructure.

The current fixture transport uses MXC_W365_TEST_CA/MXC_W365_TEST_PORT and allows a non-443 test port only for localhost (src/mxc-sdk/src/backends/w365agents/service.rs:149). Public/canary selection alone does not provide a local Graph origin. The plan needs to identify how new Graph requests reach the deterministic listener rather than live Graph.

Fix: State that a test-support-only Graph origin/adapter will be added, without weakening production endpoint restrictions. Require list/direct-fetch method, path, environment-prefix and checkout-order assertions. This asks for a validation-design seam, not implementation in this documentation PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in bf9f908: a test-support-only loopback Graph transport override with fixture CA validation. Shipping builds ignore it and keep the fixed Graph origins. The fixture plan requires list/pagination/direct-detail methods, paths, public/Canary prefixes and checkout-order assertions without live Graph calls.

## Design and security

Keep discovery, checkout and storage in existing W365 backend modules in `mxc-sdk`; no new crate or broad refactor.
Preflight storage before discovery. Save versioned, bounded per-user records keyed by canonical `w365:{poolId}:{sessionId}`,

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.

Medium (testability) - Finding 9: Isolate fixture routing storage across processes.

Attribution: introduced_by_change - persistent profile records and no-overwrite/conflict rules add shared state to fixtures that reuse fixed identities.

The existing native, Node and .NET fixtures reuse the same pool/session IDs and isolate only their existing environment keys (w365_lifecycle.rs:308-323, sdk/node/tests/integration/w365-fixture.ts:35-37, sdk/dotnet/Microsoft.Mxc.Sdk.Tests/V1/MxcLifecycleW365Tests.cs:255-257). A process-local mutex does not isolate a profile store across suites or fresh executors. Separate test-support builds also do not isolate that filesystem state.

Fix: Plan a temporary root per scenario that child executors inherit, with targeted cleanup. Specify suitable-host coverage for actual owner/link checks; a stored-identity mismatch is not a substitute for OS-owner validation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in bf9f908: each native/Node/.NET scenario gets a private temporary routing root inherited by child processes, with targeted cleanup. The plan explicitly calls for actual Unix owner/symlink and Windows owner/ACL/reparse-point checks rather than treating JSON identity mismatches as OS-owner coverage.

W365 owns the remote reservation; the caller retains release responsibility.
The routing cache neither owns the reservation nor proves remote status/readiness.
After allocation, invalid DP metadata must preserve the allocated ID and CP-only recovery routing for release.
Persistence failure reports the allocated identity, CP destination and cleanup context, never success or a second checkout.

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.

Medium (testability) - Finding 10: Make post-checkout persistence failure deterministic.

Attribution: introduced_by_change - the new recovery contract requires failure after allocation, separately from storage preflight rejection.

An unwritable root fails the proposed preflight before checkout. The existing HTTP reply queue can force service errors but cannot deterministically fail the subsequent atomic write after checkout succeeds. Racing permission changes is not a reliable Windows/Linux/macOS acceptance scenario.

Fix: Plan a test-support fault at the post-checkout persistence boundary. Assert one checkout, allocated ID/CP cleanup context in the error, no replay and no fabricated usable record. Use deterministic synchronization if process exit at this boundary is tested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in bf9f908: a test-only fault at post-checkout atomic publication, distinct from preflight failure. The planned assertions require exactly one checkout, allocated ID and CP cleanup context in the error, no replay and no fabricated usable record. An unwritable root alone is explicitly identified as only a preflight test.


## Acceptance criteria and validation plan

Extend `w365_lifecycle` (including `lifecycle_contract_and_recovery_fixture` and Windows `lifecycle_fresh_executor_fixture`),

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.

Medium (test coverage) - Finding 11: Include Unix fresh-process routing validation.

Attribution: introduced_by_change - fresh-process saved routing is proposed for all supported hosts, but the identified subprocess fixture is Windows-only.

lifecycle_fresh_executor_fixture is gated by #[cfg(windows)] (src/mxc-sdk/tests/w365_lifecycle.rs:1211-1214). The existing Node/.NET lifecycle fixtures stay in one process. Extending only these named scenarios leaves Unix fresh-process record lookup and filesystem behavior unvalidated in the proposed persisted-routing workflow.

Fix: Name a Unix subprocess scenario or equivalent Linux/macOS harness and the CI lanes that run it. Require provision followed by fresh-process start, exec and cleanup without Graph or endpoint settings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in bf9f908: proposed lifecycle_fresh_sdk_process_fixture in w365_lifecycle, using a native SDK subprocess helper on Linux/macOS for separate provision/start/exec/deprovision processes sharing isolated storage. The plan requires helper build, test discovery and execution in Build.Linux.Job.yml and Build.MacOS.Job.yml, which scheduled validation reuses. Windows executor coverage remains; this does not add lifecycle operations to Unix executors.

The [validation runbook](../../../build-and-test/ci-validation-infrastructure.md#offline-tls-fixtures)
describes build/SDK jobs; `Validation.Tests.Scheduled.yml` reuses native build jobs.

- Omitted/explicit pool: assert list order/direct fetch, null/invalid rejection,

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.

Medium (test coverage) - Finding 12: Cover the new Graph configuration/error contract.

Attribution: introduced_by_change - mandatory Graph credentials and public/canary selection add caller-visible provisioning failures.

The acceptance list covers pool selection and malformed metadata, but does not explicitly cover missing Graph credentials, unsupported environment values or service-rejected Graph credentials.

Fix: Add local rejection before discovery for missing/local-invalid configuration and unsupported environments. For a supplied token rejected by Graph, assert an explicit auth error and no checkout. A syntactically valid but expired token may require a Graph request to diagnose, so zero Graph requests is not required in that case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in bf9f908: missing/local-invalid credentials and unsupported environments must fail before Graph or checkout. Credentials rejected by Graph must produce an explicit authentication failure with no checkout; the plan allows the Graph request needed to detect that rejection.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author. label Dec 4, 2026
tbyfield and others added 8 commits December 4, 2026 14:35
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:36
@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs-Attention Requires attention or a decision from the MXC maintainers. and removed Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author. labels Dec 4, 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.

🔵 Needs a closer look

Service-owner and maintainer review is needed to confirm URL semantics, bearer-token destination trust, and experimental compatibility restrictions that offline fixtures cannot validate against deployed services.

1 open issue

Review effort: Balanced

This branch has not been deployed

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

Labels

Feature-Spec-In-Review Label for feature spec PRs that are currently in review Needs-Attention Requires attention or a decision from the MXC maintainers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants