Events: stamp who caused them, so the loop guards can fire - #27
Open
nishanthvonteddu wants to merge 1 commit into
Open
nishanthvonteddu wants to merge 1 commit into
nishanthvonteddu wants to merge 1 commit into
Conversation
`EventEnvelope.actor` is read by both self-trigger guards and defaults to
None. No producer ever set it: not cron_event, not webhook_event, not
gmail_pubsub_event, and not the channel-message route.
Both guards test the field first and admit when it is empty:
if actor and actor in self.self_actors: # governor
return bool(actor) and actor in subscription.ignore_actors # engine
So `S16_SELF_ACTORS` and every subscription's `ignore_actors` were
unreachable, and the self-sustaining loop they exist to refuse -- an agent
answering on a channel it also watches -- had nothing standing in its way.
The guards have unit tests, but those build envelopes by hand with `actor=`
already set, so the mechanism was proven and the wiring never was.
Producers now stamp it: the sending identity for a channel message, the
watched mailbox for a Gmail push, the schedule for a cron tick, the source
for a webhook, each overridable by the caller.
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.
Both self-trigger guards read
EventEnvelope.actor. No producer ever set it, so both were unreachable.What breaks
actordefaults toNone, and every guard short-circuits on empty:I grepped the whole package:
cron_event,webhook_event,gmail_pubsub_eventand the channel-message route all leave it unset. SoS16_SELF_ACTORSand every subscription’signore_actorsdid nothing, and the loop the README warns about — an agent answering on a channel it also watches, seeing its own reply arrive as a new event — had nothing standing in its way.Why it survived
The guards are tested — but the tests build envelopes by hand:
The mechanism was proven. The wiring never was.
The fix
Each producer stamps the field, overridable by the caller:
"{channel}:{channel_user_id}"— the sender"gmail:{emailAddress}"— the watched mailbox"cron.{schedule_id}"Test
test_channel_event_records_who_sent_itposts a real channel message and asserts the stored envelope names its sender. Fails before, passes after.