Skip to content

Emit captureDenials JSON output (replacement for #701) - #710

Merged
Richie Gomez (richiemsft) merged 9 commits into
mainfrom
user/saulg/learning-mode-output-replacement
Aug 3, 2026
Merged

Richie Gomez (richiemsft) merged 9 commits into
mainfrom
user/saulg/learning-mode-output-replacement

Conversation

@richiemsft

@richiemsft Richie Gomez (richiemsft) commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Replacement for #701, restoring the intended output-layer review boundary
following replacement analysis PR #709.

Adds the caller-facing captureDenials output layer:

  • Decodes the sealed ETL and writes one JSON document containing denials and
    summary.
  • Generates unique per-run internal ETL and JSON paths.
  • Returns the output path and summary as structured teardown metadata instead
    of writing from the backend to process-global stderr.
  • Prints the structured pointer only at the wxc-exec CLI boundary, while the
    Rust SDK, C ABI, and C# SDK expose the metadata programmatically.
  • Bounds ETL analysis to 10,000 unique denials and 1,000,000 processed events,
    stopping ProcessTrace and reporting truncation when either limit is reached.
  • Uses the DenialAnalyzer abstraction at the output integration seam, with
    deterministic success, empty-result, decode-failure, and ETL-cleanup tests.
  • Removes incomplete output files on write failure and propagates pointer JSON
    serialization errors instead of emitting an empty-path fallback.
  • Resolves well-known capability SIDs to policy names and falls back to custom
    SID strings.

PR #709 has merged. This PR targets main directly and now contains only the
output layer.

🔗 References

🔍 Validation

  • cargo fmt --all -- --check
  • cargo test -p learning_mode_core -p learning_mode_windows -p appcontainer_common -p mxc-sdk -p mxc_ffi --all-targets
  • cargo test -p wxc --no-run
  • cargo test -p wxc_e2e_tests --no-run
  • cargo clippy -p learning_mode_windows -p appcontainer_common -p mxc-sdk -p mxc_ffi --all-targets -- -D warnings
  • dotnet build sdk/dotnet/Microsoft.Mxc.Sdk/Microsoft.Mxc.Sdk.csproj --no-restore
  • Feature-enabled V1 Windows VM (172.17.7.153):
    • wxc-exec produced a valid JSON document and printed one matching pointer
      line at the CLI boundary.
    • An in-process mxc_engine run returned the same structured metadata while
      leaving host stderr empty.

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task

GitHub Actions runs the PR validation build automatically. The ADO pipeline
(MXC-PR-Build) is the Azure version of the PR pipeline, kept in parity with
the GitHub Actions build; it runs on merge to main, and Microsoft reviewers
with write access can trigger it on a PR with /azp run. See
docs/pull-requests.md.

If the dependency-feed-check check fails on a new dependency, the crate must
be added to the feed before the PR can pass. See
docs/pull-requests.md
for the steps.

@richiemsft
Richie Gomez (richiemsft) requested a review from a team as a code owner July 30, 2026 05:39
@azure-pipelines

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

@richiemsft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@richiemsft
Richie Gomez (richiemsft) force-pushed the user/saulg/learning-mode-output-replacement branch from abde3da to 359d785 Compare July 30, 2026 18:41

@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.

Adversarial review findings for the captureDenials JSON output layer.

Comment thread src/core/learning_mode_core/src/emit.rs Resolved
@richiemsft
Richie Gomez (richiemsft) force-pushed the user/saulg/learning-mode-output-replacement branch from 359d785 to 956db58 Compare July 31, 2026 19:47
@richiemsft
Richie Gomez (richiemsft) force-pushed the user/saulg/learning-mode-analyze-replacement branch from f5c0f96 to e8cb988 Compare July 31, 2026 20:04
@richiemsft
Richie Gomez (richiemsft) force-pushed the user/saulg/learning-mode-output-replacement branch from 13d211b to 53682ad Compare July 31, 2026 20:04
@richiemsft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@richiemsft
Richie Gomez (richiemsft) force-pushed the user/saulg/learning-mode-analyze-replacement branch 3 times, most recently from e8cb988 to 4491606 Compare August 1, 2026 02:05
@richiemsft
Richie Gomez (richiemsft) force-pushed the user/saulg/learning-mode-output-replacement branch from 53682ad to f9b365e Compare August 1, 2026 02:05
@richiemsft
Richie Gomez (richiemsft) changed the base branch from user/saulg/learning-mode-analyze-replacement to main August 1, 2026 02:06
@richiemsft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

…pability resolution (PR5)

Finalize the captureDenials deliverable as a single JSON document
({ "denials": [...], "summary": {...} }) that the launching app reads,
replacing the NDJSON frame stream. wxc-exec seals the internal ETL,
decodes it, writes the JSON file, and prints only the file-path pointer
on stderr.

Improvements:
- PID-stamped output filename: the wxc-exec pid is inserted into the
  caller's outputPath stem (denials.json -> denials.<pid>.json) so
  concurrent app instances don't collide; the real path is echoed in the
  stderr pointer (insert_pid_into_stem).
- Rename DeniedResource.path -> resource, inclusive of file paths AND
  AppContainer capabilities.
- Resolve capability identity: event-28 PackageSid/UserSid now decode via
  a new capability_names resolver (well-known S-1-15-3-1..12 SID -> policy
  name, else the SID string). Fix TDH_INTYPE_SID to 19 (was 22) so SID
  fields decode instead of rendering <unsupported>.

Remove learning_mode_core::frame (NDJSON) in favor of the JSON document
emitter. Regenerate dev schema + SDK wire types (description-only). Update
schema.md, capabilities.md, and copilot-instructions.md. All changes
VM-validated on a learning-mode-enabled Windows build.

Co-authored-by: Copilot <[email protected]>
Stream denial JSON directly, remove incomplete output files after write failures, prevent output collisions, and correct the capture mode and generated filename documentation.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: dfea4d42-e8a5-42ef-978a-6434e8bf89ec
Preserve polling exit codes, propagate internal ETL cleanup failures, and make pointer plus secondary teardown diagnostics safe when stderr is unavailable.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: dfea4d42-e8a5-42ef-978a-6434e8bf89ec
Delete the randomized JSON deliverable when stderr pointer publication fails, preserving both publication and cleanup errors so callers are not left with undiscoverable files.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: dfea4d42-e8a5-42ef-978a-6434e8bf89ec
Update the PR5 resource-field assertion retained while restacking onto the canonical path decoder change.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: dfea4d42-e8a5-42ef-978a-6434e8bf89ec
Route capture output through structured metadata, bound ETL processing, inject the analyzer seam, and expose metadata through the Rust and C# SDK surfaces.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3a8860a9-bb20-48ef-91a1-3da8e34b92fb
Update repository architecture guidance for bounded denial analysis and CLI-versus-SDK metadata publication.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3a8860a9-bb20-48ef-91a1-3da8e34b92fb
Apply rustfmt after reconciling the stacked Learning Mode branches.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3a8860a9-bb20-48ef-91a1-3da8e34b92fb
Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3a8860a9-bb20-48ef-91a1-3da8e34b92fb
@richiemsft
Richie Gomez (richiemsft) force-pushed the user/saulg/learning-mode-output-replacement branch from 4e58688 to 89f229e Compare August 3, 2026 17:25
@richiemsft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@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.

merge conflict resolution fixes

@richiemsft
Richie Gomez (richiemsft) merged commit 80cd261 into main Aug 3, 2026
40 checks passed
@richiemsft
Richie Gomez (richiemsft) deleted the user/saulg/learning-mode-output-replacement branch August 3, 2026 18:17
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