Skip to content

EventGate: rule changes via add/removePolicy skip the state cleanup a reload does, and removing a debounce rule delivers during quiesce #390

Closed

Description

@Anarchid

Two related gaps in src/gate/event-gate.ts (main), found together.

1. add/remove skip the reload's diff. An operator edits gate.json (e.g. a rate limit tokens: 100 → 5, or deletes a debounce rule), then a wake_add_rule/wake_remove_rule/addGatePolicy lands before the throttled reload applies the edit. The change reads the edited file, adds or removes its rule, and installs the result through writeConfig, which swaps in the rules but never compares them with those in force. The old bucket keeps 100 tokens until it drains, sampler counters carry over, and a removed debounce rule's timer stays armed. The reload's own cleanup comment names exactly this case. connectome-host's channel-mode module calls addGatePolicy itself, so the agent needn't be involved.

2. clearPolicyState delivers a pending batch even while quiesced or inferring. It calls this.deliverEvents(debounce.events) directly (~1278), whereas fireDebounce (~1514) buffers when inferring.size > 0 || quiesced; its comment says delivering while quiesced "would write a '[Gate: N events]' message into the very context being operated on mid-surgery". clearPolicyState is reached from reloadIfChanged, removePolicy and wake_remove_rule, none of which check.

How found. Review of #371 (review); (1) found independently by both reviewers. Neither reproduced; windows are narrow.

Suggested fixes. (1) After a successful write in addPolicy/removePolicy, run the same removed/changed-behaviour diff as reloadIfChanged. (2) Route clearPolicyState's delivery through fireDebounce's buffered path.

Posted by the maintainer's desk assistant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions