Skip to content

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

Open
Chisanan232 wants to merge 8 commits into
masterfrom
v0.0.1/AAASM-2641/refactor/align_exports
Open

[AAASM-2641] ♻️ (python-sdk): Align _core exports + native tests to the thin shim#80
Chisanan232 wants to merge 8 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

Bump the aa-core / aa-proto git-SHA pin to the agent-assembly master
commit that ships aa-sdk-client, and add aa-sdk-client itself at the
same SHA (single workspace checkout per ADR 0002). The next commit
delegates the runtime client to it.

Handle the new aa-proto ActionType::ToolResult variant in the
audit-event translation helpers, which the new SHA requires.
Make the pyo3 binding a thin shim over the shared aa-sdk-client crate
(ADR 0002). RuntimeClient.connect/send_event/close now delegate to
aa_sdk_client::AssemblyClient — the UDS transport, IPC wire codec, and
background lifecycle live once in aa-sdk-client instead of being
reimplemented here. Remove the local tokio worker loop, frame codec, and
the synchronous query_policy round-trip (PolicyResult / PolicyTimeoutError):
policy and approval are server-side per the trust model, and the advisory,
non-authoritative credential preflight is provided transitively by
aa-sdk-client — the shim holds no security authority.

Type translation (GovernanceEvent, audit_event_to/from_wire_bytes) is
retained. Drop the now-unused tokio and once_cell dependencies.
@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!

aa-sdk-client ships events over a bounded channel with a blocking send,
so under backpressure report_event can park the calling thread. Holding
the GIL there stalls every other Python thread — and deadlocks outright
when the runtime peer is an in-process Python thread (the native test's
mock runtime). Wrap the delegation in py.detach so the GIL is released
for the duration of the send.
…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.
@Chisanan232 Chisanan232 force-pushed the v0.0.1/AAASM-2641/refactor/align_exports branch from ddaa6c3 to 407ba1e Compare June 5, 2026 19:52
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.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 5, 2026

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