Skip to content

[PERF]: execute XPIA injection handle activation concurrently - #165

Open
prudhvi (apocalypse9949) wants to merge 4 commits into
microsoft:mainfrom
apocalypse9949:XPIA
Open

[PERF]: execute XPIA injection handle activation concurrently#165
prudhvi (apocalypse9949) wants to merge 4 commits into
microsoft:mainfrom
apocalypse9949:XPIA

Conversation

@apocalypse9949

@apocalypse9949 prudhvi (apocalypse9949) commented Aug 13, 2026

Copy link
Copy Markdown

This PR introduces two improvements to RAMPART:

  • Improves XPIA attack setup performance by initializing injection handles concurrently.
  • Preserves trial_groups metadata in test run reports and JSON output.

Performance: Concurrent XPIA Handle Initialization

XPIAExecution._activate_handles_async previously initialized injection handles sequentially. For attacks involving multiple injection surfaces, this caused independent asynchronous setup operations to execute serially.

This change uses asyncio.TaskGroup to initialize the handles concurrently, allowing independent setup operations such as remote file uploads to proceed in parallel.

Impact

Local testing showed approximately 45% lower activation time for multi-surface scenarios compared with the sequential implementation.

Exception and cancellation behavior is preserved. ExceptionGroup handling is explicitly unwrapped so framework-level InfrastructureError behavior remains consistent with the existing execution model.

Reporting: Preserve trial_groups

@pytest.mark.trial already produces trial-level statistical information for terminal reporting, but this metadata was not preserved when generating JSON reports.

As a result, downstream consumers received the individual test results but had to independently reconstruct trial-level statistics.

This PR adds trial_groups to TestRunReport and propagates the metadata through RampartSession to JsonFileReportSink.

JSON consumers can now access the same trial-group information directly from the generated report.

Testing

The following validation was performed:

  • uv run pytest tests -v — passed
  • uv run pre-commit run --all-files — passed
  • Added unit coverage for trial_groups propagation and JSON serialization
  • Added local concurrency testing to validate parallel XPIA handle initialization
  • Verified existing test behavior and exception handling remain unchanged

Files Changed

  • rampart/attacks/_xpia.py

    • Initialize XPIA injection handles concurrently using asyncio.TaskGroup.
  • rampart/reporting/sink.py

    • Add trial_groups to TestRunReport.
  • rampart/pytest_plugin/_session.py

    • Propagate trial-group metadata into generated test reports.
  • rampart/reporting/json_file.py

    • Include trial_groups in JSON serialization.
  • tests/unit/reporting/test_json_file.py

    • Add coverage for trial_groups JSON output.
  • tests/unit/reporting/test_report.py

    • Add coverage for report metadata.

Also includes feature addition for exposing trial group aggregation metadata to json reports.
Also includes feature addition for exposing trial group aggregation metadata to json reports.
Also includes feature addition for exposing trial group aggregation metadata to json reports.
@azure-pipelines

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

@apocalypse9949
prudhvi (apocalypse9949) requested a review from a team August 13, 2026 14:24
@apocalypse9949

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@apocalypse9949 prudhvi (apocalypse9949) changed the title perf: execute XPIA injection handle activation concurrently [PERF]: execute XPIA injection handle activation concurrently Aug 13, 2026

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.

Thanks for the suggestions, prudhvi (@apocalypse9949). I will still leave this open for comment from others 😄

Comment thread rampart/attacks/_xpia.py
Comment thread rampart/pytest_plugin/_session.py Outdated
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