brainiac-basecamp 0.0.14 → 0.0.15

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: 14642b9582bda42dff7932fe0b518957bdeb638431de432df6beae906c3206e5
4
- data.tar.gz: 2fac38d27c6c89445d49af1b8e3148bcfa25d8d6632de11984fca1dbd772dcf2
3
+ metadata.gz: e8e71f8f043a52cb54d83e974031b0bb83339f02452e701bf381e4e87b32274d
4
+ data.tar.gz: ac57b522a30cdb3cdf42c0aca069c52bb1ce27b2b93fdbdf4b63a2c9f57088b9
5
5
  SHA512:
6
- metadata.gz: f1c4b21c180b3a8306770e922c8c4c8bdb65976a1a62f9dbe02541cb4049d635ac4745f469275ad13bd1168811148cb772965e0b64e4d5b0fdac9b0eb4b7c200
7
- data.tar.gz: 7a063d983c097531096ff5d8f954050842f0b775f136f6ec1694111ab0bd9561f061b859e33a9497a7b69b8ed7e3a1aa0725d7c70895556e83789920fedc1f72
6
+ metadata.gz: 955cfcffe81b1856b0ee90e8c2124b48d13b3de28db1e258054069442b8a67096deeb95cda1b5ce0e21b20cd2b78e3bd7c73fd107c5753c3de82ef0ead916d01
7
+ data.tar.gz: 7b6e92a54b136065013d178d3422bc7583958f83b161184c9905b2d950898907ee1eebdffa6d2cf07bc7394836b98aef52acd8bb50583231b2b6b8f2f9ca3247
@@ -16,7 +16,7 @@ module Brainiac
16
16
  # :resolve_base_branch — returns epic branch as worktree base
17
17
  # :resolve_pr_target — returns epic branch as PR target
18
18
  module Hooks
19
- class << self
19
+ class << self # rubocop:disable Metrics/ClassLength
20
20
  def register_all!
21
21
  register_agent_completed
22
22
  register_pr_merged
@@ -380,14 +380,39 @@ module Brainiac
380
380
  next unless epic["review_gate"] == "epic_branch" && ReviewGate.enabled?
381
381
 
382
382
  task = epic["tasks"].find { |t| t["fizzy_card"] == card_number.to_i }
383
- # Re-trigger gates if task is in_flight (agent working/pushed fixes)
384
- # No need to check for prior reviews — if task is in_flight with a PR, gates should review
385
- next unless task && task["status"] == "in_flight" && task["pr_number"]
383
+ next unless task && task["status"] == "in_flight"
384
+
385
+ # Ensure pr_number is set it may be missing if initial gate dispatch
386
+ # failed to persist it or if state was lost during serialization.
387
+ unless task["pr_number"]
388
+ pr_number = ctx.dig(:pull_request, "number") || ctx[:pr_number]
389
+ if pr_number
390
+ task["pr_number"] = pr_number.to_i
391
+ LOG.info "[Basecamp:Hooks] Backfilled pr_number=#{pr_number} for card ##{card_number}" if defined?(LOG)
392
+ else
393
+ # Try to find it from the branch
394
+ project_key = task["project"] || Config.brainiac_project_for(epic["basecamp_project_id"])
395
+ projects_file = File.join(ENV.fetch("BRAINIAC_DIR", File.join(Dir.home, ".brainiac")), "projects.json")
396
+ projects = File.exist?(projects_file) ? JSON.parse(File.read(projects_file)) : {}
397
+ repo_path = projects.dig(project_key, "repo_path")
398
+ if repo_path
399
+ branch = ctx[:branch] || "fizzy-#{card_number}-*"
400
+ found_pr = find_pr_number(repo_path: repo_path, branch: branch)
401
+ if found_pr
402
+ task["pr_number"] = found_pr
403
+ LOG.info "[Basecamp:Hooks] Resolved pr_number=#{found_pr} for card ##{card_number} via branch lookup" if defined?(LOG)
404
+ end
405
+ end
406
+ end
407
+ end
408
+
409
+ next unless task["pr_number"]
386
410
 
387
411
  LOG.info "[Basecamp:Hooks] PR updated for card ##{card_number} — re-triggering review gates" if defined?(LOG)
388
412
 
389
413
  # Reset approvals and re-dispatch gates
390
414
  ReviewGate.reset_approvals(task)
415
+ task["changes_requested_by"] = []
391
416
  task["status"] = "in_review"
392
417
  epic["updated_at"] = Time.now.iso8601
393
418
  save_epic_state(epic)
@@ -821,6 +846,21 @@ module Brainiac
821
846
  return
822
847
  end
823
848
 
849
+ # Ensure pr_number is set — look it up if missing.
850
+ # This is critical for the pr_synchronized hook to re-trigger gates after fixes.
851
+ unless pr_number
852
+ found_pr = find_pr_number(repo_path: repo_path, branch: "fizzy-#{card_number}-*")
853
+ if found_pr
854
+ pr_number = found_pr
855
+ task["pr_number"] = pr_number
856
+ task["pr_repo"] = project_config["github_repo"]
857
+ save_epic_state(epic)
858
+ LOG.info "[Basecamp:Hooks] Backfilled pr_number=#{pr_number} for card ##{card_number} during direct dispatch" if defined?(LOG)
859
+ elsif defined?(LOG)
860
+ LOG.warn "[Basecamp:Hooks] Could not find PR for card ##{card_number} — gates won't re-trigger after fixes"
861
+ end
862
+ end
863
+
824
864
  # Find the worktree for this card
825
865
  work_items_file = File.join(ENV.fetch("BRAINIAC_DIR", File.join(Dir.home, ".brainiac")), "work_items.json")
826
866
  worktree_path = repo_path # Default to main repo
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Basecamp
6
- VERSION = "0.0.14"
6
+ VERSION = "0.0.15"
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-basecamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis