Skip to content

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

Open
richiemsft wants to merge 5 commits into
user/saulg/learning-mode-analyze-replacementfrom
user/saulg/learning-mode-output-replacement
Open

Emit captureDenials JSON output (replacement for #701)#710
richiemsft wants to merge 5 commits into
user/saulg/learning-mode-analyze-replacementfrom
user/saulg/learning-mode-output-replacement

Conversation

@richiemsft

@richiemsft richiemsft commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

📖 Description

Replacement for #701, which was mistakenly marked merged when the stacked parent branch temporarily received child-stack history during a stack-handling mistake. This PR restores the intended output-layer review boundary on top of replacement analysis PR #709.

Adds the caller-facing denial output layer:

  • Decodes the internal sealed ETL and writes one JSON document containing denials and summary.
  • Emits a structured captureDenials pointer line on stderr so callers can locate the actual deliverable.
  • Generates unique per-run internal ETL and JSON paths using the process id plus a random suffix.
  • Propagates sealing, decode, output, cleanup, and pointer-publication failures through wait().
  • Resolves well-known capability SIDs to policy names and falls back to custom SID strings.
  • Removes incomplete or unpublished JSON files when output publication fails.

This PR is intentionally stacked on #709 and should merge after #696 and #709.

🔗 References

🔍 Validation

  • cargo fmt --all -- --check
  • cargo test -p learning_mode_core -p learning_mode_windows -p appcontainer_common
  • cargo clippy -p learning_mode_core -p learning_mode_windows -p appcontainer_common --all-targets -- -D warnings
  • Prior feature-enabled Windows VM validation covered both block and allow JSON output flows.

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

Microsoft Reviewers: Open in CodeFlow

@richiemsft
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 and others added 5 commits July 30, 2026 11:41
…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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>

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 <223556219+Copilot@users.noreply.github.com>

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 <223556219+Copilot@users.noreply.github.com>

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 <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dfea4d42-e8a5-42ef-978a-6434e8bf89ec
@richiemsft
richiemsft force-pushed the user/saulg/learning-mode-output-replacement branch from abde3da to 359d785 Compare July 30, 2026 18:41
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.

1 participant