Skip to content

[AAASM-5056] 🐛 (sdk): Export PolicyViolationError & OpTerminatedError#301

Merged
Chisanan232 merged 2 commits into
mainfrom
v0.0.1/AAASM-5056/fix/export_exceptions
Jul 24, 2026
Merged

[AAASM-5056] 🐛 (sdk): Export PolicyViolationError & OpTerminatedError#301
Chisanan232 merged 2 commits into
mainfrom
v0.0.1/AAASM-5056/fix/export_exceptions

Conversation

@Chisanan232

@Chisanan232 Chisanan232 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Description

agent_assembly.exceptions.PolicyViolationError and OpTerminatedError are documented across several docs pages as top-level imports, but they were never wired into agent_assembly/__init__.py's lazy-export tables (_LAZY_EXPORTS / _ALWAYS_EXPORTED / __all__). As a result the documented import raised ImportError at runtime:

$ python -c "from agent_assembly import PolicyViolationError"
ImportError: cannot import name 'PolicyViolationError' from 'agent_assembly'
# same for OpTerminatedError

Both classes already exist in agent_assembly.exceptions — only the package-level re-export was missing. This is the same defect class as AAASM-4987.

Fix: wire both symbols through the existing lazy-export machinery exactly like the sibling ToolExecutionBlockedError export — added to _LAZY_EXPORTS (mapping to agent_assembly.exceptions), _ALWAYS_EXPORTED (which feeds __all__), and the TYPE_CHECKING re-export block. No behavior change beyond making the documented import resolve.

After the fix:

$ uv run python -c "from agent_assembly import PolicyViolationError, OpTerminatedError; print('ok')"
ok

Type of Change

  • 🔧 Bug fix

Breaking Changes

  • No

Related Issues

Testing

  • Unit tests added/updated

Added a regression test in test/unit/test_exceptions.py asserting both classes import from the package top level, appear in __all__, and resolve to the same objects as in agent_assembly.exceptions.

  • Full suite: uv run pytest → 1208 passed, 15 skipped
  • uv run ruff check . clean
  • uv run mypy --ignore-missing-imports (as CI runs it) → No issues found

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated if needed
  • All tests passing

🤖 Generated with Claude Code

Chisanan232 and others added 2 commits July 24, 2026 19:03
Both classes exist in agent_assembly.exceptions and are documented across
several docs pages as top-level imports, but were absent from the __init__
lazy-export tables, so `from agent_assembly import PolicyViolationError`
(and OpTerminatedError) raised ImportError. Wire them through the lazy-export
machinery exactly like the sibling ToolExecutionBlockedError export.

Refs AAASM-5056

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

Regression test for AAASM-5056: asserts both classes import from the package
top level, appear in __all__, and resolve to the same objects as in
agent_assembly.exceptions.

Refs AAASM-5056

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

Copy link
Copy Markdown
Contributor Author

🔎 Claude Code review — evidence for maintainer

This is evidence only — not an approval, and not self-merged. Posting local verification so a Pioneer-team reviewer can make the merge decision.

Scope — 2 files, +21 lines, no deletions:

  • agent_assembly/__init__.py — added PolicyViolationError + OpTerminatedError to _LAZY_EXPORTS, _ALWAYS_EXPORTED (feeds __all__), and the TYPE_CHECKING re-export block, wired identically to the existing ToolExecutionBlockedError export.
  • test/unit/test_exceptions.py — regression test guarding both top-level exports.

Before → after (the reported defect):

# before (on remote/main):
$ python -c "from agent_assembly import PolicyViolationError"
ImportError: cannot import name 'PolicyViolationError' from 'agent_assembly'

# after (this branch):
$ uv run python -c "from agent_assembly import PolicyViolationError, OpTerminatedError; print('ok')"
ok

Local verification (all green):

  • uv run pytest1208 passed, 15 skipped (was 1206 + the 2 new tests)
  • uv run ruff check . → clean
  • uv run mypy --ignore-missing-imports (exact CI/pre-commit invocation) → No issues found
  • pre-commit hooks ran on both commits → all Passed
  • Branch is 0 commits behind remote/main.

Side effects: none. Both classes already existed in agent_assembly.exceptions; this only adds the package-level re-export that the docs already advertise. No runtime behavior change beyond making the documented import resolve. Same defect class as AAASM-4987.

Jira: https://lightning-dust-mite.atlassian.net/browse/AAASM-5056

@@ -1,5 +1,7 @@
from __future__ import annotations

import agent_assembly
@codecov

codecov Bot commented Jul 24, 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

Copy link
Copy Markdown
Contributor Author

✅ Claude Code review — READY (maintainer evidence)

  1. CI: 23p/0f — SonarCloud PASS, CodeCov (patch + unit/integration/contract finish) PASS; pytest 1208 pass, ruff + mypy (CI invocation) clean.
  2. Sonar/CodeCov: no issues.
  3. Scope (AAASM-5056): PolicyViolationError + OpTerminatedError wired through _LAZY_EXPORTS/_ALWAYS_EXPORTED/TYPE_CHECKING exactly like sibling ToolExecutionBlockedError; top-level import now resolves (repro before ImportError → after ok). Regression test added. Complete.
  4. Side-effects: none — additive exports only; no behavior change beyond making the documented import resolve.
  5. FE: none.

Verdict: scope-complete, MERGEABLE. Evidence only — not an approval, not self-merged.

@Chisanan232
Chisanan232 merged commit 34f173e into main Jul 24, 2026
30 checks passed
@Chisanan232
Chisanan232 deleted the v0.0.1/AAASM-5056/fix/export_exceptions branch July 24, 2026 12:17
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