Skip to content

feat(decisioning): add registry observer removal#764

Closed
sangilish wants to merge 3 commits into
adcontextprotocol:mainfrom
sangilish:feat/pg-registry-observer-lifecycle-696
Closed

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

Conversation

@sangilish
Copy link
Copy Markdown
Contributor

@sangilish sangilish commented May 20, 2026

Summary

Closes #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:pg@127.0.0.1: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
Contributor 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

@bokelley
Copy link
Copy Markdown
Contributor

Local spot-check from triage: the implementation is still narrowly scoped to #696. python3 -m ruff check src/adcp/decisioning/pg/buyer_agent_registry.py tests/conformance/decisioning/test_pg_buyer_agent_registry.py passes. The targeted pytest file skipped locally because this workspace does not have the Postgres conformance fixture available, so I am relying on CI for the DB-backed run. Recommendation: ready for human review/merge once the required review gate is satisfied.

@bokelley
Copy link
Copy Markdown
Contributor

Thanks @bokelley — acknowledged. Spot-check noted: ruff passes, DB-backed conformance test deferred to CI. No action needed from me; standing by for the required review gate to clear.


Generated by Claude Code

Copy link
Copy Markdown
Contributor

@bokelley bokelley left a comment

Choose a reason for hiding this comment

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

Reviewed the scoped observer lifecycle change and current green CI. Snapshot notification semantics and thread-safe add/remove behavior look appropriate for #696.

@bokelley bokelley enabled auto-merge (squash) May 26, 2026 00:44
@bokelley
Copy link
Copy Markdown
Contributor

Superseded by #861, which mirrors this reviewed change onto a repo-owned branch so the required base-repo checks can run. #861 has merged.

@bokelley bokelley closed this May 26, 2026
auto-merge was automatically disabled May 26, 2026 01:28

Pull request was closed

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.

feat(buyer-agent-registry): observer lifecycle — remove_mutation_observer + thread-safe registry

2 participants