Skip to content

Emit shadow Rush lifecycle events - #5991

Open
Sean Larkin (TheLarkInn) wants to merge 1 commit into
copilot/reporter-r3a-session-sinkfrom
copilot/reporter-r3b-shadow-events
Open

Emit shadow Rush lifecycle events#5991
Sean Larkin (TheLarkInn) wants to merge 1 commit into
copilot/reporter-r3a-session-sinkfrom
copilot/reporter-r3b-shadow-events

Conversation

@TheLarkInn

Copy link
Copy Markdown
Member

Part of #5976

Stack parent: #5988

Summary

  • emit root session and command start/completion/result events through the scoped R3A sink boundary
  • adapt phased operation registration/status into stable project x phase identities and emit registered RUSH_OPERATION_FAILED diagnostics without routing raw chunks
  • correlate legacy AlreadyReportedError failures so catch boundaries do not emit duplicate structured diagnostics
  • feed a privacy-gated TelemetrySubscriber projection into existing Rush telemetry while leaving process exit behavior authoritative
  • add the registered RUSH_COMMAND_FAILED diagnostic for representative uncorrelated command failures

Validation

  • rush install
  • rush build --to @microsoft/rush
  • rush test --only @rushstack/rush-reporter --only @microsoft/rush-lib --only @microsoft/rush
  • rush check
  • rush change --verify

No-output guarantee

Legacy terminal rendering and StreamCollator remain the only visible stdout/stderr owners. The shadow sink emits no terminal text, operation chunks are not routed to reporters, and focused tests compare legacy graph output with and without the reporter adapter.

Non-goals

  • reporter selection, defaults, CLI controls, or automatic activation
  • replacing StreamCollator or emitting the R5 raw operation/output stream
  • removing legacy terminal/logger APIs
  • exhaustive parity, watch/retry, and integration matrices reserved for R3C
  • retargeting or merging this child stack before parent branches advance

@TheLarkInn

Copy link
Copy Markdown
Member Author

Independent R3 review against #5976/RFC phase 3: lifecycle/result ordering, phase-aware operation scope, legacy error correlation, telemetry projection, and no-raw-output behavior are correctly isolated while StreamCollator and process exit remain authoritative. The missing exhaustive parity matrix and logical-cancellation derivation are addressed in child #5992 rather than expanding this slice. Stack-only diff is one commit over #5988; no unresolved review threads are present.

@TheLarkInn

Copy link
Copy Markdown
Member Author

Combined deep review of current head e81d5a2508.

  1. HIGH ReporterOperationEventSink.ts:31-59 drops sharded operations that share project and phase identity. Shard failures can disappear from shadow diagnostics and exit derivation. Map every legacy operation name and aggregate shard status.
  2. LOW RushSession.ts:193-198 adds an envelope privacy gate that bypasses the allowlisted non-public diagnostic projection in Harden reporter telemetry privacy projection #5990. After Harden reporter telemetry privacy projection #5990 is hardened, forward all envelopes to the subscriber and keep one authoritative privacy projection.

@TheLarkInn
Sean Larkin (TheLarkInn) force-pushed the copilot/reporter-r3b-shadow-events branch from e81d5a2 to 8255a72 Compare August 28, 2026 16:32
@TheLarkInn

Copy link
Copy Markdown
Member Author

Rebased the single R3B commit onto #5988 head 07f17e4c7f and force-pushed 8255a72716.

Fixed sharded-operation-collapse: pre-shard, every shard, and collator now map to one project x phase identity. Status is aggregated per iteration, a shard failure emits one correlated diagnostic, telemetry retains the aggregate failure, and retry/watch registrations keep the same identity. R3B still exposes no raw chunk callback and legacy output remains authoritative. Also memoized reporter close after resolving the parent rebase.

Validation: build through @microsoft/rush; reporter, rush-lib, and apps/rush tests; API Extractor; rush check; rush change --verify --no-fetch; slice is one commit over 07f17e4c7f.

Low follow-on: keep the outer telemetry privacy gate until #5990 reaches shared main. Then remove it and forward all envelopes to the hardened subscriber.

@TheLarkInn

Copy link
Copy Markdown
Member Author

Four-review rerun on 8255a72716 confirms the sharded-operation fix. One MEDIUM issue remains: a failed watch iteration can permanently latch derived exit failure even after the final iteration and command lifecycle succeed. Derived status can disagree with the authoritative final exit.

Required fix: make final command or session completion, or current-iteration outcomes, establish the recovered success result. Add a fail-then-success watch test.

Dismissible low follow-ons: reset group silent state between watch iterations, and remove the outer telemetry privacy gate after #5990 reaches shared ancestry.

@TheLarkInn
Sean Larkin (TheLarkInn) force-pushed the copilot/reporter-r3b-shadow-events branch from 8255a72 to 2f9ac7d Compare August 28, 2026 17:02
@TheLarkInn

Copy link
Copy Markdown
Member Author

Round two fixed at 2f9ac7d90e.

Derived exit now follows current operation outcomes and authoritative root commandResult, commandCompleted, and sessionCompleted events. A fail-then-success watch sequence now resolves to exit 0, while an active failed iteration still resolves to exit 1. Grouped silence is recomputed after all registrations each iteration, so a group disabled after being active emits no new shadow registration or status.

Validation passed: build through @microsoft/rush; reporter, rush-lib, and apps/rush tests; API Extractor; rush check; rush change --verify --no-fetch; one-commit slice over 07f17e4c7f. The outer telemetry privacy gate remains deferred until #5990 is available in shared ancestry.

@TheLarkInn

Copy link
Copy Markdown
Member Author

Final combined review of 2f9ac7d90e found no critical, high, or medium actionable issue. Sharded aggregation, watch recovery, grouped silence, diagnostics, telemetry status, and derived exit parity are fixed.

One intentional low follow-on remains: remove the outer telemetry privacy gate after #5990 reaches shared ancestry. This head is low-only.

@TheLarkInn
Sean Larkin (TheLarkInn) force-pushed the copilot/reporter-r3b-shadow-events branch from 52f751f to 58cd2a3 Compare September 3, 2026 18:43
@TheLarkInn
Sean Larkin (TheLarkInn) force-pushed the copilot/reporter-r3b-shadow-events branch from 58cd2a3 to 14ab214 Compare September 3, 2026 20:01
@TheLarkInn
Sean Larkin (TheLarkInn) force-pushed the copilot/reporter-r3b-shadow-events branch 2 times, most recently from 2a6a582 to 6b2b758 Compare September 3, 2026 20:15
@TheLarkInn

Copy link
Copy Markdown
Member Author

Deep review of current head 3541683 found no critical, high, or medium actionable issues. Failure lifecycle output now matches the normalized process exit, and overlapping pre-iteration cycles remain isolated. Merge remains gated by #5988 and maintainer approval.

@TheLarkInn Sean Larkin (TheLarkInn) left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

R3 lifecycle acceptance review against #5976: early failure and finalization outcomes must agree with authoritative native exit behavior.

Comment thread libraries/rush-lib/src/cli/RushCommandLineParser.ts Outdated
Comment thread libraries/rush-lib/src/cli/RushCommandLineParser.ts Outdated
@TheLarkInn
Sean Larkin (TheLarkInn) force-pushed the copilot/reporter-r3b-shadow-events branch from f7909be to f439cc6 Compare September 9, 2026 16:03
Preserve published early-failure, late-telemetry and operation-callback corrections; reconcile native lifecycle fields and telemetry references, with real branded parser regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4747f826-8c83-495d-80df-3d1168662e10

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

Registration ordering, parser-failure diagnostics, and correlation of non-extensible errors need correction.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 2 Medium severity

New issues introduced by this change (3)
Severity Finding
High severity libraries/​rush-lib/​src/​pluginFramework/​RushSession.ts — Correlation is invoked for arbitrary caught errors, but LegacyErrorBridge.correlate() adds a…
Medium severity libraries/​rush-lib/​src/​cli/​RushCommandLineParser.ts — A command-line parse/selection failure is swallowed by CommandLineParser.executeAsync() and…
Medium severity libraries/​rush-lib/​src/​logic/​operations/​OperationGraph.tsonOperationRegistered runs before hooks.configureIteration, but the standard…
What changed in this PR

Adds shadow-mode Rush lifecycle, operation, diagnostic, and telemetry reporting without changing legacy terminal output.

Changes:

  • Emits session/command lifecycle events and structured failure diagnostics.
  • Projects phase-aware operation statuses into reporter telemetry.
  • Adds tests for ordering, privacy, output parity, and reporter shutdown.
File Description
specs/​2026-07-12-rush-reporter-overhaul.md Documents lifecycle ordering.
libraries/​rush-lib/​src/​pluginFramework/​RushSession.ts Adds shadow event observation and correlation.
libraries/​rush-lib/​src/​pluginFramework/​RushSession.test.ts Tests shadow reporting and privacy.
libraries/​rush-lib/​src/​logic/​test/​Telemetry.test.ts Tests telemetry projection.
libraries/​rush-lib/​src/​logic/​Telemetry.ts Adds reporter data to telemetry.
libraries/​rush-lib/​src/​logic/​operations/​test/​OperationGraphEventSink.test.ts Tests operation event aggregation.
libraries/​rush-lib/​src/​logic/​operations/​ReporterOperationEventSink.ts Adapts graph events to reporter events.
libraries/​rush-lib/​src/​logic/​operations/​OperationGraph.ts Supplies execution records to sinks.
libraries/​rush-lib/​src/​logic/​operations/​OperationEventSink.ts Extends registration callback contract.
libraries/​rush-lib/​src/​cli/​test/​TestUtils.ts Supports reporter-enabled parser tests.
libraries/​rush-lib/​src/​cli/​test/​RushCommandLineParserReporterLifecycle.test.ts Tests lifecycle and failure ordering.
libraries/​rush-lib/​src/​cli/​test/​RushCommandLineParserReporterClose.test.ts Tests reporter finalization.
libraries/​rush-lib/​src/​cli/​test/​RushCommandLineParser.test.ts Tests end-to-end shadow events.
libraries/​rush-lib/​src/​cli/​scriptActions/​PhasedScriptAction.ts Attaches operation reporting.
libraries/​rush-lib/​src/​cli/​RushCommandLineParser.ts Emits command/session lifecycle events.
libraries/​reporter/​src/​diagnostics/​templates/​operation.ts Adds command-failure text.
libraries/​reporter/​src/​diagnostics/​RushDiagnosticCodeRegistry.ts Registers command-failure diagnostics.
common/​reviews/​api/​rush-reporter.api.md Updates reporter API report.
common/​reviews/​api/​rush-lib.api.md Updates Rush library API report.
common/​changes/​@rushstack/​rush-reporter/​copilot-reporter-r3b-shadow-events_2026-08-28-04-20.json Records reporter patch.
common/​changes/​@microsoft/​rush/​reporter-foundation-lifecycle_2026-09-09.json Records lifecycle patch.
common/​changes/​@microsoft/​rush/​copilot-reporter-r3b-shadow-events_2026-08-28-04-20.json Records shadow-event patch.

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

Comment on lines +269 to +271
correlateError(error: unknown, diagnosticId: string): void {
legacyErrorBridge.correlate(error, diagnosticId);
},
Comment on lines +289 to +292
const succeeded: boolean = await super.executeAsync(args);
if (!this.#reporterCompletionEmitted) {
this._emitReporterCompletion(succeeded ? 0 : _getNumericProcessExitCode(1));
}

executionRecords.set(operation, executionRecord);
eventSink?.onOperationRegistered?.(executionRecord.name, executionRecord.silent);
eventSink?.onOperationRegistered?.(executionRecord.name, executionRecord.silent, executionRecord);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants