Skip to content

Propagate PolicyEngine request IDs to the simulation service - #3782

Merged
anth-volk merged 3 commits into
masterfrom
fix/simulation-request-id-propagation
Jul 30, 2026
Merged

Propagate PolicyEngine request IDs to the simulation service#3782
anth-volk merged 3 commits into
masterfrom
fix/simulation-request-id-propagation

Conversation

@anth-volk

Copy link
Copy Markdown
Collaborator

Fixes #3781

Summary

  • standardize API v1 request correlation on X-PolicyEngine-Request-Id
  • share request IDs safely between the ASGI shell and mounted Flask application
  • forward the active request ID through one HTTPX request hook to every simulation gateway request
  • add regression coverage for supplied/generated IDs, alias rejection, context isolation, both simulation entrypoints, and calls outside request contexts

Root cause

API v1 used X-Request-ID, while the simulation observability stack reads X-PolicyEngine-Request-Id. Flask and ASGI also had separate request-ID handling, and the shared simulation client did not forward request-scoped correlation metadata.

Impact

Synchronous API v1, Simulation Entrypoint, and Modal gateway requests can now share one observability-supported request ID. Job and batch IDs remain unchanged for asynchronous execution correlation. This PR does not change routing, URLs, authentication, secrets, workflows, or API schemas.

Tests

  • 15 focused request-ID tests passed
  • 91 affected migration logging, ASGI, and simulation-client tests passed (one unrelated heavyweight application-import test excluded locally)
  • 190 simulation contract, economy, budget-window, and deployment tests passed
  • migration quality guards passed; generated migration contracts were unchanged
  • Ruff formatting and changed-code lint passed
  • towncrier draft and Python compilation passed
  • Cloud Run Docker image build passed

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.67442% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.84%. Comparing base (c435b46) to head (fe7f66e).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
policyengine_api/migration_logging.py 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3782      +/-   ##
==========================================
+ Coverage   80.71%   80.84%   +0.13%     
==========================================
  Files          74       75       +1     
  Lines        4422     4448      +26     
  Branches      822      825       +3     
==========================================
+ Hits         3569     3596      +27     
+ Misses        623      622       -1     
  Partials      230      230              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anth-volk
anth-volk marked this pull request as ready for review July 30, 2026 19:42
@anth-volk
anth-volk merged commit 8a189d6 into master Jul 30, 2026
10 checks passed
@anth-volk
anth-volk deleted the fix/simulation-request-id-propagation branch July 30, 2026 19:54
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.

Propagate PolicyEngine request IDs to the simulation service

1 participant