brainiac-github 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cb6c5132e15d851261b150a636b895a0d8d8f6487b51a5049290a1ce2f12274
4
- data.tar.gz: c6bf867e0bb5dbca4008e0971dc0568fb95755c2b296b7865e889e2d09645120
3
+ metadata.gz: 4646b834b308b619a34c5b94da48aeb88b80caa3fb5efd107ac40a5dc56da2a0
4
+ data.tar.gz: af0c3f9c0b47e366928760c64168a74eb3651f87c193156cbced75336626bac0
5
5
  SHA512:
6
- metadata.gz: ed2481547416f7bd7d0194aff3ec96da00811c6fe2a4ee8478b4f90c63820fde0318e7ea2427ba07646bd5755abcba3ac2a3c32af78170abb6eebb461f54a4dc
7
- data.tar.gz: 3df84f31506b7fbeeaf7636f84b8d8602a9e6fee9d6d8a6a4b18b4f5b76a9de666df79e5c2dccb9c81d1f90727bc8ffd60cc8b784776ea8f55ef0385e3234791
6
+ metadata.gz: 945f7fad37cd33a37d755b6517faa8638c4a351d74f11edb60bf8299d04933837f38b34e1fa39afaea34af2b2d57c89f5b88d641fb6e6001436622928143d445
7
+ data.tar.gz: 5c2e27ab69d9af292ddbd3c7ac299629f1b97c005b85275bdaaa31d24b010903a75b4973d6d91cf99ab5ea580c53c67c77e341724f46c633a2628d2a78ad6c67
@@ -126,6 +126,16 @@ module Brainiac
126
126
  repo_name = payload.dig("repository", "full_name")
127
127
  review_state = review["state"]
128
128
  reviewer = review.dig("user", "login")
129
+ reviewer_type = review.dig("user", "type")
130
+
131
+ # If the review was submitted by a remote agent bot, ignore — the other machine handles it.
132
+ if reviewer_type == "Bot"
133
+ reviewing_agent = agent_name_from_bot_login(reviewer)
134
+ if reviewing_agent && !local_agent_names.include?(reviewing_agent)
135
+ LOG.info "[GitHub] Ignoring review from remote agent bot #{reviewer} (agent: #{reviewing_agent}) on PR ##{pr_number}"
136
+ return [200, { status: "ignored", reason: "remote agent bot review" }.to_json]
137
+ end
138
+ end
129
139
 
130
140
  # If the PR was opened by a remote agent bot (not local to this machine),
131
141
  # skip dispatch — the other machine that owns the agent will handle it.
@@ -236,12 +246,12 @@ module Brainiac
236
246
  agent_name = mentioned
237
247
  end
238
248
 
239
- # Ignore comments from this project's own bot to prevent self-triggering.
240
- # Cross-agent bot comments (e.g. GLaDOS commenting on Galen's PR) are still processed.
241
- if comment_user_type == "Bot" && own_bot_comment?(comment_user, agent_name)
242
- LOG.info "Ignoring self-triggered bot comment from #{comment_user} (agent: #{agent_name})"
243
- return [200, { status: "ignored", reason: "self-triggered bot comment" }.to_json]
244
- end
249
+ # Ignore comments from agent bots that shouldn't trigger dispatch on this machine:
250
+ # 1. Self-triggered: bot matches the dispatching agent (prevents loops)
251
+ # 2. Remote agent: bot matches a known agent that isn't local (other machine handles it)
252
+ # Cross-agent LOCAL bot comments (e.g. GLaDOS commenting on Galen's PR) are still processed.
253
+ bot_ignore_reason = bot_comment_ignore_reason(comment_user, comment_user_type, agent_name, pr_number)
254
+ return bot_ignore_reason if bot_ignore_reason
245
255
 
246
256
  branch = fetch_pr_branch(repo_name, pr_number, agent_name, project_config)
247
257
  result = find_work_item_by_branch(branch)
@@ -494,6 +504,30 @@ module Brainiac
494
504
  nil
495
505
  end
496
506
 
507
+ # Determine if a bot comment should be ignored by this machine.
508
+ # Returns a Rack response array if the comment should be ignored, or nil if it should be processed.
509
+ #
510
+ # Ignores:
511
+ # 1. Self-triggered: bot matches the dispatching agent (prevents loops)
512
+ # 2. Remote agent: bot matches a known agent that isn't local (other machine handles it)
513
+ # Allows: cross-agent LOCAL bot comments (e.g. GLaDOS commenting on Galen's PR)
514
+ def bot_comment_ignore_reason(comment_user, comment_user_type, agent_name, pr_number)
515
+ return nil unless comment_user_type == "Bot"
516
+
517
+ if own_bot_comment?(comment_user, agent_name)
518
+ LOG.info "Ignoring self-triggered bot comment from #{comment_user} (agent: #{agent_name})"
519
+ return [200, { status: "ignored", reason: "self-triggered bot comment" }.to_json]
520
+ end
521
+
522
+ commenting_agent = agent_name_from_bot_login(comment_user)
523
+ if commenting_agent && !local_agent_names.include?(commenting_agent)
524
+ LOG.info "[GitHub] Ignoring comment from remote agent bot #{comment_user} (agent: #{commenting_agent}) on PR ##{pr_number}"
525
+ return [200, { status: "ignored", reason: "remote agent bot comment" }.to_json]
526
+ end
527
+
528
+ nil
529
+ end
530
+
497
531
  # Check if a bot comment is from the same agent that would handle this PR.
498
532
  # e.g. "galen-brainiac[bot]" is a self-trigger for agent "Galen",
499
533
  # but "glados-brainiac[bot]" is a cross-agent request and should be processed.
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Github
6
- VERSION = "0.2.4"
6
+ VERSION = "0.2.5"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainiac-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis