Skip to content

[rush-daemon][WS2][9/9] Wire host request lifecycle - #5973

Merged
Mo Jazayeri (mojaza) merged 3 commits into
mainfrom
mojazayeri-microsoft-rushd-ws2-host-requests-upstream
Aug 28, 2026
Merged

[rush-daemon][WS2][9/9] Wire host request lifecycle#5973
Mo Jazayeri (mojaza) merged 3 commits into
mainfrom
mojazayeri-microsoft-rushd-ws2-host-requests-upstream

Conversation

@mojaza

Copy link
Copy Markdown
Contributor

Summary

Migrates the final WS2 layer 9/9 into microsoft/rushstack as a dependent human-review draft, wiring validated host/control-session request lifecycles through the real daemon protocol and transport while preserving one shared warm-workspace scheduler, dispatcher, and phased-build coordinator across connections.

Depends on #5972. Supersedes mojaza#9. Follows merged #5949 and references #5897 without closing it. No PBI is assigned to this integration-only layer.

Draft for explicit human review; do not merge without maintainer approval. Do not enable auto-merge.

Details

  • Adds validated request start/envelope, cancellation, queue progress, raw-mode control/acknowledgement, typed rejection/fallback, and exact-once final result controls.
  • Injects a resolver/dispatcher boundary that maps validated wire envelopes to the existing phased or global request contracts without copying Rush CLI parser internals.
  • Makes RushDaemonHost own one warm-workspace dispatcher so separate control connections share admission scheduling and phased-build coordination.
  • Extends DaemonControlSession with request identity/state validation, request-tagged stdin, ordered backpressured output/events/results, explicit/disconnect cancellation, and deterministic cleanup.
  • Fails closed with a typed workspace-recreation-required outcome rather than acknowledging invalidations or running a stale graph.
  • Adds real DaemonFrameListener end-to-end coverage for global and phased execution, warm no-op requests, shared builds across clients, admission/cancellation, interactive I/O, malformed state, graph recreation, disconnect cleanup, and host shutdown.
  • Keeps the standalone executable dead-code-safe: without injected request integration it still starts, answers ping, and rejects execution honestly as unsupported.

Limitations

#5895 remains open and still blocks command-independent plugin/phase graph construction and complete per-iteration runner lifetime. This layer consumes an integration-owned real graph/request seam; it does not duplicate PhasedScriptAction, load fake plugins, or construct a fake or empty graph.

Warm-session recreation/reload remains WS3 work. Rush CLI parsing, launcher cutover, configuration, and consumption of the typed requiresInProcess fallback remain WS4 work. Each control connection runs one active request at a time so binary operation output remains unambiguous; concurrent requests use separate connections while still sharing host scheduling and batching.

How it was tested

  • node common/scripts/install-run-rush.js test --only @rushstack/rush-daemon-protocol --only @rushstack/rush-daemon-transport --only @rushstack/rush-daemon
  • node common/scripts/install-run-rush.js test --only @rushstack/rush-daemon
  • API Extractor reports regenerated and verified for all three packages
  • node common/scripts/install-run-rush.js check
  • node common/scripts/install-run-rush.js change --verify
  • git diff --check and source-to-upstream range/file-list parity 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.

Pull request overview

Wires validated request lifecycles through the Rush daemon’s shared workspace session and transport.

Changes:

  • Adds protocol contracts and validation for request execution, cancellation, rejection, and results.
  • Introduces shared host dispatching, interactive I/O, cancellation, and shutdown handling.
  • Adds end-to-end global and phased request coverage.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rigs/local-node-rig/profiles/default/config/jest.config.json Updates test discovery pattern.
libraries/rush-daemon/src/test/DaemonRequestWireTestUtilities.ts Adds wire-test client utilities.
libraries/rush-daemon/src/test/DaemonRequestWirePhased.test.ts Tests phased wire execution.
libraries/rush-daemon/src/test/DaemonRequestWireGlobal.test.ts Tests global wire execution.
libraries/rush-daemon/src/RushDaemonHost.ts Shares and disposes the dispatcher.
libraries/rush-daemon/src/InteractiveRequestInputRouter.ts Changes completed-ID retention.
libraries/rush-daemon/src/index.ts Exports dispatcher APIs.
libraries/rush-daemon/src/DaemonWireRequestClient.ts Serializes request-scoped wire output.
libraries/rush-daemon/src/DaemonRequestDispatcher.ts Resolves and routes wire requests.
libraries/rush-daemon/src/DaemonControlSession.ts Implements request lifecycle state.
libraries/rush-daemon/README.md Documents host request routing.
libraries/rush-daemon-transport/src/DaemonFrameConnection.ts Adds abortive connection shutdown.
libraries/rush-daemon-protocol/src/test/RequestResultValidation.test.ts Tests result validation.
libraries/rush-daemon-protocol/src/test/RequestLifecycle.test.ts Tests lifecycle controls.
libraries/rush-daemon-protocol/src/test/RequestEnvelopeBounds.test.ts Tests envelope bounds.
libraries/rush-daemon-protocol/src/RequestResultValidation.ts Validates result fields.
libraries/rush-daemon-protocol/src/RequestLifecycleCapabilityValidation.ts Validates lifecycle capability.
libraries/rush-daemon-protocol/src/RequestIdentifierValidation.ts Validates request identifiers.
libraries/rush-daemon-protocol/src/RequestEnvelopeValidation.ts Validates envelope options.
libraries/rush-daemon-protocol/src/RequestControlValidation.ts Validates lifecycle messages.
libraries/rush-daemon-protocol/src/index.ts Exports lifecycle contracts.
libraries/rush-daemon-protocol/src/DaemonVerbosityFilter.ts Uses shared record validation.
libraries/rush-daemon-protocol/src/DaemonRequestEnvelope.ts Defines request envelopes.
libraries/rush-daemon-protocol/src/DaemonRequestControl.ts Defines lifecycle controls.
libraries/rush-daemon-protocol/src/DaemonProtocolVersion.ts Introduces protocol minor 5.
libraries/rush-daemon-protocol/src/DaemonEventValidation.ts Uses shared record validation.
libraries/rush-daemon-protocol/src/DaemonControlMessage.ts Extends the control-message union.
libraries/rush-daemon-protocol/src/DaemonControlKinds.ts Registers lifecycle message kinds.
libraries/rush-daemon-protocol/src/DaemonClientCaps.ts Adds lifecycle negotiation.
libraries/rush-daemon-protocol/src/ControlRecord.ts Extracts record detection.
libraries/rush-daemon-protocol/src/ControlMessageValidation.ts Dispatches lifecycle validators.
libraries/rush-daemon-protocol/README.md Documents lifecycle contracts.
common/reviews/api/rush-daemon.api.md Records daemon API changes.
common/reviews/api/rush-daemon-transport.api.md Records transport API changes.
common/reviews/api/rush-daemon-protocol.api.md Records protocol API changes.
common/changes/@rushstack/rush-daemon/mojazayeri-wire-host-requests_2026-08-22-09-30.json Adds daemon changelog entry.
common/changes/@rushstack/rush-daemon-transport/mojazayeri-wire-host-requests_2026-08-22-09-30.json Adds transport changelog entry.
common/changes/@rushstack/rush-daemon-protocol/mojazayeri-wire-host-requests_2026-08-22-09-30.json Adds protocol changelog entry.
Suppressed comments (2)

libraries/rush-daemon/src/DaemonControlSession.ts:293

  • If requestCancel arrives while resolveRequestAsync() is still pending, a cooperative resolver will reject with the abort reason. That reaches this branch as an ordinary error and is emitted as requestRejected/routingFailed, so cancellation has the wrong terminal outcome instead of the standard aborted requestResult. Add an abort-specific completion path (while preserving genuine cleanup failures) and cover cancellation of a deferred resolver.
    if (dispatchError !== undefined && !state.client.terminalOutcomeSent && !this.#connectionClosed) {
      const rejection: IClassifiedRejection = classifyRejection(dispatchError);
      await state.client.writeRejectionAsync(rejection.code, rejection.message);

libraries/rush-daemon/src/DaemonControlSession.ts:301

  • Every completed or rejected request ID is retained for the lifetime of the connection, and this PR also removes the corresponding 256-entry cap from InteractiveRequestInputRouter. Because a connection can execute unlimited sequential requests—or flood distinct rejected starts while one request is active—both sets can grow without bound. Add a bounded connection lifetime/request-count policy (closing before IDs are evicted) or another bounded uniqueness strategy.
  #completeRequest(requestId: string, state: IRequestState): void {
    if (this.#requestById.get(requestId) !== state) return;
    this.#requestById.delete(requestId);
    this.#completedRequestIds.add(requestId);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread libraries/rush-daemon/src/DaemonRequestDispatcher.ts
Comment thread libraries/rush-daemon/src/DaemonControlSession.ts
Comment thread libraries/rush-daemon/src/InteractiveRequestInputRouter.ts Outdated
@mojaza
Mo Jazayeri (mojaza) force-pushed the mojazayeri-microsoft-rushd-ws2-host-requests-upstream branch from 4e7bd6e to cc1c8a2 Compare August 27, 2026 23:33
Base automatically changed from mojazayeri-microsoft-rushd-ws2-shared-build-merge-upstream to main August 28, 2026 00:22
mojazayeri and others added 3 commits August 27, 2026 17:22
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>
@mojaza
Mo Jazayeri (mojaza) force-pushed the mojazayeri-microsoft-rushd-ws2-host-requests-upstream branch from cc1c8a2 to 2d9e070 Compare August 28, 2026 00:22
@mojaza
Mo Jazayeri (mojaza) merged commit a88b242 into main Aug 28, 2026
10 checks passed
@mojaza
Mo Jazayeri (mojaza) deleted the mojazayeri-microsoft-rushd-ws2-host-requests-upstream branch August 28, 2026 03:13
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

4 participants