fix(#508): pg-notify-listener alerts use PGUSER sender + self-safe recipients - #535
Merged
Conversation
added 2 commits
July 27, 2026 18:38
… self-safe recipients - Bind send_agent_message sender to _agent_chat_env['PGUSER'] instead of hardcoded 'schema-sync'. - Prefix all alert messages with '[schema-sync]' for attribution. - Add shared _alert_recipients() helper that excludes the sending user from primary recipients and falls back to graybeard, then broadcast. This satisfies send_agent_message's session_user + self-address guards. - Keep alert helpers non-raising on any alert-path failure. - Update #399/#506 tests to assert PGUSER sender and prefix. - Add issue #508 test module covering sender binding, recipient strategy, bound-parameter shape, failure swallow, and end-to-end regression paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Root Cause
The previous implementation hardcoded
schema-syncas the message sender for PG-notify-listener alerts. However, thesend_agent_messagefunction enforces session user guards, causing the database to reject messages when the actual connecting PGUSER (such asnova) does not match the hardcoded sender.What Changed
PGUSERenvironment variable or defaults toschema-sync.[schema-sync]prefix to messages to clearly indicate the subsystem source._alert_recipientsstrategy to ensure recipients are filtered appropriately (e.g. self-safe).Test Plan / Results
INT-508-A,INT-508-B,INT-508-C, andINT-508-D.novacorrectly routes torecipients=['graybeard'].Evidence Links & Reference files
se-runs/se511-step3-test-design.mdse-runs/se511-step6-qa-desk-review.mdse-runs/se511-step7-staging-results.mdse-runs/se511-step8-qa-validation.mdse-runs/se511-step9-doc-audit.mdCloses #508
Files Modified
cognition/scripts/pg-notify-listener.py