Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
## 2024-11-20 - JSON Decoding Performance - Index Advancement
**Learning:** Even when avoiding string slicing using `json.JSONDecoder().raw_decode(text, index)`, failing to correctly advance the index by ignoring the returned `end` index (`value, _ = decoder.raw_decode(...)`) forces the search loop to repeatedly attempt to decode nested JSON structures (e.g., inner braces `{`) sequentially. This leads to massive O(N^2) time complexity and redundant parsing for large, deeply nested JSON objects.
**Action:** Always capture and use the new end index returned by `raw_decode` (e.g., `value, next_idx = decoder.raw_decode(text, index)`) to jump over the completely parsed object and proceed efficiently.
## 2024-12-06 - gh api subprocess I/O latency optimization
**Learning:** Sequential execution of subprocesses making network calls (e.g., `gh api`) inside loops causes significant O(N) I/O wait latency, becoming a major performance bottleneck for scripts handling multiple items (e.g. iterating over pull requests).
**Action:** Always prefer using `concurrent.futures.ThreadPoolExecutor` to execute independent subprocess I/O calls concurrently. This allows parallel execution of I/O bound tasks and bypasses sequential waiting.
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ show_missing = true
[tool.interrogate]
exclude = ["tests"]
fail-under = 100

[project]
name = "opencode-review-ci"
version = "0.0.1"
requires-python = ">=3.10"
dependencies = []

[dependency-groups]
dev = [
"pytest>=8.0.0",
"pytest-cov>=5.0.0",
"interrogate>=1.7.0"
]
16 changes: 11 additions & 5 deletions scripts/ci/pr_review_merge_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import argparse
import concurrent.futures
import json
import os
import re
Expand Down Expand Up @@ -405,13 +406,18 @@ def fetch_rest_mergeable_state(repo: str, number: int) -> str:
return REST_MERGEABLE_STATE_MAP.get(raw_state.lower(), raw_state.upper())


def _fetch_and_enrich(repo: str, pr: dict[str, Any]) -> None:
"""Fetch REST mergeable state for a single PR and enrich the payload."""
try:
pr["restMergeableState"] = fetch_rest_mergeable_state(repo, int(pr["number"]))
except RuntimeError as exc:
pr["restMergeableStateError"] = bounded_error_summary(str(exc))

def enrich_rest_mergeable_states(repo: str, prs: list[dict[str, Any]]) -> None:
"""Attach REST mergeability evidence to GraphQL pull request payloads."""
for pr in prs:
try:
pr["restMergeableState"] = fetch_rest_mergeable_state(repo, int(pr["number"]))
except RuntimeError as exc:
pr["restMergeableStateError"] = bounded_error_summary(str(exc))
# ⚡ Bolt: Execute I/O bound gh api subprocess calls concurrently instead of sequentially
with concurrent.futures.ThreadPoolExecutor() as executor:
list(executor.map(lambda pr: _fetch_and_enrich(repo, pr), prs))


def effective_merge_state(pr: dict[str, Any]) -> str:
Expand Down
Loading
Loading