Skip to content

feat(decisioning): add registry observer removal#764

Open
sangilish wants to merge 1 commit into
adcontextprotocol:mainfrom
sangilish:feat/pg-registry-observer-lifecycle-696
Open

feat(decisioning): add registry observer removal#764
sangilish wants to merge 1 commit into
adcontextprotocol:mainfrom
sangilish:feat/pg-registry-observer-lifecycle-696

Conversation

@sangilish
Copy link
Copy Markdown

Summary

Refs #696.

This adds lifecycle management for PgBuyerAgentRegistry mutation observers. Observers can now be removed explicitly, and the observer registry is protected by a lock so add/remove operations do not race with mutation notification setup.

What changed

  • Added remove_mutation_observer(observer) -> bool.
  • Guarded mutation observer registration/removal with a threading.Lock.
  • Changed mutation notification to dispatch against a snapshot of observers, with callbacks still executed outside the lock.
  • Documented snapshot semantics for observers added or removed while a notification is in flight.
  • Added conformance coverage for unregistering observers and self-removal during notification.

Testing

  • uv run ruff check src/adcp/decisioning/pg/buyer_agent_registry.py tests/conformance/decisioning/test_pg_buyer_agent_registry.py
  • uv run mypy src/adcp/decisioning/pg/buyer_agent_registry.py
  • ADCP_PG_TEST_URL=postgresql://postgres:[email protected]:55432/postgres uv run python -m pytest tests/conformance/decisioning/test_pg_buyer_agent_registry.py -q

Note: uv run mypy src/adcp/decisioning/pg/buyer_agent_registry.py tests/conformance/decisioning/test_pg_buyer_agent_registry.py currently fails on the existing pytest.importorskip("psycopg_pool") typing pattern in the conformance test file, unrelated to this observer lifecycle change.

@sangilish sangilish marked this pull request as ready for review May 20, 2026 23:29
@sangilish
Copy link
Copy Markdown
Author

This is ready for review now. CI is green, and I kept the change scoped to #696: observer removal, thread-safe add/remove, and snapshot notification semantics.

@bokelley
Copy link
Copy Markdown
Contributor

Acknowledged — noted that CI is green and scope is contained to the observer lifecycle items from #696. Ready for human review.


Generated by Claude Code

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.

2 participants