Skip to content

fix(auth): reuse a process-wide wasmtime engine - #1294

Open
anastasia-nesterenko wants to merge 1 commit into
ci-integration-crash-diagnostics/schapmanfrom
anesterenko/ci-failure-fix
Open

fix(auth): reuse a process-wide wasmtime engine#1294
anastasia-nesterenko wants to merge 1 commit into
ci-integration-crash-diagnostics/schapmanfrom
anesterenko/ci-failure-fix

Conversation

@anastasia-nesterenko

@anastasia-nesterenko anastasia-nesterenko commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Auth-enabled test clients previously created a new wasmtime Engine for every OPAPolicy, repeatedly initializing native JIT and trap-handling resources until an xdist worker could terminate without a Python traceback. This change creates one lazy, thread-safe Engine per process and reuses it while each policy instance retains its own Store and evaluation state.

Changes

  • Add a thread-safe, lazily initialized process-wide wasmtime Engine.
  • Reuse the engine while each OPAPolicy continues to create its own Store, linker, module, and instance.
  • Remove the scoped-access-key xdist_group pin so the test runs through normal integration-test scheduling.
  • Retain integration coverage for valid and tampered access-key authentication.
  • Verify that revocation is listed as REVOKED and that the revoked token fails authentication and workspace access.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with documentation updates
  • Documentation only
  • Contributor tooling or automation
  • CI, build, or test infrastructure

Quality Gates

  • Tests added or updated for changed behavior
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification: this changes internal policy-engine resource management without changing user-visible or API behavior.

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Targeted validation:

  • uv run --frozen pytest -q services/core/auth/tests/integration/test_scoped_access_keys.py services/core/auth/tests/test_embedded_pdp.py services/core/auth/tests/test_embedded_pdp_stress.py -m "not slow" — 80 passed, 4 deselected.
  • uv run --frozen ruff check services/core/auth/src/nmp/core/auth/app/embedded_pdp/engine.py services/core/auth/tests/integration/test_scoped_access_keys.py — passed.
  • uv run --frozen ruff format --check services/core/auth/src/nmp/core/auth/app/embedded_pdp/engine.py services/core/auth/tests/integration/test_scoped_access_keys.py — passed.
  • uv run --frozen ty check services/core/auth/src/nmp/core/auth/app/embedded_pdp/engine.py services/core/auth/tests/integration/test_scoped_access_keys.py — passed.
  • uv run --frozen pytest -q services/core/auth/tests/integration/test_scoped_access_keys.py — 1 passed; covers REVOKED status and rejection of the revoked token by auth and workspace endpoints.
  • uv run --frozen pre-commit run -a — relevant Ruff, formatting, type-checking, config, and repository checks passed; the full gate was blocked because helm-docs is not installed and the host uv version is 0.9.18 instead of the required 0.9.14.
  • GitHub Actions run 31754381754 — CI evidence for this change.

@anastasia-nesterenko
anastasia-nesterenko requested review from a team as code owners August 13, 2026 20:08
@github-actions github-actions Bot added the fix label Aug 13, 2026
@SandyChapman
SandyChapman force-pushed the ci-integration-crash-diagnostics/schapman branch from 1fa2bd8 to 1f9ebbb Compare August 13, 2026 20:36
@anastasia-nesterenko
anastasia-nesterenko marked this pull request as draft August 13, 2026 20:36
@SandyChapman
SandyChapman force-pushed the ci-integration-crash-diagnostics/schapman branch 2 times, most recently from 12e77da to cfe8bc7 Compare August 13, 2026 21:53
@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/ci-failure-fix branch from 891a8a4 to d85ec35 Compare August 13, 2026 22:39
@anastasia-nesterenko anastasia-nesterenko changed the title fix(auth): drop the wasmtime policy singleton on service shutdown fix(auth): reuse a process-wide wasmtime engine Aug 13, 2026
Create the wasmtime Engine lazily once per process and reuse it across OPAPolicy instances. This avoids repeatedly initializing JIT and trap-handling state as auth-enabled test clients come and go, which caused native xdist worker crashes without Python tracebacks.

Remove the obsolete scoped-access-key worker pin while retaining coverage that revoked keys are reported as REVOKED and rejected by authentication and workspace endpoints.

Signed-off-by: anastasia-nesterenko <anesterenko@nvidia.com>
@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/ci-failure-fix branch from 7e004ee to 25eb353 Compare August 13, 2026 23:11
@anastasia-nesterenko
anastasia-nesterenko marked this pull request as ready for review August 13, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant