Skip to content

Complete stable telemetry runtime and lifecycle integration - #820

Merged
RamonArjona4 merged 30 commits into
mainfrom
user/ramonarjona4/telemetry-03-runtime
Sep 4, 2026
Merged

Complete stable telemetry runtime and lifecycle integration#820
RamonArjona4 merged 30 commits into
mainfrom
user/ramonarjona4/telemetry-03-runtime

Conversation

@RamonArjona4

@RamonArjona4RamonArjona4 commented Aug 12, 2026

Copy link
Copy Markdown
Member

Summary

Completes stable telemetry runtime and lifecycle integration across MXC:

  • Promotes telemetry from an experimental field to the stable 0.9 configuration contract.
  • Updates wire models, exact-version contracts, adapters, generated schemas, and Node types.
  • Connects telemetry to the execution engine and all three executors: Windows, Linux, and macOS.
  • Covers one-shot, state-aware, attached, streaming, cancellation, timeout, error, panic, and abandoned-handle paths.
  • Enforces live consent and administrative-policy authorization.
  • Adds typed JSON consent-maintenance requests and retains the read-only status CLI.
  • Persists lifecycle correlation across separate state-aware invocations.
  • Registers the WINEXT provider contract and required privacy metadata.
  • Adds unit, schema, smoke, ETW, and end-to-end coverage.

This is PR 3 of 5 and depends on the consent/policy foundation in PR 2.

Stack

OrderChangePR
1Normative privacy and telemetry documentation#818
2Consent and policy foundation#819
3Stable config and executor integration#820
4Rust SDK and C ABI#821
5Node.js and .NET SDKs#822

Review only this PR's diff; prerequisite behavior is in the PR above.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

This comment was marked as outdated.

Comment threadschemas/dev/mxc-telemetry-consent.schema.1.json Outdated
Comment threadsrc/core/wxc_common/src/config_parser.rs
Comment threadschemas/dev/mxc-config.schema.0.9.0-dev.json

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.

:shipit:

CopilotAI balanced review requested due to automatic review settings August 13, 2026 04:06
@RamonArjona4
RamonArjona4 requested a review from a teamAugust 13, 2026 04:06

This comment was marked as outdated.

CopilotAI review requested due to automatic review settings August 13, 2026 05:28

This comment was marked as outdated.

Comment threadsrc/core/mxc_engine/src/lib.rs
Comment threadsrc/core/wxc_common/src/telemetry/consent_cli.rs Outdated
Comment threadsrc/core/mxc_engine/src/lib.rs
Comment threadsrc/core/wxc_common/src/telemetry/consent_cli.rs Outdated
Comment threadsrc/core/wxc_common/src/telemetry/mod.rs Outdated
Comment threadsrc/core/mxc_engine/src/lib.rs Outdated
Comment threadsrc/core/mxc_engine/src/state_aware.rs Outdated
Comment threadsrc/core/mxc_engine/src/state_aware.rs Outdated
CopilotAI review requested due to automatic review settings August 18, 2026 18:50
@RamonArjona4
RamonArjona4force-pushed the user/ramonarjona4/telemetry-03-runtime branch from d297b29 to b1e1b8bCompareAugust 18, 2026 18:50

This comment was marked as outdated.

CopilotAI review requested due to automatic review settings August 18, 2026 19:04
Keep state-aware envelopes isolated from diagnostic output and align timeout and non-zero exit classification with one-shot telemetry.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208

CopilotAI 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

Two moderate telemetry correctness and coverage issues remain unresolved.

Review details

Suppressed comments (3)

Previously missed (2) — in code that hasn't changed since the last review.

src/core/mxc_engine/src/state_aware.rs:363

  • Telemetry is initialized only after exec_attached_gate, so a valid telemetry-enabled exec request made from redirected/non-terminal stdio returns malformed_request without the promised failure Execution/Error events (or telemetry-init warnings). Initialize telemetry/correlation before this gate and emit the gate failure through the state-aware telemetry path before returning.
    src/core/wxc_common/src/config_parser.rs:804
  • None means two different things here: omitted containment on a one-shot request (which correctly defaults to process) and an unrecognized/malformed sandboxId prefix on a non-provision state-aware request. In the latter case, telemetry-enabled dispatch failures are therefore recorded as mxc.sandbox_kind=process even though the caller did not request process containment. Preserve the context or use unknown for failed state-aware inference so error telemetry is not misattributed.

docs/telemetry/telemetry.md:206

  • This replaces the caller-visible correlation-vector contract with an internal identifier, but it never names the ETW field that consumers actually receive. Both MXC.Execution and MXC.Error emit this value as the string field __TlgCV__; documenting that name here (or in both event tables) is necessary for the event contract to be usable and auditable.
- An MXC-internal lifecycle correlation identifier. SDK callers neither supply
nor receive it.
  • Files reviewed: 89/92 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Validate the presentation request and terminal failure emitted when a piped consent request reaches stdin EOF.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208

CopilotAI 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

Provider registration is not unwind-safe, and consent override ownership validation remains unresolved.

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

Review details

Suppressed comments (2)

src/core/mxc_engine/src/state_aware.rs:363

  • This attached path also holds a successful provider registration only in a bool. If warning surfacing, backend resolution, correlation setup, or run_state_aware panics and the library caller catches the unwind, the provider reference leaks because the explicit emitter is never reached. Use the same RAII registration owner as the streaming path, disarming it after the terminal emitter releases the reference.
    src/core/mxc_engine/src/state_aware.rs:445
  • A successful initialization is not unwind-safe here: any panic before emit_sdk_state_aware_with_kind leaves the reference count incremented. Since these engine APIs can be embedded in a long-lived host that catches panics, this can keep ETW registered indefinitely and make subsequent library unloading unsafe. Own the registration with an RAII guard and disarm it only after the explicit terminal emission.
  • Files reviewed: 89/92 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment threadsrc/core/mxc_engine/src/lib.rs
Comment threadsrc/core/mxc_engine/src/state_aware.rs
Comment threadsrc/core/wxc_common/src/telemetry/consent.rs Outdated
Comment threaddocs/telemetry/telemetry-consent-design.md Outdated
Comment threaddocs/telemetry/telemetry-consent-design.md Outdated
@jsidewhite

Copy link
Copy Markdown
Member

// Copyright (c) Microsoft Corporation.

revert please


In reply to: 5515676524


Refers to: src/core/lxc/src/main.rs:1 in 4169b06. [](commit_id = 4169b06, deletion_comment = False)

@jsidewhite

Copy link
Copy Markdown
Member

// Copyright (c) Microsoft Corporation.

rvert


In reply to: 5515680362


Refers to: src/core/mxc_darwin/src/main.rs:1 in 4169b06. [](commit_id = 4169b06, deletion_comment = False)

Co-authored-by: RamonArjona4 <25335379+RamonArjona4@users.noreply.github.com>
Comment threadsrc/core/wxc_common/src/config_parser.rs

CopilotAI 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

A moderate terminal cleanup defect remains within broad cross-platform lifecycle changes.

Review details

Suppressed comments (3)

Previously missed (1) — in code that hasn't changed since the last review.

src/core/wxc_common/src/telemetry/mod.rs:319

  • This terminal path skips shutdown() when live consent/policy was withdrawn, and it also leaves the terminal slot unclaimed. The provider reference therefore remains registered, and a later panic can emit for an already-completed invocation if authorization is restored. Claim the terminal slot independently of authorization, emit only when authorized, and always release the provider reference.

This issue also appears in the following locations of the same file:

  • line 426
  • line 930

src/core/wxc_common/src/telemetry/mod.rs:430

  • As in the completion path, authorization withdrawal returns before shutdown() and before claiming the terminal slot. This leaks the registration reference and allows a later out-of-band event to represent an invocation that has already terminated. Always claim the slot and release the provider, while gating only the event writes on live authorization.
    src/core/wxc_common/src/telemetry/mod.rs:934
  • A live consent/policy change to deny collection makes this return without releasing the provider reference or consuming the process terminal slot. That breaks the balanced provider lifecycle and can permit a later panic/cancellation event after this phase already finished. Keep authorization around the writes only; terminal bookkeeping and shutdown() must still run.
  • Files reviewed: 89/92 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Remove the remaining consent command documentation and the non-Windows consent CLI and parsing refactors, while retaining the stable telemetry wiring required by the promoted runtime model.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208
Hold SDK telemetry registration with RAII until a streaming process wrapper takes ownership, and scope inherited consent-store overrides to direct child processes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208
Stamp and restore the consent-store override owner for direct executor children as well as ProcessStartInfo launches.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208
@RamonArjona4

Copy link
Copy Markdown
MemberAuthor

Addressed macOS file revert request: c4aa355 removes the consent CLI and parsing refactors; only the stable telemetry promotion wiring remains.

@RamonArjona4

Copy link
Copy Markdown
MemberAuthor

Confirmed the repeated LXC revert request is addressed by c4aa355.

@RamonArjona4

Copy link
Copy Markdown
MemberAuthor

Addressed schema-codegen removal request: PR #820 has no changes to scripts/versioning/check-schema-codegen.js.

@RamonArjona4

Copy link
Copy Markdown
MemberAuthor

Addressed LXC file revert request: c4aa355 removes the consent CLI and parsing refactors; only the stable telemetry promotion wiring remains.

@RamonArjona4

Copy link
Copy Markdown
MemberAuthor

Confirmed the repeated macOS revert request is addressed by c4aa355.

CopilotAI 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

The public Node version-default documentation is incorrect, and the Rust telemetry opt-in remains undocumented.

Review details

Suppressed comments (2)

sdk/node/src/state-aware-types.ts:170

  • Adding telemetry changes the omitted-version default to 0.9.0-alpha, but the adjacent public JSDoc still promises 0.8.0-alpha. This will mislead WSLc callers; document the conditional default here, as the implementation does in buildStateAwareEnvelope.
 telemetry?: TelemetryConfig;

src/core/mxc_engine/src/policy.rs:706

  • This adds a public Rust SDK opt-in (SandboxRequest is re-exported by mxc-sdk), but the crate README and top-level usage example still do not mention how telemetry is enabled or that consent and policy are additional gates. The repository requires Rust SDK API changes to update the crate docs/README, so please document this method in src/core/mxc-sdk/README.md (and preferably show it in the crate-level usage docs).
  • Files reviewed: 88/91 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208

CopilotAI 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

Moderate issues remain in Node versioning documentation and Windows dry-run telemetry behavior.

Review details

Suppressed comments (3)

Previously missed (1) — in code that hasn't changed since the last review.

src/core/wxc/src/main.rs:1341

  • --dry-run is documented as parsing and validating without execution, but this emits an Execution completion event before handle_dry_run_exit. Linux and macOS place this emission after their terminating dry-run branch, so Windows uniquely reports validation-only commands as executions. Move the emission below the dry-run branch.

docs/telemetry/telemetry.md:206

  • The new lifecycle identifier is emitted as __TlgCV__ on both MXC.Execution and MXC.Error, but neither event field table documents it. Add the field name, state-aware-only scope, and empty one-shot behavior to both tables so the documented event contract matches the provider payload.
- An MXC-internal lifecycle correlation identifier. SDK callers neither supply
nor receive it.

sdk/node/src/state-aware-types.ts:170

  • The public JSDoc immediately above still says an omitted WSLc version is always filled with 0.8.0-alpha, but adding telemetry makes buildStateAwareEnvelope select 0.9.0-alpha. Document this exception here so generated API docs do not contradict runtime behavior.
 telemetry?: TelemetryConfig;
  • Files reviewed: 88/91 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208

CopilotAI 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

Four moderate issues remain in API documentation, sandbox-kind attribution, consent isolation, and lifecycle correlation persistence.

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

Review details

Suppressed comments (1)

sdk/node/src/state-aware-types.ts:170

  • The preceding public JSDoc says an omitted WSLc version is always filled with 0.8.0-alpha, but adding this field changes the default to 0.9.0-alpha whenever telemetry is present. Document that conditional default here as the README already does, so generated API documentation does not mislead callers.
 telemetry?: TelemetryConfig;
  • Files reviewed: 88/91 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment on lines +1490 to +1493
let telemetry = cfg.telemetry.map(|raw| TelemetryConfig {
enabled: raw.enabled,
requested_sandbox_kind: Some(requested_sandbox_kind(cfg.containment.as_ref())),
});
Comment on lines +1447 to +1448
let owner = owner?.to_str()?.parse::<u32>().ok()?;
(Some(owner) == parent_process_id).then_some(path)
Comment on lines +110 to +114
fn phase_vector(sandbox_id: &str) -> String {
match with_store(|store| store.load_and_prune(sandbox_id)) {
Some(root) if is_relayable(&root) => spin(&root),
_ => seed(),
}
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208

CopilotAI 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

Unresolved provider-registration leaks on panic violate telemetry unload-safety guarantees.

Review details

Suppressed comments (2)

src/core/mxc_engine/src/state_aware.rs:363

  • The attached path also owns a bare provider reference after telemetry::init. A backend panic can unwind to an SDK/FFI catch boundary without reaching emit_sdk_state_aware_with_kind, leaking the registration and violating the documented unload-safety invariant. Wrap this reference in TelemetryRegistration and transfer it only when emitting the terminal event.
    src/core/mxc_engine/src/state_aware.rs:445
  • telemetry::init increments the process-wide ETW registration count, but this envelope path has no RAII owner. If run_state_aware (or warning injection/emission) panics and the library caller catches the unwind, shutdown is never called; subsequent calls retain a leaked reference, and unloading the FFI library can leave ETW callbacks pointing into unmapped code. Hold a TelemetryRegistration immediately after initialization and transfer it only to the terminal emitter, as the streaming path does.
  • Files reviewed: 88/91 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Resolve the telemetry and diagnostic overlap with PR #791 while preserving top-level telemetry consent, internal state-aware correlation, requested sandbox attribution, and the scoped ETW audit events.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e20d046-910e-4ee7-b8e8-acb0fe007208

CopilotAI 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 unresolved MS-CV boundary defect must be fixed before approval, and the stale telemetry documentation should be corrected.

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

Review details
  • Files reviewed: 89/92 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment on lines +45 to +46
/// Maximum wire length of a v2.1 vector before it must be terminated.
const MAX_LEN: usize = 128;
Comment on lines +183 to +185
> usernames, or credentials, so `MXC.Error` deliberately carries only bounded
> attribution fields, the `error_type` category, and the numeric `exit_code` —
> never the message string itself.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Copilot-InstructionsPR modifies Copilot instruction files (.github/copilot-instructions.md or .github/instructions/)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@RamonArjona4@jsidewhite@wezell@MGudgin@bbonaby