Skip to content

[AAASM-3435] ✅ (python-sdk): Gate native-core-absent test guards#148

Merged
Chisanan232 merged 2 commits into
masterfrom
v0.0.1/AAASM-3435/native_core_test_guards
Jun 19, 2026
Merged

[AAASM-3435] ✅ (python-sdk): Gate native-core-absent test guards#148
Chisanan232 merged 2 commits into
masterfrom
v0.0.1/AAASM-3435/native_core_test_guards

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

Description

Three unit tests assumed the native PyO3 _core extension is absent (CI's pure-Python matrix). When _core IS built, they failed:

  • test_init_assembly_enforcement_mode_forwarded_to_client[enforce] — monkeypatched adapters/network but not the AAASM-3402 native registration, so enforce fired a real gRPC registration → fail-closed → ConfigurationError.
  • test_to_wire_bytes_raises_helpful_import_error_without_native_core / test_from_wire_bytes_... — asserted an ImportError that only occurs when _core is absent (with _core present the wire codec runs).

This PR makes the three tests pass regardless of whether _core is importable. Test-only changes; no product code touched.

  • Gated the two wire-codec import-error tests with @pytest.mark.skipif(_native_core_available(), ...) (reusing the codebase's own agent_assembly.core.runtime_interceptor._native_core_available detector) so they only assert the import-error path when _core is genuinely absent.
  • Stubbed the native path in the enforce-mode test (monkeypatch.setattr(core_assembly, "_native_core_available", lambda: False)) so it still asserts enforcement-mode forwarding to the client without performing a live gateway connect.

Type of Change

  • 🔧 Bug fix

Breaking Changes

  • No

Related Issues

  • Related JIRA ticket: AAASM-3435

Testing

  • Unit tests added/updated

Reproduced with maturin develop (native _core present) on macOS:

  • Before: the 3 tests FAILED (gRPC endpoint unreachable for registration; DID NOT RAISE ImportError; invalid tag value: 0).
  • After: test/unit/test_assembly.py test/unit/test_types_audit_event.py39 passed, 2 skipped (the 3 target tests now pass: enforce-mode forwards for all 3 modes; the two wire-codec guards correctly skip when _core is present). The skipif path still asserts the import-error behavior when _core is absent. ruff format, mypy, and pre-commit run --all-files clean on touched files.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • All tests passing

Closes AAASM-3435

🤖 Generated with Claude Code

Chisanan232 and others added 2 commits June 19, 2026 14:35
The to_wire_bytes / from_wire_bytes import-error guards only fire in
pure-Python mode where the native _core extension is absent. Skip them
when _core is present so they pass on both CI matrices (AAASM-3435).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
With _core present, enforce mode triggered the AAASM-3402 native gRPC
registration which fails-closed without a live gateway. Force the
pure-Python path so the test only asserts enforcement-mode forwarding,
regardless of whether _core is built (AAASM-3435).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@Chisanan232 Chisanan232 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code — PR review (AAASM-3435)

Verdict: ✅ ready to merge. CI green; test-only (2 files), no product code touched.

  • Reuses the codebase's own _native_core_available detector — correct, no new ad-hoc probing. ✅
  • Wire-codec import-error tests now skipif(_native_core_available()) — they only assert the ImportError path when _core is genuinely absent. ✅
  • Enforce-mode forwarding test stubs _native_core_available → False so it verifies enforcement-mode forwarding without firing the AAASM-3402 native gRPC registration (which fail-closes without a live gateway). ✅
  • Verified RED-before / GREEN-after with _core built: 39 passed, 2 (correctly) skipped.

Pre-existing ARG002/ARG005 ruff warnings on test_assembly.py are from the existing mock pattern on master, not introduced here. Good to merge.

@Chisanan232 Chisanan232 merged commit b7cfed2 into master Jun 19, 2026
20 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-3435/native_core_test_guards branch June 19, 2026 07:57
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