Skip to content

[AAASM-2641] ♻️ (python-sdk): Align _core exports + native tests to the thin shim#80

Merged
Chisanan232 merged 5 commits into
masterfrom
v0.0.1/AAASM-2641/refactor/align_exports
Jun 6, 2026
Merged

[AAASM-2641] ♻️ (python-sdk): Align _core exports + native tests to the thin shim#80
Chisanan232 merged 5 commits into
masterfrom
v0.0.1/AAASM-2641/refactor/align_exports

Conversation

@Chisanan232
Copy link
Copy Markdown
Contributor

Description

Python-side alignment to the thin pyo3 shim (Story AAASM-2561). Stacked on #79 (AAASM-2640), which delegates the native RuntimeClient to aa-sdk-client and removes the native synchronous query_policy round-trip.

  • agent_assembly/__init__.py: drop PolicyResult / PolicyTimeoutError from the lazy export map, the optional-core __all__ list, and the TYPE_CHECKING block. The native _core surface is now RuntimeClient + GovernanceEvent.
  • test/unit/test_init_exports.py: stub _core exposes only RuntimeClient / GovernanceEvent; assert the dropped symbols are not in agent_assembly.__all__.
  • test/integration/test_native_core_runtime.py (opt-in, AAASM_RUN_NATIVE_CORE_TESTS=1): remove the query_policy timeout test and the query_policy call in the concurrency test; send_event / close still exercise the delegation. The mock runtime server keeps modelling the full wire protocol.
  • Docs: README import example, architecture overview (two _core symbols; RuntimeClient is a thin shim that ships events), and the exceptions reference no longer mention the removed symbols. (ADR 0001-hook-architecture.md is left as a historical record.)

Note (stacked PR): the diff shows #79's commits until that PR merges; this PR's own change is the Python/docs alignment above. Base branch is master per repo convention.

Type of Change

  • ♻️ Refactoring

Breaking Changes

  • Yes (please describe below)

agent_assembly.PolicyResult and agent_assembly.PolicyTimeoutError (native _core symbols) are removed. They had no pure-Python callers; documented policy checks use the httpx gateway client.

Related Issues

  • Related JIRA ticket: AAASM-2641 (Story AAASM-2561, Epic AAASM-2552)

Testing

  • uv sync + pytest green (418 passed, 10 skipped — native + optional-framework tests skip in a pure-Python install).
  • ruff / mypy introduce no new findings vs master (changes only remove code + edit Markdown).

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex logic
  • Documentation updated if needed
  • All tests passing

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Chisanan232
Copy link
Copy Markdown
Contributor Author

🤖 Claude Code — review result

CI: ✅ green (23 pass / 4 skip; unit + integration across macОS & Ubuntu, SonarCloud, codecov, benchmarks, PEP 561). BLOCKED is solely REVIEW_REQUIRED. Stacked on #79 — the diff shows #79's commits until it merges.

Scope vs AAASM-2641: ✅ complete — Python-side alignment to the thin shim.

  • agent_assembly/__init__.py: PolicyResult/PolicyTimeoutError removed from the lazy export map, _OPTIONAL_CORE, and the TYPE_CHECKING block. Native _core surface is now RuntimeClient + GovernanceEvent.
  • test_init_exports.py: now asserts the dropped symbols are absent from __all__ (positive guard, not just removal).
  • Gated test_native_core_runtime.py: query_policy cases removed; send_event/close delegation retained.
  • Docs (README / architecture / exceptions) no longer reference the removed symbols; ADR 0001 left as a historical record.
  • FFI benchmark fixed to use a valid aa_core::AuditEntry payload (c0972d1) — it previously errored whenever the native module was built (skipped in CI hid it). With the native module built locally: construction ≈ 13.6 µs, enqueue ≈ 41.7 µs (target < 2 ms).

Notes: the Story line "preserve the sdk_bench criterion benchmark" has no direct analog here — python-sdk/rust/aa-ffi-python has no [[bench]]; the pytest FFI benchmark is the equivalent and is preserved + fixed. The criterion bench likely refers to the monorepo binding (Story 9, AAASM-2562).

Verdict: ✅ Ready to approve & merge after #79 (rebase onto master once #79 lands).

…orts

The thin pyo3 shim (AAASM-2640) no longer exposes the synchronous policy
round-trip. Remove PolicyResult and PolicyTimeoutError from the lazy
export map, the optional-core __all__ list, and the TYPE_CHECKING block;
RuntimeClient and GovernanceEvent remain the native _core surface.
Drop the fake PolicyResult/PolicyTimeoutError from the stub _core module
and assert they are no longer in agent_assembly.__all__, while
RuntimeClient and GovernanceEvent still are.
The thin shim no longer exposes a synchronous policy round-trip. Remove
the query_policy timeout test and the query_policy call in the
concurrency/deadlock test; send_event and close still exercise the
delegation to aa-sdk-client. The mock runtime server keeps modelling the
full wire protocol.
The native _core module now exposes only RuntimeClient and
GovernanceEvent. Drop PolicyResult from the README import example, fix
the architecture overview (two symbols; RuntimeClient is a thin shim over
aa-sdk-client that ships events), and remove the stale PolicyTimeoutError
note from the exceptions reference.
GovernanceEvent deserializes its argument as an aa_core::AuditEntry, but
the FFI benchmark passed an ad-hoc {event_type, agent_id, ...} dict that
is not a valid AuditEntry, so the benchmark errored whenever the native
module was actually built (it is skipped in CI, which hid the bug). Use a
valid AuditEntry payload so the benchmark exercises the real FFI path.
@Chisanan232 Chisanan232 force-pushed the v0.0.1/AAASM-2641/refactor/align_exports branch from e195734 to 06037b5 Compare June 6, 2026 00:57
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 6, 2026

@Chisanan232 Chisanan232 merged commit 7a07b0c into master Jun 6, 2026
27 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-2641/refactor/align_exports branch June 6, 2026 01:03
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